Skip to content

Commit

Permalink
Define cd_to_toplevel shell function in git-sh-setup
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Jan 13, 2007
1 parent b60daf0 commit 9fde940
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions git-sh-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit 9fde940

Please sign in to comment.