fetch: support "--super-prefix"
PATCH 1/1 fetch: support "--super-prefix"
From: Glen Choo <[email protected]>
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/[email protected]/
[2] 53fcfbc84f (fsmonitor--daemon: allow --super-prefix argument,
2022-05-26)
---
fetch: support "--super-prefix"
Since "git read-tree" is seriously broken at the moment, let's not keep it hostage to the work on [1]. This is Ævar's suggested change from [2] combined with my partial clone test case from [3].
I think we can take this regardless of where we are with the RFCs; it's simple and obvious enough that it adds virtually no churn to the RFCs.
[1] https://lore.kernel.org/git/[email protected]/ [2]
https://lore.kernel.org/git/[email protected]
[3]
https://lore.kernel.org/git/[email protected]
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1378%2Fchooglen%2Ffetch%2Fsupport-super-prefix-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1378/chooglen/fetch/support-super-prefix-v1
Pull-Request: https://github.com/git/git/pull/1378
builtin/fetch.c | 6 ++++++ git.c | 2 +- t/t5616-partial-clone.sh | 43 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-)
builtin/fetch.c +6 -0
@@ -2114,6 +2114,12 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)int result =0 ;int prune_tags_ok =1 ; +/* +* NEEDSWORK: we don't actually use "--super-prefix". Unset it +* so that we don't accidentally use it or pass it down. +*/ +unsetenv (GIT_SUPER_PREFIX_ENVIRONMENT ); +packet_trace_identity ("fetch" );/* Record the command line for the reflog */
git.c +1 -1
@@ -531,7 +531,7 @@ static struct cmd_struct commands[] = { { "env--helper", cmd_env__helper }, { "fast-export", cmd_fast_export, RUN_SETUP }, { "fast-import", cmd_fast_import, RUN_SETUP | NO_PARSEOPT }, - { "fetch", cmd_fetch, RUN_SETUP }, + { "fetch", cmd_fetch, RUN_SETUP | SUPPORT_SUPER_PREFIX }, { "fetch-pack", cmd_fetch_pack, RUN_SETUP | NO_PARSEOPT }, { "fmt-merge-msg", cmd_fmt_merge_msg, RUN_SETUP }, { "for-each-ref", cmd_for_each_ref, RUN_SETUP },
t/t5616-partial-clone.sh +43 -0
49 lines not on this page · raw message
base-commit: 319605f8f00e402f3ea758a02c63534ff800a711
Signature · 1 line
gitgitgadget