git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2 (v2)] submodule: no [--merge|--rebase] when newly cloned
@ 2011-02-17 16:18 Spencer E. Olson
  2011-02-17 16:18 ` [PATCH 2/2 (v2)] t7406: "git submodule update {--merge|--rebase]" with new submodules Spencer E. Olson
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Spencer E. Olson @ 2011-02-17 16:18 UTC (permalink / raw)
  To: git; +Cc: Spencer E. Olson

Previously, when a new submodule is cloned by running "git submodule update
[--merge|--rebase]", the newly cloned submodule does not get checked out and a
rebase or merge is incorrectly attempted against an empty working directory.
This patch ignores --rebase or --merge for new submodules and instead simply
checks out the appropriate revision.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
---
 git-submodule.sh |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 8b90589..7724885 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -365,6 +365,19 @@ cmd_init()
 }
 
 #
+# Test whether an element of the ';' separated list $2 matches $1
+#
+list_contains()
+{
+	case "$2;" in
+	*";$1;"*)
+		: yes ;;
+	*)
+		! : no ;;
+	esac
+}
+
+#
 # Update each submodule path to correct revision, using clone and checkout as needed
 #
 # $@ = requested paths (default to all)
@@ -423,6 +436,7 @@ cmd_update()
 		cmd_init "--" "$@" || return
 	fi
 
+	cloned_modules=
 	module_list "$@" |
 	while read mode sha1 stage path
 	do
@@ -442,6 +456,7 @@ cmd_update()
 		if ! test -d "$path"/.git -o -f "$path"/.git
 		then
 			module_clone "$path" "$url" "$reference"|| exit
+			cloned_modules="$cloned_modules;$name"
 			subsha1=
 		else
 			subsha1=$(clear_local_git_env; cd "$path" &&
@@ -469,6 +484,12 @@ cmd_update()
 				die "Unable to fetch in submodule path '$path'"
 			fi
 
+			list_contains "$name" "$cloned_modules"
+			if test "$?" = 0
+			then
+				update_module=
+			fi
+
 			case "$update_module" in
 			rebase)
 				command="git rebase"
-- 
1.7.4.1.42.g43f9f

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-02-18  0:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-17 16:18 [PATCH 1/2 (v2)] submodule: no [--merge|--rebase] when newly cloned Spencer E. Olson
2011-02-17 16:18 ` [PATCH 2/2 (v2)] t7406: "git submodule update {--merge|--rebase]" with new submodules Spencer E. Olson
2011-02-17 19:43   ` Jens Lehmann
2011-02-17 20:18     ` Junio C Hamano
2011-02-17 21:39       ` Jens Lehmann
2011-02-17 19:41 ` [PATCH 1/2 (v2)] submodule: no [--merge|--rebase] when newly cloned Jens Lehmann
2011-02-17 20:25   ` Junio C Hamano
2011-02-17 22:17     ` Spencer E. Olson
2011-02-17 23:37       ` Junio C Hamano
2011-02-17 23:50         ` Spencer E. Olson
2011-02-17 20:02 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).