Merge branch 'sg/subtree-signed-commits' into pu
[git] / t / t8012-blame-colors.sh
1 #!/bin/sh
2
3 test_description='colored git blame'
4 . ./test-lib.sh
5
6 PROG='git blame -c'
7 . "$TEST_DIRECTORY"/annotate-tests.sh
8
9 test_expect_success 'colored blame colors contiguous lines' '
10         git blame --abbrev=12 --color-lines hello.c >actual.raw &&
11         test_decode_color <actual.raw >actual &&
12         grep "<BOLD;BLACK>(F" actual > F.expect &&
13         grep "<BOLD;BLACK>(H" actual > H.expect &&
14         test_line_count = 2 F.expect &&
15         test_line_count = 3 H.expect
16 '
17
18 test_expect_success 'colored blame colors continuous fields' '
19
20         git mv hello.c world.c &&
21         git commit -a -m "moved file" &&
22         cat <<-EOF >> world.c &&
23         void world()
24         {
25                 puts("world");
26         }
27         EOF
28         git add world.c &&
29         GIT_AUTHOR_NAME="F" GIT_AUTHOR_EMAIL="F@test.git" \
30                 git commit -m "forgot to add changes to moved file" &&
31
32         git blame --abbrev=12 --color-fields world.c >actual.raw &&
33         test_decode_color <actual.raw >actual &&
34
35         grep "<BOLD;BLACK>hello.c" actual > colored_hello.expect &&
36         grep "hello.c" actual > all_hello.expect &&
37         test_line_count = 9 colored_hello.expect &&
38         test_line_count = 10 all_hello.expect &&
39
40         grep "<BOLD;BLACK>world.c" actual > colored_world.expect &&
41         grep "world.c" actual > all_world.expect &&
42         test_line_count = 3 colored_world.expect &&
43         test_line_count = 4 all_world.expect &&
44
45         grep "(F" actual > all_F.expect &&
46         grep "<BOLD;BLACK>(F" actual > colored_F.expect &&
47         test_line_count = 8 all_F.expect &&
48         test_line_count = 5 colored_F.expect &&
49
50         grep "(H" actual > all_H.expect &&
51         grep "<BOLD;BLACK>(H" actual > colored_H.expect &&
52         test_line_count = 5 all_H.expect &&
53         test_line_count = 3 colored_H.expect
54 '
55
56 test_done