diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2009-05-04 22:30:01 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-05-09 08:27:52 -0700 |
commit | d92a39590d1126e195f1bbccf182a2cdb79218e7 (patch) | |
tree | 016b4a01b26e65ee21e9e852f164e5004ebb8f40 /git-submodule.sh | |
parent | f01f1099f40f24fe6f7802185340a6fa3a3d4f35 (diff) | |
download | git-d92a39590d1126e195f1bbccf182a2cdb79218e7.tar.gz |
Add --reference option to git submodule.
This adds --reference option to git submodule add and
git submodule update commands, which is passed to git clone.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-x | git-submodule.sh | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/git-submodule.sh b/git-submodule.sh index 8e234a4028..ab1ed02a66 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -15,6 +15,7 @@ require_work_tree command= branch= quiet= +reference= cached= nofetch= @@ -91,6 +92,7 @@ module_clone() { path=$1 url=$2 + reference="$3" # If there already is a directory at the submodule path, # expect it to be empty (since that is the default checkout @@ -106,7 +108,12 @@ module_clone() test -e "$path" && die "A file already exist at path '$path'" - git-clone -n "$url" "$path" || + if test -n "$reference" + then + git-clone "$reference" -n "$url" "$path" + else + git-clone -n "$url" "$path" + fi || die "Clone of '$url' into submodule path '$path' failed" } @@ -131,6 +138,15 @@ cmd_add() -q|--quiet) quiet=1 ;; + --reference) + case "$2" in '') usage ;; esac + reference="--reference=$2" + shift + ;; + --reference=*) + reference="$1" + shift + ;; --) shift break @@ -203,7 +219,7 @@ cmd_add() git config submodule."$path".url "$url" else - module_clone "$path" "$realrepo" || exit + module_clone "$path" "$realrepo" "$reference" || exit ( unset GIT_DIR cd "$path" && @@ -314,13 +330,22 @@ cmd_update() quiet=1 ;; -i|--init) + init=1 shift - cmd_init "$@" || return ;; -N|--no-fetch) shift nofetch=1 ;; + --reference) + case "$2" in '') usage ;; esac + reference="--reference=$2" + shift 2 + ;; + --reference=*) + reference="$1" + shift + ;; --) shift break @@ -334,6 +359,11 @@ cmd_update() esac done + if test -n "$init" + then + cmd_init "--" "$@" || return + fi + module_list "$@" | while read mode sha1 stage path do @@ -351,7 +381,7 @@ cmd_update() if ! test -d "$path"/.git -o -f "$path"/.git then - module_clone "$path" "$url" || exit + module_clone "$path" "$url" "$reference"|| exit subsha1= else subsha1=$(unset GIT_DIR; cd "$path" && |