From: Junio C Hamano <gitster@pobox.com>
To: "Alessio Attilio via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Alessio Attilio <attilio.alessio@protonmail.com>
Subject: Re: [PATCH v3 1/2] submodule: prepare URL helpers for reuse
Date: Fri, 27 Nov 2026 19:38:57 -0800 [thread overview]
Message-ID: <xmqq4id1zktq.fsf@gitster.g> (raw)
In-Reply-To: <fc300295ffaef49b592307a90ac3e58bb803b7ca.1795814853.git.gitgitgadget@gmail.com> (Alessio Attilio via GitGitGadget's message of "Fri, 27 Nov 2026 21:27:32 +0000")
"Alessio Attilio via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Alessio Attilio <attilio.alessio@protonmail.com>
>
> Move the relative submodule URL resolver and the helper that computes
> the path back to the superproject from builtin/submodule--helper.c to
> submodule.c so they can be shared with git status.
>
> Pass the repository explicitly to the resolver instead of relying on
> the_repository, and update existing callers to use the shared helpers.
This preparatory extraction may make the next patch easier to read.
Removing the get_default_remote() wrapper that has only one caller, and
calling repo_default_remote(repo) directly is safe too, because
repo_default_remote() returns a pointer owned by repo->remote_state (or
a static "origin" string) and repo_config_get_string() does not
invalidate remote_state before relative_url() runs.
> Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
> ---
> builtin/submodule--helper.c | 63 ++++++-------------------------------
> submodule.c | 41 ++++++++++++++++++++++++
> submodule.h | 3 ++
> 3 files changed, 54 insertions(+), 53 deletions(-)
While this takes 'repo', the fallback when remote.<remote>.url is unset
still calls xgetcwd(). For current callers ('submodule--helper' and
'git status' under RUN_SETUP | NEED_WORK_TREE), the working directory is
already the superproject worktree root, so behavior is preserved.
Still, if a future caller passes a 'struct repository *' for another
worktree or subrepository, xgetcwd() will resolve relative URLs against
the process working directory instead of repo->worktree.
Using
remoteurl = repo->worktree ? xstrdup(repo->worktree) : xgetcwd();
may make the helper genuinely repository-aware, perhaps?
In any case, the "repository-aware" change should be a separate step,
outside the "move code around" step, right?
> diff --git a/submodule.h b/submodule.h
> index 1a465a1208..2028f272c4 100644
> --- a/submodule.h
> +++ b/submodule.h
> @@ -62,6 +62,9 @@ int is_tree_submodule_active(struct repository *repo,
> const struct object_id *treeish_name,
> const char *path);
> int is_submodule_active(struct repository *repo, const char *path);
> +char *resolve_submodule_url(struct repository *repo, const char *url,
> + const char *up_path, int quiet);
> +char *get_submodule_up_path(const char *path);
The header names the second parameter 'url', while the definition in
submodule.c names it 'rel_url'.
It would help to add comments above the declarations of these two
functions and to document that callers free the returned string, that
'up_path' may be NULL, and that get_submodule_up_path() expects a
non-empty 'path' (because it indexes path[strlen(path) - 1]). It would
match the surrounding declarations in this header file.
next prev parent reply other threads:[~2026-11-28 3:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 10:21 [PATCH] status: warn about stale submodule URLs Alessio Attilio via GitGitGadget
2026-11-27 13:41 ` D. Ben Knoble
2026-11-27 16:16 ` [PATCH v2 0/2] status: report when submodule URLs are out of sync Alessio Attilio via GitGitGadget
2026-11-27 16:16 ` [PATCH v2 1/2] submodule: prepare URL helpers for reuse Alessio Attilio via GitGitGadget
2026-11-27 16:16 ` [PATCH v2 2/2] status: warn about stale submodule URLs Alessio Attilio via GitGitGadget
2026-11-27 18:11 ` Junio C Hamano
2026-11-27 20:35 ` ATTILIO ALESSIO
2026-11-30 15:46 ` D. Ben Knoble
2026-11-27 21:27 ` [PATCH v3 0/2] status: report when submodule URLs are out of sync Alessio Attilio via GitGitGadget
2026-11-27 21:27 ` [PATCH v3 1/2] submodule: prepare URL helpers for reuse Alessio Attilio via GitGitGadget
2026-11-28 3:38 ` Junio C Hamano [this message]
2026-11-27 21:27 ` [PATCH v3 2/2] status: warn about stale submodule URLs Alessio Attilio via GitGitGadget
2026-11-28 4:08 ` Junio C Hamano
2026-11-28 4:19 ` [PATCH v3 0/2] status: report when submodule URLs are out of sync Junio C Hamano
2026-11-28 16:53 ` [PATCH v4 0/3] " Alessio Attilio via GitGitGadget
2026-11-28 16:53 ` [PATCH v4 1/3] submodule: move URL helpers into submodule.c Alessio Attilio via GitGitGadget
2026-11-30 15:54 ` D. Ben Knoble
2026-11-28 16:53 ` [PATCH v4 2/3] submodule: make URL resolution repository-aware Alessio Attilio via GitGitGadget
2026-11-30 15:56 ` D. Ben Knoble
2026-11-28 16:53 ` [PATCH v4 3/3] status: report when submodule URLs are out of sync Alessio Attilio via GitGitGadget
2026-11-29 15:42 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq4id1zktq.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=attilio.alessio@protonmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox