From: Thomas Rast <trast@inf.ethz.ch>
To: <git@vger.kernel.org>
Cc: Paul Mackerras <paulus@samba.org>, Jens Lehmann <Jens.Lehmann@web.de>
Subject: [PATCH gitk 3/4] gitk: support showing the gathered inline diffs
Date: Sun, 9 Jun 2013 21:44:14 +0200 [thread overview]
Message-ID: <209fa0023dbb323e36665e37274adaefcd72c471.1370806329.git.trast@inf.ethz.ch> (raw)
In-Reply-To: <cover.1370806329.git.trast@inf.ethz.ch>
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>
---
gitk | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/gitk b/gitk
index 261bda8..3715136 100755
--- a/gitk
+++ b/gitk
@@ -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
@@ -7086,6 +7088,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
@@ -7227,6 +7230,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 {
@@ -7563,6 +7568,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} {
--
1.8.3.496.g0d0267b
next prev parent reply other threads:[~2013-06-09 19:44 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-09 19:44 [PATCH gitk 0/4] gitk support for git log -L Thomas Rast
2013-06-09 19:44 ` [PATCH gitk 1/4] gitk: refactor per-line part of getblobdiffline and its support Thomas Rast
2013-06-09 19:44 ` [PATCH gitk 2/4] gitk: split out diff part in $commitinfo Thomas Rast
2013-06-09 19:44 ` Thomas Rast [this message]
2013-06-09 19:44 ` [PATCH gitk 4/4] gitk: recognize -L option Thomas Rast
2013-07-23 15:19 ` [PATCH gitk 0/4] gitk support for git log -L Thomas Rast
2013-07-29 19:37 ` Thomas Rast
2013-07-29 20:07 ` Jens Lehmann
2013-07-31 13:17 ` Thomas Rast
2013-08-18 11:54 ` Paul Mackerras
2013-08-19 8:21 ` Thomas Rast
2013-08-19 17:30 ` Junio C Hamano
2013-10-13 6:31 ` Thomas Rast
2013-10-14 5:25 ` Jonathan Nieder
2013-10-20 16:57 ` [PATCH] Documentation: revamp gitk(1) Thomas Rast
2013-10-29 7:20 ` [PATCH v2 0/7] gitk -L Thomas Rast
2013-10-29 7:20 ` [PATCH v2 1/7] gitk: support -G option from the command line Thomas Rast
2013-10-30 0:52 ` Junio C Hamano
2013-10-30 6:30 ` Thomas Rast
2013-10-30 16:42 ` Junio C Hamano
2013-10-29 7:20 ` [PATCH v2 2/7] gitk: refactor per-line part of getblobdiffline and its support Thomas Rast
2013-10-29 7:20 ` [PATCH v2 3/7] gitk: split out diff part in $commitinfo Thomas Rast
2013-10-29 7:20 ` [PATCH v2 4/7] gitk: support showing the gathered inline diffs Thomas Rast
2013-10-29 7:20 ` [PATCH v2 5/7] gitk: recognize -L option Thomas Rast
2013-10-29 7:20 ` [PATCH v2 6/7] Documentation: put blame/log -L in sticked form Thomas Rast
2013-10-30 1:11 ` Junio C Hamano
2013-10-30 6:29 ` Thomas Rast
2013-10-30 17:09 ` Junio C Hamano
2013-10-30 18:59 ` Thomas Rast
2013-10-30 19:37 ` Junio C Hamano
2013-11-16 17:37 ` [PATCH v3 gitk 0/5] gitk -L Thomas Rast
2013-11-16 17:37 ` [PATCH v3 gitk 1/5] gitk: support -G option from the command line Thomas Rast
2013-11-16 17:37 ` [PATCH v3 gitk 2/5] gitk: refactor per-line part of getblobdiffline and its support Thomas Rast
2013-11-16 17:37 ` [PATCH v3 gitk 3/5] gitk: split out diff part in $commitinfo Thomas Rast
2013-11-16 17:37 ` [PATCH v3 gitk 4/5] gitk: support showing the gathered inline diffs Thomas Rast
2013-11-16 17:37 ` [PATCH v3 gitk 5/5] gitk: recognize -L option Thomas Rast
2013-12-01 22:25 ` [PATCH v3 gitk 0/5] gitk -L Paul Mackerras
2013-11-16 17:37 ` [PATCH v3 0/3] Documentation: stuck arguments and gitk log -L Thomas Rast
2013-11-16 17:37 ` [PATCH v3 1/3] commit-tree: use prefixcmp instead of memcmp(..., N) Thomas Rast
2013-11-16 17:37 ` [PATCH v3 2/3] Documentation: convert to --option=arg form where possible Thomas Rast
2013-11-16 17:37 ` [PATCH v3 3/3] Documentation/gitk: document -L option Thomas Rast
2013-10-29 7:20 ` [PATCH v2 7/7] " Thomas Rast
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=209fa0023dbb323e36665e37274adaefcd72c471.1370806329.git.trast@inf.ethz.ch \
--to=trast@inf.ethz.ch \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).