From: Jeff King <peff@peff.net>
To: Taylor Blau <me@ttaylorr.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Tribo Dar <3bodar@gmail.com>,
Stefan Beller <stefanbeller@gmail.com>,
Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH v3] builtin/submodule--helper.c: handle missing submodule URLs
Date: Wed, 24 May 2023 16:33:21 -0400 [thread overview]
Message-ID: <20230524203321.GD892557@coredump.intra.peff.net> (raw)
In-Reply-To: <ae6cf3fa461b85e346f034371dae56a2790dfa20.1684957882.git.me@ttaylorr.com>
On Wed, May 24, 2023 at 03:51:43PM -0400, Taylor Blau wrote:
> In e0a862fdaf (submodule helper: convert relative URL to absolute URL if
> needed, 2018-10-16), `prepare_to_clone_next_submodule()` lost the
> ability to handle URL-less submodules, due to a change from:
>
> if (repo_get_config_string_const(the_repostiory, sb.buf, &url))
> url = sub->url;
>
> to
>
> if (repo_get_config_string_const(the_repostiory, sb.buf, &url)) {
> if (starts_with_dot_slash(sub->url) ||
> starts_with_dot_dot_slash(sub->url)) {
> /* ... */
> }
> }
This patch looks pretty good to me. I read your v1 and the word "gross"
also crossed my mind at the "--url" handling. This one is much better.
I did have a few questions, though (below).
If I understand correctly, this is not at all new in the -rc releases,
but just something that happened to get unearthed? I.e., it can wait
until post-release.
> , which will segfault when `sub->url` is NULL, since both
> `starts_with_dot_slash()` does not guard its arguments as non-NULL.
Funny gramm-o, presumably from editing: "both" is plural, but "does" and
"its" are singular. I think the gist of it is communicated, though.
> Guard the checks to both of the above functions by first checking
> whether `sub->url` is non-NULL. There is no need to check whether `sub`
> itself is NULL, since we already perform this check earlier in
> `prepare_to_clone_next_submodule()`.
Good, thanks for checking (and communicating) that possible gotha.
> By adding a NULL-ness check on `sub->url`, we'll fall into the 'else'
> branch, setting `url` to `sub->url` (which is NULL). Before attempting
> to invoke `git submodule--helper clone`, check whether `url` is NULL,
> and die() if it is.
If I hadn't read v1, I might wonder whether this die() is consistent
with the existing behavior. But the point is that submodule--helper
would have barfed in such a case anyway, so we are just trading one
error for another.
One side effect, though, is that this die() will take down the whole
superproject process. Whereas I think the intent of the submodule code
is to keep going, handling other submodules, even if one fails. This
isn't a failure exactly (more of a misconfiguration, if I understand
it). But should we be somehow returning an error instead?
I say "somehow" because it's not clear how to work that in with the
needs_cloning return value (obviously we can say "0", but that is the
same as the "skipped" code path; we presumably want to tell the caller
there was a failure, so it affects the ultimate return code).
> +test_expect_success 'update submodules without url set in .gitconfig' '
Should this be .gitmodules in the title?
-Peff
next prev parent reply other threads:[~2023-05-24 20:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-24 6:59 [BUG] Segmentation fault in git v2.41.0.rc1 Tribo Dar
2023-05-24 14:47 ` Taylor Blau
2023-05-24 16:02 ` [PATCH] builtin/submodule--helper.c: handle missing submodule URLs Taylor Blau
2023-05-24 16:25 ` [PATCH v2] " Taylor Blau
2023-05-24 18:48 ` Eric Sunshine
2023-05-24 19:50 ` Taylor Blau
2023-05-24 19:51 ` [PATCH v3] " Taylor Blau
2023-05-24 20:29 ` René Scharfe
2023-05-24 20:36 ` Taylor Blau
2023-05-24 20:33 ` Jeff King [this message]
2023-05-24 22:58 ` [PATCH] " Jeff King
2023-05-24 20:25 ` [BUG] Segmentation fault in git v2.41.0.rc1 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=20230524203321.GD892557@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=3bodar@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@ttaylorr.com \
--cc=stefanbeller@gmail.com \
--cc=sunshine@sunshineco.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).