This patch causes the --cvs-exclude option to prefix the names listed in each dir's CVS/Entries file as per-dir includes before the dir's list of excludes taken from the .cvsignore file. To use this patch, run these commands for a successful build: patch -p1 head = lp->tail = NULL; + if (mflags & MATCHFLG_CVS_IGNORE) + cp = "CVS"; if (asprintf(&lp->debug_type, " [per-dir %s]", cp) < 0) out_of_memory("add_rule"); ret->u.mergelist = lp; @@ -449,6 +451,14 @@ void *push_local_filters(const char *dir set_filter_dir(dir, dirlen); } + if (ex->match_flags & MATCHFLG_CVS_IGNORE + && strlcpy(dirbuf + dirbuf_len, "CVS/Entries", + MAXPATHLEN - dirbuf_len) < MAXPATHLEN - dirbuf_len) { + /* Start by adding include rules for all the names in CVS/Entries. */ + parse_filter_file(lp, dirbuf, + MATCHFLG_NO_PREFIXES | MATCHFLG_INCLUDE, + XFLG_CVS_ENTRIES); + } if (strlcpy(dirbuf + dirbuf_len, ex->pattern, MAXPATHLEN - dirbuf_len) < MAXPATHLEN - dirbuf_len) { parse_filter_file(lp, dirbuf, ex->match_flags, @@ -1005,6 +1015,7 @@ void parse_filter_file(struct filter_lis char line[BIGPATHBUFLEN]; char *eob = line + sizeof line - 1; int word_split = mflags & MATCHFLG_WORD_SPLIT; + int slash_parse = xflags & XFLG_CVS_ENTRIES ? 1 : 0; if (!fname || !*fname) return; @@ -1051,6 +1062,24 @@ void parse_filter_file(struct filter_lis } break; } + switch (slash_parse) { /* CVS/Entries parsing: */ + case 1: /* Ignore starting chars until first slash. */ + if (ch == '/') + slash_parse = 2; + continue; + case 2: /* Name ends at 2nd slash on the line. */ + if (ch == '/') { + slash_parse = 3; + continue; + } + break; + case 3: /* Ignore trailing chars until EOL. */ + if (ch == '\n' || ch == '\r') { + slash_parse = 1; + goto end_the_line; + } + continue; + } if (word_split && isspace(ch)) break; if (eol_nulls? !ch : (ch == '\n' || ch == '\r')) @@ -1060,13 +1089,15 @@ void parse_filter_file(struct filter_lis else overflow = 1; } + end_the_line: if (overflow) { rprintf(FERROR, "discarding over-long filter: %s...\n", line); s = line; } *s = '\0'; /* Skip an empty token and (when line parsing) comments. */ - if (*line && (word_split || (*line != ';' && *line != '#'))) + if (*line && (word_split || slash_parse + || (*line != ';' && *line != '#'))) parse_rule(listp, line, mflags, xflags); if (ch == EOF) break; --- old/rsync.h +++ new/rsync.h @@ -132,6 +132,7 @@ #define XFLG_OLD_PREFIXES (1<<1) #define XFLG_ANCHORED2ABS (1<<2) #define XFLG_ABS_IF_SLASH (1<<3) +#define XFLG_CVS_ENTRIES (1<<4) #define ATTRS_REPORT (1<<0) #define ATTRS_SKIP_MTIME (1<<1) --- old/testsuite/exclude.test +++ new/testsuite/exclude.test @@ -19,6 +19,7 @@ export CVSIGNORE makepath "$fromdir/foo/down/to/you" makepath "$fromdir/foo/sub" +makepath "$fromdir/bar/down/to/CVS" makepath "$fromdir/bar/down/to/foo/too" makepath "$fromdir/bar/down/to/bar/baz" makepath "$fromdir/mid/for/foo/and/that/is/who" @@ -57,6 +58,9 @@ echo cvsout >"$fromdir/bar/down/to/foo/f echo gone >"$fromdir/bar/down/to/foo/file3" echo lost >"$fromdir/bar/down/to/foo/file4" echo weird >"$fromdir/bar/down/to/foo/+ file3" +echo cvsin >"$fromdir/bar/down/to/not.junk" +echo cvsout >"$fromdir/bar/down/to/not.good" +echo cvsout >"$fromdir/bar/down/to/D" echo cvsout-but-filtin >"$fromdir/bar/down/to/foo/file4.junk" echo smashed >"$fromdir/bar/down/to/foo/to" cat >"$fromdir/bar/down/to/bar/.filt2" <"$excl" <"$scratchdir/.cvsignore" <"$fromdir/bar/down/to/CVS/Entries" <"$fromdir/bar/down/to/.cvsignore" <