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

[PATCH 3/3] git-rebase--interactive.sh: Make 3-way merge strategies work for -p.

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Oct 31, 2007, 02:20 UTC
Message-ID
<1193797232-1062-3-git-send-email-B.Steinbrink@gmx.de>
In-Reply-To
<1193797232-1062-2-git-send-email-B.Steinbrink@gmx.de>

git-rebase--interactive.sh used to pass all parents of a merge commit to git-merge, which means that we have at least 3 heads to merge: HEAD, first parent and second parent. So 3-way merge strategies like recursive wouldn't work.

Fortunately, we have checked out the first parent right before the merge anyway, so that is HEAD. Therefore we can drop simply it from the list of parents, making 3-way strategies work for merge commits with only two parents.

Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index cc949db..e63e1c9 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -172,6 +172,9 @@ pick_one_preserving_merges () {
 			author_script=$(get_author_ident_from_commit $sha1)
 			eval "$author_script"
 			msg="$(git cat-file commit $sha1 | sed -e '1,/^$/d')"
+
+			# No point in merging the first parent, that's HEAD
+			new_parents=${new_parents# $first_parent}
 			# NEEDSWORK: give rerere a chance
 			if ! GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
 				GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
-- 
1.5.3.4.456.g072a
Previous: Björn SteinbrinkNext: Johannes Schindelin
Message 3 of 5 in “Fix --strategy parsing in git-rebase--interactive.sh”
  1. 1/3 Fix --strategy parsing in git-rebase--interactive.shBjörn Steinbrink, Oct 31, 2007
  2. 2/3 git-rebase--interactive.sh: Don't pass a strategy to git-cherry-pick.Björn Steinbrink, Oct 31, 2007
  3. 3/3 git-rebase--interactive.sh: Make 3-way merge strategies work for -p.Björn Steinbrink, Oct 31, 2007
  4. Johannes SchindelinOct 31, 2007
  5. Björn SteinbrinkOct 31, 2007

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.