From: Junio C Hamano Date: Fri, 19 Sep 2014 21:05:12 +0000 (-0700) Subject: Merge branch 'jk/prune-top-level-refs-after-packing' into maint X-Git-Tag: v2.1.1~3 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/fb6f843a8fbce633a4a1f39f4b7b2a862e5cb855?hp=04481347eccbd797bc9f3dc49e731e3ed7d639df Merge branch 'jk/prune-top-level-refs-after-packing' into maint * jk/prune-top-level-refs-after-packing: pack-refs: prune top-level refs like "refs/foo" --- diff --git a/refs.c b/refs.c index 27927f2319..82e5b1b14f 100644 --- a/refs.c +++ b/refs.c @@ -2387,7 +2387,8 @@ static void try_remove_empty_parents(char *name) /* make sure nobody touched the ref, and unlink */ static void prune_ref(struct ref_to_prune *r) { - struct ref_lock *lock = lock_ref_sha1(r->name + 5, r->sha1); + struct ref_lock *lock = lock_any_ref_for_update(r->name, r->sha1, + 0, NULL); if (lock) { unlink_or_warn(git_path("%s", r->name)); diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh index 1a2080e3dc..3a017bf437 100755 --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@ -151,4 +151,11 @@ test_expect_success 'delete ref while another dangling packed ref' ' test_cmp /dev/null result ' +test_expect_success 'pack ref directly below refs/' ' + git update-ref refs/top HEAD && + git pack-refs --all --prune && + grep refs/top .git/packed-refs && + test_path_is_missing .git/refs/top +' + test_done