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>
Steven Drake committed
Jan 12, 2010 at 11:34 UTC
91dc602de9579fe8dc29814819904e2b5a4e92e1
1 file changed
+5
-14
git-sh-setup.sh
+5
-14
@@ -120,20 +120,11 @@ is_bare_repository () {
120
}
121
122
cd_to_toplevel () {
123
- cdup=$(git rev-parse --show-cdup)
124
- if test ! -z "$cdup"
125
- then
126
- # The "-P" option says to follow "physical" directory
127
- # structure instead of following symbolic links. When cdup is
128
- # "../", this means following the ".." entry in the current
129
- # directory instead textually removing a symlink path element
130
- # from the PWD shell variable. The "-P" behavior is more
131
- # consistent with the C-style chdir used by most of Git.
132
- cd -P "$cdup" || {
133
- echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
134
- exit 1
135
- }
136
- fi
123
+ cdup=$(git rev-parse --show-toplevel) &&
124
+ cd "$cdup" || {
125
+ echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
126
+ exit 1
127
+ }
128
}
129
130
require_work_tree () {