diff mbox series

[10/12] upload-pack: move allow_ref_in_want to upload_pack_data

Message ID 20200527164742.23067-11-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 move the 'allow_ref_in_want' static
variable into this struct.

It is only used by protocol v0 code since protocol v2 assumes
certain baseline capabilities, but rolling it into
upload_pack_data and just letting v2 code ignore it as it does
now is more coherent and cleaner.

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

Comments

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

> As we cleanup 'upload-pack.c' by using 'struct upload_pack_data'
> more thoroughly, let's move the 'allow_ref_in_want' static
> variable into this struct.
> 
> It is only used by protocol v0 code since protocol v2 assumes
> certain baseline capabilities, but rolling it into
> upload_pack_data and just letting v2 code ignore it as it does
> now is more coherent and cleaner.

I think this is opposite, isn't it? Ref-in-want is a v2-only feature,
and v0 does not support it at all (though it could).

-Peff
diff mbox series

Patch

diff --git a/upload-pack.c b/upload-pack.c
index 10bafeb8b6..b5647eb47c 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -55,8 +55,6 @@  static int shallow_nr;
 static struct object_array extra_edge_obj;
 static const char *pack_objects_hook;
 
-static int allow_ref_in_want;
-
 static int allow_sideband_all;
 
 struct upload_pack_data {
@@ -100,6 +98,7 @@  struct upload_pack_data {
 	unsigned filter_capability_requested : 1;
 
 	unsigned allow_filter : 1;
+	unsigned allow_ref_in_want : 1;
 };
 
 static void upload_pack_data_init(struct upload_pack_data *data)
@@ -1141,7 +1140,7 @@  static int upload_pack_config(const char *var, const char *value, void *cb_data)
 	} else if (!strcmp("uploadpack.allowfilter", var)) {
 		data->allow_filter = git_config_bool(var, value);
 	} else if (!strcmp("uploadpack.allowrefinwant", var)) {
-		allow_ref_in_want = git_config_bool(var, value);
+		data->allow_ref_in_want = git_config_bool(var, value);
 	} else if (!strcmp("uploadpack.allowsidebandall", var)) {
 		allow_sideband_all = git_config_bool(var, value);
 	} else if (!strcmp("core.precomposeunicode", var)) {
@@ -1285,7 +1284,7 @@  static void process_args(struct packet_reader *request,
 		/* process want */
 		if (parse_want(&data->writer, arg, &data->want_obj))
 			continue;
-		if (allow_ref_in_want &&
+		if (data->allow_ref_in_want &&
 		    parse_want_ref(&data->writer, arg, &data->wanted_refs,
 				   &data->want_obj))
 			continue;