Skip to content

Commit a2aed08

Browse files
wkinggitster
authored andcommitted
submodule: make 'checkout' update_module mode more explicit
This avoids the current awkwardness of having either '' or 'checkout' for checkout-mode updates, which makes testing for checkout-mode updates (or non-checkout-mode updates) easier. Signed-off-by: W. Trevor King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent efa8fd7 commit a2aed08

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

git-submodule.sh

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -803,17 +803,10 @@ cmd_update()
803803
update_module=$update
804804
else
805805
update_module=$(git config submodule."$name".update)
806-
case "$update_module" in
807-
'')
808-
;; # Unset update mode
809-
checkout | rebase | merge | none)
810-
;; # Known update modes
811-
!*)
812-
;; # Custom update command
813-
*)
814-
die "$(eval_gettext "Invalid update mode '$update_module' for submodule '$name'")"
815-
;;
816-
esac
806+
if test -z "$update_module"
807+
then
808+
update_module="checkout"
809+
fi
817810
fi
818811

819812
displaypath=$(relative_path "$prefix$sm_path")
@@ -882,11 +875,16 @@ Maybe you want to use 'update --init'?")"
882875
case ";$cloned_modules;" in
883876
*";$name;"*)
884877
# then there is no local change to integrate
885-
update_module= ;;
878+
update_module=checkout ;;
886879
esac
887880

888881
must_die_on_failure=
889882
case "$update_module" in
883+
checkout)
884+
command="git checkout $subforce -q"
885+
die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$displaypath'")"
886+
say_msg="$(eval_gettext "Submodule path '\$displaypath': checked out '\$sha1'")"
887+
;;
890888
rebase)
891889
command="git rebase"
892890
die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$displaypath'")"
@@ -906,10 +904,7 @@ Maybe you want to use 'update --init'?")"
906904
must_die_on_failure=yes
907905
;;
908906
*)
909-
command="git checkout $subforce -q"
910-
die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$displaypath'")"
911-
say_msg="$(eval_gettext "Submodule path '\$displaypath': checked out '\$sha1'")"
912-
;;
907+
die "$(eval_gettext "Invalid update mode '$update_module' for submodule '$name'")"
913908
esac
914909

915910
if (clear_local_git_env; cd "$sm_path" && $command "$sha1")

0 commit comments

Comments
 (0)