From: Eric Sunshine <sunshine@sunshineco.com>
To: Mara <mara@marabos.nl>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Use correct default remote for fetching in submodule.
Date: Mon, 13 Feb 2023 08:45:15 -0500 [thread overview]
Message-ID: <CAPig+cRotsJZHnRMUqWaYz=nw1sBRsW5ms7WWuApviG2be2GTQ@mail.gmail.com> (raw)
In-Reply-To: <623b0b8a-a5b3-408c-b924-9f88d9763b0e@app.fastmail.com>
On Mon, Feb 13, 2023 at 8:31 AM Mara <mara@marabos.nl> wrote:
> "git submodule update" first tries a regular "git fetch"
> to fetch the commit, but when that doesn't retrieve the commit
> it wants, it tries "git fetch <remote> <commit>".
> For <remote>, it used the wrong default remote: the default
> remote of the outer repository, rather than the default remote
> of the submodule.
>
> Signed-off-by: Mara Bos <mara@marabos.nl>
> ---
I'm not a submodule user and I don't have any particular familiarity
with this code, so I may be wrong, but...
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index 4c173d8b37..50b96e0b9d 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -2225,7 +2225,10 @@ static int fetch_in_submodule(const char *module_path, int depth, int quiet,
> - char *remote = get_default_remote();
> + char *remote;
> + int code = get_default_remote_submodule(module_path, &remote);
> + if (code)
> + return code;
> strvec_pushl(&cp.args, remote, hex, NULL);
> free(remote);
... it looks like this change may introduce a memory leak. Digging
down through get_default_remote_submodule() and the functions it
calls, it appears that repo_get_default_remote() can return a non-zero
code _after_ it has allocated memory for `remote`. If I'm reading this
correctly, then the above should probably be:
char *remote = NULL;
int code = get_default_remote_submodule(module_path, &remote);
if (code) {
free(remote);
return code;
}
Also, if possible, add a new test, perhaps to
t/t7406-submodule-update.sh, demonstrating that this change fixes the
problem and to ensure that it doesn't get broken again. If you have a
minimal-reproduction recipe which exhibits the problem, then you may
be able to turn it into an actual test.
prev parent reply other threads:[~2023-02-13 13:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-13 13:14 [PATCH] Use correct default remote for fetching in submodule Mara
2023-02-13 13:45 ` Eric Sunshine [this message]
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='CAPig+cRotsJZHnRMUqWaYz=nw1sBRsW5ms7WWuApviG2be2GTQ@mail.gmail.com' \
--to=sunshine@sunshineco.com \
--cc=git@vger.kernel.org \
--cc=mara@marabos.nl \
/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;
as well as URLs for NNTP newsgroup(s).