]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/prune-top-level-refs-after-packing'
authorJunio C Hamano <gitster@pobox.com>
Thu, 11 Sep 2014 17:33:33 +0000 (10:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 11 Sep 2014 17:33:33 +0000 (10:33 -0700)
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"

1  2 
refs.c

diff --cc refs.c
index 808e261c235b9803a80faefd79a6329cebcf5fc1,130b89e92b6c8ff005e61fd5051845bf1b247fd0..2ce5d690907d33bda557f66150ef1317f39b4f93
--- 1/refs.c
--- 2/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)