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

[PATCH] builtin-commit: avoid using reduce_heads()

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Sep 26, 2008, 00:35 UTC
Message-ID
<1222389359-22191-1-git-send-email-vmiklos@frugalware.org>
In-Reply-To
<20080925235029.GA15837@neumann>

reduce_heads() can filter "duplicated" parents, where "duplicated" means: A is duplicated if both A and B are parent candidates and A is reachable from B. Doing so in builtin-merge makes sense, but not in builtin-commit, because this breaks git merge --no-commit --no-ff.

Test case by SZEDER Gabor <szeder@ira.uka.de> ---

Here is a patch that fixes the problem for me. In fact I think it would be nice if somehow git-merge could tell git-commit that 'do not reduce heads now' and in other cases it could still do so, but:

	1) This is not something git-commit did in the past, either.
	2) I have no idea what would be the right interface to do so
           (maybe a new MERGE_FOO file under .git?)
 builtin-commit.c |    1 -
 t/t7600-merge.sh |    9 +++++++++
 2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 55e1087..9daab0a 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -988,7 +988,6 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		reflog_msg = "commit";
 		pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
 	}
-	parents = reduce_heads(parents);
 
 	/* Finally, get the commit message */
 	strbuf_init(&sb, 0);
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 9516f54..98cfc53 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -511,4 +511,13 @@ test_expect_success 'in-index merge' '
 
 test_debug 'gitk --all'
 
+test_expect_success 'merge --no-ff --no-commit && commit' '
+	git reset --hard c0 &&
+	git merge --no-ff --no-commit c1 &&
+	EDITOR=: git commit &&
+	verify_parents $c0 $c1
+'
+
+test_debug 'gitk --all'
+
 test_done
-- 
1.6.0.2
Previous: SZEDER GáborNext: SZEDER Gábor
Message 2 of 22 in “[BUG] merge --no-ff --no-commit && commit”
  1. SZEDER GáborSep 25, 2008
  2. builtin-commit: avoid using reduce_heads()Miklos Vajna, Sep 26, 2008
  3. SZEDER GáborSep 26, 2008
  4. Miklos VajnaSep 26, 2008
  5. Miklos VajnaSep 26, 2008
  6. builtin-commit: avoid always using reduce_heads()Miklos Vajna, Sep 26, 2008
  7. Shawn O. PearceSep 26, 2008
  8. builtin-commit: avoid always using reduce_heads()Miklos Vajna, Sep 26, 2008
  9. Shawn O. PearceOct 3, 2008
  10. builtin-commit: avoid always using reduce_heads()Miklos Vajna, Oct 3, 2008
  11. Shawn O. PearceOct 3, 2008
  12. builtin-commit: avoid always using reduce_heads()Miklos Vajna, Oct 5, 2008
  13. Shawn O. PearceOct 6, 2008
  14. builtin-commit: use reduce_heads() only when appropriateSZEDER Gábor, Oct 3, 2008
  15. Miklos VajnaOct 5, 2008
  16. Jakub NarebskiSep 26, 2008
  17. Miklos VajnaSep 26, 2008
  18. Jakub NarebskiSep 26, 2008
  19. Miklos VajnaSep 29, 2008
  20. Miklos VajnaSep 29, 2008
  21. Jakub NarebskiSep 29, 2008
  22. SZEDER GáborSep 27, 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.