summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4170af8)
raw | patch | inline | side by side (parent: 4170af8)
author | Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de> | |
Wed, 21 Jun 2006 09:04:12 +0000 (11:04 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 21 Jun 2006 09:30:46 +0000 (02:30 -0700) |
If match is "", match[-1] is accessed. Let pathspec_matches return 1 in that
case indicating that "" matches everything.
Incidently this fixes git-grep'ing in ".".
Signed-off-by: Uwe Zeisberger <Uwe_Zeisberger@digi.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
case indicating that "" matches everything.
Incidently this fixes git-grep'ing in ".".
Signed-off-by: Uwe Zeisberger <Uwe_Zeisberger@digi.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-grep.c | patch | blob | history |
diff --git a/builtin-grep.c b/builtin-grep.c
index 9806499263dcb92c7a6903ead36646baf676b178..f7767bb4eeacf4d4c06ef54e6bb3f4099e96d198 100644 (file)
--- a/builtin-grep.c
+++ b/builtin-grep.c
int matchlen = strlen(match);
const char *cp, *meta;
- if ((matchlen <= namelen) &&
- !strncmp(name, match, matchlen) &&
- (match[matchlen-1] == '/' ||
- name[matchlen] == '\0' || name[matchlen] == '/'))
+ if (!matchlen ||
+ ((matchlen <= namelen) &&
+ !strncmp(name, match, matchlen) &&
+ (match[matchlen-1] == '/' ||
+ name[matchlen] == '\0' || name[matchlen] == '/')))
return 1;
if (!fnmatch(match, name, 0))
return 1;