Skip to content

Commit efa8fd7

Browse files
ceztkogitster
authored andcommitted
git-submodule.sh: 'checkout' is a valid update mode
'checkout' is documented as one of the valid values for the 'submodule.<name>.update' variable, and in a repository with the variable set to 'checkout', "git submodule update" command does update using the 'checkout' mode. However, it has been an accident that the implementation works this way; any unknown value would trigger the same codepath and update using the 'checkout' mode. Explicitly list 'checkout' as one of the known update modes, and error out when an unknown update mode is used. Teach the codepath that initializes the configuration variable from an in-tree .gitmodules that 'checkout' is one of the valid values. The code since ac1fbbd (submodule: do not copy unknown update mode from .gitmodules, 2013-12-02) used to treat the value 'checkout' as unknown and mapped it to 'none', which made little sense. With this change, 'checkout' specified in .gitmodules will stay to be 'checkout'. Signed-off-by: Francesco Pretto <[email protected]> Signed-off-by: Signed-off-by: Junio C Hamano <[email protected]>
1 parent b9cf14d commit efa8fd7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

git-submodule.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ cmd_init()
617617
test -z "$(git config submodule."$name".update)"
618618
then
619619
case "$upd" in
620-
rebase | merge | none)
620+
checkout | rebase | merge | none)
621621
;; # known modes of updating
622622
*)
623623
echo >&2 "warning: unknown update mode '$upd' suggested for submodule '$name'"
@@ -803,6 +803,17 @@ 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
806817
fi
807818

808819
displaypath=$(relative_path "$prefix$sm_path")

0 commit comments

Comments
 (0)