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 <alban.gruin@gmail.com>
Alban Gruin committed
May 28, 2018 at 14:34 UTC
ef64bb328df9c131c6c454ad65169fa3972da512
1 file changed
+4
-61
git-rebase--preserve-merges.sh
+4
-61
@@ -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.
3
#
4
# Copyright (c) 2006 Johannes E. Schindelin
5
#
7
-# The original idea comes from Eric W. Biederman, in
8
-# https://public-inbox.org/git/m1odwkyuf5.fsf_-_@ebiederm.dsl.xmission.com/
9
-#
6
# The file containing rebase commands, comments, and empty lines.
7
# This file is created by "git rebase -i" then edited by the user. As
8
# the lines are processed, they are removed from the front of this
@@ -287,17 +283,7 @@ pick_one () {
283
empty_args="--allow-empty"
284
fi
285
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 "$@"
287
}
288
289
pick_one_preserving_merges () {
@@ -761,11 +747,6 @@ get_missing_commit_check_level () {
747
initiate_action () {
748
case "$1" in
749
continue)
764
- if test ! -d "$rewritten"
765
- then
766
- exec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \
767
- --continue
768
- fi
750
# do we have anything to commit?
751
if git diff-index --cached --quiet HEAD --
752
then
@@ -824,12 +805,6 @@ first and then run 'git rebase --continue' again.")"
805
;;
806
skip)
807
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
808
do_rest
809
return 0
810
;;
@@ -944,43 +919,11 @@ EOF
919
}
920
921
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
-
922
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
923
do_rest
924
}
925
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 () {
927
initiate_action "$action"
928
ret=$?
929
if test $ret = 0; then