git-gui: Correct crash when saving options in blame mode.
Martin Waitz noticed that git-gui crashed while saving the user's options out if the application was started in blame mode. This was caused by the do_save_config procedure invoking reshow_diff incase the number of context lines was modified by the user. Because we bypassed main window UI setup to enter blame mode we did not set many of the globals which were accessed by reshow_diff, and reading unset variables is an error in Tcl. Aside from moving the globals to be set earlier, I also modified reshow_diff to not invoke clear_diff if there is no path currently in the diff viewer. This way reshow_diff does not crash when in blame mode due to the $ui_diff command not being defined. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Feb 18, 2007 at 02:12 UTC
372ef954a15c321a1065bf7e764449ce7767277f
1 file changed
+21
-15
git-gui.sh
+21
-15
@@ -359,6 +359,24 @@ set _reponame [lindex [file split \
359
[file normalize [file dirname $_gitdir]]] \
360
end]
361
362
+######################################################################
363
+##
364
+## global init
365
+
366
+set current_diff_path {}
367
+set current_diff_side {}
368
+set diff_actions [list]
369
+set ui_status_value {Initializing...}
370
+
371
+set HEAD {}
372
+set PARENT {}
373
+set MERGE_HEAD [list]
374
+set commit_type {}
375
+set empty_tree {}
376
+set current_branch {}
377
+set current_diff_path {}
378
+set selected_commit_type new
379
+
380
######################################################################
381
##
382
## task management
@@ -682,8 +700,9 @@ proc reshow_diff {} {
700
global current_diff_path current_diff_side
701
702
set p $current_diff_path
685
- if {$p eq {}
686
- || $current_diff_side eq {}
703
+ if {$p eq {}} {
704
+ # No diff is being shown.
705
+ } elseif {$current_diff_side eq {}
706
|| [catch {set s $file_states($p)}]
707
|| [lsearch -sorted -exact $file_lists($current_diff_side) $p] == -1} {
708
clear_diff
@@ -5647,9 +5666,6 @@ bind_button3 $ui_comm "tk_popup $ctxm %X %Y"
5666
5667
# -- Diff Header
5668
#
5650
-set current_diff_path {}
5651
-set current_diff_side {}
5652
-set diff_actions [list]
5669
proc trace_current_diff_path {varname args} {
5670
global current_diff_path diff_actions file_states
5671
if {$current_diff_path eq {}} {
@@ -5842,7 +5858,6 @@ unset ui_diff_applyhunk
5858
5859
# -- Status Bar
5860
#
5845
-set ui_status_value {Initializing...}
5861
label .status -textvariable ui_status_value \
5862
-anchor w \
5863
-justify left \
@@ -5916,15 +5931,6 @@ unset i
5931
set file_lists($ui_index) [list]
5932
set file_lists($ui_workdir) [list]
5933
5919
-set HEAD {}
5920
-set PARENT {}
5921
-set MERGE_HEAD [list]
5922
-set commit_type {}
5923
-set empty_tree {}
5924
-set current_branch {}
5925
-set current_diff_path {}
5926
-set selected_commit_type new
5927
-
5934
wm title . "[appname] ([file normalize [file dirname [gitdir]]])"
5935
focus -force $ui_comm
5936