Fix CDPATH problem.
authorJunio C Hamano <junkio@cox.net>
Tue, 13 Sep 2005 02:47:07 +0000 (19:47 -0700)
committerJunio C Hamano <junkio@cox.net>
Tue, 13 Sep 2005 05:52:51 +0000 (22:52 -0700)
CDPATH has two problems:

* It takes scripts to unexpected places (somebody had
CDPATH=..:../..:$HOME and the "cd" in git-clone.sh:get_repo_base
took him to $HOME/.git when he said "clone foo bar" to clone a
repository in "foo" which had "foo/.git"). CDPATH mechanism does
not implicitly give "." at the beginning of CDPATH, which is
the most irritating part.

* The extra echo when it does its thing confuses scripts further.

Most of our scripts that use "cd" includes git-sh-setup so the problem
is primarily fixed there. git-clone starts without a repository, and
it needs its own fix.

Signed-off-by: Junio C Hamano <junkio@cox.net>
git-clone.sh
git-sh-setup.sh
index c0762922751a8f906116e74fd8a2c2ce19194b2b..a21f13af2ab1ea54db3b8919a5fbb00c5bb59bf4 100755 (executable)
@@ -5,6 +5,9 @@
 # 
 # Clone a repository into a different directory that does not yet exist.
 
+# See git-sh-setup why.
+unset CDPATH
+
 usage() {
        echo >&2 "* git clone [-l [-s]] [-q] [-u <upload-pack>] <repo> <dir>"
        exit 1
index 06d8299ce067a424f047a2830a23ad302d56ec00..d5bfa62dee0e85d404f955edefd2151e8c0e7aab 100755 (executable)
@@ -6,6 +6,12 @@
 : ${GIT_DIR=.git}
 : ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
 
+# Having this variable in your environment would break scripts because
+# you would cause "cd" to be be taken to unexpected places.  If you
+# like CDPATH, define it for your interactive shell sessions without
+# exporting it.
+unset CDPATH
+
 die() {
        echo "$@" >&2
        exit 1