diff mbox series

[07/12] upload-pack: pass upload_pack_data to upload_pack_config()

Message ID 20200527164742.23067-8-chriscool@tuxfamily.org (mailing list archive)
State New, archived
Headers show
Series upload-pack: use 'struct upload_pack_data' thoroughly, part 2 | expand

Commit Message

Christian Couder May 27, 2020, 4:47 p.m. UTC
As we cleanup 'upload-pack.c' by using 'struct upload_pack_data'
more thoroughly, let's pass that struct to upload_pack_config(),
so that this function can use all the fields of the struct.

This will be used in followup commits to move static variables
that are set in upload_pack_config() into 'upload_pack_data'.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 upload-pack.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Jeff King May 27, 2020, 6:36 p.m. UTC | #1
On Wed, May 27, 2020 at 06:47:37PM +0200, Christian Couder wrote:

> As we cleanup 'upload-pack.c' by using 'struct upload_pack_data'
> more thoroughly, let's pass that struct to upload_pack_config(),
> so that this function can use all the fields of the struct.
> 
> This will be used in followup commits to move static variables
> that are set in upload_pack_config() into 'upload_pack_data'.

Makes sense...

> @@ -1153,10 +1153,10 @@ void upload_pack(struct upload_pack_options *options)
>  	struct packet_reader reader;
>  	struct upload_pack_data data;
>  
> -	git_config(upload_pack_config, NULL);
> -
>  	upload_pack_data_init(&data);
>  
> +	git_config(upload_pack_config, &data);
> +

...and we know there can't be any init-time dependency issues with this
reordering, because the original could not have accessed &data at all.

Looks good.

-Peff
diff mbox series

Patch

diff --git a/upload-pack.c b/upload-pack.c
index d211bebc0e..101e28f478 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1108,7 +1108,7 @@  static int find_symref(const char *refname, const struct object_id *oid,
 	return 0;
 }
 
-static int upload_pack_config(const char *var, const char *value, void *unused)
+static int upload_pack_config(const char *var, const char *value, void *cb_data)
 {
 	if (!strcmp("uploadpack.allowtipsha1inwant", var)) {
 		if (git_config_bool(var, value))
@@ -1153,10 +1153,10 @@  void upload_pack(struct upload_pack_options *options)
 	struct packet_reader reader;
 	struct upload_pack_data data;
 
-	git_config(upload_pack_config, NULL);
-
 	upload_pack_data_init(&data);
 
+	git_config(upload_pack_config, &data);
+
 	data.stateless_rpc = options->stateless_rpc;
 	data.daemon_mode = options->daemon_mode;
 	data.timeout = options->timeout;
@@ -1486,11 +1486,11 @@  int upload_pack_v2(struct repository *r, struct argv_array *keys,
 
 	clear_object_flags(ALL_FLAGS);
 
-	git_config(upload_pack_config, NULL);
-
 	upload_pack_data_init(&data);
 	data.use_sideband = LARGE_PACKET_MAX;
 
+	git_config(upload_pack_config, &data);
+
 	while (state != FETCH_DONE) {
 		switch (state) {
 		case FETCH_PROCESS_ARGS: