git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/4] upload-pack: use repository struct to get config
Date: Mon, 4 Mar 2024 08:45:02 +0100	[thread overview]
Message-ID: <ZeV7_obKou-jtyA-@tanuki> (raw)
In-Reply-To: <20240228224647.GA1158898@coredump.intra.peff.net>

[-- Attachment #1: Type: text/plain, Size: 2587 bytes --]

On Wed, Feb 28, 2024 at 05:46:47PM -0500, Jeff King wrote:
> 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

Nit: s/starting/start

Patrick

> 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>
> ---
>  upload-pack.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/upload-pack.c b/upload-pack.c
> index 2537affa90..e156c1e472 100644
> --- a/upload-pack.c
> +++ b/upload-pack.c
> @@ -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) {
> -- 
> 2.44.0.rc2.424.gbdbf4d014b
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2024-03-04  7:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28 22:46 [PATCH 0/4] some v2 capability advertisement cleanups Jeff King
2024-02-28 22:46 ` [PATCH 1/4] upload-pack: use repository struct to get config Jeff King
2024-03-04  7:45   ` Patrick Steinhardt [this message]
2024-02-28 22:47 ` [PATCH 2/4] upload-pack: centralize setup of sideband-all config Jeff King
2024-02-28 22:48 ` [PATCH 3/4] upload-pack: use existing config mechanism for advertisement Jeff King
2024-02-28 22:50 ` [PATCH 4/4] upload-pack: only accept packfile-uris if we advertised it Jeff King
2024-02-28 23:43   ` Junio C Hamano
2024-02-29  5:42   ` Jeff King
2024-02-29 16:34     ` Junio C Hamano
2024-03-01  7:10       ` Jeff King
2024-03-04  7:45   ` Patrick Steinhardt
2024-02-28 23:51 ` [PATCH 0/4] some v2 capability advertisement cleanups Junio C Hamano
2024-02-29  0:44   ` Jeff King
2024-03-04  7:44 ` Patrick Steinhardt
2024-03-04 10:02   ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZeV7_obKou-jtyA-@tanuki \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).