Skip to content

Commit

Permalink
submodule: make 'checkout' update_module mode more explicit
Browse files Browse the repository at this point in the history
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 <wking@tremily.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
W. Trevor King authored and Junio C Hamano committed Feb 24, 2014
1 parent efa8fd7 commit a2aed08
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions git-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -803,17 +803,10 @@ cmd_update()
update_module=$update
else
update_module=$(git config submodule."$name".update)
case "$update_module" in
'')
;; # Unset update mode
checkout | rebase | merge | none)
;; # Known update modes
!*)
;; # Custom update command
*)
die "$(eval_gettext "Invalid update mode '$update_module' for submodule '$name'")"
;;
esac
if test -z "$update_module"
then
update_module="checkout"
fi
fi

displaypath=$(relative_path "$prefix$sm_path")
Expand Down Expand Up @@ -882,11 +875,16 @@ Maybe you want to use 'update --init'?")"
case ";$cloned_modules;" in
*";$name;"*)
# then there is no local change to integrate
update_module= ;;
update_module=checkout ;;
esac

must_die_on_failure=
case "$update_module" in
checkout)
command="git checkout $subforce -q"
die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$displaypath'")"
say_msg="$(eval_gettext "Submodule path '\$displaypath': checked out '\$sha1'")"
;;
rebase)
command="git rebase"
die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$displaypath'")"
Expand All @@ -906,10 +904,7 @@ Maybe you want to use 'update --init'?")"
must_die_on_failure=yes
;;
*)
command="git checkout $subforce -q"
die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$displaypath'")"
say_msg="$(eval_gettext "Submodule path '\$displaypath': checked out '\$sha1'")"
;;
die "$(eval_gettext "Invalid update mode '$update_module' for submodule '$name'")"
esac

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

0 comments on commit a2aed08

Please sign in to comment.