@matheusbsbs / matheus-bagliano / commits / f34f2b0b38
Fork 0

Fix read-tree merging more than 3 trees using 3-way merge

For multi-base merges, we allowed read-tree -m to take more than three trees (the last two are our and their branches, and all the earlier ones, typically one but potentially more, are used as the merge base). Unfortunately, the conversion done by commit 933bf40 broke this. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 15, 2007 at 15:45 UTC f34f2b0b384b42f7a0d0d92966c145b05fe55217
1 file changed +6 -2
builtin-read-tree.c
+6 -2
@@ -13,8 +13,9 @@
13 #include "dir.h"
14 #include "builtin.h"
15
16 +#define MAX_TREES 4
17 static int nr_trees;
17 -static struct tree *trees[4];
18 +static struct tree *trees[MAX_TREES];
19
20 static int list_tree(unsigned char *sha1)
21 {
@@ -96,7 +97,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
97 {
98 int i, newfd, stage = 0;
99 unsigned char sha1[20];
99 - struct tree_desc t[3];
100 + struct tree_desc t[MAX_TREES];
101 struct unpack_trees_options opts;
102
103 memset(&opts, 0, sizeof(opts));
@@ -263,6 +264,9 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
264 opts.head_idx = 1;
265 }
266
267 + if (MAX_TREES < nr_trees)
268 + die("I cannot read more than %d trees", MAX_TREES);
269 +
270 for (i = 0; i < nr_trees; i++) {
271 struct tree *tree = trees[i];
272 parse_tree(tree);