Re: [PATCH] additional help when editing during interactive rebase
Hi,
On Fri, 11 Jan 2008, Junio C Hamano wrote:
Show 13 quoted lines
> Do you mean you would instead suggest "git rebase --continue" in
> the insn, and make the workflow like this:
>
> $ git rebase -i ...
> Now do whatever you want and say "rebase --continue"
> $ edit foo.c
> $ git add foo.c
> $ git rebase --continue
>
> and have "rebase --continue" to continue with the modified
> contents recorded in the index, invoking "git commit --amend",
> but doing so only if the user hasn't run "git commit" with or
> without --amend yet?
> It feels like a better automation than what we currently have,
> but I somewhat worry how that would change the user experience
> for using 'edit' to split a commit into two or more.
If you want to split a commit into two or more, you will already have committed twice when you say "--continue", and all is fine.
However, if you do the first commit, and then only add the files for the second commit, the HEAD's commit name has changed! And so, rebase can pick up on that, and avoid the --amend.
IOW something like below. However, this patch does not yet make "rebase -i" call "commit --amend" automatically when both the index and HEAD are unchanged.
-- snipsnap -- [PATCH] rebase -i: only ever commit --amend when HEAD is untouched
When a commit is marked to edit, and the index is dirty when "rebase --continue" is called, that state will be committed with the "--amend" option.
However, this is wrong when the user wanted to split the commit.
Luckily, we can pick up on that, by recording the HEAD's name in the file "amend", and only --amend when no commit was made in the interim.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
git-rebase--interactive.sh | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
Show changes to git-rebase--interactive.sh +4 −2
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index acdcc54..4a8a980 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -257,7 +257,7 @@ do_next () {
pick_one $sha1 ||
die_with_patch $sha1 "Could not apply $sha1... $rest"
make_patch $sha1
- : > "$DOTEST"/amend
+ git rev-parse HEAD > "$DOTEST"/amend
warn
warn "You can amend the commit now, with"
warn
@@ -378,7 +378,9 @@ do
else
. "$DOTEST"/author-script ||
die "Cannot find the author identity"
- if test -f "$DOTEST"/amend
+ if test -f "$DOTEST"/amend &&
+ test $(git rev-parse HEAD) = \
+ $(cat "$DOTEST"/amend)
then
git reset --soft HEAD^ ||
die "Cannot rewind the HEAD"