Skip to content

Commit 0a0b8d1

Browse files
mhaggergitster
authored andcommitted
t3210: test for spurious error messages for dangling packed refs
A packed reference can be overridden by a loose reference, in which case the packed reference is obsolete and is never used. The object pointed to by such a reference can be garbage collected. Since d66da47, this could lead to the emission of a spurious error message: error: refs/heads/master does not point to a valid object! The error is generated by repack_without_ref() if there is an obsolete dangling packed reference in packed-refs when the packed-refs file has to be rewritten due to the deletion of another packed reference. Add a failing test demonstrating this problem and some passing tests of related scenarios. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 624cac3 commit 0a0b8d1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

t/t3210-pack-refs.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,37 @@ test_expect_success 'pack, prune and repack' '
118118
test_cmp all-of-them again
119119
'
120120

121+
test_expect_success 'explicit pack-refs with dangling packed reference' '
122+
git commit --allow-empty -m "soon to be garbage-collected" &&
123+
git pack-refs --all &&
124+
git reset --hard HEAD^ &&
125+
git reflog expire --expire=all --all &&
126+
git prune --expire=all &&
127+
git pack-refs --all 2>result &&
128+
test_cmp /dev/null result
129+
'
130+
131+
test_expect_success 'delete ref with dangling packed version' '
132+
git checkout -b lamb &&
133+
git commit --allow-empty -m "future garbage" &&
134+
git pack-refs --all &&
135+
git reset --hard HEAD^ &&
136+
git checkout master &&
137+
git reflog expire --expire=all --all &&
138+
git prune --expire=all &&
139+
git branch -d lamb 2>result &&
140+
test_cmp /dev/null result
141+
'
142+
143+
test_expect_failure 'delete ref while another dangling packed ref' '
144+
git branch lamb &&
145+
git commit --allow-empty -m "future garbage" &&
146+
git pack-refs --all &&
147+
git reset --hard HEAD^ &&
148+
git reflog expire --expire=all --all &&
149+
git prune --expire=all &&
150+
git branch -d lamb 2>result &&
151+
test_cmp /dev/null result
152+
'
153+
121154
test_done

0 commit comments

Comments
 (0)