int sparse_expect_files_outside_of_patterns;
int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
unsigned long pack_size_limit_cfg;
-int max_allowed_tree_depth =
-#ifdef _MSC_VER
- /*
- * When traversing into too-deep trees, Visual C-compiled Git seems to
- * run into some internal stack overflow detection in the
- * `RtlpAllocateHeap()` function that is called from within
- * `git_inflate_init()`'s call tree. The following value seems to be
- * low enough to avoid that by letting Git exit with an error before
- * the stack overflow can occur.
- */
- 512;
-#elif defined(GIT_WINDOWS_NATIVE) && defined(__clang__) && defined(__aarch64__)
- /*
- * Similar to Visual C, it seems that on Windows/ARM64 the clang-based
- * builds have a smaller stack space available. When running out of
- * that stack space, a `STATUS_STACK_OVERFLOW` is produced. When the
- * Git command was run from an MSYS2 Bash, this unfortunately results
- * in an exit code 127. Let's prevent that by lowering the maximal
- * tree depth; This value seems to be low enough.
- */
- 1280;
-#else
- 2048;
-#endif
#ifndef PROTECT_HFS_DEFAULT
#define PROTECT_HFS_DEFAULT 0
return 0;
}
- if (!strcmp(var, "core.maxtreedepth")) {
- max_allowed_tree_depth = git_config_int(var, value, ctx->kvi);
- return 0;
- }
-
/* Add other config variables here and to Documentation/config.adoc. */
return platform_core_config(var, value, ctx, cb);
}
extern int zlib_compression_level;
extern int pack_compression_level;
extern unsigned long pack_size_limit_cfg;
-extern int max_allowed_tree_depth;
extern int precomposed_unicode;
extern int protect_hfs;
#define DEFAULT_PACKED_GIT_LIMIT \
((1024L * 1024L) * (size_t)(sizeof(void*) >= 8 ? (32 * 1024L * 1024L) : 256))
+#ifdef _MSC_VER
+ /*
+ * When traversing into too-deep trees, Visual C-compiled Git seems to
+ * run into some internal stack overflow detection in the
+ * `RtlpAllocateHeap()` function that is called from within
+ * `git_inflate_init()`'s call tree. The following value seems to be
+ * low enough to avoid that by letting Git exit with an error before
+ * the stack overflow can occur.
+ */
+#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 512
+#elif defined(GIT_WINDOWS_NATIVE) && defined(__clang__) && defined(__aarch64__)
+ /*
+ * Similar to Visual C, it seems that on Windows/ARM64 the clang-based
+ * builds have a smaller stack space available. When running out of
+ * that stack space, a `STATUS_STACK_OVERFLOW` is produced. When the
+ * Git command was run from an MSYS2 Bash, this unfortunately results
+ * in an exit code 127. Let's prevent that by lowering the maximal
+ * tree depth; This value seems to be low enough.
+ */
+#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 1280
+#else
+#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 2048
+#endif
+
int git_open_cloexec(const char *name, int flags);
#define git_open(name) git_open_cloexec(name, O_RDONLY)
!revs->include_check_obj(&tree->object, revs->include_check_data))
return;
- if (ctx->depth > max_allowed_tree_depth)
+ if (ctx->depth > revs->repo->settings.max_allowed_tree_depth)
die("exceeded maximum allowed tree depth");
failed_parse = parse_tree_gently(tree, 1);
*/
if (!repo_config_get_int(r, "index.version", &value))
r->settings.index_version = value;
+ repo_cfg_int(r, "core.maxtreedepth",
+ &r->settings.max_allowed_tree_depth,
+ DEFAULT_MAX_ALLOWED_TREE_DEPTH);
if (!repo_config_get_string_tmp(r, "core.untrackedcache", &strval)) {
int v = git_parse_maybe_bool(strval);
size_t packed_git_limit;
unsigned long big_file_threshold;
+ int max_allowed_tree_depth;
+
char *hooks_path;
};
#define REPO_SETTINGS_INIT { \
.delta_base_cache_limit = DEFAULT_DELTA_BASE_CACHE_LIMIT, \
.packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE, \
.packed_git_limit = DEFAULT_PACKED_GIT_LIMIT, \
+ .max_allowed_tree_depth = DEFAULT_MAX_ALLOWED_TREE_DEPTH, \
}
void prepare_repo_settings(struct repository *r);
void *ttree, **tptree;
int i;
- if (depth > max_allowed_tree_depth)
+ if (depth > opt->repo->settings.max_allowed_tree_depth)
die("exceeded maximum allowed tree depth");
FAST_ARRAY_ALLOC(tp, nparent);
#include "pathspec.h"
#include "json-writer.h"
#include "environment.h"
+#include "read-cache-ll.h"
static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned long size, struct strbuf *err)
{
struct strbuf base = STRBUF_INIT;
int interesting = 1;
char *traverse_path;
+ struct repository *r = istate ? istate->repo : the_repository;
- if (traverse_trees_cur_depth > max_allowed_tree_depth)
+ if (traverse_trees_cur_depth > r->settings.max_allowed_tree_depth)
return error("exceeded maximum allowed tree depth");
traverse_trees_count++;
int len, oldlen = base->len;
enum interesting retval = entry_not_interesting;
- if (depth > max_allowed_tree_depth)
+ if (depth > r->settings.max_allowed_tree_depth)
return error("exceeded maximum allowed tree depth");
if (parse_tree(tree))