diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index dbdf209ec0e7d6468c199d1905c3e7788a9cd246..838233926f7ed07f781f2eb2e7547a2a5a086071 100755 (executable)
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
cdup=$(git rev-parse --show-cdup)
if test ! -z "$cdup"
then
- cd "$cdup" || {
+ # The "-P" option says to follow "physical" directory
+ # structure instead of following symbolic links. When cdup is
+ # "../", this means following the ".." entry in the current
+ # directory instead textually removing a symlink path element
+ # from the PWD shell variable. The "-P" behavior is more
+ # consistent with the C-style chdir used by most of Git.
+ cd -P "$cdup" || {
echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
exit 1
}