Skip to content

Commit

Permalink
Merge branch 'jk/prune-top-level-refs-after-packing' into maint
Browse files Browse the repository at this point in the history
* jk/prune-top-level-refs-after-packing:
  pack-refs: prune top-level refs like "refs/foo"
  • Loading branch information
Junio C Hamano committed Sep 19, 2014
2 parents 0448134 + afd11d3 commit fb6f843
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
7 changes: 7 additions & 0 deletions t/t3210-pack-refs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fb6f843

Please sign in to comment.