From: W. Trevor King Date: Thu, 09 Jan 2014 06:17:53 GMT Subject: [RFC v3 2/4] submodule: Teach 'update' to preserve local branches Message-ID: <34c874fbdb0c472e1fadc068baaf7ed00b7b696d.1389247320.git.wking@tremily.us> In-Reply-To: From: "W. Trevor King" There's no sense in setting up a local branch if we're just going to go back to a detached HEAD with every checkout-mode update. This commit replaces the checkout with a reset, updating whatever the locally checked out branch (or detached HEAD) happens to be. While it is tempting to checkout a new local-branch here (as we did after the clone), it's more consistent to follow the lead of the other update modes and just use the currently checked out branch. --- git-submodule.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 56fc3f1..c5ea7bd 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -930,9 +930,9 @@ 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'")" + command="git reset --hard -q" + die_msg="$(eval_gettext "Unable to reset branch to '\$sha1' in submodule path '\$displaypath'")" + say_msg="$(eval_gettext "Submodule path '\$displaypath': reset branch to '\$sha1'")" ;; esac -- 1.8.5.2.237.g01c62c6