refs: add a transaction_commit() method
authorRonnie Sahlberg <sahlberg@google.com>
Sun, 4 Sep 2016 16:08:16 +0000 (18:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Sep 2016 22:28:12 +0000 (15:28 -0700)
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>
refs.c
refs/files-backend.c
refs/refs-internal.h
diff --git a/refs.c b/refs.c
index ca57a6e1e5e6837e75d6bb7068b7467d50c56390..abccd7ebd775314280087789c65e6fb6eaa90878 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1377,3 +1377,12 @@ void assert_main_repository(struct ref_store *refs, const char *caller)
        if (*refs->submodule)
                die("BUG: %s called for a submodule", caller);
 }
+
+/* backend functions */
+int ref_transaction_commit(struct ref_transaction *transaction,
+                          struct strbuf *err)
+{
+       struct ref_store *refs = get_ref_store(NULL);
+
+       return refs->be->transaction_commit(refs, transaction, err);
+}
index 17404413cc813b3f0b16bbb1ba0b0c463451481b..2d847f57e438b2342eb0846c4f60ba89203e2df7 100644 (file)
@@ -3700,11 +3700,12 @@ static int lock_ref_for_update(struct ref_update *update,
        return 0;
 }
 
-int ref_transaction_commit(struct ref_transaction *transaction,
-                          struct strbuf *err)
+static int files_transaction_commit(struct ref_store *ref_store,
+                                   struct ref_transaction *transaction,
+                                   struct strbuf *err)
 {
        struct files_ref_store *refs =
-               get_files_ref_store(NULL, "ref_transaction_commit");
+               files_downcast(ref_store, 0, "ref_transaction_commit");
        int ret = 0, i;
        struct string_list refs_to_delete = STRING_LIST_INIT_NODUP;
        struct string_list_item *ref_to_delete;
@@ -4093,5 +4094,6 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
 struct ref_storage_be refs_be_files = {
        NULL,
        "files",
-       files_ref_store_create
+       files_ref_store_create,
+       files_transaction_commit
 };
index b952038bf1489e75bac277532a73486b86b86c8a..b7367ab4c16a97c5d7f1a19a052addf1c76aea76 100644 (file)
@@ -535,10 +535,15 @@ int read_raw_ref(const char *refname, unsigned char *sha1,
  */
 typedef struct ref_store *ref_store_init_fn(const char *submodule);
 
+typedef int ref_transaction_commit_fn(struct ref_store *refs,
+                                     struct ref_transaction *transaction,
+                                     struct strbuf *err);
+
 struct ref_storage_be {
        struct ref_storage_be *next;
        const char *name;
        ref_store_init_fn *init;
+       ref_transaction_commit_fn *transaction_commit;
 };
 
 extern struct ref_storage_be refs_be_files;