From dbbcd44fb47347a3fdbee88ea21805b7f4ac0b98 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 28 Jul 2020 16:23:39 -0400 Subject: strvec: rename files from argv-array to strvec This requires updating #include lines across the code-base, but that's all fairly mechanical, and was done with: git ls-files '*.c' '*.h' | xargs perl -i -pe 's/argv-array.h/strvec.h/' Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- remote-curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'remote-curl.c') diff --git a/remote-curl.c b/remote-curl.c index 5cbc6e5002..05fb794ddd 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -10,7 +10,7 @@ #include "pkt-line.h" #include "string-list.h" #include "sideband.h" -#include "argv-array.h" +#include "strvec.h" #include "credential.h" #include "oid-array.h" #include "send-pack.h" -- cgit v1.2.3 From c972bf4cf546a56fe1c54ddde1d33ebb9f454a0f Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 28 Jul 2020 16:25:12 -0400 Subject: strvec: convert remaining callers away from argv_array name We eventually want to drop the argv_array name and just use strvec consistently. There's no particular reason we have to do it all at once, or care about interactions between converted and unconverted bits. Because of our preprocessor compat layer, the names are interchangeable to the compiler (so even a definition and declaration using different names is OK). This patch converts all of the remaining files, as the resulting diff is reasonably sized. The conversion was done purely mechanically with: git ls-files '*.c' '*.h' | xargs perl -i -pe ' s/ARGV_ARRAY/STRVEC/g; s/argv_array/strvec/g; ' We'll deal with any indentation/style fallouts separately. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- remote-curl.c | 86 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'remote-curl.c') diff --git a/remote-curl.c b/remote-curl.c index 05fb794ddd..85ce4f7e6f 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1141,41 +1141,41 @@ static int fetch_git(struct discovery *heads, struct rpc_state rpc; struct strbuf preamble = STRBUF_INIT; int i, err; - struct argv_array args = ARGV_ARRAY_INIT; + struct strvec args = STRVEC_INIT; struct strbuf rpc_result = STRBUF_INIT; - argv_array_pushl(&args, "fetch-pack", "--stateless-rpc", + strvec_pushl(&args, "fetch-pack", "--stateless-rpc", "--stdin", "--lock-pack", NULL); if (options.followtags) - argv_array_push(&args, "--include-tag"); + strvec_push(&args, "--include-tag"); if (options.thin) - argv_array_push(&args, "--thin"); + strvec_push(&args, "--thin"); if (options.verbosity >= 3) - argv_array_pushl(&args, "-v", "-v", NULL); + strvec_pushl(&args, "-v", "-v", NULL); if (options.check_self_contained_and_connected) - argv_array_push(&args, "--check-self-contained-and-connected"); + strvec_push(&args, "--check-self-contained-and-connected"); if (options.cloning) - argv_array_push(&args, "--cloning"); + strvec_push(&args, "--cloning"); if (options.update_shallow) - argv_array_push(&args, "--update-shallow"); + strvec_push(&args, "--update-shallow"); if (!options.progress) - argv_array_push(&args, "--no-progress"); + strvec_push(&args, "--no-progress"); if (options.depth) - argv_array_pushf(&args, "--depth=%lu", options.depth); + strvec_pushf(&args, "--depth=%lu", options.depth); if (options.deepen_since) - argv_array_pushf(&args, "--shallow-since=%s", options.deepen_since); + strvec_pushf(&args, "--shallow-since=%s", options.deepen_since); for (i = 0; i < options.deepen_not.nr; i++) - argv_array_pushf(&args, "--shallow-exclude=%s", + strvec_pushf(&args, "--shallow-exclude=%s", options.deepen_not.items[i].string); if (options.deepen_relative && options.depth) - argv_array_push(&args, "--deepen-relative"); + strvec_push(&args, "--deepen-relative"); if (options.from_promisor) - argv_array_push(&args, "--from-promisor"); + strvec_push(&args, "--from-promisor"); if (options.no_dependents) - argv_array_push(&args, "--no-dependents"); + strvec_push(&args, "--no-dependents"); if (options.filter) - argv_array_pushf(&args, "--filter=%s", options.filter); - argv_array_push(&args, url.buf); + strvec_pushf(&args, "--filter=%s", options.filter); + strvec_push(&args, url.buf); for (i = 0; i < nr_heads; i++) { struct ref *ref = to_fetch[i]; @@ -1195,7 +1195,7 @@ static int fetch_git(struct discovery *heads, write_or_die(1, rpc_result.buf, rpc_result.len); strbuf_release(&rpc_result); strbuf_release(&preamble); - argv_array_clear(&args); + strvec_clear(&args); return err; } @@ -1267,15 +1267,15 @@ static int push_dav(int nr_spec, const char **specs) size_t i; child.git_cmd = 1; - argv_array_push(&child.args, "http-push"); - argv_array_push(&child.args, "--helper-status"); + strvec_push(&child.args, "http-push"); + strvec_push(&child.args, "--helper-status"); if (options.dry_run) - argv_array_push(&child.args, "--dry-run"); + strvec_push(&child.args, "--dry-run"); if (options.verbosity > 1) - argv_array_push(&child.args, "--verbose"); - argv_array_push(&child.args, url.buf); + strvec_push(&child.args, "--verbose"); + strvec_push(&child.args, url.buf); for (i = 0; i < nr_spec; i++) - argv_array_push(&child.args, specs[i]); + strvec_push(&child.args, specs[i]); if (run_command(&child)) die(_("git-http-push failed")); @@ -1286,38 +1286,38 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs) { struct rpc_state rpc; int i, err; - struct argv_array args; + struct strvec args; struct string_list_item *cas_option; struct strbuf preamble = STRBUF_INIT; struct strbuf rpc_result = STRBUF_INIT; - argv_array_init(&args); - argv_array_pushl(&args, "send-pack", "--stateless-rpc", "--helper-status", + strvec_init(&args); + strvec_pushl(&args, "send-pack", "--stateless-rpc", "--helper-status", NULL); if (options.thin) - argv_array_push(&args, "--thin"); + strvec_push(&args, "--thin"); if (options.dry_run) - argv_array_push(&args, "--dry-run"); + strvec_push(&args, "--dry-run"); if (options.push_cert == SEND_PACK_PUSH_CERT_ALWAYS) - argv_array_push(&args, "--signed=yes"); + strvec_push(&args, "--signed=yes"); else if (options.push_cert == SEND_PACK_PUSH_CERT_IF_ASKED) - argv_array_push(&args, "--signed=if-asked"); + strvec_push(&args, "--signed=if-asked"); if (options.atomic) - argv_array_push(&args, "--atomic"); + strvec_push(&args, "--atomic"); if (options.verbosity == 0) - argv_array_push(&args, "--quiet"); + strvec_push(&args, "--quiet"); else if (options.verbosity > 1) - argv_array_push(&args, "--verbose"); + strvec_push(&args, "--verbose"); for (i = 0; i < options.push_options.nr; i++) - argv_array_pushf(&args, "--push-option=%s", + strvec_pushf(&args, "--push-option=%s", options.push_options.items[i].string); - argv_array_push(&args, options.progress ? "--progress" : "--no-progress"); + strvec_push(&args, options.progress ? "--progress" : "--no-progress"); for_each_string_list_item(cas_option, &cas_options) - argv_array_push(&args, cas_option->string); - argv_array_push(&args, url.buf); + strvec_push(&args, cas_option->string); + strvec_push(&args, url.buf); - argv_array_push(&args, "--stdin"); + strvec_push(&args, "--stdin"); for (i = 0; i < nr_spec; i++) packet_buf_write(&preamble, "%s\n", specs[i]); packet_buf_flush(&preamble); @@ -1330,7 +1330,7 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs) write_or_die(1, rpc_result.buf, rpc_result.len); strbuf_release(&rpc_result); strbuf_release(&preamble); - argv_array_clear(&args); + strvec_clear(&args); return err; } @@ -1349,13 +1349,13 @@ static int push(int nr_spec, const char **specs) static void parse_push(struct strbuf *buf) { - struct argv_array specs = ARGV_ARRAY_INIT; + struct strvec specs = STRVEC_INIT; int ret; do { const char *arg; if (skip_prefix(buf->buf, "push ", &arg)) - argv_array_push(&specs, arg); + strvec_push(&specs, arg); else die(_("http transport does not support %s"), buf->buf); @@ -1374,7 +1374,7 @@ static void parse_push(struct strbuf *buf) exit(128); /* error already reported */ free_specs: - argv_array_clear(&specs); + strvec_clear(&specs); } static int stateless_connect(const char *service_name) -- cgit v1.2.3 From f6d8942b1fc6c968980c8ae03054d7b2114b4415 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 28 Jul 2020 16:26:31 -0400 Subject: strvec: fix indentation in renamed calls Code which split an argv_array call across multiple lines, like: argv_array_pushl(&args, "one argument", "another argument", "and more", NULL); was recently mechanically renamed to use strvec, which results in mis-matched indentation like: strvec_pushl(&args, "one argument", "another argument", "and more", NULL); Let's fix these up to align the arguments with the opening paren. I did this manually by sifting through the results of: git jump grep 'strvec_.*,$' and liberally applying my editor's auto-format. Most of the changes are of the form shown above, though I also normalized a few that had originally used a single-tab indentation (rather than our usual style of aligning with the open paren). I also rewrapped a couple of obvious cases (e.g., where previously too-long lines became short enough to fit on one), but I wasn't aggressive about it. In cases broken to three or more lines, the grouping of arguments is sometimes meaningful, and it wasn't worth my time or reviewer time to ponder each case individually. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- remote-curl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'remote-curl.c') diff --git a/remote-curl.c b/remote-curl.c index 85ce4f7e6f..7feaddc003 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1145,7 +1145,7 @@ static int fetch_git(struct discovery *heads, struct strbuf rpc_result = STRBUF_INIT; strvec_pushl(&args, "fetch-pack", "--stateless-rpc", - "--stdin", "--lock-pack", NULL); + "--stdin", "--lock-pack", NULL); if (options.followtags) strvec_push(&args, "--include-tag"); if (options.thin) @@ -1166,7 +1166,7 @@ static int fetch_git(struct discovery *heads, strvec_pushf(&args, "--shallow-since=%s", options.deepen_since); for (i = 0; i < options.deepen_not.nr; i++) strvec_pushf(&args, "--shallow-exclude=%s", - options.deepen_not.items[i].string); + options.deepen_not.items[i].string); if (options.deepen_relative && options.depth) strvec_push(&args, "--deepen-relative"); if (options.from_promisor) @@ -1293,7 +1293,7 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs) strvec_init(&args); strvec_pushl(&args, "send-pack", "--stateless-rpc", "--helper-status", - NULL); + NULL); if (options.thin) strvec_push(&args, "--thin"); @@ -1311,7 +1311,7 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs) strvec_push(&args, "--verbose"); for (i = 0; i < options.push_options.nr; i++) strvec_pushf(&args, "--push-option=%s", - options.push_options.items[i].string); + options.push_options.items[i].string); strvec_push(&args, options.progress ? "--progress" : "--no-progress"); for_each_string_list_item(cas_option, &cas_options) strvec_push(&args, cas_option->string); -- cgit v1.2.3 From d70a9eb611a9d242c1d26847d223b8677609305b Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 28 Jul 2020 20:37:20 -0400 Subject: strvec: rename struct fields The "argc" and "argv" names made sense when the struct was argv_array, but now they're just confusing. Let's rename them to "nr" (which we use for counts elsewhere) and "v" (which is rather terse, but reads well when combined with typical variable names like "args.v"). Note that we have to update all of the callers immediately. Playing tricks with the preprocessor is hard here, because we wouldn't want to rewrite unrelated tokens. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- remote-curl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'remote-curl.c') diff --git a/remote-curl.c b/remote-curl.c index 7feaddc003..41c3ac5c92 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1190,7 +1190,7 @@ static int fetch_git(struct discovery *heads, rpc.service_name = "git-upload-pack", rpc.gzip_request = 1; - err = rpc_service(&rpc, heads, args.argv, &preamble, &rpc_result); + err = rpc_service(&rpc, heads, args.v, &preamble, &rpc_result); if (rpc_result.len) write_or_die(1, rpc_result.buf, rpc_result.len); strbuf_release(&rpc_result); @@ -1325,7 +1325,7 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs) memset(&rpc, 0, sizeof(rpc)); rpc.service_name = "git-receive-pack", - err = rpc_service(&rpc, heads, args.argv, &preamble, &rpc_result); + err = rpc_service(&rpc, heads, args.v, &preamble, &rpc_result); if (rpc_result.len) write_or_die(1, rpc_result.buf, rpc_result.len); strbuf_release(&rpc_result); @@ -1366,7 +1366,7 @@ static void parse_push(struct strbuf *buf) break; } while (1); - ret = push(specs.argc, specs.argv); + ret = push(specs.nr, specs.v); printf("\n"); fflush(stdout); -- cgit v1.2.3