summaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorFredrik Gustafsson <iveqy@iveqy.com>2013-07-02 23:42:56 +0200
committerJunio C Hamano <gitster@pobox.com>2013-07-03 10:33:32 -0700
commit275cd184d52b5b81cb89e4ec33e540fb2ae61c1f (patch)
treebbc8d455ea6b67d31c4c2079eada1e7dcf9d927f /git-submodule.sh
parentedca4152560522a431a51fc0a06147fc680b5b18 (diff)
downloadgit-275cd184d52b5b81cb89e4ec33e540fb2ae61c1f.tar.gz
Add --depth to submodule update/addfg/submodule-clone-depth
Add the --depth option to the add and update commands of "git submodule", which is then passed on to the clone command. This is useful when the submodule(s) are huge and you're not really interested in anything but the latest commit. Tests are added and some indention adjustments were made to conform to the rest of the testfile on "submodule update can handle symbolic links in pwd". Signed-off-by: Fredrik Gustafsson <iveqy@iveqy.com> Acked-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh24
1 files changed, 21 insertions, 3 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 79bfaac9d4..2458e1fcfb 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -32,6 +32,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
@@ -211,6 +212,7 @@ module_clone()
name=$2
url=$3
reference="$4"
+ depth="$5"
quiet=
if test -n "$GIT_QUIET"
then
@@ -233,7 +235,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")"
@@ -309,6 +311,14 @@ cmd_add()
custom_name=$2
shift
;;
+ --depth)
+ case "$2" in '') usage ;; esac
+ depth="--depth=$2"
+ shift
+ ;;
+ --depth=*)
+ depth=$1
+ ;;
--)
shift
break
@@ -405,7 +415,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" &&
@@ -676,6 +686,14 @@ cmd_update()
--checkout)
update="checkout"
;;
+ --depth)
+ case "$2" in '') usage ;; esac
+ depth="--depth=$2"
+ shift
+ ;;
+ --depth=*)
+ depth=$1
+ ;;
--)
shift
break
@@ -735,7 +753,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