From: Marcel M. Cary Date: Sat, 15 Nov 2008 15:11:35 GMT Subject: [RFC PATCH 2/2] Support shell scripts that run from symlinks into a git working dir Message-ID: In-Reply-To: <096bfa3393a6c5ccaa550ae6363e7fcfc90867d1.1226759762.git.marcel@oak.homeunix.org> Use "cd -P" instead of just "cd" when switching to the top level of the git working directory. When working from a symlink into GIT_WORK_TREE, the shell function cd_to_toplevel will now change to GIT_WORK_TREE rather than the parent of the symlink, which may not even be the root of a git working directory. Unfortunately this solution looks non-portable. Signed-off-by: Marcel M. Cary --- git-sh-setup.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/git-sh-setup.sh b/git-sh-setup.sh index dbdf209..4006150 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -85,7 +85,7 @@ cd_to_toplevel () { cdup=$(git rev-parse --show-cdup) if test ! -z "$cdup" then - cd "$cdup" || { + cd -P "$cdup" || { echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree" exit 1 } -- 1.6.0.3