# [PATCH 0/2] rebase -i: Some nice-to-have behaviors for "reword"

4 messages from 2011-07-25 to 2011-07-30. Participants: Andrew Wong, Sverre Rabbelier.
Thread: https://gitlist.dev/t/27961

## Andrew Wong, 2011-07-25 03:38

Subject: [PATCH 0/2] rebase -i: Some nice-to-have behaviors for "reword"
Message-ID: <1311565113-5022-1-git-send-email-andrew.kw.w@gmail.com>
URL: https://gitlist.dev/e/1311565113-5022-1-git-send-email-andrew.kw.w%40gmail.com

```
I've been using the "reword" command fairly often, and these are two small
modifications that I've always wished I could do during a "reword".  They're
more of a convenience than anything.  Hopefully they're not derailing the
original intent of "reword" too much...

1/2:
Often times when I need to reword commit, it's because the commit message was
unclear.  So when the "commit --amend" happens, I often found myself having to
do a "show HEAD" to inspect the diff to figure out what the commit was actually
doing.  This patch saves me this extra step.  Since this behavior isn't what
users might expect when they run "rebase -v", maybe I'm better off putting this
into a new flag, like "rebase --commit-verbose".  Any thoughts?

2/2:
Sometimes when I'm rewording a bunch of commits, I'd realize that I actually
want to edit the commit that I'm current rewording, like a quick fix or
something.  Or I might even want to abort the entire rebase operation
altogether.  This patch provides a way to gracefully to abort the "reword".  

Andrew Wong (2):
  rebase -i: run "commit --amend" with verbose if rebase was called
    with -v
  rebase -i: interrupt rebase when "commit --amend" failed

 git-rebase--interactive.sh |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

-- 
1.7.2.2

```

## Andrew Wong, 2011-07-25 03:38

Subject: [PATCH 1/2] rebase -i: run "commit --amend" with verbose if rebase was called with -v
Message-ID: <1311565113-5022-2-git-send-email-andrew.kw.w@gmail.com>
URL: https://gitlist.dev/e/1311565113-5022-2-git-send-email-andrew.kw.w%40gmail.com
In-Reply-To: <1311565113-5022-1-git-send-email-andrew.kw.w@gmail.com>

```
This provides a convenient way to inspect the diff while rewording
commits, which is really useful when rewording commit messages that are
unclear.

Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
---
 git-rebase--interactive.sh |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index c6ba7c1..df9f7e9 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -392,10 +392,12 @@ do_next () {
 	reword|r)
 		comment_for_reflog reword
 
+		test t = "$verbose" && commit_verbose_flag=--verbose
+
 		mark_action_done
 		pick_one $sha1 ||
 			die_with_patch $sha1 "Could not apply $sha1... $rest"
-		git commit --amend --no-post-rewrite
+		git commit $commit_verbose_flag --amend --no-post-rewrite
 		record_in_rewritten $sha1
 		;;
 	edit|e)
-- 
1.7.2.2

```

## Andrew Wong, 2011-07-25 03:38

Subject: [PATCH 2/2] rebase -i: interrupt rebase when "commit --amend" failed
Message-ID: <1311565113-5022-3-git-send-email-andrew.kw.w@gmail.com>
URL: https://gitlist.dev/e/1311565113-5022-3-git-send-email-andrew.kw.w%40gmail.com
In-Reply-To: <1311565113-5022-1-git-send-email-andrew.kw.w@gmail.com>

```
"commit --amend" could fail if the user empties the commit message.
Although this is not a real error, it seems to make more sense to
interrupt the rebasing, rather than ignoring the error and continue on
rebasing.  This gives users a way to gracefully interrupt a "reword" if
they decided they actually want to do an "edit", or even "rebase
--abort".

Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
---
 git-rebase--interactive.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index df9f7e9..7055ef4 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -397,7 +397,8 @@ do_next () {
 		mark_action_done
 		pick_one $sha1 ||
 			die_with_patch $sha1 "Could not apply $sha1... $rest"
-		git commit $commit_verbose_flag --amend --no-post-rewrite
+		git commit $commit_verbose_flag --amend --no-post-rewrite ||
+			die_with_patch $sha1 "Cannot amend commit after successfully picking $sha1... $rest"
 		record_in_rewritten $sha1
 		;;
 	edit|e)
-- 
1.7.2.2

```

## Sverre Rabbelier, 2011-07-30 11:52

Subject: Re: [PATCH 2/2] rebase -i: interrupt rebase when "commit --amend" failed
Message-ID: <CAGdFq_in9huck5kGo5N00jF53B2USsHy_CXb914jZrMZ4HpTUg@mail.gmail.com>
URL: https://gitlist.dev/e/CAGdFq_in9huck5kGo5N00jF53B2USsHy_CXb914jZrMZ4HpTUg%40mail.gmail.com
In-Reply-To: <1311565113-5022-3-git-send-email-andrew.kw.w@gmail.com>

```
Heya,

On Mon, Jul 25, 2011 at 05:38, Andrew Wong <andrew.kw.w@gmail.com> wrote:
> "commit --amend" could fail if the user empties the commit message.
> Although this is not a real error, it seems to make more sense to
> interrupt the rebasing, rather than ignoring the error and continue on
> rebasing.  This gives users a way to gracefully interrupt a "reword" if
> they decided they actually want to do an "edit", or even "rebase
> --abort".

Yesplease. I've had this where I marked an entire patch series for
reword only to discover on the first patch that I made a mistake, so I
ended up having to type ":wq" some twenty times. It would have been
much nicer if I could just have done ":cq" once and then 'git rebase
--abort'.

-- 
Cheers,

Sverre Rabbelier

```
