From a2b45a5dd5e5e97015650b029614f1147bc9e60d Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Sat, 20 Apr 2013 18:32:01 +0200 Subject: [PATCH] git grep: honor textconv by default Currently, "git grep" does not honor textconv settings by default. Make it honor them by default just like "git log --grep" does. --- Documentation/git-grep.txt | 2 +- grep.c | 2 ++ t/t7008-grep-binary.sh | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt index a5c5a27da4..f54ac0c37a 100644 --- a/Documentation/git-grep.txt +++ b/Documentation/git-grep.txt @@ -82,10 +82,10 @@ OPTIONS --textconv:: Honor textconv filter settings. + This is the default. --no-textconv:: Do not honor textconv filter settings. - This is the default. -i:: --ignore-case:: diff --git a/grep.c b/grep.c index c668034739..161d3f099a 100644 --- a/grep.c +++ b/grep.c @@ -31,6 +31,7 @@ void init_grep_defaults(void) opt->max_depth = -1; opt->pattern_type_option = GREP_PATTERN_TYPE_UNSPECIFIED; opt->extended_regexp_option = 0; + opt->allow_textconv = 1; strcpy(opt->color_context, ""); strcpy(opt->color_filename, ""); strcpy(opt->color_function, ""); @@ -134,6 +135,7 @@ void grep_init(struct grep_opt *opt, const char *prefix) opt->pathname = def->pathname; opt->regflags = def->regflags; opt->relative = def->relative; + opt->allow_textconv = def->allow_textconv; strcpy(opt->color_context, def->color_context); strcpy(opt->color_filename, def->color_filename); diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh index 10b2c8b810..2fc9d9cb79 100755 --- a/t/t7008-grep-binary.sh +++ b/t/t7008-grep-binary.sh @@ -156,7 +156,7 @@ test_expect_success 'setup textconv filters' ' git config diff.foo.textconv "\"$(pwd)\""/nul_to_q_textconv ' -test_expect_failure 'grep does not honor textconv' ' +test_expect_success 'grep does honor textconv' ' echo "a:binaryQfile" >expect && git grep Qfile >actual && test_cmp expect actual @@ -172,7 +172,7 @@ test_expect_success 'grep --no-textconv does not honor textconv' ' test_must_fail git grep --no-textconv Qfile ' -test_expect_failure 'grep blob does not honor textconv' ' +test_expect_success 'grep blob does honor textconv' ' echo "HEAD:a:binaryQfile" >expect && git grep Qfile HEAD:a >actual && test_cmp expect actual -- 2.11.4.GIT