Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] [submodule] Add depth to submodule update

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:55

Summoning area experts ;-)

Thanks.

Fredrik Gustafsson [off-list ref] writes:
quoted hunk
Used only when a clone is initialized. This is useful when the submodule(s)
are huge and you're not really interested in anything but the latest commit.

Signed-off-by: Fredrik Gustafsson <redacted>
---
 git-submodule.sh | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 79bfaac..b102fa8 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -211,12 +211,18 @@ module_clone()
 	name=$2
 	url=$3
 	reference="$4"
+	depth=$5
 	quiet=
 	if test -n "$GIT_QUIET"
 	then
 		quiet=-q
 	fi

+	if test -n "$depth"
+	then
+		depth="--depth=$depth"
+	fi
+
 	gitdir=
 	gitdir_base=
 	base_name=$(dirname "$name")
@@ -233,7 +239,7 @@ module_clone()
 		mkdir -p "$gitdir_base"
 		(
 			clear_local_git_env
-			git clone $quiet -n ${reference:+"$reference"} \
+			git clone $quiet $depth -n ${reference:+"$reference"} \
 				--separate-git-dir "$gitdir" "$url" "$sm_path"
 		) ||
 		die "$(eval_gettext "Clone of '\$url' into submodule path '\$sm_path' failed")"
@@ -676,6 +682,9 @@ cmd_update()
 		--checkout)
 			update="checkout"
 			;;
+		--depth)
+			depth=$2
+			;;
 		--)
 			shift
 			break
@@ -735,7 +744,7 @@ Maybe you want to use 'update --init'?")"

 		if ! test -d "$sm_path"/.git -o -f "$sm_path"/.git
 		then
-			module_clone "$sm_path" "$name" "$url" "$reference" || exit
+			module_clone "$sm_path" "$name" "$url" "$reference" "$depth" || exit
 			cloned_modules="$cloned_modules;$name"
 			subsha1=
 		else
--
1.8.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help