summaryrefslogtreecommitdiff
path: root/refs/files-backend.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-12-06 17:08:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-12-06 17:08:50 (GMT)
commit02abc6be8eee1ccfcb5f4fb160f53a62c6528c04 (patch)
tree56194469374f78e0bb6b2496995444dfc68f14d9 /refs/files-backend.c
parent9b185bef0c15cec1ea8753ce091e42ea041f2c31 (diff)
parent7c6bd25c7d65e777b5bb26ad5c8248fb3607e6d5 (diff)
downloadgit-02abc6be8eee1ccfcb5f4fb160f53a62c6528c04.zip
git-02abc6be8eee1ccfcb5f4fb160f53a62c6528c04.tar.gz
git-02abc6be8eee1ccfcb5f4fb160f53a62c6528c04.tar.bz2
Merge branch 'mh/avoid-rewriting-packed-refs' into maint
Recent update to the refs infrastructure implementation started rewriting packed-refs file more often than before; this has been optimized again for most trivial cases. * mh/avoid-rewriting-packed-refs: files-backend: don't rewrite the `packed-refs` file unnecessarily t1409: check that `packed-refs` is not rewritten unnecessarily
Diffstat (limited to 'refs/files-backend.c')
-rw-r--r--refs/files-backend.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 8cc1e07..a80d60a 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -2605,7 +2605,23 @@ static int files_transaction_prepare(struct ref_store *ref_store,
goto cleanup;
}
backend_data->packed_refs_locked = 1;
- ret = ref_transaction_prepare(packed_transaction, err);
+
+ if (is_packed_transaction_needed(refs->packed_ref_store,
+ packed_transaction)) {
+ ret = ref_transaction_prepare(packed_transaction, err);
+ } else {
+ /*
+ * We can skip rewriting the `packed-refs`
+ * file. But we do need to leave it locked, so
+ * that somebody else doesn't pack a reference
+ * that we are trying to delete.
+ */
+ if (ref_transaction_abort(packed_transaction, err)) {
+ ret = TRANSACTION_GENERIC_ERROR;
+ goto cleanup;
+ }
+ backend_data->packed_transaction = NULL;
+ }
}
cleanup: