Got rid of some fuzz.
[rsync/rsync-patches.git] / filter.diff
index eeab362..846f26f 100644 (file)
@@ -4,7 +4,7 @@ command before "make":
     make proto
 
 This patch adds the --filter option, which implements an improved set of
-excludes/includes rules:
+include/exclude rules:
 
     . SINGLE-INSTANCE_MERGE_FILE
     : PER-DIRECTORY_MERGE_FILE
@@ -12,8 +12,9 @@ excludes/includes rules:
     + include-pattern
 
 Note that the prefix for a filter rule is NOT optional, and that the
-separating space can be an equal-sign (=), if desired.  There are also
-optional modifiers that can be specified for a merge-file rule.
+separating space can be replaced by an equal-sign (=) or an underscore (_),
+if desired.  There are also optional modifiers that can be specified for
+the merge-file rules.
 
 A per-directory merge file is one that will be looked for in every
 sub-directory that rsync visits, and the rules found in that sub-
@@ -21,27 +22,27 @@ directory's file will affect that dir and (if desired) its subdirs.
 
 For example:
 
-  rsync -av --filter :=.filt from/ to
+  rsync -av --filter :_.rules from/ to
 
-The above will look for a file named ".filt" in every directory of the
+The above will look for a file named ".rules" in every directory of the
 hierarchy that rsync visits, and it will filter names based on the rules
-found therein.  If one of the .filt files contains this:
+found therein.  If one of the .rules files contains this:
 
   + *.c
-  : .filt2
-  . .filt3
+  : .rules2
+  . .rules3
   - *.o
   - /foobar
 
-Then the file ".filt2" will also be read in from the current dir and all
-its subdirs.  The file ".filt3" would just be read in from the current dir
-only.  The exclusion of "foobar" will only happen in that .filt file's
+Then the file ".rules2" will also be read in from the current dir and all
+its subdirs.  The file ".rules3" would just be read in from the current dir
+only.  The exclusion of "foobar" will only happen in that .rules file's
 directory because the rule is anchored, which is one way to make a rule
-local instead of inherited (see also the 'n' option).
+local instead of inherited (see also the 'n' modifier).
 
 ..wayne..
 
---- orig/clientserver.c        2005-01-01 21:11:00
+--- orig/clientserver.c        2005-01-22 22:48:52
 +++ clientserver.c     2005-01-16 23:33:02
 @@ -49,12 +49,14 @@ extern int no_detach;
  extern int default_af_hint;
@@ -59,7 +60,7 @@ local instead of inherited (see also the 'n' option).
  /**
   * Run a client connected to an rsyncd.  The alternative to this
   * function for remote-shell connections is do_cmd().
-@@ -304,26 +306,33 @@ static int rsync_module(int f_in, int f_
+@@ -310,26 +312,33 @@ static int rsync_module(int f_in, int f_
        /* TODO: Perhaps take a list of gids, and make them into the
         * supplementary groups. */
  
@@ -102,9 +103,9 @@ local instead of inherited (see also the 'n' option).
  
        log_init();
  
---- orig/exclude.c     2005-01-13 23:15:56
-+++ exclude.c  2005-01-17 00:25:08
-@@ -30,15 +30,73 @@ extern int verbose;
+--- orig/exclude.c     2005-01-22 22:48:52
++++ exclude.c  2005-01-23 07:33:21
+@@ -30,15 +30,68 @@ extern int verbose;
  extern int eol_nulls;
  extern int list_only;
  extern int recurse;
@@ -122,11 +123,6 @@ local instead of inherited (see also the 'n' option).
 -char *exclude_path_prefix = NULL;
  
 -/** Build an exclude structure given an exclude pattern. */
-+struct mergelist_save_struct {
-+    struct exclude_list_struct *array;
-+    int count;
-+};
-+
 +/* The dirbuf is set by push_local_excludes() to the current subdirectory
 + * relative to curr_dir that is being processed.  The path always has a
 + * trailing slash appended, and the variable dirbuf_len contains the length
@@ -181,15 +177,16 @@ local instead of inherited (see also the 'n' option).
  static void make_exclude(struct exclude_list_struct *listp, const char *pat,
                         unsigned int pat_len, unsigned int mflags)
  {
-@@ -46,23 +104,44 @@ static void make_exclude(struct exclude_
+@@ -46,23 +99,45 @@ static void make_exclude(struct exclude_
        const char *cp;
        unsigned int ex_len;
  
 +      if (verbose > 2) {
 +              rprintf(FINFO, "[%s] add_exclude(%.*s, %s%s)\n",
-+                      who_am_i(), (int)pat_len, pat, listp->debug_type,
-+                      mflags & MATCHFLG_MERGE_FILE ? "MERGE-FILE"
-+                      : mflags & MATCHFLG_INCLUDE ? "include" : "exclude");
++                      who_am_i(), (int)pat_len, pat,
++                      mflags & MATCHFLG_MERGE_FILE ? "per-dir-merge"
++                      : mflags & MATCHFLG_INCLUDE ? "include" : "exclude",
++                      listp->debug_type);
 +      }
 +
 +      if (mflags & MATCHFLG_MERGE_FILE) {
@@ -232,7 +229,7 @@ local instead of inherited (see also the 'n' option).
        strlcpy(ret->pattern + ex_len, pat, pat_len + 1);
        pat_len += ex_len;
  
-@@ -81,14 +160,40 @@ static void make_exclude(struct exclude_
+@@ -81,14 +156,40 @@ static void make_exclude(struct exclude_
                mflags |= MATCHFLG_DIRECTORY;
        }
  
@@ -248,7 +245,7 @@ local instead of inherited (see also the 'n' option).
 +                      cp++;
 +              else
 +                      cp = ret->pattern;
-+              if (asprintf(&lp->debug_type, "per-dir %s ", cp) < 0)
++              if (asprintf(&lp->debug_type, " (per-dir %s)", cp) < 0)
 +                      out_of_memory("make_exclude");
 +              ret->u.mergelist = lp;
 +              if (mergelist_cnt == mergelist_size) {
@@ -277,13 +274,14 @@ local instead of inherited (see also the 'n' option).
                listp->tail->next = ret;
                listp->tail = ret;
        }
-@@ -96,22 +201,270 @@ static void make_exclude(struct exclude_
+@@ -96,22 +197,263 @@ static void make_exclude(struct exclude_
  
  static void free_exclude(struct exclude_struct *ex)
  {
 +      if (ex->match_flags & MATCHFLG_MERGE_FILE) {
 +              free(ex->u.mergelist->debug_type);
 +              free(ex->u.mergelist);
++              mergelist_cnt--;
 +      }
        free(ex->pattern);
        free(ex);
@@ -459,21 +457,16 @@ local instead of inherited (see also the 'n' option).
 + * into dirbuf so that we can easily append a file name on the end. */
 +void *push_local_excludes(const char *dir, unsigned int dirlen)
 +{
-+      struct mergelist_save_struct *push;
-+      struct exclude_list_struct *ap;
++      struct exclude_list_struct *ap, *push;
 +      int i;
 +
 +      set_excludes_dir(dir, dirlen);
 +
-+      if (!(push = new_array(struct mergelist_save_struct, 1)))
-+              out_of_memory("push_local_excludes");
-+
-+      push->count = mergelist_cnt;
-+      push->array = new_array(struct exclude_list_struct, mergelist_cnt);
-+      if (!push->array)
++      push = new_array(struct exclude_list_struct, mergelist_cnt);
++      if (!push)
 +              out_of_memory("push_local_excludes");
 +
-+      for (i = 0, ap = push->array; i < mergelist_cnt; i++) {
++      for (i = 0, ap = push; i < mergelist_cnt; i++) {
 +              memcpy(ap++, mergelist_parents[i]->u.mergelist,
 +                     sizeof (struct exclude_list_struct));
 +      }
@@ -486,7 +479,7 @@ local instead of inherited (see also the 'n' option).
 +              int flags = 0;
 +
 +              if (verbose > 2) {
-+                      rprintf(FINFO, "[%s] pushing %sexclude list\n",
++                      rprintf(FINFO, "[%s] pushing exclude list%s\n",
 +                              who_am_i(), lp->debug_type);
 +              }
 +
@@ -525,8 +518,7 @@ local instead of inherited (see also the 'n' option).
 +
 +void pop_local_excludes(void *mem)
 +{
-+      struct mergelist_save_struct *pop = (struct mergelist_save_struct*)mem;
-+      struct exclude_list_struct *ap;
++      struct exclude_list_struct *ap, *pop = (struct exclude_list_struct*)mem;
 +      int i;
 +
 +      for (i = mergelist_cnt; i-- > 0; ) {
@@ -534,27 +526,25 @@ local instead of inherited (see also the 'n' option).
 +              struct exclude_list_struct *lp = ex->u.mergelist;
 +
 +              if (verbose > 2) {
-+                      rprintf(FINFO, "[%s] popping %sexclude list\n",
++                      rprintf(FINFO, "[%s] popping exclude list%s\n",
 +                              who_am_i(), lp->debug_type);
 +              }
 +
 +              clear_exclude_list(lp);
 +      }
 +
-+      mergelist_cnt = pop->count;
-+      for (i = 0, ap = pop->array; i < mergelist_cnt; i++) {
++      for (i = 0, ap = pop; i < mergelist_cnt; i++) {
 +              memcpy(mergelist_parents[i]->u.mergelist, ap++,
 +                     sizeof (struct exclude_list_struct));
 +      }
 +
-+      free(pop->array);
 +      free(pop);
 +}
 +
  static int check_one_exclude(char *name, struct exclude_struct *ex,
                               int name_is_dir)
  {
-@@ -125,13 +478,14 @@ static int check_one_exclude(char *name,
+@@ -125,13 +467,14 @@ static int check_one_exclude(char *name,
        /* If the pattern does not have any slashes AND it does not have
         * a "**" (which could match a slash), then we just match the
         * name portion of the path. */
@@ -572,7 +562,7 @@ local instead of inherited (see also the 'n' option).
                name = full_name;
        }
  
-@@ -148,9 +502,9 @@ static int check_one_exclude(char *name,
+@@ -148,9 +491,9 @@ static int check_one_exclude(char *name,
        if (ex->match_flags & MATCHFLG_WILD) {
                /* A non-anchored match with an infix slash and no "**"
                 * needs to match the last slash_cnt+1 name elements. */
@@ -584,7 +574,23 @@ local instead of inherited (see also the 'n' option).
                        for (p = name + strlen(name) - 1; p >= name; p--) {
                                if (*p == '/' && !--cnt)
                                        break;
-@@ -221,6 +575,13 @@ int check_exclude(struct exclude_list_st
+@@ -202,12 +545,11 @@ static void report_exclude_result(char c
+        * case we add it back in here. */
+       if (verbose >= 2) {
+-              rprintf(FINFO, "[%s] %scluding %s %s because of %spattern %s%s\n",
++              rprintf(FINFO, "[%s] %scluding %s %s because of pattern %s%s%s\n",
+                       who_am_i(),
+                       ent->match_flags & MATCHFLG_INCLUDE ? "in" : "ex",
+-                      name_is_dir ? "directory" : "file", name, type,
+-                      ent->pattern,
+-                      ent->match_flags & MATCHFLG_DIRECTORY ? "/" : "");
++                      name_is_dir ? "directory" : "file", name, ent->pattern,
++                      ent->match_flags & MATCHFLG_DIRECTORY ? "/" : "", type);
+       }
+ }
+@@ -221,6 +563,13 @@ int check_exclude(struct exclude_list_st
        struct exclude_struct *ent;
  
        for (ent = listp->head; ent; ent = ent->next) {
@@ -598,7 +604,7 @@ local instead of inherited (see also the 'n' option).
                if (check_one_exclude(name, ent, name_is_dir)) {
                        report_exclude_result(name, ent, name_is_dir,
                                              listp->debug_type);
-@@ -236,7 +597,7 @@ int check_exclude(struct exclude_list_st
+@@ -236,32 +585,102 @@ int check_exclude(struct exclude_list_st
   * be '\0' terminated, so use the returned length to limit the string.
   * Also, be sure to add this length to the returned pointer before passing
   * it back to ask for the next token.  This routine parses the "!" (list-
@@ -607,21 +613,29 @@ local instead of inherited (see also the 'n' option).
   * +/- prefixes for overriding the include/exclude mode.  The *flag_ptr
   * value will also be set to the MATCHFLG_* bits for the current token.
   */
-@@ -245,6 +606,7 @@ static const char *get_exclude_tok(const
+-static const char *get_exclude_tok(const char *p, unsigned int *len_ptr,
+-                                 unsigned int *flag_ptr, int xflags)
++static const char *get_exclude_tok(const char *p, int xflags,
++                      unsigned int *len_ptr, unsigned int *flag_ptr)
  {
        const unsigned char *s = (const unsigned char *)p;
        unsigned int len, mflags = 0;
-+      int add_dot_cvsinore = 0;
++      int empty_pat_is_OK = 0;
  
        if (xflags & XFLG_WORD_SPLIT) {
                /* Skip over any initial whitespace. */
-@@ -254,14 +616,74 @@ static const char *get_exclude_tok(const
+               while (isspace(*s))
+                       s++;
+-              /* Update for "!" check. */
++              /* Update to point to real start of rule. */
                p = (const char *)s;
        }
++      if (!*s)
++              return NULL;
  
 -      /* Is this a '+' or '-' followed by a space (not whitespace)? */
 -      if (!(xflags & XFLG_WORDS_ONLY)
-+      /* Check for a leading '+' or '-'. */
++      /* Figure out what kind of a filter rule "s" is pointing at. */
 +      if (!(xflags & (XFLG_DEF_INCLUDE | XFLG_DEF_EXCLUDE))) {
 +              char *mods = "";
 +              switch (*s) {
@@ -639,18 +653,21 @@ local instead of inherited (see also the 'n' option).
 +              case '-':
 +                      break;
 +              case '!':
++                      mflags |= MATCHFLG_CLEAR_LIST;
++                      mods = NULL;
 +                      break;
-+              case '\0':
-+                      len = 0;
-+                      goto all_done;
 +              default:
-+                      rprintf(FERROR, "Unknown filter command: %s\n", p);
++                      rprintf(FERROR, "Unknown filter rule: %s\n", p);
 +                      exit_cleanup(RERR_SYNTAX);
 +              }
-+              while (*++s && *s != ' ' && *s != '=') {
++              while (mods && *++s && *s != ' ' && *s != '=' && *s != '_') {
 +                      if (strchr(mods, *s) == NULL) {
++                              if (xflags & XFLG_WORD_SPLIT && isspace(*s)) {
++                                      s--;
++                                      break;
++                              }
 +                              rprintf(FERROR,
-+                                      "unknown option '%c' in filter command: %s\n",
++                                      "unknown option '%c' in filter rule: %s\n",
 +                                      *s, p);
 +                              exit_cleanup(RERR_SYNTAX);
 +                      }
@@ -663,7 +680,7 @@ local instead of inherited (see also the 'n' option).
 +                                      | MATCHFLG_INCLUDE;
 +                              break;
 +                      case 'C':
-+                              add_dot_cvsinore = 1;
++                              empty_pat_is_OK = 1;
 +                              mflags |= MATCHFLG_NO_PREFIXES
 +                                      | MATCHFLG_WORD_SPLIT
 +                                      | MATCHFLG_NO_INHERIT;
@@ -686,34 +703,43 @@ local instead of inherited (see also the 'n' option).
                if (*s == '+')
                        mflags |= MATCHFLG_INCLUDE;
                s += 2;
-       } else if (xflags & XFLG_DEF_INCLUDE)
-               mflags |= MATCHFLG_INCLUDE;
+-      } else if (xflags & XFLG_DEF_INCLUDE)
+-              mflags |= MATCHFLG_INCLUDE;
++      } else {
++              if (xflags & XFLG_DEF_INCLUDE)
++                      mflags |= MATCHFLG_INCLUDE;
++              if (*s == '!')
++                      mflags |= MATCHFLG_CLEAR_LIST; /* Tentative! */
++      }
 +
        if (xflags & XFLG_DIRECTORY)
                mflags |= MATCHFLG_DIRECTORY;
  
-@@ -274,9 +696,20 @@ static const char *get_exclude_tok(const
+@@ -274,8 +693,21 @@ static const char *get_exclude_tok(const
        } else
                len = strlen(s);
  
-+      if (add_dot_cvsinore && !len) {
-+              s = ".cvsignore";
-+              len = 10;
-+      } else if (!len && *p) {
-+              rprintf(FERROR, "truncated filter command: %s\n", p);
+-      if (*p == '!' && len == 1)
+-              mflags |= MATCHFLG_CLEAR_LIST;
++      if (mflags & MATCHFLG_CLEAR_LIST) {
++              if (!(xflags & (XFLG_DEF_INCLUDE | XFLG_DEF_EXCLUDE)) && len) {
++                      rprintf(FERROR,
++                              "'!' rule has trailing characters: %s\n", p);
++                      exit_cleanup(RERR_SYNTAX);
++              }
++              if (len > 1)
++                      mflags &= ~MATCHFLG_CLEAR_LIST;
++      } else if (!len && !empty_pat_is_OK) {
++              rprintf(FERROR, "unexpected end of filter rule: %s\n", p);
 +              exit_cleanup(RERR_SYNTAX);
 +      }
 +
-       if (*p == '!' && len == 1)
-               mflags |= MATCHFLG_CLEAR_LIST;
 +      if (xflags & XFLG_ABS_PATH)
 +              mflags |= MATCHFLG_ABS_PATH;
  
-+    all_done:
        *len_ptr = len;
        *flag_ptr = mflags;
-       return (const char *)s;
-@@ -287,7 +720,7 @@ void add_exclude(struct exclude_list_str
+@@ -287,35 +719,71 @@ void add_exclude(struct exclude_list_str
                 int xflags)
  {
        unsigned int pat_len, mflags;
@@ -722,23 +748,31 @@ local instead of inherited (see also the 'n' option).
  
        if (!pattern)
                return;
-@@ -295,9 +728,15 @@ void add_exclude(struct exclude_list_str
-       cp = pattern;
-       pat_len = 0;
+-      cp = pattern;
+-      pat_len = 0;
        while (1) {
+-              cp = get_exclude_tok(cp + pat_len, &pat_len, &mflags, xflags);
+-              if (!pat_len)
 +              /* Remember that the returned string is NOT '\0' terminated! */
-               cp = get_exclude_tok(cp + pat_len, &pat_len, &mflags, xflags);
-               if (!pat_len)
++              cp = get_exclude_tok(pattern, xflags, &pat_len, &mflags);
++              if (!cp)
                        break;
 +              if (pat_len >= MAXPATHLEN) {
 +                      rprintf(FERROR, "discarding over-long exclude: %s\n",
 +                              cp);
 +                      continue;
 +              }
++              pattern = cp + pat_len;
  
                if (mflags & MATCHFLG_CLEAR_LIST) {
                        if (verbose > 2) {
-@@ -309,13 +748,39 @@ void add_exclude(struct exclude_list_str
+                               rprintf(FINFO,
+-                                      "[%s] clearing %sexclude list\n",
++                                      "[%s] clearing exclude list%s\n",
+                                       who_am_i(), listp->debug_type);
+                       }
+                       clear_exclude_list(listp);
                        continue;
                }
  
@@ -748,6 +782,11 @@ local instead of inherited (see also the 'n' option).
 -                      rprintf(FINFO, "[%s] add_exclude(%.*s, %s%sclude)\n",
 -                              who_am_i(), (int)pat_len, cp, listp->debug_type,
 -                              mflags & MATCHFLG_INCLUDE ? "in" : "ex");
++              if (!pat_len) {
++                      cp = ".cvsignore";
++                      pat_len = 10;
++              }
++
 +              if (mflags & MATCHFLG_MERGE_FILE) {
 +                      unsigned int len = pat_len;
 +                      if (mflags & MATCHFLG_EXCLUDE_SELF) {
@@ -784,7 +823,7 @@ local instead of inherited (see also the 'n' option).
        }
  }
  
-@@ -324,7 +789,7 @@ void add_exclude_file(struct exclude_lis
+@@ -324,7 +792,7 @@ void add_exclude_file(struct exclude_lis
                      int xflags)
  {
        FILE *fp;
@@ -793,15 +832,16 @@ local instead of inherited (see also the 'n' option).
        char *eob = line + sizeof line - 1;
        int word_split = xflags & XFLG_WORD_SPLIT;
  
-@@ -338,13 +803,19 @@ void add_exclude_file(struct exclude_lis
+@@ -338,13 +806,19 @@ void add_exclude_file(struct exclude_lis
        if (!fp) {
                if (xflags & XFLG_FATAL_ERRORS) {
                        rsyserr(FERROR, errno,
 -                              "failed to open %s file %s",
 -                              xflags & XFLG_DEF_INCLUDE ? "include" : "exclude",
+-                              fname);
 +                              "failed to open %sclude file %s",
 +                              xflags & XFLG_DEF_INCLUDE ? "in" : "ex",
-                               fname);
++                              safe_fname(fname));
                        exit_cleanup(RERR_FILEIO);
                }
                return;
@@ -810,21 +850,21 @@ local instead of inherited (see also the 'n' option).
 +
 +      if (verbose > 2) {
 +              rprintf(FINFO, "[%s] add_exclude_file(%s,%d)\n",
-+                      who_am_i(), fname, xflags);
++                      who_am_i(), safe_fname(fname), xflags);
 +      }
  
        while (1) {
                char *s = line;
-@@ -388,7 +859,7 @@ void send_exclude_list(int f)
-        * FIXME: This pattern shows up in the output of
-        * report_exclude_result(), which is not ideal. */
-       if (list_only && !recurse)
+@@ -386,7 +860,7 @@ void send_exclude_list(int f)
+       /* This is a complete hack - blame Rusty.  FIXME!
+        * Remove this hack when older rsyncs (below 2.6.4) are gone. */
+       if (list_only == 1 && !recurse)
 -              add_exclude(&exclude_list, "/*/*", 0);
 +              add_exclude(&exclude_list, "/*/*", XFLG_DEF_EXCLUDE);
  
        for (ent = exclude_list.head; ent; ent = ent->next) {
                unsigned int l;
-@@ -402,10 +873,33 @@ void send_exclude_list(int f)
+@@ -400,10 +874,34 @@ void send_exclude_list(int f)
                        p[l] = '\0';
                }
  
@@ -832,7 +872,8 @@ local instead of inherited (see also the 'n' option).
 +              if (ent->match_flags & MATCHFLG_PERDIR_MERGE) {
 +                      char buf[32], *op = buf;
 +                      if (protocol_version < 29) {
-+                              rprintf(FERROR, "remote rsync is too old to understand per-directory filter files.\n");
++                              rprintf(FERROR,
++                                      "remote rsync is too old to understand per-directory filter files.\n");
 +                              exit_cleanup(RERR_SYNTAX);
 +                      }
 +                      *op++ = ':';
@@ -860,7 +901,7 @@ local instead of inherited (see also the 'n' option).
                        write_int(f, l + 2);
                        write_buf(f, "- ", 2);
                } else
-@@ -419,14 +913,15 @@ void send_exclude_list(int f)
+@@ -417,14 +915,15 @@ void send_exclude_list(int f)
  
  void recv_exclude_list(int f)
  {
@@ -878,7 +919,7 @@ local instead of inherited (see also the 'n' option).
        }
  }
  
-@@ -443,18 +938,18 @@ static char default_cvsignore[] = 
+@@ -441,18 +940,18 @@ static char default_cvsignore[] = 
  
  void add_cvs_excludes(void)
  {
@@ -903,20 +944,21 @@ local instead of inherited (see also the 'n' option).
 -                  XFLG_WORD_SPLIT | XFLG_WORDS_ONLY);
 +      add_exclude(&exclude_list, getenv("CVSIGNORE"), cvs_flags);
  }
---- orig/flist.c       2005-01-01 21:11:00
+--- orig/flist.c       2005-01-24 00:18:21
 +++ flist.c    2004-08-12 18:59:28
-@@ -40,10 +40,9 @@ extern int module_id;
+@@ -40,11 +40,10 @@ extern int module_id;
  extern int ignore_errors;
  extern int numeric_ids;
  
 -extern int cvs_exclude;
 -
  extern int recurse;
+ extern int xfer_dirs;
  extern char curr_dir[MAXPATHLEN];
 +extern unsigned int curr_dir_len;
- extern char *files_from;
  extern int filesfrom_fd;
  
+ extern int one_file_system;
 @@ -67,7 +66,6 @@ extern int list_only;
  
  extern struct exclude_list_struct exclude_list;
@@ -962,7 +1004,7 @@ local instead of inherited (see also the 'n' option).
        }
  }
  
-@@ -1002,6 +987,7 @@ static void send_directory(int f, struct
+@@ -1004,6 +989,7 @@ static void send_directory(int f, struct
        struct dirent *di;
        char fname[MAXPATHLEN];
        unsigned int offset;
@@ -970,7 +1012,7 @@ local instead of inherited (see also the 'n' option).
        char *p;
  
        d = opendir(dir);
-@@ -1025,18 +1011,7 @@ static void send_directory(int f, struct
+@@ -1027,18 +1013,7 @@ static void send_directory(int f, struct
                offset++;
        }
  
@@ -990,7 +1032,7 @@ local instead of inherited (see also the 'n' option).
  
        for (errno = 0, di = readdir(d); di; errno = 0, di = readdir(d)) {
                char *dname = d_name(di);
-@@ -1057,6 +1032,8 @@ static void send_directory(int f, struct
+@@ -1060,6 +1035,8 @@ static void send_directory(int f, struct
                rsyserr(FERROR, errno, "readdir(%s)", dir);
        }
  
@@ -999,7 +1041,7 @@ local instead of inherited (see also the 'n' option).
        closedir(d);
  }
  
-@@ -1076,6 +1053,7 @@ struct file_list *send_file_list(int f, 
+@@ -1079,6 +1056,7 @@ struct file_list *send_file_list(int f, 
        char *p, *dir, olddir[sizeof curr_dir];
        char lastpath[MAXPATHLEN] = "";
        struct file_list *flist;
@@ -1007,7 +1049,7 @@ local instead of inherited (see also the 'n' option).
        int64 start_write;
        int use_ff_fd = 0;
  
-@@ -1096,6 +1074,10 @@ struct file_list *send_file_list(int f, 
+@@ -1099,6 +1077,10 @@ struct file_list *send_file_list(int f, 
                                exit_cleanup(RERR_FILESELECT);
                        }
                        use_ff_fd = 1;
@@ -1018,9 +1060,9 @@ local instead of inherited (see also the 'n' option).
                }
        }
  
-@@ -1126,6 +1108,15 @@ struct file_list *send_file_list(int f, 
-                       }
-               }
+@@ -1135,6 +1117,15 @@ struct file_list *send_file_list(int f, 
+               } else if (recurse > 0)
+                       recurse = 0;
  
 +              if (need_first_push) {
 +                      if ((p = strrchr(fname, '/')) != NULL) {
@@ -1068,9 +1110,9 @@ local instead of inherited (see also the 'n' option).
  FN_LOCAL_STRING(lp_exclude, exclude)
  FN_LOCAL_STRING(lp_exclude_from, exclude_from)
  FN_LOCAL_STRING(lp_include, include)
---- orig/options.c     2005-01-15 21:23:15
-+++ options.c  2005-01-16 23:34:15
-@@ -144,6 +144,7 @@ int list_only = 0;
+--- orig/options.c     2005-01-24 00:18:21
++++ options.c  2005-01-23 07:33:55
+@@ -146,6 +146,7 @@ int list_only = 0;
  char *batch_name = NULL;
  
  static int daemon_opt;   /* sets am_daemon after option error-reporting */
@@ -1078,34 +1120,34 @@ local instead of inherited (see also the 'n' option).
  static int modify_window_set;
  static char *dest_option = NULL;
  static char *max_size_arg;
-@@ -291,6 +292,9 @@ void usage(enum logcode F)
+@@ -294,6 +295,9 @@ void usage(enum logcode F)
    rprintf(F," -P                          equivalent to --partial --progress\n");
    rprintf(F," -z, --compress              compress file data\n");
    rprintf(F," -C, --cvs-exclude           auto ignore files in the same way CVS does\n");
 +  rprintf(F," -f, --filter=RULE           add a file-filtering RULE\n");
-+  rprintf(F," -F                          same as --filter=': /.rsync-rules'\n");
-+  rprintf(F,"                             repeated: --filter='- .rsync-rules'\n");
++  rprintf(F," -F                          same as --filter=': /.rsync-filter'\n");
++  rprintf(F,"                             repeated: --filter='- .rsync-filter'\n");
    rprintf(F,"     --exclude=PATTERN       exclude files matching PATTERN\n");
    rprintf(F,"     --exclude-from=FILE     exclude patterns listed in FILE\n");
    rprintf(F,"     --include=PATTERN       don't exclude files matching PATTERN\n");
-@@ -320,7 +324,7 @@ void usage(enum logcode F)
+@@ -324,7 +328,7 @@ void usage(enum logcode F)
  }
  
  enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
--      OPT_DELETE_AFTER, OPT_DELETE_EXCLUDED,
-+      OPT_FILTER, OPT_DELETE_AFTER, OPT_DELETE_EXCLUDED,
-       OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST,
+-      OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST,
++      OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST,
        OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
        OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_TIMEOUT, OPT_MAX_SIZE,
-@@ -343,6 +347,7 @@ static struct poptOption long_options[] 
-   {"delete-excluded",  0,  POPT_ARG_NONE,   0, OPT_DELETE_EXCLUDED, 0, 0 },
+       OPT_REFUSED_BASE = 9000};
+@@ -346,6 +350,7 @@ static struct poptOption long_options[] 
+   {"delete-excluded",  0,  POPT_ARG_NONE,   &delete_excluded, 0, 0, 0 },
    {"force",            0,  POPT_ARG_NONE,   &force_delete, 0, 0, 0 },
    {"numeric-ids",      0,  POPT_ARG_NONE,   &numeric_ids, 0, 0, 0 },
 +  {"filter",          'f', POPT_ARG_STRING, 0, OPT_FILTER, 0, 0 },
    {"exclude",          0,  POPT_ARG_STRING, 0, OPT_EXCLUDE, 0, 0 },
    {"include",          0,  POPT_ARG_STRING, 0, OPT_INCLUDE, 0, 0 },
    {"exclude-from",     0,  POPT_ARG_STRING, 0, OPT_EXCLUDE_FROM, 0, 0 },
-@@ -393,6 +398,7 @@ static struct poptOption long_options[] 
+@@ -398,6 +403,7 @@ static struct poptOption long_options[] 
    {"ignore-errors",    0,  POPT_ARG_NONE,   &ignore_errors, 0, 0, 0 },
    {"blocking-io",      0,  POPT_ARG_VAL,    &blocking_io, 1, 0, 0 },
    {"no-blocking-io",   0,  POPT_ARG_VAL,    &blocking_io, 0, 0, 0 },
@@ -1113,8 +1155,8 @@ local instead of inherited (see also the 'n' option).
    {0,                 'P', POPT_ARG_NONE,   0, 'P', 0, 0 },
    {"port",             0,  POPT_ARG_INT,    &rsync_port, 0, 0, 0 },
    {"log-format",       0,  POPT_ARG_STRING, &log_format, 0, 0, 0 },
-@@ -622,10 +628,15 @@ int parse_arguments(int *argc, const cha
-                       delete_mode = 1;
+@@ -619,10 +625,15 @@ int parse_arguments(int *argc, const cha
+                       modify_window_set = 1;
                        break;
  
 -              case OPT_EXCLUDE:
@@ -1130,7 +1172,7 @@ local instead of inherited (see also the 'n' option).
                case OPT_INCLUDE:
                        add_exclude(&exclude_list, poptGetOptArg(pc),
                                    XFLG_DEF_INCLUDE);
-@@ -643,8 +654,8 @@ int parse_arguments(int *argc, const cha
+@@ -640,8 +651,8 @@ int parse_arguments(int *argc, const cha
                                        goto options_rejected;
                        }
                        add_exclude_file(&exclude_list, arg, XFLG_FATAL_ERRORS
@@ -1141,7 +1183,7 @@ local instead of inherited (see also the 'n' option).
                        break;
  
                case 'h':
-@@ -668,6 +679,19 @@ int parse_arguments(int *argc, const cha
+@@ -665,6 +676,19 @@ int parse_arguments(int *argc, const cha
                        am_sender = 1;
                        break;
  
@@ -1149,11 +1191,11 @@ local instead of inherited (see also the 'n' option).
 +                      switch (++F_option_cnt) {
 +                      case 1:
 +                              add_exclude(&exclude_list,
-+                                          ": /.rsync-rules", 0);
++                                          ": /.rsync-filter", 0);
 +                              break;
 +                      case 2:
 +                              add_exclude(&exclude_list,
-+                                          "- .rsync-rules", 0);
++                                          "- .rsync-filter", 0);
 +                              break;
 +                      }
 +                      break;
@@ -1161,7 +1203,7 @@ local instead of inherited (see also the 'n' option).
                case 'P':
                        do_progress = 1;
                        keep_partial = 1;
-@@ -972,7 +996,7 @@ int parse_arguments(int *argc, const cha
+@@ -971,7 +995,7 @@ int parse_arguments(int *argc, const cha
                                partial_dir = NULL;
                        else if (*partial_dir != '/') {
                                add_exclude(&exclude_list, partial_dir,
@@ -1170,41 +1212,32 @@ local instead of inherited (see also the 'n' option).
                        }
                        keep_partial = 1;
                }
---- orig/rsync.h       2005-01-15 21:18:09
+--- orig/rsync.h       2005-01-21 00:35:26
 +++ rsync.h    2005-01-17 00:16:04
-@@ -62,7 +62,7 @@
- #define FLAG_MOUNT_POINT (1<<2)       /* sender only */
- /* update this if you make incompatible changes */
--#define PROTOCOL_VERSION 28
-+#define PROTOCOL_VERSION 29
- /* We refuse to interoperate with versions that are not in this range.
-  * Note that we assume we'll work with later versions: the onus is on
-@@ -108,9 +108,11 @@
+@@ -109,9 +109,11 @@
  
  #define XFLG_FATAL_ERRORS     (1<<0)
  #define XFLG_DEF_INCLUDE      (1<<1)
 -#define XFLG_WORDS_ONLY       (1<<2)
-+#define XFLG_NO_PREFIXES      (1<<2)
++#define XFLG_DEF_EXCLUDE      (1<<2)
  #define XFLG_WORD_SPLIT       (1<<3)
  #define XFLG_DIRECTORY                (1<<4)
-+#define XFLG_ABS_PATH         (1<<5)
-+#define XFLG_DEF_EXCLUDE      (1<<6)
++#define XFLG_NO_PREFIXES      (1<<5)
++#define XFLG_ABS_PATH         (1<<6)
  
  #define PERMS_REPORT          (1<<0)
  #define PERMS_SKIP_MTIME      (1<<1)
-@@ -512,11 +514,21 @@ struct map_struct {
+@@ -507,11 +509,21 @@ struct map_struct {
  #define MATCHFLG_INCLUDE      (1<<4) /* this is an include, not an exclude */
  #define MATCHFLG_DIRECTORY    (1<<5) /* this matches only directories */
  #define MATCHFLG_CLEAR_LIST   (1<<6) /* this item is the "!" token */
-+#define MATCHFLG_MERGE_FILE   (1<<7) /* specifies a file to merge */
++#define MATCHFLG_WORD_SPLIT   (1<<7) /* split rules on whitespace */
 +#define MATCHFLG_NO_INHERIT   (1<<8) /* don't inherit these rules */
-+#define MATCHFLG_PERDIR_MERGE (1<<9) /* merge-file is searched per-dir */
-+#define MATCHFLG_FINISH_SETUP (1<<10)/* per-dir merge file needs setup */
-+#define MATCHFLG_EXCLUDE_SELF (1<<11)/* merge-file name should be excluded */
-+#define MATCHFLG_NO_PREFIXES  (1<<12)/* parse no prefixes from patterns */
-+#define MATCHFLG_WORD_SPLIT   (1<<13)/* spilt on whitespace */
++#define MATCHFLG_NO_PREFIXES  (1<<9) /* parse no prefixes from patterns */
++#define MATCHFLG_MERGE_FILE   (1<<10)/* specifies a file to merge */
++#define MATCHFLG_PERDIR_MERGE (1<<11)/* merge-file is searched per-dir */
++#define MATCHFLG_EXCLUDE_SELF (1<<12)/* merge-file name should be excluded */
++#define MATCHFLG_FINISH_SETUP (1<<13)/* per-dir merge file needs setup */
  struct exclude_struct {
        struct exclude_struct *next;
        char *pattern;
@@ -1217,19 +1250,19 @@ local instead of inherited (see also the 'n' option).
  };
  
  struct exclude_list_struct {
---- orig/rsync.yo      2005-01-15 04:36:32
-+++ rsync.yo   2005-01-16 22:49:57
-@@ -361,6 +361,9 @@ verb(
+--- orig/rsync.yo      2005-01-24 00:18:21
++++ rsync.yo   2005-01-21 19:56:38
+@@ -362,6 +362,9 @@ verb(
   -P                          equivalent to --partial --progress
   -z, --compress              compress file data
   -C, --cvs-exclude           auto ignore files in the same way CVS does
 + -f, --filter=RULE           add a file-filtering RULE
-+ -F                          same as --filter=': /.rsync-rules'
-+                             repeated: --filter='- .rsync-rules'
++ -F                          same as --filter=': /.rsync-filter'
++                             repeated: --filter='- .rsync-filter'
       --exclude=PATTERN       exclude files matching PATTERN
       --exclude-from=FILE     exclude patterns listed in FILE
       --include=PATTERN       don't exclude files matching PATTERN
-@@ -754,14 +757,41 @@ Finally, any file is ignored if it is in
+@@ -764,14 +767,41 @@ Finally, any file is ignored if it is in
  .cvsignore file and matches one of the patterns listed therein.
  See the bf(cvs(1)) manual for more information.
  
@@ -1251,19 +1284,19 @@ local instead of inherited (see also the 'n' option).
 +your command.  The first time it is used is a shorthand for this rule:
 +
 +verb(
-+  --filter=': /.rsync-rules'
++  --filter=': /.rsync-filter'
 +)
 +
-+This tells rsync to look for per-directory .rsync-rules files that have
++This tells rsync to look for per-directory .rsync-filter files that have
 +been sprinkled through the hierarchy and use their rules to filter the
 +files in the transfer.  If -F is repeated, it is a shorthand for this
 +rule:
 +
 +verb(
-+  --filter='- .rsync-rules'
++  --filter='- .rsync-filter'
 +)
 +
-+This filters out the .rsync-rules files themselves from the transfer.
++This filters out the .rsync-filter files themselves from the transfer.
 +
 +See the FILTER RULES section for detailed information on how these options
 +work.
@@ -1276,7 +1309,7 @@ local instead of inherited (see also the 'n' option).
  
  dit(bf(--exclude-from=FILE)) This option is similar to the --exclude
  option, but instead it adds all exclude patterns listed in the file
-@@ -769,11 +799,11 @@ FILE to the exclude list.  Blank lines i
+@@ -779,11 +809,11 @@ FILE to the exclude list.  Blank lines i
  ';' or '#' are ignored.
  If em(FILE) is bf(-) the list will be read from standard input.
  
@@ -1292,7 +1325,7 @@ local instead of inherited (see also the 'n' option).
  
  dit(bf(--include-from=FILE)) This specifies a list of include patterns
  from a file.
-@@ -818,7 +848,8 @@ was located on the remote "src" host.
+@@ -828,7 +858,8 @@ was located on the remote "src" host.
  
  dit(bf(-0, --from0)) This tells rsync that the filenames it reads from a
  file are terminated by a null ('\0') character, not a NL, CR, or CR+LF.
@@ -1302,7 +1335,7 @@ local instead of inherited (see also the 'n' option).
  It does not affect --cvs-exclude (since all names read from a .cvsignore
  file are split on whitespace).
  
-@@ -957,8 +988,8 @@ If the partial-dir value is not an absol
+@@ -967,8 +998,8 @@ If the partial-dir value is not an absol
  will prevent partial-dir files from being transferred and also prevent the
  untimely deletion of partial-dir items on the receiving side.  An example:
  the above --partial-dir option would add an "--exclude=.rsync-partial/"
@@ -1313,7 +1346,7 @@ local instead of inherited (see also the 'n' option).
  rule for this directory exclusion somewhere higher up in the list so that
  it has a high enough priority to be effective (e.g., if your rules specify
  a trailing --exclude=* rule, the auto-added rule will be ineffective).
-@@ -1108,30 +1139,310 @@ page describing the options available fo
+@@ -1125,30 +1156,322 @@ page describing the options available fo
  
  enddit()
  
@@ -1336,7 +1369,7 @@ local instead of inherited (see also the 'n' option).
 +
 +As the list of files/directories to transfer is built, rsync checks each
 +name to be transferred against the list of include/exclude patterns in
-+turn, and t first matching pattern is acted on:  if it is an exclude
++turn, and the first matching pattern is acted on:  if it is an exclude
 +pattern, then that file is skipped; if it is an include pattern then that
 +filename is not skipped; if no matching pattern is found, then the
  filename is not skipped.
@@ -1351,15 +1384,14 @@ local instead of inherited (see also the 'n' option).
 +
 +itemize(
 +  it() x RULE
-+  it() x=RULE
 +  it() xMODIFIERS RULE
-+  it() xMODIFIERS=RULE
 +  it() !
 +)
 +
 +The 'x' is a single-letter that specifies the kind of rule to create.  It
-+can have trailing options, and is separated from the RULE by either a
-+single space or an equal-sign.  Here are the available rules:
++can have trailing modifiers, and is separated from the RULE by one of the
++following characters: a single space, an equal-sign (=), or an underscore
++(_).  Here are the available rule prefixes:
 +
 +verb(
 +  -  specifies an exclude pattern.
@@ -1369,20 +1401,23 @@ local instead of inherited (see also the 'n' option).
 +  !  clears the current include/exclude list
 +)
 +
-+Note that the include/exclude command-line options do not allow the full
-+range of rule parsing as described above -- they only allow the
++Note that the --include/--exclude command-line options do not allow the
++full range of rule parsing as described above -- they only allow the
 +specification of include/exclude patterns and the "!" token (not to
 +mention the comment lines when reading rules from a file).  If a pattern
 +does not begin with "- " (dash, space) or "+ " (plus, space), then the
 +rule will be interpreted as if "+ " (for an include option) or "- " (for
-+an exclude option) were prefixed to the string, and the resulting rule
-+passed to the --filter option.
++an exclude option) were prefixed to the string.  A --filter option, on
++the other hand, must always contain one of the prefixes above.
 +
 +Note also that the --filter, --include, and --exclude options take one
 +rule/pattern each. To add multiple ones, you can repeat the options on
 +the command-line, use the merge-file syntax of the --filter option, or
 +the --include-from/--exclude-from options.
 +
++When rules are being read from a file, empty lines are ignored, as are
++comment lines that start with a "#".
++
 +manpagesection(INCLUDE/EXCLUDE PATTERN RULES)
 +
 +You can include and exclude files by specifing patterns using the "+" and
@@ -1422,15 +1457,18 @@ local instead of inherited (see also the 'n' option).
 +  it() if the pattern contains a / (not counting a trailing /) or a "**"
 +  then it is matched against the full pathname, including any leading
 +  directories. If the pattern doesn't contain a / or a "**", then it is
-+  matched only against the final component of the filename.  Again,
-+  remember that the algorithm is applied recursively so "full filename" can
-+  actually be any portion of a path below the starting directory.
++  matched only against the final component of the filename.
++  (Remember that the algorithm is applied recursively so "full filename"
++  can actually be any portion of a path fomr the starting directory on
++  down.)
 +
 +)
 +
 +Note that, when using the --recursive (-r) option (which is implied by
 +-a), every subcomponent of every path is visited from the top down, so
-+include/exclude patterns get applied recursively to each subcomponent.
++include/exclude patterns get applied recursively to each subcomponent's
++full name (e.g. to include "/foo/bar/baz" the subcomponents "/foo" and
++"/foo/bar" must not be excluded).
 +The exclude patterns actually short-circuit the directory traversal stage
 +when rsync finds the files to send.  If a pattern excludes a particular
 +parent directory, it can render a deeper include pattern ineffectual
@@ -1447,8 +1485,8 @@ local instead of inherited (see also the 'n' option).
 +This fails because the parent directory "some" is excluded by the '*'
 +rule, so rsync never visits any of the files in the "some" or "some/path"
 +directories.  One solution is to ask for all directories in the hierarchy
-+to be included by using a single rule: "+ */" (put it somewhere before the
-+"- *" rule).  Another solution is to add specific include rules for all
++to be included by using a single rule: "+_*/" (put it somewhere before the
++"-_*" rule).  Another solution is to add specific include rules for all
 +the parent dirs that need to be visited.  For instance, this set of rules
 +works fine:
 +
@@ -1499,28 +1537,35 @@ local instead of inherited (see also the 'n' option).
 +
 +verb(
 +    . /etc/rsync/default.rules
-+    : .per-dir-rules
++    : .per-dir-filter
 +    :n- .non-inherited-per-dir-excludes
 +)
 +
 +The following modifiers are accepted after the "." or ":":
 +
 +itemize(
-+  it() A "-" or "+" specifies that the file should consist of only
-+  exclude (-) or include (+) patterns, with no other rule-parsing except
-+  for the list-clearing token ("!").
++  it() A "-" specifies that the file should consist of only exclude
++  patterns, with no other rule-parsing except for the list-clearing
++  token ("!").
++
++  it() A "+" specifies that the file should consist of only include
++  patterns, with no other rule-parsing except for the list-clearing
++  token ("!").
 +
 +  it() A "C" is a shorthand for the modifiers "sn-", which makes the
 +  parsing compatible with the way CVS parses their exclude files.  If no
 +  filename is specified, ".cvsignore" is assumed.
 +
 +  it() A "e" will exclude the merge-file from the transfer; e.g.
-+  ":e\ .rules" is like ":\ .rules" and "-\ .rules".
++  ":e_.rules" is like ":_.rules" and "-_.rules".
 +
 +  it() An "n" specifies that the rules are not inherited by subdirectories.
 +
 +  it() An "s" specifies that the rules are split on all whitespace instead
-+  of the normal line-splitting.  It also turns off comments.
++  of the normal line-splitting.  This also turns off comments.  Note: the
++  space that separates the prefix from the rule is treated specially, so
++  "- foo + bar" is parsed as two rules (assuming that "-" or "+" was not
++  specified to turn off the parsing of prefixes).
 +)
 +
 +Per-directory rules are inherited in all subdirectories of the directory
@@ -1542,14 +1587,14 @@ local instead of inherited (see also the 'n' option).
 +Here's an example filter file which you'd specify via --filter=". file":
 +
 +verb(
-+    . /home/user/.global-rules
++    . /home/user/.global-filter
 +    - *.gz
 +    : .rules
 +    + *.[ch]
 +    - *.o
 +)
 +
-+This will merge the contents of the /home/user/.global-rules file at the
++This will merge the contents of the /home/user/.global-filter file at the
 +start of the list and also turns the ".rules" filename into a per-directory
 +filter file.  All rules read-in prior to the start of the directory scan
 +follow the global anchoring rules (i.e. a leading slash matches at the root
@@ -1561,10 +1606,10 @@ local instead of inherited (see also the 'n' option).
 +per-directory file.  For instance, here is a common filter (see -F):
 +
 +verb(
-+  --filter=': /.rsync-rules'
++  --filter=': /.rsync-filter'
 +)
 +
-+That rule tells rsync to scan for the file .rsync-rules in all
++That rule tells rsync to scan for the file .rsync-filter in all
 +directories from the root down through the parent directory of the
 +transfer prior to the start of the normal directory scan of the file in
 +the directories that are sent as a part of the transfer.  (Note: for an
@@ -1574,19 +1619,19 @@ local instead of inherited (see also the 'n' option).
 +
 +verb(
 +  rsync -avF /src/path/ /dest/dir
-+  rsync -av --filter=': ../../.rsync-rules' /src/path/ /dest/dir
-+  rsync -av --fitler=': .rsync-rules' /src/path/ /dest/dir
++  rsync -av --filter=': ../../.rsync-filter' /src/path/ /dest/dir
++  rsync -av --fitler=': .rsync-filter' /src/path/ /dest/dir
 +)
 +
-+The first two commands above will look for ".rsync-rules" in "/" and
++The first two commands above will look for ".rsync-filter" in "/" and
 +"/src" before the normal scan begins looking for the file in "/src/path"
 +and its subdirectories.  The last command avoids the parent-dir scan
-+and only looks for the ".rsync-rules" files in each directory that is
++and only looks for the ".rsync-filter" files in each directory that is
 +a part of the transfer.
 +
 +If you want to include the contents of a ".cvsignore" in your patterns,
 +you should use the rule ":C" -- this is a short-hand for the rule
-+":sn-.cvsignore", and ensures that the .cvsignore file's contents are
++":sn-_.cvsignore", and ensures that the .cvsignore file's contents are
 +interpreted according to the same parsing rules that CVS uses.  You can
 +use this to affect where the --cvs-exclude (-C) option's inclusion of the
 +per-directory .cvsignore file gets placed into your rules by putting a
@@ -1640,7 +1685,7 @@ local instead of inherited (see also the 'n' option).
  
  Let's say that we want to match two source files, one with an absolute
  path of "/home/me/foo/bar", and one with a path of "/home/you/bar/baz".
-@@ -1163,114 +1474,59 @@ verb(
+@@ -1180,115 +1503,59 @@ verb(
     Target file: /dest/you/bar/baz
  )
  
@@ -1652,7 +1697,8 @@ local instead of inherited (see also the 'n' option).
 -Note that, when using the --recursive (-r) option (which is implied by -a),
 -every subcomponent of
 -every path is visited from the top down, so include/exclude patterns get
--applied recursively to each subcomponent.
+-applied recursively to each subcomponent's full name (e.g. to include
+-"/foo/bar/baz" the subcomponents "/foo" and "/foo/bar" must not be excluded).
 -The exclude patterns actually short-circuit the directory traversal stage
 -when rsync finds the files to send.  If a pattern excludes a particular
 -parent directory, it can render a deeper include pattern ineffectual
@@ -1662,9 +1708,14 @@ local instead of inherited (see also the 'n' option).
 -Note also that the --include and --exclude options take one pattern
 -each. To add multiple patterns use the --include-from and
 ---exclude-from options or multiple --include and --exclude options. 
--
++manpagesection(PER-DIRECTORY RULES AND DELETE)
 -The patterns can take several forms. The rules are:
--
++Without a delete option, per-directory rules are only relevant on the
++sending side, so you can feel free to exclude the merge files themselves
++without affecting the transfer.  To make this easy, the 'e' modifier adds
++this exclude for you, as seen in these two equivalent commands:
 -itemize(
 -
 -  it() if the pattern starts with a / then it is matched against the
@@ -1684,14 +1735,13 @@ local instead of inherited (see also the 'n' option).
 -  it() if the pattern contains a wildcard character from the set
 -  *?[ then expression matching is applied using the shell filename
 -  matching rules. Otherwise a simple string match is used.
-+manpagesection(PER-DIRECTORY RULES AND DELETE)
+-
 -  it() the double asterisk pattern "**" will match slashes while a
 -  single asterisk pattern "*" will stop at slashes.
-+Without a delete option, per-directory rules are only relevant on the
-+sending side, so you can feel free to exclude the merge files themselves
-+without affecting the transfer.  To make this easy, the 'e' modifier adds
-+this exclude for you, as seen in these two equivalent commands:
++verb(
++  rsync -av --filter=': .excl' --exclude=.excl host:src/dir /dest
++  rsync -av --filter=':e .excl' host:src/dir /dest
++)
  
 -  it() if the pattern contains a / (not counting a trailing /) or a "**"
 -  then it is matched against the full filename, including any leading
@@ -1699,11 +1749,7 @@ local instead of inherited (see also the 'n' option).
 -  matched only against the final component of the filename.  Again,
 -  remember that the algorithm is applied recursively so "full filename" can
 -  actually be any portion of a path below the starting directory.
-+verb(
-+  rsync -av --filter=': .excl' --exclude=.excl host:src/dir /dest
-+  rsync -av --filter=':e .excl' host:src/dir /dest
-+)
+-
 -  it() if the pattern starts with "+ " (a plus followed by a space)
 -  then it is always considered an include pattern, even if specified as
 -  part of an exclude option. The prefix is discarded before matching.
@@ -1767,8 +1813,8 @@ local instead of inherited (see also the 'n' option).
 +merged from the .rules files because they were specified after the
 +per-directory merge rule.
 +
-+In one final example, the remote side is excluding the .rsync-rules
-+files from the transfer, but we want to use our own .rsync-rules files
++In one final example, the remote side is excluding the .rsync-filter
++files from the transfer, but we want to use our own .rsync-filter files
 +to control what gets deleted on the receiving side.  To do this we must
 +specifically exclude the per-directory merge files (so that they don't get
 +deleted) and then put rules into the local files to control what else
@@ -1788,12 +1834,12 @@ local instead of inherited (see also the 'n' option).
 -  only foo/bar.c (the foo/ directory must be explicitly included or
 -  it would be excluded by the "*")
 +verb(
-+  rsync -av --filter=':e /.rsync-rules' --delete host:src/dir /dest
++  rsync -av --filter=':e /.rsync-filter' --delete host:src/dir /dest
 +  rsync -avFF --delete host:src/dir /dest
  )
  
  manpagesection(BATCH MODE)
-@@ -1439,7 +1695,7 @@ it. The most common cause is incorrectly
+@@ -1457,7 +1724,7 @@ it. The most common cause is incorrectly
  scripts (such as .cshrc or .profile) that contain output statements
  for non-interactive logins.
  
@@ -1802,13 +1848,35 @@ local instead of inherited (see also the 'n' option).
  try specifying the -vv option.  At this level of verbosity rsync will
  show why each individual file is included or excluded.
  
+--- orig/rsyncd.conf.yo        2005-01-01 21:11:01
++++ rsyncd.conf.yo     2005-01-17 06:49:39
+@@ -208,6 +208,16 @@ file transfers to and from that module s
+ was run as root. This complements the "uid" option. The default is gid -2,
+ which is normally the group "nobody".
++dit(bf(filter)) The "filter" option allows you to specify a space-separated
++list of filter rules that the server will not allow to be read or written.
++This is only superficially equivalent to the client specifying these
++patterns with the --filter option.  Only one "filter" option may be
++specified, but it may contain as many rules as you like, including
++merge-file rules.  Note that per-directory merge-file rules do not provide
++as much protection as global rules, but they can be used to make --delete
++work better when a client downloads the server's files (if the per-dir
++merge files are included in the transfer).
++
+ dit(bf(exclude)) The "exclude" option allows you to specify a
+ space-separated list of patterns that the server will not allow to be read
+ or written.  This is only superficially equivalent to the client
 --- orig/testsuite/exclude.test        2004-05-29 21:25:45
-+++ testsuite/exclude.test     2005-01-17 00:15:40
-@@ -23,19 +23,47 @@ export HOME CVSIGNORE
++++ testsuite/exclude.test     2005-01-17 06:19:10
+@@ -23,19 +23,50 @@ export HOME CVSIGNORE
  makepath "$fromdir/foo/down/to/you"
  makepath "$fromdir/bar/down/to/foo/too"
  makepath "$fromdir/mid/for/foo/and/that/is/who"
 +cat >"$fromdir/.excl" <<EOF
++- down
++: .excl-temp
++!
 +- .excl
 +- *.bak
 +- *.old
@@ -1852,7 +1920,25 @@ local instead of inherited (see also the 'n' option).
  echo cvsin >"$fromdir/mid/for/one-in-one-out"
  echo expunged >"$fromdir/mid/for/foo/extra"
  echo retained >"$fromdir/mid/for/foo/keep"
-@@ -97,7 +125,26 @@ $RSYNC -av --existing --include='*/' --e
+@@ -45,6 +76,7 @@ ln -s too "$fromdir/bar/down/to/foo/sym"
+ excl="$scratchdir/exclude-from"
+ cat >"$excl" <<EOF
++!
+ # If the second line of these two lines does anything, it's a bug.
+ + **/bar
+ - /bar
+@@ -82,7 +114,8 @@ $RSYNC -av --existing --include='*/' --e
+ # Now, test if rsync excludes the same files.
+-checkit "$RSYNC -avv --exclude-from=\"$excl\" \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
++checkit "$RSYNC -avv --exclude-from=\"$excl\" \
++    --delete \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
+ # Modify the chk dir by removing cvs-ignored files and then tweaking the dir times.
+@@ -97,7 +130,26 @@ $RSYNC -av --existing --include='*/' --e
  # Now, test if rsync excludes the same files, this time with --cvs-exclude
  # and --delete-excluded.
  
@@ -1876,7 +1962,7 @@ local instead of inherited (see also the 'n' option).
 +# Now, test if rsync excludes the same files, this time with a merge-exclude
 +# file.
 +
-+checkit "$RSYNC -avv --filter=': .excl' --filter=\". $excl\" \
++checkit "sed '/!/d' \"$excl\" | $RSYNC -avv -f :_.excl -f ._- \
      --delete-excluded \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
  
  # The script would have aborted on error, so getting here means we've won.