3 test_description
='colored git blame'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_CREATE_REPO_NO_TEMPLATE
=1
8 TEST_PASSES_SANITIZE_LEAK
=true
12 .
"$TEST_DIRECTORY"/annotate-tests.sh
14 test_expect_success
'colored blame colors contiguous lines' '
15 git -c color.blame.repeatedLines=yellow blame --color-lines --abbrev=12 hello.c >actual.raw &&
16 git -c color.blame.repeatedLines=yellow -c blame.coloring=repeatedLines blame --abbrev=12 hello.c >actual.raw.2 &&
17 test_cmp actual.raw actual.raw.2 &&
18 test_decode_color <actual.raw >actual &&
19 grep "<YELLOW>" <actual >darkened &&
20 grep "(F" darkened > F.expect &&
21 grep "(H" darkened > H.expect &&
22 test_line_count = 2 F.expect &&
23 test_line_count = 3 H.expect
26 test_expect_success
'color by age consistently colors old code' '
27 git blame --color-by-age hello.c >actual.raw &&
28 git -c blame.coloring=highlightRecent blame hello.c >actual.raw.2 &&
29 test_cmp actual.raw actual.raw.2 &&
30 test_decode_color <actual.raw >actual &&
31 grep "<BLUE>" <actual >colored &&
32 test_line_count = 10 colored
35 test_expect_success
'blame color by age: new code is different' '
36 cat >>hello.c <<-EOF &&
40 GIT_AUTHOR_DATE="" git commit -m "new commit" &&
42 git -c color.blame.highlightRecent="yellow,1 month ago, cyan" blame --color-by-age hello.c >actual.raw &&
43 test_decode_color <actual.raw >actual &&
45 grep "<YELLOW>" <actual >colored &&
46 test_line_count = 10 colored &&
48 grep "<CYAN>" <actual >colored &&
49 test_line_count = 1 colored &&