Commit | Line | Data |
---|---|---|
f891cd92 WD |
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. | |
4 | ||
03019e41 WD |
5 | To use this patch, run these commands for a successful build: |
6 | ||
7 | patch -p1 <patches/cvs-entries.diff | |
8 | ./configure (optional if already run) | |
9 | make | |
10 | ||
cc3e685d | 11 | diff --git a/exclude.c b/exclude.c |
fc557362 | 12 | index 5fa6e00..60e557d 100644 |
cc3e685d WD |
13 | --- a/exclude.c |
14 | +++ b/exclude.c | |
fc557362 | 15 | @@ -275,6 +275,8 @@ static void add_rule(struct filter_list_struct *listp, const char *pat, |
e7636e55 WD |
16 | if (!(lp = new_array(struct filter_list_struct, 1))) |
17 | out_of_memory("add_rule"); | |
fc557362 | 18 | lp->head = lp->tail = lp->parent_dirscan_head = NULL; |
e7636e55 WD |
19 | + if (mflags & MATCHFLG_CVS_IGNORE) |
20 | + cp = "CVS"; | |
21 | if (asprintf(&lp->debug_type, " [per-dir %s]", cp) < 0) | |
22 | out_of_memory("add_rule"); | |
23 | ret->u.mergelist = lp; | |
fc557362 | 24 | @@ -536,6 +538,14 @@ void *push_local_filters(const char *dir, unsigned int dirlen) |
f891cd92 WD |
25 | set_filter_dir(dir, dirlen); |
26 | } | |
27 | ||
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, | |
34 | + XFLG_CVS_ENTRIES); | |
35 | + } | |
36 | if (strlcpy(dirbuf + dirbuf_len, ex->pattern, | |
37 | MAXPATHLEN - dirbuf_len) < MAXPATHLEN - dirbuf_len) { | |
38 | parse_filter_file(lp, dirbuf, ex->match_flags, | |
fc557362 | 39 | @@ -1122,6 +1132,7 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname, |
edea1111 | 40 | char line[BIGPATHBUFLEN]; |
f891cd92 WD |
41 | char *eob = line + sizeof line - 1; |
42 | int word_split = mflags & MATCHFLG_WORD_SPLIT; | |
43 | + int slash_parse = xflags & XFLG_CVS_ENTRIES ? 1 : 0; | |
44 | ||
45 | if (!fname || !*fname) | |
46 | return; | |
fc557362 | 47 | @@ -1168,6 +1179,24 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname, |
4a65fe72 | 48 | } |
f891cd92 WD |
49 | break; |
50 | } | |
cb0d2e2b WD |
51 | + switch (slash_parse) { /* CVS/Entries parsing: */ |
52 | + case 1: /* Ignore starting chars until first slash. */ | |
53 | + if (ch == '/') | |
f891cd92 | 54 | + slash_parse = 2; |
cb0d2e2b WD |
55 | + continue; |
56 | + case 2: /* Name ends at 2nd slash on the line. */ | |
f891cd92 WD |
57 | + if (ch == '/') { |
58 | + slash_parse = 3; | |
59 | + continue; | |
60 | + } | |
61 | + break; | |
cb0d2e2b | 62 | + case 3: /* Ignore trailing chars until EOL. */ |
f891cd92 WD |
63 | + if (ch == '\n' || ch == '\r') { |
64 | + slash_parse = 1; | |
cb0d2e2b | 65 | + goto end_the_line; |
f891cd92 WD |
66 | + } |
67 | + continue; | |
f891cd92 WD |
68 | + } |
69 | if (word_split && isspace(ch)) | |
70 | break; | |
71 | if (eol_nulls? !ch : (ch == '\n' || ch == '\r')) | |
fc557362 | 72 | @@ -1177,13 +1206,15 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname, |
f891cd92 WD |
73 | else |
74 | overflow = 1; | |
75 | } | |
cb0d2e2b | 76 | + end_the_line: |
f891cd92 WD |
77 | if (overflow) { |
78 | rprintf(FERROR, "discarding over-long filter: %s...\n", line); | |
79 | s = line; | |
cb0d2e2b WD |
80 | } |
81 | *s = '\0'; | |
82 | /* Skip an empty token and (when line parsing) comments. */ | |
83 | - if (*line && (word_split || (*line != ';' && *line != '#'))) | |
84 | + if (*line && (word_split || slash_parse | |
85 | + || (*line != ';' && *line != '#'))) | |
86 | parse_rule(listp, line, mflags, xflags); | |
87 | if (ch == EOF) | |
88 | break; | |
cc3e685d | 89 | diff --git a/rsync.h b/rsync.h |
fc557362 | 90 | index be7cf8a..6605092 100644 |
cc3e685d WD |
91 | --- a/rsync.h |
92 | +++ b/rsync.h | |
fc557362 | 93 | @@ -152,6 +152,7 @@ |
c0c7984e WD |
94 | #define XFLG_ANCHORED2ABS (1<<2) /* leading slash indicates absolute */ |
95 | #define XFLG_ABS_IF_SLASH (1<<3) /* leading or interior slash is absolute */ | |
96 | #define XFLG_DIR2WILD3 (1<<4) /* dir/ match gets trailing *** added */ | |
97 | +#define XFLG_CVS_ENTRIES (1<<5) | |
f891cd92 | 98 | |
4a65fe72 WD |
99 | #define ATTRS_REPORT (1<<0) |
100 | #define ATTRS_SKIP_MTIME (1<<1) | |
cc3e685d | 101 | diff --git a/testsuite/exclude.test b/testsuite/exclude.test |
fc557362 | 102 | index 099344f..993edcc 100644 |
cc3e685d WD |
103 | --- a/testsuite/exclude.test |
104 | +++ b/testsuite/exclude.test | |
9a7eef96 | 105 | @@ -19,6 +19,7 @@ export CVSIGNORE |
cb0d2e2b WD |
106 | |
107 | makepath "$fromdir/foo/down/to/you" | |
ffadcb36 | 108 | makepath "$fromdir/foo/sub" |
cb0d2e2b WD |
109 | +makepath "$fromdir/bar/down/to/CVS" |
110 | makepath "$fromdir/bar/down/to/foo/too" | |
111 | makepath "$fromdir/bar/down/to/bar/baz" | |
112 | makepath "$fromdir/mid/for/foo/and/that/is/who" | |
cc3e685d | 113 | @@ -57,6 +58,9 @@ echo cvsout >"$fromdir/bar/down/to/foo/file1.bak" |
cb0d2e2b WD |
114 | echo gone >"$fromdir/bar/down/to/foo/file3" |
115 | echo lost >"$fromdir/bar/down/to/foo/file4" | |
116 | echo weird >"$fromdir/bar/down/to/foo/+ file3" | |
117 | +echo cvsin >"$fromdir/bar/down/to/not.junk" | |
118 | +echo cvsout >"$fromdir/bar/down/to/not.good" | |
119 | +echo cvsout >"$fromdir/bar/down/to/D" | |
120 | echo cvsout-but-filtin >"$fromdir/bar/down/to/foo/file4.junk" | |
121 | echo smashed >"$fromdir/bar/down/to/foo/to" | |
122 | cat >"$fromdir/bar/down/to/bar/.filt2" <<EOF | |
cc3e685d | 123 | @@ -102,7 +106,18 @@ cat >"$excl" <<EOF |
cb0d2e2b WD |
124 | EOF |
125 | ||
126 | cat >"$scratchdir/.cvsignore" <<EOF | |
127 | -home-cvs-exclude | |
128 | +home-cvs-exclude D | |
129 | +EOF | |
130 | +cat >"$fromdir/bar/down/to/CVS/Entries" <<EOF | |
131 | +/not.junk/1.1/Mon Jan 1 11:11:11 2001// | |
132 | +filt2 | |
133 | +/another.file/1.1/Tue Jan 1 22:22:22 2002// | |
134 | +invalid lines should just be ignored... | |
135 | +D/directory//// | |
136 | +D | |
137 | +EOF | |
138 | +cat >"$fromdir/bar/down/to/.cvsignore" <<EOF | |
139 | +not.good | |
140 | EOF | |
141 | ||
cc3e685d WD |
142 | # Start with a check of --prune-empty-dirs: |
143 | @@ -136,6 +151,10 @@ checkit "$RSYNC -avv --exclude-from='$excl' \ | |
cb0d2e2b WD |
144 | # Modify the chk dir by removing cvs-ignored files and then tweaking the dir times. |
145 | ||
146 | rm "$chkdir"/foo/*.old | |
147 | +rm "$chkdir"/bar/down/to/D | |
148 | +rm "$chkdir"/bar/down/to/CVS/Entries | |
149 | +rmdir "$chkdir"/bar/down/to/CVS | |
150 | +rm "$chkdir"/bar/down/to/not.good | |
151 | rm "$chkdir"/bar/down/to/foo/*.bak | |
152 | rm "$chkdir"/bar/down/to/foo/*.junk | |
153 | rm "$chkdir"/bar/down/to/home-cvs-exclude | |
cc3e685d | 154 | @@ -151,8 +170,12 @@ checkit "$RSYNC -avvC --filter='merge $excl' --delete-excluded \ |
cb0d2e2b WD |
155 | |
156 | # Modify the chk dir for our merge-exclude test and then tweak the dir times. | |
157 | ||
158 | +makepath "$chkdir/bar/down/to/CVS" | |
159 | rm "$chkdir"/foo/file1 | |
160 | rm "$chkdir"/bar/down/to/bar/baz/*.deep | |
7f0bf1cb WD |
161 | +cp_touch "$fromdir"/bar/down/to/D "$chkdir"/bar/down/to/D |
162 | +cp_touch "$fromdir"/bar/down/to/not.good "$chkdir"/bar/down/to/not.good | |
163 | +cp_touch "$fromdir"/bar/down/to/CVS/Entries "$chkdir"/bar/down/to/CVS/Entries | |
164 | cp_touch "$fromdir"/bar/down/to/foo/*.junk "$chkdir"/bar/down/to/foo | |
165 | cp_touch "$fromdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo | |
cb0d2e2b | 166 |