{"thread":{"id":"21144","subject":"[PATCH] Teach 'rebase -i' the command \"reword\"","startedAt":"2009-10-07T06:13:23Z","lastAt":"2009-10-07T06:13:23Z","messageCount":1,"participants":["Björn Gustavsson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"124325","messageId":"4ACC3183.4050604@gmail.com","threadId":"21144","inReplyTo":null,"subject":"[PATCH] Teach 'rebase -i' the command \"reword\"","fromName":"Björn Gustavsson","fromEmail":"bgustavsson@gmail.com","sentAt":"2009-10-07T06:13:23Z","receivedAt":"2009-10-07T06:13:23Z","isPatch":true,"sender":{"key":"bgustavsson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/74840?v=4"},"body":"Make it easier to edit just the commit message for a commit\nusing 'git rebase -i' by introducing the \"reword\" command.\n\nSigned-off-by: Björn Gustavsson <bgustavsson@gmail.com>\n---\nRe-roll of my patch with improvements to the documentation\nand help text suggested by Johannes Sixt and Stephen Boyd.\n\n Documentation/git-rebase.txt  |    9 ++++++---\n git-rebase--interactive.sh    |    9 +++++++++\n t/lib-rebase.sh               |    6 +++---\n t/t3404-rebase-interactive.sh |   14 ++++++++++++++\n 4 files changed, 32 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex 0aefc34..33e0ef1 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -368,14 +368,17 @@ By replacing the command \"pick\" with the command \"edit\", you can tell\n the files and/or the commit message, amend the commit, and continue\n rebasing.\n \n+If you just want to edit the commit message for a commit, replace the\n+command \"pick\" with the command \"reword\".\n+\n If you want to fold two or more commits into one, replace the command\n \"pick\" with \"squash\" for the second and subsequent commit.  If the\n commits had different authors, it will attribute the squashed commit to\n the author of the first commit.\n \n-In both cases, or when a \"pick\" does not succeed (because of merge\n-errors), the loop will stop to let you fix things, and you can continue\n-the loop with `git rebase --continue`.\n+'git-rebase' will stop when \"pick\" has been replaced with \"edit\" or\n+when a command fails due to merge errors. When you are done editing\n+and/or resolving conflicts you can continue with `git rebase --continue`.\n \n For example, if you want to reorder the last 5 commits, such that what\n was HEAD~4 becomes the new HEAD. To achieve that, you would call\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 23ded48..a43ee22 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -340,6 +340,14 @@ do_next () {\n \t\tpick_one $sha1 ||\n \t\t\tdie_with_patch $sha1 \"Could not apply $sha1... $rest\"\n \t\t;;\n+\treword|r)\n+\t\tcomment_for_reflog reword\n+\n+\t\tmark_action_done\n+\t\tpick_one $sha1 ||\n+\t\t\tdie_with_patch $sha1 \"Could not apply $sha1... $rest\"\n+\t\toutput git commit --amend\n+\t\t;;\n \tedit|e)\n \t\tcomment_for_reflog edit\n \n@@ -752,6 +760,7 @@ first and then run 'git rebase --continue' again.\"\n #\n # Commands:\n #  p, pick = use commit\n+#  r, reword = use commit, but edit the commit message\n #  e, edit = use commit, but stop for amending\n #  s, squash = use commit, but meld into previous commit\n #\ndiff --git a/t/lib-rebase.sh b/t/lib-rebase.sh\nindex 260a231..62f452c 100644\n--- a/t/lib-rebase.sh\n+++ b/t/lib-rebase.sh\n@@ -9,8 +9,8 @@\n #\n #\t\"[<lineno1>] [<lineno2>]...\"\n #\n-#   If a line number is prefixed with \"squash\" or \"edit\", the respective line's\n-#   command will be replaced with the specified one.\n+#   If a line number is prefixed with \"squash\", \"edit\", or \"reword\", the\n+#   respective line's command will be replaced with the specified one.\n \n set_fake_editor () {\n \techo \"#!$SHELL_PATH\" >fake-editor.sh\n@@ -32,7 +32,7 @@ cat \"$1\".tmp\n action=pick\n for line in $FAKE_LINES; do\n \tcase $line in\n-\tsquash|edit)\n+\tsquash|edit|reword)\n \t\taction=\"$line\";;\n \t*)\n \t\techo sed -n \"${line}s/^pick/$action/p\"\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 4cae019..3a37793 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -470,4 +470,18 @@ test_expect_success 'avoid unnecessary reset' '\n \ttest 123456789 = $MTIME\n '\n \n+test_expect_success 'reword' '\n+\tgit checkout -b reword-branch master &&\n+\tFAKE_LINES=\"1 2 3 reword 4\" FAKE_COMMIT_MESSAGE=\"E changed\" git rebase -i A &&\n+\tgit show HEAD | grep \"E changed\" &&\n+\ttest $(git rev-parse master) != $(git rev-parse HEAD) &&\n+\ttest $(git rev-parse master^) = $(git rev-parse HEAD^) &&\n+\tFAKE_LINES=\"1 2 reword 3 4\" FAKE_COMMIT_MESSAGE=\"D changed\" git rebase -i A &&\n+\tgit show HEAD^ | grep \"D changed\" &&\n+\tFAKE_LINES=\"reword 1 2 3 4\" FAKE_COMMIT_MESSAGE=\"B changed\" git rebase -i A &&\n+\tgit show HEAD~3 | grep \"B changed\" &&\n+\tFAKE_LINES=\"1 reword 2 3 4\" FAKE_COMMIT_MESSAGE=\"C changed\" git rebase -i A &&\n+\tgit show HEAD~2 | grep \"C changed\"\n+'\n+\n test_done\n-- \n1.6.4.4\n"}]}