Skip to content

Commit

Permalink
gitk: Support showing the gathered inline diffs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Rast authored and Paul Mackerras committed Dec 1, 2013
1 parent b449eb2 commit 9403bd0
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions gitk
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ proc unmerged_files {files} {

proc parseviewargs {n arglist} {
global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env
global vinlinediff
global worddiff git_version

set vdatemode($n) 0
set vmergeonly($n) 0
set vinlinediff($n) 0
set glflags {}
set diffargs {}
set nextisval 0
Expand Down Expand Up @@ -7131,6 +7133,7 @@ proc selectline {l isnew {desired_loc {}}} {
global cmitmode showneartags allcommits
global targetrow targetid lastscrollrows
global autoselect autosellen jump_to_here
global vinlinediff

catch {unset pending_select}
$canv delete hover
Expand Down Expand Up @@ -7272,6 +7275,8 @@ proc selectline {l isnew {desired_loc {}}} {
init_flist [mc "Comments"]
if {$cmitmode eq "tree"} {
gettree $id
} elseif {$vinlinediff($curview) == 1} {
showinlinediff $id
} elseif {[llength $olds] <= 1} {
startdiff $id
} else {
Expand Down Expand Up @@ -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
# then return true to include the file in the listing.
proc path_filter {filter name} {
Expand Down

0 comments on commit 9403bd0

Please sign in to comment.