Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2020-08-03 21:00:17 +0300
committerJunio C Hamano <gitster@pobox.com>2020-08-04 04:03:46 +0300
commit5b01a4e8ff19fa9797a67b53df2db0a1a574fe81 (patch)
tree611f65243e8bec6abe5c6192fb25f35e888bf95a /upload-pack.c
parent6dd3456a8ccbad6a0a6a31bc7192025617114243 (diff)
upload-pack.c: introduce 'uploadpackfilter.tree.maxDepth'
In b79cf959b2 (upload-pack.c: allow banning certain object filter(s), 2020-02-26), we introduced functionality to disallow certain object filters from being chosen from within 'git upload-pack'. Traditionally, administrators use this functionality to disallow filters that are known to perform slowly, for e.g., those that do not have bitmap-level filtering. In the past, the '--filter=tree:<n>' was one such filter that does not have bitmap-level filtering support, and so was likely to be banned by administrators. However, in the previous couple of commits, we introduced bitmap-level filtering for the case when 'n' is equal to '0', i.e., as if we had a '--filter=tree:none' choice. While it would be sufficient to simply write $ git config uploadpackfilter.tree.allow true (since it would allow all values of 'n'), we would like to be able to allow this filter for certain values of 'n', i.e., those no greater than some pre-specified maximum. In order to do this, introduce a new configuration key, as follows: $ git config uploadpackfilter.tree.maxDepth <m> where '<m>' specifies the maximum allowed value of 'n' in the filter 'tree:n'. Administrators who wish to allow for only the value '0' can write: $ git config uploadpackfilter.tree.allow true $ git config uploadpackfilter.tree.maxDepth 0 which allows '--filter=tree:0', but no other values. Signed-off-by: Taylor Blau <me@ttaylorr.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 5a9d767a12..fb9c7e1315 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -105,6 +105,7 @@ struct upload_pack_data {
unsigned use_include_tag : 1;
unsigned allow_filter : 1;
unsigned allow_filter_fallback : 1;
+ unsigned long tree_filter_max_depth;
unsigned done : 1; /* v2 only */
unsigned allow_ref_in_want : 1; /* v2 only */
@@ -136,6 +137,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)
data->extra_edge_obj = extra_edge_obj;
data->allowed_filters = allowed_filters;
data->allow_filter_fallback = 1;
+ data->tree_filter_max_depth = ULONG_MAX;
packet_writer_init(&data->writer, 1);
data->keepalive = 5;
@@ -1019,6 +1021,13 @@ static void check_one_filter(struct upload_pack_data *data,
if (!allowed)
send_err_and_die(data, "filter '%s' not supported", key);
+
+ if (opts->choice == LOFC_TREE_DEPTH &&
+ opts->tree_exclude_depth > data->tree_filter_max_depth)
+ send_err_and_die(data,
+ "tree filter allows max depth %lu, but got %lu",
+ data->tree_filter_max_depth,
+ opts->tree_exclude_depth);
}
static void check_filter_recurse(struct upload_pack_data *data,
@@ -1247,6 +1256,15 @@ static int parse_object_filter_config(const char *var, const char *value,
if (!strcmp(key, "allow"))
string_list_insert(&data->allowed_filters, buf.buf)->util =
(void *)(intptr_t)git_config_bool(var, value);
+ else if (!strcmp(buf.buf, "tree") && !strcmp(key, "maxdepth")) {
+ if (!value) {
+ strbuf_release(&buf);
+ return config_error_nonbool(var);
+ }
+ string_list_insert(&data->allowed_filters, buf.buf)->util =
+ (void *)(intptr_t)1;
+ data->tree_filter_max_depth = git_config_ulong(var, value);
+ }
strbuf_release(&buf);
return 0;