diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-09-23 13:44:49 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-09-23 13:44:49 -0700 |
commit | f7511fdfbd6dc249aca551d56fcb3011d85ddd08 (patch) | |
tree | a3ad3c5cac546e8f00fa84c31184f1ef92bf8018 /builtin/submodule--helper.c | |
parent | Merge branch 'ma/doc-git-version' (diff) | |
parent | submodule: extract path to submodule gitdir func (diff) | |
download | tgif-f7511fdfbd6dc249aca551d56fcb3011d85ddd08.tar.xz |
Merge branch 'jt/submodule-name-to-gitdir'
Code refactoring.
* jt/submodule-name-to-gitdir:
submodule: extract path to submodule gitdir func
Diffstat (limited to 'builtin/submodule--helper.c')
-rw-r--r-- | builtin/submodule--helper.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index f8fb70c826..5336daf186 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1668,18 +1668,24 @@ static int add_possible_reference_from_superproject( * standard layout with .git/(modules/<name>)+/objects */ if (strip_suffix(odb->path, "/objects", &len)) { + struct repository alternate; char *sm_alternate; struct strbuf sb = STRBUF_INIT; struct strbuf err = STRBUF_INIT; strbuf_add(&sb, odb->path, len); + repo_init(&alternate, sb.buf, NULL); + /* * We need to end the new path with '/' to mark it as a dir, * otherwise a submodule name containing '/' will be broken * as the last part of a missing submodule reference would * be taken as a file name. */ - strbuf_addf(&sb, "/modules/%s/", sas->submodule_name); + strbuf_reset(&sb); + submodule_name_to_gitdir(&sb, &alternate, sas->submodule_name); + strbuf_addch(&sb, '/'); + repo_clear(&alternate); sm_alternate = compute_alternate_path(sb.buf, &err); if (sm_alternate) { @@ -1749,7 +1755,7 @@ static int clone_submodule(struct module_clone_data *clone_data) struct strbuf sb = STRBUF_INIT; struct child_process cp = CHILD_PROCESS_INIT; - strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), clone_data->name); + submodule_name_to_gitdir(&sb, the_repository, clone_data->name); sm_gitdir = absolute_pathdup(sb.buf); strbuf_reset(&sb); |