Skip to content

Commit ef64bb3

Browse files
agrngitster
authored andcommitted
rebase: strip unused code in git-rebase--preserve-merges.sh
This removes the code coming from git-rebase--interactive.sh that is not needed by preserve-merges, and changes the header comment accordingly. In a following commit, the -p code from git-rebase--interactive.sh will be stripped out. As preserve-merges’ successor is already in the works, this will be the only script to be converted. This also seems to fix a bug where a failure in `pick_one_preserving_merges()` would fallback to the non-preserve-merges `pick_one()`. Signed-off-by: Alban Gruin <[email protected]>
1 parent c42abfe commit ef64bb3

File tree

1 file changed

+4
-61
lines changed

1 file changed

+4
-61
lines changed

git-rebase--preserve-merges.sh

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
# This shell script fragment is sourced by git-rebase to implement
2-
# its interactive mode. "git rebase --interactive" makes it easy
3-
# to fix up commits in the middle of a series and rearrange commits.
1+
# This shell script fragment is sourced by git-rebase to implement its
2+
# preserve-merges mode.
43
#
54
# Copyright (c) 2006 Johannes E. Schindelin
65
#
7-
# The original idea comes from Eric W. Biederman, in
8-
# https://public-inbox.org/git/[email protected]/
9-
#
106
# The file containing rebase commands, comments, and empty lines.
117
# This file is created by "git rebase -i" then edited by the user. As
128
# the lines are processed, they are removed from the front of this
@@ -287,17 +283,7 @@ pick_one () {
287283
empty_args="--allow-empty"
288284
fi
289285

290-
test -d "$rewritten" &&
291-
pick_one_preserving_merges "$@" && return
292-
output eval git cherry-pick $allow_rerere_autoupdate $allow_empty_message \
293-
${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")} \
294-
$signoff "$strategy_args" $empty_args $ff "$@"
295-
296-
# If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule
297-
# previous task so this commit is not lost.
298-
ret=$?
299-
case "$ret" in [01]) ;; *) reschedule_last_action ;; esac
300-
return $ret
286+
pick_one_preserving_merges "$@"
301287
}
302288

303289
pick_one_preserving_merges () {
@@ -761,11 +747,6 @@ get_missing_commit_check_level () {
761747
initiate_action () {
762748
case "$1" in
763749
continue)
764-
if test ! -d "$rewritten"
765-
then
766-
exec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \
767-
--continue
768-
fi
769750
# do we have anything to commit?
770751
if git diff-index --cached --quiet HEAD --
771752
then
@@ -824,12 +805,6 @@ first and then run 'git rebase --continue' again.")"
824805
;;
825806
skip)
826807
git rerere clear
827-
828-
if test ! -d "$rewritten"
829-
then
830-
exec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \
831-
--continue
832-
fi
833808
do_rest
834809
return 0
835810
;;
@@ -944,43 +919,11 @@ EOF
944919
}
945920

946921
expand_todo_ids
947-
948-
test -d "$rewritten" || test -n "$force_rebase" ||
949-
onto="$(git rebase--helper --skip-unnecessary-picks)" ||
950-
die "Could not skip unnecessary pick commands"
951-
952922
checkout_onto
953-
if test ! -d "$rewritten"
954-
then
955-
require_clean_work_tree "rebase"
956-
exec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \
957-
--continue
958-
fi
959923
do_rest
960924
}
961925

962-
git_rebase__interactive () {
963-
initiate_action "$action"
964-
ret=$?
965-
if test $ret = 0; then
966-
return 0
967-
fi
968-
969-
setup_reflog_action
970-
init_basic_state
971-
972-
init_revisions_and_shortrevisions
973-
974-
git rebase--helper --make-script ${keep_empty:+--keep-empty} \
975-
${rebase_merges:+--rebase-merges} \
976-
${rebase_cousins:+--rebase-cousins} \
977-
$revisions ${restrict_revision+^$restrict_revision} >"$todo" ||
978-
die "$(gettext "Could not generate todo list")"
979-
980-
complete_action
981-
}
982-
983-
git_rebase__interactive__preserve_merges () {
926+
git_rebase__preserve_merges () {
984927
initiate_action "$action"
985928
ret=$?
986929
if test $ret = 0; then

0 commit comments

Comments
 (0)