Skip to content

Commit

Permalink
Merge branch 'jh/update-ref-d-through-symref' into next
Browse files Browse the repository at this point in the history
"update-ref -d --deref SYM" to delete a ref through a symbolic ref
that points to it did not remove it correctly.

* jh/update-ref-d-through-symref:
  Fix failure to delete a packed ref through a symref
  t1400-update-ref: Add test verifying bug with symrefs in delete_ref()
  • Loading branch information
gitster committed Nov 19, 2012
2 parents f9964da + b274a71 commit 6bcca4c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion refs.c
Expand Up @@ -1779,7 +1779,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
* packed one. Also, if it was not loose we need to repack
* without it.
*/
ret |= repack_without_ref(refname);
ret |= repack_without_ref(lock->ref_name);

unlink_or_warn(git_path("logs/%s", lock->ref_name));
invalidate_ref_cache(NULL);
Expand Down
18 changes: 18 additions & 0 deletions t/t1400-update-ref.sh
Expand Up @@ -74,6 +74,24 @@ test_expect_success "delete $m (by HEAD)" '
'
rm -f .git/$m

test_expect_success \
"create $m (by HEAD)" \
"git update-ref HEAD $A &&
test $A"' = $(cat .git/'"$m"')'
test_expect_success \
"pack refs" \
"git pack-refs --all"
test_expect_success \
"move $m (by HEAD)" \
"git update-ref HEAD $B $A &&
test $B"' = $(cat .git/'"$m"')'
test_expect_success "delete $m (by HEAD) should remove both packed and loose $m" '
git update-ref -d HEAD $B &&
! grep "$m" .git/packed-refs &&
! test -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 &&
Expand Down

0 comments on commit 6bcca4c

Please sign in to comment.