Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 9403bd0

Browse files
Thomas Rastpaulusmack
authored andcommitted
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 <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent b449eb2 commit 9403bd0

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

gitk

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,12 @@ proc unmerged_files {files} {
156156

157157
proc parseviewargs {n arglist} {
158158
global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env
159+
global vinlinediff
159160
global worddiff git_version
160161

161162
set vdatemode($n) 0
162163
set vmergeonly($n) 0
164+
set vinlinediff($n) 0
163165
set glflags {}
164166
set diffargs {}
165167
set nextisval 0
@@ -7131,6 +7133,7 @@ proc selectline {l isnew {desired_loc {}}} {
71317133
global cmitmode showneartags allcommits
71327134
global targetrow targetid lastscrollrows
71337135
global autoselect autosellen jump_to_here
7136+
global vinlinediff
71347137

71357138
catch {unset pending_select}
71367139
$canv delete hover
@@ -7272,6 +7275,8 @@ proc selectline {l isnew {desired_loc {}}} {
72727275
init_flist [mc "Comments"]
72737276
if {$cmitmode eq "tree"} {
72747277
gettree $id
7278+
} elseif {$vinlinediff($curview) == 1} {
7279+
showinlinediff $id
72757280
} elseif {[llength $olds] <= 1} {
72767281
startdiff $id
72777282
} else {
@@ -7608,6 +7613,39 @@ proc startdiff {ids} {
76087613
}
76097614
}
76107615

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+
76117649
# If the filename (name) is under any of the passed filter paths
76127650
# then return true to include the file in the listing.
76137651
proc path_filter {filter name} {

0 commit comments

Comments
 (0)