* [PATCH] Teach 'rebase -i' the command "reword"
@ 2009-10-05 16:16 Björn Gustavsson
2009-10-05 20:38 ` Johannes Schindelin
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Björn Gustavsson @ 2009-10-05 16:16 UTC (permalink / raw)
To: git; +Cc: gitster
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 <bgustavsson@gmail.com>
---
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(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 0aefc34..52af656 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -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
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 23ded48..30c2f62 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -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
#
diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
index 260a231..62f452c 100644
--- a/t/lib-rebase.sh
+++ b/t/lib-rebase.sh
@@ -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"
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 4cae019..3a37793 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -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
--
1.6.5.rc2.18.g020de
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] Teach 'rebase -i' the command "reword"
2009-10-05 16:16 Björn Gustavsson
@ 2009-10-05 20:38 ` Johannes Schindelin
2009-10-06 2:09 ` Sebastian Pipping
2009-10-06 2:34 ` Stephen Boyd
2 siblings, 0 replies; 9+ messages in thread
From: Johannes Schindelin @ 2009-10-05 20:38 UTC (permalink / raw)
To: Björn Gustavsson; +Cc: git, gitster
[-- Attachment #1: Type: TEXT/PLAIN, Size: 256 bytes --]
Hi,
On Mon, 5 Oct 2009, Björn Gustavsson wrote:
> 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 <bgustavsson@gmail.com>
ACK!
Thanks,
Dscho
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Teach 'rebase -i' the command "reword"
2009-10-05 16:16 Björn Gustavsson
2009-10-05 20:38 ` Johannes Schindelin
@ 2009-10-06 2:09 ` Sebastian Pipping
2009-10-06 2:34 ` Stephen Boyd
2 siblings, 0 replies; 9+ messages in thread
From: Sebastian Pipping @ 2009-10-06 2:09 UTC (permalink / raw)
To: git
Björn Gustavsson wrote:
> Make it easier to edit just the commit message for a commit
> using 'git rebase -i' by introducing the "reword" command.
Awesome!
Sebastian
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Teach 'rebase -i' the command "reword"
2009-10-05 16:16 Björn Gustavsson
2009-10-05 20:38 ` Johannes Schindelin
2009-10-06 2:09 ` Sebastian Pipping
@ 2009-10-06 2:34 ` Stephen Boyd
2009-10-06 7:03 ` Björn Gustavsson
2 siblings, 1 reply; 9+ messages in thread
From: Stephen Boyd @ 2009-10-06 2:34 UTC (permalink / raw)
To: Björn Gustavsson; +Cc: git, gitster
Björn Gustavsson wrote:
> diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
> index 0aefc34..52af656 100644
> --- a/Documentation/git-rebase.txt
> +++ b/Documentation/git-rebase.txt
> @@ -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, ...
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index 23ded48..30c2f62 100755
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
>
> @@ -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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Teach 'rebase -i' the command "reword"
2009-10-06 2:34 ` Stephen Boyd
@ 2009-10-06 7:03 ` Björn Gustavsson
2009-10-06 7:23 ` Johannes Sixt
2009-10-06 7:43 ` Stephen Boyd
0 siblings, 2 replies; 9+ messages in thread
From: Björn Gustavsson @ 2009-10-06 7:03 UTC (permalink / raw)
To: Stephen Boyd; +Cc: git, gitster
Stephen Boyd wrote:
> Björn Gustavsson wrote:
>> +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.
> 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".
>> +# 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(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 52af656..0ae8449 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -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
--
1.6.5.rc2.18.g020de
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] Teach 'rebase -i' the command "reword"
2009-10-06 7:03 ` Björn Gustavsson
@ 2009-10-06 7:23 ` Johannes Sixt
2009-10-06 7:43 ` Stephen Boyd
1 sibling, 0 replies; 9+ messages in thread
From: Johannes Sixt @ 2009-10-06 7:23 UTC (permalink / raw)
To: Björn Gustavsson; +Cc: Stephen Boyd, git, gitster
Björn Gustavsson schrieb:
> @@ -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`.
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Teach 'rebase -i' the command "reword"
2009-10-06 7:03 ` Björn Gustavsson
2009-10-06 7:23 ` Johannes Sixt
@ 2009-10-06 7:43 ` Stephen Boyd
2009-10-06 8:25 ` Björn Gustavsson
1 sibling, 1 reply; 9+ messages in thread
From: Stephen Boyd @ 2009-10-06 7:43 UTC (permalink / raw)
To: Björn Gustavsson; +Cc: git, gitster
Björn Gustavsson wrote:
>> 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`")
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
>
> -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`.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Teach 'rebase -i' the command "reword"
2009-10-06 7:43 ` Stephen Boyd
@ 2009-10-06 8:25 ` Björn Gustavsson
0 siblings, 0 replies; 9+ messages in thread
From: Björn Gustavsson @ 2009-10-06 8:25 UTC (permalink / raw)
To: Stephen Boyd; +Cc: git, gitster
Thanks to both of you!
Stephen Boyd wrote:
> 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.
> 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(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 52af656..33e0ef1 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -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
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 30c2f62..a43ee22 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -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
#
--
1.6.5.rc2.18.g020de
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH] Teach 'rebase -i' the command "reword"
@ 2009-10-07 6:13 Björn Gustavsson
0 siblings, 0 replies; 9+ messages in thread
From: Björn Gustavsson @ 2009-10-07 6:13 UTC (permalink / raw)
To: gitster; +Cc: git
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 <bgustavsson@gmail.com>
---
Re-roll of my patch with improvements to the documentation
and help text suggested by Johannes Sixt and Stephen Boyd.
Documentation/git-rebase.txt | 9 ++++++---
git-rebase--interactive.sh | 9 +++++++++
t/lib-rebase.sh | 6 +++---
t/t3404-rebase-interactive.sh | 14 ++++++++++++++
4 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 0aefc34..33e0ef1 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -368,14 +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, 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
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 23ded48..a43ee22 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -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 edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
#
diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
index 260a231..62f452c 100644
--- a/t/lib-rebase.sh
+++ b/t/lib-rebase.sh
@@ -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"
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 4cae019..3a37793 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -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
--
1.6.4.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-10-07 6:15 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-07 6:13 [PATCH] Teach 'rebase -i' the command "reword" Björn Gustavsson
-- strict thread matches above, loose matches on Subject: below --
2009-10-05 16:16 Björn Gustavsson
2009-10-05 20:38 ` Johannes Schindelin
2009-10-06 2:09 ` Sebastian Pipping
2009-10-06 2:34 ` Stephen Boyd
2009-10-06 7:03 ` Björn Gustavsson
2009-10-06 7:23 ` Johannes Sixt
2009-10-06 7:43 ` Stephen Boyd
2009-10-06 8:25 ` Björn Gustavsson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).