{"thread":{"id":"11305","subject":"[RFC 2/4] gitk: Add diff-diff support","startedAt":"2007-12-15T16:51:42Z","lastAt":"2007-12-15T19:34:49Z","messageCount":8,"participants":["Steffen Prohaska","Johannes Schindelin","Björn Steinbrink","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"63257","messageId":"1197737505128-git-send-email-prohaska@zib.de","threadId":"11305","inReplyTo":null,"subject":"[RFC 1/4] Add diff-diff, which compares the diffs of two commits","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-12-15T16:51:42Z","receivedAt":"2007-12-15T16:51:42Z","isPatch":false,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"The following patch series adds experimental diff-diff support.\nIt adds a very basic command line version and experimental gitk\nsupport for displaying the differences between the patches\nassociated with two commits.\n\n\"git diff-diff commit1 commit2\" displays the differences between\nthe changes introduced by commit1 and commit2.  This is displayed\nas a unified diff between the two patches.\n\nIn gitk you can select one commit, right click on a second\ncommit, and select \"Diff Diff selected -> this\" to display the\nchanges between the patches for the two commits.  Highlighting\nof the result could certainly be improved.  But it is already\nkind of helpful.\n\nThis can, for example, be used to compare a first version of a\npatch with an improved version of the same patch.  In this case\nit is helpful to display the difference between the patches (not\nthe files changed).  If you commented on the first version, you\nmay just want to check if the original author improved the patch\naccording to your comments.\n\nAt this point, I'm only seeking comments about the general direction.\nThe patches should not be applied to git.git.\n\n - Do you think something like this would be helpful?\n - Are similar approaches already available?\n - How do you use git to support code review; besides discussing\n   patches on mailing lists?\n\n    Steffen\n\n---\n Makefile         |    3 ++-\n git-diff-diff.sh |   22 ++++++++++++++++++++++\n 2 files changed, 24 insertions(+), 1 deletions(-)\n create mode 100755 git-diff-diff.sh\n\ndiff --git a/Makefile b/Makefile\nindex b9fe40b..2e015ad 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -227,7 +227,8 @@ SCRIPT_SH = \\\n \tgit-lost-found.sh git-quiltimport.sh git-submodule.sh \\\n \tgit-filter-branch.sh \\\n \tgit-stash.sh \\\n-\tgit-browse--help.sh\n+\tgit-browse--help.sh \\\n+\tgit-diff-diff.sh\n \n SCRIPT_PERL = \\\n \tgit-add--interactive.perl \\\ndiff --git a/git-diff-diff.sh b/git-diff-diff.sh\nnew file mode 100755\nindex 0000000..aa402b2\n--- /dev/null\n+++ b/git-diff-diff.sh\n@@ -0,0 +1,22 @@\n+#!/bin/sh\n+\n+OPTIONS_KEEPDASHDASH=\n+OPTIONS_SPEC=\"\\\n+git-diff-diff <commit> <commit>\n+--\n+\"\n+\n+. git-sh-setup\n+require_work_tree\n+\n+[ $# = 3 ] || usage\n+\n+from=$(git rev-parse --verify $2) || exit\n+to=$(git rev-parse --verify $3) || exit\n+\n+git show $from >.git-commit-$from\n+git show $to >.git-commit-$to\n+\n+diff -u .git-commit-$from .git-commit-$to\n+\n+rm .git-commit-$from .git-commit-$to\n-- \n1.5.4.rc0.37.geff3a-dirty\n"},{"id":"63255","messageId":"1197737505599-git-send-email-prohaska@zib.de","threadId":"11305","inReplyTo":"1197737505128-git-send-email-prohaska@zib.de","subject":"[RFC 2/4] gitk: Add diff-diff support","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-12-15T16:51:43Z","receivedAt":"2007-12-15T16:51:43Z","isPatch":false,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\n---\n gitk-git/gitk |   46 ++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 46 insertions(+), 0 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex 1da0b0a..ca121e4 100644\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -1019,6 +1019,8 @@ proc makewindow {} {\n \t-command {diffvssel 0}\n     $rowctxmenu add command -label \"Diff selected -> this\" \\\n \t-command {diffvssel 1}\n+    $rowctxmenu add command -label \"Diff Diff selected -> this\" \\\n+\t-command {diffdiffvssel 1}\n     $rowctxmenu add command -label \"Make patch\" -command mkpatch\n     $rowctxmenu add command -label \"Create tag\" -command mktag\n     $rowctxmenu add command -label \"Write commit to file\" -command writecommit\n@@ -6010,6 +6012,50 @@ proc doseldiff {oldid newid} {\n     startdiff [list $oldid $newid]\n }\n \n+proc diffdiffvssel {dirn} {\n+    global rowmenuid selectedline displayorder\n+\n+    if {![info exists selectedline]} return\n+    if {$dirn} {\n+\tset oldid [lindex $displayorder $selectedline]\n+\tset newid $rowmenuid\n+    } else {\n+\tset oldid $rowmenuid\n+\tset newid [lindex $displayorder $selectedline]\n+    }\n+    addtohistory [list doseldiffdiff $oldid $newid]\n+    doseldiffdiff $oldid $newid\n+}\n+\n+proc doseldiffdiff {oldid newid} {\n+    global ctext\n+    global commitinfo\n+\n+    $ctext conf -state normal\n+    clear_ctext\n+    init_flist \"Top\"\n+    $ctext insert end \"From Commit \"\n+    $ctext insert end $oldid link0\n+    setlink $oldid link0\n+    $ctext insert end \"\\n     \"\n+    $ctext insert end [lindex $commitinfo($oldid) 0]\n+    $ctext insert end \"\\n\\nTo Commit   \"\n+    $ctext insert end $newid link1\n+    setlink $newid link1\n+    $ctext insert end \"\\n     \"\n+    $ctext insert end [lindex $commitinfo($newid) 0]\n+    $ctext insert end \"\\n\"\n+    $ctext insert end \"\\n\"\n+    $ctext conf -state disabled\n+    $ctext tag remove found 1.0 end\n+\n+    set diff [exec git diff-diff $oldid $newid]\n+    $ctext conf -state normal\n+    $ctext insert end \"\\n\"\n+    $ctext insert end $diff\n+    $ctext conf -state disabled\n+}\n+\n proc mkpatch {} {\n     global rowmenuid currentid commitinfo patchtop patchnum\n \n-- \n1.5.4.rc0.37.geff3a-dirty\n"},{"id":"63256","messageId":"11977375051617-git-send-email-prohaska@zib.de","threadId":"11305","inReplyTo":"1197737505599-git-send-email-prohaska@zib.de","subject":"[RFC 3/4] gitk: Refactor getblobdiffline to split off adddiffline","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-12-15T16:51:44Z","receivedAt":"2007-12-15T16:51:44Z","isPatch":false,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"getblobdiffline used to read from a file descriptor, parsed\nthe line read, and displayed the line nicely formatted.\n\nParsing and displaying the line is split off to a separate\nfunction adddiffline.\n\n---\n gitk-git/gitk |   30 +++++++++++++++++++-----------\n 1 files changed, 19 insertions(+), 11 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex ca121e4..3c4ec03 100644\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -5324,18 +5324,11 @@ proc makediffhdr {fname ids} {\n     $ctext insert $curdiffstart \"$pad $fname $pad\" filesep\n }\n \n-proc getblobdiffline {bdf ids} {\n+proc adddiffline {line ids} {\n     global diffids blobdifffd ctext curdiffstart\n     global diffnexthead diffnextnote difffilestart\n     global diffinhdr treediffs\n \n-    set nr 0\n-    $ctext conf -state normal\n-    while {[incr nr] <= 1000 && [gets $bdf line] >= 0} {\n-\tif {$ids != $diffids || $bdf != $blobdifffd($ids)} {\n-\t    close $bdf\n-\t    return 0\n-\t}\n \tif {![string compare -length 11 \"diff --git \" $line]} {\n \t    # trim off \"diff --git \"\n \t    set line [string range $line 11 end]\n@@ -5357,7 +5350,7 @@ proc getblobdiffline {bdf ids} {\n \t    if {!(($l & 1) && [string index $line $i] eq \" \" &&\n \t\t  [string range $line 2 [expr {$i - 1}]] eq \\\n \t\t      [string range $line [expr {$i + 3}] end])} {\n-\t\tcontinue\n+\t\treturn\n \t    }\n \t    # unescape if quoted and chop off the a/ from the front\n \t    if {[string index $line 0] eq \"\\\"\"} {\n@@ -5391,10 +5384,10 @@ proc getblobdiffline {bdf ids} {\n \t\tmakediffhdr $fname $ids\n \t    } elseif {[string compare -length 3 $line \"---\"] == 0} {\n \t\t# do nothing\n-\t\tcontinue\n+\t\treturn\n \t    } elseif {[string compare -length 3 $line \"+++\"] == 0} {\n \t\tset diffinhdr 0\n-\t\tcontinue\n+\t\treturn\n \t    }\n \t    $ctext insert end \"$line\\n\" filesep\n \n@@ -5411,6 +5404,21 @@ proc getblobdiffline {bdf ids} {\n \t\t$ctext insert end \"$line\\n\" hunksep\n \t    }\n \t}\n+}\n+\n+proc getblobdiffline {bdf ids} {\n+    global diffids blobdifffd ctext curdiffstart\n+    global diffnexthead diffnextnote difffilestart\n+    global diffinhdr treediffs\n+\n+    set nr 0\n+    $ctext conf -state normal\n+    while {[incr nr] <= 1000 && [gets $bdf line] >= 0} {\n+\tif {$ids != $diffids || $bdf != $blobdifffd($ids)} {\n+\t    close $bdf\n+\t    return 0\n+\t}\n+\tadddiffline $line $ids\n     }\n     $ctext conf -state disabled\n     if {[eof $bdf]} {\n-- \n1.5.4.rc0.37.geff3a-dirty\n"},{"id":"63258","messageId":"11977375052395-git-send-email-prohaska@zib.de","threadId":"11305","inReplyTo":"11977375051617-git-send-email-prohaska@zib.de","subject":"[RFC 4/4] gitk: Use adddiffline to nicely format diff-diff","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-12-15T16:51:45Z","receivedAt":"2007-12-15T16:51:45Z","isPatch":false,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\n---\n gitk-git/gitk |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex 3c4ec03..31b2b5f 100644\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -6059,8 +6059,9 @@ proc doseldiffdiff {oldid newid} {\n \n     set diff [exec git diff-diff $oldid $newid]\n     $ctext conf -state normal\n-    $ctext insert end \"\\n\"\n-    $ctext insert end $diff\n+    foreach line [split $diff \"\\n\"] {\n+\tadddiffline $line [list $oldid $newid]\n+    }\n     $ctext conf -state disabled\n }\n \n-- \n1.5.4.rc0.37.geff3a-dirty\n"},{"id":"63259","messageId":"Pine.LNX.4.64.0712151654060.27959@racer.site","threadId":"11305","inReplyTo":"1197737505128-git-send-email-prohaska@zib.de","subject":"Re: [RFC 1/4] Add diff-diff, which compares the diffs of two commits","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-12-15T16:55:14Z","receivedAt":"2007-12-15T16:55:14Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 15 Dec 2007, Steffen Prohaska wrote:\n\n> The following patch series adds experimental diff-diff support. It adds \n> a very basic command line version and experimental gitk support for \n> displaying the differences between the patches associated with two \n> commits.\n\nI briefly considered adding something like interdiff a year ago, but \ndecided that installing patchutils and having an alias was enough for my \nneeds.\n\nIOW I do not need this to be a git command.\n\nCiao,\nDscho\n"},{"id":"63260","messageId":"20071215170436.GA22485@atjola.homenet","threadId":"11305","inReplyTo":"1197737505128-git-send-email-prohaska@zib.de","subject":"Re: [RFC 1/4] Add diff-diff, which compares the diffs of two commits","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2007-12-15T17:04:36Z","receivedAt":"2007-12-15T17:04:36Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2007.12.15 17:51:42 +0100, Steffen Prohaska wrote:\n> The following patch series adds experimental diff-diff support.\n[...]\n> At this point, I'm only seeking comments about the general direction.\n> The patches should not be applied to git.git.\n> \n>  - Do you think something like this would be helpful?\n\nI think I might use it to e.g. compare stuff when upstream modified the\npatch I submitted.\n\n>  - Are similar approaches already available?\n\ninterdiff from patchutils. Probably interdiff would also be a better\nname than diff-diff, just to be consistent with what is already there.\nAnd using interdiff instead of plain diff in your script might also\nyield better results (I didn't use interdiff that often yet).\n\nBjörn\n"},{"id":"63262","messageId":"A5764757-D8D1-4B4C-B70D-4D1B0775423B@zib.de","threadId":"11305","inReplyTo":"20071215170436.GA22485@atjola.homenet","subject":"Re: [RFC 1/4] Add diff-diff, which compares the diffs of two commits","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-12-15T17:33:07Z","receivedAt":"2007-12-15T17:33:07Z","isPatch":false,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Dec 15, 2007, at 6:04 PM, Björn Steinbrink wrote:\n\n> On 2007.12.15 17:51:42 +0100, Steffen Prohaska wrote:\n>> The following patch series adds experimental diff-diff support.\n> [...]\n>> At this point, I'm only seeking comments about the general direction.\n>> The patches should not be applied to git.git.\n>>\n>>  - Are similar approaches already available?\n>\n> interdiff from patchutils. Probably interdiff would also be a better\n> name than diff-diff, just to be consistent with what is already there.\n> And using interdiff instead of plain diff in your script might also\n> yield better results (I didn't use interdiff that often yet).\n\n\nAt a first glance, interdiff yields more intuitive results if it\nworks, but it may fail if the two patches differ to much.  I need\nto play more to see how useful it is in real world examples.  I\ndid not know interdiff before.\n\nAt this point I'm not convinced that interdiff is exactly what I\nhave in mind.  For example it doesn't show differences between\ncommit messages of two git patches.\n\n\tSteffen\n"},{"id":"63270","messageId":"7vzlwblpk6.fsf@gitster.siamese.dyndns.org","threadId":"11305","inReplyTo":"1197737505128-git-send-email-prohaska@zib.de","subject":"Re: [RFC 1/4] Add diff-diff, which compares the diffs of two commits","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-12-15T19:34:49Z","receivedAt":"2007-12-15T19:34:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steffen Prohaska <prohaska@zib.de> writes:\n\n> At this point, I'm only seeking comments about the general direction.\n> The patches should not be applied to git.git.\n>\n>  - Do you think something like this would be helpful?\n>  - Are similar approaches already available?\n>  - How do you use git to support code review; besides discussing\n>    patches on mailing lists?\n\nI think there are other good building blocks you can use outside git to\nhelp reviewing evolution of patches (interdiff comes to mind).\n\nWhen I receive a replacement series to a topic, I use RP script\n(available in my 'todo' branch and checked out in Meta/ directory in my\nwork area, together with other scripts from 'todo'), which:\n\n * finds where the older series were applied;\n * detaches HEAD at that commit, and apply the new series;\n * runs diff between the old and new;\n * updates the tip of that topic with the new series.\n\nAfter it finishes, \"diff topic@{1} topic\" becomes the incremental diff\nbetween the old and the new series, and if I do not like the end result,\nI can reset --hard back to topic@{1}.\n"}]}