[09/12] upload-pack: move allow_filter to upload_pack_data
diff mbox series

Message ID 20200527164742.23067-10-chriscool@tuxfamily.org
State New
Headers show
Series
  • upload-pack: use 'struct upload_pack_data' thoroughly, part 2
Related show

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_filter' 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 | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

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

> As we cleanup 'upload-pack.c' by using 'struct upload_pack_data'
> more thoroughly, let's move the 'allow_filter' 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'm not sure that's true. It should be reflecting the
uploadpack.allowfilter config in both cases. This final hunk:

> @@ -1329,7 +1331,7 @@ static void process_args(struct packet_reader *request,
>  			continue;
>  		}
>  
> -		if (allow_filter && skip_prefix(arg, "filter ", &p)) {
> +		if (data->allow_filter && skip_prefix(arg, "filter ", &p)) {
>  			list_objects_filter_die_if_populated(&data->filter_options);
>  			parse_list_objects_filter(&data->filter_options, p);
>  			continue;

is v2 respecting it.

-Peff

Patch
diff mbox series

diff --git a/upload-pack.c b/upload-pack.c
index e00631a703..10bafeb8b6 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -55,7 +55,6 @@  static int shallow_nr;
 static struct object_array extra_edge_obj;
 static const char *pack_objects_hook;
 
-static int allow_filter;
 static int allow_ref_in_want;
 
 static int allow_sideband_all;
@@ -99,6 +98,8 @@  struct upload_pack_data {
 	unsigned done : 1;
 	unsigned no_done : 1;
 	unsigned filter_capability_requested : 1;
+
+	unsigned allow_filter : 1;
 };
 
 static void upload_pack_data_init(struct upload_pack_data *data)
@@ -979,7 +980,8 @@  static void receive_needs(struct upload_pack_data *data,
 			data->no_progress = 1;
 		if (parse_feature_request(features, "include-tag"))
 			data->use_include_tag = 1;
-		if (allow_filter && parse_feature_request(features, "filter"))
+		if (data->allow_filter &&
+		    parse_feature_request(features, "filter"))
 			data->filter_capability_requested = 1;
 
 		o = parse_object(the_repository, &oid_buf);
@@ -1085,7 +1087,7 @@  static int send_ref(const char *refname, const struct object_id *oid,
 				     " allow-reachable-sha1-in-want" : "",
 			     data->stateless_rpc ? " no-done" : "",
 			     symref_info.buf,
-			     allow_filter ? " filter" : "",
+			     data->allow_filter ? " filter" : "",
 			     git_user_agent_sanitized());
 		strbuf_release(&symref_info);
 	} else {
@@ -1137,7 +1139,7 @@  static int upload_pack_config(const char *var, const char *value, void *cb_data)
 		if (!data->keepalive)
 			data->keepalive = -1;
 	} else if (!strcmp("uploadpack.allowfilter", var)) {
-		allow_filter = git_config_bool(var, value);
+		data->allow_filter = git_config_bool(var, value);
 	} else if (!strcmp("uploadpack.allowrefinwant", var)) {
 		allow_ref_in_want = git_config_bool(var, value);
 	} else if (!strcmp("uploadpack.allowsidebandall", var)) {
@@ -1329,7 +1331,7 @@  static void process_args(struct packet_reader *request,
 			continue;
 		}
 
-		if (allow_filter && skip_prefix(arg, "filter ", &p)) {
+		if (data->allow_filter && skip_prefix(arg, "filter ", &p)) {
 			list_objects_filter_die_if_populated(&data->filter_options);
 			parse_list_objects_filter(&data->filter_options, p);
 			continue;