Skip to content

Commit 5797b13

Browse files
derrickstoleegitster
authored andcommitted
t4207: test coloring of grafted decorations
The color.decorate.<slot> config option added the 'grafted' slot in 09c4ba4 (log-tree: allow to customize 'grafted' color, 2018-05-26) but included no tests for this behavior. When modifying some logic around decorations, this ref namespace was ignored and could have been lost as a default namespace for 'git log' decorations by default. Add two tests to t4207 that check that the replaced objects are correctly decorated. Use "black" as the color since it is distinct from the other colors already in the test. The first test uses regular replace-objects while the second creates a commit graft. Be sure to test both modes with GIT_REPLACE_REF_BASE unset and set to an alternative base. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b004521 commit 5797b13

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

t/t4207-log-decoration-colors.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ test_expect_success setup '
1717
git config color.decorate.remoteBranch red &&
1818
git config color.decorate.tag "reverse bold yellow" &&
1919
git config color.decorate.stash magenta &&
20+
git config color.decorate.grafted black &&
2021
git config color.decorate.HEAD cyan &&
2122
2223
c_reset="<RESET>" &&
@@ -27,6 +28,7 @@ test_expect_success setup '
2728
c_tag="<BOLD;REVERSE;YELLOW>" &&
2829
c_stash="<MAGENTA>" &&
2930
c_HEAD="<CYAN>" &&
31+
c_grafted="<BLACK>" &&
3032
3133
test_commit A &&
3234
git clone . other &&
@@ -66,4 +68,55 @@ On main: Changes to A.t
6668
cmp_filtered_decorations
6769
'
6870

71+
test_expect_success 'test coloring with replace-objects' '
72+
test_when_finished rm -rf .git/refs/replace* &&
73+
test_commit C &&
74+
test_commit D &&
75+
76+
git replace HEAD~1 HEAD~2 &&
77+
78+
cat >expect <<-EOF &&
79+
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD -> \
80+
${c_reset}${c_branch}main${c_reset}${c_commit}, \
81+
${c_reset}${c_tag}tag: D${c_reset}${c_commit})${c_reset} D
82+
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: C${c_reset}${c_commit}, \
83+
${c_reset}${c_grafted}replaced${c_reset}${c_commit})${c_reset} B
84+
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
85+
EOF
86+
87+
git log --first-parent --no-abbrev --decorate --oneline --color=always HEAD >actual &&
88+
cmp_filtered_decorations &&
89+
git replace -d HEAD~1 &&
90+
91+
GIT_REPLACE_REF_BASE=refs/replace2/ git replace HEAD~1 HEAD~2 &&
92+
GIT_REPLACE_REF_BASE=refs/replace2/ git log --first-parent \
93+
--no-abbrev --decorate --oneline --color=always HEAD >actual &&
94+
cmp_filtered_decorations
95+
'
96+
97+
test_expect_success 'test coloring with grafted commit' '
98+
test_when_finished rm -rf .git/refs/replace* &&
99+
100+
git replace --graft HEAD HEAD~2 &&
101+
102+
cat >expect <<-EOF &&
103+
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD -> \
104+
${c_reset}${c_branch}main${c_reset}${c_commit}, \
105+
${c_reset}${c_tag}tag: D${c_reset}${c_commit}, \
106+
${c_reset}${c_grafted}replaced${c_reset}${c_commit})${c_reset} D
107+
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: v1.0${c_reset}${c_commit}, \
108+
${c_reset}${c_tag}tag: B${c_reset}${c_commit})${c_reset} B
109+
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
110+
EOF
111+
112+
git log --first-parent --no-abbrev --decorate --oneline --color=always HEAD >actual &&
113+
cmp_filtered_decorations &&
114+
git replace -d HEAD &&
115+
116+
GIT_REPLACE_REF_BASE=refs/replace2/ git replace --graft HEAD HEAD~2 &&
117+
GIT_REPLACE_REF_BASE=refs/replace2/ git log --first-parent \
118+
--no-abbrev --decorate --oneline --color=always HEAD >actual &&
119+
cmp_filtered_decorations
120+
'
121+
69122
test_done

0 commit comments

Comments
 (0)