summaryrefslogtreecommitdiff
path: root/builtin/grep.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-01-21 13:00:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-01-22 00:57:38 (GMT)
commit0b0ecaac2ad984599923999d6d4c32e6111bb73f (patch)
treec562068adb24c8321271e48dd94fb45685a7d5c6 /builtin/grep.c
parent4db86e8b6e8002b3113341ad742bf2fd94d4df50 (diff)
downloadgit-0b0ecaac2ad984599923999d6d4c32e6111bb73f.zip
git-0b0ecaac2ad984599923999d6d4c32e6111bb73f.tar.gz
git-0b0ecaac2ad984599923999d6d4c32e6111bb73f.tar.bz2
grep: avoid accepting ambiguous revision
Unlike other commands that take both revs and pathspecs without "--" disamiguators only when the boundary is clear, "git grep" treated what can be interpreted as a rev as-is, without making sure that it could also have meant a pathspec. E.g. $ git grep -e foo master when 'master' is in the working tree, should have triggered an ambiguity error, but it didn't, and searched in the tree of the commit named by 'master'. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/grep.c')
-rw-r--r--builtin/grep.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 0e1b6c8..8025964 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -823,6 +823,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
struct object *object = parse_object(sha1);
if (!object)
die(_("bad object %s"), arg);
+ if (!seen_dashdash)
+ verify_non_filename(prefix, arg);
add_object_array(object, arg, &list);
continue;
}