@@ -35,6 +35,7 @@ nofetch=
3535update=
3636prefix=
3737custom_name=
38+ depth=
3839
3940# The function takes at most 2 arguments. The first argument is the
4041# URL that navigates to the submodule origin repo. When relative, this URL
@@ -251,6 +252,7 @@ module_clone()
251252 name=$2
252253 url=$3
253254 reference=" $4 "
255+ depth=" $5 "
254256 quiet=
255257 if test -n " $GIT_QUIET "
256258 then
@@ -273,7 +275,7 @@ module_clone()
273275 mkdir -p " $gitdir_base "
274276 (
275277 clear_local_git_env
276- git clone $quiet -n ${reference: +" $reference " } \
278+ git clone $quiet ${depth : + " $depth " } -n ${reference: +" $reference " } \
277279 --separate-git-dir " $gitdir " " $url " " $sm_path "
278280 ) ||
279281 die " $( eval_gettext " Clone of '\$ url' into submodule path '\$ sm_path' failed" ) "
@@ -350,6 +352,14 @@ cmd_add()
350352 custom_name=$2
351353 shift
352354 ;;
355+ --depth)
356+ case " $2 " in ' ' ) usage ;; esac
357+ depth=" --depth=$2 "
358+ shift
359+ ;;
360+ --depth=* )
361+ depth=$1
362+ ;;
353363 --)
354364 shift
355365 break
@@ -459,7 +469,7 @@ Use -f if you really want to add it." >&2
459469 echo " $( eval_gettext " Reactivating local git directory for submodule '\$ sm_name'." ) "
460470 fi
461471 fi
462- module_clone " $sm_path " " $sm_name " " $realrepo " " $reference " || exit
472+ module_clone " $sm_path " " $sm_name " " $realrepo " " $reference " " $depth " || exit
463473 (
464474 clear_local_git_env
465475 cd " $sm_path " &&
@@ -736,6 +746,14 @@ cmd_update()
736746 --checkout)
737747 update=" checkout"
738748 ;;
749+ --depth)
750+ case " $2 " in ' ' ) usage ;; esac
751+ depth=" --depth=$2 "
752+ shift
753+ ;;
754+ --depth=* )
755+ depth=$1
756+ ;;
739757 --)
740758 shift
741759 break
@@ -797,7 +815,7 @@ Maybe you want to use 'update --init'?")"
797815
798816 if ! test -d " $sm_path " /.git -o -f " $sm_path " /.git
799817 then
800- module_clone " $sm_path " " $name " " $url " " $reference " || exit
818+ module_clone " $sm_path " " $name " " $url " " $reference " " $depth " || exit
801819 cloned_modules=" $cloned_modules ;$name "
802820 subsha1=
803821 else
0 commit comments