Merge branch 'jk/use-compat-util-in-test-tool'
[git/raj.git] / t / t8012-blame-colors.sh
blobed38f74de95c92b358cc9a27d2470e890b9bdbb3
1 #!/bin/sh
3 test_description='colored git blame'
4 . ./test-lib.sh
6 PROG='git blame -c'
7 . "$TEST_DIRECTORY"/annotate-tests.sh
9 test_expect_success 'colored blame colors contiguous lines' '
10 git -c color.blame.repeatedLines=yellow blame --color-lines --abbrev=12 hello.c >actual.raw &&
11 git -c color.blame.repeatedLines=yellow -c blame.coloring=repeatedLines blame --abbrev=12 hello.c >actual.raw.2 &&
12 test_cmp actual.raw actual.raw.2 &&
13 test_decode_color <actual.raw >actual &&
14 grep "<YELLOW>" <actual >darkened &&
15 grep "(F" darkened > F.expect &&
16 grep "(H" darkened > H.expect &&
17 test_line_count = 2 F.expect &&
18 test_line_count = 3 H.expect
21 test_expect_success 'color by age consistently colors old code' '
22 git blame --color-by-age hello.c >actual.raw &&
23 git -c blame.coloring=highlightRecent blame hello.c >actual.raw.2 &&
24 test_cmp actual.raw actual.raw.2 &&
25 test_decode_color <actual.raw >actual &&
26 grep "<BLUE>" <actual >colored &&
27 test_line_count = 10 colored
30 test_expect_success 'blame color by age: new code is different' '
31 cat >>hello.c <<-EOF &&
32 void qfunc();
33 EOF
34 git add hello.c &&
35 GIT_AUTHOR_DATE="" git commit -m "new commit" &&
37 git -c color.blame.highlightRecent="yellow,1 month ago, cyan" blame --color-by-age hello.c >actual.raw &&
38 test_decode_color <actual.raw >actual &&
40 grep "<YELLOW>" <actual >colored &&
41 test_line_count = 10 colored &&
43 grep "<CYAN>" <actual >colored &&
44 test_line_count = 1 colored &&
45 grep qfunc colored
48 test_done