From: Steffen Prohaska <prohaska@zib.de>
To: git@vger.kernel.org
Cc: Steffen Prohaska <prohaska@zib.de>
Subject: [RFC 3/4] gitk: Refactor getblobdiffline to split off adddiffline
Date: Sat, 15 Dec 2007 17:51:44 +0100 [thread overview]
Message-ID: <11977375051617-git-send-email-prohaska@zib.de> (raw)
In-Reply-To: <1197737505599-git-send-email-prohaska@zib.de>
getblobdiffline used to read from a file descriptor, parsed
the line read, and displayed the line nicely formatted.
Parsing and displaying the line is split off to a separate
function adddiffline.
---
gitk-git/gitk | 30 +++++++++++++++++++-----------
1 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/gitk-git/gitk b/gitk-git/gitk
index ca121e4..3c4ec03 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -5324,18 +5324,11 @@ proc makediffhdr {fname ids} {
$ctext insert $curdiffstart "$pad $fname $pad" filesep
}
-proc getblobdiffline {bdf ids} {
+proc adddiffline {line ids} {
global diffids blobdifffd ctext curdiffstart
global diffnexthead diffnextnote difffilestart
global diffinhdr treediffs
- set nr 0
- $ctext conf -state normal
- while {[incr nr] <= 1000 && [gets $bdf line] >= 0} {
- if {$ids != $diffids || $bdf != $blobdifffd($ids)} {
- close $bdf
- return 0
- }
if {![string compare -length 11 "diff --git " $line]} {
# trim off "diff --git "
set line [string range $line 11 end]
@@ -5357,7 +5350,7 @@ proc getblobdiffline {bdf ids} {
if {!(($l & 1) && [string index $line $i] eq " " &&
[string range $line 2 [expr {$i - 1}]] eq \
[string range $line [expr {$i + 3}] end])} {
- continue
+ return
}
# unescape if quoted and chop off the a/ from the front
if {[string index $line 0] eq "\""} {
@@ -5391,10 +5384,10 @@ proc getblobdiffline {bdf ids} {
makediffhdr $fname $ids
} elseif {[string compare -length 3 $line "---"] == 0} {
# do nothing
- continue
+ return
} elseif {[string compare -length 3 $line "+++"] == 0} {
set diffinhdr 0
- continue
+ return
}
$ctext insert end "$line\n" filesep
@@ -5411,6 +5404,21 @@ proc getblobdiffline {bdf ids} {
$ctext insert end "$line\n" hunksep
}
}
+}
+
+proc getblobdiffline {bdf ids} {
+ global diffids blobdifffd ctext curdiffstart
+ global diffnexthead diffnextnote difffilestart
+ global diffinhdr treediffs
+
+ set nr 0
+ $ctext conf -state normal
+ while {[incr nr] <= 1000 && [gets $bdf line] >= 0} {
+ if {$ids != $diffids || $bdf != $blobdifffd($ids)} {
+ close $bdf
+ return 0
+ }
+ adddiffline $line $ids
}
$ctext conf -state disabled
if {[eof $bdf]} {
--
1.5.4.rc0.37.geff3a-dirty
next prev parent reply other threads:[~2007-12-15 16:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-15 16:51 [RFC 1/4] Add diff-diff, which compares the diffs of two commits Steffen Prohaska
2007-12-15 16:51 ` [RFC 2/4] gitk: Add diff-diff support Steffen Prohaska
2007-12-15 16:51 ` Steffen Prohaska [this message]
2007-12-15 16:51 ` [RFC 4/4] gitk: Use adddiffline to nicely format diff-diff Steffen Prohaska
2007-12-15 16:55 ` [RFC 1/4] Add diff-diff, which compares the diffs of two commits Johannes Schindelin
2007-12-15 17:04 ` Björn Steinbrink
2007-12-15 17:33 ` Steffen Prohaska
2007-12-15 19:34 ` Junio C Hamano
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=11977375051617-git-send-email-prohaska@zib.de \
--to=prohaska@zib.de \
--cc=git@vger.kernel.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).