summaryrefslogtreecommitdiff
path: root/git-clone.sh
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-05-09 17:11:15 -0700
committerJunio C Hamano <junkio@cox.net>2007-05-10 13:26:14 -0700
commitc2f599e09fd0496413d1744b5b89b9b5c223555d (patch)
tree7a1ea1e4ad23972c12bef9281edf9034cfe16640 /git-clone.sh
parentc69f4050958b648acd668b37dc77772e05148a97 (diff)
downloadgit-c2f599e09fd0496413d1744b5b89b9b5c223555d.tar.gz
git-clone: don't get fooled by $PWD
If you have /home/me/git symlink pointing at /pub/git/mine, trying to clone from /pub/git/his/ using relative path would not work as expected: $ cd /home/me $ cd git $ ls ../ his mine $ git clone -l -s -n ../his/stuff.git This is because "cd ../his/stuff.git" done inside git-clone to check if the repository is local is confused by $PWD, which is set to /home/me, and tries to go to /home/his/stuff.git which is different from /pub/git/his/stuff.git. We could probably say "set -P" (or "cd -P") instead, if we know the shell is POSIX, but the way the patch is coded is probably more portable. [jc: this is updated with Andy Whitcroft's improvements] Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-clone.sh')
-rwxr-xr-xgit-clone.sh9
1 files changed, 8 insertions, 1 deletions
diff --git a/git-clone.sh b/git-clone.sh
index cad5c0c088..70374aaaf0 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -18,7 +18,14 @@ usage() {
}
get_repo_base() {
- (cd "$1" && (cd .git ; pwd)) 2> /dev/null
+ (
+ cd "`/bin/pwd`" &&
+ cd "$1" &&
+ {
+ cd .git 2>/dev/null
+ pwd
+ }
+ )
}
if [ -n "$GIT_SSL_NO_VERIFY" ]; then