grep: error out if --untracked is used with --cached
The options --untracked and --cached are not compatible, but if they are used together, grep just silently ignores --cached and searches the working tree. Error out, instead, to avoid any potential confusion. Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
773e25afc4
commit
0c5d83b248
@ -1157,6 +1157,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);
|
||||
|
Loading…
Reference in New Issue
Block a user