Merge branch 'bg/rebase-reword'
* bg/rebase-reword: rebase -i: fix reword when using a terminal editor Teach 'rebase -i' the command "reword"
This commit is contained in:
commit
e79999b1a2
@ -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
|
the files and/or the commit message, amend the commit, and continue
|
||||||
rebasing.
|
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
|
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
|
"pick" with "squash" for the second and subsequent commit. If the
|
||||||
commits had different authors, it will attribute the squashed commit to
|
commits had different authors, it will attribute the squashed commit to
|
||||||
the author of the first commit.
|
the author of the first commit.
|
||||||
|
|
||||||
In both cases, or when a "pick" does not succeed (because of merge
|
'git-rebase' will stop when "pick" has been replaced with "edit" or
|
||||||
errors), the loop will stop to let you fix things, and you can continue
|
when a command fails due to merge errors. When you are done editing
|
||||||
the loop with `git rebase --continue`.
|
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
|
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
|
was HEAD~4 becomes the new HEAD. To achieve that, you would call
|
||||||
|
@ -340,6 +340,14 @@ do_next () {
|
|||||||
pick_one $sha1 ||
|
pick_one $sha1 ||
|
||||||
die_with_patch $sha1 "Could not apply $sha1... $rest"
|
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"
|
||||||
|
git commit --amend
|
||||||
|
;;
|
||||||
edit|e)
|
edit|e)
|
||||||
comment_for_reflog edit
|
comment_for_reflog edit
|
||||||
|
|
||||||
@ -752,6 +760,7 @@ first and then run 'git rebase --continue' again."
|
|||||||
#
|
#
|
||||||
# Commands:
|
# Commands:
|
||||||
# p, pick = use commit
|
# p, pick = use commit
|
||||||
|
# r, reword = use commit, but edit the commit message
|
||||||
# e, edit = use commit, but stop for amending
|
# e, edit = use commit, but stop for amending
|
||||||
# s, squash = use commit, but meld into previous commit
|
# s, squash = use commit, but meld into previous commit
|
||||||
#
|
#
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#
|
#
|
||||||
# "[<lineno1>] [<lineno2>]..."
|
# "[<lineno1>] [<lineno2>]..."
|
||||||
#
|
#
|
||||||
# If a line number is prefixed with "squash" or "edit", the respective line's
|
# If a line number is prefixed with "squash", "edit", or "reword", the
|
||||||
# command will be replaced with the specified one.
|
# respective line's command will be replaced with the specified one.
|
||||||
|
|
||||||
set_fake_editor () {
|
set_fake_editor () {
|
||||||
echo "#!$SHELL_PATH" >fake-editor.sh
|
echo "#!$SHELL_PATH" >fake-editor.sh
|
||||||
@ -32,7 +32,7 @@ cat "$1".tmp
|
|||||||
action=pick
|
action=pick
|
||||||
for line in $FAKE_LINES; do
|
for line in $FAKE_LINES; do
|
||||||
case $line in
|
case $line in
|
||||||
squash|edit)
|
squash|edit|reword)
|
||||||
action="$line";;
|
action="$line";;
|
||||||
*)
|
*)
|
||||||
echo sed -n "${line}s/^pick/$action/p"
|
echo sed -n "${line}s/^pick/$action/p"
|
||||||
|
@ -470,4 +470,18 @@ test_expect_success 'avoid unnecessary reset' '
|
|||||||
test 123456789 = $MTIME
|
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
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user