]> git.ipfire.org Git - thirdparty/git.git/blame - t/t8012-blame-colors.sh
Merge branch 'js/range-diff-wo-dotdot'
[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
cdc2d5f1
SB
7. ./test-lib.sh
8
9PROG='git blame -c'
10. "$TEST_DIRECTORY"/annotate-tests.sh
11
12test_expect_success 'colored blame colors contiguous lines' '
13 git -c color.blame.repeatedLines=yellow blame --color-lines --abbrev=12 hello.c >actual.raw &&
0dc95a4d
SB
14 git -c color.blame.repeatedLines=yellow -c blame.coloring=repeatedLines blame --abbrev=12 hello.c >actual.raw.2 &&
15 test_cmp actual.raw actual.raw.2 &&
cdc2d5f1
SB
16 test_decode_color <actual.raw >actual &&
17 grep "<YELLOW>" <actual >darkened &&
18 grep "(F" darkened > F.expect &&
19 grep "(H" darkened > H.expect &&
20 test_line_count = 2 F.expect &&
21 test_line_count = 3 H.expect
22'
23
25d5f529
SB
24test_expect_success 'color by age consistently colors old code' '
25 git blame --color-by-age hello.c >actual.raw &&
0dc95a4d
SB
26 git -c blame.coloring=highlightRecent blame hello.c >actual.raw.2 &&
27 test_cmp actual.raw actual.raw.2 &&
25d5f529
SB
28 test_decode_color <actual.raw >actual &&
29 grep "<BLUE>" <actual >colored &&
30 test_line_count = 10 colored
31'
32
33test_expect_success 'blame color by age: new code is different' '
34 cat >>hello.c <<-EOF &&
35 void qfunc();
36 EOF
37 git add hello.c &&
38 GIT_AUTHOR_DATE="" git commit -m "new commit" &&
39
40 git -c color.blame.highlightRecent="yellow,1 month ago, cyan" blame --color-by-age hello.c >actual.raw &&
41 test_decode_color <actual.raw >actual &&
42
43 grep "<YELLOW>" <actual >colored &&
44 test_line_count = 10 colored &&
45
46 grep "<CYAN>" <actual >colored &&
47 test_line_count = 1 colored &&
48 grep qfunc colored
49'
50
cdc2d5f1 51test_done