git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH RFC] gitk: Allow commit editing

From
Michal Sojka <sojka@os.inf.tu-dresden.de>
Date
Aug 17, 2011, 19:56 UTC
Message-ID
<1313610971-1741-1-git-send-email-sojka@os.inf.tu-dresden.de>

Hi, this is a proof of concept patch that allows editing of commits from gitk. I often review patches before pushing in gitk and if I would like to have an easy way of fixing typos in commit messages etc.

So the patch adds "Edit this commit" item to gitk's context menu and the actual editing is done by non-interactively invoking interactive rebase :-) and git gui.

There is almost no error checking etc., but before learning TCL and coding this properly, I'd like to get some feedback.

-Michal
Signed-off-by: Michal Sojka <sojka@os.inf.tu-dresden.de>
---
 gitk-git/gitk |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 4cde0c4..121b926 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2497,6 +2497,7 @@ proc makewindow {} {
 	{mc "Return to mark" command gotomark}
 	{mc "Find descendant of this and mark" command find_common_desc}
 	{mc "Compare with marked commit" command compare_commits}
+	{mc "Edit this commit" command edit_commit}
     }
     $rowctxmenu configure -tearoff 0
 
@@ -9102,6 +9103,21 @@ proc cherrypick {} {
     notbusy cherrypick
 }
 
+proc edit_commit {} {
+    global rowmenuid
+
+    nowbusy edit [mc "Editing commit"]
+    if {[catch {exec sh -c "(GIT_EDITOR='sed -ie 1s/^pick/edit/' git rebase -i $rowmenuid^ && git gui citool --amend && git rebase --continue) 2>&1"} err]} {
+	notbusy edit
+	error_popup $err
+	exec git rebase --abort
+	return
+    }
+    notbusy edit
+    run updatecommits
+}
+
+
 proc resethead {} {
     global mainhead rowmenuid confirm_ok resettype NS
 
-- 
1.7.5.4
Next: Jeff King
Message 1 of 5 in “gitk: Allow commit editing”
  1. gitk: Allow commit editingMichal Sojka, Aug 17, 2011
  2. Jeff KingAug 18, 2011
  3. Chris PackhamAug 19, 2011
  4. Michal SojkaAug 19, 2011
  5. Michal SojkaAug 19, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.