refs: rename get_ref_store() to get_submodule_ref_store() and make it public
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 26 Mar 2017 02:42:33 +0000 (09:42 +0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Apr 2017 10:53:25 +0000 (03:53 -0700)
This function is intended to replace *_submodule() refs API. It provides
a ref store for a specific submodule, which can be operated on by a new
set of refs API.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
refs.h
refs/refs-internal.h
diff --git a/refs.c b/refs.c
index c7bffac06d223a149b12a9830e5a89d90b921d96..fbbd9e1f63a906bff562cc31eb3805afc94f5ed1 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1171,7 +1171,7 @@ int head_ref(each_ref_fn fn, void *cb_data)
 static int do_for_each_ref(const char *submodule, const char *prefix,
                           each_ref_fn fn, int trim, int flags, void *cb_data)
 {
-       struct ref_store *refs = get_ref_store(submodule);
+       struct ref_store *refs = get_submodule_ref_store(submodule);
        struct ref_iterator *iter;
 
        if (!refs)
@@ -1344,10 +1344,10 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,
                /* We need to strip off one or more trailing slashes */
                char *stripped = xmemdupz(submodule, len);
 
-               refs = get_ref_store(stripped);
+               refs = get_submodule_ref_store(stripped);
                free(stripped);
        } else {
-               refs = get_ref_store(submodule);
+               refs = get_submodule_ref_store(submodule);
        }
 
        if (!refs)
@@ -1460,13 +1460,17 @@ static void register_submodule_ref_store(struct ref_store *refs,
                    submodule);
 }
 
-struct ref_store *get_ref_store(const char *submodule)
+struct ref_store *get_submodule_ref_store(const char *submodule)
 {
        struct strbuf submodule_sb = STRBUF_INIT;
        struct ref_store *refs;
        int ret;
 
        if (!submodule || !*submodule) {
+               /*
+                * FIXME: This case is ideally not allowed. But that
+                * can't happen until we clean up all the callers.
+                */
                return get_main_ref_store();
        }
 
diff --git a/refs.h b/refs.h
index a6cd12267fbb7c1ea9e0cba8962239cfb76639cb..e6d8f67895f32549c8eb7a85cd9f4d89d63e939d 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -562,5 +562,16 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
 int ref_storage_backend_exists(const char *name);
 
 struct ref_store *get_main_ref_store(void);
+/*
+ * Return the ref_store instance for the specified submodule. For the
+ * main repository, use submodule==NULL; such a call cannot fail. For
+ * a submodule, the submodule must exist and be a nonbare repository,
+ * otherwise return NULL. If the requested reference store has not yet
+ * been initialized, initialize it first.
+ *
+ * For backwards compatibility, submodule=="" is treated the same as
+ * submodule==NULL.
+ */
+struct ref_store *get_submodule_ref_store(const char *submodule);
 
 #endif /* REFS_H */
index 0cca280b5c0fb31acfeadd87ef141610602ab0f6..f20dde39ee606488f5a479bbda6bfa2042ae2990 100644 (file)
@@ -646,18 +646,6 @@ struct ref_store {
 void base_ref_store_init(struct ref_store *refs,
                         const struct ref_storage_be *be);
 
-/*
- * Return the ref_store instance for the specified submodule. For the
- * main repository, use submodule==NULL; such a call cannot fail. For
- * a submodule, the submodule must exist and be a nonbare repository,
- * otherwise return NULL. If the requested reference store has not yet
- * been initialized, initialize it first.
- *
- * For backwards compatibility, submodule=="" is treated the same as
- * submodule==NULL.
- */
-struct ref_store *get_ref_store(const char *submodule);
-
 const char *resolve_ref_recursively(struct ref_store *refs,
                                    const char *refname,
                                    int resolve_flags,