Skip to content

Commit 5312a85

Browse files
tfidfwastakengitster
authored andcommitted
submodule--helper: refactor get_submodule_displaypath()
We create a function called `do_get_submodule_displaypath()` that generates the display path required by several submodule functions, and takes a custom superprefix parameter, instead of reading it from the environment. We then redefine the existing `get_submodule_displaypath()` function as a call to this new function, where the superprefix is obtained from the environment. 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 1012a5c commit 5312a85

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

builtin/submodule--helper.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,10 @@ static int resolve_relative_url_test(int argc, const char **argv, const char *pr
247247
return 0;
248248
}
249249

250-
/* the result should be freed by the caller. */
251-
static char *get_submodule_displaypath(const char *path, const char *prefix)
250+
static char *do_get_submodule_displaypath(const char *path,
251+
const char *prefix,
252+
const char *super_prefix)
252253
{
253-
const char *super_prefix = get_super_prefix();
254-
255254
if (prefix && super_prefix) {
256255
BUG("cannot have prefix '%s' and superprefix '%s'",
257256
prefix, super_prefix);
@@ -267,6 +266,13 @@ static char *get_submodule_displaypath(const char *path, const char *prefix)
267266
}
268267
}
269268

269+
/* the result should be freed by the caller. */
270+
static char *get_submodule_displaypath(const char *path, const char *prefix)
271+
{
272+
const char *super_prefix = get_super_prefix();
273+
return do_get_submodule_displaypath(path, prefix, super_prefix);
274+
}
275+
270276
static char *compute_rev_name(const char *sub_path, const char* object_id)
271277
{
272278
struct strbuf sb = STRBUF_INIT;

0 commit comments

Comments
 (0)