3 # Copyright (c) 2010 Nazri Ramliy
6 test_description
='Test for "git log --decorate" colors'
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
13 test_expect_success setup
'
14 git config diff.color.commit yellow &&
15 git config color.decorate.branch green &&
16 git config color.decorate.remoteBranch red &&
17 git config color.decorate.tag "reverse bold yellow" &&
18 git config color.decorate.stash magenta &&
19 git config color.decorate.HEAD cyan &&
23 c_commit="<YELLOW>" &&
25 c_remoteBranch="<RED>" &&
26 c_tag="<BOLD;REVERSE;YELLOW>" &&
27 c_stash="<MAGENTA>" &&
37 git remote add -f other ./other &&
41 git stash save Changes to A.t
45 ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD ->\
46 ${c_reset}${c_branch}main${c_reset}${c_commit},\
47 ${c_reset}${c_tag}tag: v1.0${c_reset}${c_commit},\
48 ${c_reset}${c_tag}tag: B${c_reset}${c_commit})${c_reset} B
49 ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A1${c_reset}${c_commit},\
50 ${c_reset}${c_remoteBranch}other/main${c_reset}${c_commit})${c_reset} A1
51 ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_stash}refs/stash${c_reset}${c_commit})${c_reset}\
52 On main: Changes to A.t
53 ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
56 # We want log to show all, but the second parent to refs/stash is irrelevant
57 # to this test since it does not contain any decoration, hence --first-parent
58 test_expect_success
'Commit Decorations Colored Correctly' '
59 git log --first-parent --abbrev=10 --all --decorate --oneline --color=always |
60 sed "s/[0-9a-f]\{10,10\}/COMMIT_ID/" |
61 test_decode_color >out &&