From eca35a25a92a1ad725af2a549fc9158488c4cc43 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 26 Oct 2008 03:33:56 +0100 Subject: Fix git branch -m for symrefs. This had two problems with symrefs. First, it copied the actual sha1 instead of the "pointer", second it failed to remove the old ref after a successful rename. Given that till now delete_ref() always dereferenced symrefs, a new parameters has been introduced to delete_ref() to allow deleting refs without a dereference. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 't') diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 2147eacc50..fdeb1f529c 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -112,6 +112,15 @@ test_expect_success 'config information was renamed, too' \ "test $(git config branch.s.dummy) = Hello && test_must_fail git config branch.s/s/dummy" +test_expect_success 'renaming a symref' \ +' + git symbolic-ref refs/heads/master2 refs/heads/master && + git branch -m master2 master3 && + git symbolic-ref refs/heads/master3 && + test -f .git/refs/heads/master && + ! test -f .git/refs/heads/master2 +' + test_expect_success \ 'git branch -m u v should fail when the reflog for u is a symlink' ' git branch -l u && -- cgit v1.2.3 From 569740bdd0533ef5cf032edd6233710161a35725 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 26 Oct 2008 03:33:58 +0100 Subject: Fix git update-ref --no-deref -d. Till now --no-deref was just ignored when deleting refs, fix this. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- t/t1400-update-ref.sh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 't') diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 04c2b164bc..8139cd6cc9 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 " -- cgit v1.2.3 From fa58186c9ba50514b36ac5ef192cd7e0bc4d7780 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 29 Oct 2008 01:05:27 +0100 Subject: git branch -m: forbid renaming of a symref There may be cases where one would really want to rename the symbolic ref without changing its value, but "git branch -m" is not such a use-case. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't') diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index fdeb1f529c..25e9971fd8 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -112,13 +112,13 @@ test_expect_success 'config information was renamed, too' \ "test $(git config branch.s.dummy) = Hello && test_must_fail git config branch.s/s/dummy" -test_expect_success 'renaming a symref' \ +test_expect_success 'renaming a symref is not allowed' \ ' git symbolic-ref refs/heads/master2 refs/heads/master && - git branch -m master2 master3 && - git symbolic-ref refs/heads/master3 && + test_must_fail git branch -m master2 master3 && + git symbolic-ref refs/heads/master2 && test -f .git/refs/heads/master && - ! test -f .git/refs/heads/master2 + ! test -f .git/refs/heads/master3 ' test_expect_success \ -- cgit v1.2.3 From 045a476f91a9a308c823a2709977163238baa3fd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 1 Nov 2008 00:25:44 +0100 Subject: update-ref --no-deref -d: handle the case when the pointed ref is packed 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 Signed-off-by: Junio C Hamano --- t/t1400-update-ref.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't') diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 8139cd6cc9..bd589268fc 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 " -- cgit v1.2.3