summaryrefslogtreecommitdiff
path: root/builtin/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-01-20 19:43:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-01-20 19:43:39 (GMT)
commit52bae62f7888edf5e87ef85bbe04803474f67c10 (patch)
treea4f85d775b4dacc8356f99de3bbfd4d33cc3269f /builtin/grep.c
parent569ff48deb0d36f9e80c4d03d78e8b507820dc57 (diff)
parentecd9ba61778e436dde12f08781a12ad1149d5ebf (diff)
downloadgit-52bae62f7888edf5e87ef85bbe04803474f67c10.zip
git-52bae62f7888edf5e87ef85bbe04803474f67c10.tar.gz
git-52bae62f7888edf5e87ef85bbe04803474f67c10.tar.bz2
Merge branch 'tg/grep-no-index-fallback'
"git grep" by default does not fall back to its "--no-index" behaviour outside a directory under Git's control (otherwise the user may by mistake end up running a huge recursive search); with a new configuration (set in $HOME/.gitconfig--by definition this cannot be set in the config file per project), this safety can be disabled. * tg/grep-no-index-fallback: builtin/grep: add grep.fallbackToNoIndex config t7810: correct --no-index test
Diffstat (limited to 'builtin/grep.c')
-rw-r--r--builtin/grep.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 06ab682..5526fd7 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -768,9 +768,15 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
PARSE_OPT_STOP_AT_NON_OPTION);
grep_commit_pattern_type(pattern_type_arg, &opt);
- if (use_index && !startup_info->have_repository)
- /* die the same way as if we did it at the beginning */
- setup_git_directory();
+ if (use_index && !startup_info->have_repository) {
+ int fallback = 0;
+ git_config_get_bool("grep.fallbacktonoindex", &fallback);
+ if (fallback)
+ use_index = 0;
+ else
+ /* die the same way as if we did it at the beginning */
+ setup_git_directory();
+ }
/*
* skip a -- separator; we know it cannot be