From: Junio C Hamano Date: Thu, 11 Sep 2014 17:33:33 +0000 (-0700) Subject: Merge branch 'jk/prune-top-level-refs-after-packing' X-Git-Tag: v2.2.0-rc0~135 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/88e7dff93d7010bb2974f8e1599a4e53c73e18f3 Merge branch 'jk/prune-top-level-refs-after-packing' After "pack-refs --prune" packed refs at the top-level, it failed to prune them. * jk/prune-top-level-refs-after-packing: pack-refs: prune top-level refs like "refs/foo" --- 88e7dff93d7010bb2974f8e1599a4e53c73e18f3 diff --cc refs.c index 808e261c23,130b89e92b..2ce5d69090 --- a/refs.c +++ b/refs.c @@@ -2386,25 -2353,14 +2386,25 @@@ static void try_remove_empty_parents(ch /* make sure nobody touched the ref, and unlink */ static void prune_ref(struct ref_to_prune *r) { - struct ref_lock *lock = lock_any_ref_for_update(r->name, r->sha1, - 0, NULL); + struct ref_transaction *transaction; + struct strbuf err = STRBUF_INIT; - if (check_refname_format(r->name + 5, 0)) - if (lock) { - unlink_or_warn(git_path("%s", r->name)); - unlock_ref(lock); - try_remove_empty_parents(r->name); ++ if (check_refname_format(r->name, 0)) + return; + + transaction = ref_transaction_begin(&err); + if (!transaction || + ref_transaction_delete(transaction, r->name, r->sha1, + REF_ISPRUNING, 1, &err) || + ref_transaction_commit(transaction, NULL, &err)) { + ref_transaction_free(transaction); + error("%s", err.buf); + strbuf_release(&err); + return; } + ref_transaction_free(transaction); + strbuf_release(&err); + try_remove_empty_parents(r->name); } static void prune_refs(struct ref_to_prune *r)