summaryrefslogtreecommitdiff
path: root/t/t8012-blame-colors.sh
blob: 18f9c9a16d537c5808d538d7786a8ffb3a3bc16f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh

test_description='colored git blame'
. ./test-lib.sh

PROG='git blame -c'
. "$TEST_DIRECTORY"/annotate-tests.sh

test_expect_success 'colored blame colors contiguous lines' '
	git blame --abbrev=12 --color-lines hello.c >actual.raw &&
	test_decode_color <actual.raw >actual &&
	grep "<BOLD;BLACK>(F" actual > F.expect &&
	grep "<BOLD;BLACK>(H" actual > H.expect &&
	test_line_count = 2 F.expect &&
	test_line_count = 3 H.expect
'

test_expect_success 'colored blame colors continuous fields' '

	git mv hello.c world.c &&
	git commit -a -m "moved file" &&
	cat <<-EOF >> world.c &&
	void world()
	{
		puts("world");
	}
	EOF
	git add world.c &&
	GIT_AUTHOR_NAME="F" GIT_AUTHOR_EMAIL="F@test.git" \
		git commit -m "forgot to add changes to moved file" &&

	git blame --abbrev=12 --color-fields world.c >actual.raw &&
	test_decode_color <actual.raw >actual &&

	grep "<BOLD;BLACK>hello.c" actual > colored_hello.expect &&
	grep "hello.c" actual > all_hello.expect &&
	test_line_count = 9 colored_hello.expect &&
	test_line_count = 10 all_hello.expect &&

	grep "<BOLD;BLACK>world.c" actual > colored_world.expect &&
	grep "world.c" actual > all_world.expect &&
	test_line_count = 3 colored_world.expect &&
	test_line_count = 4 all_world.expect &&

	grep "(F" actual > all_F.expect &&
	grep "<BOLD;BLACK>(F" actual > colored_F.expect &&
	test_line_count = 8 all_F.expect &&
	test_line_count = 5 colored_F.expect &&

	grep "(H" actual > all_H.expect &&
	grep "<BOLD;BLACK>(H" actual > colored_H.expect &&
	test_line_count = 5 all_H.expect &&
	test_line_count = 3 colored_H.expect
'

test_done