Fix git update-ref --no-deref -d.
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>
This commit is contained in:
parent
450d4c0f5a
commit
569740bdd0
@ -13,7 +13,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
|
|||||||
{
|
{
|
||||||
const char *refname, *oldval, *msg=NULL;
|
const char *refname, *oldval, *msg=NULL;
|
||||||
unsigned char sha1[20], oldsha1[20];
|
unsigned char sha1[20], oldsha1[20];
|
||||||
int delete = 0, no_deref = 0;
|
int delete = 0, no_deref = 0, flags = 0;
|
||||||
struct option options[] = {
|
struct option options[] = {
|
||||||
OPT_STRING( 'm', NULL, &msg, "reason", "reason of the update"),
|
OPT_STRING( 'm', NULL, &msg, "reason", "reason of the update"),
|
||||||
OPT_BOOLEAN('d', NULL, &delete, "deletes the reference"),
|
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))
|
if (oldval && *oldval && get_sha1(oldval, oldsha1))
|
||||||
die("%s: not a valid old SHA1", oldval);
|
die("%s: not a valid old SHA1", oldval);
|
||||||
|
|
||||||
|
if (no_deref)
|
||||||
|
flags = REF_NODEREF;
|
||||||
if (delete)
|
if (delete)
|
||||||
return delete_ref(refname, oldval ? oldsha1 : NULL, 0);
|
return delete_ref(refname, oldval ? oldsha1 : NULL, flags);
|
||||||
else
|
else
|
||||||
return update_ref(msg, refname, sha1, oldval ? oldsha1 : NULL,
|
return update_ref(msg, refname, sha1, oldval ? oldsha1 : NULL,
|
||||||
no_deref ? REF_NODEREF : 0, DIE_ON_ERR);
|
flags, DIE_ON_ERR);
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,13 @@ test_expect_success "delete $m (by HEAD)" '
|
|||||||
'
|
'
|
||||||
rm -f .git/$m
|
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_expect_success '(not) create HEAD with old sha1' "
|
||||||
test_must_fail git update-ref HEAD $A $B
|
test_must_fail git update-ref HEAD $A $B
|
||||||
"
|
"
|
||||||
|
Loading…
Reference in New Issue
Block a user