]> git.ipfire.org Git - thirdparty/git.git/blob - t/t8012-blame-colors.sh
clone: allow "--bare" with "-o"
[thirdparty/git.git] / t / t8012-blame-colors.sh
1 #!/bin/sh
2
3 test_description='colored git blame'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
7 . ./test-lib.sh
8
9 PROG='git blame -c'
10 . "$TEST_DIRECTORY"/annotate-tests.sh
11
12 test_expect_success 'colored blame colors contiguous lines' '
13 git -c color.blame.repeatedLines=yellow blame --color-lines --abbrev=12 hello.c >actual.raw &&
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 &&
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
24 test_expect_success 'color by age consistently colors old code' '
25 git blame --color-by-age hello.c >actual.raw &&
26 git -c blame.coloring=highlightRecent blame hello.c >actual.raw.2 &&
27 test_cmp actual.raw actual.raw.2 &&
28 test_decode_color <actual.raw >actual &&
29 grep "<BLUE>" <actual >colored &&
30 test_line_count = 10 colored
31 '
32
33 test_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
51 test_done