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

[RFC/PATCH] commit-tree: bump MAX_PARENTS to 128

From
Jeff King <peff@peff.net>
Date
Feb 26, 2007, 12:15 UTC
Message-ID
<20070226121557.GA18114@coredump.intra.peff.net>

This limit doesn't seem to come into effect anywhere else; it's simply an arbitrary limit to make memory allocation easier. It's used to declare a single static array of 20-byte hashes, so this increase wastes about 2K. --- This limit is arbitrary; should it be ridiculously high (I think 128 is already ridiculous, but we could go to 1024 and waste 20K). Or should it simply allocate dynamically?

I ran into this while trying to make an octopus with 25 heads. I have a set of 25 small repositories imported from CVS. They no longer see active development, but I want to keep them around for historical purposes. Checking out 25 repos is a pain, so I wanted to put them all in one repo. However, I didn't just want the histories on separate branches; I wanted everything checked out at once. So I did:

  rm -f .git/MERGE_HEAD
  for i in $repos; do
    git fetch ../$i $i
    git read-tree --prefix=$i/ $i
    git checkout -- $i
    git rev-parse $i >>.git/MERGE_HEAD
  done
  git commit

Which of course barfed on the giant octopus. Bumping up the limit allowed it to happen with no visible problems (the history browsing code works fine). Yes, I obviously could have done a series of 25 pair-wise merges (or even 2 16-way octopus merges), but I think this more closely represents what I'm trying to accomplish.

 builtin-commit-tree.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c
index 2a818a0..48dbf1d 100644
--- a/builtin-commit-tree.c
+++ b/builtin-commit-tree.c
@@ -60,7 +60,7 @@ static void check_valid(unsigned char *sha1, const char *expect)
  * Having more than two parents is not strange at all, and this is
  * how multi-way merges are represented.
  */
-#define MAXPARENT (16)
+#define MAXPARENT (128)
 static unsigned char parent_sha1[MAXPARENT][20];
 
 static const char commit_tree_usage[] = "git-commit-tree <sha1> [-p <sha1>]* < changelog";
-- 
1.5.0.1.793.gedfd5-dirty
Next: Shawn O. Pearce
Message 1 of 12 in “commit-tree: bump MAX_PARENTS to 128”
  1. commit-tree: bump MAX_PARENTS to 128Jeff King, Feb 26, 2007
  2. Shawn O. PearceFeb 26, 2007
  3. Johannes SchindelinFeb 26, 2007
  4. Junio C HamanoFeb 27, 2007
  5. Jeff KingFeb 27, 2007
  6. Junio C HamanoFeb 27, 2007
  7. Jeff KingFeb 27, 2007
  8. Junio C HamanoFeb 27, 2007
  9. Andy ParkinsFeb 27, 2007
  10. Jeff KingFeb 27, 2007
  11. Jakub NarebskiFeb 27, 2007
  12. Johannes SchindelinFeb 27, 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.