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 <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Miklos Vajna committed
Nov 1, 2008 at 00:25 UTC
045a476f91a9a308c823a2709977163238baa3fd
2 files changed
+12
-1
refs.c
+1
-1
@@ -920,7 +920,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
920
lock = lock_ref_sha1_basic(refname, sha1, 0, &flag);
921
if (!lock)
922
return 1;
923
- if (!(flag & REF_ISPACKED)) {
923
+ if (!(flag & REF_ISPACKED) || flag & REF_ISSYMREF) {
924
/* loose */
925
const char *path;
926
t/t1400-update-ref.sh
+11
@@ -82,6 +82,17 @@ test_expect_success "delete symref without dereference" '
82
'
83
cp -f .git/HEAD.orig .git/HEAD
84
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
+
96
test_expect_success '(not) create HEAD with old sha1' "
97
test_must_fail git update-ref HEAD $A $B
98
"