Created
August 17, 2011 16:57
-
-
Save suzak/1152012 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/git-submodule.sh b/git-submodule.sh | |
index d189a24..1ab1f70 100755 | |
--- a/git-submodule.sh | |
+++ b/git-submodule.sh | |
@@ -121,12 +121,29 @@ module_clone() | |
path=$1 | |
url=$2 | |
reference="$3" | |
+ submodulecachedir=$(git config --path submodule.cachedir) | |
if test -n "$reference" | |
then | |
git-clone "$reference" -n "$url" "$path" | |
else | |
- git-clone -n "$url" "$path" | |
+ if test -n "$submodulecachedir" -a x$(which git-new-workdir) != x | |
+ then | |
+ cachedir="$submodulecachedir/$(echo $url | sed -e 's/:/\//g')" | |
+ if test ! -e "$cachedir" | |
+ then | |
+ git-clone -n "$url" "$cachedir" | |
+ fi | |
+ if test -e "$path" | |
+ then | |
+ # When git-clone parent repository, | |
+ # git-1.7.4+ makes submodule directory. | |
+ rmdir "$path" | |
+ fi | |
+ git-new-workdir "$cachedir" "$path" | |
+ else | |
+ git-clone -n "$url" "$path" | |
+ fi | |
fi || | |
die "Clone of '$url' into submodule path '$path' failed" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment