Define cd_to_toplevel shell function in git-sh-setup

Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Junio C Hamano 2007-01-12 12:44:08 -08:00
parent b60daf0515
commit 9fde9401a9

View File

@ -36,6 +36,17 @@ is_bare_repository () {
esac
}
cd_to_toplevel () {
cdup=$(git-rev-parse --show-cdup)
if test ! -z "$cdup"
then
cd "$cdup" || {
echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
exit 1
}
fi
}
require_work_tree () {
test $(is_bare_repository) = false ||
die "fatal: $0 cannot be used without a working tree."