summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-02-18 01:21:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-02-18 01:21:41 (GMT)
commitf712632a518ffd2611ae4a33cce43b53c73ce2c1 (patch)
treea7d5a439805e9b6ea99eb6be665d6e9056cc2711 /builtin
parent78a26cb7204ddb96a5f75f09e41fbefd81c85f59 (diff)
parent0c5d83b2484c027971b793c442d147979c7e1a04 (diff)
downloadgit-f712632a518ffd2611ae4a33cce43b53c73ce2c1.zip
git-f712632a518ffd2611ae4a33cce43b53c73ce2c1.tar.gz
git-f712632a518ffd2611ae4a33cce43b53c73ce2c1.tar.bz2
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
Diffstat (limited to 'builtin')
-rw-r--r--builtin/grep.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 55d06c9..e348e6b 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -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);