remote-curl: reduce scope of rpc_state.argv

The argv field in struct rpc_state is only used in rpc_service(), and not in any functions it directly or indirectly calls. Refactor it to become an argument of rpc_service() instead. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Feb 14, 2019 at 11:06 UTC 7d50d34fc7d9764766c13eb4f86171f241664b98
1 file changed +5 -7
remote-curl.c
+5 -7
@@ -505,7 +505,6 @@ static void output_refs(struct ref *refs)
505
506 struct rpc_state {
507 const char *service_name;
508 - const char **argv;
508 struct strbuf *stdin_preamble;
509 char *service_url;
510 char *hdr_content_type;
@@ -829,7 +828,8 @@ retry:
828 return err;
829 }
830
832 -static int rpc_service(struct rpc_state *rpc, struct discovery *heads)
831 +static int rpc_service(struct rpc_state *rpc, struct discovery *heads,
832 + const char **client_argv)
833 {
834 const char *svc = rpc->service_name;
835 struct strbuf buf = STRBUF_INIT;
@@ -840,7 +840,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)
840 client.in = -1;
841 client.out = -1;
842 client.git_cmd = 1;
843 - client.argv = rpc->argv;
843 + client.argv = client_argv;
844 if (start_command(&client))
845 exit(1);
846 if (preamble)
@@ -978,11 +978,10 @@ static int fetch_git(struct discovery *heads,
978
979 memset(&rpc, 0, sizeof(rpc));
980 rpc.service_name = "git-upload-pack",
981 - rpc.argv = args.argv;
981 rpc.stdin_preamble = &preamble;
982 rpc.gzip_request = 1;
983
985 - err = rpc_service(&rpc, heads);
984 + err = rpc_service(&rpc, heads, args.argv);
985 if (rpc.result.len)
986 write_or_die(1, rpc.result.buf, rpc.result.len);
987 strbuf_release(&rpc.result);
@@ -1112,10 +1111,9 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
1111
1112 memset(&rpc, 0, sizeof(rpc));
1113 rpc.service_name = "git-receive-pack",
1115 - rpc.argv = args.argv;
1114 rpc.stdin_preamble = &preamble;
1115
1118 - err = rpc_service(&rpc, heads);
1116 + err = rpc_service(&rpc, heads, args.argv);
1117 if (rpc.result.len)
1118 write_or_die(1, rpc.result.buf, rpc.result.len);
1119 strbuf_release(&rpc.result);