git-gui: Cleaned up error message formatting.

Added an extra blank line between the first line of each error message
and the rest of the message, as usually the rest of the message is
coming from Tcl or is the stderr output of a git command we tried to
invoke.  This makes it easier to read the output (if any).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
diff --git a/git-gui b/git-gui
index 81fe38f..4449c7d 100755
--- a/git-gui
+++ b/git-gui
@@ -73,7 +73,8 @@
 			end]
 		append title {)}
 	}
-	tk_messageBox -parent . \
+	tk_messageBox \
+		-parent . \
 		-icon error \
 		-type ok \
 		-title "$title: error" \
@@ -84,8 +85,10 @@
 ##
 ## repository setup
 
-if {[catch {set cdup [exec git rev-parse --show-cdup]} err]} {
-	error_popup "Cannot find the git directory:\n$err"
+if {   [catch {set cdup [exec git rev-parse --show-cdup]} err]
+	|| [catch {set gitdir [exec git rev-parse --git-dir]} err]} {
+	catch {wm withdraw .}
+	error_popup "Cannot find the git directory:\n\n$err"
 	exit 1
 }
 if {$cdup != ""} {
@@ -93,11 +96,6 @@
 }
 unset cdup
 
-if {[catch {set gitdir [exec git rev-parse --git-dir]} err]} {
-	error_popup "Cannot find the git directory:\n$err"
-	exit 1
-}
-
 if {$appname == {git-citool}} {
 	set single_commit 1
 }
@@ -420,7 +418,7 @@
 			set diff_active 0
 			unlock_index
 			set ui_status_value "Unable to display [escape_path $path]"
-			error_popup "Error loading file:\n$err"
+			error_popup "Error loading file:\n\n$err"
 			return
 		}
 		$ui_diff conf -state normal
@@ -437,7 +435,7 @@
 		set diff_active 0
 		unlock_index
 		set ui_status_value "Unable to display [escape_path $path]"
-		error_popup "Error loading diff:\n$err"
+		error_popup "Error loading diff:\n\n$err"
 		return
 	}
 
@@ -523,7 +521,7 @@
 			set msg [string trim [read $fd]]
 			close $fd
 		} err]} {
-		error_popup "Error loading commit data for amend:\n$err"
+		error_popup "Error loading commit data for amend:\n\n$err"
 		return
 	}
 
@@ -655,10 +653,8 @@
 	global file_states
 
 	gets $fd_wt tree_id
-	close $fd_wt
-
-	if {$tree_id == {}} {
-		error_popup "write-tree failed"
+	if {$tree_id == {} || [catch {close $fd_wt} err]} {
+		error_popup "write-tree failed:\n\n$err"
 		set commit_active 0
 		set ui_status_value {Commit failed.}
 		unlock_index
@@ -679,7 +675,7 @@
 				}
 				close $fd_mh
 			} err]} {
-			error_popup "Loading MERGE_HEAD failed:\n$err"
+			error_popup "Loading MERGE_HEAD failed:\n\n$err"
 			set commit_active 0
 			set ui_status_value {Commit failed.}
 			unlock_index
@@ -692,7 +688,7 @@
 	}
 	lappend cmd << $msg
 	if {[catch {set cmt_id [eval exec $cmd]} err]} {
-		error_popup "commit-tree failed:\n$err"
+		error_popup "commit-tree failed:\n\n$err"
 		set commit_active 0
 		set ui_status_value {Commit failed.}
 		unlock_index
@@ -713,7 +709,7 @@
 	}
 	set cmd [list git update-ref -m $reflogm HEAD $cmt_id $curHEAD]
 	if {[catch {eval exec $cmd} err]} {
-		error_popup "update-ref failed:\n$err"
+		error_popup "update-ref failed:\n\n$err"
 		set commit_active 0
 		set ui_status_value {Commit failed.}
 		unlock_index
@@ -1481,12 +1477,12 @@
 
 	if {$GIT_COMMITTER_IDENT == {}} {
 		if {[catch {set me [exec git var GIT_COMMITTER_IDENT]} err]} {
-			error_popup "Unable to obtain your identity:\n$err"
+			error_popup "Unable to obtain your identity:\n\n$err"
 			return
 		}
 		if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \
 			$me me GIT_COMMITTER_IDENT]} {
-			error_popup "Invalid GIT_COMMITTER_IDENT:\n$me"
+			error_popup "Invalid GIT_COMMITTER_IDENT:\n\n$me"
 			return
 		}
 	}