git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] submodule add: sanity check existing .gitmodules

From
Elijah Newren <newren@gmail.com>
Date
Nov 25, 2025, 06:49 UTC
Message-ID
<CABPp-BES6HBGxXKC9sfBHu_5oBEDYD+aDquHtoDSZtZdaqOMBQ@mail.gmail.com>
In-Reply-To
<xmqqv7jacvdq.fsf@gitster.g>
On Sat, Nov 15, 2025 at 11:03 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 6 quoted lines
>
> "git submodule add" tries to find if a submodule with the same name
> already exists at a different path, by looking up an entry in the
> .gitmodules file.  If the entry in the file is incomplete, e.g.,
> when the submodule.<name>.something variable is defined but there is
> no definition of submodule.<name>.path variable, it accessing the
accessing => tries to access
  (or accessing => accesses)
Show 16 quoted lines
> missing .path member of the submodule structure and triggers a
> segfault.
>
> A brief audit was done to make sure that the code does not assume
> members other than those that are absolutely certain to exist: a
> submodule obtained by submodule_from_name() should have .name
> member, while a submodule obtained by submodule_from_path() should
> also have .path as well as .name member, and we cannot assume
> anything else.  Luckily, the module_add() codepath was the only
> problematic one.  It is fairly recent code that comes from 1fa06ced
> (submodule: prevent overwriting .gitmodules on path reuse,
> 2025-07-24).
>
> A helper used by update_submodule() seems to assume that its call to
> submodule_from_path() always yields a submodule object without a
> failure, which seems to rely on the caller's making sure it is the
caller's => caller ?
> case.  Leave an assert() with a NEEDSWORK comment there for future
> developers to make sure the assumption actually holds.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 3 in “submodule add: sanity check existing .gitmodules”
  1. submodule add: sanity check existing .gitmodulesJunio C Hamano, Nov 16, 2025
  2. Elijah NewrenNov 25, 2025
  3. Junio C HamanoNov 25, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.