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

[PATCH 1/4] git-merge: test octopus with redundant parents

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 17, 2012, 20:34 UTC
Message-ID
<1334694886-27756-2-git-send-email-gitster@pobox.com>
In-Reply-To
<1334694886-27756-1-git-send-email-gitster@pobox.com>
From: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>

This happens when git merge is run to merge multiple commits that are descendants of current HEAD (or are HEAD). We've hit this while updating master to origin/master but accidentaly we called (while being on master):

	$ git merge master origin/master
Here is a minimal testcase:
	$ git init a && cd a
	$ echo a >a && git add a
	$ git commit -minitial
	$ echo b >a && git add a
	$ git commit -msecond
	$ git checkout master^
	$ git merge master master
	Fast-forwarding to: master
	Already up-to-date with master
	Merge made by the 'octopus' strategy.
	 a |    2 +-
	  1 files changed, 1 insertions(+), 1 deletions(-)
	$ git cat-file commit HEAD
	tree eebfed94e75e7760540d1485c740902590a00332
	parent bd679e85202280b263e20a57639a142fa14c2c64
	author Michał Kiedrowicz <michal.kiedrowicz@gmail.com> 1329132996 +0100
	committer Michał Kiedrowicz <michal.kiedrowicz@gmail.com> 1329132996 +0100
	Merge branches 'master' and 'master' into HEAD
Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t6028-merge-up-to-date.sh |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/t/t6028-merge-up-to-date.sh b/t/t6028-merge-up-to-date.sh
index a91644e..824fca5 100755
--- a/t/t6028-merge-up-to-date.sh
+++ b/t/t6028-merge-up-to-date.sh
@@ -16,7 +16,12 @@ test_expect_success setup '
 	test_tick &&
 	git commit -m second &&
 	git tag c1 &&
-	git branch test
+	git branch test &&
+	echo third >file &&
+	git add file &&
+	test_tick &&
+	git commit -m third &&
+	git tag c2
 '
 
 test_expect_success 'merge -s recursive up-to-date' '
@@ -74,4 +79,14 @@ test_expect_success 'merge -s subtree up-to-date' '
 
 '
 
+test_expect_failure 'merge fast-forward octopus' '
+
+	git reset --hard c0 &&
+	test_tick &&
+	git merge c1 c2
+	expect=$(git rev-parse c2) &&
+	current=$(git rev-parse HEAD) &&
+	test "$expect" = "$current"
+'
+
 test_done
-- 
1.7.10.332.g1863c
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 22 in “Re: What's cooking in git.git (Apr 2012, #05; Thu, 12)”
  1. Michal KiedrowiczApr 16, 2012
  2. Linus TorvaldsApr 16, 2012
  3. Junio C HamanoApr 16, 2012
  4. Linus TorvaldsApr 16, 2012
  5. Junio C HamanoApr 16, 2012
  6. 0/4 merge: reduce set of parents consistentlyJunio C Hamano, Apr 17, 2012
  7. 1/4 git-merge: test octopus with redundant parentsJunio C Hamano, Apr 17, 2012
  8. 2/4 builtin/merge.c: remove "remoteheads" global variableJunio C Hamano, Apr 17, 2012
  9. 3/4 builtin/merge.c: collect other parents earlyJunio C Hamano, Apr 17, 2012
  10. 4/4 builtin/merge.c: reduce parents earlyJunio C Hamano, Apr 17, 2012
  11. Junio C HamanoApr 16, 2012
  12. Linus TorvaldsApr 16, 2012
  13. Linus TorvaldsApr 16, 2012
  14. Michał KiedrowiczApr 16, 2012
  15. Linus TorvaldsApr 17, 2012
  16. git-merge: Reduce heads before trying to merge themMichał Kiedrowicz, Apr 17, 2012
  17. Junio C HamanoApr 17, 2012
  18. Linus TorvaldsApr 17, 2012
  19. Junio C HamanoApr 17, 2012
  20. Michał KiedrowiczApr 18, 2012
  21. Junio C HamanoApr 18, 2012
  22. Junio C HamanoApr 19, 2012

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.