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>
This commit is contained in:

committed by
Junio C Hamano

parent
4db86e8b6e
commit
0b0ecaac2a
@ -823,6 +823,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
|
|||||||
struct object *object = parse_object(sha1);
|
struct object *object = parse_object(sha1);
|
||||||
if (!object)
|
if (!object)
|
||||||
die(_("bad object %s"), arg);
|
die(_("bad object %s"), arg);
|
||||||
|
if (!seen_dashdash)
|
||||||
|
verify_non_filename(prefix, arg);
|
||||||
add_object_array(object, arg, &list);
|
add_object_array(object, arg, &list);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user