Skip to content

Commit 3ce52cb

Browse files
tfidfwastakengitster
authored andcommitted
submodule--helper: allow setting superprefix for init_submodule()
We allow callers of the `init_submodule()` function to optionally override the superprefix from the environment. We need to enable this option because in our conversion of the update command that will follow, the '--init' option will be handled through this API. We will need to change the superprefix at that time to ensure the display paths show correctly in the output messages. Mentored-by: Christian Couder <[email protected]> Mentored-by: Shourya Shukla <[email protected]> Signed-off-by: Atharva Raykar <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5312a85 commit 3ce52cb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

builtin/submodule--helper.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,18 +594,22 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
594594

595595
struct init_cb {
596596
const char *prefix;
597+
const char *superprefix;
597598
unsigned int flags;
598599
};
599600
#define INIT_CB_INIT { 0 }
600601

601602
static void init_submodule(const char *path, const char *prefix,
602-
unsigned int flags)
603+
const char *superprefix, unsigned int flags)
603604
{
604605
const struct submodule *sub;
605606
struct strbuf sb = STRBUF_INIT;
606607
char *upd = NULL, *url = NULL, *displaypath;
607608

608-
displaypath = get_submodule_displaypath(path, prefix);
609+
/* try superprefix from the environment, if it is not passed explicitly */
610+
if (!superprefix)
611+
superprefix = get_super_prefix();
612+
displaypath = do_get_submodule_displaypath(path, prefix, superprefix);
609613

610614
sub = submodule_from_path(the_repository, null_oid(), path);
611615

@@ -679,7 +683,7 @@ static void init_submodule(const char *path, const char *prefix,
679683
static void init_submodule_cb(const struct cache_entry *list_item, void *cb_data)
680684
{
681685
struct init_cb *info = cb_data;
682-
init_submodule(list_item->name, info->prefix, info->flags);
686+
init_submodule(list_item->name, info->prefix, info->superprefix, info->flags);
683687
}
684688

685689
static int module_init(int argc, const char **argv, const char *prefix)

0 commit comments

Comments
 (0)