@matheusbsbs / matheus-bagliano / commits / 9fde9401a9
Fork 0

Define cd_to_toplevel shell function in git-sh-setup

Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jan 12, 2007 at 12:44 UTC 9fde9401a9c3974a407f302d60a1b75e8787f715
1 file changed +11
git-sh-setup.sh
+11
@@ -36,6 +36,17 @@ is_bare_repository () {
36 esac
37 }
38
39 +cd_to_toplevel () {
40 + cdup=$(git-rev-parse --show-cdup)
41 + if test ! -z "$cdup"
42 + then
43 + cd "$cdup" || {
44 + echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
45 + exit 1
46 + }
47 + fi
48 +}
49 +
50 require_work_tree () {
51 test $(is_bare_repository) = false ||
52 die "fatal: $0 cannot be used without a working tree."