{"thread":{"id":"2694","subject":"[PATCH] Fix gitk this->selected diffs","startedAt":"2005-11-27T22:29:30Z","lastAt":"2005-11-28T08:28:13Z","messageCount":2,"participants":["Yann Dirson","Paul Mackerras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"12822","messageId":"20051127222929.GM3393@nowhere.earth","threadId":"2694","inReplyTo":null,"subject":"[PATCH] Fix gitk this->selected diffs","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2005-11-27T22:29:30Z","receivedAt":"2005-11-27T22:29:30Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"The change made in 8b7e5d76e836396a097bb6f61cf930ea872a7bd3 to\naccomodate dense revlists in single-commit diffs has broken computing\nof diffs between arbitrary trees, which does need to consider two\ncommit ids.\n\nThis patch changes the two git-diff-tree calls to get the necessary\ntwo ids in this case.  It does so by propagating a \"singlecommit\" flag\nthrough all functions involved via an additional argument.\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n\n---\n\nthis->selected diffs have been broken for a month now - I'd like it to\nget fixed before 1.0 :)\n\nA previous version of this patch was sent under the 'Make \"gitk\" work\nbetter with dense revlists' thread.  I have done some minor cleanups\nto it.  I'm still not comfortable with the number of funcs I had to\ntouch to propagate the information - any better idea ?\n\n gitk |   53 ++++++++++++++++++++++++++++++++---------------------\n 1 files changed, 32 insertions(+), 21 deletions(-)\n\napplies-to: 1dc0816b6c98ef90985d2761f1ab80739e4fbc7d\n4664daceca4faac92f0e15d3e80824f172192d84\ndiff --git a/gitk b/gitk\nindex 3dd97e2..4841a80 100755\n--- a/gitk\n+++ b/gitk\n@@ -2164,9 +2164,9 @@ proc selectline {l isnew} {\n     $cflist delete 0 end\n     $cflist insert end \"Comments\"\n     if {$nparents($id) == 1} {\n-\tstartdiff [concat $id $parents($id)]\n+\tstartdiff [concat $id $parents($id)] 1\n     } elseif {$nparents($id) > 1} {\n-\tmergediff $id\n+\tmergediff $id 1\n     }\n }\n \n@@ -2235,7 +2235,7 @@ proc goforw {} {\n     }\n }\n \n-proc mergediff {id} {\n+proc mergediff {id singlecommit} {\n     global parents diffmergeid diffmergegca mergefilelist diffpindex\n \n     set diffmergeid $id\n@@ -2246,7 +2246,7 @@ proc mergediff {id} {\n \t    showmergediff\n \t}\n     } else {\n-\tcontmergediff {}\n+\tcontmergediff {} $singlecommit\n     }\n }\n \n@@ -2266,7 +2266,7 @@ proc findgca {ids} {\n     return $gca\n }\n \n-proc contmergediff {ids} {\n+proc contmergediff {ids singlecommit} {\n     global diffmergeid diffpindex parents nparents diffmergegca\n     global treediffs mergefilelist diffids treepending\n \n@@ -2283,7 +2283,7 @@ proc contmergediff {ids} {\n \tif {![info exists treediffs($ids)]} {\n \t    set diffids $ids\n \t    if {![info exists treepending]} {\n-\t\tgettreediffs $ids\n+\t\tgettreediffs $ids $singlecommit\n \t    }\n \t    return\n \t}\n@@ -2761,39 +2761,45 @@ proc similarity {pnum l nlc f events} {\n     return [expr {200 * $same / (2 * $same + $diff)}]\n }\n \n-proc startdiff {ids} {\n+proc startdiff {ids singlecommit} {\n     global treediffs diffids treepending diffmergeid\n \n     set diffids $ids\n     catch {unset diffmergeid}\n     if {![info exists treediffs($ids)]} {\n \tif {![info exists treepending]} {\n-\t    gettreediffs $ids\n+\t    gettreediffs $ids $singlecommit\n \t}\n     } else {\n-\taddtocflist $ids\n+\taddtocflist $ids $singlecommit\n     }\n }\n \n-proc addtocflist {ids} {\n+proc addtocflist {ids singlecommit} {\n     global treediffs cflist\n     foreach f $treediffs($ids) {\n \t$cflist insert end $f\n     }\n-    getblobdiffs $ids\n+    getblobdiffs $ids $singlecommit\n }\n \n-proc gettreediffs {ids} {\n+proc gettreediffs {ids singlecommit} {\n     global treediff parents treepending\n     set treepending $ids\n     set treediff {}\n     set id [lindex $ids 0]\n-    if [catch {set gdtf [open \"|git-diff-tree --no-commit-id -r $id\" r]}] return\n+    if {$singlecommit == 1} {\n+\tset range \"$id\"\n+    } else {\n+\tset p [lindex $ids 1]\n+\tset range \"$p $id\"\n+    }\n+    if [catch {set gdtf [open \"|git-diff-tree --no-commit-id -r $range\" r]}] return\n     fconfigure $gdtf -blocking 0\n-    fileevent $gdtf readable [list gettreediffline $gdtf $ids]\n+    fileevent $gdtf readable [list gettreediffline $gdtf $ids $singlecommit]\n }\n \n-proc gettreediffline {gdtf ids} {\n+proc gettreediffline {gdtf ids singlecommit} {\n     global treediff treediffs treepending diffids diffmergeid\n \n     set n [gets $gdtf line]\n@@ -2803,12 +2809,12 @@ proc gettreediffline {gdtf ids} {\n \tset treediffs($ids) $treediff\n \tunset treepending\n \tif {$ids != $diffids} {\n-\t    gettreediffs $diffids\n+\t    gettreediffs $diffids $singlecommit\n \t} else {\n \t    if {[info exists diffmergeid]} {\n-\t\tcontmergediff $ids\n+\t\tcontmergediff $ids $singlecommit\n \t    } else {\n-\t\taddtocflist $ids\n+\t\taddtocflist $ids $singlecommit\n \t    }\n \t}\n \treturn\n@@ -2817,13 +2823,18 @@ proc gettreediffline {gdtf ids} {\n     lappend treediff $file\n }\n \n-proc getblobdiffs {ids} {\n+proc getblobdiffs {ids singlecommit} {\n     global diffopts blobdifffd diffids env curdifftag curtagstart\n     global difffilestart nextupdate diffinhdr treediffs\n \n     set id [lindex $ids 0]\n     set env(GIT_DIFF_OPTS) $diffopts\n-    set cmd [list | git-diff-tree --no-commit-id -r -p -C $id]\n+    if {$singlecommit == 1} {\n+\tset cmd [list | git-diff-tree --no-commit-id -r -p -C $id]\n+    } else {\n+\tset p [lindex $ids 1]\n+\tset cmd [list | git-diff-tree --no-commit-id -r -p -C $p $id]\n+    }\n     if {[catch {set bdf [open $cmd r]} err]} {\n \tputs \"error getting diffs: $err\"\n \treturn\n@@ -3340,7 +3351,7 @@ proc doseldiff {oldid newid} {\n     $ctext conf -state disabled\n     $ctext tag delete Comments\n     $ctext tag remove found 1.0 end\n-    startdiff [list $newid $oldid]\n+    startdiff [list $newid $oldid] 0\n }\n \n proc mkpatch {} {\n---\n0.99.9.GIT\n\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"12858","messageId":"17290.49053.798223.402920@cargo.ozlabs.ibm.com","threadId":"2694","inReplyTo":"20051127222929.GM3393@nowhere.earth","subject":"Re: [PATCH] Fix gitk this->selected diffs","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2005-11-28T08:28:13Z","receivedAt":"2005-11-28T08:28:13Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Yann Dirson writes:\n\n> This patch changes the two git-diff-tree calls to get the necessary\n> two ids in this case.  It does so by propagating a \"singlecommit\" flag\n> through all functions involved via an additional argument.\n\nSeems a bit ugly...  Why can't we just make the ids list that we pass\naround have either 1 or 2 elements instead?  I'll have a closer look,\nbut assuming that works I think it'll be a lot cleaner.\n\nThanks,\nPaul.\n"}]}