From: Jason Holden <jason.k.holden.swdev@gmail.com>
To: git@vger.kernel.org
Cc: paulus@samba.org, Jason Holden <jason.k.holden.swdev@gmail.com>
Subject: [RFC/PATCH] gitk: Visualize a merge commit with a right-click in gitk
Date: Sat, 29 Dec 2012 19:16:16 -0500 [thread overview]
Message-ID: <1356826576-24334-1-git-send-email-jason.k.holden.swdev@gmail.com> (raw)
When first doing a merge in git-gui, the "Visualize Merge" button is
quite helpful to visualize the changes due to a merge.
But once the merge is complete, there's not a similarly convenient
way to recreate that merge view in gitk.
This commit adds to gitk the ability to right-click on a merge commit and
bring up a new gitk window displaying only those commits involved in
the merge.
When right-clicking on a non-merge commit, this option is grayed out. This
patch also supports correct visualization of octopus merges
Signed-off-by: Jason Holden <jason.k.holden.swdev@gmail.com>
---
gitk | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/gitk b/gitk
index 379582a..17e1fcb 100755
--- a/gitk
+++ b/gitk
@@ -2551,6 +2551,7 @@ proc makewindow {} {
{mc "Compare with marked commit" command compare_commits}
{mc "Diff this -> marked commit" command {diffvsmark 0}}
{mc "Diff marked commit -> this" command {diffvsmark 1}}
+ {mc "Visualize this merge" command visualize_merge}
}
$rowctxmenu configure -tearoff 0
@@ -2590,6 +2591,31 @@ proc makewindow {} {
$diff_menu configure -tearoff 0
}
+# Return the number of parents for a given sha1 id
+proc get_numparents_from_id {id} {
+ global parentlist
+ set row [rowofcommit $id]
+ return [llength [lindex $parentlist $row]]
+}
+
+proc visualize_merge {} {
+ global parents currentid parentlist
+ global rowmenuid
+
+ set num_parents [get_numparents_from_id $rowmenuid]
+ set row [rowofcommit $rowmenuid]
+
+ if {$num_parents >= 2} {
+ set revlist $rowmenuid
+ for { set i 1 } {$i < $num_parents} {incr i} {
+
+ set revlist "$revlist [lindex $parentlist $row 0]..[lindex $parentlist $row $i] $rowmenuid"
+ }
+
+ eval exec gitk $revlist
+ }
+}
+
# Windows sends all mouse wheel events to the current focused window, not
# the one where the mouse hovers, so bind those events here and redirect
# to the correct window
@@ -8577,6 +8603,13 @@ proc rowmenu {x y id} {
$menu entryconfigure 9 -state $mstate
$menu entryconfigure 10 -state $mstate
$menu entryconfigure 11 -state $mstate
+
+ # Disable visualize-merge on only one parent
+ if {[get_numparents_from_id $id] == 1} {
+ $menu entryconfigure 15 -state disabled
+ } else {
+ $menu entryconfigure 15 -state normal
+ }
} else {
set menu $fakerowmenu
}
--
1.8.1.rc3.28.g0ab5d1f
next reply other threads:[~2012-12-30 0:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-30 0:16 Jason Holden [this message]
2012-12-31 4:27 ` [RFC/PATCH] gitk: Visualize a merge commit with a right-click in gitk Paul Mackerras
2012-12-31 18:46 ` Jason Holden
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1356826576-24334-1-git-send-email-jason.k.holden.swdev@gmail.com \
--to=jason.k.holden.swdev@gmail.com \
--cc=git@vger.kernel.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).