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>
This commit is contained in:
Steven Drake 2010-01-12 11:34:34 +13:00 коммит произвёл Junio C Hamano
Родитель 7cceca5ccc
Коммит 91dc602de9
1 изменённых файлов: 5 добавлений и 14 удалений

Просмотреть файл

@ -120,20 +120,11 @@ is_bare_repository () {
} }
cd_to_toplevel () { cd_to_toplevel () {
cdup=$(git rev-parse --show-cdup) cdup=$(git rev-parse --show-toplevel) &&
if test ! -z "$cdup" cd "$cdup" || {
then echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
# The "-P" option says to follow "physical" directory exit 1
# 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
} }
require_work_tree () { require_work_tree () {