2010-07-28 08:20:16 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='git rebase --continue tests'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
. "$TEST_DIRECTORY"/lib-rebase.sh
|
|
|
|
|
|
|
|
set_fake_editor
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
test_commit "commit-new-file-F1" F1 1 &&
|
|
|
|
test_commit "commit-new-file-F2" F2 2 &&
|
|
|
|
|
|
|
|
git checkout -b topic HEAD^ &&
|
|
|
|
test_commit "commit-new-file-F2-on-topic-branch" F2 22 &&
|
|
|
|
|
|
|
|
git checkout master
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'interactive rebase --continue works with touched file' '
|
|
|
|
rm -fr .git/rebase-* &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout master &&
|
|
|
|
|
|
|
|
FAKE_LINES="edit 1" git rebase -i HEAD^ &&
|
2018-03-24 07:44:31 +00:00
|
|
|
test-tool chmtime =-60 F1 &&
|
2010-07-28 08:20:16 +00:00
|
|
|
git rebase --continue
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'non-interactive rebase --continue works with touched file' '
|
|
|
|
rm -fr .git/rebase-* &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout master &&
|
|
|
|
|
|
|
|
test_must_fail git rebase --onto master master topic &&
|
|
|
|
echo "Resolved" >F2 &&
|
|
|
|
git add F2 &&
|
2018-03-24 07:44:31 +00:00
|
|
|
test-tool chmtime =-60 F1 &&
|
2010-07-28 08:20:16 +00:00
|
|
|
git rebase --continue
|
|
|
|
'
|
|
|
|
|
2011-02-06 18:43:36 +00:00
|
|
|
test_expect_success 'rebase --continue can not be used with other options' '
|
|
|
|
test_must_fail git rebase -v --continue &&
|
|
|
|
test_must_fail git rebase --continue -v
|
|
|
|
'
|
|
|
|
|
2011-02-06 18:43:55 +00:00
|
|
|
test_expect_success 'rebase --continue remembers merge strategy and options' '
|
|
|
|
rm -fr .git/rebase-* &&
|
|
|
|
git reset --hard commit-new-file-F2-on-topic-branch &&
|
|
|
|
test_commit "commit-new-file-F3-on-topic-branch" F3 32 &&
|
|
|
|
test_when_finished "rm -fr test-bin funny.was.run" &&
|
|
|
|
mkdir test-bin &&
|
2011-12-08 13:10:17 +00:00
|
|
|
cat >test-bin/git-merge-funny <<-EOF &&
|
2011-02-06 18:43:55 +00:00
|
|
|
#!$SHELL_PATH
|
|
|
|
case "\$1" in --opt) ;; *) exit 2 ;; esac
|
|
|
|
shift &&
|
|
|
|
>funny.was.run &&
|
|
|
|
exec git merge-recursive "\$@"
|
|
|
|
EOF
|
|
|
|
chmod +x test-bin/git-merge-funny &&
|
|
|
|
(
|
2018-07-02 00:23:58 +00:00
|
|
|
PATH=./test-bin:$PATH &&
|
2011-02-06 18:43:55 +00:00
|
|
|
test_must_fail git rebase -s funny -Xopt master topic
|
|
|
|
) &&
|
|
|
|
test -f funny.was.run &&
|
|
|
|
rm funny.was.run &&
|
|
|
|
echo "Resolved" >F2 &&
|
|
|
|
git add F2 &&
|
|
|
|
(
|
2018-07-02 00:23:58 +00:00
|
|
|
PATH=./test-bin:$PATH &&
|
2011-02-06 18:43:55 +00:00
|
|
|
git rebase --continue
|
|
|
|
) &&
|
|
|
|
test -f funny.was.run
|
|
|
|
'
|
2018-01-04 21:31:52 +00:00
|
|
|
|
2018-06-27 15:48:04 +00:00
|
|
|
test_expect_success 'rebase -i --continue handles merge strategy and options' '
|
2018-06-27 15:48:03 +00:00
|
|
|
rm -fr .git/rebase-* &&
|
|
|
|
git reset --hard commit-new-file-F2-on-topic-branch &&
|
|
|
|
test_commit "commit-new-file-F3-on-topic-branch-for-dash-i" F3 32 &&
|
|
|
|
test_when_finished "rm -fr test-bin funny.was.run funny.args" &&
|
|
|
|
mkdir test-bin &&
|
|
|
|
cat >test-bin/git-merge-funny <<-EOF &&
|
|
|
|
#!$SHELL_PATH
|
|
|
|
echo "\$@" >>funny.args
|
|
|
|
case "\$1" in --opt) ;; *) exit 2 ;; esac
|
|
|
|
case "\$2" in --foo) ;; *) exit 2 ;; esac
|
|
|
|
case "\$4" in --) ;; *) exit 2 ;; esac
|
|
|
|
shift 2 &&
|
|
|
|
>funny.was.run &&
|
|
|
|
exec git merge-recursive "\$@"
|
|
|
|
EOF
|
|
|
|
chmod +x test-bin/git-merge-funny &&
|
|
|
|
(
|
|
|
|
PATH=./test-bin:$PATH &&
|
|
|
|
test_must_fail git rebase -i -s funny -Xopt -Xfoo master topic
|
|
|
|
) &&
|
|
|
|
test -f funny.was.run &&
|
|
|
|
rm funny.was.run &&
|
|
|
|
echo "Resolved" >F2 &&
|
|
|
|
git add F2 &&
|
|
|
|
(
|
|
|
|
PATH=./test-bin:$PATH &&
|
|
|
|
git rebase --continue
|
|
|
|
) &&
|
|
|
|
test -f funny.was.run
|
|
|
|
'
|
|
|
|
|
2018-10-31 20:02:02 +00:00
|
|
|
test_expect_success REBASE_P 'rebase passes merge strategy options correctly' '
|
2018-01-04 21:31:52 +00:00
|
|
|
rm -fr .git/rebase-* &&
|
|
|
|
git reset --hard commit-new-file-F3-on-topic-branch &&
|
|
|
|
test_commit theirs-to-merge &&
|
|
|
|
git reset --hard HEAD^ &&
|
|
|
|
test_commit some-commit &&
|
|
|
|
test_tick &&
|
|
|
|
git merge --no-ff theirs-to-merge &&
|
|
|
|
FAKE_LINES="1 edit 2 3" git rebase -i -f -p -m \
|
|
|
|
-s recursive --strategy-option=theirs HEAD~2 &&
|
|
|
|
test_commit force-change &&
|
|
|
|
git rebase --continue
|
|
|
|
'
|
2018-04-27 20:48:16 +00:00
|
|
|
|
rebase --skip: clean up commit message after a failed fixup/squash
During a series of fixup/squash commands, the interactive rebase builds
up a commit message with comments. This will be presented to the user in
the editor if at least one of those commands was a `squash`.
In any case, the commit message will be cleaned up eventually, removing
all those intermediate comments, in the final step of such a
fixup/squash chain.
However, if the last fixup/squash command in such a chain fails with
merge conflicts, and if the user then decides to skip it (or resolve it
to a clean worktree and then continue the rebase), the current code
fails to clean up the commit message.
This commit fixes that behavior.
The fix is quite a bit more involved than meets the eye because it is
not only about the question whether we are `git rebase --skip`ing a
fixup or squash. It is also about removing the skipped fixup/squash's
commit message from the accumulated commit message. And it is also about
the question whether we should let the user edit the final commit
message or not ("Was there a squash in the chain *that was not
skipped*?").
For example, in this case we will want to fix the commit message, but
not open it in an editor:
pick <- succeeds
fixup <- succeeds
squash <- fails, will be skipped
This is where the newly-introduced `current-fixups` file comes in real
handy. A quick look and we can determine whether there was a non-skipped
squash. We only need to make sure to keep it up to date with respect to
skipped fixup/squash commands. As a bonus, we can even avoid committing
unnecessarily, e.g. when there was only one fixup, and it failed, and
was skipped.
To fix only the bug where the final commit message was not cleaned up
properly, but without fixing the rest, would have been more complicated
than fixing it all in one go, hence this commit lumps together more than
a single concern.
For the same reason, this commit also adds a bit more to the existing
test case for the regression we just fixed.
The diff is best viewed with --color-moved.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-04-27 20:48:30 +00:00
|
|
|
test_expect_success '--skip after failed fixup cleans commit message' '
|
2018-04-27 20:48:16 +00:00
|
|
|
test_when_finished "test_might_fail git rebase --abort" &&
|
|
|
|
git checkout -b with-conflicting-fixup &&
|
|
|
|
test_commit wants-fixup &&
|
|
|
|
test_commit "fixup! wants-fixup" wants-fixup.t 1 wants-fixup-1 &&
|
|
|
|
test_commit "fixup! wants-fixup" wants-fixup.t 2 wants-fixup-2 &&
|
|
|
|
test_commit "fixup! wants-fixup" wants-fixup.t 3 wants-fixup-3 &&
|
rebase --skip: clean up commit message after a failed fixup/squash
During a series of fixup/squash commands, the interactive rebase builds
up a commit message with comments. This will be presented to the user in
the editor if at least one of those commands was a `squash`.
In any case, the commit message will be cleaned up eventually, removing
all those intermediate comments, in the final step of such a
fixup/squash chain.
However, if the last fixup/squash command in such a chain fails with
merge conflicts, and if the user then decides to skip it (or resolve it
to a clean worktree and then continue the rebase), the current code
fails to clean up the commit message.
This commit fixes that behavior.
The fix is quite a bit more involved than meets the eye because it is
not only about the question whether we are `git rebase --skip`ing a
fixup or squash. It is also about removing the skipped fixup/squash's
commit message from the accumulated commit message. And it is also about
the question whether we should let the user edit the final commit
message or not ("Was there a squash in the chain *that was not
skipped*?").
For example, in this case we will want to fix the commit message, but
not open it in an editor:
pick <- succeeds
fixup <- succeeds
squash <- fails, will be skipped
This is where the newly-introduced `current-fixups` file comes in real
handy. A quick look and we can determine whether there was a non-skipped
squash. We only need to make sure to keep it up to date with respect to
skipped fixup/squash commands. As a bonus, we can even avoid committing
unnecessarily, e.g. when there was only one fixup, and it failed, and
was skipped.
To fix only the bug where the final commit message was not cleaned up
properly, but without fixing the rest, would have been more complicated
than fixing it all in one go, hence this commit lumps together more than
a single concern.
For the same reason, this commit also adds a bit more to the existing
test case for the regression we just fixed.
The diff is best viewed with --color-moved.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-04-27 20:48:30 +00:00
|
|
|
test_must_fail env FAKE_LINES="1 fixup 2 squash 4" \
|
2018-04-27 20:48:16 +00:00
|
|
|
git rebase -i HEAD~4 &&
|
|
|
|
|
|
|
|
: now there is a conflict, and comments in the commit message &&
|
|
|
|
git show HEAD >out &&
|
|
|
|
grep "fixup! wants-fixup" out &&
|
|
|
|
|
|
|
|
: skip and continue &&
|
rebase --skip: clean up commit message after a failed fixup/squash
During a series of fixup/squash commands, the interactive rebase builds
up a commit message with comments. This will be presented to the user in
the editor if at least one of those commands was a `squash`.
In any case, the commit message will be cleaned up eventually, removing
all those intermediate comments, in the final step of such a
fixup/squash chain.
However, if the last fixup/squash command in such a chain fails with
merge conflicts, and if the user then decides to skip it (or resolve it
to a clean worktree and then continue the rebase), the current code
fails to clean up the commit message.
This commit fixes that behavior.
The fix is quite a bit more involved than meets the eye because it is
not only about the question whether we are `git rebase --skip`ing a
fixup or squash. It is also about removing the skipped fixup/squash's
commit message from the accumulated commit message. And it is also about
the question whether we should let the user edit the final commit
message or not ("Was there a squash in the chain *that was not
skipped*?").
For example, in this case we will want to fix the commit message, but
not open it in an editor:
pick <- succeeds
fixup <- succeeds
squash <- fails, will be skipped
This is where the newly-introduced `current-fixups` file comes in real
handy. A quick look and we can determine whether there was a non-skipped
squash. We only need to make sure to keep it up to date with respect to
skipped fixup/squash commands. As a bonus, we can even avoid committing
unnecessarily, e.g. when there was only one fixup, and it failed, and
was skipped.
To fix only the bug where the final commit message was not cleaned up
properly, but without fixing the rest, would have been more complicated
than fixing it all in one go, hence this commit lumps together more than
a single concern.
For the same reason, this commit also adds a bit more to the existing
test case for the regression we just fixed.
The diff is best viewed with --color-moved.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-04-27 20:48:30 +00:00
|
|
|
echo "cp \"\$1\" .git/copy.txt" | write_script copy-editor.sh &&
|
|
|
|
(test_set_editor "$PWD/copy-editor.sh" && git rebase --skip) &&
|
|
|
|
|
|
|
|
: the user should not have had to edit the commit message &&
|
|
|
|
test_path_is_missing .git/copy.txt &&
|
2018-04-27 20:48:16 +00:00
|
|
|
|
|
|
|
: now the comments in the commit message should have been cleaned up &&
|
|
|
|
git show HEAD >out &&
|
rebase --skip: clean up commit message after a failed fixup/squash
During a series of fixup/squash commands, the interactive rebase builds
up a commit message with comments. This will be presented to the user in
the editor if at least one of those commands was a `squash`.
In any case, the commit message will be cleaned up eventually, removing
all those intermediate comments, in the final step of such a
fixup/squash chain.
However, if the last fixup/squash command in such a chain fails with
merge conflicts, and if the user then decides to skip it (or resolve it
to a clean worktree and then continue the rebase), the current code
fails to clean up the commit message.
This commit fixes that behavior.
The fix is quite a bit more involved than meets the eye because it is
not only about the question whether we are `git rebase --skip`ing a
fixup or squash. It is also about removing the skipped fixup/squash's
commit message from the accumulated commit message. And it is also about
the question whether we should let the user edit the final commit
message or not ("Was there a squash in the chain *that was not
skipped*?").
For example, in this case we will want to fix the commit message, but
not open it in an editor:
pick <- succeeds
fixup <- succeeds
squash <- fails, will be skipped
This is where the newly-introduced `current-fixups` file comes in real
handy. A quick look and we can determine whether there was a non-skipped
squash. We only need to make sure to keep it up to date with respect to
skipped fixup/squash commands. As a bonus, we can even avoid committing
unnecessarily, e.g. when there was only one fixup, and it failed, and
was skipped.
To fix only the bug where the final commit message was not cleaned up
properly, but without fixing the rest, would have been more complicated
than fixing it all in one go, hence this commit lumps together more than
a single concern.
For the same reason, this commit also adds a bit more to the existing
test case for the regression we just fixed.
The diff is best viewed with --color-moved.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-04-27 20:48:30 +00:00
|
|
|
! grep "fixup! wants-fixup" out &&
|
|
|
|
|
|
|
|
: now, let us ensure that "squash" is handled correctly &&
|
|
|
|
git reset --hard wants-fixup-3 &&
|
|
|
|
test_must_fail env FAKE_LINES="1 squash 4 squash 2 squash 4" \
|
|
|
|
git rebase -i HEAD~4 &&
|
|
|
|
|
|
|
|
: the first squash failed, but there are two more in the chain &&
|
|
|
|
(test_set_editor "$PWD/copy-editor.sh" &&
|
|
|
|
test_must_fail git rebase --skip) &&
|
|
|
|
|
|
|
|
: not the final squash, no need to edit the commit message &&
|
|
|
|
test_path_is_missing .git/copy.txt &&
|
|
|
|
|
|
|
|
: The first squash was skipped, therefore: &&
|
|
|
|
git show HEAD >out &&
|
|
|
|
test_i18ngrep "# This is a combination of 2 commits" out &&
|
2018-08-15 09:41:25 +00:00
|
|
|
test_i18ngrep "# This is the commit message #2:" out &&
|
rebase --skip: clean up commit message after a failed fixup/squash
During a series of fixup/squash commands, the interactive rebase builds
up a commit message with comments. This will be presented to the user in
the editor if at least one of those commands was a `squash`.
In any case, the commit message will be cleaned up eventually, removing
all those intermediate comments, in the final step of such a
fixup/squash chain.
However, if the last fixup/squash command in such a chain fails with
merge conflicts, and if the user then decides to skip it (or resolve it
to a clean worktree and then continue the rebase), the current code
fails to clean up the commit message.
This commit fixes that behavior.
The fix is quite a bit more involved than meets the eye because it is
not only about the question whether we are `git rebase --skip`ing a
fixup or squash. It is also about removing the skipped fixup/squash's
commit message from the accumulated commit message. And it is also about
the question whether we should let the user edit the final commit
message or not ("Was there a squash in the chain *that was not
skipped*?").
For example, in this case we will want to fix the commit message, but
not open it in an editor:
pick <- succeeds
fixup <- succeeds
squash <- fails, will be skipped
This is where the newly-introduced `current-fixups` file comes in real
handy. A quick look and we can determine whether there was a non-skipped
squash. We only need to make sure to keep it up to date with respect to
skipped fixup/squash commands. As a bonus, we can even avoid committing
unnecessarily, e.g. when there was only one fixup, and it failed, and
was skipped.
To fix only the bug where the final commit message was not cleaned up
properly, but without fixing the rest, would have been more complicated
than fixing it all in one go, hence this commit lumps together more than
a single concern.
For the same reason, this commit also adds a bit more to the existing
test case for the regression we just fixed.
The diff is best viewed with --color-moved.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-04-27 20:48:30 +00:00
|
|
|
|
|
|
|
(test_set_editor "$PWD/copy-editor.sh" && git rebase --skip) &&
|
|
|
|
git show HEAD >out &&
|
|
|
|
test_i18ngrep ! "# This is a combination" out &&
|
|
|
|
|
|
|
|
: Final squash failed, but there was still a squash &&
|
2018-08-15 09:41:25 +00:00
|
|
|
test_i18ngrep "# This is a combination of 2 commits" .git/copy.txt &&
|
|
|
|
test_i18ngrep "# This is the commit message #2:" .git/copy.txt
|
2018-04-27 20:48:16 +00:00
|
|
|
'
|
2011-02-06 18:43:55 +00:00
|
|
|
|
2017-08-02 10:44:16 +00:00
|
|
|
test_expect_success 'setup rerere database' '
|
2011-02-06 18:43:56 +00:00
|
|
|
rm -fr .git/rebase-* &&
|
|
|
|
git reset --hard commit-new-file-F3-on-topic-branch &&
|
2011-12-08 13:10:17 +00:00
|
|
|
git checkout master &&
|
2011-02-06 18:43:56 +00:00
|
|
|
test_commit "commit-new-file-F3" F3 3 &&
|
2017-08-02 10:44:16 +00:00
|
|
|
test_config rerere.enabled true &&
|
2018-10-31 20:02:00 +00:00
|
|
|
git update-ref refs/heads/topic commit-new-file-F3-on-topic-branch &&
|
2011-02-06 18:43:56 +00:00
|
|
|
test_must_fail git rebase -m master topic &&
|
|
|
|
echo "Resolved" >F2 &&
|
2017-08-02 10:44:16 +00:00
|
|
|
cp F2 expected-F2 &&
|
2011-02-06 18:43:56 +00:00
|
|
|
git add F2 &&
|
|
|
|
test_must_fail git rebase --continue &&
|
|
|
|
echo "Resolved" >F3 &&
|
2017-08-02 10:44:16 +00:00
|
|
|
cp F3 expected-F3 &&
|
2011-02-06 18:43:56 +00:00
|
|
|
git add F3 &&
|
|
|
|
git rebase --continue &&
|
2017-08-02 10:44:16 +00:00
|
|
|
git reset --hard topic@{1}
|
2011-02-06 18:43:56 +00:00
|
|
|
'
|
|
|
|
|
2017-08-02 10:44:16 +00:00
|
|
|
prepare () {
|
|
|
|
rm -fr .git/rebase-* &&
|
|
|
|
git reset --hard commit-new-file-F3-on-topic-branch &&
|
|
|
|
git checkout master &&
|
|
|
|
test_config rerere.enabled true
|
|
|
|
}
|
|
|
|
|
|
|
|
test_rerere_autoupdate () {
|
|
|
|
action=$1 &&
|
|
|
|
test_expect_success "rebase $action --continue remembers --rerere-autoupdate" '
|
|
|
|
prepare &&
|
|
|
|
test_must_fail git rebase $action --rerere-autoupdate master topic &&
|
|
|
|
test_cmp expected-F2 F2 &&
|
|
|
|
git diff-files --quiet &&
|
|
|
|
test_must_fail git rebase --continue &&
|
|
|
|
test_cmp expected-F3 F3 &&
|
|
|
|
git diff-files --quiet &&
|
|
|
|
git rebase --continue
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "rebase $action --continue honors rerere.autoUpdate" '
|
|
|
|
prepare &&
|
|
|
|
test_config rerere.autoupdate true &&
|
|
|
|
test_must_fail git rebase $action master topic &&
|
|
|
|
test_cmp expected-F2 F2 &&
|
|
|
|
git diff-files --quiet &&
|
|
|
|
test_must_fail git rebase --continue &&
|
|
|
|
test_cmp expected-F3 F3 &&
|
|
|
|
git diff-files --quiet &&
|
|
|
|
git rebase --continue
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "rebase $action --continue remembers --no-rerere-autoupdate" '
|
|
|
|
prepare &&
|
|
|
|
test_config rerere.autoupdate true &&
|
|
|
|
test_must_fail git rebase $action --no-rerere-autoupdate master topic &&
|
|
|
|
test_cmp expected-F2 F2 &&
|
|
|
|
test_must_fail git diff-files --quiet &&
|
|
|
|
git add F2 &&
|
|
|
|
test_must_fail git rebase --continue &&
|
|
|
|
test_cmp expected-F3 F3 &&
|
|
|
|
test_must_fail git diff-files --quiet &&
|
|
|
|
git add F3 &&
|
|
|
|
git rebase --continue
|
|
|
|
'
|
|
|
|
}
|
|
|
|
|
|
|
|
test_rerere_autoupdate
|
|
|
|
test_rerere_autoupdate -m
|
2017-08-02 10:44:17 +00:00
|
|
|
GIT_SEQUENCE_EDITOR=: && export GIT_SEQUENCE_EDITOR
|
|
|
|
test_rerere_autoupdate -i
|
2018-10-31 20:02:02 +00:00
|
|
|
test_have_prereq !REBASE_P || test_rerere_autoupdate --preserve-merges
|
2017-08-02 10:44:16 +00:00
|
|
|
|
2010-07-28 08:20:16 +00:00
|
|
|
test_done
|