[RFC v3 2/4] submodule: Teach 'update' to preserve local branches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "W. Trevor King" <wking@xxxxxxxxxx>

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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]