@matheusbsbs / matheus-bagliano / commits / 44be340e4d
Fork 0

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>

Shawn O. Pearce committed Nov 11, 2006 at 19:10 UTC 44be340e4d8d39475e86d3e00cec31fec0d0f6c1
1 file changed +16 -20
git-gui
+16 -20
@@ -73,7 +73,8 @@ proc error_popup {msg} {
73 end]
74 append title {)}
75 }
76 - tk_messageBox -parent . \
76 + tk_messageBox \
77 + -parent . \
78 -icon error \
79 -type ok \
80 -title "$title: error" \
@@ -84,8 +85,10 @@ proc error_popup {msg} {
85 ##
86 ## repository setup
87
87 -if {[catch {set cdup [exec git rev-parse --show-cdup]} err]} {
88 - error_popup "Cannot find the git directory:\n$err"
88 +if { [catch {set cdup [exec git rev-parse --show-cdup]} err]
89 + || [catch {set gitdir [exec git rev-parse --git-dir]} err]} {
90 + catch {wm withdraw .}
91 + error_popup "Cannot find the git directory:\n\n$err"
92 exit 1
93 }
94 if {$cdup != ""} {
@@ -93,11 +96,6 @@ if {$cdup != ""} {
96 }
97 unset cdup
98
96 -if {[catch {set gitdir [exec git rev-parse --git-dir]} err]} {
97 - error_popup "Cannot find the git directory:\n$err"
98 - exit 1
99 -}
100 -
99 if {$appname == {git-citool}} {
100 set single_commit 1
101 }
@@ -420,7 +418,7 @@ proc show_diff {path {w {}} {lno {}}} {
418 set diff_active 0
419 unlock_index
420 set ui_status_value "Unable to display [escape_path $path]"
423 - error_popup "Error loading file:\n$err"
421 + error_popup "Error loading file:\n\n$err"
422 return
423 }
424 $ui_diff conf -state normal
@@ -437,7 +435,7 @@ proc show_diff {path {w {}} {lno {}}} {
435 set diff_active 0
436 unlock_index
437 set ui_status_value "Unable to display [escape_path $path]"
440 - error_popup "Error loading diff:\n$err"
438 + error_popup "Error loading diff:\n\n$err"
439 return
440 }
441
@@ -523,7 +521,7 @@ proc load_last_commit {} {
521 set msg [string trim [read $fd]]
522 close $fd
523 } err]} {
526 - error_popup "Error loading commit data for amend:\n$err"
524 + error_popup "Error loading commit data for amend:\n\n$err"
525 return
526 }
527
@@ -655,10 +653,8 @@ proc commit_stage2 {fd_wt curHEAD msg} {
653 global file_states
654
655 gets $fd_wt tree_id
658 - close $fd_wt
659 -
660 - if {$tree_id == {}} {
661 - error_popup "write-tree failed"
656 + if {$tree_id == {} || [catch {close $fd_wt} err]} {
657 + error_popup "write-tree failed:\n\n$err"
658 set commit_active 0
659 set ui_status_value {Commit failed.}
660 unlock_index
@@ -679,7 +675,7 @@ proc commit_stage2 {fd_wt curHEAD msg} {
675 }
676 close $fd_mh
677 } err]} {
682 - error_popup "Loading MERGE_HEAD failed:\n$err"
678 + error_popup "Loading MERGE_HEAD failed:\n\n$err"
679 set commit_active 0
680 set ui_status_value {Commit failed.}
681 unlock_index
@@ -692,7 +688,7 @@ proc commit_stage2 {fd_wt curHEAD msg} {
688 }
689 lappend cmd << $msg
690 if {[catch {set cmt_id [eval exec $cmd]} err]} {
695 - error_popup "commit-tree failed:\n$err"
691 + error_popup "commit-tree failed:\n\n$err"
692 set commit_active 0
693 set ui_status_value {Commit failed.}
694 unlock_index
@@ -713,7 +709,7 @@ proc commit_stage2 {fd_wt curHEAD msg} {
709 }
710 set cmd [list git update-ref -m $reflogm HEAD $cmt_id $curHEAD]
711 if {[catch {eval exec $cmd} err]} {
716 - error_popup "update-ref failed:\n$err"
712 + error_popup "update-ref failed:\n\n$err"
713 set commit_active 0
714 set ui_status_value {Commit failed.}
715 unlock_index
@@ -1481,12 +1477,12 @@ proc do_signoff {} {
1477
1478 if {$GIT_COMMITTER_IDENT == {}} {
1479 if {[catch {set me [exec git var GIT_COMMITTER_IDENT]} err]} {
1484 - error_popup "Unable to obtain your identity:\n$err"
1480 + error_popup "Unable to obtain your identity:\n\n$err"
1481 return
1482 }
1483 if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \
1484 $me me GIT_COMMITTER_IDENT]} {
1489 - error_popup "Invalid GIT_COMMITTER_IDENT:\n$me"
1485 + error_popup "Invalid GIT_COMMITTER_IDENT:\n\n$me"
1486 return
1487 }
1488 }