git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] update-ref --no-deref -d: handle the case when the pointed ref is packed
@ 2008-10-31 23:25 Miklos Vajna
  0 siblings, 0 replies; only message in thread
From: Miklos Vajna @ 2008-10-31 23:25 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff King, Brandon Casey, git

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>
---

This applies on top of 'mv/maint-branch-m-symref' (fa58186).

 refs.c                |    2 +-
 t/t1400-update-ref.sh |   11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/refs.c b/refs.c
index 8a38e08..0d239e1 100644
--- a/refs.c
+++ b/refs.c
@@ -920,7 +920,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
 	lock = lock_ref_sha1_basic(refname, sha1, 0, &flag);
 	if (!lock)
 		return 1;
-	if (!(flag & REF_ISPACKED)) {
+	if (!(flag & REF_ISPACKED) || flag & REF_ISSYMREF) {
 		/* loose */
 		const char *path;
 
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index 8139cd6..bd58926 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -82,6 +82,17 @@ test_expect_success "delete symref without dereference" '
 '
 cp -f .git/HEAD.orig .git/HEAD
 
+test_expect_success "delete symref without dereference when the referred ref is packed" '
+	echo foo >foo.c &&
+	git add foo.c &&
+	git commit -m foo &&
+	git pack-refs --all &&
+	git update-ref --no-deref -d HEAD &&
+	! test -f .git/HEAD
+'
+cp -f .git/HEAD.orig .git/HEAD
+git update-ref -d $m
+
 test_expect_success '(not) create HEAD with old sha1' "
 	test_must_fail git update-ref HEAD $A $B
 "
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-10-31 23:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-31 23:25 [PATCH] update-ref --no-deref -d: handle the case when the pointed ref is packed Miklos Vajna

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).