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:
authorGlen Choo <chooglen@google.com>2023-06-28 22:26:27 +0300
committerJunio C Hamano <gitster@pobox.com>2023-06-29 00:06:40 +0300
commit8868b1ebfb8274a3ef90e1ba69ed45be94f6c3fb (patch)
tree24c7285d318bc7573aa6e89efcc8edf3e1d74f0d /upload-pack.c
parentdc9020849773393e47c37c2834a5582374b55ecc (diff)
config: pass kvi to die_bad_number()
Plumb "struct key_value_info" through all code paths that end in die_bad_number(), which lets us remove the helper functions that read analogous values from "struct config_reader". As a result, nothing reads config_reader.config_kvi any more, so remove that too. In config.c, this requires changing the signature of git_configset_get_value() to 'return' "kvi" in an out parameter so that git_configset_get_<type>() can pass it to git_config_<type>(). Only numeric types will use "kvi", so for non-numeric types (e.g. git_configset_get_string()), pass NULL to indicate that the out parameter isn't needed. Outside of config.c, config callbacks now need to pass "ctx->kvi" to any of the git_config_<type>() functions that parse a config string into a number type. Included is a .cocci patch to make that refactor. The only exceptional case is builtin/config.c, where git_config_<type>() is called outside of a config callback (namely, on user-provided input), so config source information has never been available. In this case, die_bad_number() defaults to a generic, but perfectly descriptive message. Let's provide a safe, non-NULL for "kvi" anyway, but make sure not to change the message. Signed-off-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 951fd1f9c2..c03415a546 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1275,7 +1275,8 @@ static int find_symref(const char *refname,
}
static int parse_object_filter_config(const char *var, const char *value,
- struct upload_pack_data *data)
+ const struct key_value_info *kvi,
+ struct upload_pack_data *data)
{
struct strbuf buf = STRBUF_INIT;
const char *sub, *key;
@@ -1302,7 +1303,8 @@ static int parse_object_filter_config(const char *var, const char *value,
}
string_list_insert(&data->allowed_filters, buf.buf)->util =
(void *)(intptr_t)1;
- data->tree_filter_max_depth = git_config_ulong(var, value);
+ data->tree_filter_max_depth = git_config_ulong(var, value,
+ kvi);
}
strbuf_release(&buf);
@@ -1310,7 +1312,7 @@ static int parse_object_filter_config(const char *var, const char *value,
}
static int upload_pack_config(const char *var, const char *value,
- const struct config_context *ctx UNUSED,
+ const struct config_context *ctx,
void *cb_data)
{
struct upload_pack_data *data = cb_data;
@@ -1331,7 +1333,7 @@ static int upload_pack_config(const char *var, const char *value,
else
data->allow_uor &= ~ALLOW_ANY_SHA1;
} else if (!strcmp("uploadpack.keepalive", var)) {
- data->keepalive = git_config_int(var, value);
+ data->keepalive = git_config_int(var, value, ctx->kvi);
if (!data->keepalive)
data->keepalive = -1;
} else if (!strcmp("uploadpack.allowfilter", var)) {
@@ -1346,7 +1348,7 @@ static int upload_pack_config(const char *var, const char *value,
data->advertise_sid = git_config_bool(var, value);
}
- if (parse_object_filter_config(var, value, data) < 0)
+ if (parse_object_filter_config(var, value, ctx->kvi, data) < 0)
return -1;
return parse_hide_refs_config(var, value, "uploadpack", &data->hidden_refs);