git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] rebase -i -p: Fix --continue after a merge could not be redone

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 22, 2008, 21:06 UTC
Message-ID
<alpine.DEB.1.00.0812222139340.30769@pacific.mpi-cbg.de>
In-Reply-To
<1229335531-32707-2-git-send-email-j6t@kdbg.org>
Hi,
On Mon, 15 Dec 2008, Johannes Sixt wrote:
Show 10 quoted lines
> When a merge that has a conflict was rebased, then rebase stopped to let
> the user resolve the conflicts. However, thereafter --continue failed
> because the author-script was not saved. (This is rebase -i's way to
> preserve a commit's authorship.) This fixes it by doing taking the same
> failure route after a merge that is also taken after a normal cherry-pick.
> 
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
> ---
>  This is an attempt at fixing the failure.  I don't know whether it is
>  problematic to leave a "patch" behind if there was actually a merge.

I'd suggest leaving behind a --cc patch, so that nobody is tempted to "fix" the patch until it applies.

Show 12 quoted lines
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index 1172e47..89c39eb 100755
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -253,15 +253,14 @@ pick_one_preserving_merges () {
>  			if ! GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
>  				GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
>  				GIT_AUTHOR_DATE="$GIT_AUTHOR_DATE" \
>  				output git merge $STRATEGY -m "$msg" \
>  					$new_parents
>  			then
> -				git rerere
Why?  I found rerere pretty helpful when rebasing merges.

Ah, it is done by die_with_patch() already. You might want to prevent headscratching and hunting around for a few minutes, by simply mentioning that fact in the commit message.

I'll leave the commit message fixing to you, but the --cc patch probably looks something like this -- feel free to squash in:

---
 git-rebase--interactive.sh |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 89c39eb..b20c101 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -115,9 +115,21 @@ mark_action_done () {
 }
 
 make_patch () {
-	parent_sha1=$(git rev-parse --verify "$1"^) ||
-		die "Cannot get patch for $1^"
-	git diff-tree -p "$parent_sha1".."$1" > "$DOTEST"/patch
+	sha1_and_parents="$(git rev-list --parents -1 $1)"
+	case "$sha1_and_parents" in
+	*' '*' '*' '*)
+		echo "Octopus merge"
+	;;
+	*' '*' '*)
+		git diff --cc $sha1_and_parents
+	;;
+	*' '*)
+		git diff-tree -R -p $sha1_and_parents
+	;;
+	*)
+		echo "Root commit"
+	;;
+	esac > "$DOTEST"/patch
 	test -f "$DOTEST"/message ||
 		git cat-file commit "$1" | sed "1,/^$/d" > "$DOTEST"/message
 	test -f "$DOTEST"/author-script ||
Previous: Junio C HamanoNext: Johannes Schindelin
Message 5 of 6 in “Show a failure of rebase -p if the merge had a conflict”
  1. Show a failure of rebase -p if the merge had a conflictJohannes Sixt, Dec 11, 2008
  2. 1/2 Show a failure of rebase -p if the merge had a conflictJohannes Sixt, Dec 15, 2008
  3. 2/2 rebase -i -p: Fix --continue after a merge could not be redoneJohannes Sixt, Dec 15, 2008
  4. Junio C HamanoDec 15, 2008
  5. Johannes SchindelinDec 22, 2008
  6. Johannes SchindelinDec 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.