X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-sh-setup.sh;h=838233926f7ed07f781f2eb2e7547a2a5a086071;hb=78360b576acb0ee47c90552cb3f976a3c6ba4d6a;hp=2142308bcc6d2e2c4962859d18e12070cd4c1b1d;hpb=1487eb68f7fd145151caa9a11ee00283629b75ef;p=git.git diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 2142308bc..838233926 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -85,27 +85,14 @@ cd_to_toplevel () { cdup=$(git rev-parse --show-cdup) if test ! -z "$cdup" then - case "$cdup" in - /*) - # Not quite the same as if we did "cd -P '$cdup'" when - # $cdup contains ".." after symlink path components. - # Don't fix that case at least until Git switches to - # "cd -P" across the board. - phys="$cdup" - ;; - ..|../*|*/..|*/../*) - # Interpret $cdup relative to the physical, not logical, cwd. - # Probably /bin/pwd is more portable than passing -P to cd or pwd. - phys="$(unset PWD; /bin/pwd)/$cdup" - ;; - *) - # There's no "..", so no need to make things absolute. - phys="$cdup" - ;; - esac - - cd "$phys" || { - echo >&2 "Cannot chdir to $phys, the toplevel of the working tree" + # 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 } fi