* [PATCH] gitk: Add menu item for reverting commits
@ 2013-04-27 14:36 Knut Franke
2013-05-11 9:43 ` Paul Mackerras
0 siblings, 1 reply; 2+ messages in thread
From: Knut Franke @ 2013-04-27 14:36 UTC (permalink / raw
To: git; +Cc: Paul Mackerras
Sometimes it's helpful (at least psychologically) to have this feature
easily accessible. Code borrows heavily from cherrypick.
Signed-off-by: Knut Franke <Knut.Franke@gmx.de>
---
gitk | 62
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/gitk b/gitk
index 572f73f..fb1a6ce 100755
--- a/gitk
+++ b/gitk
@@ -2562,6 +2562,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 "Revert this commit" command revert}
}
$rowctxmenu configure -tearoff 0
@@ -9347,6 +9348,67 @@ proc cherrypick {} {
notbusy cherrypick
}
+proc revert {} {
+ global rowmenuid curview
+ global mainhead mainheadid
+ global gitdir
+
+ set oldhead [exec git rev-parse HEAD]
+ set dheads [descheads $rowmenuid]
+ if { $dheads eq {} || [lsearch -exact $dheads $oldhead] == -1 } {
+ set ok [confirm_popup [mc "Commit %s is not\
+ included in branch %s -- really revert it?" \
+ [string range $rowmenuid 0 7] $mainhead]]
+ if {!$ok} return
+ }
+ nowbusy revert [mc "Reverting"]
+ update
+
+ if [catch {exec git revert --no-edit $rowmenuid} err] {
+ notbusy revert
+ if [regexp {files would be overwritten by merge:(\n(( |\t)+[^
\n]+\n)+)}\
+ $err match files] {
+ regsub {\n( |\t)+} $files "\n" files
+ error_popup [mc "Revert failed because of local changes to
\
+ the following files:%s Please commit, reset or stash \
+ your changes and try again." $files]
+ } elseif [regexp {error: could not revert} $err] {
+ if [confirm_popup [mc "Revert failed because of merge
conflict.\n\
+ Do you wish to run git citool to resolve it?"]] {
+ # Force citool to read MERGE_MSG
+ file delete [file join $gitdir "GITGUI_MSG"]
+ exec_citool {} $rowmenuid
+ }
+ } else { error_popup $err }
+ run updatecommits
+ return
+ }
+
+ set newhead [exec git rev-parse HEAD]
+ if { $newhead eq $oldhead } {
+ notbusy revert
+ error_popup [mc "No changes committed"]
+ return
+ }
+
+ addnewchild $newhead $oldhead
+
+ if [commitinview $oldhead $curview] {
+ # XXX this isn't right if we have a path limit...
+ insertrow $newhead $oldhead $curview
+ if {$mainhead ne {}} {
+ movehead $newhead $mainhead
+ movedhead $newhead $mainhead
+ }
+ set mainheadid $newhead
+ redrawtags $oldhead
+ redrawtags $newhead
+ selbyid $newhead
+ }
+
+ notbusy revert
+}
+
proc resethead {} {
global mainhead rowmenuid confirm_ok resettype NS
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gitk: Add menu item for reverting commits
2013-04-27 14:36 [PATCH] gitk: Add menu item for reverting commits Knut Franke
@ 2013-05-11 9:43 ` Paul Mackerras
0 siblings, 0 replies; 2+ messages in thread
From: Paul Mackerras @ 2013-05-11 9:43 UTC (permalink / raw
To: Knut Franke; +Cc: git
On Sat, Apr 27, 2013 at 04:36:13PM +0200, Knut Franke wrote:
> Sometimes it's helpful (at least psychologically) to have this feature
> easily accessible. Code borrows heavily from cherrypick.
>
> Signed-off-by: Knut Franke <Knut.Franke@gmx.de>
Thanks, applied, after undoing the linewrapping (done by your mailer?).
Paul.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-11 10:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-27 14:36 [PATCH] gitk: Add menu item for reverting commits Knut Franke
2013-05-11 9:43 ` Paul Mackerras
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).