Skip to content

Commit fb6f843

Browse files
committed
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"
2 parents 0448134 + afd11d3 commit fb6f843

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

refs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2387,7 +2387,8 @@ static void try_remove_empty_parents(char *name)
23872387
/* make sure nobody touched the ref, and unlink */
23882388
static void prune_ref(struct ref_to_prune *r)
23892389
{
2390-
struct ref_lock *lock = lock_ref_sha1(r->name + 5, r->sha1);
2390+
struct ref_lock *lock = lock_any_ref_for_update(r->name, r->sha1,
2391+
0, NULL);
23912392

23922393
if (lock) {
23932394
unlink_or_warn(git_path("%s", r->name));

t/t3210-pack-refs.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,11 @@ test_expect_success 'delete ref while another dangling packed ref' '
151151
test_cmp /dev/null result
152152
'
153153

154+
test_expect_success 'pack ref directly below refs/' '
155+
git update-ref refs/top HEAD &&
156+
git pack-refs --all --prune &&
157+
grep refs/top .git/packed-refs &&
158+
test_path_is_missing .git/refs/top
159+
'
160+
154161
test_done

0 commit comments

Comments
 (0)