git-gui: Simplified format of geometry configuration.
[gitweb.git] / git-gui
diff --git a/git-gui b/git-gui
index 81fe38f0068335f2f3dba8abae905eb3cdd8db84..ce49c38987e2eac9b438388ab3fd9038bbdaca5f 100755 (executable)
--- a/git-gui
+++ b/git-gui
@@ -48,11 +48,9 @@ proc save_my_config {} {
                set repo_config(gui.trustmtime) [list $cfg_trust_mtime]
        }
 
-       set cfg_geometry [list \
-               [wm geometry .] \
-               [.vpane sash coord 0] \
-               [.vpane.files sash coord 0] \
-               ]
+       set cfg_geometry [wm geometry .]
+       append cfg_geometry " [lindex [.vpane sash coord 0] 1]"
+       append cfg_geometry " [lindex [.vpane.files sash coord 0] 0]"
        if {[catch {set rc_geometry $repo_config(gui.geometry)}]} {
                set rc_geometry [list [list]]
        }
@@ -73,7 +71,8 @@ proc error_popup {msg} {
                        end]
                append title {)}
        }
-       tk_messageBox -parent . \
+       tk_messageBox \
+               -parent . \
                -icon error \
                -type ok \
                -title "$title: error" \
@@ -84,8 +83,10 @@ proc error_popup {msg} {
 ##
 ## 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 +94,6 @@ if {$cdup != ""} {
 }
 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 +416,7 @@ proc show_diff {path {w {}} {lno {}}} {
                        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 +433,7 @@ proc show_diff {path {w {}} {lno {}}} {
                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 +519,7 @@ proc load_last_commit {} {
                        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 +651,8 @@ proc commit_stage2 {fd_wt curHEAD msg} {
        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 +673,7 @@ proc commit_stage2 {fd_wt curHEAD msg} {
                                }
                                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 +686,7 @@ proc commit_stage2 {fd_wt curHEAD msg} {
        }
        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 +707,7 @@ proc commit_stage2 {fd_wt curHEAD msg} {
        }
        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
@@ -1426,8 +1420,13 @@ proc do_repack {} {
        console_exec $w $cmd
 }
 
+set quitting 0
+
 proc do_quit {} {
-       global gitdir ui_comm
+       global gitdir ui_comm quitting
+
+       if {$quitting} return
+       set quitting 1
 
        set save [file join $gitdir GITGUI_MSG]
        set msg [string trim [$ui_comm get 0.0 end]]
@@ -1481,12 +1480,12 @@ proc do_signoff {} {
 
        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
                }
        }
@@ -1841,10 +1840,16 @@ pack .status -anchor w -side bottom -fill x
 
 # -- Load geometry
 catch {
-wm geometry . [lindex $repo_config(gui.geometry) 0 0]
-eval .vpane sash place 0 [lindex $repo_config(gui.geometry) 0 1]
-eval .vpane.files sash place 0 [lindex $repo_config(gui.geometry) 0 2]
-}
+set gm [lindex $repo_config(gui.geometry) 0]
+wm geometry . [lindex $gm 0]
+.vpane sash place 0 \
+       [lindex [.vpane sash coord 0] 0] \
+       [lindex $gm 1]
+.vpane.files sash place 0 \
+       [lindex $gm 2] \
+       [lindex [.vpane.files sash coord 0] 1]
+}
+unset gm
 
 # -- Key Bindings
 bind $ui_comm <$M1B-Key-Return> {do_commit;break}