Use "use warnings" rather than -w on the #! line.
[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
03019e41
WD
5To 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
WD
11diff --git a/exclude.c b/exclude.c
12--- a/exclude.c
13+++ b/exclude.c
c0c7984e 14@@ -239,6 +239,8 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
e7636e55
WD
15 if (!(lp = new_array(struct filter_list_struct, 1)))
16 out_of_memory("add_rule");
17 lp->head = lp->tail = NULL;
18+ if (mflags & MATCHFLG_CVS_IGNORE)
19+ cp = "CVS";
20 if (asprintf(&lp->debug_type, " [per-dir %s]", cp) < 0)
21 out_of_memory("add_rule");
22 ret->u.mergelist = lp;
65ecbe35 23@@ -470,6 +472,14 @@ void *push_local_filters(const char *dir, unsigned int dirlen)
f891cd92
WD
24 set_filter_dir(dir, dirlen);
25 }
26
27+ if (ex->match_flags & MATCHFLG_CVS_IGNORE
28+ && strlcpy(dirbuf + dirbuf_len, "CVS/Entries",
29+ MAXPATHLEN - dirbuf_len) < MAXPATHLEN - dirbuf_len) {
30+ /* Start by adding include rules for all the names in CVS/Entries. */
31+ parse_filter_file(lp, dirbuf,
32+ MATCHFLG_NO_PREFIXES | MATCHFLG_INCLUDE,
33+ XFLG_CVS_ENTRIES);
34+ }
35 if (strlcpy(dirbuf + dirbuf_len, ex->pattern,
36 MAXPATHLEN - dirbuf_len) < MAXPATHLEN - dirbuf_len) {
37 parse_filter_file(lp, dirbuf, ex->match_flags,
65ecbe35 38@@ -1030,6 +1040,7 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname,
edea1111 39 char line[BIGPATHBUFLEN];
f891cd92
WD
40 char *eob = line + sizeof line - 1;
41 int word_split = mflags & MATCHFLG_WORD_SPLIT;
42+ int slash_parse = xflags & XFLG_CVS_ENTRIES ? 1 : 0;
43
44 if (!fname || !*fname)
45 return;
65ecbe35 46@@ -1076,6 +1087,24 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname,
4a65fe72 47 }
f891cd92
WD
48 break;
49 }
cb0d2e2b
WD
50+ switch (slash_parse) { /* CVS/Entries parsing: */
51+ case 1: /* Ignore starting chars until first slash. */
52+ if (ch == '/')
f891cd92 53+ slash_parse = 2;
cb0d2e2b
WD
54+ continue;
55+ case 2: /* Name ends at 2nd slash on the line. */
f891cd92
WD
56+ if (ch == '/') {
57+ slash_parse = 3;
58+ continue;
59+ }
60+ break;
cb0d2e2b 61+ case 3: /* Ignore trailing chars until EOL. */
f891cd92
WD
62+ if (ch == '\n' || ch == '\r') {
63+ slash_parse = 1;
cb0d2e2b 64+ goto end_the_line;
f891cd92
WD
65+ }
66+ continue;
f891cd92
WD
67+ }
68 if (word_split && isspace(ch))
69 break;
70 if (eol_nulls? !ch : (ch == '\n' || ch == '\r'))
65ecbe35 71@@ -1085,13 +1114,15 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname,
f891cd92
WD
72 else
73 overflow = 1;
74 }
cb0d2e2b 75+ end_the_line:
f891cd92
WD
76 if (overflow) {
77 rprintf(FERROR, "discarding over-long filter: %s...\n", line);
78 s = line;
cb0d2e2b
WD
79 }
80 *s = '\0';
81 /* Skip an empty token and (when line parsing) comments. */
82- if (*line && (word_split || (*line != ';' && *line != '#')))
83+ if (*line && (word_split || slash_parse
84+ || (*line != ';' && *line != '#')))
85 parse_rule(listp, line, mflags, xflags);
86 if (ch == EOF)
87 break;
cc3e685d
WD
88diff --git a/rsync.h b/rsync.h
89--- a/rsync.h
90+++ b/rsync.h
e8972101 91@@ -151,6 +151,7 @@
c0c7984e
WD
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)
f891cd92 96
4a65fe72
WD
97 #define ATTRS_REPORT (1<<0)
98 #define ATTRS_SKIP_MTIME (1<<1)
cc3e685d
WD
99diff --git a/testsuite/exclude.test b/testsuite/exclude.test
100--- a/testsuite/exclude.test
101+++ b/testsuite/exclude.test
9a7eef96 102@@ -19,6 +19,7 @@ export CVSIGNORE
cb0d2e2b
WD
103
104 makepath "$fromdir/foo/down/to/you"
ffadcb36 105 makepath "$fromdir/foo/sub"
cb0d2e2b
WD
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"
cc3e685d 110@@ -57,6 +58,9 @@ echo cvsout >"$fromdir/bar/down/to/foo/file1.bak"
cb0d2e2b
WD
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
cc3e685d 120@@ -102,7 +106,18 @@ cat >"$excl" <<EOF
cb0d2e2b
WD
121 EOF
122
123 cat >"$scratchdir/.cvsignore" <<EOF
124-home-cvs-exclude
125+home-cvs-exclude D
126+EOF
127+cat >"$fromdir/bar/down/to/CVS/Entries" <<EOF
128+/not.junk/1.1/Mon Jan 1 11:11:11 2001//
129+filt2
130+/another.file/1.1/Tue Jan 1 22:22:22 2002//
131+invalid lines should just be ignored...
132+D/directory////
133+D
134+EOF
135+cat >"$fromdir/bar/down/to/.cvsignore" <<EOF
136+not.good
137 EOF
138
cc3e685d
WD
139 # Start with a check of --prune-empty-dirs:
140@@ -136,6 +151,10 @@ checkit "$RSYNC -avv --exclude-from='$excl' \
cb0d2e2b
WD
141 # Modify the chk dir by removing cvs-ignored files and then tweaking the dir times.
142
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
cc3e685d 151@@ -151,8 +170,12 @@ checkit "$RSYNC -avvC --filter='merge $excl' --delete-excluded \
cb0d2e2b
WD
152
153 # Modify the chk dir for our merge-exclude test and then tweak the dir times.
154
155+makepath "$chkdir/bar/down/to/CVS"
156 rm "$chkdir"/foo/file1
157 rm "$chkdir"/bar/down/to/bar/baz/*.deep
7f0bf1cb
WD
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
cb0d2e2b 163