All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Support \ in non-wildcard .gitignore entries
@ 2009-02-10 12:11 Finn Arne Gangstad
  2009-02-10 12:56 ` Johannes Schindelin
  0 siblings, 1 reply; 13+ messages in thread
From: Finn Arne Gangstad @ 2009-02-10 12:11 UTC (permalink / raw)
  To: git, gitster

If you had an exclude-pattern with a backslash in it, e.g. "\#foo",
this would not work, since git would do a strcmp of the exclude pattern
and the filename. Only wildcard patterns were matched with fnmatch,
which does the right thing with backslashes. We now also treat all patterns
containing backslashes as wildcards.

De-escaping the pattern while reading the .gitignore file is error prone,
since that would break patterns with both backslashes and wildcards.
E.g. "\\*.c" would be translated to "\*.c" before fnmatch got it,
and would change the meaning of the rule dramatically.

Signed-off-by: Finn Arne Gangstad <finnag@pvv.org>
---
 dir.c |    2 +-
 1 files changed, 1 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,
-- 
1.6.2.rc0.11.g68cbb.dirty

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-02-12 21:05 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-10 12:11 [PATCH] Support \ in non-wildcard .gitignore entries Finn Arne Gangstad
2009-02-10 12:56 ` Johannes Schindelin
2009-02-10 12:58   ` Finn Arne Gangstad
2009-02-10 13:02     ` Johannes Schindelin
2009-02-10 14:20       ` [PATCH v2] Support "\" in non-wildcard exclusion entries Finn Arne Gangstad
2009-02-10 14:27         ` Johannes Schindelin
2009-02-10 14:37           ` Finn Arne Gangstad
2009-02-10 15:24             ` Junio C Hamano
2009-02-10 16:41               ` Junio C Hamano
2009-02-10 17:23                 ` Finn Arne Gangstad
2009-02-12  9:32                 ` [PATCH v3] " Finn Arne Gangstad
2009-02-12 10:44                   ` Johannes Schindelin
2009-02-12 21:03                     ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.