rsync, --cvs-exclude option.

Wayne Davison wayned at samba.org
Thu Apr 7 17:12:01 GMT 2005


On Wed, Apr 06, 2005 at 11:54:51PM -0700, Wayne Davison wrote:
> The one thing that it doesn't mention is that rsync will not know about
> any exceptions made to cvs's default ignore rules (which could only be
> discovered by reading the names in the CVS/Entries file -- something
> that rsync doesn't do).

An interesting question is:  should rsync do this?  On the one hand, it
makes an existing option (--cvs-ignore) work more correctly.  On the
other hand, it binds rsync even more tightly to a single version-control
program, and perhaps we should start transitioning over to having folks
translate their version-control-specific exception-lists into
.rsync-filter files and use the -F option.  E.g., a simple perl script
could parse the CVS/Entries file into "+ NAME" entries, and then
word-split the items in the .cvsignore file into "- NAME" entries, and
save the whole thing as a local .rsync-filter file.

The code to support direct reading of CVS/Entries files is pretty easy
to do, so I've attached a patch that turns the names in the file into
include rules on a per-directory basis -- allowing files that were
explicitly added into CVS to override a cvsignore rule.

Comments?

..wayne..
-------------- next part --------------
--- exclude.c	7 Apr 2005 18:06:06 -0000	1.115
+++ exclude.c	7 Apr 2005 18:06:34 -0000
@@ -442,6 +442,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,
@@ -958,6 +966,7 @@ void parse_filter_file(struct filter_lis
 	char line[MAXPATHLEN+MAX_RULE_PREFIX+1]; /* +1 for trailing slash. */
 	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;
@@ -1002,6 +1011,29 @@ void parse_filter_file(struct filter_lis
 					continue;
 				break;
 			}
+			switch (slash_parse) {
+			case 1:
+				if (ch == '/') {
+					s = line;
+					slash_parse = 2;
+					continue;
+				}
+				break;
+			case 2:
+				if (ch == '/') {
+					slash_parse = 3;
+					continue;
+				}
+				break;
+			case 3:
+				if (ch == '\n' || ch == '\r') {
+					slash_parse = 1;
+					goto double_break;
+				}
+				continue;
+			default:
+				break;
+			}
 			if (word_split && isspace(ch))
 				break;
 			if (eol_nulls? !ch : (ch == '\n' || ch == '\r'))
@@ -1011,6 +1043,7 @@ void parse_filter_file(struct filter_lis
 			else
 				overflow = 1;
 		}
+	    double_break:
 		if (overflow) {
 			rprintf(FERROR, "discarding over-long filter: %s...\n", line);
 			s = line;
--- rsync.h	28 Mar 2005 17:08:47 -0000	1.261
+++ rsync.h	7 Apr 2005 18:06:34 -0000
@@ -115,6 +115,7 @@
 #define XFLG_FATAL_ERRORS	(1<<0)
 #define XFLG_OLD_PREFIXES	(1<<1)
 #define XFLG_ANCHORED2ABS	(1<<2)
+#define XFLG_CVS_ENTRIES	(1<<3)
 
 #define PERMS_REPORT		(1<<0)
 #define PERMS_SKIP_MTIME	(1<<1)


More information about the rsync mailing list