@@ -246,9 +246,6 @@ module_name()
246246# $3 = URL to clone
247247# $4 = reference repository to reuse (empty for independent)
248248# $5 = depth argument for shallow clones (empty for deep)
249- # $6 = (remote-tracking) starting point for the local branch (empty for HEAD)
250- # $7 = local branch to create (empty for a detached HEAD, unless $6 is
251- # also empty, in which case the local branch is left unchanged)
252249#
253250# Prior to calling, cmd_update checks that a possibly existing
254251# path is not a git repository.
@@ -262,8 +259,6 @@ module_clone()
262259 url=$3
263260 reference=" $4 "
264261 depth=" $5 "
265- start_point=" $6 "
266- local_branch=" $7 "
267262 quiet=
268263 if test -n " $GIT_QUIET "
269264 then
@@ -317,16 +312,7 @@ module_clone()
317312 echo " gitdir: $rel /$a " > " $sm_path /.git"
318313
319314 rel=$( echo $a | sed -e ' s|[^/][^/]*|..|g' )
320- (
321- clear_local_git_env
322- cd " $sm_path " &&
323- GIT_WORK_TREE=. git config core.worktree " $rel /$b " &&
324- # ash fails to wordsplit ${local_branch:+-B "$local_branch"...}
325- case " $local_branch " in
326- ' ' ) git checkout -f -q ${start_point: +" $start_point " } ;;
327- ?* ) git checkout -f -q -B " $local_branch " ${start_point: +" $start_point " } ;;
328- esac
329- ) || die " $( eval_gettext " Unable to setup cloned submodule '\$ sm_path'" ) "
315+ (clear_local_git_env; cd " $sm_path " && GIT_WORK_TREE=. git config core.worktree " $rel /$b " )
330316}
331317
332318isnumber ()
@@ -489,15 +475,16 @@ Use -f if you really want to add it." >&2
489475 echo " $( eval_gettext " Reactivating local git directory for submodule '\$ sm_name'." ) "
490476 fi
491477 fi
492- if test -n " $branch "
493- then
494- start_point=" origin/$branch "
495- local_branch=" $branch "
496- else
497- start_point=" "
498- local_branch=" "
499- fi
500- module_clone " $sm_path " " $sm_name " " $realrepo " " $reference " " $depth " " $start_point " " $local_branch " || exit
478+ module_clone " $sm_path " " $sm_name " " $realrepo " " $reference " " $depth " || exit
479+ (
480+ clear_local_git_env
481+ cd " $sm_path " &&
482+ # ash fails to wordsplit ${branch:+-b "$branch"...}
483+ case " $branch " in
484+ ' ' ) git checkout -f -q ;;
485+ ?* ) git checkout -f -q -B " $branch " " origin/$branch " ;;
486+ esac
487+ ) || die " $( eval_gettext " Unable to checkout submodule '\$ sm_path'" ) "
501488 fi
502489 git config submodule." $sm_name " .url " $realrepo "
503490
@@ -818,9 +805,7 @@ cmd_update()
818805 fi
819806 name=$( module_name " $sm_path " ) || exit
820807 url=$( git config submodule." $name " .url)
821- config_branch=$( get_submodule_config " $name " branch)
822- branch=" ${config_branch:- master} "
823- local_branch=" $branch "
808+ branch=$( get_submodule_config " $name " branch master)
824809 if ! test -z " $update "
825810 then
826811 update_module=$update
@@ -834,19 +819,11 @@ cmd_update()
834819
835820 displaypath=$( relative_path " $prefix$sm_path " )
836821
837- case " $update_module " in
838- none)
822+ if test " $update_module " = " none "
823+ then
839824 echo " Skipping submodule '$displaypath '"
840825 continue
841- ;;
842- checkout)
843- local_branch=" "
844- ;;
845- rebase | merge | !* )
846- ;;
847- * )
848- die " $( eval_gettext " Invalid update mode '$update_module ' for submodule '$name '" ) "
849- esac
826+ fi
850827
851828 if test -z " $url "
852829 then
@@ -860,8 +837,7 @@ Maybe you want to use 'update --init'?")"
860837
861838 if ! test -d " $sm_path " /.git -o -f " $sm_path " /.git
862839 then
863- start_point=" origin/${branch} "
864- module_clone " $sm_path " " $name " " $url " " $reference " " $depth " " $start_point " " $local_branch " || exit
840+ module_clone " $sm_path " " $name " " $url " " $reference " " $depth " || exit
865841 cloned_modules=" $cloned_modules ;$name "
866842 subsha1=
867843 else
@@ -907,7 +883,7 @@ Maybe you want to use 'update --init'?")"
907883 case " ;$cloned_modules ;" in
908884 * " ;$name ;" * )
909885 # then there is no local change to integrate
910- update_module=' !git reset --hard -q '
886+ update_module=checkout ;;
911887 esac
912888
913889 must_die_on_failure=
0 commit comments