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

Clean-up read-tree error condition.

This is a follow-up to f34f2b0b; list_tree() function is where it first notices that the command line fed too many trees for us to handle, so move the error exit message to there, and raise the MAX_TREES to 8 (not that it matters very much in practice). Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 16, 2007 at 19:24 UTC a9ab2009dbbf769aadd52957950c1bad60a0c8fd
1 file changed +3 -6
builtin-read-tree.c
+3 -6
@@ -13,7 +13,7 @@
13 #include "dir.h"
14 #include "builtin.h"
15
16 -#define MAX_TREES 4
16 +#define MAX_TREES 8
17 static int nr_trees;
18 static struct tree *trees[MAX_TREES];
19
@@ -21,8 +21,8 @@ static int list_tree(unsigned char *sha1)
21 {
22 struct tree *tree;
23
24 - if (nr_trees >= 4)
25 - return -1;
24 + if (nr_trees >= MAX_TREES)
25 + die("I cannot read more than %d trees", MAX_TREES);
26 tree = parse_tree_indirect(sha1);
27 if (!tree)
28 return -1;
@@ -264,9 +264,6 @@ 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 -
267 for (i = 0; i < nr_trees; i++) {
268 struct tree *tree = trees[i];
269 parse_tree(tree);