Skip to content

Commit 372ef95

Browse files
committed
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>
1 parent b90d479 commit 372ef95

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

git-gui.sh

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,24 @@ set _reponame [lindex [file split \
359359
[file normalize [file dirname $_gitdir]]] \
360360
end]
361361

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+
362380
######################################################################
363381
##
364382
## task management
@@ -682,8 +700,9 @@ proc reshow_diff {} {
682700
global current_diff_path current_diff_side
683701

684702
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 {}
687706
|| [catch {set s $file_states($p)}]
688707
|| [lsearch -sorted -exact $file_lists($current_diff_side) $p] == -1} {
689708
clear_diff
@@ -5647,9 +5666,6 @@ bind_button3 $ui_comm "tk_popup $ctxm %X %Y"
56475666

56485667
# -- Diff Header
56495668
#
5650-
set current_diff_path {}
5651-
set current_diff_side {}
5652-
set diff_actions [list]
56535669
proc trace_current_diff_path {varname args} {
56545670
global current_diff_path diff_actions file_states
56555671
if {$current_diff_path eq {}} {
@@ -5842,7 +5858,6 @@ unset ui_diff_applyhunk
58425858

58435859
# -- Status Bar
58445860
#
5845-
set ui_status_value {Initializing...}
58465861
label .status -textvariable ui_status_value \
58475862
-anchor w \
58485863
-justify left \
@@ -5916,15 +5931,6 @@ unset i
59165931
set file_lists($ui_index) [list]
59175932
set file_lists($ui_workdir) [list]
59185933

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-
59285934
wm title . "[appname] ([file normalize [file dirname [gitdir]]])"
59295935
focus -force $ui_comm
59305936

0 commit comments

Comments
 (0)