summaryrefslogtreecommitdiff
path: root/builtin/grep.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2016-01-20 11:43:38 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-01-20 11:43:39 -0800
commit52bae62f7888edf5e87ef85bbe04803474f67c10 (patch)
treea4f85d775b4dacc8356f99de3bbfd4d33cc3269f /builtin/grep.c
parentMerge branch 'ho/gitweb-squelch-undef-warning' (diff)
parentbuiltin/grep: add grep.fallbackToNoIndex config (diff)
downloadtgif-52bae62f7888edf5e87ef85bbe04803474f67c10.tar.xz
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 06ab68223a..5526fd7056 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