Skip to content

Commit 5290d45

Browse files
peffgitster
authored andcommitted
tree-walk.c: break circular dependency with unpack-trees
The unpack-trees API depends on the tree-walk API. But we've recently introduced a dependency in tree-walk.c on MAX_UNPACK_TREES, which doesn't otherwise care about unpack-trees at all. Let's break that dependency by reversing the constants: we'll introduce a new MAX_TRAVERSE_TREES which belongs to the tree-walk API. And then we can define MAX_UNPACK_TREES in terms of that (since unpack-trees cannot possibly work with more trees than it can traverse at once via tree-walk). The value for both will remain at 8. This is somewhat arbitrary and probably more than is necessary, per ca885a4 (read-tree() and unpack_trees(): use consistent limit, 2008-03-13), but there's not really any pressing need to reduce it. Suggested-by: Elijah Newren <[email protected]> Signed-off-by: Jeff King <[email protected]> Acked-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8dd40c0 commit 5290d45

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

tree-walk.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "cache.h"
22
#include "tree-walk.h"
3-
#include "unpack-trees.h"
43
#include "dir.h"
54
#include "object-store.h"
65
#include "tree.h"
@@ -410,7 +409,7 @@ int traverse_trees(struct index_state *istate,
410409
struct traverse_info *info)
411410
{
412411
int error = 0;
413-
struct name_entry entry[MAX_UNPACK_TREES];
412+
struct name_entry entry[MAX_TRAVERSE_TREES];
414413
int i;
415414
struct tree_desc_x tx[ARRAY_SIZE(entry)];
416415
struct strbuf base = STRBUF_INIT;

tree-walk.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "cache.h"
55

6+
#define MAX_TRAVERSE_TREES 8
7+
68
/**
79
* The tree walking API is used to traverse and inspect trees.
810
*/

unpack-trees.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "string-list.h"
77
#include "tree-walk.h"
88

9-
#define MAX_UNPACK_TREES 8
9+
#define MAX_UNPACK_TREES MAX_TRAVERSE_TREES
1010

1111
struct cache_entry;
1212
struct unpack_trees_options;

0 commit comments

Comments
 (0)