@matheusbsbs / matheus-bagliano / commits / d327244a84
Fork 0

gitk: Fix diff this->selected and selected->this functions

The change in 8b7e5d76e836396a097bb6f61cf930ea872a7bd3, which makes a couple of git-diff-tree calls supply only one id rather than two, fixes the display when showing what a single commit did with dense revlists, but broke the diff this->selected and diff selected->this right-click menu functions. Yann Dirson pointed this out and had a patch that fixed the diff menu functions by passing a "singlecommit" flag around. This fixes it a bit differently, by making the ids and diffids variables be either a single id, in the case of showing what a commit did, or {oldid newid}, in the case of the diff menu functions. That way we can just pass $ids to git-diff-tree as is. Most of the changes in fact are just reversing the order of ids in $ids and $diffids, because they used to be {child parent}, but git-diff-tree requires old id before new id. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Nov 28, 2005 at 20:41 UTC d327244a8435539b62d73ab151bd6c46324cbeb6
1 file changed +10 -12
gitk
+10 -12
@@ -2165,7 +2165,7 @@ proc selectline {l isnew} {
2165 $cflist delete 0 end
2166 $cflist insert end "Comments"
2167 if {$nparents($id) == 1} {
2168 - startdiff [concat $id $parents($id)]
2168 + startdiff $id
2169 } elseif {$nparents($id) > 1} {
2170 mergediff $id
2171 }
@@ -2274,12 +2274,12 @@ proc contmergediff {ids} {
2274 # diff the child against each of the parents, and diff
2275 # each of the parents against the GCA.
2276 while 1 {
2277 - if {[lindex $ids 0] == $diffmergeid && $diffmergegca ne {}} {
2278 - set ids [list [lindex $ids 1] $diffmergegca]
2277 + if {[lindex $ids 1] == $diffmergeid && $diffmergegca ne {}} {
2278 + set ids [list $diffmergegca [lindex $ids 0]]
2279 } else {
2280 if {[incr diffpindex] >= $nparents($diffmergeid)} break
2281 set p [lindex $parents($diffmergeid) $diffpindex]
2282 - set ids [list $diffmergeid $p]
2282 + set ids [list $p $diffmergeid]
2283 }
2284 if {![info exists treediffs($ids)]} {
2285 set diffids $ids
@@ -2297,8 +2297,8 @@ proc contmergediff {ids} {
2297 if {$diffmergegca ne {}} {
2298 set files {}
2299 foreach p $parents($diffmergeid) {
2300 - set gcadiffs $treediffs([list $p $diffmergegca])
2301 - foreach f $treediffs([list $diffmergeid $p]) {
2300 + set gcadiffs $treediffs([list $diffmergegca $p])
2301 + foreach f $treediffs([list $p $diffmergeid]) {
2302 if {[lsearch -exact $files $f] < 0
2303 && [lsearch -exact $gcadiffs $f] >= 0} {
2304 lappend files $f
@@ -2311,7 +2311,7 @@ proc contmergediff {ids} {
2311 set files $treediffs([list $diffmergeid $p])
2312 for {set i 1} {$i < $nparents($diffmergeid) && $files ne {}} {incr i} {
2313 set p [lindex $parents($diffmergeid) $i]
2314 - set df $treediffs([list $diffmergeid $p])
2314 + set df $treediffs([list $p $diffmergeid])
2315 set nf {}
2316 foreach f $files {
2317 if {[lsearch -exact $df $f] >= 0} {
@@ -2788,8 +2788,7 @@ proc gettreediffs {ids} {
2788 global treediff parents treepending
2789 set treepending $ids
2790 set treediff {}
2791 - set id [lindex $ids 0]
2792 - if [catch {set gdtf [open "|git-diff-tree --no-commit-id -r $id" r]}] return
2791 + if [catch {set gdtf [open [concat | git-diff-tree --no-commit-id -r $ids] r]}] return
2792 fconfigure $gdtf -blocking 0
2793 fileevent $gdtf readable [list gettreediffline $gdtf $ids]
2794 }
@@ -2822,9 +2821,8 @@ proc getblobdiffs {ids} {
2821 global diffopts blobdifffd diffids env curdifftag curtagstart
2822 global difffilestart nextupdate diffinhdr treediffs
2823
2825 - set id [lindex $ids 0]
2824 set env(GIT_DIFF_OPTS) $diffopts
2827 - set cmd [list | git-diff-tree --no-commit-id -r -p -C $id]
2825 + set cmd [concat | git-diff-tree --no-commit-id -r -p -C $ids]
2826 if {[catch {set bdf [open $cmd r]} err]} {
2827 puts "error getting diffs: $err"
2828 return
@@ -3341,7 +3339,7 @@ proc doseldiff {oldid newid} {
3339 $ctext conf -state disabled
3340 $ctext tag delete Comments
3341 $ctext tag remove found 1.0 end
3344 - startdiff [list $newid $oldid]
3342 + startdiff [list $oldid $newid]
3343 }
3344
3345 proc mkpatch {} {