Skip to content

Commit 7d50d34

Browse files
jonathantanmygitster
authored andcommitted
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>
1 parent 8989e19 commit 7d50d34

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

remote-curl.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ static void output_refs(struct ref *refs)
505505

506506
struct rpc_state {
507507
const char *service_name;
508-
const char **argv;
509508
struct strbuf *stdin_preamble;
510509
char *service_url;
511510
char *hdr_content_type;
@@ -829,7 +828,8 @@ static int post_rpc(struct rpc_state *rpc)
829828
return err;
830829
}
831830

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)
833833
{
834834
const char *svc = rpc->service_name;
835835
struct strbuf buf = STRBUF_INIT;
@@ -840,7 +840,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)
840840
client.in = -1;
841841
client.out = -1;
842842
client.git_cmd = 1;
843-
client.argv = rpc->argv;
843+
client.argv = client_argv;
844844
if (start_command(&client))
845845
exit(1);
846846
if (preamble)
@@ -978,11 +978,10 @@ static int fetch_git(struct discovery *heads,
978978

979979
memset(&rpc, 0, sizeof(rpc));
980980
rpc.service_name = "git-upload-pack",
981-
rpc.argv = args.argv;
982981
rpc.stdin_preamble = &preamble;
983982
rpc.gzip_request = 1;
984983

985-
err = rpc_service(&rpc, heads);
984+
err = rpc_service(&rpc, heads, args.argv);
986985
if (rpc.result.len)
987986
write_or_die(1, rpc.result.buf, rpc.result.len);
988987
strbuf_release(&rpc.result);
@@ -1112,10 +1111,9 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
11121111

11131112
memset(&rpc, 0, sizeof(rpc));
11141113
rpc.service_name = "git-receive-pack",
1115-
rpc.argv = args.argv;
11161114
rpc.stdin_preamble = &preamble;
11171115

1118-
err = rpc_service(&rpc, heads);
1116+
err = rpc_service(&rpc, heads, args.argv);
11191117
if (rpc.result.len)
11201118
write_or_die(1, rpc.result.buf, rpc.result.len);
11211119
strbuf_release(&rpc.result);

0 commit comments

Comments
 (0)