[RFC PATCH 2/2] Support shell scripts that run from symlinks into a git working dir
- From
Marcel M. Cary <marcel@oak.homeunix.org>
- Date
- Nov 15, 2008, 15:11 UTC
- Message-ID
- <fff3a66296d7150a3ce07d39032bce668aa3ebd5.1226759762.git.marcel@oak.homeunix.org>
- 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 <marcel@oak.homeunix.org> --- 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