Skip to content

Commit a9ab200

Browse files
committed
Clean-up read-tree error condition.
This is a follow-up to f34f2b0; 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>
1 parent d1d028e commit a9ab200

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

builtin-read-tree.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
#include "dir.h"
1414
#include "builtin.h"
1515

16-
#define MAX_TREES 4
16+
#define MAX_TREES 8
1717
static int nr_trees;
1818
static struct tree *trees[MAX_TREES];
1919

2020
static int list_tree(unsigned char *sha1)
2121
{
2222
struct tree *tree;
2323

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);
2626
tree = parse_tree_indirect(sha1);
2727
if (!tree)
2828
return -1;
@@ -264,9 +264,6 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
264264
opts.head_idx = 1;
265265
}
266266

267-
if (MAX_TREES < nr_trees)
268-
die("I cannot read more than %d trees", MAX_TREES);
269-
270267
for (i = 0; i < nr_trees; i++) {
271268
struct tree *tree = trees[i];
272269
parse_tree(tree);

0 commit comments

Comments
 (0)