From: Michal Sojka <sojka@os.inf.tu-dresden.de>
To: git@vger.kernel.org
Cc: peff@peff.net, paulus@samba.org,
Michal Sojka <sojka@os.inf.tu-dresden.de>
Subject: [PATCH] gitk: Allow commit editing
Date: Fri, 19 Aug 2011 14:25:53 +0200 [thread overview]
Message-ID: <1313756753-26498-1-git-send-email-sojka@os.inf.tu-dresden.de> (raw)
In-Reply-To: <87obzlwpx0.fsf@steelpick.2x.cz>
I often use gitk to review patches before pushing them and would like
to have an easy way of fixing typos in commit messages. The current
approach if copying the commitid, switching to terminal, invoking git
rebase -i, editing the commit and switching back to gitk is a way too
complicated just for chaning a single letter.
This patch adds "Edit this commit" item to gitk's context menu which
invokes interactive rebase in a non-interactive way :-). git gui is
used to actually edit the commit.
The user is warned if the commit that is going to be edited is
contained in a remote branch.
Signed-off-by: Michal Sojka <sojka@os.inf.tu-dresden.de>
---
gitk-git/gitk | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 4cde0c4..83b3307 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2487,6 +2487,7 @@ proc makewindow {} {
makemenu $rowctxmenu {
{mc "Diff this -> selected" command {diffvssel 0}}
{mc "Diff selected -> this" command {diffvssel 1}}
+ {mc "Edit this commit" command edit_commit}
{mc "Make patch" command mkpatch}
{mc "Create tag" command mktag}
{mc "Write commit to file" command writecommit}
@@ -9102,6 +9103,36 @@ proc cherrypick {} {
notbusy cherrypick
}
+proc edit_commit {} {
+ global rowmenuid selectedline
+
+ if {[exec git branch -r --contains=$rowmenuid] ne {}} {
+ if {![confirm_popup [mc "The commit you are going to edit appears in at least one\
+ remote branch. It is a bad idea to change a branch that is\
+ possibly used by other people. See git-rebase(1) for details.\n\n\
+ Do you want to continue?"]]} return }
+
+ nowbusy edit [mc "Editing commit"]
+ if {[catch {exec sh -c "(GIT_EDITOR='sed -ie 1s/^pick/edit/' git rebase -p -i $rowmenuid^ && git gui citool --amend) 2>&1"} err]} {
+ notbusy edit
+ error_popup $err
+ exec git rebase --abort
+ return
+ }
+ set newcommit [exec git rev-parse HEAD]
+ if {[catch {exec sh -c "git rebase --continue 2>&1"} err]} {
+ notbusy edit
+ error_popup $err
+ exec git rebase --abort
+ return
+ }
+ updatecommits
+ # XXX How to select the edited commit? This doesn't work.
+ selbyid $newcommit
+ notbusy edit
+}
+
+
proc resethead {} {
global mainhead rowmenuid confirm_ok resettype NS
--
1.7.5.4
next prev parent reply other threads:[~2011-08-19 12:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-17 19:56 [PATCH RFC] gitk: Allow commit editing Michal Sojka
2011-08-18 22:33 ` Jeff King
2011-08-19 11:44 ` Chris Packham
2011-08-19 13:34 ` Michal Sojka
2011-08-19 14:40 ` Michal Sojka
2011-08-19 12:23 ` Michal Sojka
2011-08-19 12:25 ` Michal Sojka [this message]
2011-08-25 3:14 ` [PATCH] " Jeff King
2011-08-25 13:15 ` [PATCH v3] " Michal Sojka
2011-08-25 17:30 ` Jeff King
2011-08-27 12:31 ` [PATCH v4] " Michal Sojka
2011-09-07 20:10 ` Jeff King
2011-09-08 20:59 ` Paul Mackerras
2011-09-13 23:11 ` Michal Sojka
2011-08-25 3:07 ` [PATCH RFC] " Jeff King
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=1313756753-26498-1-git-send-email-sojka@os.inf.tu-dresden.de \
--to=sojka@os.inf.tu-dresden.de \
--cc=git@vger.kernel.org \
--cc=paulus@samba.org \
--cc=peff@peff.net \
/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).