Skip to content

Commit e439e09

Browse files
angavrilovpaulusmack
authored andcommitted
gitk: Arrange to kill diff-files & diff-index on quit
Local change analysis can take a noticeable amount of time on large file sets, and produce no output if there are no changes. Register the back-ends in commfd, so that they get properly killed on window close. Signed-off-by: Alexander Gavrilov <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent e2f90ee commit e439e09

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

gitk

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ proc dorunq {} {
9090
}
9191
}
9292

93+
proc reg_instance {fd} {
94+
global commfd leftover loginstance
95+
96+
set i [incr loginstance]
97+
set commfd($i) $fd
98+
set leftover($i) {}
99+
return $i
100+
}
101+
93102
proc unmerged_files {files} {
94103
global nr_unmerged
95104

@@ -294,10 +303,10 @@ proc parseviewrevs {view revs} {
294303
# Start off a git log process and arrange to read its output
295304
proc start_rev_list {view} {
296305
global startmsecs commitidx viewcomplete curview
297-
global commfd leftover tclencoding
306+
global tclencoding
298307
global viewargs viewargscmd viewfiles vfilelimit
299308
global showlocalchanges commitinterest
300-
global viewactive loginstance viewinstances vmergeonly
309+
global viewactive viewinstances vmergeonly
301310
global pending_select mainheadid
302311
global vcanopt vflags vrevs vorigargs
303312

@@ -354,10 +363,8 @@ proc start_rev_list {view} {
354363
error_popup "[mc "Error executing git log:"] $err"
355364
return 0
356365
}
357-
set i [incr loginstance]
366+
set i [reg_instance $fd]
358367
set viewinstances($view) [list $i]
359-
set commfd($i) $fd
360-
set leftover($i) {}
361368
if {$showlocalchanges && $mainheadid ne {}} {
362369
lappend commitinterest($mainheadid) {dodiffindex}
363370
}
@@ -420,8 +427,8 @@ proc getcommits {} {
420427

421428
proc updatecommits {} {
422429
global curview vcanopt vorigargs vfilelimit viewinstances
423-
global viewactive viewcomplete loginstance tclencoding
424-
global startmsecs commfd showneartags showlocalchanges leftover
430+
global viewactive viewcomplete tclencoding
431+
global startmsecs showneartags showlocalchanges
425432
global mainheadid pending_select
426433
global isworktree
427434
global varcid vposids vnegids vflags vrevs
@@ -482,10 +489,8 @@ proc updatecommits {} {
482489
if {$viewactive($view) == 0} {
483490
set startmsecs [clock clicks -milliseconds]
484491
}
485-
set i [incr loginstance]
492+
set i [reg_instance $fd]
486493
lappend viewinstances($view) $i
487-
set commfd($i) $fd
488-
set leftover($i) {}
489494
fconfigure $fd -blocking 0 -translation lf -eofchar {}
490495
if {$tclencoding != {}} {
491496
fconfigure $fd -encoding $tclencoding
@@ -4063,10 +4068,11 @@ proc dodiffindex {} {
40634068
incr lserial
40644069
set fd [open "|git diff-index --cached HEAD" r]
40654070
fconfigure $fd -blocking 0
4066-
filerun $fd [list readdiffindex $fd $lserial]
4071+
set i [reg_instance $fd]
4072+
filerun $fd [list readdiffindex $fd $lserial $i]
40674073
}
40684074

4069-
proc readdiffindex {fd serial} {
4075+
proc readdiffindex {fd serial inst} {
40704076
global mainheadid nullid nullid2 curview commitinfo commitdata lserial
40714077

40724078
set isdiff 1
@@ -4077,7 +4083,7 @@ proc readdiffindex {fd serial} {
40774083
set isdiff 0
40784084
}
40794085
# we only need to see one line and we don't really care what it says...
4080-
close $fd
4086+
stop_instance $inst
40814087

40824088
if {$serial != $lserial} {
40834089
return 0
@@ -4086,7 +4092,8 @@ proc readdiffindex {fd serial} {
40864092
# now see if there are any local changes not checked in to the index
40874093
set fd [open "|git diff-files" r]
40884094
fconfigure $fd -blocking 0
4089-
filerun $fd [list readdifffiles $fd $serial]
4095+
set i [reg_instance $fd]
4096+
filerun $fd [list readdifffiles $fd $serial $i]
40904097

40914098
if {$isdiff && ![commitinview $nullid2 $curview]} {
40924099
# add the line for the changes in the index to the graph
@@ -4103,7 +4110,7 @@ proc readdiffindex {fd serial} {
41034110
return 0
41044111
}
41054112

4106-
proc readdifffiles {fd serial} {
4113+
proc readdifffiles {fd serial inst} {
41074114
global mainheadid nullid nullid2 curview
41084115
global commitinfo commitdata lserial
41094116

@@ -4115,7 +4122,7 @@ proc readdifffiles {fd serial} {
41154122
set isdiff 0
41164123
}
41174124
# we only need to see one line and we don't really care what it says...
4118-
close $fd
4125+
stop_instance $inst
41194126

41204127
if {$serial != $lserial} {
41214128
return 0

0 commit comments

Comments
 (0)