diff mbox series

[11/13] upload-pack: remove static variable 'stateless_rpc'

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

Commit Message

Christian Couder May 15, 2020, 10:04 a.m. UTC
As we cleanup 'upload-pack.c' by using 'struct upload_pack_data'
more thoroughly, let's remove the 'stateless_rpc' static
variable, as we can now use the field of 'struct upload_pack_data'
with the same name instead.

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

Comments

Jeff King May 15, 2020, 6:38 p.m. UTC | #1
On Fri, May 15, 2020 at 12:04:52PM +0200, Christian Couder wrote:

> As we cleanup 'upload-pack.c' by using 'struct upload_pack_data'
> more thoroughly, let's remove the 'stateless_rpc' static
> variable, as we can now use the field of 'struct upload_pack_data'
> with the same name instead.

OK, here's where all of the struct passing in the previous commits
begins to pay off, as we get to start deleting globals:

>  static int use_sideband;
> -static int stateless_rpc;
>  static const char *pack_objects_hook;

Definitely a positive direction, and it should be obvious that all of
the appropriate spots have been converted because the old variable goes
away.

-Peff
diff mbox series

Patch

diff --git a/upload-pack.c b/upload-pack.c
index 680c38cc13..4ac40c5b04 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -63,7 +63,6 @@  static int keepalive = 5;
  * otherwise maximum packet size (up to 65520 bytes).
  */
 static int use_sideband;
-static int stateless_rpc;
 static const char *pack_objects_hook;
 
 static int filter_capability_requested;
@@ -449,7 +448,7 @@  static int get_common_commits(struct upload_pack_data *data,
 				packet_write_fmt(1, "ACK %s\n", last_hex);
 				return 0;
 			}
-			if (stateless_rpc)
+			if (data->stateless_rpc)
 				exit(0);
 			got_common = 0;
 			got_other = 0;
@@ -663,7 +662,8 @@  static void check_non_tip(struct upload_pack_data *data)
 	 * uploadpack.allowReachableSHA1InWant,
 	 * non-tip requests can never happen.
 	 */
-	if (!stateless_rpc && !(allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1))
+	if (!data->stateless_rpc
+	    && !(allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1))
 		goto error;
 	if (!has_unreachable(&data->want_obj))
 		/* All the non-tip ones are ancestors of what we advertised */
@@ -1074,7 +1074,7 @@  static int send_ref(const char *refname, const struct object_id *oid,
 				     " allow-tip-sha1-in-want" : "",
 			     (allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1) ?
 				     " allow-reachable-sha1-in-want" : "",
-			     stateless_rpc ? " no-done" : "",
+			     data->stateless_rpc ? " no-done" : "",
 			     symref_info.buf,
 			     allow_filter ? " filter" : "",
 			     git_user_agent_sanitized());
@@ -1149,7 +1149,6 @@  void upload_pack(struct upload_pack_options *options)
 	struct packet_reader reader;
 	struct upload_pack_data data;
 
-	stateless_rpc = options->stateless_rpc;
 	timeout = options->timeout;
 	daemon_mode = options->daemon_mode;
 
@@ -1157,9 +1156,11 @@  void upload_pack(struct upload_pack_options *options)
 
 	upload_pack_data_init(&data);
 
+	data.stateless_rpc = options->stateless_rpc;
+
 	head_ref_namespaced(find_symref, &data.symref);
 
-	if (options->advertise_refs || !stateless_rpc) {
+	if (options->advertise_refs || !data.stateless_rpc) {
 		reset_timeout();
 		head_ref_namespaced(send_ref, &data);
 		for_each_namespaced_ref(send_ref, &data);