@matheusbsbs / matheus-bagliano / commits / 3e6b893f33
Fork 0

gitk: Get rid of lookingforhead, use commitinterest instead

Now that we have a general-purpose way of taking some action when a commit ID of interest is encountered, use that for triggering the git diff-index process when we find the currently checked-out head, rather than the special-purpose lookingforhead variable. Also do the commitinterest processing in getcommitlines rather than in showstuff. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Sep 15, 2007 at 09:33 UTC 3e6b893f33476e7969c7bd5b8914e8bcc62385e3
1 file changed +17 -25
gitk
+17 -25
@@ -83,7 +83,7 @@ proc start_rev_list {view} {
83 global startmsecs
84 global commfd leftover tclencoding datemode
85 global viewargs viewfiles commitidx viewcomplete vnextroot
86 - global lookingforhead showlocalchanges
86 + global showlocalchanges commitinterest mainheadid
87
88 set startmsecs [clock clicks -milliseconds]
89 set commitidx($view) 0
@@ -102,7 +102,9 @@ proc start_rev_list {view} {
102 }
103 set commfd($view) $fd
104 set leftover($view) {}
105 - set lookingforhead $showlocalchanges
105 + if {$showlocalchanges} {
106 + lappend commitinterest($mainheadid) {dodiffindex}
107 + }
108 fconfigure $fd -blocking 0 -translation lf -eofchar {}
109 if {$tclencoding != {}} {
110 fconfigure $fd -encoding $tclencoding
@@ -147,7 +149,7 @@ proc strrep {n} {
149 }
150
151 proc getcommitlines {fd view} {
150 - global commitlisted
152 + global commitlisted commitinterest
153 global leftover commfd
154 global displayorder commitidx viewcomplete commitrow commitdata
155 global parentlist children curview hlview
@@ -303,6 +305,12 @@ proc getcommitlines {fd view} {
305 lappend vdisporder($view) $id
306 lappend vcmitlisted($view) $listed
307 }
308 + if {[info exists commitinterest($id)]} {
309 + foreach script $commitinterest($id) {
310 + eval [string map [list "%I" $id] $script]
311 + }
312 + unset commitinterest($id)
313 + }
314 set gotsome 1
315 }
316 if {$gotsome} {
@@ -2715,7 +2723,7 @@ proc layoutmore {} {
2723
2724 proc showstuff {canshow last} {
2725 global numcommits commitrow pending_select selectedline curview
2718 - global lookingforhead mainheadid displayorder selectfirst
2726 + global mainheadid displayorder selectfirst
2727 global lastscrollset commitinterest
2728
2729 if {$numcommits == 0} {
@@ -2723,15 +2731,6 @@ proc showstuff {canshow last} {
2731 set phase "incrdraw"
2732 allcanvs delete all
2733 }
2726 - for {set l $numcommits} {$l < $canshow} {incr l} {
2727 - set id [lindex $displayorder $l]
2728 - if {[info exists commitinterest($id)]} {
2729 - foreach script $commitinterest($id) {
2730 - eval [string map [list "%I" $id] $script]
2731 - }
2732 - unset commitinterest($id)
2733 - }
2734 - }
2734 set r0 $numcommits
2735 set prev $numcommits
2736 set numcommits $canshow
@@ -2762,28 +2761,22 @@ proc showstuff {canshow last} {
2761 set selectfirst 0
2762 }
2763 }
2765 - if {$lookingforhead && [info exists commitrow($curview,$mainheadid)]
2766 - && ($last || $commitrow($curview,$mainheadid) < $numcommits - 1)} {
2767 - set lookingforhead 0
2768 - dodiffindex
2769 - }
2764 }
2765
2766 proc doshowlocalchanges {} {
2773 - global lookingforhead curview mainheadid phase commitrow
2767 + global curview mainheadid phase commitrow
2768
2769 if {[info exists commitrow($curview,$mainheadid)] &&
2770 ($phase eq {} || $commitrow($curview,$mainheadid) < $numcommits - 1)} {
2771 dodiffindex
2772 } elseif {$phase ne {}} {
2779 - set lookingforhead 1
2773 + lappend commitinterest($mainheadid) {}
2774 }
2775 }
2776
2777 proc dohidelocalchanges {} {
2784 - global lookingforhead localfrow localirow lserial
2778 + global localfrow localirow lserial
2779
2786 - set lookingforhead 0
2780 if {$localfrow >= 0} {
2781 removerow $localfrow
2782 set localfrow -1
@@ -2800,8 +2793,9 @@ proc dohidelocalchanges {} {
2793
2794 # spawn off a process to do git diff-index --cached HEAD
2795 proc dodiffindex {} {
2803 - global localirow localfrow lserial
2796 + global localirow localfrow lserial showlocalchanges
2797
2798 + if {!$showlocalchanges} return
2799 incr lserial
2800 set localfrow -1
2801 set localirow -1
@@ -6188,7 +6182,6 @@ proc cherrypick {} {
6182
6183 proc resethead {} {
6184 global mainheadid mainhead rowmenuid confirm_ok resettype
6191 - global showlocalchanges
6185
6186 set confirm_ok 0
6187 set w ".confirmreset"
@@ -8249,7 +8242,6 @@ set cmdlineok 0
8242 set stopped 0
8243 set stuffsaved 0
8244 set patchnum 0
8252 -set lookingforhead 0
8245 set localirow -1
8246 set localfrow -1
8247 set lserial 0