diff options
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | 2011-06-05 17:24:15 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-06-05 18:10:50 -0700 |
commit | 08303c3636ef750bfafd1c47f363120cb439b367 (patch) | |
tree | 4f6f843c4e7381b2c066d7f837ae3a406ca0fffd /t/t7810-grep.sh | |
parent | a6605d76cdad37ed3c55a7be4d2e0af0f4721bb2 (diff) | |
download | git-08303c3636ef750bfafd1c47f363120cb439b367.tar.gz |
grep: fix coloring of hunk marks between files
Commit 431d6e7b (grep: enable threading for context line printing)
split the printing of the "--\n" mark between results from different
files out into two places: show_line() in grep.c for the non-threaded
case and work_done() in builtin/grep.c for the threaded case. Commit
55f638bd (grep: Colorize filename, line number, and separator) updated
the former, but not the latter, so the separators between files are
not colored if threads are used.
This patch merges the two. In the threaded case, hunk marks are now
printed by show_line() for every file, including the first one, and the
very first mark is simply skipped in work_done(). This ensures that the
output is properly colored and works just as well.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7810-grep.sh')
-rwxr-xr-x | t/t7810-grep.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 69bd576d1c..539a8fe6e9 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -716,4 +716,34 @@ test_expect_success LIBPCRE 'grep -G -F -E -P pattern' ' test_cmp expected actual ' +test_config() { + git config "$1" "$2" && + test_when_finished "git config --unset $1" +} + +cat >expected <<EOF +hello.c<RED>:<RESET>int main(int argc, const char **argv) +hello.c<RED>-<RESET>{ +<RED>--<RESET> +hello.c<RED>:<RESET> /* char ?? */ +hello.c<RED>-<RESET>} +<RED>--<RESET> +hello_world<RED>:<RESET>Hello_world +hello_world<RED>-<RESET>HeLLo_world +EOF + +test_expect_success 'grep --color, separator' ' + test_config color.grep.context normal && + test_config color.grep.filename normal && + test_config color.grep.function normal && + test_config color.grep.linenumber normal && + test_config color.grep.match normal && + test_config color.grep.selected normal && + test_config color.grep.separator red && + + git grep --color=always -A1 -e char -e lo_w hello.c hello_world | + test_decode_color >actual && + test_cmp expected actual +' + test_done |