git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miklos Vajna <vmiklos@frugalware.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, Brandon Casey <casey@nrlssc.navy.mil>,
	git@vger.kernel.org
Subject: [PATCH 3/3] Fix git update-ref --no-deref -d.
Date: Sun, 26 Oct 2008 03:33:58 +0100	[thread overview]
Message-ID: <f10fa3f86cbdf14ae935eaf806ee6b4a1922e0c2.1224987945.git.vmiklos@frugalware.org> (raw)
In-Reply-To: <b06bf89aeeb844903e16f7c231c6add011a910bf.1224987945.git.vmiklos@frugalware.org>
In-Reply-To: <cover.1224987944.git.vmiklos@frugalware.org>

Till now --no-deref was just ignored when deleting refs, fix this.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 builtin-update-ref.c  |    8 +++++---
 t/t1400-update-ref.sh |    7 +++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/builtin-update-ref.c b/builtin-update-ref.c
index d8f3142..378dc1b 100644
--- a/builtin-update-ref.c
+++ b/builtin-update-ref.c
@@ -13,7 +13,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
 {
 	const char *refname, *oldval, *msg=NULL;
 	unsigned char sha1[20], oldsha1[20];
-	int delete = 0, no_deref = 0;
+	int delete = 0, no_deref = 0, flags = 0;
 	struct option options[] = {
 		OPT_STRING( 'm', NULL, &msg, "reason", "reason of the update"),
 		OPT_BOOLEAN('d', NULL, &delete, "deletes the reference"),
@@ -47,9 +47,11 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
 	if (oldval && *oldval && get_sha1(oldval, oldsha1))
 		die("%s: not a valid old SHA1", oldval);
 
+	if (no_deref)
+		flags = REF_NODEREF;
 	if (delete)
-		return delete_ref(refname, oldval ? oldsha1 : NULL, 0);
+		return delete_ref(refname, oldval ? oldsha1 : NULL, flags);
 	else
 		return update_ref(msg, refname, sha1, oldval ? oldsha1 : NULL,
-				  no_deref ? REF_NODEREF : 0, DIE_ON_ERR);
+				  flags, DIE_ON_ERR);
 }
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index 04c2b16..8139cd6 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -75,6 +75,13 @@ test_expect_success "delete $m (by HEAD)" '
 '
 rm -f .git/$m
 
+cp -f .git/HEAD .git/HEAD.orig
+test_expect_success "delete symref without dereference" '
+	git update-ref --no-deref -d HEAD &&
+	! test -f .git/HEAD
+'
+cp -f .git/HEAD.orig .git/HEAD
+
 test_expect_success '(not) create HEAD with old sha1' "
 	test_must_fail git update-ref HEAD $A $B
 "
-- 
1.6.0.2

  reply	other threads:[~2008-10-26  2:34 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-22  0:23 [PATCH] Implement git remote mv Miklos Vajna
2008-10-22 16:52 ` Brandon Casey
2008-10-23  1:18   ` Miklos Vajna
2008-10-23  3:52     ` Jeff King
2008-10-23 12:56       ` [PATCH] Implement git remote rename Miklos Vajna
2008-10-24 23:33         ` Junio C Hamano
2008-10-25 12:58           ` [PATCH 0/2] Fixes for git branch -m / update-ref --no-deref -d Miklos Vajna
2008-10-25 12:58             ` [PATCH 1/2] Fix git branch -m for symrefs Miklos Vajna
2008-10-25 12:58               ` [PATCH 2/2] Fix git update-ref --no-deref -d Miklos Vajna
2008-10-25 18:31               ` [PATCH 1/2] Fix git branch -m for symrefs Junio C Hamano
2008-10-26  2:33                 ` [PATCH 0/3] symref rename/delete fixes Miklos Vajna
2008-10-26  2:33                   ` [PATCH 1/3] Fix git branch -m for symrefs Miklos Vajna
2008-10-26  2:33                     ` [PATCH 2/3] rename_ref(): handle the case when the reflog of a ref does not exist Miklos Vajna
2008-10-26  2:33                       ` Miklos Vajna [this message]
2008-10-27  5:31                   ` [PATCH 0/3] symref rename/delete fixes Junio C Hamano
2008-10-27  8:50                     ` Miklos Vajna
2008-10-27 19:50                       ` Miklos Vajna
2008-10-27 19:50                         ` [PATCH 1/3] Disallow git branch -m for symrefs Miklos Vajna
2008-10-27 19:50                           ` [PATCH 2/3] rename_ref(): handle the case when the reflog of a ref does not exist Miklos Vajna
2008-10-27 19:50                             ` [PATCH 3/3] Fix git update-ref --no-deref -d Miklos Vajna
2008-10-28 23:45                         ` [PATCH 0/3] symref rename/delete fixes Miklos Vajna
2008-10-29  0:05                           ` [PATCH] git branch -m: forbid renaming of a symref Miklos Vajna
2008-11-03 18:26           ` [PATCH] Implement git remote rename Miklos Vajna
2008-11-10 20:42           ` Miklos Vajna
2008-11-10 20:43             ` [PATCH 1/4] remote: add a new 'origin' variable to the struct Miklos Vajna
2008-11-10 20:43               ` [PATCH 2/4] git-remote rename: support remotes->config migration Miklos Vajna
2008-11-10 20:43                 ` [PATCH 3/4] git-remote rename: support branches->config migration Miklos Vajna
2008-11-10 20:43                   ` [PATCH 4/4] git-remote: document the migration feature of the rename subcommand Miklos Vajna
2008-11-12  0:49                   ` [PATCH 3/4] git-remote rename: support branches->config migration Junio C Hamano
2008-11-12  2:01                     ` Miklos Vajna
2008-11-12  4:22                       ` Junio C Hamano
2008-11-12 17:11                         ` [PATCH v2 0/4] " Miklos Vajna
2008-11-12 17:11                           ` [PATCH 1/4] remote: add a new 'origin' variable to the struct Miklos Vajna
2008-11-12 17:11                             ` [PATCH 2/4] git-remote rename: support remotes->config migration Miklos Vajna
2008-11-12 17:11                               ` [PATCH 3/4] git-remote rename: support branches->config migration Miklos Vajna
2008-11-12 17:11                                 ` [PATCH 4/4] git-remote: document the migration feature of the rename subcommand Miklos Vajna

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f10fa3f86cbdf14ae935eaf806ee6b4a1922e0c2.1224987945.git.vmiklos@frugalware.org \
    --to=vmiklos@frugalware.org \
    --cc=casey@nrlssc.navy.mil \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).