Skip to content

Commit b274a71

Browse files
jherlandgitster
authored andcommitted
Fix failure to delete a packed ref through a symref
When deleting a ref through a symref (e.g. using 'git update-ref -d HEAD' to delete refs/heads/master), we would remove the loose ref, but a packed version of the same ref would remain, the end result being that instead of deleting refs/heads/master we would appear to reset it to its state as of the last repack. This patch fixes the issue, by making sure we pass the correct ref name when invoking repack_without_ref() from within delete_ref(). Signed-off-by: Johan Herland <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 75c96e0 commit b274a71

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
17781778
* packed one. Also, if it was not loose we need to repack
17791779
* without it.
17801780
*/
1781-
ret |= repack_without_ref(refname);
1781+
ret |= repack_without_ref(lock->ref_name);
17821782

17831783
unlink_or_warn(git_path("logs/%s", lock->ref_name));
17841784
invalidate_ref_cache(NULL);

t/t1400-update-ref.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ test_expect_success \
8585
"move $m (by HEAD)" \
8686
"git update-ref HEAD $B $A &&
8787
test $B"' = $(cat .git/'"$m"')'
88-
test_expect_failure "delete $m (by HEAD) should remove both packed and loose $m" '
88+
test_expect_success "delete $m (by HEAD) should remove both packed and loose $m" '
8989
git update-ref -d HEAD $B &&
9090
! grep "$m" .git/packed-refs &&
9191
! test -f .git/$m

0 commit comments

Comments
 (0)