1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-31 23:36:10 +02:00

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
This commit is contained in:
Junio C Hamano 2021-02-17 17:21:41 -08:00
commit f712632a51

View File

@ -1152,6 +1152,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
if (!use_index && (untracked || cached))
die(_("--cached or --untracked cannot be used with --no-index"));
if (untracked && cached)
die(_("--untracked cannot be used with --cached"));
if (!use_index || untracked) {
int use_exclude = (opt_exclude < 0) ? use_index : !!opt_exclude;
hit = grep_directory(&opt, &pathspec, use_exclude, use_index);