Teach 'rebase -i' the command "reword"
PATCH 1/1 Teach 'rebase -i' the command "reword"
Make it easier to edit just the commit message for a commit using 'git rebase -i' by introducing the "reword" command.
---
Here is the re-roll of my previous patch.
The only difference is that "amend" (which would be mis-leading) has been replaced with "reword".
Documentation/git-rebase.txt | 3 +++ git-rebase--interactive.sh | 9 +++++++++ t/lib-rebase.sh | 6 +++--- t/t3404-rebase-interactive.sh | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-)
Documentation/git-rebase.txt +3 -0
@@ -368,6 +368,9 @@ By replacing the command "pick" with the command "edit", you can tell the files and/or the commit message, amend the commit, and continue rebasing. +If you just want to edit the commit message for a commit, you can replace +the command "pick" with the command "reword". + If you want to fold two or more commits into one, replace the command "pick" with "squash" for the second and subsequent commit. If the commits had different authors, it will attribute the squashed commit to
git-rebase--interactive.sh +9 -0
@@ -340,6 +340,14 @@ do_next () { pick_one $sha1 || die_with_patch $sha1 "Could not apply $sha1... $rest" ;; + reword|r) + comment_for_reflog reword + + mark_action_done + pick_one $sha1 || + die_with_patch $sha1 "Could not apply $sha1... $rest" + output git commit --amend + ;; edit|e) comment_for_reflog edit
@@ -752,6 +760,7 @@ first and then run 'git rebase --continue' again." # # Commands: # p, pick = use commit +# r, reword = use commit, but allow editing of the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit #
t/lib-rebase.sh +3 -3
@@ -9,8 +9,8 @@ # # "[<lineno1>] [<lineno2>]..." # -# If a line number is prefixed with "squash" or "edit", the respective line's -# command will be replaced with the specified one. +# If a line number is prefixed with "squash", "edit", or "reword", the +# respective line's command will be replaced with the specified one. set_fake_editor () { echo "#!$SHELL_PATH" >fake-editor.sh
@@ -32,7 +32,7 @@ cat "$1".tmp action=pick for line in $FAKE_LINES; do case $line in - squash|edit) + squash|edit|reword) action="$line";; *) echo sed -n "${line}s/^pick/$action/p"
t/t3404-rebase-interactive.sh +14 -0
@@ -470,4 +470,18 @@ test_expect_success 'avoid unnecessary reset' ' test 123456789 = $MTIME ' +test_expect_success 'reword' ' + git checkout -b reword-branch master && + FAKE_LINES="1 2 3 reword 4" FAKE_COMMIT_MESSAGE="E changed" git rebase -i A && + git show HEAD | grep "E changed" && + test $(git rev-parse master) != $(git rev-parse HEAD) && + test $(git rev-parse master^) = $(git rev-parse HEAD^) && + FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" git rebase -i A && + git show HEAD^ | grep "D changed" && + FAKE_LINES="reword 1 2 3 4" FAKE_COMMIT_MESSAGE="B changed" git rebase -i A && + git show HEAD~3 | grep "B changed" && + FAKE_LINES="1 reword 2 3 4" FAKE_COMMIT_MESSAGE="C changed" git rebase -i A && + git show HEAD~2 | grep "C changed" +' + test_done
Signature · 1 line
1.6.5.rc2.18.g020de
Quoted 2 lines · Björn Gustavsson
Make it easier to edit just the commit message for a commit using 'git rebase -i' by introducing the "reword" command.
Awesome!
Sebastian
Documentation/git-rebase.txt By replacing the command "pick" with the command "edit", you can tell · line 373
Quoted 11 lines · Björn Gustavsson
Documentation/git-rebase.txt +3
-0@@ -368,6 +368,9 @@ By replacing the command "pick" with the command "edit", you can tell the files and/or the commit message, amend the commit, and continue rebasing. +If you just want to edit the commit message for a commit, you can replace +the command "pick" with the command "reword". +
Maybe use the imperative here. So instead of "you can replace" just say "replace".
Also, two paragraphs down we say "In both cases ..." but now there are three cases right? Maybe we should say
When a "pick" doesn't succeed (because of merge errors) or when "pick" has been replaced with another command, ...
git-rebase--interactive.sh first and then run 'git rebase --continue' again." · line 763
Quoted 10 lines
git-rebase--interactive.sh +1
-0@@ -752,6 +760,7 @@ first and then run 'git rebase --continue' again." # # Commands: # p, pick = use commit +# r, reword = use commit, but allow editing of the commit message
How about this?
use commit, but stop to edit (or reword?) the commit message
Quoted 6 lines · Stephen Boyd
Review
Quoted 3 lines · Björn Gustavsson
(quoted diff) +3
-0+If you just want to edit the commit message for a commit, you can replace +the command "pick" with the command "reword". +Maybe use the imperative here. So instead of "you can replace" just say "replace".
Yes, that's better.
Quoted 2 lines
Also, two paragraphs down we say "In both cases ..." but now there are three cases right? Maybe we should say
Well spotted. I didn't think about that.
But actually, I think that in "In both cases..." was wrong to begin with, as there only is one case, namely if the command is "edit".
Quoted 4 lines
Quoted 1 line
+# r, reword = use commit, but allow editing of the commit message
How about this?
use commit, but stop to edit (or reword?) the commit message
No, I think that would be misleading, as "stop" means exit to the shell so that you can run other git commands. (The documentation says:
"...the loop will stop to let you fix things, and you can continue -the loop with git rebase --continue")
Here comes a patch that improves the documentation. It should be applied on top of my previous patch and then combined with it.
If you want me to send a new, combined patch, I will of course do that.
-- >8 --
Subject: [PATCH] Minor polishing of documentation
To be combined with my previous patch.
--- Documentation/git-rebase.txt | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
Documentation/git-rebase.txt +5 -5
@@ -368,17 +368,17 @@ By replacing the command "pick" with the command "edit", you can tell the files and/or the commit message, amend the commit, and continue rebasing. -If you just want to edit the commit message for a commit, you can replace -the command "pick" with the command "reword". +If you just want to edit the commit message for a commit, replace the +command "pick" with the command "reword". If you want to fold two or more commits into one, replace the command "pick" with "squash" for the second and subsequent commit. If the commits had different authors, it will attribute the squashed commit to the author of the first commit. -In both cases, or when a "pick" does not succeed (because of merge -errors), the loop will stop to let you fix things, and you can continue -the loop with `git rebase --continue`. +When "pick" has been replaced with "edit" or when a "pick" does not +succeed (because of merge errors), the loop will stop to let you fix +things, and you can continue the loop with `git rebase --continue`. For example, if you want to reorder the last 5 commits, such that what was HEAD~4 becomes the new HEAD. To achieve that, you would call
Signature · 1 line
1.6.5.rc2.18.g020de
Quoted 10 lines · Björn Gustavsson
Documentation/git-rebase.txt +2
-2@@ -368,17 +368,17 @@ By replacing the command "pick" with the command "edit", you can tell the files and/or the commit message, amend the commit, and continue rebasing. -If you just want to edit the commit message for a commit, you can replace -the command "pick" with the command "reword". +If you just want to edit the commit message for a commit, replace the +command "pick" with the command "reword". If you want to fold two or more commits into one, replace the command
Documentation/git-rebase.txt By replacing the command "pick" with the command "edit", you can tell · line 381
Quoted 10 lines
Documentation/git-rebase.txt +3
-3"pick" with "squash" for the second and subsequent commit. If the commits had different authors, it will attribute the squashed commit to the author of the first commit. -In both cases, or when a "pick" does not succeed (because of merge -errors), the loop will stop to let you fix things, and you can continue -the loop with `git rebase --continue`. +When "pick" has been replaced with "edit" or when a "pick" does not +succeed (because of merge errors), the loop will stop to let you fix +things, and you can continue the loop with `git rebase --continue`.
Since "reword" is "pick" + editor, it can fail due to conflicts as well. Perhaps:
'git-rebase' will stop after an edit command or when a command failed (due to merge errors). When you are done with your edits or with resolving merge conflicts, continue with git rebase --continue.
(I'm unsure about the mark-up.)
-- Hannes
Quoted 8 lines · Björn Gustavsson
Quoted 3 lines
How about this?
use commit, but stop to edit (or reword?) the commit message
No, I think that would be misleading, as "stop" means exit to the shell so that you can run other git commands. (The documentation says:
"...the loop will stop to let you fix things, and you can continue -the loop withgit rebase --continue")
Ok, "stop" being misleading makes sense but I still think the English is wrong. Particularly the part about allow editing. Maybe just remove "stop", so
use commit, but edit the commit message
Documentation/git-rebase.txt By replacing the command "pick" with the command "edit", you can tell · line 381
Quoted 8 lines
Documentation/git-rebase.txt +3
-3-In both cases, or when a "pick" does not succeed (because of merge -errors), the loop will stop to let you fix things, and you can continue -the loop with `git rebase --continue`. +When "pick" has been replaced with "edit" or when a "pick" does not +succeed (because of merge errors), the loop will stop to let you fix +things, and you can continue the loop with `git rebase --continue`.
Patch looks good, but if you decide to resend due to my comment above maybe you could think about replacing the word "loop" with "rebase". We should probably just say "the rebase will stop" and "you can continue with `git rebase ..."
Or we could combine yours, mine, and Hannes' versions.
The rebase will stop when "pick" has been replaced with "edit" or when a command fails due to merge errors. When you are done editing and/or resolving conflicts you can continue with git rebase --continue.
Thanks to both of you!
Quoted 7 lines · Stephen Boyd
Björn Gustavsson wrote:
Ok, "stop" being misleading makes sense but I still think the English is wrong. Particularly the part about allow editing. Maybe just remove "stop", so
use commit, but edit the commit message
OK.
Quoted 4 lines
Or we could combine yours, mine, and Hannes' versions.
The rebase will stop when "pick" has been replaced with "edit" or when a command fails due to merge errors. When you are done editing and/or resolving conflicts you can continue with
git rebase --continue.
I changed "The rebase" to "'git-rebase' to be consistent with the rest of the documentation.
Here is a new patch, to be applied on top of my original patch.
To avoid confusion, I'll better re-roll the patch. But I'll wait a day or so, in case there will be more corrections or suggestions for improvements.
-- >8 --
Subject: [PATCH] Minor polishing of documentation, second attempt
To be applied on top of and combined with my original patch.
--- Documentation/git-rebase.txt | 10 +++++----- git-rebase--interactive.sh | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
Documentation/git-rebase.txt +5 -5
@@ -368,17 +368,17 @@ By replacing the command "pick" with the command "edit", you can tell the files and/or the commit message, amend the commit, and continue rebasing. -If you just want to edit the commit message for a commit, you can replace -the command "pick" with the command "reword". +If you just want to edit the commit message for a commit, replace the +command "pick" with the command "reword". If you want to fold two or more commits into one, replace the command "pick" with "squash" for the second and subsequent commit. If the commits had different authors, it will attribute the squashed commit to the author of the first commit. -In both cases, or when a "pick" does not succeed (because of merge -errors), the loop will stop to let you fix things, and you can continue -the loop with `git rebase --continue`. +'git-rebase' will stop when "pick" has been replaced with "edit" or +when a command fails due to merge errors. When you are done editing +and/or resolving conflicts you can continue with `git rebase --continue`. For example, if you want to reorder the last 5 commits, such that what was HEAD~4 becomes the new HEAD. To achieve that, you would call
git-rebase--interactive.sh +1 -1
@@ -760,7 +760,7 @@ first and then run 'git rebase --continue' again." # # Commands: # p, pick = use commit -# r, reword = use commit, but allow editing of the commit message +# r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit #
Signature · 1 line
1.6.5.rc2.18.g020de
Hi,
Quoted 4 lines · Björn Gustavsson
Make it easier to edit just the commit message for a commit using 'git rebase -i' by introducing the "reword" command.
Signed-off-by Björn Gustavsson <[email protected]>
ACK!
Thanks,
Dscho