Merge branch 'mv/maint-branch-m-symref'

* mv/maint-branch-m-symref:
  update-ref --no-deref -d: handle the case when the pointed ref is packed
  git branch -m: forbid renaming of a symref
  Fix git update-ref --no-deref -d.
  rename_ref(): handle the case when the reflog of a ref does not exist
  Fix git branch -m for symrefs.
This commit is contained in:
Junio C Hamano
2008-11-05 11:33:19 -08:00
11 changed files with 65 additions and 24 deletions

View File

@@ -75,6 +75,24 @@ 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 "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
"

View File

@@ -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 is not allowed' \
'
git symbolic-ref refs/heads/master2 refs/heads/master &&
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/master3
'
test_expect_success \
'git branch -m u v should fail when the reflog for u is a symlink' '
git branch -l u &&