OSDN Git Service

refs: make verify_refname_available() virtual
authorMichael Haggerty <mhagger@alum.mit.edu>
Sun, 4 Sep 2016 16:08:26 +0000 (18:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Sep 2016 22:28:13 +0000 (15:28 -0700)
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 775c54e..a5c1108 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1428,3 +1428,13 @@ int ref_transaction_commit(struct ref_transaction *transaction,
 
        return refs->be->transaction_commit(refs, transaction, err);
 }
+
+int verify_refname_available(const char *refname,
+                            const struct string_list *extra,
+                            const struct string_list *skip,
+                            struct strbuf *err)
+{
+       struct ref_store *refs = get_ref_store(NULL);
+
+       return refs->be->verify_refname_available(refs, refname, extra, skip, err);
+}
index 9cf2f82..44eef1c 100644 (file)
@@ -2549,13 +2549,14 @@ out:
        return ret;
 }
 
-int verify_refname_available(const char *newname,
-                            const struct string_list *extras,
-                            const struct string_list *skip,
-                            struct strbuf *err)
+static int files_verify_refname_available(struct ref_store *ref_store,
+                                         const char *newname,
+                                         const struct string_list *extras,
+                                         const struct string_list *skip,
+                                         struct strbuf *err)
 {
        struct files_ref_store *refs =
-               get_files_ref_store(NULL, "verify_refname_available");
+               files_downcast(ref_store, 1, "verify_refname_available");
        struct ref_dir *packed_refs = get_packed_refs(refs);
        struct ref_dir *loose_refs = get_loose_refs(refs);
 
@@ -4021,5 +4022,6 @@ struct ref_storage_be refs_be_files = {
        files_ref_store_create,
        files_transaction_commit,
 
-       files_read_raw_ref
+       files_read_raw_ref,
+       files_verify_refname_available
 };
index 19cb6e1..6c698f4 100644 (file)
@@ -542,6 +542,12 @@ typedef int read_raw_ref_fn(struct ref_store *ref_store,
                            const char *refname, unsigned char *sha1,
                            struct strbuf *referent, unsigned int *type);
 
+typedef int verify_refname_available_fn(struct ref_store *ref_store,
+                                       const char *newname,
+                                       const struct string_list *extras,
+                                       const struct string_list *skip,
+                                       struct strbuf *err);
+
 struct ref_storage_be {
        struct ref_storage_be *next;
        const char *name;
@@ -549,6 +555,7 @@ struct ref_storage_be {
        ref_transaction_commit_fn *transaction_commit;
 
        read_raw_ref_fn *read_raw_ref;
+       verify_refname_available_fn *verify_refname_available;
 };
 
 extern struct ref_storage_be refs_be_files;