Skip to content

Commit f712632

Browse files
committed
Merge branch 'mt/grep-cached-untracked'
"git grep --untracked" is meant to be "let's ALSO find in these files on the filesystem" when looking for matches in the working tree files, and does not make any sense if the primary search is done against the index, or the tree objects. The "--cached" and "--untracked" options have been marked as mutually incompatible. * mt/grep-cached-untracked: grep: error out if --untracked is used with --cached
2 parents 78a26cb + 0c5d83b commit f712632

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

builtin/grep.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
11521152
if (!use_index && (untracked || cached))
11531153
die(_("--cached or --untracked cannot be used with --no-index"));
11541154

1155+
if (untracked && cached)
1156+
die(_("--untracked cannot be used with --cached"));
1157+
11551158
if (!use_index || untracked) {
11561159
int use_exclude = (opt_exclude < 0) ? use_index : !!opt_exclude;
11571160
hit = grep_directory(&opt, &pathspec, use_exclude, use_index);

0 commit comments

Comments
 (0)