Browse Source

rebase --keep-empty: always use interactive rebase

rebase --merge accepts --keep-empty but just ignores it, by using an
implicit interactive rebase the user still gets the rename detection
of a merge based rebase but with with --keep-empty support.

If rebase --keep-empty without --interactive or --merge stops for the
user to resolve merge conflicts then 'git rebase --continue' will
fail. This is because it uses a different code path that does not
create $git_dir/rebase-apply. As rebase --keep-empty was implemented
using cherry-pick it has never supported the am options and now that
interactive rebases support --signoff there is no loss of
functionality by using an implicit interactive rebase.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Phillip Wood 7 years ago committed by Junio C Hamano
parent
commit
da27a6fbd5
  1. 30
      git-rebase--am.sh
  2. 5
      git-rebase.sh
  3. 4
      t/t3421-rebase-topology-linear.sh

30
git-rebase--am.sh

@ -38,29 +38,18 @@ else
fi fi


ret=0 ret=0
if test -n "$keep_empty" rm -f "$GIT_DIR/rebased-patches"
then
# we have to do this the hard way. git format-patch completely squashes
# empty commits and even if it didn't the format doesn't really lend
# itself well to recording empty patches. fortunately, cherry-pick
# makes this easy
git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty \
$allow_rerere_autoupdate --right-only "$revisions" \
${restrict_revision+^$restrict_revision}
ret=$?
else
rm -f "$GIT_DIR/rebased-patches"


git format-patch -k --stdout --full-index --cherry-pick --right-only \ git format-patch -k --stdout --full-index --cherry-pick --right-only \
--src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \ --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
--pretty=mboxrd \ --pretty=mboxrd \
$git_format_patch_opt \ $git_format_patch_opt \
"$revisions" ${restrict_revision+^$restrict_revision} \ "$revisions" ${restrict_revision+^$restrict_revision} \
>"$GIT_DIR/rebased-patches" >"$GIT_DIR/rebased-patches"
ret=$? ret=$?


if test 0 != $ret if test 0 != $ret
then then
rm -f "$GIT_DIR/rebased-patches" rm -f "$GIT_DIR/rebased-patches"
case "$head_name" in case "$head_name" in
refs/heads/*) refs/heads/*)
@ -81,16 +70,15 @@ else
As a result, git cannot rebase them. As a result, git cannot rebase them.
EOF EOF
return $ret return $ret
fi fi


git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \ git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
--patch-format=mboxrd \ --patch-format=mboxrd \
$allow_rerere_autoupdate \ $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=$?


rm -f "$GIT_DIR/rebased-patches" rm -f "$GIT_DIR/rebased-patches"
fi


if test 0 != $ret if test 0 != $ret
then then

5
git-rebase.sh

@ -452,6 +452,11 @@ then
test -z "$interactive_rebase" && interactive_rebase=implied test -z "$interactive_rebase" && interactive_rebase=implied
fi fi


if test -n "$keep_empty"
then
test -z "$interactive_rebase" && interactive_rebase=implied
fi

if test -n "$interactive_rebase" if test -n "$interactive_rebase"
then then
type=interactive type=interactive

4
t/t3421-rebase-topology-linear.sh

@ -199,7 +199,7 @@ test_run_rebase () {
" "
} }
test_run_rebase success '' test_run_rebase success ''
test_run_rebase failure -m test_run_rebase success -m
test_run_rebase success -i test_run_rebase success -i
test_run_rebase failure -p test_run_rebase failure -p


@ -214,7 +214,7 @@ test_run_rebase () {
" "
} }
test_run_rebase success '' test_run_rebase success ''
test_run_rebase failure -m test_run_rebase success -m
test_run_rebase success -i test_run_rebase success -i
test_run_rebase failure -p test_run_rebase failure -p



Loading…
Cancel
Save