]> git.ipfire.org Git - thirdparty/git.git/blame - t/t8012-blame-colors.sh
The third batch
[thirdparty/git.git] / t / t8012-blame-colors.sh
CommitLineData
cdc2d5f1
SB
1#!/bin/sh
2
3test_description='colored git blame'
747f6c68 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
93e02b6e 7TEST_CREATE_REPO_NO_TEMPLATE=1
cdc2d5f1
SB
8. ./test-lib.sh
9
10PROG='git blame -c'
11. "$TEST_DIRECTORY"/annotate-tests.sh
12
13test_expect_success 'colored blame colors contiguous lines' '
14 git -c color.blame.repeatedLines=yellow blame --color-lines --abbrev=12 hello.c >actual.raw &&
0dc95a4d
SB
15 git -c color.blame.repeatedLines=yellow -c blame.coloring=repeatedLines blame --abbrev=12 hello.c >actual.raw.2 &&
16 test_cmp actual.raw actual.raw.2 &&
cdc2d5f1
SB
17 test_decode_color <actual.raw >actual &&
18 grep "<YELLOW>" <actual >darkened &&
19 grep "(F" darkened > F.expect &&
20 grep "(H" darkened > H.expect &&
21 test_line_count = 2 F.expect &&
22 test_line_count = 3 H.expect
23'
24
25d5f529
SB
25test_expect_success 'color by age consistently colors old code' '
26 git blame --color-by-age hello.c >actual.raw &&
0dc95a4d
SB
27 git -c blame.coloring=highlightRecent blame hello.c >actual.raw.2 &&
28 test_cmp actual.raw actual.raw.2 &&
25d5f529
SB
29 test_decode_color <actual.raw >actual &&
30 grep "<BLUE>" <actual >colored &&
31 test_line_count = 10 colored
32'
33
34test_expect_success 'blame color by age: new code is different' '
35 cat >>hello.c <<-EOF &&
36 void qfunc();
37 EOF
38 git add hello.c &&
39 GIT_AUTHOR_DATE="" git commit -m "new commit" &&
40
41 git -c color.blame.highlightRecent="yellow,1 month ago, cyan" blame --color-by-age hello.c >actual.raw &&
42 test_decode_color <actual.raw >actual &&
43
44 grep "<YELLOW>" <actual >colored &&
45 test_line_count = 10 colored &&
46
47 grep "<CYAN>" <actual >colored &&
48 test_line_count = 1 colored &&
49 grep qfunc colored
50'
51
cdc2d5f1 52test_done