summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-02-08 22:47:17 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2007-02-08 23:14:44 (GMT)
commitdb7f34d4c54c1162d976be4d1752642c85e063b4 (patch)
treecd22ad2375bbdb293536e650a58f3e8ab84f0dba
parent64a906f8611ee195efcde76f5587c8e08bac7a25 (diff)
downloadgit-db7f34d4c54c1162d976be4d1752642c85e063b4.zip
git-db7f34d4c54c1162d976be4d1752642c85e063b4.tar.gz
git-db7f34d4c54c1162d976be4d1752642c85e063b4.tar.bz2
git-gui: Optionally save commit buffer on exit.
If the commit area does not exist, don't save the commit message to a file, or the window geometry. The reason I'm doing this is I want to make the main window entirely optional, such as if the user has asked us to show a blame from the command line. In such cases the commit area won't exist and trying to get its text would cause an error. If we are running without the commit message area, we cannot save our window geometry either, as the root window '.' won't be a normal commit window. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rwxr-xr-xgit-gui.sh54
1 files changed, 28 insertions, 26 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 50bcd11..335b5f8 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -4126,34 +4126,36 @@ proc do_quit {} {
if {$is_quitting} return
set is_quitting 1
- # -- Stash our current commit buffer.
- #
- set save [gitdir GITGUI_MSG]
- set msg [string trim [$ui_comm get 0.0 end]]
- regsub -all -line {[ \r\t]+$} $msg {} msg
- if {(![string match amend* $commit_type]
- || [$ui_comm edit modified])
- && $msg ne {}} {
- catch {
- set fd [open $save w]
- puts -nonewline $fd $msg
- close $fd
+ if {[winfo exists $ui_comm]} {
+ # -- Stash our current commit buffer.
+ #
+ set save [gitdir GITGUI_MSG]
+ set msg [string trim [$ui_comm get 0.0 end]]
+ regsub -all -line {[ \r\t]+$} $msg {} msg
+ if {(![string match amend* $commit_type]
+ || [$ui_comm edit modified])
+ && $msg ne {}} {
+ catch {
+ set fd [open $save w]
+ puts -nonewline $fd $msg
+ close $fd
+ }
+ } else {
+ catch {file delete $save}
}
- } else {
- catch {file delete $save}
- }
- # -- Stash our current window geometry into this repository.
- #
- set cfg_geometry [list]
- lappend cfg_geometry [wm geometry .]
- lappend cfg_geometry [lindex [.vpane sash coord 0] 1]
- lappend cfg_geometry [lindex [.vpane.files sash coord 0] 0]
- if {[catch {set rc_geometry $repo_config(gui.geometry)}]} {
- set rc_geometry {}
- }
- if {$cfg_geometry ne $rc_geometry} {
- catch {exec git repo-config gui.geometry $cfg_geometry}
+ # -- Stash our current window geometry into this repository.
+ #
+ set cfg_geometry [list]
+ lappend cfg_geometry [wm geometry .]
+ lappend cfg_geometry [lindex [.vpane sash coord 0] 1]
+ lappend cfg_geometry [lindex [.vpane.files sash coord 0] 0]
+ if {[catch {set rc_geometry $repo_config(gui.geometry)}]} {
+ set rc_geometry {}
+ }
+ if {$cfg_geometry ne $rc_geometry} {
+ catch {exec git repo-config gui.geometry $cfg_geometry}
+ }
}
destroy .