{"thread":{"id":"35247","subject":"Show patch in gitk --first-parent ?","startedAt":"2013-10-30T12:39:08Z","lastAt":"2013-10-31T14:59:12Z","messageCount":6,"participants":["Karl Wiberg","Stefan Haller","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"229812","messageId":"CAFAOj7p49pQo=hXZT3TmMFF+KThKY-PZ2cgsZasH=e8rgjri1A@mail.gmail.com","threadId":"35247","inReplyTo":null,"subject":"Show patch in gitk --first-parent ?","fromName":"Karl Wiberg","fromEmail":"kha@treskal.com","sentAt":"2013-10-30T12:39:08Z","receivedAt":"2013-10-30T12:39:08Z","isPatch":false,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"Hi all,\n\nWith \"gitk --first-parent\", I get a graph that only follows the first\nparent of every merge---perfect if you always merge topic branches\ninto the main branch. However, the diff shown is still the normal\nmerge diff, and not the diff between the new tree and the first\nparent's tree---is it possible to make it do that instead?\n\n(With \"git log --first-parent -p -m\", I get precisely the diffs I\nwant, but everything is fully expanded so it's hard to navigate.)\n\n-- \nKarl Wiberg, kha@treskal.com\n   subrabbit.wordpress.com\n   www.treskal.com/kalle\n"},{"id":"229813","messageId":"1lbk7r8.1khd6h5pbrifuM%lists@haller-berlin.de","threadId":"35247","inReplyTo":"CAFAOj7p49pQo=hXZT3TmMFF+KThKY-PZ2cgsZasH=e8rgjri1A@mail.gmail.com","subject":"Re: Show patch in gitk --first-parent ?","fromName":"Stefan Haller","fromEmail":"lists@haller-berlin.de","sentAt":"2013-10-30T14:30:27Z","receivedAt":"2013-10-30T14:30:27Z","isPatch":false,"sender":{"key":"lists@haller-berlin.de","avatar":null},"body":"Karl Wiberg <kha@treskal.com> wrote:\n\n> With \"gitk --first-parent\", I get a graph that only follows the first\n> parent of every merge---perfect if you always merge topic branches\n> into the main branch. However, the diff shown is still the normal\n> merge diff, and not the diff between the new tree and the first\n> parent's tree---is it possible to make it do that instead?\n\nI once posted a patch that adds a \"First parent\" checkbox to gitk's\nwindow: <http://comments.gmane.org/gmane.comp.version-control.git/160920>\n\nThe patch no longer applies today, but I can send an updated version that\ndoes, if there's interest.\n\nThe topic didn't go anywhere for two reasons:\n\n1) There's the confusion about history traversal option (the existing\n--first-parent command-line option) versus diff option (the new check\nbox); they have similar names, but control different things (and it\nshould be possible to control these independently).\n\n2) Space is short in the diff pane; you need to make the window rather\nwide to see them all.\n\nI didn't have the energy to drive these to a resolution back then; if you\ncould do that, it would be great. Personally I'm using my own gitk with\nmy patch applied, and I do use the \"First parent\" checkbox rather often.\n\n\n-- \nStefan Haller\nBerlin, Germany\nhttp://www.haller-berlin.de/\n"},{"id":"229833","messageId":"CAFAOj7orccjudOu4czDpaN-TZBCFb=T-Qo8f9eo_1dnKBGXJ4g@mail.gmail.com","threadId":"35247","inReplyTo":"1lbk7r8.1khd6h5pbrifuM%lists@haller-berlin.de","subject":"Re: Show patch in gitk --first-parent ?","fromName":"Karl Wiberg","fromEmail":"kha@treskal.com","sentAt":"2013-10-30T17:10:43Z","receivedAt":"2013-10-30T17:10:43Z","isPatch":false,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On Wed, Oct 30, 2013 at 3:30 PM, Stefan Haller <lists@haller-berlin.de> wrote:\n\n> I once posted a patch that adds a \"First parent\" checkbox to gitk's\n> window:\n> <http://comments.gmane.org/gmane.comp.version-control.git/160920>\n>\n> The patch no longer applies today, but I can send an updated version\n> that does, if there's interest.\n\nPlease do. I don't have the time to attempt to drive inclusion of the\npatch (I'd have to start by reading up on tcl and gitk), but if you\nhave a patch ready, I'd like to try it.\n\n> The topic didn't go anywhere for two reasons:\n>\n> 1) There's the confusion about history traversal option (the\n> existing --first-parent command-line option) versus diff option (the\n> new check box); they have similar names, but control different\n> things (and it should be possible to control these independently).\n>\n> 2) Space is short in the diff pane; you need to make the window\n> rather wide to see them all.\n>\n> I didn't have the energy to drive these to a resolution back then;\n> if you could do that, it would be great. Personally I'm using my own\n> gitk with my patch applied, and I do use the \"First parent\" checkbox\n> rather often.\n\nHmmm, I wonder... a related feature I'd like to have is to see the\ncombined diff of two or more commits. I guess the fully general form\nof this is to allow the user to select one \"after\" commit and zero or\nmore \"before\" commits, and then present the resulting diff.\n\nFor example, when the user clicks on the shortlog of a commit, gitk\ncould automatically select its parents (by painting their dots in the\nDAG differently, say). The user could then click on any commit dot in\nthe dag to toggle it between being included in and excluded from the\n\"before\" set. (A simpler variant would be to limit the \"before\" set to\nexactly one commit as soon as the user changes it at all.)\n\nAs I said, I don't have time to do this myself; I just thought I'd\ntoss the idea out there, since good ideas are so scarce and competent\nprogrammers with free time on their hands are so plentiful.\n\n-- \nKarl Wiberg, kha@treskal.com\n   subrabbit.wordpress.com\n   www.treskal.com/kalle\n"},{"id":"229845","messageId":"874n7yiqxo.fsf@igel.home","threadId":"35247","inReplyTo":"CAFAOj7p49pQo=hXZT3TmMFF+KThKY-PZ2cgsZasH=e8rgjri1A@mail.gmail.com","subject":"Re: Show patch in gitk --first-parent ?","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2013-10-30T17:55:47Z","receivedAt":"2013-10-30T17:55:47Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Karl Wiberg <kha@treskal.com> writes:\n\n> With \"gitk --first-parent\", I get a graph that only follows the first\n> parent of every merge---perfect if you always merge topic branches\n> into the main branch. However, the diff shown is still the normal\n> merge diff, and not the diff between the new tree and the first\n> parent's tree---is it possible to make it do that instead?\n\nWhile not automatic, you can right click on the parent and select\nDiff this->selected.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"229911","messageId":"CAFAOj7oskj3TKZU4O5-=CejJVV7v0OiS9t-S9vO4nBtC+jA6jQ@mail.gmail.com","threadId":"35247","inReplyTo":"874n7yiqxo.fsf@igel.home","subject":"Re: Show patch in gitk --first-parent ?","fromName":"Karl Wiberg","fromEmail":"kha@treskal.com","sentAt":"2013-10-31T10:10:54Z","receivedAt":"2013-10-31T10:10:54Z","isPatch":false,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On Wed, Oct 30, 2013 at 6:55 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:\n> While not automatic, you can right click on the parent and select\n> Diff this->selected.\n\nAnd there's also the option to \"mark\" a commit, and diff this with\nmarked. Thanks, that's just what I needed (although as you say, it\nisn't automatic).\n\n-- \nKarl Wiberg, kha@treskal.com\n   subrabbit.wordpress.com\n   www.treskal.com/kalle\n"},{"id":"229919","messageId":"1383231552-63504-1-git-send-email-stefan@haller-berlin.de","threadId":"35247","inReplyTo":"CAFAOj7orccjudOu4czDpaN-TZBCFb=T-Qo8f9eo_1dnKBGXJ4g@mail.gmail.com","subject":"[PATCH] gitk: Add \"First parent\" checkbox","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2013-10-31T14:59:12Z","receivedAt":"2013-10-31T14:59:12Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"Sometimes it's desirable to see what changes were introduced by a\nmerge commit, rather than how conflicts were resolved. This adds\na checkbox which, when turned on, makes gitk show the equivalent\nof \"git show --first-parent <commit>\" for merge commits.\n\nSigned-off-by: Stefan Haller <stefan@haller-berlin.de>\n---\nThis is the same patch as the one I sent in\n<http://comments.gmane.org/gmane.comp.version-control.git/160920>, with\nthe same issues discussed in that thread. I just brought it up to date\nwith current master.\n\n gitk | 25 ++++++++++++++++++++++---\n 1 file changed, 22 insertions(+), 3 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 5cd00d8..3466054 100755\n--- a/gitk\n+++ b/gitk\n@@ -2336,6 +2336,10 @@ proc makewindow {} {\n \tpack .bleft.mid.worddiff -side left -padx 5\n     }\n\n+    ${NS}::checkbutton .bleft.mid.firstparent -text [mc \"First parent\"] \\\n+\t-command changefirstparent -variable firstparent\n+    pack .bleft.mid.firstparent -side left -padx 5\n+\n     set ctext .bleft.bottom.ctext\n     text $ctext -background $bgcolor -foreground $fgcolor \\\n \t-state disabled -font textfont \\\n@@ -7080,6 +7084,7 @@ proc selectline {l isnew {desired_loc {}}} {\n     global cmitmode showneartags allcommits\n     global targetrow targetid lastscrollrows\n     global autoselect autosellen jump_to_here\n+    global firstparent\n\n     catch {unset pending_select}\n     $canv delete hover\n@@ -7221,7 +7226,7 @@ proc selectline {l isnew {desired_loc {}}} {\n     init_flist [mc \"Comments\"]\n     if {$cmitmode eq \"tree\"} {\n \tgettree $id\n-    } elseif {[llength $olds] <= 1} {\n+    } elseif {[llength $olds] <= 1 || $firstparent} {\n \tstartdiff $id\n     } else {\n \tmergediff $id\n@@ -7624,7 +7629,7 @@ proc diffcmd {ids flags} {\n proc gettreediffs {ids} {\n     global treediff treepending limitdiffs vfilelimit curview\n\n-    set cmd [diffcmd $ids {--no-commit-id}]\n+    set cmd [diffcmd $ids {--no-commit-id -m --first-parent}]\n     if {$limitdiffs && $vfilelimit($curview) ne {}} {\n \t    set cmd [concat $cmd -- $vfilelimit($curview)]\n     }\n@@ -7710,12 +7715,20 @@ proc changeworddiff {name ix op} {\n     reselectline\n }\n\n+proc changefirstparent {} {\n+    global treediffs\n+    catch {unset treediffs}\n+\n+    reselectline\n+}\n+\n proc getblobdiffs {ids} {\n     global blobdifffd diffids env\n     global diffinhdr treediffs\n     global diffcontext\n     global ignorespace\n     global worddiff\n+    global firstparent\n     global limitdiffs vfilelimit curview\n     global diffencoding targetline diffnparents\n     global git_version currdiffsubmod\n@@ -7728,13 +7741,18 @@ proc getblobdiffs {ids} {\n     if {[package vcompare $git_version \"1.6.6\"] >= 0} {\n \tset submodule \"--submodule\"\n     }\n-    set cmd [diffcmd $ids \"-p $textconv $submodule  -C --cc --no-commit-id -U$diffcontext\"]\n+    set cmd [diffcmd $ids \"-p $textconv $submodule  -C --no-commit-id -U$diffcontext\"]\n     if {$ignorespace} {\n \tappend cmd \" -w\"\n     }\n     if {$worddiff ne [mc \"Line diff\"]} {\n \tappend cmd \" --word-diff=porcelain\"\n     }\n+    if {$firstparent} {\n+\tappend cmd \" -m --first-parent\"\n+    } else {\n+\tappend cmd \" --cc\"\n+    }\n     if {$limitdiffs && $vfilelimit($curview) ne {}} {\n \tset cmd [concat $cmd -- $vfilelimit($curview)]\n     }\n@@ -11865,6 +11883,7 @@ set diffcontext 3\n set mergecolors {red blue green purple brown \"#009090\" magenta \"#808000\" \"#009000\" \"#ff0080\" cyan \"#b07070\" \"#70b0f0\" \"#70f0b0\" \"#f0b070\" \"#ff70b0\"}\n set ignorespace 0\n set worddiff \"\"\n+set firstparent 0\n set markbgcolor \"#e0e0ff\"\n\n set headbgcolor green\n--\n1.8.3.2.747.g15edaa9\n"}]}