diff options
author | Matheus Tavares <matheus.bernardino@usp.br> | 2021-02-08 16:43:28 -0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-02-09 12:39:06 -0800 |
commit | 0c5d83b2484c027971b793c442d147979c7e1a04 (patch) | |
tree | 155254ee5db22a818e338212c2af5d51407a3275 /builtin/grep.c | |
parent | 773e25afc41b1b6533fa9ae2cd825d0b4a697fad (diff) | |
download | git-0c5d83b2484c027971b793c442d147979c7e1a04.tar.gz |
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>
Diffstat (limited to 'builtin/grep.c')
-rw-r--r-- | builtin/grep.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index ca259af441..392acf8cab 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -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); |