3
# Copyright (c) 2010 Nazri Ramliy
4
#
5
6
-test_description='Test for "git log --decorate" colors'
6
+test_description='test "git log --decorate" colors'
7
8
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
42
git stash save Changes to A.t
43
'
44
45
-cat >expected <<EOF
46
-${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD ->\
47
- ${c_reset}${c_branch}main${c_reset}${c_commit},\
48
- ${c_reset}${c_tag}tag: v1.0${c_reset}${c_commit},\
49
- ${c_reset}${c_tag}tag: B${c_reset}${c_commit})${c_reset} B
50
-${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A1${c_reset}${c_commit},\
51
- ${c_reset}${c_remoteBranch}other/main${c_reset}${c_commit})${c_reset} A1
52
-${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_stash}refs/stash${c_reset}${c_commit})${c_reset}\
53
- On main: Changes to A.t
54
-${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
55
-EOF
45
+cmp_filtered_decorations () {
46
+ sed "s/$OID_REGEX/COMMIT_ID/" actual | test_decode_color >filtered &&
47
+ test_cmp expect filtered
48
+}
49
50
# We want log to show all, but the second parent to refs/stash is irrelevant
51
# to this test since it does not contain any decoration, hence --first-parent
59
-test_expect_success 'Commit Decorations Colored Correctly' '
60
- git log --first-parent --abbrev=10 --all --decorate --oneline --color=always |
61
- sed "s/[0-9a-f]\{10,10\}/COMMIT_ID/" |
62
- test_decode_color >out &&
63
- test_cmp expected out
52
+test_expect_success 'commit decorations colored correctly' '
53
+ cat >expect <<-EOF &&
54
+ ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD -> \
55
+${c_reset}${c_branch}main${c_reset}${c_commit}, \
56
+${c_reset}${c_tag}tag: v1.0${c_reset}${c_commit}, \
57
+${c_reset}${c_tag}tag: B${c_reset}${c_commit})${c_reset} B
58
+${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A1${c_reset}${c_commit}, \
59
+${c_reset}${c_remoteBranch}other/main${c_reset}${c_commit})${c_reset} A1
60
+ ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_stash}refs/stash${c_reset}${c_commit})${c_reset} \
61
+On main: Changes to A.t
62
+ ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
63
+ EOF
64
+
65
+ git log --first-parent --no-abbrev --decorate --oneline --color=always --all >actual &&
66
+ cmp_filtered_decorations
67
'
68
69
test_done