From: Junio C Hamano Date: Thu, 30 Jun 2011 00:03:13 +0000 (-0700) Subject: Merge branch 'rs/grep-color' X-Git-Tag: v1.7.7-rc0~119 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/1692d0c64a6386ae08d12ed90c9d975911451cbe?ds=inline;hp=-c Merge branch 'rs/grep-color' * rs/grep-color: grep: add --heading grep: add --break grep: fix coloring of hunk marks between files --- 1692d0c64a6386ae08d12ed90c9d975911451cbe diff --combined t/t7810-grep.sh index 6379ad60bc,1227fa69b4..a29ae45b39 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@@ -658,9 -658,9 +658,9 @@@ test_expect_success LIBPCRE 'grep -P - ' test_expect_success LIBPCRE 'grep -P -i pattern' ' - { - echo "hello.c: printf(\"Hello world.\n\");" - } >expected && + cat >expected <<-EOF && + hello.c: printf("Hello world.\n"); + EOF git grep -P -i "PRINTF\([^\d]+\)" hello.c >actual && test_cmp expected actual ' @@@ -716,4 -716,99 +716,99 @@@ test_expect_success LIBPCRE 'grep -G - test_cmp expected actual ' + test_config() { + git config "$1" "$2" && + test_when_finished "git config --unset $1" + } + + cat >expected <:int main(int argc, const char **argv) + hello.c-{ + -- + hello.c: /* char ?? */ + hello.c-} + -- + hello_world:Hello_world + hello_world-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 + ' + + cat >expected <actual && + test_cmp expected actual + ' + + cat >expected <actual && + test_cmp expected actual + ' + + cat >expected <actual && + test_cmp expected actual + ' + + cat >expected <hello.c + 2:int main(int argc, const char **argv) + 6: /* char ?? */ + + hello_world + 3:Hello_world + EOF + + test_expect_success 'mimic ack-grep --group' ' + test_config color.grep.context normal && + test_config color.grep.filename "bold green" && + test_config color.grep.function normal && + test_config color.grep.linenumber normal && + test_config color.grep.match "black yellow" && + test_config color.grep.selected normal && + test_config color.grep.separator normal && + + git grep --break --heading -n --color \ + -e char -e lo_w hello.c hello_world | + test_decode_color >actual && + test_cmp expected actual + ' + test_done