From: Yann Dirson <ydirson@altern.org>
To: git@vger.kernel.org
Subject: [PATCH, take 2] Re: Make "gitk" work better with dense revlists
Date: Sat, 19 Nov 2005 23:48:20 +0100 [thread overview]
Message-ID: <20051119224819.GG3393@nowhere.earth> (raw)
In-Reply-To: <20051115225740.GB28173@nowhere.earth>
On Tue, Nov 15, 2005 at 11:57:40PM +0100, Yann Dirson wrote:
> Linus wrote:
> >To generate the diff for a commit, gitk used to do
> >
> > git-diff-tree -p -C $p $id
>
> Although the "$p" reference is harmful to --dense mode, and redundant
> when we just want to look at a single commit, removing it breaks the
> "Diff this -> selected" and "Diff selected -> this" features.
As noted by Junio off-list, this original fix was not good. Here is
another try, which should be more robust, and, unlike the 1st try,
handle all cases. Also pullable from
http://ydirson.free.fr/soft/git/git.git/
commit 6483475ddd1af24fc138d36cfec986335685663e
tree 421f408703235272f7b4d86f77a451f4e6606ec3
parent 6ed64058e1241f9939c4abf5d6a9eaed6a2cc795
author Yann Dirson <ydirson@altern.org> Sat, 19 Nov 2005 23:36:16 +0100
committer Yann Dirson <dwitch@gandelf.nowhere.earth> Sat, 19 Nov 2005 23:36:16 +0100
Fix gitk this->selected diffs
The change made to accomodate dense revlists in single-commit diffs
had broken computing of diffs between arbitrary trees, which does need
to pass two commit ids, whether sparse or dense.
This patch changes the two git-diff-tree calls to get the necessary
two ids in this case. It does so by propagating a "singlecommit" flag
through all functions involved via an additionnal argument.
Signed-off-by: Yann Dirson <ydirson@altern.org>
6483475ddd1af24fc138d36cfec986335685663e
diff --git a/gitk b/gitk
index 95b05c0..e3389e2 100755
--- a/gitk
+++ b/gitk
@@ -2197,9 +2197,9 @@ proc selectline {l isnew} {
$cflist delete 0 end
$cflist insert end "Comments"
if {$nparents($id) == 1} {
- startdiff [concat $id $parents($id)]
+ startdiff [concat $id $parents($id)] 1
} elseif {$nparents($id) > 1} {
- mergediff $id
+ mergediff $id 1
}
}
@@ -2268,7 +2268,7 @@ proc goforw {} {
}
}
-proc mergediff {id} {
+proc mergediff {id singlecommit} {
global parents diffmergeid diffmergegca mergefilelist diffpindex
set diffmergeid $id
@@ -2279,7 +2279,7 @@ proc mergediff {id} {
showmergediff
}
} else {
- contmergediff {}
+ contmergediff {} $singlecommit
}
}
@@ -2299,7 +2299,7 @@ proc findgca {ids} {
return $gca
}
-proc contmergediff {ids} {
+proc contmergediff {ids singlecommit} {
global diffmergeid diffpindex parents nparents diffmergegca
global treediffs mergefilelist diffids treepending
@@ -2316,7 +2316,7 @@ proc contmergediff {ids} {
if {![info exists treediffs($ids)]} {
set diffids $ids
if {![info exists treepending]} {
- gettreediffs $ids
+ gettreediffs $ids $singlecommit
}
return
}
@@ -2794,40 +2794,45 @@ proc similarity {pnum l nlc f events} {
return [expr {200 * $same / (2 * $same + $diff)}]
}
-proc startdiff {ids} {
+proc startdiff {ids singlecommit} {
global treediffs diffids treepending diffmergeid
set diffids $ids
catch {unset diffmergeid}
if {![info exists treediffs($ids)]} {
if {![info exists treepending]} {
- gettreediffs $ids
+ gettreediffs $ids $singlecommit
}
} else {
- addtocflist $ids
+ addtocflist $ids $singlecommit
}
}
-proc addtocflist {ids} {
+proc addtocflist {ids singlecommit} {
global treediffs cflist
foreach f $treediffs($ids) {
$cflist insert end $f
}
- getblobdiffs $ids
+ getblobdiffs $ids $singlecommit
}
-proc gettreediffs {ids} {
+proc gettreediffs {ids singlecommit} {
global treediff parents treepending
set treepending $ids
set treediff {}
set id [lindex $ids 0]
set p [lindex $ids 1]
- if [catch {set gdtf [open "|git-diff-tree -r $id" r]}] return
+ if {$singlecommit == 1} {
+ set range "$id"
+ } else {
+ set range "$p $id"
+ }
+ if [catch {set gdtf [open "|git-diff-tree -r $range" r]}] return
fconfigure $gdtf -blocking 0
- fileevent $gdtf readable [list gettreediffline $gdtf $ids]
+ fileevent $gdtf readable [list gettreediffline $gdtf $ids $singlecommit]
}
-proc gettreediffline {gdtf ids} {
+proc gettreediffline {gdtf ids singlecommit} {
global treediff treediffs treepending diffids diffmergeid
set n [gets $gdtf line]
@@ -2837,12 +2842,12 @@ proc gettreediffline {gdtf ids} {
set treediffs($ids) $treediff
unset treepending
if {$ids != $diffids} {
- gettreediffs $diffids
+ gettreediffs $diffids $singlecommit
} else {
if {[info exists diffmergeid]} {
- contmergediff $ids
+ contmergediff $ids $singlecommit
} else {
- addtocflist $ids
+ addtocflist $ids $singlecommit
}
}
return
@@ -2851,14 +2856,18 @@ proc gettreediffline {gdtf ids} {
lappend treediff $file
}
-proc getblobdiffs {ids} {
+proc getblobdiffs {ids singlecommit} {
global diffopts blobdifffd diffids env curdifftag curtagstart
global difffilestart nextupdate diffinhdr treediffs
set id [lindex $ids 0]
set p [lindex $ids 1]
set env(GIT_DIFF_OPTS) $diffopts
- set cmd [list | git-diff-tree -r -p -C $id]
+ if {$singlecommit == 1} {
+ set cmd [list | git-diff-tree -r -p -C $id]
+ } else {
+ set cmd [list | git-diff-tree -r -p -C $p $id]
+ }
if {[catch {set bdf [open $cmd r]} err]} {
puts "error getting diffs: $err"
return
@@ -3373,7 +3382,7 @@ proc doseldiff {oldid newid} {
$ctext conf -state disabled
$ctext tag delete Comments
$ctext tag remove found 1.0 end
- startdiff [list $newid $oldid]
+ startdiff [list $newid $oldid] 0
}
proc mkpatch {} {
--
Yann Dirson <ydirson@altern.org> |
Debian-related: <dirson@debian.org> | Support Debian GNU/Linux:
| Freedom, Power, Stability, Gratis
http://ydirson.free.fr/ | Check <http://www.debian.org/>
prev parent reply other threads:[~2005-11-19 22:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-15 22:57 [PATCH] Re: Make "gitk" work better with dense revlists Yann Dirson
2005-11-19 22:48 ` Yann Dirson [this message]
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=20051119224819.GG3393@nowhere.earth \
--to=ydirson@altern.org \
--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).