summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 773b69b)
raw | patch | inline | side by side (parent: 773b69b)
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | |
Fri, 6 Aug 2010 03:06:39 +0000 (22:06 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 11 Aug 2010 16:24:26 +0000 (09:24 -0700) |
git grep already runs a repository search unconditionally,
even when the --no-index option is supplied; running such a
search earlier is not very risky.
Just like with shortlog, without this change, the
“[pager] grep” configuration is not respected at all.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
even when the --no-index option is supplied; running such a
search earlier is not very risky.
Just like with shortlog, without this change, the
“[pager] grep” configuration is not respected at all.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/grep.c | patch | blob | history | |
git.c | patch | blob | history | |
t/t7006-pager.sh | patch | blob | history |
diff --git a/builtin/grep.c b/builtin/grep.c
index 597f76bc42f51e0fc1906c287981e3d37dc0f536..ca56c5b0099e19059b51440880d032c5e1d27f5e 100644 (file)
--- a/builtin/grep.c
+++ b/builtin/grep.c
struct string_list path_list = { NULL, 0, 0, 0 };
int i;
int dummy;
- int nongit = 0, use_index = 1;
+ int use_index = 1;
struct option options[] = {
OPT_BOOLEAN(0, "cached", &cached,
"search in index instead of in the work tree"),
OPT_END()
};
- prefix = setup_git_directory_gently(&nongit);
-
/*
* 'git grep -h', unlike 'git grep -h <pattern>', is a request
* to show usage information and exit.
PARSE_OPT_STOP_AT_NON_OPTION |
PARSE_OPT_NO_INTERNAL_HELP);
- if (use_index && nongit)
+ if (use_index && !startup_info->have_repository)
/* die the same way as if we did it at the beginning */
setup_git_directory();
index 3d96c2bcd30cf22f452abcdd44c214d2f2b4d579..5a47bfbcbd39b7e6ec5b2bbc358f63fb134120c1 100644 (file)
--- a/git.c
+++ b/git.c
{ "fsck-objects", cmd_fsck, RUN_SETUP },
{ "gc", cmd_gc, RUN_SETUP },
{ "get-tar-commit-id", cmd_get_tar_commit_id },
- { "grep", cmd_grep },
+ { "grep", cmd_grep, RUN_SETUP_GENTLY },
{ "hash-object", cmd_hash_object },
{ "help", cmd_help },
{ "index-pack", cmd_index_pack },
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index 43b310218ae7a4b17e66f3b5949cf42218da07c8..bb9533581ebaf57eb2f4904dcd41d13b85e78270 100755 (executable)
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
! test -e paginated.out
'
+test_expect_success TTY 'configuration can disable pager' '
+ rm -f paginated.out &&
+ test_might_fail git config --unset pager.grep &&
+ test_terminal git grep initial &&
+ test -e paginated.out &&
+
+ rm -f paginated.out &&
+ git config pager.grep false &&
+ test_when_finished "git config --unset pager.grep" &&
+ test_terminal git grep initial &&
+ ! test -e paginated.out
+'
+
# A colored commit log will begin with an appropriate ANSI escape
# for the first color; the text "commit" comes later.
colorful() {