summaryrefslogtreecommitdiff
path: root/git-sh-setup.sh
diff options
context:
space:
mode:
authorSteven Drake <sdrake@xnet.co.nz>2010-01-11 22:34:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-01-12 03:47:52 (GMT)
commit91dc602de9579fe8dc29814819904e2b5a4e92e1 (patch)
tree2e337a7162a9fa0be04189951eb5a55d752b190e /git-sh-setup.sh
parent7cceca5cccdcf1f0f9caa80b82d26fcff65e6fdf (diff)
downloadgit-91dc602de9579fe8dc29814819904e2b5a4e92e1.zip
git-91dc602de9579fe8dc29814819904e2b5a4e92e1.tar.gz
git-91dc602de9579fe8dc29814819904e2b5a4e92e1.tar.bz2
Use $(git rev-parse --show-toplevel) in cd_to_toplevel().
rev-parse --show-toplevel gives the absolute (aka "physical") path of the toplevel directory and is more portable as 'cd -P' is not supported by all shell implementations. This is also closer to what setup_work_tree() does. Signed-off-by: Steven Drake <sdrake@xnet.co.nz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-sh-setup.sh')
-rwxr-xr-xgit-sh-setup.sh19
1 files changed, 5 insertions, 14 deletions
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index dfcb807..d56426d 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -120,20 +120,11 @@ is_bare_repository () {
}
cd_to_toplevel () {
- cdup=$(git rev-parse --show-cdup)
- if test ! -z "$cdup"
- then
- # 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
+ cdup=$(git rev-parse --show-toplevel) &&
+ cd "$cdup" || {
+ echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
+ exit 1
+ }
}
require_work_tree () {