Skip to contentSkip to conversation

branch: improve advice when --recurse-submodules fails

PATCH In review Philippe Blain via GitGitGadget 2 participants 2 messages Jan 16, 2023 – Jan 18, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 branch: improve advice when --recurse-submodules fails

From: Philippe Blain <[email protected]>

'git branch --recurse-submodules start from-here' fails if any submodule present in 'from-here' is not yet cloned (under submodule.propagateBranches=true). We then give this advice:

"You may try updating the submodules using 'git checkout from-here && git submodule update --init'"

If 'submodule.recurse' is set, 'git checkout from-here' will also fail since it will try to recursively checkout the submodules.

Improve the advice by adding '--no-recurse-submodules' to the checkout command.

---
branch: improve advice when --recurse-submodules fails

Hi Glen,

This is a small improvement I thought about when looking at that code recently.

Cheers,

Philippe.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1464%2Fphil-blain%2Fbranch-recurse-improve-advice-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1464/phil-blain/branch-recurse-improve-advice-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1464

 branch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
branch.c +1 -1
index d182756827f..e5614b53b36 100644
@@ -756,7 +756,7 @@ void create_branches_recursively(struct repository *r, const char *name,
 				_("submodule '%s': unable to find submodule"),
 				submodule_entry_list.entries[i].submodule->name);
 			if (advice_enabled(ADVICE_SUBMODULES_NOT_UPDATED))
-				advise(_("You may try updating the submodules using 'git checkout %s && git submodule update --init'"),
+				advise(_("You may try updating the submodules using 'git checkout --no-recurse-submodules %s && git submodule update --init'"),
 				       start_commitish);
 			exit(code);
 		}

base-commit: 4dbebc36b0893f5094668ddea077d0e235560b16

Signature · 1 line
gitgitgadget
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Philippe Blain via GitGitGadget

From: Philippe Blain <[email protected]>

'git branch --recurse-submodules start from-here' fails if any submodule present in 'from-here' is not yet cloned (under submodule.propagateBranches=true). We then give this advice:

"You may try updating the submodules using 'git checkout from-here && git submodule update --init'"

If 'submodule.recurse' is set, 'git checkout from-here' will also fail since it will try to recursively checkout the submodules.

Ah, yes that is true.

Quoted 6 lines
branch.c +0 -0
index d182756827f..e5614b53b36 100644

branch.c void create_branches_recursively(struct repository *r, const char *name, · line 762

Quoted 8 lines
branch.c +1 -1
@@ -756,7 +756,7 @@ void create_branches_recursively(struct repository *r, const char *name,
 				_("submodule '%s': unable to find submodule"),
 				submodule_entry_list.entries[i].submodule->name);
 			if (advice_enabled(ADVICE_SUBMODULES_NOT_UPDATED))
-				advise(_("You may try updating the submodules using 'git checkout %s && git submodule update --init'"),
+				advise(_("You may try updating the submodules using 'git checkout --no-recurse-submodules %s && git submodule update --init'"),
 				       start_commitish);
 			exit(code);
 		}

Makes sense. Thanks!