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>

Nguyễn Thái Ngọc Duy committed Jan 21, 2013 at 20:00 UTC 0b0ecaac2ad984599923999d6d4c32e6111bb73f
1 file changed +2
builtin/grep.c
+2
@@ -823,6 +823,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
823 struct object *object = parse_object(sha1);
824 if (!object)
825 die(_("bad object %s"), arg);
826 + if (!seen_dashdash)
827 + verify_non_filename(prefix, arg);
828 add_object_array(object, arg, &list);
829 continue;
830 }