The patches for 3.1.1pre1.
[rsync-patches.git] / cvs-entries.diff
index f685ac26c6a18e30ff7b6d4612b233499ec246f8..53355c183c5fbe98726346fea821e5912711150f 100644 (file)
@@ -2,76 +2,162 @@ 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.
 
---- orig/exclude.c     2005-10-14 18:45:50
-+++ exclude.c  2005-04-07 18:06:34
-@@ -446,6 +446,14 @@ void *push_local_filters(const char *dir
+To use this patch, run these commands for a successful build:
+
+    patch -p1 <patches/cvs-entries.diff
+    ./configure                                 (optional if already run)
+    make
+
+based-on: 8946cfc6f8018e30740ee1db4cc2e2008e4f7e7e
+diff --git a/exclude.c b/exclude.c
+--- a/exclude.c
++++ b/exclude.c
+@@ -267,6 +267,8 @@ static void add_rule(filter_rule_list *listp, const char *pat, unsigned int pat_
+               if (!(lp = new_array(filter_rule_list, 1)))
+                       out_of_memory("add_rule");
+               lp->head = lp->tail = lp->parent_dirscan_head = NULL;
++              if (rule->rflags & FILTRULE_CVS_IGNORE)
++                      cp = "CVS";
+               if (asprintf(&lp->debug_type, " [per-dir %s]", cp) < 0)
+                       out_of_memory("add_rule");
+               rule->u.mergelist = lp;
+@@ -526,6 +528,14 @@ void *push_local_filters(const char *dir, unsigned int dirlen)
                                set_filter_dir(dir, dirlen);
                }
  
-+              if (ex->match_flags & MATCHFLG_CVS_IGNORE
++              if (ex->rflags & FILTRULE_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,
++                                    rule_template(FILTRULE_NO_PREFIXES | FILTRULE_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,
-@@ -962,6 +970,7 @@ void parse_filter_file(struct filter_lis
+                       parse_filter_file(lp, dirbuf, ex,
+@@ -1147,6 +1157,7 @@ void parse_filter_file(filter_rule_list *listp, const char *fname, const filter_
        char line[BIGPATHBUFLEN];
        char *eob = line + sizeof line - 1;
-       int word_split = mflags & MATCHFLG_WORD_SPLIT;
+       BOOL word_split = (template->rflags & FILTRULE_WORD_SPLIT) != 0;
 +      int slash_parse = xflags & XFLG_CVS_ENTRIES ? 1 : 0;
  
        if (!fname || !*fname)
                return;
-@@ -1006,6 +1015,29 @@ void parse_filter_file(struct filter_lis
-                                       continue;
+@@ -1193,6 +1204,24 @@ void parse_filter_file(filter_rule_list *listp, const char *fname, const filter_
+                               }
                                break;
                        }
-+                      switch (slash_parse) {
-+                      case 1:
-+                              if (ch == '/') {
-+                                      s = line;
++                      switch (slash_parse) { /* CVS/Entries parsing: */
++                      case 1: /* Ignore starting chars until first slash. */
++                              if (ch == '/')
 +                                      slash_parse = 2;
-+                                      continue;
-+                              }
-+                              break;
-+                      case 2:
++                              continue;
++                      case 2: /* Name ends at 2nd slash on the line. */
 +                              if (ch == '/') {
 +                                      slash_parse = 3;
 +                                      continue;
 +                              }
 +                              break;
-+                      case 3:
++                      case 3: /* Ignore trailing chars until EOL. */
 +                              if (ch == '\n' || ch == '\r') {
 +                                      slash_parse = 1;
-+                                      goto double_break;
++                                      goto end_the_line;
 +                              }
 +                              continue;
-+                      default:
-+                              break;
 +                      }
                        if (word_split && isspace(ch))
                                break;
                        if (eol_nulls? !ch : (ch == '\n' || ch == '\r'))
-@@ -1015,6 +1047,7 @@ void parse_filter_file(struct filter_lis
+@@ -1202,13 +1231,14 @@ void parse_filter_file(filter_rule_list *listp, const char *fname, const filter_
                        else
                                overflow = 1;
                }
-+          double_break:
++        end_the_line:
                if (overflow) {
                        rprintf(FERROR, "discarding over-long filter: %s...\n", line);
                        s = line;
---- orig/rsync.h       2005-10-14 18:45:50
-+++ rsync.h    2005-10-14 19:17:51
-@@ -116,6 +116,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)
+               }
+               *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_filter_str(listp, line, template, xflags);
+               if (ch == EOF)
+                       break;
+diff --git a/rsync.h b/rsync.h
+--- a/rsync.h
++++ b/rsync.h
+@@ -162,6 +162,7 @@
+ #define XFLG_ANCHORED2ABS     (1<<2) /* leading slash indicates absolute */
+ #define XFLG_ABS_IF_SLASH     (1<<3) /* leading or interior slash is absolute */
+ #define XFLG_DIR2WILD3                (1<<4) /* dir/ match gets trailing *** added */
++#define XFLG_CVS_ENTRIES      (1<<5)
+ #define ATTRS_REPORT          (1<<0)
+ #define ATTRS_SKIP_MTIME      (1<<1)
+diff --git a/testsuite/exclude.test b/testsuite/exclude.test
+--- a/testsuite/exclude.test
++++ b/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/file1.bak"
+ 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" <<EOF
+@@ -102,7 +106,18 @@ cat >"$excl" <<EOF
+ EOF
+ cat >"$scratchdir/.cvsignore" <<EOF
+-home-cvs-exclude
++home-cvs-exclude D
++EOF
++cat >"$fromdir/bar/down/to/CVS/Entries" <<EOF
++/not.junk/1.1/Mon Jan  1 11:11:11 2001//
++filt2
++/another.file/1.1/Tue Jan  1 22:22:22 2002//
++invalid lines should just be ignored...
++D/directory////
++D
++EOF
++cat >"$fromdir/bar/down/to/.cvsignore" <<EOF
++not.good
+ EOF
+ # Start with a check of --prune-empty-dirs:
+@@ -136,6 +151,10 @@ checkit "$RSYNC -avv --exclude-from='$excl' \
+ # Modify the chk dir by removing cvs-ignored files and then tweaking the dir times.
+ rm "$chkdir"/foo/*.old
++rm "$chkdir"/bar/down/to/D
++rm "$chkdir"/bar/down/to/CVS/Entries
++rmdir "$chkdir"/bar/down/to/CVS
++rm "$chkdir"/bar/down/to/not.good
+ rm "$chkdir"/bar/down/to/foo/*.bak
+ rm "$chkdir"/bar/down/to/foo/*.junk
+ rm "$chkdir"/bar/down/to/home-cvs-exclude
+@@ -151,8 +170,12 @@ checkit "$RSYNC -avvC --filter='merge $excl' --delete-excluded \
+ # Modify the chk dir for our merge-exclude test and then tweak the dir times.
++makepath "$chkdir/bar/down/to/CVS"
+ rm "$chkdir"/foo/file1
+ rm "$chkdir"/bar/down/to/bar/baz/*.deep
++cp_touch "$fromdir"/bar/down/to/D "$chkdir"/bar/down/to/D
++cp_touch "$fromdir"/bar/down/to/not.good "$chkdir"/bar/down/to/not.good
++cp_touch "$fromdir"/bar/down/to/CVS/Entries "$chkdir"/bar/down/to/CVS/Entries
+ cp_touch "$fromdir"/bar/down/to/foo/*.junk "$chkdir"/bar/down/to/foo
+ cp_touch "$fromdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo
  
- #define PERMS_REPORT          (1<<0)
- #define PERMS_SKIP_MTIME      (1<<1)