Skip to content

Commit 0b0ecaa

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4db86e8 commit 0b0ecaa

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

builtin/grep.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
823823
struct object *object = parse_object(sha1);
824824
if (!object)
825825
die(_("bad object %s"), arg);
826+
if (!seen_dashdash)
827+
verify_non_filename(prefix, arg);
826828
add_object_array(object, arg, &list);
827829
continue;
828830
}

0 commit comments

Comments
 (0)