submodule--helper: introduce new update-module-mode helper

This chews off a bit of the shell part of the update command in
git-submodule.sh. When writing the C code, keep in mind that the
submodule--helper part will go away eventually and we want to have
a C function that is able to determine the submodule update strategy,
it as a nicety, make determine_submodule_update_strategy accessible
for arbitrary repositories.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Stefan Beller
2018-08-13 15:42:35 -07:00
committed by Junio C Hamano
parent 74d4731da1
commit ee69b2a90c
2 changed files with 62 additions and 15 deletions

View File

@ -537,27 +537,13 @@ cmd_update()
git submodule--helper ensure-core-worktree "$sm_path"
name=$(git submodule--helper name "$sm_path") || exit
if ! test -z "$update"
then
update_module=$update
else
update_module=$(git config submodule."$name".update)
if test -z "$update_module"
then
update_module="checkout"
fi
fi
update_module=$(git submodule--helper update-module-mode $just_cloned "$sm_path" $update)
displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
if test $just_cloned -eq 1
then
subsha1=
case "$update_module" in
merge | rebase | none)
update_module=checkout ;;
esac
else
subsha1=$(sanitize_submodule_env; cd "$sm_path" &&
git rev-parse --verify HEAD) ||