From: Han-Wen Nienhuys <hanwen@xxxxxxxxxx> Reftable updates are cheap (compared to packed-refs updates), so do them always. This also helps exercise this code more in tests. This should commit should not be merged currently. It fails 55 tests when running with GIT_TEST_REFTABLE. Signed-off-by: Han-Wen Nienhuys <hanwen@xxxxxxxxxx> --- refs/files-backend.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 2cd596bbeba..0d61a18b4ba 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -2800,6 +2800,7 @@ static int files_transaction_prepare(struct ref_store *ref_store, int head_type; struct files_transaction_backend_data *backend_data; struct ref_transaction *packed_transaction = NULL; + int is_reftable = !strcmp(refs->packed_ref_store->be->name, "reftable"); assert(err); @@ -2809,6 +2810,16 @@ static int files_transaction_prepare(struct ref_store *ref_store, CALLOC_ARRAY(backend_data, 1); transaction->backend_data = backend_data; + if (is_reftable) { + packed_transaction = ref_store_transaction_begin( + refs->packed_ref_store, err); + if (!packed_transaction) { + ret = TRANSACTION_GENERIC_ERROR; + goto cleanup; + } + backend_data->packed_transaction = packed_transaction; + } + /* * Fail if a refname appears more than once in the * transaction. (If we end up splitting up any updates using @@ -2881,9 +2892,9 @@ static int files_transaction_prepare(struct ref_store *ref_store, if (ret) goto cleanup; - if (update->flags & REF_DELETING && - !(update->flags & REF_LOG_ONLY) && - !(update->flags & REF_IS_PRUNING)) { + if (is_reftable || (update->flags & REF_DELETING && + !(update->flags & REF_LOG_ONLY) && + !(update->flags & REF_IS_PRUNING))) { /* * This reference has to be deleted from * packed-refs if it exists there. @@ -2909,8 +2920,9 @@ static int files_transaction_prepare(struct ref_store *ref_store, } if (packed_transaction) { - backend_data->packed_transaction_needed = is_packed_transaction_needed(refs->packed_ref_store, - packed_transaction); + backend_data->packed_transaction_needed = is_reftable || + is_packed_transaction_needed(refs->packed_ref_store, + packed_transaction); if (backend_data->packed_transaction_needed) { ret = ref_transaction_prepare(packed_transaction, err); /* -- gitgitgadget