diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-07-15 10:28:48 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-07-15 10:28:48 -0700 |
commit | 2bb7aface663f4d9f01d08282ee38cf8f636df0d (patch) | |
tree | d09bfbfb5dd648bff2d895ea23edceb8e50dc033 /git-submodule.sh | |
parent | 3bb6149186ea6bed5e6fd7b2f830fb499a1a8658 (diff) | |
parent | 275cd184d52b5b81cb89e4ec33e540fb2ae61c1f (diff) | |
download | git-2bb7aface663f4d9f01d08282ee38cf8f636df0d.tar.gz |
Merge branch 'fg/submodule-clone-depth'
Allow shallow-cloning of submodules with "git submodule update".
* fg/submodule-clone-depth:
Add --depth to submodule update/add
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-x | git-submodule.sh | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/git-submodule.sh b/git-submodule.sh index c87515de10..2979197087 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -35,6 +35,7 @@ nofetch= update= prefix= custom_name= +depth= # The function takes at most 2 arguments. The first argument is the # URL that navigates to the submodule origin repo. When relative, this URL @@ -251,6 +252,7 @@ module_clone() name=$2 url=$3 reference="$4" + depth="$5" quiet= if test -n "$GIT_QUIET" then @@ -273,7 +275,7 @@ module_clone() mkdir -p "$gitdir_base" ( clear_local_git_env - git clone $quiet -n ${reference:+"$reference"} \ + git clone $quiet ${depth:+"$depth"} -n ${reference:+"$reference"} \ --separate-git-dir "$gitdir" "$url" "$sm_path" ) || die "$(eval_gettext "Clone of '\$url' into submodule path '\$sm_path' failed")" @@ -350,6 +352,14 @@ cmd_add() custom_name=$2 shift ;; + --depth) + case "$2" in '') usage ;; esac + depth="--depth=$2" + shift + ;; + --depth=*) + depth=$1 + ;; --) shift break @@ -459,7 +469,7 @@ Use -f if you really want to add it." >&2 echo "$(eval_gettext "Reactivating local git directory for submodule '\$sm_name'.")" fi fi - module_clone "$sm_path" "$sm_name" "$realrepo" "$reference" || exit + module_clone "$sm_path" "$sm_name" "$realrepo" "$reference" "$depth" || exit ( clear_local_git_env cd "$sm_path" && @@ -736,6 +746,14 @@ cmd_update() --checkout) update="checkout" ;; + --depth) + case "$2" in '') usage ;; esac + depth="--depth=$2" + shift + ;; + --depth=*) + depth=$1 + ;; --) shift break @@ -797,7 +815,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 |