diff mbox series

[04/12] upload-pack: move filter_capability_requested to upload_pack_data

Message ID 20200527164742.23067-5-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 filter_capability_requested
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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

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

> As we cleanup 'upload-pack.c' by using 'struct upload_pack_data'
> more thoroughly, let's move the filter_capability_requested
> 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.

Looks good, though this is another candidate for grouping/commenting in
the struct that it's v0-only.

-Peff
diff mbox series

Patch

diff --git a/upload-pack.c b/upload-pack.c
index a5a9750890..e81b326690 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -57,7 +57,6 @@  static struct object_array extra_edge_obj;
 static int keepalive = 5;
 static const char *pack_objects_hook;
 
-static int filter_capability_requested;
 static int allow_filter;
 static int allow_ref_in_want;
 
@@ -94,6 +93,7 @@  struct upload_pack_data {
 	unsigned use_include_tag : 1;
 	unsigned done : 1;
 	unsigned no_done : 1;
+	unsigned filter_capability_requested : 1;
 };
 
 static void upload_pack_data_init(struct upload_pack_data *data)
@@ -937,7 +937,7 @@  static void receive_needs(struct upload_pack_data *data,
 			continue;
 
 		if (skip_prefix(reader->line, "filter ", &arg)) {
-			if (!filter_capability_requested)
+			if (!data->filter_capability_requested)
 				die("git upload-pack: filtering capability not negotiated");
 			list_objects_filter_die_if_populated(&data->filter_options);
 			parse_list_objects_filter(&data->filter_options, arg);
@@ -970,7 +970,7 @@  static void receive_needs(struct upload_pack_data *data,
 		if (parse_feature_request(features, "include-tag"))
 			data->use_include_tag = 1;
 		if (allow_filter && parse_feature_request(features, "filter"))
-			filter_capability_requested = 1;
+			data->filter_capability_requested = 1;
 
 		o = parse_object(the_repository, &oid_buf);
 		if (!o) {