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