Skip to content

Commit

Permalink
Fix CDPATH problem.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Sep 13, 2005
1 parent 2aba319 commit 365527a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions git-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions git-sh-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 365527a

Please sign in to comment.