Skip to content

Commit 6d98d0c

Browse files
agrngitster
authored andcommitted
rebase: use the new git-rebase--preserve-merges.sh
Create a new type of rebase, "preserve-merges", used when rebase is called with -p. Before that, the type for preserve-merges was "interactive", and some places of this script compared $type to "interactive". Instead, the code now checks if $interactive_rebase is empty or not, as it is set to "explicit" when calling an interactive rebase (and, possibly, one of its submodes), and "implied" when calling one of its submodes (eg. preserve-merges) *without* interactive rebase. It also detects the presence of the directory "$merge_dir"/rewritten left by the preserve-merges script when calling rebase --continue, --skip, etc., and, if it exists, sets the rebase mode to preserve-merges. In this case, interactive_rebase is set to "explicit", as "implied" would break some tests. Signed-off-by: Alban Gruin <[email protected]>
1 parent ef64bb3 commit 6d98d0c

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

git-rebase.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,14 @@ run_specific_rebase () {
207207
autosquash=
208208
fi
209209
. git-rebase--$type
210-
git_rebase__$type${preserve_merges:+__preserve_merges}
210+
211+
if test -z "$preserve_merges"
212+
then
213+
git_rebase__$type
214+
else
215+
git_rebase__preserve_merges
216+
fi
217+
211218
ret=$?
212219
if test $ret -eq 0
213220
then
@@ -239,7 +246,12 @@ then
239246
state_dir="$apply_dir"
240247
elif test -d "$merge_dir"
241248
then
242-
if test -f "$merge_dir"/interactive
249+
if test -d "$merge_dir"/rewritten
250+
then
251+
type=preserve-merges
252+
interactive_rebase=explicit
253+
preserve_merges=t
254+
elif test -f "$merge_dir"/interactive
243255
then
244256
type=interactive
245257
interactive_rebase=explicit
@@ -402,14 +414,14 @@ if test -n "$action"
402414
then
403415
test -z "$in_progress" && die "$(gettext "No rebase in progress?")"
404416
# Only interactive rebase uses detailed reflog messages
405-
if test "$type" = interactive && test "$GIT_REFLOG_ACTION" = rebase
417+
if test -n "$interactive_rebase" && test "$GIT_REFLOG_ACTION" = rebase
406418
then
407419
GIT_REFLOG_ACTION="rebase -i ($action)"
408420
export GIT_REFLOG_ACTION
409421
fi
410422
fi
411423

412-
if test "$action" = "edit-todo" && test "$type" != "interactive"
424+
if test "$action" = "edit-todo" && test -z "$interactive_rebase"
413425
then
414426
die "$(gettext "The --edit-todo action can only be used during interactive rebase.")"
415427
fi
@@ -487,7 +499,13 @@ fi
487499

488500
if test -n "$interactive_rebase"
489501
then
490-
type=interactive
502+
if test -z "$preserve_merges"
503+
then
504+
type=interactive
505+
else
506+
type=preserve-merges
507+
fi
508+
491509
state_dir="$merge_dir"
492510
elif test -n "$do_merge"
493511
then
@@ -647,7 +665,7 @@ require_clean_work_tree "rebase" "$(gettext "Please commit or stash them.")"
647665
# but this should be done only when upstream and onto are the same
648666
# and if this is not an interactive rebase.
649667
mb=$(git merge-base "$onto" "$orig_head")
650-
if test "$type" != interactive && test "$upstream" = "$onto" &&
668+
if test -z "$interactive_rebase" && test "$upstream" = "$onto" &&
651669
test "$mb" = "$onto" && test -z "$restrict_revision" &&
652670
# linear history?
653671
! (git rev-list --parents "$onto".."$orig_head" | sane_grep " .* ") > /dev/null
@@ -691,7 +709,7 @@ then
691709
GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
692710
fi
693711

694-
test "$type" = interactive && run_specific_rebase
712+
test -n "$interactive_rebase" && run_specific_rebase
695713

696714
# Detach HEAD and reset the tree
697715
say "$(gettext "First, rewinding head to replay your work on top of it...")"

0 commit comments

Comments
 (0)