1 This patch causes the --cvs-exclude option to prefix the names listed
2 in each dir's CVS/Entries file as per-dir includes before the dir's list
3 of excludes taken from the .cvsignore file.
5 To use this patch, run these commands for a successful build:
7 patch -p1 <patches/cvs-entries.diff
8 ./configure (optional if already run)
11 based-on: 3b8f8192227b14e708bf535072485e50f4362270
12 diff --git a/exclude.c b/exclude.c
15 @@ -267,6 +267,8 @@ static void add_rule(filter_rule_list *listp, const char *pat, unsigned int pat_
16 if (!(lp = new_array(filter_rule_list, 1)))
17 out_of_memory("add_rule");
18 lp->head = lp->tail = lp->parent_dirscan_head = NULL;
19 + if (mflags & MATCHFLG_CVS_IGNORE)
21 if (asprintf(&lp->debug_type, " [per-dir %s]", cp) < 0)
22 out_of_memory("add_rule");
23 rule->u.mergelist = lp;
24 @@ -526,6 +528,14 @@ void *push_local_filters(const char *dir, unsigned int dirlen)
25 set_filter_dir(dir, dirlen);
28 + if (ex->match_flags & MATCHFLG_CVS_IGNORE
29 + && strlcpy(dirbuf + dirbuf_len, "CVS/Entries",
30 + MAXPATHLEN - dirbuf_len) < MAXPATHLEN - dirbuf_len) {
31 + /* Start by adding include rules for all the names in CVS/Entries. */
32 + parse_filter_file(lp, dirbuf,
33 + MATCHFLG_NO_PREFIXES | MATCHFLG_INCLUDE,
36 if (strlcpy(dirbuf + dirbuf_len, ex->pattern,
37 MAXPATHLEN - dirbuf_len) < MAXPATHLEN - dirbuf_len) {
38 parse_filter_file(lp, dirbuf, ex,
39 @@ -1151,6 +1161,7 @@ void parse_filter_file(filter_rule_list *listp, const char *fname, const filter_
40 char line[BIGPATHBUFLEN];
41 char *eob = line + sizeof line - 1;
42 BOOL word_split = (template->rflags & FILTRULE_WORD_SPLIT) != 0;
43 + int slash_parse = xflags & XFLG_CVS_ENTRIES ? 1 : 0;
45 if (!fname || !*fname)
47 @@ -1197,6 +1208,24 @@ void parse_filter_file(filter_rule_list *listp, const char *fname, const filter_
51 + switch (slash_parse) { /* CVS/Entries parsing: */
52 + case 1: /* Ignore starting chars until first slash. */
56 + case 2: /* Name ends at 2nd slash on the line. */
62 + case 3: /* Ignore trailing chars until EOL. */
63 + if (ch == '\n' || ch == '\r') {
69 if (word_split && isspace(ch))
71 if (eol_nulls? !ch : (ch == '\n' || ch == '\r'))
72 @@ -1206,13 +1235,14 @@ void parse_filter_file(filter_rule_list *listp, const char *fname, const filter_
78 rprintf(FERROR, "discarding over-long filter: %s...\n", line);
82 /* Skip an empty token and (when line parsing) comments. */
83 - if (*line && (word_split || (*line != ';' && *line != '#')))
84 + if (*line && (word_split || slash_parse || (*line != ';' && *line != '#')))
85 parse_filter_str(listp, line, template, xflags);
88 diff --git a/rsync.h b/rsync.h
92 #define XFLG_ANCHORED2ABS (1<<2) /* leading slash indicates absolute */
93 #define XFLG_ABS_IF_SLASH (1<<3) /* leading or interior slash is absolute */
94 #define XFLG_DIR2WILD3 (1<<4) /* dir/ match gets trailing *** added */
95 +#define XFLG_CVS_ENTRIES (1<<5)
97 #define ATTRS_REPORT (1<<0)
98 #define ATTRS_SKIP_MTIME (1<<1)
99 diff --git a/testsuite/exclude.test b/testsuite/exclude.test
100 --- a/testsuite/exclude.test
101 +++ b/testsuite/exclude.test
102 @@ -19,6 +19,7 @@ export CVSIGNORE
104 makepath "$fromdir/foo/down/to/you"
105 makepath "$fromdir/foo/sub"
106 +makepath "$fromdir/bar/down/to/CVS"
107 makepath "$fromdir/bar/down/to/foo/too"
108 makepath "$fromdir/bar/down/to/bar/baz"
109 makepath "$fromdir/mid/for/foo/and/that/is/who"
110 @@ -57,6 +58,9 @@ echo cvsout >"$fromdir/bar/down/to/foo/file1.bak"
111 echo gone >"$fromdir/bar/down/to/foo/file3"
112 echo lost >"$fromdir/bar/down/to/foo/file4"
113 echo weird >"$fromdir/bar/down/to/foo/+ file3"
114 +echo cvsin >"$fromdir/bar/down/to/not.junk"
115 +echo cvsout >"$fromdir/bar/down/to/not.good"
116 +echo cvsout >"$fromdir/bar/down/to/D"
117 echo cvsout-but-filtin >"$fromdir/bar/down/to/foo/file4.junk"
118 echo smashed >"$fromdir/bar/down/to/foo/to"
119 cat >"$fromdir/bar/down/to/bar/.filt2" <<EOF
120 @@ -102,7 +106,18 @@ cat >"$excl" <<EOF
123 cat >"$scratchdir/.cvsignore" <<EOF
127 +cat >"$fromdir/bar/down/to/CVS/Entries" <<EOF
128 +/not.junk/1.1/Mon Jan 1 11:11:11 2001//
130 +/another.file/1.1/Tue Jan 1 22:22:22 2002//
131 +invalid lines should just be ignored...
135 +cat >"$fromdir/bar/down/to/.cvsignore" <<EOF
139 # Start with a check of --prune-empty-dirs:
140 @@ -136,6 +151,10 @@ checkit "$RSYNC -avv --exclude-from='$excl' \
141 # Modify the chk dir by removing cvs-ignored files and then tweaking the dir times.
143 rm "$chkdir"/foo/*.old
144 +rm "$chkdir"/bar/down/to/D
145 +rm "$chkdir"/bar/down/to/CVS/Entries
146 +rmdir "$chkdir"/bar/down/to/CVS
147 +rm "$chkdir"/bar/down/to/not.good
148 rm "$chkdir"/bar/down/to/foo/*.bak
149 rm "$chkdir"/bar/down/to/foo/*.junk
150 rm "$chkdir"/bar/down/to/home-cvs-exclude
151 @@ -151,8 +170,12 @@ checkit "$RSYNC -avvC --filter='merge $excl' --delete-excluded \
153 # Modify the chk dir for our merge-exclude test and then tweak the dir times.
155 +makepath "$chkdir/bar/down/to/CVS"
156 rm "$chkdir"/foo/file1
157 rm "$chkdir"/bar/down/to/bar/baz/*.deep
158 +cp_touch "$fromdir"/bar/down/to/D "$chkdir"/bar/down/to/D
159 +cp_touch "$fromdir"/bar/down/to/not.good "$chkdir"/bar/down/to/not.good
160 +cp_touch "$fromdir"/bar/down/to/CVS/Entries "$chkdir"/bar/down/to/CVS/Entries
161 cp_touch "$fromdir"/bar/down/to/foo/*.junk "$chkdir"/bar/down/to/foo
162 cp_touch "$fromdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo