rebase: honor --rerere-autoupdate
Rebase accepts '--rerere-autoupdate' as an option but only honors it if '-m' is also given. Fix it for a non-interactive rebase by passing on the option to 'git am' and 'git cherry-pick'. Rework the tests so that they can be used for each rebase flavor and extend them. Reported-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
fd4a3f486d
commit
5fb415b57f
|
@ -45,7 +45,7 @@ then
|
||||||
# itself well to recording empty patches. fortunately, cherry-pick
|
# itself well to recording empty patches. fortunately, cherry-pick
|
||||||
# makes this easy
|
# makes this easy
|
||||||
git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty \
|
git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty \
|
||||||
--right-only "$revisions" \
|
$allow_rerere_autoupdate --right-only "$revisions" \
|
||||||
${restrict_revision+^$restrict_revision}
|
${restrict_revision+^$restrict_revision}
|
||||||
ret=$?
|
ret=$?
|
||||||
else
|
else
|
||||||
|
@ -82,6 +82,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
|
git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
|
||||||
|
$allow_rerere_autoupdate \
|
||||||
${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
|
${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
|
||||||
ret=$?
|
ret=$?
|
||||||
|
|
||||||
|
|
|
@ -40,25 +40,6 @@ test_expect_success 'non-interactive rebase --continue works with touched file'
|
||||||
git rebase --continue
|
git rebase --continue
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'non-interactive rebase --continue with rerere enabled' '
|
|
||||||
test_config rerere.enabled true &&
|
|
||||||
test_when_finished "test_might_fail git rebase --abort" &&
|
|
||||||
git reset --hard commit-new-file-F2-on-topic-branch &&
|
|
||||||
git checkout master &&
|
|
||||||
rm -fr .git/rebase-* &&
|
|
||||||
|
|
||||||
test_must_fail git rebase --onto master master topic &&
|
|
||||||
echo "Resolved" >F2 &&
|
|
||||||
git add F2 &&
|
|
||||||
cp F2 F2.expected &&
|
|
||||||
git rebase --continue &&
|
|
||||||
|
|
||||||
git reset --hard commit-new-file-F2-on-topic-branch &&
|
|
||||||
git checkout master &&
|
|
||||||
test_must_fail git rebase --onto master master topic &&
|
|
||||||
test_cmp F2.expected F2
|
|
||||||
'
|
|
||||||
|
|
||||||
test_expect_success 'rebase --continue can not be used with other options' '
|
test_expect_success 'rebase --continue can not be used with other options' '
|
||||||
test_must_fail git rebase -v --continue &&
|
test_must_fail git rebase -v --continue &&
|
||||||
test_must_fail git rebase --continue -v
|
test_must_fail git rebase --continue -v
|
||||||
|
@ -93,25 +74,72 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
|
||||||
test -f funny.was.run
|
test -f funny.was.run
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'rebase --continue remembers --rerere-autoupdate' '
|
test_expect_success 'setup rerere database' '
|
||||||
rm -fr .git/rebase-* &&
|
rm -fr .git/rebase-* &&
|
||||||
git reset --hard commit-new-file-F3-on-topic-branch &&
|
git reset --hard commit-new-file-F3-on-topic-branch &&
|
||||||
git checkout master &&
|
git checkout master &&
|
||||||
test_commit "commit-new-file-F3" F3 3 &&
|
test_commit "commit-new-file-F3" F3 3 &&
|
||||||
git config rerere.enabled true &&
|
test_config rerere.enabled true &&
|
||||||
test_must_fail git rebase -m master topic &&
|
test_must_fail git rebase -m master topic &&
|
||||||
echo "Resolved" >F2 &&
|
echo "Resolved" >F2 &&
|
||||||
|
cp F2 expected-F2 &&
|
||||||
git add F2 &&
|
git add F2 &&
|
||||||
test_must_fail git rebase --continue &&
|
test_must_fail git rebase --continue &&
|
||||||
echo "Resolved" >F3 &&
|
echo "Resolved" >F3 &&
|
||||||
|
cp F3 expected-F3 &&
|
||||||
git add F3 &&
|
git add F3 &&
|
||||||
git rebase --continue &&
|
git rebase --continue &&
|
||||||
git reset --hard topic@{1} &&
|
git reset --hard topic@{1}
|
||||||
test_must_fail git rebase -m --rerere-autoupdate master &&
|
|
||||||
test "$(cat F2)" = "Resolved" &&
|
|
||||||
test_must_fail git rebase --continue &&
|
|
||||||
test "$(cat F3)" = "Resolved" &&
|
|
||||||
git rebase --continue
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in New Issue