summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 450d4c0)
raw | patch | inline | side by side (parent: 450d4c0)
author | Miklos Vajna <vmiklos@frugalware.org> | |
Sun, 26 Oct 2008 02:33:58 +0000 (03:33 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 26 Oct 2008 21:44:25 +0000 (14:44 -0700) |
Till now --no-deref was just ignored when deleting refs, fix this.
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-update-ref.c | patch | blob | history | |
t/t1400-update-ref.sh | patch | blob | history |
diff --git a/builtin-update-ref.c b/builtin-update-ref.c
index d8f3142c06c2d7c5202c9c132a12457d6e8b43a6..378dc1b7a6bb4d56d301a34a4d44dae2f9a37e44 100644 (file)
--- a/builtin-update-ref.c
+++ b/builtin-update-ref.c
{
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"),
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 04c2b164bcba0bdead45a50bbb14ceff19e8411f..8139cd6cc96535d2ba6526aec946578b8a455de1 100755 (executable)
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
'
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
"