git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitk: Add "First parent" checkbox
@ 2010-11-08 10:42 Stefan Haller
  2010-11-08 17:24 ` Jonathan Nieder
  2010-12-12  4:27 ` Paul Mackerras
  0 siblings, 2 replies; 11+ messages in thread
From: Stefan Haller @ 2010-11-08 10:42 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: git

Sometimes it's desirable to see what changes were introduced by a
merge commit, rather than how conflicts were resolved. This adds
a checkbox which, when turned on, makes gitk show the equivalent
of "git show --first-parent <commit>" for merge commits.

Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
---
I realize this conflicts with Thomas Rast's recent patch to
add a word-diff dropdown box; things are fighting for space
in the diff pane header...

 gitk |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/gitk b/gitk
index 45e3380..db0f022 100755
--- a/gitk
+++ b/gitk
@@ -2245,6 +2245,9 @@ proc makewindow {} {
     ${NS}::checkbutton .bleft.mid.ignspace -text [mc "Ignore space change"] \
 	-command changeignorespace -variable ignorespace
     pack .bleft.mid.ignspace -side left -padx 5
+    ${NS}::checkbutton .bleft.mid.firstparent -text [mc "First parent"] \
+	-command changefirstparent -variable firstparent
+    pack .bleft.mid.firstparent -side left -padx 5
     set ctext .bleft.bottom.ctext
     text $ctext -background $bgcolor -foreground $fgcolor \
 	-state disabled -font textfont \
@@ -6872,6 +6875,7 @@ proc selectline {l isnew {desired_loc {}}} {
     global cmitmode showneartags allcommits
     global targetrow targetid lastscrollrows
     global autoselect jump_to_here
+    global firstparent
 
     catch {unset pending_select}
     $canv delete hover
@@ -7013,7 +7017,7 @@ proc selectline {l isnew {desired_loc {}}} {
     init_flist [mc "Comments"]
     if {$cmitmode eq "tree"} {
 	gettree $id
-    } elseif {[llength $olds] <= 1} {
+    } elseif {[llength $olds] <= 1 || $firstparent} {
 	startdiff $id
     } else {
 	mergediff $id
@@ -7416,7 +7420,7 @@ proc diffcmd {ids flags} {
 proc gettreediffs {ids} {
     global treediff treepending
 
-    if {[catch {set gdtf [open [diffcmd $ids {--no-commit-id}] r]}]} return
+    if {[catch {set gdtf [open [diffcmd $ids {--no-commit-id -m --first-parent}] r]}]} return
 
     set treepending $ids
     set treediff {}
@@ -7504,11 +7508,19 @@ proc changeignorespace {} {
     reselectline
 }
 
+proc changefirstparent {} {
+    global treediffs
+    catch {unset treediffs}
+
+    reselectline
+}
+
 proc getblobdiffs {ids} {
     global blobdifffd diffids env
     global diffinhdr treediffs
     global diffcontext
     global ignorespace
+    global firstparent
     global limitdiffs vfilelimit curview
     global diffencoding targetline diffnparents
     global git_version currdiffsubmod
@@ -7521,10 +7533,15 @@ proc getblobdiffs {ids} {
     if {[package vcompare $git_version "1.6.6"] >= 0} {
 	set submodule "--submodule"
     }
-    set cmd [diffcmd $ids "-p $textconv $submodule  -C --cc --no-commit-id -U$diffcontext"]
+    set cmd [diffcmd $ids "-p $textconv $submodule  -C --no-commit-id -U$diffcontext"]
     if {$ignorespace} {
 	append cmd " -w"
     }
+    if {$firstparent} {
+	append cmd " -m --first-parent"
+    } else {
+	append cmd " --cc"
+    }
     if {$limitdiffs && $vfilelimit($curview) ne {}} {
 	set cmd [concat $cmd -- $vfilelimit($curview)]
     }
@@ -11393,6 +11410,7 @@ if {[tk windowingsystem] eq "win32"} {
 set diffcolors {red "#00a000" blue}
 set diffcontext 3
 set ignorespace 0
+set firstparent 0
 set markbgcolor "#e0e0ff"
 
 set circlecolors {white blue gray blue blue}
-- 
1.7.3.2.153.g8250e

^ permalink raw reply related	[flat|nested] 11+ messages in thread
* [PATCH] gitk: Add "First parent" checkbox
@ 2010-11-08 11:58 Stefan Haller
  0 siblings, 0 replies; 11+ messages in thread
From: Stefan Haller @ 2010-11-08 11:58 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: git

Sometimes it's desirable to see what changes were introduced by a
merge commit, rather than how conflicts were resolved. This adds
a checkbox which, when turned on, makes gitk show the equivalent
of "git show --first-parent <commit>" for merge commits.

Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
---
I realize this conflicts with Thomas Rast's recent path to add a
word-diff dropdown box; things are fighting for space in the diff
pane header...

 gitk |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/gitk b/gitk
index 45e3380..db0f022 100755
--- a/gitk
+++ b/gitk
@@ -2245,6 +2245,9 @@ proc makewindow {} {
     ${NS}::checkbutton .bleft.mid.ignspace -text [mc "Ignore space change"] \
 	-command changeignorespace -variable ignorespace
     pack .bleft.mid.ignspace -side left -padx 5
+    ${NS}::checkbutton .bleft.mid.firstparent -text [mc "First parent"] \
+	-command changefirstparent -variable firstparent
+    pack .bleft.mid.firstparent -side left -padx 5
     set ctext .bleft.bottom.ctext
     text $ctext -background $bgcolor -foreground $fgcolor \
 	-state disabled -font textfont \
@@ -6872,6 +6875,7 @@ proc selectline {l isnew {desired_loc {}}} {
     global cmitmode showneartags allcommits
     global targetrow targetid lastscrollrows
     global autoselect jump_to_here
+    global firstparent
 
     catch {unset pending_select}
     $canv delete hover
@@ -7013,7 +7017,7 @@ proc selectline {l isnew {desired_loc {}}} {
     init_flist [mc "Comments"]
     if {$cmitmode eq "tree"} {
 	gettree $id
-    } elseif {[llength $olds] <= 1} {
+    } elseif {[llength $olds] <= 1 || $firstparent} {
 	startdiff $id
     } else {
 	mergediff $id
@@ -7416,7 +7420,7 @@ proc diffcmd {ids flags} {
 proc gettreediffs {ids} {
     global treediff treepending
 
-    if {[catch {set gdtf [open [diffcmd $ids {--no-commit-id}] r]}]} return
+    if {[catch {set gdtf [open [diffcmd $ids {--no-commit-id -m --first-parent}] r]}]} return
 
     set treepending $ids
     set treediff {}
@@ -7504,11 +7508,19 @@ proc changeignorespace {} {
     reselectline
 }
 
+proc changefirstparent {} {
+    global treediffs
+    catch {unset treediffs}
+
+    reselectline
+}
+
 proc getblobdiffs {ids} {
     global blobdifffd diffids env
     global diffinhdr treediffs
     global diffcontext
     global ignorespace
+    global firstparent
     global limitdiffs vfilelimit curview
     global diffencoding targetline diffnparents
     global git_version currdiffsubmod
@@ -7521,10 +7533,15 @@ proc getblobdiffs {ids} {
     if {[package vcompare $git_version "1.6.6"] >= 0} {
 	set submodule "--submodule"
     }
-    set cmd [diffcmd $ids "-p $textconv $submodule  -C --cc --no-commit-id -U$diffcontext"]
+    set cmd [diffcmd $ids "-p $textconv $submodule  -C --no-commit-id -U$diffcontext"]
     if {$ignorespace} {
 	append cmd " -w"
     }
+    if {$firstparent} {
+	append cmd " -m --first-parent"
+    } else {
+	append cmd " --cc"
+    }
     if {$limitdiffs && $vfilelimit($curview) ne {}} {
 	set cmd [concat $cmd -- $vfilelimit($curview)]
     }
@@ -11393,6 +11410,7 @@ if {[tk windowingsystem] eq "win32"} {
 set diffcolors {red "#00a000" blue}
 set diffcontext 3
 set ignorespace 0
+set firstparent 0
 set markbgcolor "#e0e0ff"
 
 set circlecolors {white blue gray blue blue}
-- 
1.7.3.2.153.g8250e

^ permalink raw reply related	[flat|nested] 11+ messages in thread
* Re: Show patch in gitk --first-parent ?
@ 2013-10-30 17:10 Karl Wiberg
  2013-10-31 14:59 ` [PATCH] gitk: Add "First parent" checkbox Stefan Haller
  0 siblings, 1 reply; 11+ messages in thread
From: Karl Wiberg @ 2013-10-30 17:10 UTC (permalink / raw)
  To: Stefan Haller; +Cc: Git Mailing List, Paul Mackerras, Jonathan Nieder

On Wed, Oct 30, 2013 at 3:30 PM, Stefan Haller <lists@haller-berlin.de> wrote:

> I once posted a patch that adds a "First parent" checkbox to gitk's
> window:
> <http://comments.gmane.org/gmane.comp.version-control.git/160920>
>
> The patch no longer applies today, but I can send an updated version
> that does, if there's interest.

Please do. I don't have the time to attempt to drive inclusion of the
patch (I'd have to start by reading up on tcl and gitk), but if you
have a patch ready, I'd like to try it.

> The topic didn't go anywhere for two reasons:
>
> 1) There's the confusion about history traversal option (the
> existing --first-parent command-line option) versus diff option (the
> new check box); they have similar names, but control different
> things (and it should be possible to control these independently).
>
> 2) Space is short in the diff pane; you need to make the window
> rather wide to see them all.
>
> I didn't have the energy to drive these to a resolution back then;
> if you could do that, it would be great. Personally I'm using my own
> gitk with my patch applied, and I do use the "First parent" checkbox
> rather often.

Hmmm, I wonder... a related feature I'd like to have is to see the
combined diff of two or more commits. I guess the fully general form
of this is to allow the user to select one "after" commit and zero or
more "before" commits, and then present the resulting diff.

For example, when the user clicks on the shortlog of a commit, gitk
could automatically select its parents (by painting their dots in the
DAG differently, say). The user could then click on any commit dot in
the dag to toggle it between being included in and excluded from the
"before" set. (A simpler variant would be to limit the "before" set to
exactly one commit as soon as the user changes it at all.)

As I said, I don't have time to do this myself; I just thought I'd
toss the idea out there, since good ideas are so scarce and competent
programmers with free time on their hands are so plentiful.

-- 
Karl Wiberg, kha@treskal.com
   subrabbit.wordpress.com
   www.treskal.com/kalle

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-10-31 14:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-08 10:42 [PATCH] gitk: Add "First parent" checkbox Stefan Haller
2010-11-08 17:24 ` Jonathan Nieder
2010-11-08 19:40   ` Stefan Haller
2010-11-08 19:48     ` Jonathan Nieder
2010-11-08 20:23       ` Stefan Haller
2010-11-08 21:11         ` Jonathan Nieder
2010-11-10  7:17           ` Stefan Haller
2010-12-12  4:27 ` Paul Mackerras
2010-12-12 20:08   ` [PATCH v2/RFC] " lists
  -- strict thread matches above, loose matches on Subject: below --
2010-11-08 11:58 [PATCH] " Stefan Haller
2013-10-30 17:10 Show patch in gitk --first-parent ? Karl Wiberg
2013-10-31 14:59 ` [PATCH] gitk: Add "First parent" checkbox Stefan Haller

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).