gitk: Support showing the gathered inline diffs
The previous commit split the diffs into a separate field. Now we actually want to show them. To that end we use the stored diff, and - process it once to build a fake "tree diff", i.e., a list of all changed files; - feed it through parseblobdiffline to actually format it into the $ctext field, like the existing diff machinery would. Signed-off-by: Thomas Rast <trast@inf.ethz.ch> Signed-off-by: Paul Mackerras <paulus@samba.org>
Thomas Rast committed
Nov 16, 2013 at 18:37 UTC
9403bd02dd96a2f8b1a5802d86e1592d0dcf2358
1 file changed
+38
gitk
+38
@@ -156,10 +156,12 @@ proc unmerged_files {files} {
156
157
proc parseviewargs {n arglist} {
158
global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env
159
+ global vinlinediff
160
global worddiff git_version
161
162
set vdatemode($n) 0
163
set vmergeonly($n) 0
164
+ set vinlinediff($n) 0
165
set glflags {}
166
set diffargs {}
167
set nextisval 0
@@ -7131,6 +7133,7 @@ proc selectline {l isnew {desired_loc {}}} {
7133
global cmitmode showneartags allcommits
7134
global targetrow targetid lastscrollrows
7135
global autoselect autosellen jump_to_here
7136
+ global vinlinediff
7137
7138
catch {unset pending_select}
7139
$canv delete hover
@@ -7272,6 +7275,8 @@ proc selectline {l isnew {desired_loc {}}} {
7275
init_flist [mc "Comments"]
7276
if {$cmitmode eq "tree"} {
7277
gettree $id
7278
+ } elseif {$vinlinediff($curview) == 1} {
7279
+ showinlinediff $id
7280
} elseif {[llength $olds] <= 1} {
7281
startdiff $id
7282
} else {
@@ -7608,6 +7613,39 @@ proc startdiff {ids} {
7613
}
7614
}
7615
7616
+proc showinlinediff {ids} {
7617
+ global commitinfo commitdata ctext
7618
+ global treediffs
7619
+
7620
+ set info $commitinfo($ids)
7621
+ set diff [lindex $info 7]
7622
+ set difflines [split $diff "\n"]
7623
+
7624
+ initblobdiffvars
7625
+ set treediff {}
7626
+
7627
+ set inhdr 0
7628
+ foreach line $difflines {
7629
+ if {![string compare -length 5 "diff " $line]} {
7630
+ set inhdr 1
7631
+ } elseif {$inhdr && ![string compare -length 4 "+++ " $line]} {
7632
+ # offset also accounts for the b/ prefix
7633
+ lappend treediff [string range $line 6 end]
7634
+ set inhdr 0
7635
+ }
7636
+ }
7637
+
7638
+ set treediffs($ids) $treediff
7639
+ add_flist $treediff
7640
+
7641
+ $ctext conf -state normal
7642
+ foreach line $difflines {
7643
+ parseblobdiffline $ids $line
7644
+ }
7645
+ maybe_scroll_ctext 1
7646
+ $ctext conf -state disabled
7647
+}
7648
+
7649
# If the filename (name) is under any of the passed filter paths
7650
# then return true to include the file in the listing.
7651
proc path_filter {filter name} {