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>
This commit is contained in:
parent
b449eb2cb3
commit
9403bd02dd
38
gitk
38
gitk
@ -156,10 +156,12 @@ proc unmerged_files {files} {
|
|||||||
|
|
||||||
proc parseviewargs {n arglist} {
|
proc parseviewargs {n arglist} {
|
||||||
global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env
|
global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env
|
||||||
|
global vinlinediff
|
||||||
global worddiff git_version
|
global worddiff git_version
|
||||||
|
|
||||||
set vdatemode($n) 0
|
set vdatemode($n) 0
|
||||||
set vmergeonly($n) 0
|
set vmergeonly($n) 0
|
||||||
|
set vinlinediff($n) 0
|
||||||
set glflags {}
|
set glflags {}
|
||||||
set diffargs {}
|
set diffargs {}
|
||||||
set nextisval 0
|
set nextisval 0
|
||||||
@ -7131,6 +7133,7 @@ proc selectline {l isnew {desired_loc {}}} {
|
|||||||
global cmitmode showneartags allcommits
|
global cmitmode showneartags allcommits
|
||||||
global targetrow targetid lastscrollrows
|
global targetrow targetid lastscrollrows
|
||||||
global autoselect autosellen jump_to_here
|
global autoselect autosellen jump_to_here
|
||||||
|
global vinlinediff
|
||||||
|
|
||||||
catch {unset pending_select}
|
catch {unset pending_select}
|
||||||
$canv delete hover
|
$canv delete hover
|
||||||
@ -7272,6 +7275,8 @@ proc selectline {l isnew {desired_loc {}}} {
|
|||||||
init_flist [mc "Comments"]
|
init_flist [mc "Comments"]
|
||||||
if {$cmitmode eq "tree"} {
|
if {$cmitmode eq "tree"} {
|
||||||
gettree $id
|
gettree $id
|
||||||
|
} elseif {$vinlinediff($curview) == 1} {
|
||||||
|
showinlinediff $id
|
||||||
} elseif {[llength $olds] <= 1} {
|
} elseif {[llength $olds] <= 1} {
|
||||||
startdiff $id
|
startdiff $id
|
||||||
} else {
|
} else {
|
||||||
@ -7608,6 +7613,39 @@ proc startdiff {ids} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc showinlinediff {ids} {
|
||||||
|
global commitinfo commitdata ctext
|
||||||
|
global treediffs
|
||||||
|
|
||||||
|
set info $commitinfo($ids)
|
||||||
|
set diff [lindex $info 7]
|
||||||
|
set difflines [split $diff "\n"]
|
||||||
|
|
||||||
|
initblobdiffvars
|
||||||
|
set treediff {}
|
||||||
|
|
||||||
|
set inhdr 0
|
||||||
|
foreach line $difflines {
|
||||||
|
if {![string compare -length 5 "diff " $line]} {
|
||||||
|
set inhdr 1
|
||||||
|
} elseif {$inhdr && ![string compare -length 4 "+++ " $line]} {
|
||||||
|
# offset also accounts for the b/ prefix
|
||||||
|
lappend treediff [string range $line 6 end]
|
||||||
|
set inhdr 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set treediffs($ids) $treediff
|
||||||
|
add_flist $treediff
|
||||||
|
|
||||||
|
$ctext conf -state normal
|
||||||
|
foreach line $difflines {
|
||||||
|
parseblobdiffline $ids $line
|
||||||
|
}
|
||||||
|
maybe_scroll_ctext 1
|
||||||
|
$ctext conf -state disabled
|
||||||
|
}
|
||||||
|
|
||||||
# If the filename (name) is under any of the passed filter paths
|
# If the filename (name) is under any of the passed filter paths
|
||||||
# then return true to include the file in the listing.
|
# then return true to include the file in the listing.
|
||||||
proc path_filter {filter name} {
|
proc path_filter {filter name} {
|
||||||
|
Loading…
Reference in New Issue
Block a user