Merge branch 'jk/prune-top-level-refs-after-packing' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 19 Sep 2014 21:05:12 +0000 (14:05 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Sep 2014 21:05:12 +0000 (14:05 -0700)
* jk/prune-top-level-refs-after-packing:
pack-refs: prune top-level refs like "refs/foo"

refs.c
t/t3210-pack-refs.sh
diff --git a/refs.c b/refs.c
index 27927f2319130cc0575817542dfd47c37cc5149b..82e5b1b14f7a6e7341dfcf8fbf61ae3982851e18 100644 (file)
--- 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));
index 1a2080e3dca272b6ed40739a7539f01f4f6ae65c..3a017bf437395526cf54403d4ea1db36a3cff0b3 100755 (executable)
@@ -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