Skip to content

pr-git-1378/chooglen/fetch/support-super-prefix-v1

From: Glen Choo <chooglen@google.com>

In a repo with partially cloned submodules, "git restore
--recurse-submodules" from the superproject can fail with "fatal: fetch
doesn't support --super-prefix". This error is encountered when the
super prefix is set (either by passing "--super-prefix" or by setting
the GIT_INTERNAL_SUPER_PREFIX env var) on a command that isn't marked
SUPPORT_SUPER_PREFIX. In this case, "git restore --recurse-submodules"
invokes "git read-tree --super-prefix=<path to submodule>", which in
turn, invokes a "git fetch" to fetch promisor objects.

The usefulness of this "--super-prefix" check is up for debate, and
there is WIP to get rid of the option altogether [1], but we can't just
leave "git restore" broken in the meantime, so let's do the barest
minimum to fix this without causing too much trouble for that effort.

Mark cmd_fetch as SUPPORT_SUPER_PREFIX, and add a test that shows that
this fixes the bug described above.

There is precedent for using SUPPORT_SUPER_PREFIX solely as a workaround
for the super prefix check (c.f. [2]), which is all the more reason to
get rid of this check.

[1] https://lore.kernel.org/git/Y27D8QUl3I2d4xNe@nand.local/
[2] 53fcfbc84f (fsmonitor--daemon: allow --super-prefix argument,
    2022-05-26)

Suggested-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Glen Choo <chooglen@google.com>

Submitted-As: https://lore.kernel.org/git/pull.1378.git.git.1668210935360.gitgitgadget@gmail.com
Assets 2