git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Phillip Wood <phillip.wood@talktalk.net>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: [PATCH v2 3/3] rebase --keep-empty: always use interactive rebase
Date: Tue, 20 Mar 2018 11:10:57 +0000	[thread overview]
Message-ID: <20180320111057.23862-4-phillip.wood@talktalk.net> (raw)
In-Reply-To: <20180320111057.23862-1-phillip.wood@talktalk.net>

From: Phillip Wood <phillip.wood@dunelm.org.uk>

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>
---
 git-rebase--am.sh                 | 79 ++++++++++++++++-----------------------
 git-rebase.sh                     |  5 +++
 t/t3421-rebase-topology-linear.sh |  4 +-
 3 files changed, 40 insertions(+), 48 deletions(-)

diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index be3f068922..ae596d3731 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -41,60 +41,47 @@ else
 fi
 
 ret=0
-if test -n "$keep_empty"
-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" \
-		$allow_empty_message \
-		${restrict_revision+^$restrict_revision}
-	ret=$?
-else
-	rm -f "$GIT_DIR/rebased-patches"
+rm -f "$GIT_DIR/rebased-patches"
 
-	git format-patch -k --stdout --full-index --cherry-pick --right-only \
-		--src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
-		--pretty=mboxrd \
-		$git_format_patch_opt \
-		"$revisions" ${restrict_revision+^$restrict_revision} \
-		>"$GIT_DIR/rebased-patches"
-	ret=$?
+git format-patch -k --stdout --full-index --cherry-pick --right-only \
+	--src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
+	--pretty=mboxrd \
+	$git_format_patch_opt \
+	"$revisions" ${restrict_revision+^$restrict_revision} \
+	>"$GIT_DIR/rebased-patches"
+ret=$?
 
-	if test 0 != $ret
-	then
-		rm -f "$GIT_DIR/rebased-patches"
-		case "$head_name" in
-		refs/heads/*)
-			git checkout -q "$head_name"
-			;;
-		*)
-			git checkout -q "$orig_head"
-			;;
-		esac
+if test 0 != $ret
+then
+	rm -f "$GIT_DIR/rebased-patches"
+	case "$head_name" in
+	refs/heads/*)
+		git checkout -q "$head_name"
+		;;
+	*)
+		git checkout -q "$orig_head"
+		;;
+	esac
 
-		cat >&2 <<-EOF
+	cat >&2 <<-EOF
 
-		git encountered an error while preparing the patches to replay
-		these revisions:
+	git encountered an error while preparing the patches to replay
+	these revisions:
 
-		    $revisions
+	    $revisions
 
-		As a result, git cannot rebase them.
-		EOF
-		return $ret
-	fi
+	As a result, git cannot rebase them.
+	EOF
+	return $ret
+fi
 
-	git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
-		--patch-format=mboxrd \
-		$allow_rerere_autoupdate \
-		${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
-	ret=$?
+git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
+	--patch-format=mboxrd \
+	$allow_rerere_autoupdate \
+	${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
+ret=$?
 
-	rm -f "$GIT_DIR/rebased-patches"
-fi
+rm -f "$GIT_DIR/rebased-patches"
 
 if test 0 != $ret
 then
diff --git a/git-rebase.sh b/git-rebase.sh
index 7d3bb9d443..ad1a3bd3ef 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -459,6 +459,11 @@ then
 	test -z "$interactive_rebase" && interactive_rebase=implied
 fi
 
+if test -n "$keep_empty"
+then
+	test -z "$interactive_rebase" && interactive_rebase=implied
+fi
+
 if test -n "$interactive_rebase"
 then
 	type=interactive
diff --git a/t/t3421-rebase-topology-linear.sh b/t/t3421-rebase-topology-linear.sh
index 68fe2003ef..13e5c1a2f1 100755
--- a/t/t3421-rebase-topology-linear.sh
+++ b/t/t3421-rebase-topology-linear.sh
@@ -199,7 +199,7 @@ test_run_rebase () {
 	"
 }
 test_run_rebase success ''
-test_run_rebase failure -m
+test_run_rebase success -m
 test_run_rebase success -i
 test_run_rebase failure -p
 
@@ -214,7 +214,7 @@ test_run_rebase () {
 	"
 }
 test_run_rebase success ''
-test_run_rebase failure -m
+test_run_rebase success -m
 test_run_rebase failure -i
 test_run_rebase failure -p
 
-- 
2.16.2


  parent reply	other threads:[~2018-03-20 11:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-14 11:11 [PATCH 1/2] rebase: support --signoff with implicit rebase Phillip Wood
2018-03-14 11:11 ` [PATCH 2/2] rebase --root -k: fix when root commit is empty Phillip Wood
2018-03-15 10:28   ` Johannes Schindelin
2018-03-15 10:59   ` Phillip Wood
2018-03-14 17:48 ` [PATCH 1/2] rebase: support --signoff with implicit rebase Junio C Hamano
2018-03-15 10:11   ` Johannes Schindelin
2018-03-15 10:18 ` Johannes Schindelin
2018-03-15 10:55   ` Phillip Wood
2018-03-16 12:36     ` Johannes Schindelin
2018-03-20 11:10 ` [PATCH v2 0/3] rebase: extend --signoff support Phillip Wood
2018-03-20 11:10   ` [PATCH v2 1/3] " Phillip Wood
2018-03-20 11:10   ` [PATCH v2 2/3] rebase -p: error out if --signoff is given Phillip Wood
2018-03-20 11:10   ` Phillip Wood [this message]
2018-03-20 16:08     ` [PATCH v2 3/3] rebase --keep-empty: always use interactive rebase Johannes Schindelin
2018-03-20 18:44       ` Phillip Wood

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=20180320111057.23862-4-phillip.wood@talktalk.net \
    --to=phillip.wood@talktalk.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    --subject='Re: [PATCH v2 3/3] rebase --keep-empty: always use interactive rebase' \
    /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

Code repositories for project(s) associated with this 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).