refs: add a transaction_commit() method
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ronnie Sahlberg committed
Sep 4, 2016 at 18:08 UTC
127b42a18618538438b811a29cd95e79c646eb70
3 files changed
+20
-4
refs.c
+9
@@ -1377,3 +1377,12 @@ void assert_main_repository(struct ref_store *refs, const char *caller)
1377
if (*refs->submodule)
1378
die("BUG: %s called for a submodule", caller);
1379
}
1380
+
1381
+/* backend functions */
1382
+int ref_transaction_commit(struct ref_transaction *transaction,
1383
+ struct strbuf *err)
1384
+{
1385
+ struct ref_store *refs = get_ref_store(NULL);
1386
+
1387
+ return refs->be->transaction_commit(refs, transaction, err);
1388
+}
refs/files-backend.c
+6
-4
@@ -3700,11 +3700,12 @@ static int lock_ref_for_update(struct ref_update *update,
3700
return 0;
3701
}
3702
3703
-int ref_transaction_commit(struct ref_transaction *transaction,
3704
- struct strbuf *err)
3703
+static int files_transaction_commit(struct ref_store *ref_store,
3704
+ struct ref_transaction *transaction,
3705
+ struct strbuf *err)
3706
{
3707
struct files_ref_store *refs =
3707
- get_files_ref_store(NULL, "ref_transaction_commit");
3708
+ files_downcast(ref_store, 0, "ref_transaction_commit");
3709
int ret = 0, i;
3710
struct string_list refs_to_delete = STRING_LIST_INIT_NODUP;
3711
struct string_list_item *ref_to_delete;
@@ -4093,5 +4094,6 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
4094
struct ref_storage_be refs_be_files = {
4095
NULL,
4096
"files",
4096
- files_ref_store_create
4097
+ files_ref_store_create,
4098
+ files_transaction_commit
4099
};
refs/refs-internal.h
+5
@@ -535,10 +535,15 @@ int read_raw_ref(const char *refname, unsigned char *sha1,
535
*/
536
typedef struct ref_store *ref_store_init_fn(const char *submodule);
537
538
+typedef int ref_transaction_commit_fn(struct ref_store *refs,
539
+ struct ref_transaction *transaction,
540
+ struct strbuf *err);
541
+
542
struct ref_storage_be {
543
struct ref_storage_be *next;
544
const char *name;
545
ref_store_init_fn *init;
546
+ ref_transaction_commit_fn *transaction_commit;
547
};
548
549
extern struct ref_storage_be refs_be_files;