From: Pierre Dumuid <pmdumuid@gmail.com>
To: paulus@ozlabs.org, git@vger.kernel.org
Cc: Pierre Dumuid <pmdumuid@gmail.com>
Subject: [PATCH 1/6] Enable ability to visualise the results of git cherry C1 C2
Date: Thu, 15 Dec 2016 21:58:42 +1030 [thread overview]
Message-ID: <20161215112847.14719-1-pmdumuid@gmail.com> (raw)
It's a bit clunky but it works!!
Usage:
- mark commit one (e.g. v45)
- Select commit two.
- Switch the gdttype to the option, "git-cherry between marked commit and:"
Signed-off-by: Pierre Dumuid <pmdumuid@gmail.com>
---
gitk | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 107 insertions(+), 3 deletions(-)
diff --git a/gitk b/gitk
index a14d7a1..50d1ef4 100755
--- a/gitk
+++ b/gitk
@@ -2319,7 +2319,9 @@ proc makewindow {} {
[mc "containing:"] \
[mc "touching paths:"] \
[mc "adding/removing string:"] \
- [mc "changing lines matching:"]]
+ [mc "changing lines matching:"] \
+ [mc "git-cherry between marked commit and:"] \
+ ]
trace add variable gdttype write gdttype_change
pack .tf.lbar.gdttype -side left -fill y
@@ -4707,6 +4709,18 @@ proc gdttype_change {name ix op} {
global gdttype highlight_files findstring findpattern
stopfinding
+
+ if {$gdttype eq [mc "git-cherry between marked commit and:"]} {
+ if {$highlight_files ne {}} {
+ set highlight_files {}
+ hfiles_change
+ }
+ findcom_change
+ update_gitcherrylist
+ drawvisible
+ return
+ }
+
if {$findstring ne {}} {
if {$gdttype eq [mc "containing:"]} {
if {$highlight_files ne {}} {
@@ -4733,6 +4747,9 @@ proc find_change {name ix op} {
stopfinding
if {$gdttype eq [mc "containing:"]} {
findcom_change
+ } elseif {$gdttype eq [mc "git-cherry between marked commit and:"]} {
+ findcom_change
+ update_gitcherrylist
} else {
if {$highlight_files ne $findstring} {
set highlight_files $findstring
@@ -4742,6 +4759,54 @@ proc find_change {name ix op} {
drawvisible
}
+proc update_gitcherrylist {} {
+ global gitcherryids
+ global markedid
+ global findstring
+ global fstring
+ global currentid
+ global iddrawn
+
+ unset -nocomplain gitcherryids
+ set fs $findstring
+
+ if {$findstring eq {}} {
+ $fstring delete 0 end
+ $fstring insert 0 $currentid
+ }
+
+ if {![info exists markedid]} {
+ error_popup [mc "Please mark a git commit before using this find method!"]
+ return
+ }
+
+ #puts [join [list "Running cherry between: `" $markedid "` and `" $findstring "`"] ""]
+
+ if {[catch {set cherryOutput [exec git cherry $markedid $findstring]}]} {
+ puts "ERROR: An error occured running git-cherry!"
+ return
+ }
+
+ set cherryLines [split $cherryOutput "\n"]
+ foreach cherryLine $cherryLines {
+ set op [lindex [split $cherryLine " "] 0]
+ set gitSha [lindex [split $cherryLine " "] 1]
+
+ #puts [join [list "line is: `" $cherryLine "`, op:`" $op "`, gitSha:`" $gitSha "`"] ""]
+ if {$op eq "+"} {
+ set gitcherryids($gitSha) 1
+ if ([info exists iddrawn($gitSha)]) {
+ bolden $gitSha mainfontbold
+ }
+
+ }
+ }
+ # puts "list is as follows"
+ #foreach {gitsha setBold} [array get gitcherryids] {
+ # puts [concat $gitsha = $setBold]
+ #}
+}
+
proc findcom_change args {
global nhighlights boldnameids
global findpattern findtype findstring gdttype
@@ -4802,6 +4867,9 @@ proc do_file_hl {serial} {
set gdtargs [list "-S$highlight_files"]
} elseif {$gdttype eq [mc "changing lines matching:"]} {
set gdtargs [list "-G$highlight_files"]
+ } elseif {$gdttype eq [mc "git-cherry between marked commit and:"]} {
+ # Skipping opening the file handle, filehighlight
+ return
} else {
# must be "containing:", i.e. we're searching commit info
return
@@ -4882,6 +4950,17 @@ proc doesmatch {f} {
}
}
+proc askcherryhighlight {row id} {
+ global nhighlights gitcherryids
+
+ set isbold 0
+ if {[info exists gitcherryids($id)]} {
+ set isbold 1
+ }
+
+ set nhighlights($id) $isbold
+}
+
proc askfindhighlight {row id} {
global nhighlights commitinfo iddrawn
global findloc
@@ -6216,6 +6295,7 @@ proc drawcmitrow {row} {
global filehighlight fhighlights findpattern nhighlights
global hlview vhighlights
global highlight_related rhighlights
+ global gdttype
if {$row >= $numcommits} return
@@ -6226,6 +6306,11 @@ proc drawcmitrow {row} {
if {[info exists filehighlight] && ![info exists fhighlights($id)]} {
askfilehighlight $row $id
}
+
+ if {$gdttype eq [mc "git-cherry between marked commit and:"] && ![info exists nhighlights($id)]} {
+ askcherryhighlight $row $id
+ }
+
if {$findpattern ne {} && ![info exists nhighlights($id)]} {
askfindhighlight $row $id
}
@@ -6776,7 +6861,9 @@ proc dofind {{dirn 1} {wrap 1}} {
}
set findcurline $findstartline
nowbusy finding [mc "Searching"]
- if {$gdttype ne [mc "containing:"] && ![info exists filehighlight]} {
+ if {$gdttype eq [mc "git-cherry between marked commit and:"]} {
+ # Don't do anything related to open do_file_hl since we'll just have a list
+ } elseif {$gdttype ne [mc "containing:"] && ![info exists filehighlight]} {
after cancel do_file_hl $fh_serial
do_file_hl $fh_serial
}
@@ -6803,6 +6890,7 @@ proc findmore {} {
global findstartline findcurline findallowwrap
global find_dirn gdttype fhighlights fprogcoord
global curview varcorder vrownum varccommits vrowmod
+ global gitcherryids
if {![info exists find_dirn]} {
return 0
@@ -6848,7 +6936,23 @@ proc findmore {} {
set arow [lindex $vrownum($curview) $ai]
set ids [lindex $varccommits($curview,$a)]
set arowend [expr {$arow + [llength $ids]}]
- if {$gdttype eq [mc "containing:"]} {
+
+ if {$gdttype eq [mc "git-cherry between marked commit and:"]} {
+ for {} {$n > 0} {incr n -1; incr l $find_dirn} {
+ if {$l < $arow || $l >= $arowend} {
+ incr ai $find_dirn
+ set a [lindex $varcorder($curview) $ai]
+ set arow [lindex $vrownum($curview) $ai]
+ set ids [lindex $varccommits($curview,$a)]
+ set arowend [expr {$arow + [llength $ids]}]
+ }
+ set id [lindex $ids [expr {$l - $arow}]]
+ if {[info exists gitcherryids($id)]} {
+ set found 1
+ }
+ if {$found} break
+ }
+ } elseif {$gdttype eq [mc "containing:"]} {
for {} {$n > 0} {incr n -1; incr l $find_dirn} {
if {$l < $arow || $l >= $arowend} {
incr ai $find_dirn
--
2.10.2
next reply other threads:[~2016-12-15 11:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-15 11:28 Pierre Dumuid [this message]
2016-12-15 11:28 ` [PATCH 2/6] Add ability to follow a remote branch with a dialog Pierre Dumuid
2016-12-31 8:53 ` Paul Mackerras
2016-12-15 11:28 ` [PATCH 3/6] Add a tree view to the local branches, remote branches and tags, where / is treated as a directory seperator Pierre Dumuid
2016-12-31 9:08 ` Paul Mackerras
2016-12-15 11:28 ` [PATCH 4/6] Add DirDiffTool as additional option Pierre Dumuid
2016-12-15 11:28 ` [PATCH 5/6] gitk: Add a "Save file as" menu item Pierre Dumuid
2016-12-15 11:28 ` [PATCH 6/6] Rename 'remotes/' to 'r../' in heads Pierre Dumuid
2016-12-31 8:30 ` [PATCH 1/6] Enable ability to visualise the results of git cherry C1 C2 Paul Mackerras
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161215112847.14719-1-pmdumuid@gmail.com \
--to=pmdumuid@gmail.com \
--cc=git@vger.kernel.org \
--cc=paulus@ozlabs.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).