Skip to content

Commit 18d0002

Browse files
pcloudsgitster
authored andcommitted
refs: rename get_ref_store() to get_submodule_ref_store() and make it public
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>
1 parent 9e7ec63 commit 18d0002

3 files changed

Lines changed: 19 additions & 16 deletions

File tree

refs.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ int head_ref(each_ref_fn fn, void *cb_data)
11711171
static int do_for_each_ref(const char *submodule, const char *prefix,
11721172
each_ref_fn fn, int trim, int flags, void *cb_data)
11731173
{
1174-
struct ref_store *refs = get_ref_store(submodule);
1174+
struct ref_store *refs = get_submodule_ref_store(submodule);
11751175
struct ref_iterator *iter;
11761176

11771177
if (!refs)
@@ -1344,10 +1344,10 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,
13441344
/* We need to strip off one or more trailing slashes */
13451345
char *stripped = xmemdupz(submodule, len);
13461346

1347-
refs = get_ref_store(stripped);
1347+
refs = get_submodule_ref_store(stripped);
13481348
free(stripped);
13491349
} else {
1350-
refs = get_ref_store(submodule);
1350+
refs = get_submodule_ref_store(submodule);
13511351
}
13521352

13531353
if (!refs)
@@ -1460,13 +1460,17 @@ static void register_submodule_ref_store(struct ref_store *refs,
14601460
submodule);
14611461
}
14621462

1463-
struct ref_store *get_ref_store(const char *submodule)
1463+
struct ref_store *get_submodule_ref_store(const char *submodule)
14641464
{
14651465
struct strbuf submodule_sb = STRBUF_INIT;
14661466
struct ref_store *refs;
14671467
int ret;
14681468

14691469
if (!submodule || !*submodule) {
1470+
/*
1471+
* FIXME: This case is ideally not allowed. But that
1472+
* can't happen until we clean up all the callers.
1473+
*/
14701474
return get_main_ref_store();
14711475
}
14721476

refs.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,5 +562,16 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
562562
int ref_storage_backend_exists(const char *name);
563563

564564
struct ref_store *get_main_ref_store(void);
565+
/*
566+
* Return the ref_store instance for the specified submodule. For the
567+
* main repository, use submodule==NULL; such a call cannot fail. For
568+
* a submodule, the submodule must exist and be a nonbare repository,
569+
* otherwise return NULL. If the requested reference store has not yet
570+
* been initialized, initialize it first.
571+
*
572+
* For backwards compatibility, submodule=="" is treated the same as
573+
* submodule==NULL.
574+
*/
575+
struct ref_store *get_submodule_ref_store(const char *submodule);
565576

566577
#endif /* REFS_H */

refs/refs-internal.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -646,18 +646,6 @@ struct ref_store {
646646
void base_ref_store_init(struct ref_store *refs,
647647
const struct ref_storage_be *be);
648648

649-
/*
650-
* Return the ref_store instance for the specified submodule. For the
651-
* main repository, use submodule==NULL; such a call cannot fail. For
652-
* a submodule, the submodule must exist and be a nonbare repository,
653-
* otherwise return NULL. If the requested reference store has not yet
654-
* been initialized, initialize it first.
655-
*
656-
* For backwards compatibility, submodule=="" is treated the same as
657-
* submodule==NULL.
658-
*/
659-
struct ref_store *get_ref_store(const char *submodule);
660-
661649
const char *resolve_ref_recursively(struct ref_store *refs,
662650
const char *refname,
663651
int resolve_flags,

0 commit comments

Comments
 (0)