Fix gitk this->selected diffs
The change made in 8b7e5d76e836396a097bb6f61cf930ea872a7bd3 to accomodate dense revlists in single-commit diffs has broken computing of diffs between arbitrary trees, which does need to consider two commit ids. This patch changes the two git-diff-tree calls to get the necessary two ids in this case. It does so by propagating a "singlecommit" flag through all functions involved via an additional argument. Signed-off-by: Yann Dirson <ydirson@altern.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Yann Dirson committed
Nov 27, 2005 at 23:29 UTC
55d1eb047d4dffc633502ea2a80dd092194fc900
1 file changed
+32
-21
gitk
+32
-21
@@ -2165,9 +2165,9 @@ 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 [concat $id $parents($id)] 1
2169
} elseif {$nparents($id) > 1} {
2170
- mergediff $id
2170
+ mergediff $id 1
2171
}
2172
}
2173
@@ -2236,7 +2236,7 @@ proc goforw {} {
2236
}
2237
}
2238
2239
-proc mergediff {id} {
2239
+proc mergediff {id singlecommit} {
2240
global parents diffmergeid diffmergegca mergefilelist diffpindex
2241
2242
set diffmergeid $id
@@ -2247,7 +2247,7 @@ proc mergediff {id} {
2247
showmergediff
2248
}
2249
} else {
2250
- contmergediff {}
2250
+ contmergediff {} $singlecommit
2251
}
2252
}
2253
@@ -2267,7 +2267,7 @@ proc findgca {ids} {
2267
return $gca
2268
}
2269
2270
-proc contmergediff {ids} {
2270
+proc contmergediff {ids singlecommit} {
2271
global diffmergeid diffpindex parents nparents diffmergegca
2272
global treediffs mergefilelist diffids treepending
2273
@@ -2284,7 +2284,7 @@ proc contmergediff {ids} {
2284
if {![info exists treediffs($ids)]} {
2285
set diffids $ids
2286
if {![info exists treepending]} {
2287
- gettreediffs $ids
2287
+ gettreediffs $ids $singlecommit
2288
}
2289
return
2290
}
@@ -2762,39 +2762,45 @@ proc similarity {pnum l nlc f events} {
2762
return [expr {200 * $same / (2 * $same + $diff)}]
2763
}
2764
2765
-proc startdiff {ids} {
2765
+proc startdiff {ids singlecommit} {
2766
global treediffs diffids treepending diffmergeid
2767
2768
set diffids $ids
2769
catch {unset diffmergeid}
2770
if {![info exists treediffs($ids)]} {
2771
if {![info exists treepending]} {
2772
- gettreediffs $ids
2772
+ gettreediffs $ids $singlecommit
2773
}
2774
} else {
2775
- addtocflist $ids
2775
+ addtocflist $ids $singlecommit
2776
}
2777
}
2778
2779
-proc addtocflist {ids} {
2779
+proc addtocflist {ids singlecommit} {
2780
global treediffs cflist
2781
foreach f $treediffs($ids) {
2782
$cflist insert end $f
2783
}
2784
- getblobdiffs $ids
2784
+ getblobdiffs $ids $singlecommit
2785
}
2786
2787
-proc gettreediffs {ids} {
2787
+proc gettreediffs {ids singlecommit} {
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
2792
+ if {$singlecommit == 1} {
2793
+ set range "$id"
2794
+ } else {
2795
+ set p [lindex $ids 1]
2796
+ set range "$p $id"
2797
+ }
2798
+ if [catch {set gdtf [open "|git-diff-tree --no-commit-id -r $range" r]}] return
2799
fconfigure $gdtf -blocking 0
2794
- fileevent $gdtf readable [list gettreediffline $gdtf $ids]
2800
+ fileevent $gdtf readable [list gettreediffline $gdtf $ids $singlecommit]
2801
}
2802
2797
-proc gettreediffline {gdtf ids} {
2803
+proc gettreediffline {gdtf ids singlecommit} {
2804
global treediff treediffs treepending diffids diffmergeid
2805
2806
set n [gets $gdtf line]
@@ -2804,12 +2810,12 @@ proc gettreediffline {gdtf ids} {
2810
set treediffs($ids) $treediff
2811
unset treepending
2812
if {$ids != $diffids} {
2807
- gettreediffs $diffids
2813
+ gettreediffs $diffids $singlecommit
2814
} else {
2815
if {[info exists diffmergeid]} {
2810
- contmergediff $ids
2816
+ contmergediff $ids $singlecommit
2817
} else {
2812
- addtocflist $ids
2818
+ addtocflist $ids $singlecommit
2819
}
2820
}
2821
return
@@ -2818,13 +2824,18 @@ proc gettreediffline {gdtf ids} {
2824
lappend treediff $file
2825
}
2826
2821
-proc getblobdiffs {ids} {
2827
+proc getblobdiffs {ids singlecommit} {
2828
global diffopts blobdifffd diffids env curdifftag curtagstart
2829
global difffilestart nextupdate diffinhdr treediffs
2830
2831
set id [lindex $ids 0]
2832
set env(GIT_DIFF_OPTS) $diffopts
2827
- set cmd [list | git-diff-tree --no-commit-id -r -p -C $id]
2833
+ if {$singlecommit == 1} {
2834
+ set cmd [list | git-diff-tree --no-commit-id -r -p -C $id]
2835
+ } else {
2836
+ set p [lindex $ids 1]
2837
+ set cmd [list | git-diff-tree --no-commit-id -r -p -C $p $id]
2838
+ }
2839
if {[catch {set bdf [open $cmd r]} err]} {
2840
puts "error getting diffs: $err"
2841
return
@@ -3341,7 +3352,7 @@ proc doseldiff {oldid newid} {
3352
$ctext conf -state disabled
3353
$ctext tag delete Comments
3354
$ctext tag remove found 1.0 end
3344
- startdiff [list $newid $oldid]
3355
+ startdiff [list $newid $oldid] 0
3356
}
3357
3358
proc mkpatch {} {