branch: improve advice when --recurse-submodules fails

'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. Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com> Reviewed-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Philippe Blain committed Jan 16, 2023 at 17:41 UTC 97cf0c7de5dd49d9b518ebe694036159f6515422
1 file changed +1 -1
branch.c
+1 -1
@@ -756,7 +756,7 @@ void create_branches_recursively(struct repository *r, const char *name,
756 _("submodule '%s': unable to find submodule"),
757 submodule_entry_list.entries[i].submodule->name);
758 if (advice_enabled(ADVICE_SUBMODULES_NOT_UPDATED))
759 - advise(_("You may try updating the submodules using 'git checkout %s && git submodule update --init'"),
759 + advise(_("You may try updating the submodules using 'git checkout --no-recurse-submodules %s && git submodule update --init'"),
760 start_commitish);
761 exit(code);
762 }