Use cd_to_toplevel in scripts that implement it by hand.

This converts scripts that do "cd $(rev-parse --show-cdup)" by
hand to use cd_to_toplevel.

I think git-fetch does not have to go to the toplevel, but that
should be dealt with in a separate patch.

Signed-off-by: Junio C Hamano <junkio@cox.net>
diff --git a/git-commit.sh b/git-commit.sh
index eddd863..9fdf234 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -316,22 +316,16 @@
 ################################################################
 # Prepare index to have a tree to be committed
 
-TOP=`git-rev-parse --show-cdup`
-if test -z "$TOP"
-then
-	TOP=./
-fi
-
 case "$all,$also" in
 t,)
 	save_index &&
 	(
-		cd "$TOP"
-		GIT_INDEX_FILE="$NEXT_INDEX"
-		export GIT_INDEX_FILE
+		cd_to_toplevel &&
+		GIT_INDEX_FILE="$NEXT_INDEX" &&
+		export GIT_INDEX_FILE &&
 		git-diff-files --name-only -z |
 		git-update-index --remove -z --stdin
-	)
+	) || exit
 	;;
 ,t)
 	save_index &&
@@ -339,11 +333,11 @@
 
 	git-diff-files --name-only -z -- "$@"  |
 	(
-		cd "$TOP"
-		GIT_INDEX_FILE="$NEXT_INDEX"
-		export GIT_INDEX_FILE
+		cd_to_toplevel &&
+		GIT_INDEX_FILE="$NEXT_INDEX" &&
+		export GIT_INDEX_FILE &&
 		git-update-index --remove -z --stdin
-	)
+	) || exit
 	;;
 ,)
 	case "$#" in