{"thread":{"id":"25669","subject":"[PATCH] gitk: Add \"First parent\" checkbox","startedAt":"2010-11-08T11:58:14Z","lastAt":"2010-11-08T11:58:14Z","messageCount":1,"participants":["Stefan Haller"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"155374","messageId":"1289217494-69931-1-git-send-email-lists@haller-berlin.de","threadId":"25669","inReplyTo":null,"subject":"[PATCH] gitk: Add \"First parent\" checkbox","fromName":"Stefan Haller","fromEmail":"lists@haller-berlin.de","sentAt":"2010-11-08T11:58:14Z","receivedAt":"2010-11-08T11:58:14Z","isPatch":true,"sender":{"key":"lists@haller-berlin.de","avatar":null},"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---\nI realize this conflicts with Thomas Rast's recent path to add a\nword-diff dropdown box; things are fighting for space in the diff\npane header...\n\n gitk |   24 +++++++++++++++++++++---\n 1 files changed, 21 insertions(+), 3 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 45e3380..db0f022 100755\n--- a/gitk\n+++ b/gitk\n@@ -2245,6 +2245,9 @@ proc makewindow {} {\n     ${NS}::checkbutton .bleft.mid.ignspace -text [mc \"Ignore space change\"] \\\n \t-command changeignorespace -variable ignorespace\n     pack .bleft.mid.ignspace -side left -padx 5\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     set ctext .bleft.bottom.ctext\n     text $ctext -background $bgcolor -foreground $fgcolor \\\n \t-state disabled -font textfont \\\n@@ -6872,6 +6875,7 @@ proc selectline {l isnew {desired_loc {}}} {\n     global cmitmode showneartags allcommits\n     global targetrow targetid lastscrollrows\n     global autoselect jump_to_here\n+    global firstparent\n \n     catch {unset pending_select}\n     $canv delete hover\n@@ -7013,7 +7017,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@@ -7416,7 +7420,7 @@ proc diffcmd {ids flags} {\n proc gettreediffs {ids} {\n     global treediff treepending\n \n-    if {[catch {set gdtf [open [diffcmd $ids {--no-commit-id}] r]}]} return\n+    if {[catch {set gdtf [open [diffcmd $ids {--no-commit-id -m --first-parent}] r]}]} return\n \n     set treepending $ids\n     set treediff {}\n@@ -7504,11 +7508,19 @@ proc changeignorespace {} {\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 firstparent\n     global limitdiffs vfilelimit curview\n     global diffencoding targetline diffnparents\n     global git_version currdiffsubmod\n@@ -7521,10 +7533,15 @@ 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 {$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@@ -11393,6 +11410,7 @@ if {[tk windowingsystem] eq \"win32\"} {\n set diffcolors {red \"#00a000\" blue}\n set diffcontext 3\n set ignorespace 0\n+set firstparent 0\n set markbgcolor \"#e0e0ff\"\n \n set circlecolors {white blue gray blue blue}\n-- \n1.7.3.2.153.g8250e\n"}]}