diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-02-15 01:44:58 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-02-15 01:44:58 -0800 |
commit | f7a2bdb1f070cd79879671391fa8121ef9930abe (patch) | |
tree | 82dca95702b6488df3c099a570add33164df66d3 /git-sh-setup.sh | |
parent | 7b83a9243147a8cec4f556af1d29f2cc21c12518 (diff) | |
parent | 2c3c395e84409c278bd7b050877c36d04b952056 (diff) | |
download | git-f7a2bdb1f070cd79879671391fa8121ef9930abe.tar.gz git-f7a2bdb1f070cd79879671391fa8121ef9930abe.tar.xz |
Merge branch 'mc/setup-cd-p'
* mc/setup-cd-p:
git-sh-setup: Use "cd" option, not /bin/pwd, for symlinked work tree
Diffstat (limited to 'git-sh-setup.sh')
-rwxr-xr-x | git-sh-setup.sh | 29 |
1 files changed, 8 insertions, 21 deletions
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 |