From: Finn Arne Gangstad Date: Thu, 12 Feb 2009 09:32:50 GMT Subject: [PATCH v3] Support "\" in non-wildcard exclusion entries Message-ID: <20090212093250.GA9623@pvv.org> In-Reply-To: <7v7i3ynt1z.fsf@gitster.siamese.dyndns.org> On Tue, Feb 10, 2009 at 08:41:12AM -0800, Junio C Hamano wrote: > Junio C Hamano writes: > > Oh, by the way, do we really want to add a new test script? I am > wondering why the test is not an update to an existing test for the > exclusion feature, such as t/t3001-ls-files-others-exclude.sh Ok, here is the final version with your suggested test-modification, which seems to to the trick! - Finn Arne --8<-- Support "\" in non-wildcard exclusion entries "\" was treated differently in exclude rules depending on whether a wildcard match was done. For wildcard rules, "\" was de-escaped in fnmatch, but this was not done for other rules since they used strcmp instead. A file named "#foo" would not be excluded by "\#foo", but would be excluded by "\#foo*". We now treat all rules with "\" as wildcard rules. Another solution could be to de-escape all non-wildcard rules as we read them, but we would have to do the de-escaping exactly as fnmatch does it to avoid inconsistencies. Signed-off-by: Finn Arne Gangstad --- dir.c | 2 +- t/t3001-ls-files-others-exclude.sh | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletions(-) diff --git a/dir.c b/dir.c index cfd1ea5..2245749 100644 --- a/dir.c +++ b/dir.c @@ -137,7 +137,7 @@ int match_pathspec(const char **pathspec, const char *name, int namelen, static int no_wildcard(const char *string) { - return string[strcspn(string, "*?[{")] == '\0'; + return string[strcspn(string, "*?[{\\")] == '\0'; } void add_exclude(const char *string, const char *base, diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index 85aef12..9be9557 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -19,6 +19,9 @@ do >$dir/a.$i done done +>"#ignore1" +>"#ignore2" +>"#hidden" cat >expect < excludes-file << EOF *.[1-8] e* +\#* EOF git config core.excludesFile excludes-file -- 1.6.2.rc0.11.g665ed