On Fri, 19 Aug 2011, Chris Packham wrote: > One thing I've thought about (but don't know enough TCL to begin to > implement) is a graphical rebase front end. I often use git gui to make > tweaks to the last commit (message and content) so why not extend that > to a rebase operation. I think that might address some of Peffs concerns > because the user would be invoking something specifically intended for > rebasing and accepts all the caveats that go along with that. Hi Chris, the version of the patch below supports not only editing of commit message but also of the commit itself. There is an easy way to split commits and to remove lines/hunks form the commits. Additionally, with the help of editor and "Rescan" button in git gui, you can add things to the commits. I think that in the similar way as in this patch, it would be easy to allow gitk doing fixup and squash operations offered by rebase. -Michal --8<---------------cut here---------------start------------->8--- >From 1d0f0a778afbaeb928cdecb3f18065757b3aa2fa Mon Sep 17 00:00:00 2001 From: Michal Sojka <sojka@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 19 Aug 2011 15:21:47 +0200 Subject: [PATCH] gitk: Allow commit editing 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 with 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 changing a single letter in commit message or remove a debug printf(). 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. Splitting of commits (as described in git-rebase(1)) is also supported. 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@xxxxxxxxxxxxxxxxxxxx> --- gitk-git/gitk | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-) diff --git a/gitk-git/gitk b/gitk-git/gitk index 4cde0c4..432ca9b 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,45 @@ 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 is contained 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] + while {[catch {exec sh -c "git diff-index --quiet --cached HEAD && git diff-files --quiet"} err]} { + if {[confirm_popup [mc "There are uncommited changes in the working tree or in the index.\ + Do you want to create a new commit (OK) or throw them away (Cancel)?"]]} { + catch {exec git gui citool} err; + # In case of error (i.e. the user did not commit anything), we just ask him again + } else { + exec git reset --hard + } + } + 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 --8<---------------cut here---------------end--------------->8--- -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html