git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Alban Gruin <alban.gruin@gmail.com>
To: git@vger.kernel.org
Cc: Stefan Beller <sbeller@google.com>,
	Christian Couder <christian.couder@gmail.com>,
	Pratik Karki <predatoramigo@gmail.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	phillip.wood@dunelm.org.uk, Wink Saville <wink@saville.com>,
	Alban Gruin <alban.gruin@gmail.com>
Subject: [GSoC][PATCH 3/4] rebase: use the new git-rebase--preserve-merges.sh
Date: Tue, 22 May 2018 15:31:09 +0200	[thread overview]
Message-ID: <20180522133110.32723-4-alban.gruin@gmail.com> (raw)
In-Reply-To: <20180522133110.32723-1-alban.gruin@gmail.com>

Creates 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 <alban.gruin@gmail.com>
---
 git-rebase.sh | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/git-rebase.sh b/git-rebase.sh
index 40be59ecc..19bdebb48 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -207,7 +207,14 @@ run_specific_rebase () {
 		autosquash=
 	fi
 	. git-rebase--$type
-	git_rebase__$type${preserve_merges:+__preserve_merges}
+
+	if test -z "$preserve_merges"
+	then
+		git_rebase__$type
+	else
+		git_rebase__preserve_merges
+	fi
+
 	ret=$?
 	if test $ret -eq 0
 	then
@@ -239,7 +246,12 @@ then
 	state_dir="$apply_dir"
 elif test -d "$merge_dir"
 then
-	if test -f "$merge_dir"/interactive
+	if test -d "$merge_dir"/rewritten
+	then
+		type=preserve-merges
+		interactive_rebase=explicit
+		preserve_merges=t
+	elif test -f "$merge_dir"/interactive
 	then
 		type=interactive
 		interactive_rebase=explicit
@@ -402,14 +414,14 @@ if test -n "$action"
 then
 	test -z "$in_progress" && die "$(gettext "No rebase in progress?")"
 	# Only interactive rebase uses detailed reflog messages
-	if test "$type" = interactive && test "$GIT_REFLOG_ACTION" = rebase
+	if test -n "$interactive_rebase" && test "$GIT_REFLOG_ACTION" = rebase
 	then
 		GIT_REFLOG_ACTION="rebase -i ($action)"
 		export GIT_REFLOG_ACTION
 	fi
 fi
 
-if test "$action" = "edit-todo" && test "$type" != "interactive"
+if test "$action" = "edit-todo" && test -z "$interactive_rebase"
 then
 	die "$(gettext "The --edit-todo action can only be used during interactive rebase.")"
 fi
@@ -487,7 +499,13 @@ fi
 
 if test -n "$interactive_rebase"
 then
-	type=interactive
+	if test -z "$preserve_merges"
+	then
+		type=interactive
+	else
+		type=preserve-merges
+	fi
+
 	state_dir="$merge_dir"
 elif test -n "$do_merge"
 then
@@ -647,7 +665,7 @@ require_clean_work_tree "rebase" "$(gettext "Please commit or stash them.")"
 # but this should be done only when upstream and onto are the same
 # and if this is not an interactive rebase.
 mb=$(git merge-base "$onto" "$orig_head")
-if test "$type" != interactive && test "$upstream" = "$onto" &&
+if test -z "$interactive_rebase" && test "$upstream" = "$onto" &&
 	test "$mb" = "$onto" && test -z "$restrict_revision" &&
 	# linear history?
 	! (git rev-list --parents "$onto".."$orig_head" | sane_grep " .* ") > /dev/null
@@ -691,7 +709,7 @@ then
 	GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
 fi
 
-test "$type" = interactive && run_specific_rebase
+test -n "$interactive_rebase" && run_specific_rebase
 
 # Detach HEAD and reset the tree
 say "$(gettext "First, rewinding head to replay your work on top of it...")"
-- 
2.16.1


  parent reply	other threads:[~2018-05-22 13:31 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22 13:31 [GSoC][PATCH 0/4] rebase: split rebase -p from rebase -i Alban Gruin
2018-05-22 13:31 ` [GSoC][PATCH 1/4] rebase: duplicate git-rebase--interactive.sh to git-rebase--preserve-merges.sh Alban Gruin
2018-05-22 18:26   ` Stefan Beller
2018-05-22 19:15     ` Alban Gruin
2018-05-22 13:31 ` [GSoC][PATCH 2/4] rebase: strip unused code in git-rebase--preserve-merges.sh Alban Gruin
2018-05-22 13:31 ` Alban Gruin [this message]
2018-05-22 13:31 ` [GSoC][PATCH 4/4] rebase: remove -p code from git-rebase--interactive.sh Alban Gruin
2018-05-22 18:29 ` [GSoC][PATCH 0/4] rebase: split rebase -p from rebase -i Stefan Beller
2018-05-22 21:16 ` [GSoC][PATCH v2 " Alban Gruin
2018-05-22 21:16   ` [GSoC][PATCH v2 1/4] rebase: duplicate git-rebase--interactive.sh to git-rebase--preserve-merges.sh Alban Gruin
2018-05-22 21:16   ` [GSoC][PATCH v2 2/4] rebase: strip unused code in git-rebase--preserve-merges.sh Alban Gruin
2018-05-22 21:16   ` [GSoC][PATCH v2 3/4] rebase: use the new git-rebase--preserve-merges.sh Alban Gruin
2018-05-22 21:16   ` [GSoC][PATCH v2 4/4] rebase: remove -p code from git-rebase--interactive.sh Alban Gruin
2018-05-24 11:49   ` [GSoC][PATCH v3 0/4] rebase: split rebase -p from rebase -i Alban Gruin
2018-05-24 11:49     ` [GSoC][PATCH v3 1/4] rebase: duplicate git-rebase--interactive.sh to git-rebase--preserve-merges.sh Alban Gruin
2018-05-26  2:54       ` Junio C Hamano
2018-05-24 11:49     ` [GSoC][PATCH v3 2/4] rebase: strip unused code in git-rebase--preserve-merges.sh Alban Gruin
2018-05-24 11:49     ` [GSoC][PATCH v3 3/4] rebase: use the new git-rebase--preserve-merges.sh Alban Gruin
2018-05-24 11:49     ` [GSoC][PATCH v3 4/4] rebase: remove -p code from git-rebase--interactive.sh Alban Gruin
2018-05-24 11:52     ` [GSoC][PATCH v3 0/4] rebase: split rebase -p from rebase -i Alban Gruin
2018-05-25  9:51     ` Johannes Schindelin
2018-05-28 12:34     ` [GSoC][PATCH v4 " Alban Gruin
2018-05-28 12:34       ` [GSoC][PATCH v4 1/4] rebase: introduce a dedicated backend for --preserve-merges Alban Gruin
2018-05-28 12:34       ` [GSoC][PATCH v4 2/4] rebase: strip unused code in git-rebase--preserve-merges.sh Alban Gruin
2018-05-28 12:34       ` [GSoC][PATCH v4 3/4] rebase: use the new git-rebase--preserve-merges.sh Alban Gruin
2018-05-28 12:34       ` [GSoC][PATCH v4 4/4] rebase: remove -p code from git-rebase--interactive.sh Alban Gruin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180522133110.32723-4-alban.gruin@gmail.com \
    --to=alban.gruin@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=predatoramigo@gmail.com \
    --cc=sbeller@google.com \
    --cc=wink@saville.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).