Skip to content

Commit 468bcae

Browse files
committed
gitk: Don't filter view arguments through git rev-parse
Previously we passed the arguments indicating what commits the user wants to view through git rev-parse to get a list of IDs (positive and negative), then gave that to git log. This had a couple of problems, notably that --merge and --left-right didn't get handled properly. Instead we now just pass the original arguments to git log. When doing an update, we append --not followed by the list of commits we have seen that have no children, since we have got (or will get) their ancestors from the first git log. If the first git log isn't finished yet, we might get some duplicates from the second git log, but that doesn't cause any problem. Also get rid of the unused vnextroot variable. Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent ac1276a commit 468bcae

File tree

1 file changed

+22
-47
lines changed

1 file changed

+22
-47
lines changed

gitk

Lines changed: 22 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -94,30 +94,21 @@ proc dorunq {} {
9494
proc start_rev_list {view} {
9595
global startmsecs
9696
global commfd leftover tclencoding datemode
97-
global viewargs viewfiles commitidx viewcomplete vnextroot
97+
global viewargs viewfiles commitidx viewcomplete
9898
global showlocalchanges commitinterest mainheadid
9999
global progressdirn progresscoords proglastnc curview
100-
global viewincl viewactive loginstance viewinstances
100+
global viewactive loginstance viewinstances
101101
global pending_select mainheadid
102102

103103
set startmsecs [clock clicks -milliseconds]
104104
set commitidx($view) 0
105105
set viewcomplete($view) 0
106106
set viewactive($view) 1
107-
set vnextroot($view) 0
108107
varcinit $view
109108

110-
set commits [eval exec git rev-parse --default HEAD --revs-only \
111-
$viewargs($view)]
112-
set viewincl($view) {}
113-
foreach c $commits {
114-
if {[regexp {^[0-9a-fA-F]{40}$} $c]} {
115-
lappend viewincl($view) $c
116-
}
117-
}
118109
if {[catch {
119110
set fd [open [concat | git log --no-color -z --pretty=raw --parents \
120-
--boundary $commits "--" $viewfiles($view)] r]
111+
--boundary $viewargs($view) "--" $viewfiles($view)] r]
121112
} err]} {
122113
error_popup "[mc "Error executing git log:"] $err"
123114
exit 1
@@ -170,9 +161,9 @@ proc getcommits {} {
170161
}
171162

172163
proc updatecommits {} {
173-
global curview viewargs viewfiles viewincl viewinstances
164+
global curview viewargs viewfiles viewinstances
174165
global viewactive viewcomplete loginstance tclencoding mainheadid
175-
global varcid startmsecs commfd showneartags showlocalchanges leftover
166+
global startmsecs commfd showneartags showlocalchanges leftover
176167
global mainheadid pending_select
177168

178169
set oldmainid $mainheadid
@@ -186,33 +177,10 @@ proc updatecommits {} {
186177
}
187178
}
188179
set view $curview
189-
set commits [exec git rev-parse --default HEAD --revs-only \
190-
$viewargs($view)]
191-
set pos {}
192-
set neg {}
193-
set flags {}
194-
foreach c $commits {
195-
if {[string match "^*" $c]} {
196-
lappend neg $c
197-
} elseif {[regexp {^[0-9a-fA-F]{40}$} $c]} {
198-
if {!([info exists varcid($view,$c)] ||
199-
[lsearch -exact $viewincl($view) $c] >= 0)} {
200-
lappend pos $c
201-
}
202-
} else {
203-
lappend flags $c
204-
}
205-
}
206-
if {$pos eq {}} {
207-
return
208-
}
209-
foreach id $viewincl($view) {
210-
lappend neg "^$id"
211-
}
212-
set viewincl($view) [concat $viewincl($view) $pos]
213180
if {[catch {
214181
set fd [open [concat | git log --no-color -z --pretty=raw --parents \
215-
--boundary $pos $neg $flags "--" $viewfiles($view)] r]
182+
--boundary $viewargs($view) --not [seeds $view] \
183+
"--" $viewfiles($view)] r]
216184
} err]} {
217185
error_popup "Error executing git log: $err"
218186
exit 1
@@ -322,6 +290,19 @@ proc resetvarcs {view} {
322290
catch {unset ordertok}
323291
}
324292

293+
# returns a list of the commits with no children
294+
proc seeds {v} {
295+
global vdownptr vleftptr varcstart
296+
297+
set ret {}
298+
set a [lindex $vdownptr($v) 0]
299+
while {$a != 0} {
300+
lappend ret [lindex $varcstart($v) $a]
301+
set a [lindex $vleftptr($v) $a]
302+
}
303+
return $ret
304+
}
305+
325306
proc newvarc {view id} {
326307
global varcid varctok parents children datemode
327308
global vupptr vdownptr vleftptr vbackptr varcrow varcix varcstart
@@ -1000,7 +981,7 @@ proc getcommitlines {fd inst view updating} {
1000981
global cmitlisted commitinterest leftover
1001982
global commitidx commitdata datemode
1002983
global parents children curview hlview
1003-
global vnextroot idpending ordertok
984+
global idpending ordertok
1004985
global varccommits varcid varctok vtokmod viewfiles
1005986

1006987
set stuff [read $fd 500000]
@@ -7103,7 +7084,7 @@ proc mkbrgo {top} {
71037084
}
71047085

71057086
proc cherrypick {} {
7106-
global rowmenuid curview viewincl
7087+
global rowmenuid curview
71077088
global mainhead mainheadid
71087089

71097090
set oldhead [exec git rev-parse HEAD]
@@ -7137,12 +7118,6 @@ proc cherrypick {} {
71377118
movedhead $newhead $mainhead
71387119
set mainheadid $newhead
71397120
}
7140-
# remove oldhead from viewincl and add newhead
7141-
set i [lsearch -exact $viewincl($curview) $oldhead]
7142-
if {$i >= 0} {
7143-
set viewincl($curview) [lreplace $viewincl($curview) $i $i]
7144-
}
7145-
lappend viewincl($curview) $newhead
71467121
redrawtags $oldhead
71477122
redrawtags $newhead
71487123
selbyid $newhead

0 commit comments

Comments
 (0)