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 | ||
edea1111 | 5 | --- orig/exclude.c 2005-10-14 18:45:50 |
cb0d2e2b | 6 | +++ exclude.c 2005-12-17 19:52:48 |
edea1111 | 7 | @@ -446,6 +446,14 @@ void *push_local_filters(const char *dir |
f891cd92 WD |
8 | set_filter_dir(dir, dirlen); |
9 | } | |
10 | ||
11 | + if (ex->match_flags & MATCHFLG_CVS_IGNORE | |
12 | + && strlcpy(dirbuf + dirbuf_len, "CVS/Entries", | |
13 | + MAXPATHLEN - dirbuf_len) < MAXPATHLEN - dirbuf_len) { | |
14 | + /* Start by adding include rules for all the names in CVS/Entries. */ | |
15 | + parse_filter_file(lp, dirbuf, | |
16 | + MATCHFLG_NO_PREFIXES | MATCHFLG_INCLUDE, | |
17 | + XFLG_CVS_ENTRIES); | |
18 | + } | |
19 | if (strlcpy(dirbuf + dirbuf_len, ex->pattern, | |
20 | MAXPATHLEN - dirbuf_len) < MAXPATHLEN - dirbuf_len) { | |
21 | parse_filter_file(lp, dirbuf, ex->match_flags, | |
edea1111 WD |
22 | @@ -962,6 +970,7 @@ void parse_filter_file(struct filter_lis |
23 | char line[BIGPATHBUFLEN]; | |
f891cd92 WD |
24 | char *eob = line + sizeof line - 1; |
25 | int word_split = mflags & MATCHFLG_WORD_SPLIT; | |
26 | + int slash_parse = xflags & XFLG_CVS_ENTRIES ? 1 : 0; | |
27 | ||
28 | if (!fname || !*fname) | |
29 | return; | |
cb0d2e2b | 30 | @@ -1006,6 +1015,24 @@ void parse_filter_file(struct filter_lis |
f891cd92 WD |
31 | continue; |
32 | break; | |
33 | } | |
cb0d2e2b WD |
34 | + switch (slash_parse) { /* CVS/Entries parsing: */ |
35 | + case 1: /* Ignore starting chars until first slash. */ | |
36 | + if (ch == '/') | |
f891cd92 | 37 | + slash_parse = 2; |
cb0d2e2b WD |
38 | + continue; |
39 | + case 2: /* Name ends at 2nd slash on the line. */ | |
f891cd92 WD |
40 | + if (ch == '/') { |
41 | + slash_parse = 3; | |
42 | + continue; | |
43 | + } | |
44 | + break; | |
cb0d2e2b | 45 | + case 3: /* Ignore trailing chars until EOL. */ |
f891cd92 WD |
46 | + if (ch == '\n' || ch == '\r') { |
47 | + slash_parse = 1; | |
cb0d2e2b | 48 | + goto end_the_line; |
f891cd92 WD |
49 | + } |
50 | + continue; | |
f891cd92 WD |
51 | + } |
52 | if (word_split && isspace(ch)) | |
53 | break; | |
54 | if (eol_nulls? !ch : (ch == '\n' || ch == '\r')) | |
cb0d2e2b | 55 | @@ -1015,13 +1042,15 @@ void parse_filter_file(struct filter_lis |
f891cd92 WD |
56 | else |
57 | overflow = 1; | |
58 | } | |
cb0d2e2b | 59 | + end_the_line: |
f891cd92 WD |
60 | if (overflow) { |
61 | rprintf(FERROR, "discarding over-long filter: %s...\n", line); | |
62 | s = line; | |
cb0d2e2b WD |
63 | } |
64 | *s = '\0'; | |
65 | /* Skip an empty token and (when line parsing) comments. */ | |
66 | - if (*line && (word_split || (*line != ';' && *line != '#'))) | |
67 | + if (*line && (word_split || slash_parse | |
68 | + || (*line != ';' && *line != '#'))) | |
69 | parse_rule(listp, line, mflags, xflags); | |
70 | if (ch == EOF) | |
71 | break; | |
72 | --- orig/rsync.h 2005-12-15 23:00:49 | |
73 | +++ rsync.h 2005-12-17 19:52:48 | |
edea1111 | 74 | @@ -116,6 +116,7 @@ |
f891cd92 WD |
75 | #define XFLG_OLD_PREFIXES (1<<1) |
76 | #define XFLG_ANCHORED2ABS (1<<2) | |
edea1111 WD |
77 | #define XFLG_ABS_IF_SLASH (1<<3) |
78 | +#define XFLG_CVS_ENTRIES (1<<4) | |
f891cd92 WD |
79 | |
80 | #define PERMS_REPORT (1<<0) | |
81 | #define PERMS_SKIP_MTIME (1<<1) | |
cb0d2e2b WD |
82 | --- orig/testsuite/exclude.test 2005-02-26 19:47:43 |
83 | +++ testsuite/exclude.test 2005-12-17 19:52:49 | |
84 | @@ -21,6 +21,7 @@ set -x | |
85 | # Build some files/dirs/links to copy | |
86 | ||
87 | makepath "$fromdir/foo/down/to/you" | |
88 | +makepath "$fromdir/bar/down/to/CVS" | |
89 | makepath "$fromdir/bar/down/to/foo/too" | |
90 | makepath "$fromdir/bar/down/to/bar/baz" | |
91 | makepath "$fromdir/mid/for/foo/and/that/is/who" | |
92 | @@ -56,6 +57,9 @@ echo cvsout >"$fromdir/bar/down/to/foo/f | |
93 | echo gone >"$fromdir/bar/down/to/foo/file3" | |
94 | echo lost >"$fromdir/bar/down/to/foo/file4" | |
95 | echo weird >"$fromdir/bar/down/to/foo/+ file3" | |
96 | +echo cvsin >"$fromdir/bar/down/to/not.junk" | |
97 | +echo cvsout >"$fromdir/bar/down/to/not.good" | |
98 | +echo cvsout >"$fromdir/bar/down/to/D" | |
99 | echo cvsout-but-filtin >"$fromdir/bar/down/to/foo/file4.junk" | |
100 | echo smashed >"$fromdir/bar/down/to/foo/to" | |
101 | cat >"$fromdir/bar/down/to/bar/.filt2" <<EOF | |
102 | @@ -98,7 +102,18 @@ cat >"$excl" <<EOF | |
103 | EOF | |
104 | ||
105 | cat >"$scratchdir/.cvsignore" <<EOF | |
106 | -home-cvs-exclude | |
107 | +home-cvs-exclude D | |
108 | +EOF | |
109 | +cat >"$fromdir/bar/down/to/CVS/Entries" <<EOF | |
110 | +/not.junk/1.1/Mon Jan 1 11:11:11 2001// | |
111 | +filt2 | |
112 | +/another.file/1.1/Tue Jan 1 22:22:22 2002// | |
113 | +invalid lines should just be ignored... | |
114 | +D/directory//// | |
115 | +D | |
116 | +EOF | |
117 | +cat >"$fromdir/bar/down/to/.cvsignore" <<EOF | |
118 | +not.good | |
119 | EOF | |
120 | ||
121 | # Create the chk dir with what we expect to be excluded | |
122 | @@ -125,6 +140,10 @@ checkit "$RSYNC -avv --exclude-from=\"$e | |
123 | # Modify the chk dir by removing cvs-ignored files and then tweaking the dir times. | |
124 | ||
125 | rm "$chkdir"/foo/*.old | |
126 | +rm "$chkdir"/bar/down/to/D | |
127 | +rm "$chkdir"/bar/down/to/CVS/Entries | |
128 | +rmdir "$chkdir"/bar/down/to/CVS | |
129 | +rm "$chkdir"/bar/down/to/not.good | |
130 | rm "$chkdir"/bar/down/to/foo/*.bak | |
131 | rm "$chkdir"/bar/down/to/foo/*.junk | |
132 | rm "$chkdir"/bar/down/to/home-cvs-exclude | |
133 | @@ -140,8 +159,12 @@ checkit "$RSYNC -avvC --filter=\"merge $ | |
134 | ||
135 | # Modify the chk dir for our merge-exclude test and then tweak the dir times. | |
136 | ||
137 | +makepath "$chkdir/bar/down/to/CVS" | |
138 | rm "$chkdir"/foo/file1 | |
139 | rm "$chkdir"/bar/down/to/bar/baz/*.deep | |
140 | +cp -p "$fromdir"/bar/down/to/D "$chkdir"/bar/down/to/D | |
141 | +cp -p "$fromdir"/bar/down/to/not.good "$chkdir"/bar/down/to/not.good | |
142 | +cp -p "$fromdir"/bar/down/to/CVS/Entries "$chkdir"/bar/down/to/CVS/Entries | |
143 | cp -p "$fromdir"/bar/down/to/foo/*.junk "$chkdir"/bar/down/to/foo | |
144 | cp -p "$fromdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo | |
145 |