aboutsummaryrefslogtreecommitdiffstats
path: root/git-clone-script
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-07-08 15:46:33 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-08 15:46:33 -0700
commitba375acff7692cbca16f7cc2e69b71563188ab7f (patch)
tree2259172791ee09de8f115e3ec147fb27814608ce /git-clone-script
parent51cb06c36de67007f3464d864f63d93213fcaf86 (diff)
downloadgit-ba375acff7692cbca16f7cc2e69b71563188ab7f.tar.gz
Make "git clone" a lot more user-friendly
This silently adds the ".git" directory component if needed, so you don't need to state it explicitly for the source. Also, it turns the source into an absolute pathname when local, so that you can use relative pathnames without losing sight of the source when we cd into the destination.
Diffstat (limited to 'git-clone-script')
-rwxr-xr-xgit-clone-script16
1 files changed, 14 insertions, 2 deletions
diff --git a/git-clone-script b/git-clone-script
index 4f80ade21c..19697427ec 100755
--- a/git-clone-script
+++ b/git-clone-script
@@ -10,6 +10,10 @@ usage() {
exit 1
}
+get_repo_base() {
+ (cd "$1" && (cd .git ; pwd)) 2> /dev/null
+}
+
use_local=no
while
case "$#,$1" in
@@ -22,7 +26,15 @@ do
shift
done
+# Turn the source into an absolute path if
+# it is local
repo="$1"
+local=no
+if base=$(get_repo_base "$repo"); then
+ repo="$base"
+ local=yes
+fi
+
dir="$2"
mkdir "$dir" &&
D=$(
@@ -31,8 +43,8 @@ D=$(
test -d "$D" || usage
# We do local magic only when the user tells us to.
-case "$use_local" in
-yes)
+case "$local,$use_local" in
+yes,yes)
( cd "$repo/objects" ) || {
repo="$repo/.git"
( cd "$repo/objects" ) || {