]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tree-walk.c: break circular dependency with unpack-trees
authorJeff King <peff@peff.net>
Sat, 1 Feb 2020 11:39:22 +0000 (06:39 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 Feb 2020 18:32:15 +0000 (10:32 -0800)
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 ca885a4fe6 (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 <newren@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
tree-walk.c
tree-walk.h
unpack-trees.h

index 3093cf7098ba6ec8e3c10098484845fc7e6e12b9..bb0ad34c5457d3b812663fb41ece1804fff6ef7a 100644 (file)
@@ -1,6 +1,5 @@
 #include "cache.h"
 #include "tree-walk.h"
-#include "unpack-trees.h"
 #include "dir.h"
 #include "object-store.h"
 #include "tree.h"
@@ -410,7 +409,7 @@ int traverse_trees(struct index_state *istate,
                   struct traverse_info *info)
 {
        int error = 0;
-       struct name_entry entry[MAX_UNPACK_TREES];
+       struct name_entry entry[MAX_TRAVERSE_TREES];
        int i;
        struct tree_desc_x tx[ARRAY_SIZE(entry)];
        struct strbuf base = STRBUF_INIT;
index 826396c8edc7eb3d38e2b8c6d8836d28cd27c5db..a5058469e9b3a83fdd58a04f2af72690742d08bd 100644 (file)
@@ -3,6 +3,8 @@
 
 #include "cache.h"
 
+#define MAX_TRAVERSE_TREES 8
+
 /**
  * The tree walking API is used to traverse and inspect trees.
  */
index ca94a421a5dd8451ccf4ef0ec1aa35ec25d612dc..ae1557fb8046c957dfa1feef6349a0117617f389 100644 (file)
@@ -6,7 +6,7 @@
 #include "string-list.h"
 #include "tree-walk.h"
 
-#define MAX_UNPACK_TREES 8
+#define MAX_UNPACK_TREES MAX_TRAVERSE_TREES
 
 struct cache_entry;
 struct unpack_trees_options;