Skip to content

Commit 045a476

Browse files
Miklos Vajnagitster
authored andcommitted
update-ref --no-deref -d: handle the case when the pointed ref is packed
In this case we did nothing in the past, but we should delete the reference in fact. The problem was that when the symref is not packed but the referenced ref is packed, then we assumed that the symref is packed as well, but symrefs are never packed. Signed-off-by: Miklos Vajna <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fa58186 commit 045a476

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
920920
lock = lock_ref_sha1_basic(refname, sha1, 0, &flag);
921921
if (!lock)
922922
return 1;
923-
if (!(flag & REF_ISPACKED)) {
923+
if (!(flag & REF_ISPACKED) || flag & REF_ISSYMREF) {
924924
/* loose */
925925
const char *path;
926926

t/t1400-update-ref.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ test_expect_success "delete symref without dereference" '
8282
'
8383
cp -f .git/HEAD.orig .git/HEAD
8484

85+
test_expect_success "delete symref without dereference when the referred ref is packed" '
86+
echo foo >foo.c &&
87+
git add foo.c &&
88+
git commit -m foo &&
89+
git pack-refs --all &&
90+
git update-ref --no-deref -d HEAD &&
91+
! test -f .git/HEAD
92+
'
93+
cp -f .git/HEAD.orig .git/HEAD
94+
git update-ref -d $m
95+
8596
test_expect_success '(not) create HEAD with old sha1' "
8697
test_must_fail git update-ref HEAD $A $B
8798
"

0 commit comments

Comments
 (0)