summaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-10-10 15:56:16 -0700
committerJunio C Hamano <gitster@pobox.com>2011-10-10 15:56:17 -0700
commitefc5fb6a77780c53c6636326ca82ff87b17e4c5f (patch)
treedf55c7da6100b8b102b183dee72c9137b0d68075 /git-submodule.sh
parent27c0f768843b6d844674f1fb8dc2676d830b56e3 (diff)
parent501770e1bb5d132ae4f79aa96715f07f6b84e1f6 (diff)
downloadgit-efc5fb6a77780c53c6636326ca82ff87b17e4c5f.tar.gz
Merge branch 'fg/submodule-git-file-git-dir'
* fg/submodule-git-file-git-dir: Move git-dir for submodules rev-parse: add option --resolve-git-dir <path> Conflicts: cache.h git-submodule.sh
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh68
1 files changed, 57 insertions, 11 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 814d0d914e..928a62f626 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -128,13 +128,49 @@ module_clone()
quiet=-q
fi
- if test -n "$reference"
+ gitdir=
+ gitdir_base=
+ name=$(module_name "$path")
+ base_path=$(dirname "$path")
+
+ gitdir=$(git rev-parse --git-dir)
+ gitdir_base="$gitdir/modules/$base_path"
+ gitdir="$gitdir/modules/$path"
+
+ case $gitdir in
+ /*)
+ a="$(cd_to_toplevel && pwd)/"
+ b=$gitdir
+ while [ "$b" ] && [ "${a%%/*}" = "${b%%/*}" ]
+ do
+ a=${a#*/} b=${b#*/};
+ done
+
+ rel="$a$name"
+ rel=`echo $rel | sed -e 's|[^/]*|..|g'`
+ rel_gitdir="$rel/$b"
+ ;;
+ *)
+ rel=`echo $name | sed -e 's|[^/]*|..|g'`
+ rel_gitdir="$rel/$gitdir"
+ ;;
+ esac
+
+ if test -d "$gitdir"
then
- git-clone $quiet "$reference" -n "$url" "$path"
+ mkdir -p "$path"
+ echo "gitdir: $rel_gitdir" >"$path/.git"
+ rm -f "$gitdir/index"
else
- git-clone $quiet -n "$url" "$path"
- fi ||
- die "$(eval_gettext "Clone of '\$url' into submodule path '\$path' failed")"
+ mkdir -p "$gitdir_base"
+ if test -n "$reference"
+ then
+ git-clone $quiet "$reference" -n "$url" "$path" --separate-git-dir "$gitdir"
+ else
+ git-clone $quiet -n "$url" "$path" --separate-git-dir "$gitdir"
+ fi ||
+ die "$(eval_gettext "Clone of '\$url' into submodule path '\$path' failed")"
+ fi
}
#
@@ -426,6 +462,9 @@ cmd_update()
--recursive)
recursive=1
;;
+ --checkout)
+ update="checkout"
+ ;;
--)
shift
break
@@ -458,7 +497,19 @@ cmd_update()
fi
name=$(module_name "$path") || exit
url=$(git config submodule."$name".url)
- update_module=$(git config submodule."$name".update)
+ if ! test -z "$update"
+ then
+ update_module=$update
+ else
+ update_module=$(git config submodule."$name".update)
+ fi
+
+ if test "$update_module" = "none"
+ then
+ echo "Skipping submodule '$path'"
+ continue
+ fi
+
if test -z "$url"
then
# Only mention uninitialized submodules when its
@@ -480,11 +531,6 @@ Maybe you want to use 'update --init'?")"
die "$(eval_gettext "Unable to find current revision in submodule path '\$path'")"
fi
- if ! test -z "$update"
- then
- update_module=$update
- fi
-
if test "$subsha1" != "$sha1"
then
subforce=$force