Paul Slootman
2005-Sep-16 13:28 UTC
Bug#314473: rsync still fails badly with an "!" in .cvsignore
Here a bug report about "!" not working properly in 2.6.4 and above, paraphrased...> Ok, see attachment. I've tested it right now between two hosts > running rsync 2.6.3-2 and 2.6.6-1. It works in the forward direction, > backwards it gives > > '!' rule has trailing characters: ! > rsync error: syntax or usage error (code 1) at exclude.c(833)> --------------------------------------------------------------------------- > #! /bin/bash -ex > > echo '!' > ~/.cvsignore > echo '*~' >> ~/.cvsignore > rm -rf /tmp/tester > mkdir /tmp/tester > cp /etc/passwd /tmp/tester > cp /tmp/tester/passwd{,~} > rsync -avbu --cvs-exclude --delete /tmp/tester remotehost:/tmp/I've found that when "!" was scanned, the pointer was not advanced, hence there appeared to be trailing chars... The following patch seems to fix it. Paul Slootman --- rsync-2.6.6.orig/exclude.c +++ rsync-2.6.6/exclude.c @@ -665,8 +665,10 @@ * for old include/exclude patterns where just "+ " and "- " are * allowed as optional prefixes. */ if (mflags & MATCHFLG_NO_PREFIXES) { - if (*s == '!' && mflags & MATCHFLG_CVS_IGNORE) + if (*s == '!' && mflags & MATCHFLG_CVS_IGNORE) { new_mflags |= MATCHFLG_CLEAR_LIST; /* Tentative! */ + s++; + } } else if (xflags & XFLG_OLD_PREFIXES) { if (*s == '-' && s[1] == ' ') { new_mflags &= ~MATCHFLG_INCLUDE; @@ -674,8 +676,10 @@ } else if (*s == '+' && s[1] == ' ') { new_mflags |= MATCHFLG_INCLUDE; s += 2; - } else if (*s == '!') + } else if (*s == '!') { new_mflags |= MATCHFLG_CLEAR_LIST; /* Tentative! */ + s++; + } } else { char ch = 0, *mods = ""; switch (*s) {
Wayne Davison
2005-Sep-16 16:09 UTC
Bug#314473: rsync still fails badly with an "!" in .cvsignore
On Fri, Sep 16, 2005 at 03:27:22PM +0200, Paul Slootman wrote:> I've found that when "!" was scanned, the pointer was not advanced, > hence there appeared to be trailing chars... The following patch seems > to fix it.No, the pointer must not be advanced or it will not properly handle names that start with a '!'. Thus, your patch creates a new bug. The problem is that the length-check was trying to only complain about fitler rules, but it also accidentally complaind about cvsignore rules. The fix is attached. ..wayne.. -------------- next part -------------- --- exclude.c 29 Jul 2005 18:31:07 -0000 1.119 +++ exclude.c 16 Sep 2005 16:07:14 -0000 @@ -827,7 +827,8 @@ static const char *parse_rule_tok(const len = strlen((char*)s); if (new_mflags & MATCHFLG_CLEAR_LIST) { - if (!(xflags & XFLG_OLD_PREFIXES) && len) { + if (!(mflags & MATCHFLG_NO_PREFIXES) + && !(xflags & XFLG_OLD_PREFIXES) && len) { rprintf(FERROR, "'!' rule has trailing characters: %s\n", p); exit_cleanup(RERR_SYNTAX);