upload-pack: use repository struct to get config

Our upload_pack_v2() function gets a repository struct, but we ignore it
totally.  In practice this doesn't cause any problems, as it will never
differ from the_repository. But in the spirit of taking a small step
towards getting rid of the_repository, let's at least starting using it
to grab config. There are probably other spots that could benefit, but
it's a start.

Note that we don't need to pass the repo for protected_config(); the
whole point there is that we are not looking at repo config, so there is
no repo-specific version of the function.

For the v0 version of the protocol, we're not passed a repository
struct, so we'll continue to use the_repository there.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2024-02-28 17:46:47 -05:00 коммит произвёл Junio C Hamano
Родитель 3c2a3fdc38
Коммит 922fdefb84
1 изменённых файлов: 6 добавлений и 5 удалений

Просмотреть файл

@ -1385,9 +1385,10 @@ static int upload_pack_protected_config(const char *var, const char *value,
return 0;
}
static void get_upload_pack_config(struct upload_pack_data *data)
static void get_upload_pack_config(struct repository *r,
struct upload_pack_data *data)
{
git_config(upload_pack_config, data);
repo_config(r, upload_pack_config, data);
git_protected_config(upload_pack_protected_config, data);
}
@ -1398,7 +1399,7 @@ void upload_pack(const int advertise_refs, const int stateless_rpc,
struct upload_pack_data data;
upload_pack_data_init(&data);
get_upload_pack_config(&data);
get_upload_pack_config(the_repository, &data);
data.stateless_rpc = stateless_rpc;
data.timeout = timeout;
@ -1771,7 +1772,7 @@ enum fetch_state {
FETCH_DONE,
};
int upload_pack_v2(struct repository *r UNUSED, struct packet_reader *request)
int upload_pack_v2(struct repository *r, struct packet_reader *request)
{
enum fetch_state state = FETCH_PROCESS_ARGS;
struct upload_pack_data data;
@ -1780,7 +1781,7 @@ int upload_pack_v2(struct repository *r UNUSED, struct packet_reader *request)
upload_pack_data_init(&data);
data.use_sideband = LARGE_PACKET_MAX;
get_upload_pack_config(&data);
get_upload_pack_config(r, &data);
while (state != FETCH_DONE) {
switch (state) {