Skip to content

Commit c6429fb

Browse files
pks-tgitster
authored andcommitted
t4207: delete replace references via git-update-ref(1)
In t4207 we set up a set of replace objects via git-replace(1). Because these references should not be impacting subsequent tests we also set up some cleanup logic that deletes the replacement references via a call to `rm -rf`. This reaches into the internal implementation details of the reference backend and will thus break when we grow an alternative refdb implementation. Refactor the tests to delete the replacement refs via Git commands so that we become independent of the actual refdb that's in use. As we don't have a nice way to delete all replacements or all references in a certain namespace, we opt for a combination of git-for-each-ref(1) and git-update-ref(1)'s `--stdin` mode. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c603138 commit c6429fb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

t/t4207-log-decoration-colors.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,14 @@ ${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A
7070
cmp_filtered_decorations
7171
'
7272

73+
remove_replace_refs () {
74+
git for-each-ref 'refs/replace*/**' --format='delete %(refname)' >in &&
75+
git update-ref --stdin <in &&
76+
rm in
77+
}
78+
7379
test_expect_success 'test coloring with replace-objects' '
74-
test_when_finished rm -rf .git/refs/replace* &&
80+
test_when_finished remove_replace_refs &&
7581
test_commit C &&
7682
test_commit D &&
7783
@@ -99,7 +105,7 @@ EOF
99105
'
100106

101107
test_expect_success 'test coloring with grafted commit' '
102-
test_when_finished rm -rf .git/refs/replace* &&
108+
test_when_finished remove_replace_refs &&
103109
104110
git replace --graft HEAD HEAD~2 &&
105111

0 commit comments

Comments
 (0)