{"thread":{"id":"16117","subject":"[PATCH] update-ref --no-deref -d: handle the case when the pointed ref is packed","startedAt":"2008-10-31T23:25:44Z","lastAt":"2008-10-31T23:25:44Z","messageCount":1,"participants":["Miklos Vajna"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"94492","messageId":"1225495544-21487-1-git-send-email-vmiklos@frugalware.org","threadId":"16117","inReplyTo":null,"subject":"[PATCH] update-ref --no-deref -d: handle the case when the pointed ref is packed","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-10-31T23:25:44Z","receivedAt":"2008-10-31T23:25:44Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"In this case we did nothing in the past, but we should delete the\nreference in fact.\n\nThe problem was that when the symref is not packed but the referenced\nref is packed, then we assumed that the symref is packed as well, but\nsymrefs are never packed.\n\nSigned-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n\nThis applies on top of 'mv/maint-branch-m-symref' (fa58186).\n\n refs.c                |    2 +-\n t/t1400-update-ref.sh |   11 +++++++++++\n 2 files changed, 12 insertions(+), 1 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 8a38e08..0d239e1 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -920,7 +920,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)\n \tlock = lock_ref_sha1_basic(refname, sha1, 0, &flag);\n \tif (!lock)\n \t\treturn 1;\n-\tif (!(flag & REF_ISPACKED)) {\n+\tif (!(flag & REF_ISPACKED) || flag & REF_ISSYMREF) {\n \t\t/* loose */\n \t\tconst char *path;\n \ndiff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh\nindex 8139cd6..bd58926 100755\n--- a/t/t1400-update-ref.sh\n+++ b/t/t1400-update-ref.sh\n@@ -82,6 +82,17 @@ test_expect_success \"delete symref without dereference\" '\n '\n cp -f .git/HEAD.orig .git/HEAD\n \n+test_expect_success \"delete symref without dereference when the referred ref is packed\" '\n+\techo foo >foo.c &&\n+\tgit add foo.c &&\n+\tgit commit -m foo &&\n+\tgit pack-refs --all &&\n+\tgit update-ref --no-deref -d HEAD &&\n+\t! test -f .git/HEAD\n+'\n+cp -f .git/HEAD.orig .git/HEAD\n+git update-ref -d $m\n+\n test_expect_success '(not) create HEAD with old sha1' \"\n \ttest_must_fail git update-ref HEAD $A $B\n \"\n-- \n1.6.0.2\n"}]}