Skip to contentSkip to conversation

renaming argv_array

PATCH In review Jeff King 9 participants 46 messages Jul 28, 2020 – Aug 12, 2020

Subsystems (2)
lore
Share & tools
lore

Jeff King

author
#0 lore raw

cover renaming argv_array

The argv_array data type has turned out to be useful in our code base, but the name isn't very good. From patch 2 of this series:

The name "argv-array" isn't very good, because it describes what the data type can be used for (program argument arrays), not what it actually is (a dynamically-growing string array that maintains a NULL-terminator invariant). This leads to people being hesitant to use it for other cases where it would actually be a good fit. The existing name is also clunky to use. It's overly long, and the name often leads to saying things like "argv.argv" (i.e., the field names overlap with variable names, since they're describing the use, not the type). Let's give it a more neutral name.

This has bugged me for a while, so I decided to finally fix it. It wasn't _too_ painful, though I'm sure there will be a little fallout with topics in flight.

I tried to split out the mechanical bits into their own patches to make reviewing easier. Patches 5-7 really could be a single patch, but they're too big for the mailing list. I'm OK to leave them separate, or they could be squashed together.

We could stop at patch 9 for now and allow topics in flight to catch up before removing the compat layers. But the struct field renaming has to happen as a single step, so it will be a pain whenever we do it. If we're going to go this route, I'd just as soon do it all now and deal with other topics as they get merged.

[01/11]: argv-array: use size_t for count and alloc [02/11]: argv-array: rename to strvec
[03/11]: strvec: rename files from argv-array to strvec [04/11]: quote: rename sq_dequote_to_argv_array to mention strvec [05/11]: strvec: convert builtin/ callers away from argv_array name [06/11]: strvec: convert more callers away from argv_array name [07/11]: strvec: convert remaining callers away from argv_array name [08/11]: strvec: fix indentation in renamed calls [09/11]: strvec: update documention to avoid argv_array [10/11]: strvec: drop argv_array compatibility layer [11/11]: strvec: rename struct fields

 Documentation/technical/api-parse-options.txt |   4 +-
 Makefile                                      |   2 +-
 add-interactive.c                             |  28 +--
 add-patch.c                                   |  48 ++--
 argv-array.c                                  | 109 ---------
 bisect.c                                      |  20 +-
 builtin/add.c                                 |  18 +-
 builtin/am.c                                  |  80 +++----
 builtin/annotate.c                            |  10 +-
 builtin/bisect--helper.c                      |  20 +-
 builtin/bundle.c                              |  14 +-
 builtin/clone.c                               |  38 +--
 builtin/commit.c                              |   8 +-
 builtin/describe.c                            |  44 ++--
 builtin/difftool.c                            |  30 +--
 builtin/fetch.c                               |  64 ++---
 builtin/gc.c                                  |  78 +++----
 builtin/grep.c                                |   2 +-
 builtin/log.c                                 |  12 +-
 builtin/ls-remote.c                           |   6 +-
 builtin/pack-objects.c                        |  26 +--
 builtin/pull.c                                | 160 ++++++-------
 builtin/range-diff.c                          |   4 +-
 builtin/rebase.c                              |  90 ++++----
 builtin/receive-pack.c                        | 126 +++++-----
 builtin/remote-ext.c                          |   4 +-
 builtin/remote.c                              |  26 +--
 builtin/repack.c                              |  72 +++---
 builtin/replace.c                             |  18 +-
 builtin/show-branch.c                         |  16 +-
 builtin/stash.c                               | 162 ++++++-------
 builtin/submodule--helper.c                   | 144 ++++++------
 builtin/update-ref.c                          |   2 +-
 builtin/upload-archive.c                      |  12 +-
 builtin/worktree.c                            |  68 +++---
 bundle.c                                      |  24 +-
 bundle.h                                      |   4 +-
 column.c                                      |  12 +-
 commit.c                                      |  10 +-
 compat/mingw.c                                |   4 +-
 compat/terminal.c                             |  18 +-
 connect.c                                     |  69 +++---
 connected.c                                   |  24 +-
 daemon.c                                      |  60 ++---
 diff.c                                        |  32 +--
 environment.c                                 |  12 +-
 exec-cmd.c                                    |  18 +-
 exec-cmd.h                                    |   4 +-
 fast-import.c                                 |   4 +-
 fetch-pack.c                                  |  46 ++--
 fsmonitor.c                                   |   6 +-
 git.c                                         |  32 +--
 gpg-interface.c                               |  22 +-
 graph.c                                       |  16 +-
 http-backend.c                                |   8 +-
 http-push.c                                   |  18 +-
 http.c                                        |   8 +-
 imap-send.c                                   |   2 +-
 line-log.c                                    |   8 +-
 list-objects-filter-options.c                 |   2 +-
 ls-refs.c                                     |  18 +-
 ls-refs.h                                     |   4 +-
 merge.c                                       |  18 +-
 midx.c                                        |  12 +-
 pager.c                                       |   8 +-
 parse-options-cb.c                            |   8 +-
 pathspec.c                                    |  10 +-
 quote.c                                       |   8 +-
 quote.h                                       |   8 +-
 range-diff.c                                  |  40 ++--
 range-diff.h                                  |   4 +-
 ref-filter.c                                  |  12 +-
 refs.c                                        |   8 +-
 refs.h                                        |   4 +-
 refspec.c                                     |  10 +-
 refspec.h                                     |   4 +-
 remote-curl.c                                 | 102 ++++----
 remote-testsvn.c                              |  10 +-
 remote.c                                      |  20 +-
 remote.h                                      |   4 +-
 revision.c                                    |  20 +-
 run-command.c                                 |  72 +++---
 run-command.h                                 |  12 +-
 send-pack.c                                   |  18 +-
 sequencer.c                                   | 126 +++++-----
 serve.c                                       |  20 +-
 serve.h                                       |   4 +-
 sha1-file.c                                   |  14 +-
 strvec.c                                      | 109 +++++++++
 argv-array.h => strvec.h                      |  58 ++---
 sub-process.c                                 |   2 +-
 submodule.c                                   | 218 +++++++++---------
 submodule.h                                   |   6 +-
 t/helper/test-run-command.c                   |  52 ++---
 t/helper/test-trace2.c                        |   2 +-
 tmp-objdir.c                                  |  20 +-
 transport-helper.c                            |  36 +--
 transport-internal.h                          |   4 +-
 transport.c                                   |  12 +-
 transport.h                                   |   2 +-
 unpack-trees.c                                |  12 +-
 unpack-trees.h                                |   4 +-
 upload-pack.c                                 |  53 +++--
 upload-pack.h                                 |   4 +-
 wt-status.c                                   |  19 +-
 105 files changed, 1619 insertions(+), 1620 deletions(-)
 delete mode 100644 argv-array.c
 create mode 100644 strvec.c
 rename argv-array.h => strvec.h (50%)
author
#1 lore raw

PATCH 1/11 argv-array: use size_t for count and alloc

On most 64-bit platforms, "int" is significantly smaller than a size_t, which could lead to integer overflow and under-allocation of the array. It's probably impossible to trigger in practice, as it would imply on the order of 2^32 individual allocations. Even if was possible to grow an array in that way (and we typically only use it for sets of strings, like command line options), each allocation needs a pointer, malloc overhead, etc. You'd quite likely run out of RAM before succeeding in such an overflow.

But all that hand-waving aside, it's easy enough to use the correct type, so let's do so.

---
This one is obviously of value even without the renaming.

 argv-array.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
argv-array.h +2 -2
index a7d3b10707..4fc57b6902 100644
@@ -29,8 +29,8 @@ extern const char *empty_argv[];
  */
 struct argv_array {
 	const char **argv;
-	int argc;
-	int alloc;
+	size_t argc;
+	size_t alloc;
 };
 
 #define ARGV_ARRAY_INIT { empty_argv, 0, 0 }
Signature · 1 line
2.28.0.rc2.475.g53c7e1c7f4
author
#2 lore raw

PATCH 2/11 argv-array: rename to strvec

In reply to Jeff King

The name "argv-array" isn't very good, because it describes what the data type can be used for (program argument arrays), not what it actually is (a dynamically-growing string array that maintains a NULL-terminator invariant). This leads to people being hesitant to use it for other cases where it would actually be a good fit. The existing name is also clunky to use. It's overly long, and the name often leads to saying things like "argv.argv" (i.e., the field names overlap with variable names, since they're describing the use, not the type). Let's give it a more neutral name.

I settled on "strvec" because "vector" is the name for a dynamic array type in many programming languages. "strarray" would work, too, but it's longer and a bit more awkward to say (and don't we all say these things in our mind as we type them?).

A more extreme direction would be a generic data structure which stores a NULL-terminated of _any_ type. That would be easy to do with void pointers, but we'd lose some type safety for the existing cases. Plus it raises questions about memory allocation and ownership. So I limited myself here to changing names only, and not semantics. If we do find a use for that more generic data type, we could perhaps implement it at a lower level and then provide type-safe wrappers around it for strings. But that can come later.

This patch does the minimum to convert the struct and function names in the header and implementation, leaving a few things for follow-on patches:

- files retain their original names for now

- struct field names are retained for now

- there's a preprocessor compat layer that lets most users remain the same for now. The exception is headers which made a manual forward declaration of the struct. I've converted them (and their dependent function declarations) here.

---
 argv-array.c         | 44 +++++++++++++++++++-------------------
 argv-array.h         | 51 +++++++++++++++++++++++++++-----------------
 exec-cmd.h           |  4 ++--
 ls-refs.h            |  4 ++--
 quote.h              |  4 ++--
 refs.h               |  4 ++--
 refspec.h            |  4 ++--
 remote.h             |  4 ++--
 serve.h              |  4 ++--
 submodule.h          |  6 +++---
 transport-internal.h |  2 +-
 upload-pack.h        |  4 ++--
 12 files changed, 74 insertions(+), 61 deletions(-)
argv-array.c +22 -22
index 61ef8c0dfd..b7461c47e4 100644
@@ -2,32 +2,32 @@
 #include "argv-array.h"
 #include "strbuf.h"
 
-const char *empty_argv[] = { NULL };
+const char *empty_strvec[] = { NULL };
 
-void argv_array_init(struct argv_array *array)
+void strvec_init(struct strvec *array)
 {
-	array->argv = empty_argv;
+	array->argv = empty_strvec;
 	array->argc = 0;
 	array->alloc = 0;
 }
 
-static void argv_array_push_nodup(struct argv_array *array, const char *value)
+static void strvec_push_nodup(struct strvec *array, const char *value)
 {
-	if (array->argv == empty_argv)
+	if (array->argv == empty_strvec)
 		array->argv = NULL;
 
 	ALLOC_GROW(array->argv, array->argc + 2, array->alloc);
 	array->argv[array->argc++] = value;
 	array->argv[array->argc] = NULL;
 }
 
-const char *argv_array_push(struct argv_array *array, const char *value)
+const char *strvec_push(struct strvec *array, const char *value)
 {
-	argv_array_push_nodup(array, xstrdup(value));
+	strvec_push_nodup(array, xstrdup(value));
 	return array->argv[array->argc - 1];
 }
 
-const char *argv_array_pushf(struct argv_array *array, const char *fmt, ...)
+const char *strvec_pushf(struct strvec *array, const char *fmt, ...)
 {
 	va_list ap;
 	struct strbuf v = STRBUF_INIT;
@@ -36,28 +36,28 @@ const char *argv_array_pushf(struct argv_array *array, const char *fmt, ...)
 	strbuf_vaddf(&v, fmt, ap);
 	va_end(ap);
 
-	argv_array_push_nodup(array, strbuf_detach(&v, NULL));
+	strvec_push_nodup(array, strbuf_detach(&v, NULL));
 	return array->argv[array->argc - 1];
 }
 
-void argv_array_pushl(struct argv_array *array, ...)
+void strvec_pushl(struct strvec *array, ...)
 {
 	va_list ap;
 	const char *arg;
 
 	va_start(ap, array);
 	while ((arg = va_arg(ap, const char *)))
-		argv_array_push(array, arg);
+		strvec_push(array, arg);
 	va_end(ap);
 }
 
-void argv_array_pushv(struct argv_array *array, const char **argv)
+void strvec_pushv(struct strvec *array, const char **argv)
 {
 	for (; *argv; argv++)
-		argv_array_push(array, *argv);
+		strvec_push(array, *argv);
 }
 
-void argv_array_pop(struct argv_array *array)
+void strvec_pop(struct strvec *array)
 {
 	if (!array->argc)
 		return;
@@ -66,7 +66,7 @@ void argv_array_pop(struct argv_array *array)
 	array->argc--;
 }
 
-void argv_array_split(struct argv_array *array, const char *to_split)
+void strvec_split(struct strvec *array, const char *to_split)
 {
 	while (isspace(*to_split))
 		to_split++;
@@ -78,32 +78,32 @@ void argv_array_split(struct argv_array *array, const char *to_split)
 
 		while (*p && !isspace(*p))
 			p++;
-		argv_array_push_nodup(array, xstrndup(to_split, p - to_split));
+		strvec_push_nodup(array, xstrndup(to_split, p - to_split));
 
 		while (isspace(*p))
 			p++;
 		to_split = p;
 	}
 }
 
-void argv_array_clear(struct argv_array *array)
+void strvec_clear(struct strvec *array)
 {
-	if (array->argv != empty_argv) {
+	if (array->argv != empty_strvec) {
 		int i;
 		for (i = 0; i < array->argc; i++)
 			free((char *)array->argv[i]);
 		free(array->argv);
 	}
-	argv_array_init(array);
+	strvec_init(array);
 }
 
-const char **argv_array_detach(struct argv_array *array)
+const char **strvec_detach(struct strvec *array)
 {
-	if (array->argv == empty_argv)
+	if (array->argv == empty_strvec)
 		return xcalloc(1, sizeof(const char *));
 	else {
 		const char **ret = array->argv;
-		argv_array_init(array);
+		strvec_init(array);
 		return ret;
 	}
 }
argv-array.h +32 -19

108 lines not on this page · raw message

exec-cmd.h +2 -2
index 8cd1df28d3..330b41d54d 100644
@@ -1,13 +1,13 @@
 #ifndef GIT_EXEC_CMD_H
 #define GIT_EXEC_CMD_H
 
-struct argv_array;
+struct strvec;
 
 void git_set_exec_path(const char *exec_path);
 void git_resolve_executable_dir(const char *path);
 const char *git_exec_path(void);
 void setup_path(void);
-const char **prepare_git_cmd(struct argv_array *out, const char **argv);
+const char **prepare_git_cmd(struct strvec *out, const char **argv);
 int execv_git_cmd(const char **argv); /* NULL terminated */
 LAST_ARG_MUST_BE_NULL
 int execl_git_cmd(const char *cmd, ...);
ls-refs.h +2 -2
index 7e5646f5f6..7b33a7c6b8 100644
@@ -2,9 +2,9 @@
 #define LS_REFS_H
 
 struct repository;
-struct argv_array;
+struct strvec;
 struct packet_reader;
-int ls_refs(struct repository *r, struct argv_array *keys,
+int ls_refs(struct repository *r, struct strvec *keys,
 	    struct packet_reader *request);
 
 #endif /* LS_REFS_H */
quote.h +2 -2
index ca8ee3144a..210d580229 100644
@@ -60,8 +60,8 @@ int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc);
  * still modify arg in place, but unlike sq_dequote_to_argv, the argv_array
  * will duplicate and take ownership of the strings.
  */
-struct argv_array;
-int sq_dequote_to_argv_array(char *arg, struct argv_array *);
+struct strvec;
+int sq_dequote_to_argv_array(char *arg, struct strvec *);
 
 int unquote_c_style(struct strbuf *, const char *quoted, const char **endp);
 size_t quote_c_style(const char *name, struct strbuf *, FILE *, int no_dq);
refs.h +2 -2
index f212f8945e..29e28124cd 100644
@@ -145,8 +145,8 @@ int refname_match(const char *abbrev_name, const char *full_name);
  * Given a 'prefix' expand it by the rules in 'ref_rev_parse_rules' and add
  * the results to 'prefixes'
  */
-struct argv_array;
-void expand_ref_prefix(struct argv_array *prefixes, const char *prefix);
+struct strvec;
+void expand_ref_prefix(struct strvec *prefixes, const char *prefix);
 
 int expand_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
 int repo_dwim_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
refspec.h +2 -2
index 3f2bd4aaa5..23e1555b88 100644
@@ -60,12 +60,12 @@ void refspec_clear(struct refspec *rs);
 
 int valid_fetch_refspec(const char *refspec);
 
-struct argv_array;
+struct strvec;
 /*
  * Determine what <prefix> values to pass to the peer in ref-prefix lines
  * (see Documentation/technical/protocol-v2.txt).
  */
 void refspec_ref_prefixes(const struct refspec *rs,
-			  struct argv_array *ref_prefixes);
+			  struct strvec *ref_prefixes);
 
 #endif /* REFSPEC_H */
remote.h +2 -2
index 5cc26c1b3b..5e3ea5a26d 100644
@@ -168,7 +168,7 @@ void free_refs(struct ref *ref);
 
 struct oid_array;
 struct packet_reader;
-struct argv_array;
+struct strvec;
 struct string_list;
 struct ref **get_remote_heads(struct packet_reader *reader,
 			      struct ref **list, unsigned int flags,
@@ -178,7 +178,7 @@ struct ref **get_remote_heads(struct packet_reader *reader,
 /* Used for protocol v2 in order to retrieve refs from a remote */
 struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
 			     struct ref **list, int for_push,
-			     const struct argv_array *ref_prefixes,
+			     const struct strvec *ref_prefixes,
 			     const struct string_list *server_options,
 			     int stateless_rpc);
 
serve.h +2 -2
index 42ddca7f8b..fc2683e24d 100644
@@ -1,8 +1,8 @@
 #ifndef SERVE_H
 #define SERVE_H
 
-struct argv_array;
-int has_capability(const struct argv_array *keys, const char *capability,
+struct strvec;
+int has_capability(const struct strvec *keys, const char *capability,
 		   const char **value);
 
 struct serve_options {
submodule.h +3 -3
index 4dad649f94..9ce85c03fe 100644
@@ -1,7 +1,7 @@
 #ifndef SUBMODULE_H
 #define SUBMODULE_H
 
-struct argv_array;
+struct strvec;
 struct cache_entry;
 struct diff_options;
 struct index_state;
@@ -84,7 +84,7 @@ int should_update_submodules(void);
 const struct submodule *submodule_from_ce(const struct cache_entry *ce);
 void check_for_new_submodule_commits(struct object_id *oid);
 int fetch_populated_submodules(struct repository *r,
-			       const struct argv_array *options,
+			       const struct strvec *options,
 			       const char *prefix,
 			       int command_line_option,
 			       int default_option,
@@ -143,7 +143,7 @@ void submodule_unset_core_worktree(const struct submodule *sub);
  * a submodule by clearing any repo-specific environment variables, but
  * retaining any config in the environment.
  */
-void prepare_submodule_repo_env(struct argv_array *out);
+void prepare_submodule_repo_env(struct strvec *out);
 
 #define ABSORB_GITDIR_RECURSE_SUBMODULES (1<<0)
 void absorb_git_dir_into_superproject(const char *path,
transport-internal.h +1 -1
index 1cde6258a7..284784a2a6 100644
@@ -3,7 +3,7 @@
 
 struct ref;
 struct transport;
-struct argv_array;
+struct strvec;
 
 struct transport_vtable {
 	/**
upload-pack.h +2 -2
index 4bafe16a22..27ddcdc6cb 100644
@@ -11,9 +11,9 @@ struct upload_pack_options {
 void upload_pack(struct upload_pack_options *options);
 
 struct repository;
-struct argv_array;
+struct strvec;
 struct packet_reader;
-int upload_pack_v2(struct repository *r, struct argv_array *keys,
+int upload_pack_v2(struct repository *r, struct strvec *keys,
 		   struct packet_reader *request);
 
 struct strbuf;
Signature · 1 line
2.28.0.rc2.475.g53c7e1c7f4
author
#3 lore raw

PATCH 3/11 strvec: rename files from argv-array to strvec

In reply to Jeff King

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/'

---
 Makefile                      | 2 +-
 add-patch.c                   | 2 +-
 bisect.c                      | 2 +-
 builtin/add.c                 | 2 +-
 builtin/annotate.c            | 2 +-
 builtin/bisect--helper.c      | 2 +-
 builtin/bundle.c              | 2 +-
 builtin/describe.c            | 2 +-
 builtin/difftool.c            | 2 +-
 builtin/fetch.c               | 2 +-
 builtin/gc.c                  | 2 +-
 builtin/pack-objects.c        | 2 +-
 builtin/rebase.c              | 2 +-
 builtin/receive-pack.c        | 2 +-
 builtin/remote.c              | 2 +-
 builtin/repack.c              | 2 +-
 builtin/show-branch.c         | 2 +-
 builtin/stash.c               | 2 +-
 builtin/update-ref.c          | 2 +-
 builtin/upload-archive.c      | 2 +-
 builtin/worktree.c            | 2 +-
 bundle.c                      | 2 +-
 bundle.h                      | 2 +-
 diff.c                        | 2 +-
 environment.c                 | 2 +-
 exec-cmd.c                    | 2 +-
 graph.c                       | 2 +-
 http-backend.c                | 2 +-
 http-push.c                   | 2 +-
 line-log.c                    | 2 +-
 list-objects-filter-options.c | 2 +-
 ls-refs.c                     | 2 +-
 parse-options-cb.c            | 2 +-
 pathspec.c                    | 2 +-
 quote.c                       | 2 +-
 range-diff.c                  | 2 +-
 range-diff.h                  | 2 +-
 ref-filter.c                  | 2 +-
 refs.c                        | 2 +-
 refspec.c                     | 2 +-
 remote-curl.c                 | 2 +-
 remote-testsvn.c              | 2 +-
 remote.c                      | 2 +-
 revision.c                    | 2 +-
 run-command.c                 | 2 +-
 run-command.h                 | 2 +-
 sequencer.c                   | 2 +-
 serve.c                       | 2 +-
 argv-array.c => strvec.c      | 2 +-
 argv-array.h => strvec.h      | 6 +++---
 submodule.c                   | 2 +-
 t/helper/test-run-command.c   | 2 +-
 t/helper/test-trace2.c        | 2 +-
 tmp-objdir.c                  | 2 +-
 transport-helper.c            | 2 +-
 unpack-trees.c                | 2 +-
 unpack-trees.h                | 2 +-
 upload-pack.c                 | 2 +-
 wt-status.c                   | 2 +-
 59 files changed, 61 insertions(+), 61 deletions(-)
 rename argv-array.c => strvec.c (98%)
 rename argv-array.h => strvec.h (97%)
Makefile +1 -1
index 372139f1f2..65f8cfb236 100644
@@ -828,7 +828,6 @@ LIB_OBJS += apply.o
 LIB_OBJS += archive-tar.o
 LIB_OBJS += archive-zip.o
 LIB_OBJS += archive.o
-LIB_OBJS += argv-array.o
 LIB_OBJS += attr.o
 LIB_OBJS += base85.o
 LIB_OBJS += bisect.o
@@ -986,6 +985,7 @@ LIB_OBJS += sigchain.o
 LIB_OBJS += split-index.o
 LIB_OBJS += stable-qsort.o
 LIB_OBJS += strbuf.o
+LIB_OBJS += strvec.o
 LIB_OBJS += streaming.o
 LIB_OBJS += string-list.o
 LIB_OBJS += sub-process.o
add-patch.c +1 -1
index f899389e2c..09d00c5574 100644
@@ -2,7 +2,7 @@
 #include "add-interactive.h"
 #include "strbuf.h"
 #include "run-command.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "pathspec.h"
 #include "color.h"
 #include "diff.h"
bisect.c +1 -1
index d5e830410f..3160e82e96 100644
@@ -11,7 +11,7 @@
 #include "log-tree.h"
 #include "bisect.h"
 #include "oid-array.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "commit-slab.h"
 #include "commit-reach.h"
 #include "object-store.h"
builtin/add.c +1 -1
index 298e0114f9..6cd9a4cd77 100644
@@ -18,7 +18,7 @@
 #include "diffcore.h"
 #include "revision.h"
 #include "bulk-checkin.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "submodule.h"
 #include "add-interactive.h"
 
builtin/annotate.c +1 -1
index da413ae0d1..4353448712 100644
@@ -5,7 +5,7 @@
  */
 #include "git-compat-util.h"
 #include "builtin.h"
-#include "argv-array.h"
+#include "strvec.h"
 
 int cmd_annotate(int argc, const char **argv, const char *prefix)
 {
builtin/bisect--helper.c +1 -1
index ec4996282e..e929315b38 100644
@@ -4,7 +4,7 @@
 #include "bisect.h"
 #include "refs.h"
 #include "dir.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "run-command.h"
 #include "prompt.h"
 #include "quote.h"
builtin/bundle.c +1 -1
index f049d27a14..51fc6d9739 100644
@@ -1,5 +1,5 @@
 #include "builtin.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "parse-options.h"
 #include "cache.h"
 #include "bundle.h"
builtin/describe.c +1 -1
index 21d2cb9e57..32ad6822f7 100644
@@ -12,7 +12,7 @@
 #include "revision.h"
 #include "diff.h"
 #include "hashmap.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "run-command.h"
 #include "object-store.h"
 #include "list-objects.h"
builtin/difftool.c +1 -1
index c280e682b2..c0608a78d9 100644
@@ -18,7 +18,7 @@
 #include "run-command.h"
 #include "exec-cmd.h"
 #include "parse-options.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "strbuf.h"
 #include "lockfile.h"
 #include "object-store.h"
builtin/fetch.c +1 -1
index 82ac4be8a5..b183b55ee9 100644
@@ -19,7 +19,7 @@
 #include "submodule-config.h"
 #include "submodule.h"
 #include "connected.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "utf8.h"
 #include "packfile.h"
 #include "list-objects-filter-options.h"
builtin/gc.c +1 -1
index 8e0b9cf41b..27951ee061 100644
@@ -18,7 +18,7 @@
 #include "parse-options.h"
 #include "run-command.h"
 #include "sigchain.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "commit.h"
 #include "commit-graph.h"
 #include "packfile.h"
builtin/pack-objects.c +1 -1
index 7016b28485..5f18f0ee9d 100644
@@ -27,7 +27,7 @@
 #include "delta-islands.h"
 #include "reachable.h"
 #include "oid-array.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "list.h"
 #include "packfile.h"
 #include "object-store.h"
builtin/rebase.c +1 -1
index 37ba76ac3d..38145a66ed 100644
@@ -8,7 +8,7 @@
 #include "builtin.h"
 #include "run-command.h"
 #include "exec-cmd.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "dir.h"
 #include "packfile.h"
 #include "refs.h"
builtin/receive-pack.c +1 -1
index d43663bb0a..1285631481 100644
@@ -15,7 +15,7 @@
 #include "string-list.h"
 #include "oid-array.h"
 #include "connected.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "version.h"
 #include "tag.h"
 #include "gpg-interface.h"
builtin/remote.c +1 -1
index e8377994e5..a9f35ba855 100644
@@ -10,7 +10,7 @@
 #include "refs.h"
 #include "refspec.h"
 #include "object-store.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "commit-reach.h"
 
 static const char * const builtin_remote_usage[] = {
builtin/repack.c +1 -1
index df287739d9..8bccb38a28 100644
@@ -7,7 +7,7 @@
 #include "sigchain.h"
 #include "strbuf.h"
 #include "string-list.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "midx.h"
 #include "packfile.h"
 #include "prune-packed.h"
builtin/show-branch.c +1 -1
index 7e52ee9126..f0a70538c3 100644
@@ -4,7 +4,7 @@
 #include "refs.h"
 #include "builtin.h"
 #include "color.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "parse-options.h"
 #include "dir.h"
 #include "commit-slab.h"
builtin/stash.c +1 -1
index 0c52a3b849..1acf216254 100644
@@ -7,7 +7,7 @@
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "merge-recursive.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "run-command.h"
 #include "dir.h"
 #include "rerere.h"
builtin/update-ref.c +1 -1
index b74dd9a69d..8a2df4459c 100644
@@ -4,7 +4,7 @@
 #include "builtin.h"
 #include "parse-options.h"
 #include "quote.h"
-#include "argv-array.h"
+#include "strvec.h"
 
 static const char * const git_update_ref_usage[] = {
 	N_("git update-ref [<options>] -d <refname> [<old-val>]"),
builtin/upload-archive.c +1 -1
index 018879737a..7fc8e0e82d 100644
@@ -7,7 +7,7 @@
 #include "pkt-line.h"
 #include "sideband.h"
 #include "run-command.h"
-#include "argv-array.h"
+#include "strvec.h"
 
 static const char upload_archive_usage[] =
 	"git upload-archive <repo>";
builtin/worktree.c +1 -1
index f0cbdef718..35945096f6 100644
@@ -4,7 +4,7 @@
 #include "builtin.h"
 #include "dir.h"
 #include "parse-options.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "branch.h"
 #include "refs.h"
 #include "run-command.h"
bundle.c +1 -1
index 2a0d744d3f..d46a387e66 100644
@@ -10,7 +10,7 @@
 #include "list-objects.h"
 #include "run-command.h"
 #include "refs.h"
-#include "argv-array.h"
+#include "strvec.h"
 
 static const char bundle_signature[] = "# v2 git bundle\n";
 
bundle.h +1 -1
index 2dc9442024..2cf1270092 100644
@@ -1,7 +1,7 @@
 #ifndef BUNDLE_H
 #define BUNDLE_H
 
-#include "argv-array.h"
+#include "strvec.h"
 #include "cache.h"
 
 struct ref_list {
diff.c +1 -1
index d24aaa3047..ee008155e4 100644
@@ -20,7 +20,7 @@
 #include "hashmap.h"
 #include "ll-merge.h"
 #include "string-list.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "graph.h"
 #include "packfile.h"
 #include "parse-options.h"
environment.c +1 -1
index aaca0e91ac..75fe5f4c56 100644
@@ -14,7 +14,7 @@
 #include "refs.h"
 #include "fmt-merge-msg.h"
 #include "commit.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "object-store.h"
 #include "chdir-notify.h"
 #include "shallow.h"
exec-cmd.c +1 -1
index 7deeab3039..bb24c2f3bc 100644
@@ -1,7 +1,7 @@
 #include "cache.h"
 #include "exec-cmd.h"
 #include "quote.h"
-#include "argv-array.h"
+#include "strvec.h"
 
 #if defined(RUNTIME_PREFIX)
 
graph.c +1 -1
index 4cd9915075..96af8f605a 100644
@@ -4,7 +4,7 @@
 #include "color.h"
 #include "graph.h"
 #include "revision.h"
-#include "argv-array.h"
+#include "strvec.h"
 
 /* Internal API */
 
http-backend.c +1 -1
index ec3144b444..6a42badf33 100644
@@ -9,7 +9,7 @@
 #include "run-command.h"
 #include "string-list.h"
 #include "url.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "packfile.h"
 #include "object-store.h"
 #include "protocol.h"
http-push.c +1 -1
index 1ff1883cdd..3a47921cc3 100644
@@ -11,7 +11,7 @@
 #include "remote.h"
 #include "list-objects.h"
 #include "sigchain.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "packfile.h"
 #include "object-store.h"
 #include "commit-reach.h"
line-log.c +1 -1
index c53692834d..05d077b8e7 100644
@@ -14,7 +14,7 @@
 #include "graph.h"
 #include "userdiff.h"
 #include "line-log.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "bloom.h"
 
 static void range_set_grow(struct range_set *rs, size_t extra)
list-objects-filter-options.c +1 -1
index 3553ad7b0a..3667766f29 100644
@@ -2,7 +2,7 @@
 #include "commit.h"
 #include "config.h"
 #include "revision.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "list-objects.h"
 #include "list-objects-filter.h"
 #include "list-objects-filter-options.h"
ls-refs.c +1 -1
index 50d86866c6..98fb19092a 100644
@@ -2,7 +2,7 @@
 #include "repository.h"
 #include "refs.h"
 #include "remote.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "ls-refs.h"
 #include "pkt-line.h"
 #include "config.h"
parse-options-cb.c +1 -1
index 86cd393013..7cba96454c 100644
@@ -4,7 +4,7 @@
 #include "commit.h"
 #include "color.h"
 #include "string-list.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "oid-array.h"
 
 /*----- some often used options -----*/
pathspec.c +1 -1
index 8243e06eab..57c9b58418 100644
@@ -3,7 +3,7 @@
 #include "dir.h"
 #include "pathspec.h"
 #include "attr.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "quote.h"
 
 /*
quote.c +1 -1
index bcc0dbc50d..dac8b4e55e 100644
@@ -1,6 +1,6 @@
 #include "cache.h"
 #include "quote.h"
-#include "argv-array.h"
+#include "strvec.h"
 
 int quote_path_fully = 1;
 
range-diff.c +1 -1
index 40af086281..b4d1d56445 100644
@@ -2,7 +2,7 @@
 #include "range-diff.h"
 #include "string-list.h"
 #include "run-command.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "hashmap.h"
 #include "xdiff-interface.h"
 #include "linear-assignment.h"
range-diff.h +1 -1
index e11976dc81..916f18bcd7 100644
@@ -2,7 +2,7 @@
 #define RANGE_DIFF_H
 
 #include "diff.h"
-#include "argv-array.h"
+#include "strvec.h"
 
 #define RANGE_DIFF_CREATION_FACTOR_DEFAULT 60
 
ref-filter.c +1 -1
index 8447cb09be..81c4399da9 100644
@@ -22,7 +22,7 @@
 #include "commit-reach.h"
 #include "worktree.h"
 #include "hashmap.h"
-#include "argv-array.h"
+#include "strvec.h"
 
 static struct ref_msg {
 	const char *gone;
refs.c +1 -1
index 639cba93b4..0067926262 100644
@@ -15,7 +15,7 @@
 #include "tag.h"
 #include "submodule.h"
 #include "worktree.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "repository.h"
 #include "sigchain.h"
 
refspec.c +1 -1
index 9a9bf21934..f9fb67d295 100644
@@ -1,5 +1,5 @@
 #include "cache.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "refs.h"
 #include "refspec.h"
 
remote-curl.c +1 -1
index 5cbc6e5002..05fb794ddd 100644
@@ -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"
remote-testsvn.c +1 -1
index cde39b94fb..809b290d45 100644
@@ -8,7 +8,7 @@
 #include "run-command.h"
 #include "vcs-svn/svndump.h"
 #include "notes.h"
-#include "argv-array.h"
+#include "strvec.h"
 
 static const char *url;
 static int dump_from_file;
remote.c +1 -1
index bc46413e6a..ba1a386d98 100644
@@ -11,7 +11,7 @@
 #include "tag.h"
 #include "string-list.h"
 #include "mergesort.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "commit-reach.h"
 #include "advice.h"
 
revision.c +1 -1
index 6aa7f4f567..07e16ed44b 100644
@@ -23,7 +23,7 @@
 #include "bisect.h"
 #include "packfile.h"
 #include "worktree.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "commit-reach.h"
 #include "commit-graph.h"
 #include "prio-queue.h"
run-command.c +1 -1
index a735e380a9..8f57661d96 100644
@@ -2,7 +2,7 @@
 #include "run-command.h"
 #include "exec-cmd.h"
 #include "sigchain.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "thread-utils.h"
 #include "strbuf.h"
 #include "string-list.h"
run-command.h +1 -1
index ef3071a565..f5e05d38d2 100644
@@ -3,7 +3,7 @@
 
 #include "thread-utils.h"
 
-#include "argv-array.h"
+#include "strvec.h"
 
 /**
  * The run-command API offers a versatile tool to run sub-processes with
sequencer.c +1 -1
index fd7701c88a..9e7f868b00 100644
@@ -16,7 +16,7 @@
 #include "rerere.h"
 #include "merge-recursive.h"
 #include "refs.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "quote.h"
 #include "trailer.h"
 #include "log-tree.h"
serve.c +1 -1
index fbd2fcdfb5..8d9a345b3d 100644
@@ -3,7 +3,7 @@
 #include "config.h"
 #include "pkt-line.h"
 #include "version.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "ls-refs.h"
 #include "serve.h"
 #include "upload-pack.h"
strvec.c renamed from argv-array.c +1 -1
similarity index 98%
rename from argv-array.c
rename to strvec.c
index b7461c47e4..9e76ab9295 100644
@@ -1,5 +1,5 @@
 #include "cache.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "strbuf.h"
 
 const char *empty_strvec[] = { NULL };
strvec.h renamed from argv-array.h +3 -3
similarity index 97%
rename from argv-array.h
rename to strvec.h
index ca66a338ad..4be39c8a48 100644
@@ -1,5 +1,5 @@
-#ifndef ARGV_ARRAY_H
-#define ARGV_ARRAY_H
+#ifndef STRVEC_H
+#define STRVEC_H
 
 /**
  * The argv-array API allows one to dynamically build and store
@@ -99,4 +99,4 @@ const char **strvec_detach(struct strvec *);
 #define argv_array_clear strvec_clear
 #define argv_array_detach strvec_detach
 
-#endif /* ARGV_ARRAY_H */
+#endif /* STRVEC_H */
submodule.c +1 -1
index e2ef5698c8..874db5c4b2 100644
@@ -13,7 +13,7 @@
 #include "refs.h"
 #include "string-list.h"
 #include "oid-array.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "blob.h"
 #include "thread-utils.h"
 #include "quote.h"
t/helper/test-run-command.c +1 -1
index 1646aa25d8..8d3f6d5a5e 100644
@@ -12,7 +12,7 @@
 #include "git-compat-util.h"
 #include "cache.h"
 #include "run-command.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "strbuf.h"
 #include "parse-options.h"
 #include "string-list.h"
t/helper/test-trace2.c +1 -1
index 197819c872..823f33ceff 100644
@@ -1,6 +1,6 @@
 #include "test-tool.h"
 #include "cache.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "run-command.h"
 #include "exec-cmd.h"
 #include "config.h"
tmp-objdir.c +1 -1
index 91c00567f4..06924a7875 100644
@@ -4,7 +4,7 @@
 #include "sigchain.h"
 #include "string-list.h"
 #include "strbuf.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "quote.h"
 #include "object-store.h"
 
transport-helper.c +1 -1
index c6b753bfae..441763fd7c 100644
@@ -9,7 +9,7 @@
 #include "string-list.h"
 #include "thread-utils.h"
 #include "sigchain.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "refs.h"
 #include "refspec.h"
 #include "transport-internal.h"
unpack-trees.c +1 -1
index 4be5fc3075..65c3395f0f 100644
@@ -1,5 +1,5 @@
 #include "cache.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "repository.h"
 #include "config.h"
 #include "dir.h"
unpack-trees.h +1 -1
index 9c2f08277e..f8a904a05b 100644
@@ -2,7 +2,7 @@
 #define UNPACK_TREES_H
 
 #include "cache.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "string-list.h"
 #include "tree-walk.h"
 
upload-pack.c +1 -1
index 951a2b23aa..b435dae62f 100644
@@ -18,7 +18,7 @@
 #include "sigchain.h"
 #include "version.h"
 #include "string-list.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "prio-queue.h"
 #include "protocol.h"
 #include "quote.h"
wt-status.c +1 -1
index c560cbe860..9817161da4 100644
@@ -8,7 +8,7 @@
 #include "diffcore.h"
 #include "quote.h"
 #include "run-command.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "remote.h"
 #include "refs.h"
 #include "submodule.h"
Signature · 1 line
2.28.0.rc2.475.g53c7e1c7f4
author
#4 lore raw

PATCH 4/11 quote: rename sq_dequote_to_argv_array to mention strvec

In reply to Jeff King

We want to eventually drop the use of the "argv_array" name in favor of "strvec." Unlike most other uses of the name, this one is embedded in a function name, so the definition and all of the callers need to be updated at the same time.

We don't technically need to update the parameter types here (our preprocessor compat macros make the two names interchangeable), but let's do so to keep the site consistent for now.

---
 bisect.c     | 2 +-
 builtin/am.c | 2 +-
 quote.c      | 2 +-
 quote.h      | 6 +++---
 4 files changed, 6 insertions(+), 6 deletions(-)
bisect.c +1 -1
index 3160e82e96..77e35ddd43 100644
@@ -464,7 +464,7 @@ static void read_bisect_paths(struct argv_array *array)
 
 	while (strbuf_getline_lf(&str, fp) != EOF) {
 		strbuf_trim(&str);
-		if (sq_dequote_to_argv_array(str.buf, array))
+		if (sq_dequote_to_strvec(str.buf, array))
 			die(_("Badly quoted content in file '%s': %s"),
 			    filename, str.buf);
 	}
builtin/am.c +1 -1
index 69e50de018..0641316e35 100644
@@ -399,7 +399,7 @@ static void am_load(struct am_state *state)
 
 	read_state_file(&sb, state, "apply-opt", 1);
 	argv_array_clear(&state->git_apply_opts);
-	if (sq_dequote_to_argv_array(sb.buf, &state->git_apply_opts) < 0)
+	if (sq_dequote_to_strvec(sb.buf, &state->git_apply_opts) < 0)
 		die(_("could not parse %s"), am_path(state, "apply-opt"));
 
 	state->rebasing = !!file_exists(am_path(state, "rebasing"));
quote.c +1 -1
index dac8b4e55e..10b383cc1d 100644
@@ -198,7 +198,7 @@ int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc)
 	return sq_dequote_to_argv_internal(arg, argv, nr, alloc, NULL);
 }
 
-int sq_dequote_to_argv_array(char *arg, struct argv_array *array)
+int sq_dequote_to_strvec(char *arg, struct strvec *array)
 {
 	return sq_dequote_to_argv_internal(arg, NULL, NULL, NULL, array);
 }
quote.h +3 -3
index 210d580229..fa09309cf6 100644
@@ -56,12 +56,12 @@ char *sq_dequote(char *);
 int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc);
 
 /*
- * Same as above, but store the unquoted strings in an argv_array. We will
- * still modify arg in place, but unlike sq_dequote_to_argv, the argv_array
+ * Same as above, but store the unquoted strings in a strvec. We will
+ * still modify arg in place, but unlike sq_dequote_to_argv, the strvec
  * will duplicate and take ownership of the strings.
  */
 struct strvec;
-int sq_dequote_to_argv_array(char *arg, struct strvec *);
+int sq_dequote_to_strvec(char *arg, struct strvec *);
 
 int unquote_c_style(struct strbuf *, const char *quoted, const char **endp);
 size_t quote_c_style(const char *name, struct strbuf *, FILE *, int no_dq);
Signature · 1 line
2.28.0.rc2.475.g53c7e1c7f4
author
#5 lore raw

PATCH 5/11 strvec: convert builtin/ callers away from argv_array name

In reply to Jeff King

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 files in builtin/ to keep the diff to a manageable size.

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;

'

and then selectively staging files with "git add builtin/". We'll deal with any indentation/style fallouts separately.

---
 builtin/add.c               |  14 ++--
 builtin/am.c                |  66 ++++++++--------
 builtin/annotate.c          |   6 +-
 builtin/bisect--helper.c    |  12 +--
 builtin/bundle.c            |  12 +--
 builtin/clone.c             |  34 ++++-----
 builtin/commit.c            |   6 +-
 builtin/describe.c          |  28 +++----
 builtin/difftool.c          |  14 ++--
 builtin/fetch.c             |  54 ++++++-------
 builtin/gc.c                |  50 ++++++------
 builtin/grep.c              |   2 +-
 builtin/log.c               |  12 +--
 builtin/ls-remote.c         |   6 +-
 builtin/pack-objects.c      |  22 +++---
 builtin/pull.c              | 148 ++++++++++++++++++------------------
 builtin/range-diff.c        |   4 +-
 builtin/rebase.c            |  60 +++++++--------
 builtin/receive-pack.c      |  68 ++++++++---------
 builtin/remote-ext.c        |   4 +-
 builtin/remote.c            |  20 ++---
 builtin/repack.c            |  62 +++++++--------
 builtin/replace.c           |  16 ++--
 builtin/show-branch.c       |   6 +-
 builtin/stash.c             | 114 +++++++++++++--------------
 builtin/submodule--helper.c | 118 ++++++++++++++--------------
 builtin/upload-archive.c    |   6 +-
 builtin/worktree.c          |  42 +++++-----
 28 files changed, 503 insertions(+), 503 deletions(-)
builtin/add.c +7 -7
index 6cd9a4cd77..6185dd12a8 100644
@@ -188,7 +188,7 @@ int run_add_interactive(const char *revision, const char *patch_mode,
 			const struct pathspec *pathspec)
 {
 	int status, i;
-	struct argv_array argv = ARGV_ARRAY_INIT;
+	struct strvec argv = STRVEC_INIT;
 	int use_builtin_add_i =
 		git_env_bool("GIT_TEST_ADD_I_USE_BUILTIN", -1);
 
@@ -218,18 +218,18 @@ int run_add_interactive(const char *revision, const char *patch_mode,
 		return !!run_add_p(the_repository, mode, revision, pathspec);
 	}
 
-	argv_array_push(&argv, "add--interactive");
+	strvec_push(&argv, "add--interactive");
 	if (patch_mode)
-		argv_array_push(&argv, patch_mode);
+		strvec_push(&argv, patch_mode);
 	if (revision)
-		argv_array_push(&argv, revision);
-	argv_array_push(&argv, "--");
+		strvec_push(&argv, revision);
+	strvec_push(&argv, "--");
 	for (i = 0; i < pathspec->nr; i++)
 		/* pass original pathspec, to be re-parsed */
-		argv_array_push(&argv, pathspec->items[i].original);
+		strvec_push(&argv, pathspec->items[i].original);
 
 	status = run_command_v_opt(argv.argv, RUN_GIT_CMD);
-	argv_array_clear(&argv);
+	strvec_clear(&argv);
 	return status;
 }
 
builtin/am.c +33 -33

175 lines not on this page · raw message

builtin/annotate.c +3 -3
index 4353448712..7b7ecd366d 100644
@@ -9,13 +9,13 @@
 
 int cmd_annotate(int argc, const char **argv, const char *prefix)
 {
-	struct argv_array args = ARGV_ARRAY_INIT;
+	struct strvec args = STRVEC_INIT;
 	int i;
 
-	argv_array_pushl(&args, "annotate", "-c", NULL);
+	strvec_pushl(&args, "annotate", "-c", NULL);
 
 	for (i = 1; i < argc; i++) {
-		argv_array_push(&args, argv[i]);
+		strvec_push(&args, argv[i]);
 	}
 
 	return cmd_blame(args.argc, args.argv, prefix);
builtin/bisect--helper.c +6 -6
index e929315b38..9815e78871 100644
@@ -165,18 +165,18 @@ static int bisect_reset(const char *commit)
 	}
 
 	if (!file_exists(git_path_bisect_head())) {
-		struct argv_array argv = ARGV_ARRAY_INIT;
+		struct strvec argv = STRVEC_INIT;
 
-		argv_array_pushl(&argv, "checkout", branch.buf, "--", NULL);
+		strvec_pushl(&argv, "checkout", branch.buf, "--", NULL);
 		if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
 			error(_("could not check out original"
 				" HEAD '%s'. Try 'git bisect"
 				" reset <commit>'."), branch.buf);
 			strbuf_release(&branch);
-			argv_array_clear(&argv);
+			strvec_clear(&argv);
 			return -1;
 		}
-		argv_array_clear(&argv);
+		strvec_clear(&argv);
 	}
 
 	strbuf_release(&branch);
@@ -526,9 +526,9 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
 		strbuf_read_file(&start_head, git_path_bisect_start(), 0);
 		strbuf_trim(&start_head);
 		if (!no_checkout) {
-			struct argv_array argv = ARGV_ARRAY_INIT;
+			struct strvec argv = STRVEC_INIT;
 
-			argv_array_pushl(&argv, "checkout", start_head.buf,
+			strvec_pushl(&argv, "checkout", start_head.buf,
 					 "--", NULL);
 			if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
 				res = error(_("checking out '%s' failed."
builtin/bundle.c +6 -6
index 51fc6d9739..750630bdd9 100644
@@ -59,7 +59,7 @@ static int parse_options_cmd_bundle(int argc,
 static int cmd_bundle_create(int argc, const char **argv, const char *prefix) {
 	int all_progress_implied = 0;
 	int progress = isatty(STDERR_FILENO);
-	struct argv_array pack_opts;
+	struct strvec pack_opts;
 
 	struct option options[] = {
 		OPT_SET_INT('q', "quiet", &progress,
@@ -79,15 +79,15 @@ static int cmd_bundle_create(int argc, const char **argv, const char *prefix) {
 			builtin_bundle_create_usage, options, &bundle_file);
 	/* bundle internals use argv[1] as further parameters */
 
-	argv_array_init(&pack_opts);
+	strvec_init(&pack_opts);
 	if (progress == 0)
-		argv_array_push(&pack_opts, "--quiet");
+		strvec_push(&pack_opts, "--quiet");
 	else if (progress == 1)
-		argv_array_push(&pack_opts, "--progress");
+		strvec_push(&pack_opts, "--progress");
 	else if (progress == 2)
-		argv_array_push(&pack_opts, "--all-progress");
+		strvec_push(&pack_opts, "--all-progress");
 	if (progress && all_progress_implied)
-		argv_array_push(&pack_opts, "--all-progress-implied");
+		strvec_push(&pack_opts, "--all-progress-implied");
 
 	if (!startup_info->have_repository)
 		die(_("Need a repository to create a bundle."));
builtin/clone.c +17 -17
index bef70745c0..e26bd82dc4 100644
@@ -742,9 +742,9 @@ static void update_head(const struct ref *our, const struct ref *remote,
 
 static int git_sparse_checkout_init(const char *repo)
 {
-	struct argv_array argv = ARGV_ARRAY_INIT;
+	struct strvec argv = STRVEC_INIT;
 	int result = 0;
-	argv_array_pushl(&argv, "-C", repo, "sparse-checkout", "init", NULL);
+	strvec_pushl(&argv, "-C", repo, "sparse-checkout", "init", NULL);
 
 	/*
 	 * We must apply the setting in the current process
@@ -757,7 +757,7 @@ static int git_sparse_checkout_init(const char *repo)
 		result = 1;
 	}
 
-	argv_array_clear(&argv);
+	strvec_clear(&argv);
 	return result;
 }
 
@@ -819,33 +819,33 @@ static int checkout(int submodule_progress)
 			   oid_to_hex(&oid), "1", NULL);
 
 	if (!err && (option_recurse_submodules.nr > 0)) {
-		struct argv_array args = ARGV_ARRAY_INIT;
-		argv_array_pushl(&args, "submodule", "update", "--require-init", "--recursive", NULL);
+		struct strvec args = STRVEC_INIT;
+		strvec_pushl(&args, "submodule", "update", "--require-init", "--recursive", NULL);
 
 		if (option_shallow_submodules == 1)
-			argv_array_push(&args, "--depth=1");
+			strvec_push(&args, "--depth=1");
 
 		if (max_jobs != -1)
-			argv_array_pushf(&args, "--jobs=%d", max_jobs);
+			strvec_pushf(&args, "--jobs=%d", max_jobs);
 
 		if (submodule_progress)
-			argv_array_push(&args, "--progress");
+			strvec_push(&args, "--progress");
 
 		if (option_verbosity < 0)
-			argv_array_push(&args, "--quiet");
+			strvec_push(&args, "--quiet");
 
 		if (option_remote_submodules) {
-			argv_array_push(&args, "--remote");
-			argv_array_push(&args, "--no-fetch");
+			strvec_push(&args, "--remote");
+			strvec_push(&args, "--no-fetch");
 		}
 
 		if (option_single_branch >= 0)
-			argv_array_push(&args, option_single_branch ?
+			strvec_push(&args, option_single_branch ?
 					       "--single-branch" :
 					       "--no-single-branch");
 
 		err = run_command_v_opt(args.argv, RUN_GIT_CMD);
-		argv_array_clear(&args);
+		strvec_clear(&args);
 	}
 
 	return err;
@@ -961,7 +961,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	int err = 0, complete_refs_before_fetch = 1;
 	int submodule_progress;
 
-	struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
+	struct strvec ref_prefixes = STRVEC_INIT;
 
 	packet_trace_identity("clone");
 	argc = parse_options(argc, argv, prefix, builtin_clone_options,
@@ -1211,12 +1211,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		transport->smart_options->check_self_contained_and_connected = 1;
 
 
-	argv_array_push(&ref_prefixes, "HEAD");
+	strvec_push(&ref_prefixes, "HEAD");
 	refspec_ref_prefixes(&remote->fetch, &ref_prefixes);
 	if (option_branch)
 		expand_ref_prefix(&ref_prefixes, option_branch);
 	if (!option_no_tags)
-		argv_array_push(&ref_prefixes, "refs/tags/");
+		strvec_push(&ref_prefixes, "refs/tags/");
 
 	refs = transport_get_remote_refs(transport, &ref_prefixes);
 
@@ -1327,6 +1327,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	strbuf_release(&default_refspec);
 	junk_mode = JUNK_LEAVE_ALL;
 
-	argv_array_clear(&ref_prefixes);
+	strvec_clear(&ref_prefixes);
 	return err;
 }
builtin/commit.c +3 -3
index d1b7396052..c3f4067537 100644
@@ -1005,15 +1005,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		return 0;
 
 	if (use_editor) {
-		struct argv_array env = ARGV_ARRAY_INIT;
+		struct strvec env = STRVEC_INIT;
 
-		argv_array_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
+		strvec_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
 		if (launch_editor(git_path_commit_editmsg(), NULL, env.argv)) {
 			fprintf(stderr,
 			_("Please supply the message using either -m or -F option.\n"));
 			exit(1);
 		}
-		argv_array_clear(&env);
+		strvec_clear(&env);
 	}
 
 	if (!no_verify &&
builtin/describe.c +14 -14
index 32ad6822f7..ff3c169fa9 100644
@@ -501,10 +501,10 @@ static void process_object(struct object *obj, const char *path, void *data)
 static void describe_blob(struct object_id oid, struct strbuf *dst)
 {
 	struct rev_info revs;
-	struct argv_array args = ARGV_ARRAY_INIT;
+	struct strvec args = STRVEC_INIT;
 	struct process_commit_data pcd = { null_oid, oid, dst, &revs};
 
-	argv_array_pushl(&args, "internal: The first arg is not parsed",
+	strvec_pushl(&args, "internal: The first arg is not parsed",
 		"--objects", "--in-commit-order", "--reverse", "HEAD",
 		NULL);
 
@@ -594,25 +594,25 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 
 	if (contains) {
 		struct string_list_item *item;
-		struct argv_array args;
+		struct strvec args;
 
-		argv_array_init(&args);
-		argv_array_pushl(&args, "name-rev",
+		strvec_init(&args);
+		strvec_pushl(&args, "name-rev",
 				 "--peel-tag", "--name-only", "--no-undefined",
 				 NULL);
 		if (always)
-			argv_array_push(&args, "--always");
+			strvec_push(&args, "--always");
 		if (!all) {
-			argv_array_push(&args, "--tags");
+			strvec_push(&args, "--tags");
 			for_each_string_list_item(item, &patterns)
-				argv_array_pushf(&args, "--refs=refs/tags/%s", item->string);
+				strvec_pushf(&args, "--refs=refs/tags/%s", item->string);
 			for_each_string_list_item(item, &exclude_patterns)
-				argv_array_pushf(&args, "--exclude=refs/tags/%s", item->string);
+				strvec_pushf(&args, "--exclude=refs/tags/%s", item->string);
 		}
 		if (argc)
-			argv_array_pushv(&args, argv);
+			strvec_pushv(&args, argv);
 		else
-			argv_array_push(&args, "HEAD");
+			strvec_push(&args, "HEAD");
 		return cmd_name_rev(args.argc, args.argv, prefix);
 	}
 
@@ -624,7 +624,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 	if (argc == 0) {
 		if (broken) {
 			struct child_process cp = CHILD_PROCESS_INIT;
-			argv_array_pushv(&cp.args, diff_index_args);
+			strvec_pushv(&cp.args, diff_index_args);
 			cp.git_cmd = 1;
 			cp.no_stdin = 1;
 			cp.no_stdout = 1;
@@ -646,7 +646,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 		} else if (dirty) {
 			struct lock_file index_lock = LOCK_INIT;
 			struct rev_info revs;
-			struct argv_array args = ARGV_ARRAY_INIT;
+			struct strvec args = STRVEC_INIT;
 			int fd, result;
 
 			setup_work_tree();
@@ -658,7 +658,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 				repo_update_index_if_able(the_repository, &index_lock);
 
 			repo_init_revisions(the_repository, &revs, prefix);
-			argv_array_pushv(&args, diff_index_args);
+			strvec_pushv(&args, diff_index_args);
 			if (setup_revisions(args.argc, args.argv, &revs, NULL) != 1)
 				BUG("malformed internal diff-index command line");
 			result = run_diff_index(&revs, 0);
builtin/difftool.c +7 -7
index c0608a78d9..40c4d7b6b6 100644
@@ -210,7 +210,7 @@ static void changed_files(struct hashmap *result, const char *index_path,
 	strbuf_addf(&index_env, "GIT_INDEX_FILE=%s", index_path);
 	env[0] = index_env.buf;
 
-	argv_array_pushl(&update_index.args,
+	strvec_pushl(&update_index.args,
 			 "--git-dir", git_dir, "--work-tree", workdir,
 			 "update-index", "--really-refresh", "-q",
 			 "--unmerged", NULL);
@@ -225,7 +225,7 @@ static void changed_files(struct hashmap *result, const char *index_path,
 	/* Ignore any errors of update-index */
 	run_command(&update_index);
 
-	argv_array_pushl(&diff_files.args,
+	strvec_pushl(&diff_files.args,
 			 "--git-dir", git_dir, "--work-tree", workdir,
 			 "diff-files", "--name-only", "-z", NULL);
 	diff_files.no_stdin = 1;
@@ -393,10 +393,10 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
 	child.clean_on_exit = 1;
 	child.dir = prefix;
 	child.out = -1;
-	argv_array_pushl(&child.args, "diff", "--raw", "--no-abbrev", "-z",
+	strvec_pushl(&child.args, "diff", "--raw", "--no-abbrev", "-z",
 			 NULL);
 	for (i = 0; i < argc; i++)
-		argv_array_push(&child.args, argv[i]);
+		strvec_push(&child.args, argv[i]);
 	if (start_command(&child))
 		die("could not obtain raw diff");
 	fp = xfdopen(child.out, "r");
@@ -667,7 +667,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
 static int run_file_diff(int prompt, const char *prefix,
 			 int argc, const char **argv)
 {
-	struct argv_array args = ARGV_ARRAY_INIT;
+	struct strvec args = STRVEC_INIT;
 	const char *env[] = {
 		"GIT_PAGER=", "GIT_EXTERNAL_DIFF=git-difftool--helper", NULL,
 		NULL
@@ -680,9 +680,9 @@ static int run_file_diff(int prompt, const char *prefix,
 		env[2] = "GIT_DIFFTOOL_NO_PROMPT=true";
 
 
-	argv_array_push(&args, "diff");
+	strvec_push(&args, "diff");
 	for (i = 0; i < argc; i++)
-		argv_array_push(&args, argv[i]);
+		strvec_push(&args, argv[i]);
 	ret = run_command_v_opt_cd_env(args.argv, RUN_GIT_CMD, prefix, env);
 	exit(ret);
 }
builtin/fetch.c +27 -27

143 lines not on this page · raw message

builtin/gc.c +25 -25

107 lines not on this page · raw message

builtin/grep.c +1 -1
index a5056f395a..2ae77eb8b3 100644
@@ -397,7 +397,7 @@ static void run_pager(struct grep_opt *opt, const char *prefix)
 	int i, status;
 
 	for (i = 0; i < path_list->nr; i++)
-		argv_array_push(&child.args, path_list->items[i].string);
+		strvec_push(&child.args, path_list->items[i].string);
 	child.dir = prefix;
 	child.use_shell = 1;
 
builtin/log.c +6 -6
index d104d5c688..33528fefa9 100644
@@ -1128,18 +1128,18 @@ static void prepare_cover_text(struct pretty_print_context *pp,
 
 static int get_notes_refs(struct string_list_item *item, void *arg)
 {
-	argv_array_pushf(arg, "--notes=%s", item->string);
+	strvec_pushf(arg, "--notes=%s", item->string);
 	return 0;
 }
 
-static void get_notes_args(struct argv_array *arg, struct rev_info *rev)
+static void get_notes_args(struct strvec *arg, struct rev_info *rev)
 {
 	if (!rev->show_notes) {
-		argv_array_push(arg, "--no-notes");
+		strvec_push(arg, "--no-notes");
 	} else if (rev->notes_opt.use_default_notes > 0 ||
 		   (rev->notes_opt.use_default_notes == -1 &&
 		    !rev->notes_opt.extra_notes_refs.nr)) {
-		argv_array_push(arg, "--notes");
+		strvec_push(arg, "--notes");
 	} else {
 		for_each_string_list(&rev->notes_opt.extra_notes_refs, get_notes_refs, arg);
 	}
@@ -1217,7 +1217,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 		 * can be added later if deemed desirable.
 		 */
 		struct diff_options opts;
-		struct argv_array other_arg = ARGV_ARRAY_INIT;
+		struct strvec other_arg = STRVEC_INIT;
 		diff_setup(&opts);
 		opts.file = rev->diffopt.file;
 		opts.use_color = rev->diffopt.use_color;
@@ -1226,7 +1226,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 		get_notes_args(&other_arg, rev);
 		show_range_diff(rev->rdiff1, rev->rdiff2,
 				rev->creation_factor, 1, &opts, &other_arg);
-		argv_array_clear(&other_arg);
+		strvec_clear(&other_arg);
 	}
 }
 
builtin/ls-remote.c +3 -3
index 3a4dd12903..ea91679f33 100644
@@ -45,7 +45,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 	int show_symref_target = 0;
 	const char *uploadpack = NULL;
 	const char **pattern = NULL;
-	struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
+	struct strvec ref_prefixes = STRVEC_INIT;
 	int i;
 	struct string_list server_options = STRING_LIST_INIT_DUP;
 
@@ -92,9 +92,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 	}
 
 	if (flags & REF_TAGS)
-		argv_array_push(&ref_prefixes, "refs/tags/");
+		strvec_push(&ref_prefixes, "refs/tags/");
 	if (flags & REF_HEADS)
-		argv_array_push(&ref_prefixes, "refs/heads/");
+		strvec_push(&ref_prefixes, "refs/heads/");
 
 	remote = remote_get(dest);
 	if (!remote) {
builtin/pack-objects.c +11 -11
index 5f18f0ee9d..323f8bce80 100644
@@ -3439,7 +3439,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 	int use_internal_rev_list = 0;
 	int shallow = 0;
 	int all_progress_implied = 0;
-	struct argv_array rp = ARGV_ARRAY_INIT;
+	struct strvec rp = STRVEC_INIT;
 	int rev_list_unpacked = 0, rev_list_all = 0, rev_list_reflog = 0;
 	int rev_list_index = 0;
 	struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
@@ -3575,36 +3575,36 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 		cache_max_small_delta_size = (1U << OE_Z_DELTA_BITS) - 1;
 	}
 
-	argv_array_push(&rp, "pack-objects");
+	strvec_push(&rp, "pack-objects");
 	if (thin) {
 		use_internal_rev_list = 1;
-		argv_array_push(&rp, shallow
+		strvec_push(&rp, shallow
 				? "--objects-edge-aggressive"
 				: "--objects-edge");
 	} else
-		argv_array_push(&rp, "--objects");
+		strvec_push(&rp, "--objects");
 
 	if (rev_list_all) {
 		use_internal_rev_list = 1;
-		argv_array_push(&rp, "--all");
+		strvec_push(&rp, "--all");
 	}
 	if (rev_list_reflog) {
 		use_internal_rev_list = 1;
-		argv_array_push(&rp, "--reflog");
+		strvec_push(&rp, "--reflog");
 	}
 	if (rev_list_index) {
 		use_internal_rev_list = 1;
-		argv_array_push(&rp, "--indexed-objects");
+		strvec_push(&rp, "--indexed-objects");
 	}
 	if (rev_list_unpacked) {
 		use_internal_rev_list = 1;
-		argv_array_push(&rp, "--unpacked");
+		strvec_push(&rp, "--unpacked");
 	}
 
 	if (exclude_promisor_objects) {
 		use_internal_rev_list = 1;
 		fetch_if_missing = 0;
-		argv_array_push(&rp, "--exclude-promisor-objects");
+		strvec_push(&rp, "--exclude-promisor-objects");
 	}
 	if (unpack_unreachable || keep_unreachable || pack_loose_unreachable)
 		use_internal_rev_list = 1;
@@ -3666,7 +3666,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 		write_bitmap_index = 0;
 
 	if (use_delta_islands)
-		argv_array_push(&rp, "--topo-order");
+		strvec_push(&rp, "--topo-order");
 
 	if (progress && all_progress_implied)
 		progress = 2;
@@ -3705,7 +3705,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 		read_object_list_from_stdin();
 	else {
 		get_object_list(rp.argc, rp.argv);
-		argv_array_clear(&rp);
+		strvec_clear(&rp);
 	}
 	cleanup_preferred_base();
 	if (include_tag && nr_result)
builtin/pull.c +74 -74

306 lines not on this page · raw message

builtin/range-diff.c +2 -2
index d8a4670629..24c4162f74 100644
@@ -15,7 +15,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
 {
 	int creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT;
 	struct diff_options diffopt = { NULL };
-	struct argv_array other_arg = ARGV_ARRAY_INIT;
+	struct strvec other_arg = STRVEC_INIT;
 	int simple_color = -1;
 	struct option range_diff_options[] = {
 		OPT_INTEGER(0, "creation-factor", &creation_factor,
@@ -84,7 +84,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
 	res = show_range_diff(range1.buf, range2.buf, creation_factor,
 			      simple_color < 1, &diffopt, &other_arg);
 
-	argv_array_clear(&other_arg);
+	strvec_clear(&other_arg);
 	strbuf_release(&range1);
 	strbuf_release(&range2);
 
builtin/rebase.c +30 -30

167 lines not on this page · raw message

builtin/receive-pack.c +34 -34

178 lines not on this page · raw message

builtin/remote-ext.c +2 -2
index 6a9127a33c..fd3538d4f0 100644
@@ -117,12 +117,12 @@ static char *strip_escapes(const char *str, const char *service,
 	}
 }
 
-static void parse_argv(struct argv_array *out, const char *arg, const char *service)
+static void parse_argv(struct strvec *out, const char *arg, const char *service)
 {
 	while (*arg) {
 		char *expanded = strip_escapes(arg, service, &arg);
 		if (expanded)
-			argv_array_push(out, expanded);
+			strvec_push(out, expanded);
 		free(expanded);
 	}
 }
builtin/remote.c +10 -10
index a9f35ba855..a3b33c2c88 100644
@@ -1451,35 +1451,35 @@ static int update(int argc, const char **argv)
 			 N_("prune remotes after fetching")),
 		OPT_END()
 	};
-	struct argv_array fetch_argv = ARGV_ARRAY_INIT;
+	struct strvec fetch_argv = STRVEC_INIT;
 	int default_defined = 0;
 	int retval;
 
 	argc = parse_options(argc, argv, NULL, options, builtin_remote_update_usage,
 			     PARSE_OPT_KEEP_ARGV0);
 
-	argv_array_push(&fetch_argv, "fetch");
+	strvec_push(&fetch_argv, "fetch");
 
 	if (prune != -1)
-		argv_array_push(&fetch_argv, prune ? "--prune" : "--no-prune");
+		strvec_push(&fetch_argv, prune ? "--prune" : "--no-prune");
 	if (verbose)
-		argv_array_push(&fetch_argv, "-v");
-	argv_array_push(&fetch_argv, "--multiple");
+		strvec_push(&fetch_argv, "-v");
+	strvec_push(&fetch_argv, "--multiple");
 	if (argc < 2)
-		argv_array_push(&fetch_argv, "default");
+		strvec_push(&fetch_argv, "default");
 	for (i = 1; i < argc; i++)
-		argv_array_push(&fetch_argv, argv[i]);
+		strvec_push(&fetch_argv, argv[i]);
 
 	if (strcmp(fetch_argv.argv[fetch_argv.argc-1], "default") == 0) {
 		git_config(get_remote_default, &default_defined);
 		if (!default_defined) {
-			argv_array_pop(&fetch_argv);
-			argv_array_push(&fetch_argv, "--all");
+			strvec_pop(&fetch_argv);
+			strvec_push(&fetch_argv, "--all");
 		}
 	}
 
 	retval = run_command_v_opt(fetch_argv.argv, RUN_GIT_CMD);
-	argv_array_clear(&fetch_argv);
+	strvec_clear(&fetch_argv);
 	return retval;
 }
 
builtin/repack.c +31 -31

106 lines not on this page · raw message

builtin/replace.c +8 -8
index b36d17a657..7bc5d66ed9 100644
@@ -228,13 +228,13 @@ static int export_object(const struct object_id *oid, enum object_type type,
 	if (fd < 0)
 		return error_errno(_("unable to open %s for writing"), filename);
 
-	argv_array_push(&cmd.args, "--no-replace-objects");
-	argv_array_push(&cmd.args, "cat-file");
+	strvec_push(&cmd.args, "--no-replace-objects");
+	strvec_push(&cmd.args, "cat-file");
 	if (raw)
-		argv_array_push(&cmd.args, type_name(type));
+		strvec_push(&cmd.args, type_name(type));
 	else
-		argv_array_push(&cmd.args, "-p");
-	argv_array_push(&cmd.args, oid_to_hex(oid));
+		strvec_push(&cmd.args, "-p");
+	strvec_push(&cmd.args, oid_to_hex(oid));
 	cmd.git_cmd = 1;
 	cmd.out = fd;
 
@@ -502,7 +502,7 @@ static int convert_graft_file(int force)
 	const char *graft_file = get_graft_file(the_repository);
 	FILE *fp = fopen_or_warn(graft_file, "r");
 	struct strbuf buf = STRBUF_INIT, err = STRBUF_INIT;
-	struct argv_array args = ARGV_ARRAY_INIT;
+	struct strvec args = STRVEC_INIT;
 
 	if (!fp)
 		return -1;
@@ -512,10 +512,10 @@ static int convert_graft_file(int force)
 		if (*buf.buf == '#')
 			continue;
 
-		argv_array_split(&args, buf.buf);
+		strvec_split(&args, buf.buf);
 		if (args.argc && create_graft(args.argc, args.argv, force, 1))
 			strbuf_addf(&err, "\n\t%s", buf.buf);
-		argv_array_clear(&args);
+		strvec_clear(&args);
 	}
 	fclose(fp);
 
builtin/show-branch.c +3 -3
index f0a70538c3..4c918ce90d 100644
@@ -20,7 +20,7 @@ static const char* show_branch_usage[] = {
 
 static int showbranch_use_color = -1;
 
-static struct argv_array default_args = ARGV_ARRAY_INIT;
+static struct strvec default_args = STRVEC_INIT;
 
 /*
  * TODO: convert this use of commit->object.flags to commit-slab
@@ -562,8 +562,8 @@ static int git_show_branch_config(const char *var, const char *value, void *cb)
 		 * mimic the real argv a bit better.
 		 */
 		if (!default_args.argc)
-			argv_array_push(&default_args, "show-branch");
-		argv_array_push(&default_args, value);
+			strvec_push(&default_args, "show-branch");
+		strvec_push(&default_args, value);
 		return 0;
 	}
 
builtin/stash.c +57 -57

312 lines not on this page · raw message

builtin/submodule--helper.c +59 -59

247 lines not on this page · raw message

builtin/upload-archive.c +3 -3
index 7fc8e0e82d..f02bb0ea15 100644
@@ -19,7 +19,7 @@ static const char deadchild[] =
 
 int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
 {
-	struct argv_array sent_argv = ARGV_ARRAY_INIT;
+	struct strvec sent_argv = STRVEC_INIT;
 	const char *arg_cmd = "argument ";
 
 	if (argc != 2 || !strcmp(argv[1], "-h"))
@@ -31,7 +31,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
 	init_archivers();
 
 	/* put received options in sent_argv[] */
-	argv_array_push(&sent_argv, "git-upload-archive");
+	strvec_push(&sent_argv, "git-upload-archive");
 	for (;;) {
 		char *buf = packet_read_line(0, NULL);
 		if (!buf)
@@ -41,7 +41,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
 
 		if (!starts_with(buf, arg_cmd))
 			die("'argument' token or flush expected");
-		argv_array_push(&sent_argv, buf + strlen(arg_cmd));
+		strvec_push(&sent_argv, buf + strlen(arg_cmd));
 	}
 
 	/* parse all options sent by the client */
builtin/worktree.c +21 -21

105 lines not on this page · raw message

Signature · 1 line
2.28.0.rc2.475.g53c7e1c7f4
author
#6 lore raw

PATCH 6/11 strvec: convert more callers away from argv_array name

In reply to Jeff King

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 remaining files from the first half of the alphabet, to keep the diff to a manageable size.

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;

'

and then selectively staging files with "git add '[abcdefghjkl]*'". We'll deal with any indentation/style fallouts separately.

---
 add-interactive.c | 14 ++++++-------
 add-patch.c       | 28 ++++++++++++-------------
 bisect.c          | 12 +++++------
 bundle.c          | 12 +++++------
 bundle.h          |  2 +-
 column.c          | 12 +++++------
 commit.c          |  8 ++++----
 compat/mingw.c    |  4 ++--
 compat/terminal.c | 18 ++++++++--------
 connect.c         | 48 +++++++++++++++++++++----------------------
 connected.c       | 22 ++++++++++----------
 daemon.c          | 52 +++++++++++++++++++++++------------------------
 diff.c            | 28 ++++++++++++-------------
 environment.c     |  8 ++++----
 exec-cmd.c        | 10 ++++-----
 fast-import.c     |  4 ++--
 fetch-pack.c      | 34 +++++++++++++++----------------
 fsmonitor.c       |  6 +++---
 git.c             | 22 ++++++++++----------
 gpg-interface.c   |  8 ++++----
 graph.c           | 10 ++++-----
 http-backend.c    |  4 ++--
 http-push.c       | 12 +++++------
 http.c            |  6 +++---
 imap-send.c       |  2 +-
 line-log.c        |  6 +++---
 ls-refs.c         | 10 ++++-----
 27 files changed, 201 insertions(+), 201 deletions(-)
add-interactive.c +7 -7
index 29cd2fe020..b345777d0c 100644
@@ -935,18 +935,18 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps,
 	opts->prompt = N_("Patch update");
 	count = list_and_choose(s, files, opts);
 	if (count > 0) {
-		struct argv_array args = ARGV_ARRAY_INIT;
+		struct strvec args = STRVEC_INIT;
 		struct pathspec ps_selected = { 0 };
 
 		for (i = 0; i < files->items.nr; i++)
 			if (files->selected[i])
-				argv_array_push(&args,
+				strvec_push(&args,
 						files->items.items[i].string);
 		parse_pathspec(&ps_selected,
 			       PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
 			       PATHSPEC_LITERAL_PATH, "", args.argv);
 		res = run_add_p(s->r, ADD_P_ADD, NULL, &ps_selected);
-		argv_array_clear(&args);
+		strvec_clear(&args);
 		clear_pathspec(&ps_selected);
 	}
 
@@ -976,18 +976,18 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
 	count = list_and_choose(s, files, opts);
 	opts->flags = 0;
 	if (count > 0) {
-		struct argv_array args = ARGV_ARRAY_INIT;
+		struct strvec args = STRVEC_INIT;
 
-		argv_array_pushl(&args, "git", "diff", "-p", "--cached",
+		strvec_pushl(&args, "git", "diff", "-p", "--cached",
 				 oid_to_hex(!is_initial ? &oid :
 					    s->r->hash_algo->empty_tree),
 				 "--", NULL);
 		for (i = 0; i < files->items.nr; i++)
 			if (files->selected[i])
-				argv_array_push(&args,
+				strvec_push(&args,
 						files->items.items[i].string);
 		res = run_command_v_opt(args.argv, 0);
-		argv_array_clear(&args);
+		strvec_clear(&args);
 	}
 
 	putchar('\n');
add-patch.c +14 -14
index 09d00c5574..3c91ae52ae 100644
@@ -286,11 +286,11 @@ static void setup_child_process(struct add_p_state *s,
 
 	va_start(ap, cp);
 	while ((arg = va_arg(ap, const char *)))
-		argv_array_push(&cp->args, arg);
+		strvec_push(&cp->args, arg);
 	va_end(ap);
 
 	cp->git_cmd = 1;
-	argv_array_pushf(&cp->env_array,
+	strvec_pushf(&cp->env_array,
 			 INDEX_ENVIRONMENT "=%s", s->s.r->index_file);
 }
 
@@ -370,7 +370,7 @@ static int is_octal(const char *p, size_t len)
 
 static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 {
-	struct argv_array args = ARGV_ARRAY_INIT;
+	struct strvec args = STRVEC_INIT;
 	const char *diff_algorithm = s->s.interactive_diff_algorithm;
 	struct strbuf *plain = &s->plain, *colored = NULL;
 	struct child_process cp = CHILD_PROCESS_INIT;
@@ -380,32 +380,32 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 	struct hunk *hunk = NULL;
 	int res;
 
-	argv_array_pushv(&args, s->mode->diff_cmd);
+	strvec_pushv(&args, s->mode->diff_cmd);
 	if (diff_algorithm)
-		argv_array_pushf(&args, "--diff-algorithm=%s", diff_algorithm);
+		strvec_pushf(&args, "--diff-algorithm=%s", diff_algorithm);
 	if (s->revision) {
 		struct object_id oid;
-		argv_array_push(&args,
+		strvec_push(&args,
 				/* could be on an unborn branch */
 				!strcmp("HEAD", s->revision) &&
 				get_oid("HEAD", &oid) ?
 				empty_tree_oid_hex() : s->revision);
 	}
 	color_arg_index = args.argc;
 	/* Use `--no-color` explicitly, just in case `diff.color = always`. */
-	argv_array_pushl(&args, "--no-color", "-p", "--", NULL);
+	strvec_pushl(&args, "--no-color", "-p", "--", NULL);
 	for (i = 0; i < ps->nr; i++)
-		argv_array_push(&args, ps->items[i].original);
+		strvec_push(&args, ps->items[i].original);
 
 	setup_child_process(s, &cp, NULL);
 	cp.argv = args.argv;
 	res = capture_command(&cp, plain, 0);
 	if (res) {
-		argv_array_clear(&args);
+		strvec_clear(&args);
 		return error(_("could not parse diff"));
 	}
 	if (!plain->len) {
-		argv_array_clear(&args);
+		strvec_clear(&args);
 		return 0;
 	}
 	strbuf_complete_line(plain);
@@ -419,7 +419,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 		colored_cp.argv = args.argv;
 		colored = &s->colored;
 		res = capture_command(&colored_cp, colored, 0);
-		argv_array_clear(&args);
+		strvec_clear(&args);
 		if (res)
 			return error(_("could not parse colored diff"));
 
@@ -444,7 +444,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 		colored_p = colored->buf;
 		colored_pend = colored_p + colored->len;
 	}
-	argv_array_clear(&args);
+	strvec_clear(&args);
 
 	/* parse files and hunks */
 	p = plain->buf;
@@ -1158,7 +1158,7 @@ static int run_apply_check(struct add_p_state *s,
 
 	setup_child_process(s, &cp,
 			    "apply", "--check", NULL);
-	argv_array_pushv(&cp.args, s->mode->apply_check_args);
+	strvec_pushv(&cp.args, s->mode->apply_check_args);
 	if (pipe_command(&cp, s->buf.buf, s->buf.len, NULL, 0, NULL, 0))
 		return error(_("'git apply --cached' failed"));
 
@@ -1619,7 +1619,7 @@ static int patch_update_file(struct add_p_state *s,
 					   s->mode->is_reverse);
 		else {
 			setup_child_process(s, &cp, "apply", NULL);
-			argv_array_pushv(&cp.args, s->mode->apply_args);
+			strvec_pushv(&cp.args, s->mode->apply_args);
 			if (pipe_command(&cp, s->buf.buf, s->buf.len,
 					 NULL, 0, NULL, 0))
 				error(_("'git apply' failed"));
bisect.c +6 -6
index 77e35ddd43..3e50b51c11 100644
@@ -456,7 +456,7 @@ static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG")
 static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS")
 static GIT_PATH_FUNC(git_path_head_name, "head-name")
 
-static void read_bisect_paths(struct argv_array *array)
+static void read_bisect_paths(struct strvec *array)
 {
 	struct strbuf str = STRBUF_INIT;
 	const char *filename = git_path_bisect_names();
@@ -632,20 +632,20 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs,
 			     const char *bad_format, const char *good_format,
 			     int read_paths)
 {
-	struct argv_array rev_argv = ARGV_ARRAY_INIT;
+	struct strvec rev_argv = STRVEC_INIT;
 	int i;
 
 	repo_init_revisions(r, revs, prefix);
 	revs->abbrev = 0;
 	revs->commit_format = CMIT_FMT_UNSPECIFIED;
 
 	/* rev_argv.argv[0] will be ignored by setup_revisions */
-	argv_array_push(&rev_argv, "bisect_rev_setup");
-	argv_array_pushf(&rev_argv, bad_format, oid_to_hex(current_bad_oid));
+	strvec_push(&rev_argv, "bisect_rev_setup");
+	strvec_pushf(&rev_argv, bad_format, oid_to_hex(current_bad_oid));
 	for (i = 0; i < good_revs.nr; i++)
-		argv_array_pushf(&rev_argv, good_format,
+		strvec_pushf(&rev_argv, good_format,
 				 oid_to_hex(good_revs.oid + i));
-	argv_array_push(&rev_argv, "--");
+	strvec_push(&rev_argv, "--");
 	if (read_paths)
 		read_bisect_paths(&rev_argv);
 
bundle.c +6 -6
index d46a387e66..709b2abc9c 100644
@@ -269,16 +269,16 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
 
 
 /* Write the pack data to bundle_fd */
-static int write_pack_data(int bundle_fd, struct rev_info *revs, struct argv_array *pack_options)
+static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *pack_options)
 {
 	struct child_process pack_objects = CHILD_PROCESS_INIT;
 	int i;
 
-	argv_array_pushl(&pack_objects.args,
+	strvec_pushl(&pack_objects.args,
 			 "pack-objects",
 			 "--stdout", "--thin", "--delta-base-offset",
 			 NULL);
-	argv_array_pushv(&pack_objects.args, pack_options->argv);
+	strvec_pushv(&pack_objects.args, pack_options->argv);
 	pack_objects.in = -1;
 	pack_objects.out = bundle_fd;
 	pack_objects.git_cmd = 1;
@@ -321,11 +321,11 @@ static int compute_and_write_prerequisites(int bundle_fd,
 	FILE *rls_fout;
 	int i;
 
-	argv_array_pushl(&rls.args,
+	strvec_pushl(&rls.args,
 			 "rev-list", "--boundary", "--pretty=oneline",
 			 NULL);
 	for (i = 1; i < argc; i++)
-		argv_array_push(&rls.args, argv[i]);
+		strvec_push(&rls.args, argv[i]);
 	rls.out = -1;
 	rls.git_cmd = 1;
 	if (start_command(&rls))
@@ -449,7 +449,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 }
 
 int create_bundle(struct repository *r, const char *path,
-		  int argc, const char **argv, struct argv_array *pack_options)
+		  int argc, const char **argv, struct strvec *pack_options)
 {
 	struct lock_file lock = LOCK_INIT;
 	int bundle_fd = -1;
bundle.h +1 -1
index 2cf1270092..3f5c9ad220 100644
@@ -21,7 +21,7 @@ struct bundle_header {
 int is_bundle(const char *path, int quiet);
 int read_bundle_header(const char *path, struct bundle_header *header);
 int create_bundle(struct repository *r, const char *path,
-		  int argc, const char **argv, struct argv_array *pack_options);
+		  int argc, const char **argv, struct strvec *pack_options);
 int verify_bundle(struct repository *r, struct bundle_header *header, int verbose);
 #define BUNDLE_VERBOSE 1
 int unbundle(struct repository *r, struct bundle_header *header,
column.c +6 -6
index 4a38eed322..a79c2621b0 100644
@@ -358,22 +358,22 @@ static struct child_process column_process = CHILD_PROCESS_INIT;
 
 int run_column_filter(int colopts, const struct column_options *opts)
 {
-	struct argv_array *argv;
+	struct strvec *argv;
 
 	if (fd_out != -1)
 		return -1;
 
 	child_process_init(&column_process);
 	argv = &column_process.args;
 
-	argv_array_push(argv, "column");
-	argv_array_pushf(argv, "--raw-mode=%d", colopts);
+	strvec_push(argv, "column");
+	strvec_pushf(argv, "--raw-mode=%d", colopts);
 	if (opts && opts->width)
-		argv_array_pushf(argv, "--width=%d", opts->width);
+		strvec_pushf(argv, "--width=%d", opts->width);
 	if (opts && opts->indent)
-		argv_array_pushf(argv, "--indent=%s", opts->indent);
+		strvec_pushf(argv, "--indent=%s", opts->indent);
 	if (opts && opts->padding)
-		argv_array_pushf(argv, "--padding=%d", opts->padding);
+		strvec_pushf(argv, "--padding=%d", opts->padding);
 
 	fflush(stdout);
 	column_process.in = -1;
commit.c +4 -4
index 7128895c3a..a5176a25bd 100644
@@ -1630,22 +1630,22 @@ size_t ignore_non_trailer(const char *buf, size_t len)
 int run_commit_hook(int editor_is_used, const char *index_file,
 		    const char *name, ...)
 {
-	struct argv_array hook_env = ARGV_ARRAY_INIT;
+	struct strvec hook_env = STRVEC_INIT;
 	va_list args;
 	int ret;
 
-	argv_array_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file);
+	strvec_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file);
 
 	/*
 	 * Let the hook know that no editor will be launched.
 	 */
 	if (!editor_is_used)
-		argv_array_push(&hook_env, "GIT_EDITOR=:");
+		strvec_push(&hook_env, "GIT_EDITOR=:");
 
 	va_start(args, name);
 	ret = run_hook_ve(hook_env.argv,name, args);
 	va_end(args);
-	argv_array_clear(&hook_env);
+	strvec_clear(&hook_env);
 
 	return ret;
 }
compat/mingw.c +2 -2
index 8ee0b6408e..4454b3e67b 100644
@@ -18,8 +18,8 @@ void open_in_gdb(void)
 	static struct child_process cp = CHILD_PROCESS_INIT;
 	extern char *_pgmptr;
 
-	argv_array_pushl(&cp.args, "mintty", "gdb", NULL);
-	argv_array_pushf(&cp.args, "--pid=%d", getpid());
+	strvec_pushl(&cp.args, "mintty", "gdb", NULL);
+	strvec_pushf(&cp.args, "--pid=%d", getpid());
 	cp.clean_on_exit = 1;
 	if (start_command(&cp) < 0)
 		die_errno("Could not start gdb");
compat/terminal.c +9 -9
index 35bca03d14..43b73ddc75 100644
@@ -86,9 +86,9 @@ static void restore_term(void)
 		if (stty_restore.nr == 0)
 			return;
 
-		argv_array_push(&cp.args, "stty");
+		strvec_push(&cp.args, "stty");
 		for (i = 0; i < stty_restore.nr; i++)
-			argv_array_push(&cp.args, stty_restore.items[i].string);
+			strvec_push(&cp.args, stty_restore.items[i].string);
 		run_command(&cp);
 		string_list_clear(&stty_restore, 0);
 		return;
@@ -107,25 +107,25 @@ static int disable_bits(DWORD bits)
 	if (use_stty) {
 		struct child_process cp = CHILD_PROCESS_INIT;
 
-		argv_array_push(&cp.args, "stty");
+		strvec_push(&cp.args, "stty");
 
 		if (bits & ENABLE_LINE_INPUT) {
 			string_list_append(&stty_restore, "icanon");
-			argv_array_push(&cp.args, "-icanon");
+			strvec_push(&cp.args, "-icanon");
 		}
 
 		if (bits & ENABLE_ECHO_INPUT) {
 			string_list_append(&stty_restore, "echo");
-			argv_array_push(&cp.args, "-echo");
+			strvec_push(&cp.args, "-echo");
 		}
 
 		if (bits & ENABLE_PROCESSED_INPUT) {
 			string_list_append(&stty_restore, "-ignbrk");
 			string_list_append(&stty_restore, "intr");
 			string_list_append(&stty_restore, "^c");
-			argv_array_push(&cp.args, "ignbrk");
-			argv_array_push(&cp.args, "intr");
-			argv_array_push(&cp.args, "");
+			strvec_push(&cp.args, "ignbrk");
+			strvec_push(&cp.args, "intr");
+			strvec_push(&cp.args, "");
 		}
 
 		if (run_command(&cp) == 0)
@@ -273,7 +273,7 @@ static int is_known_escape_sequence(const char *sequence)
 		hashmap_init(&sequences, (hashmap_cmp_fn)sequence_entry_cmp,
 			     NULL, 0);
 
-		argv_array_pushl(&cp.args, "infocmp", "-L", "-1", NULL);
+		strvec_pushl(&cp.args, "infocmp", "-L", "-1", NULL);
 		if (pipe_command(&cp, NULL, 0, &buf, 0, NULL, 0))
 			strbuf_setlen(&buf, 0);
 
connect.c +24 -24

139 lines not on this page · raw message

connected.c +11 -11
index 937b4bae38..96b47879d3 100644
@@ -90,22 +90,22 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
 
 no_promisor_pack_found:
 	if (opt->shallow_file) {
-		argv_array_push(&rev_list.args, "--shallow-file");
-		argv_array_push(&rev_list.args, opt->shallow_file);
+		strvec_push(&rev_list.args, "--shallow-file");
+		strvec_push(&rev_list.args, opt->shallow_file);
 	}
-	argv_array_push(&rev_list.args,"rev-list");
-	argv_array_push(&rev_list.args, "--objects");
-	argv_array_push(&rev_list.args, "--stdin");
+	strvec_push(&rev_list.args,"rev-list");
+	strvec_push(&rev_list.args, "--objects");
+	strvec_push(&rev_list.args, "--stdin");
 	if (has_promisor_remote())
-		argv_array_push(&rev_list.args, "--exclude-promisor-objects");
+		strvec_push(&rev_list.args, "--exclude-promisor-objects");
 	if (!opt->is_deepening_fetch) {
-		argv_array_push(&rev_list.args, "--not");
-		argv_array_push(&rev_list.args, "--all");
+		strvec_push(&rev_list.args, "--not");
+		strvec_push(&rev_list.args, "--all");
 	}
-	argv_array_push(&rev_list.args, "--quiet");
-	argv_array_push(&rev_list.args, "--alternate-refs");
+	strvec_push(&rev_list.args, "--quiet");
+	strvec_push(&rev_list.args, "--alternate-refs");
 	if (opt->progress)
-		argv_array_pushf(&rev_list.args, "--progress=%s",
+		strvec_pushf(&rev_list.args, "--progress=%s",
 				 _("Checking connectivity"));
 
 	rev_list.git_cmd = 1;
daemon.c +26 -26

147 lines not on this page · raw message

diff.c +14 -14
index ee008155e4..f1a3758922 100644
@@ -4192,14 +4192,14 @@ static struct diff_tempfile *prepare_temp_file(struct repository *r,
 }
 
 static void add_external_diff_name(struct repository *r,
-				   struct argv_array *argv,
+				   struct strvec *argv,
 				   const char *name,
 				   struct diff_filespec *df)
 {
 	struct diff_tempfile *temp = prepare_temp_file(r, name, df);
-	argv_array_push(argv, temp->name);
-	argv_array_push(argv, temp->hex);
-	argv_array_push(argv, temp->mode);
+	strvec_push(argv, temp->name);
+	strvec_push(argv, temp->hex);
+	strvec_push(argv, temp->mode);
 }
 
 /* An external diff command takes:
@@ -4216,35 +4216,35 @@ static void run_external_diff(const char *pgm,
 			      const char *xfrm_msg,
 			      struct diff_options *o)
 {
-	struct argv_array argv = ARGV_ARRAY_INIT;
-	struct argv_array env = ARGV_ARRAY_INIT;
+	struct strvec argv = STRVEC_INIT;
+	struct strvec env = STRVEC_INIT;
 	struct diff_queue_struct *q = &diff_queued_diff;
 
-	argv_array_push(&argv, pgm);
-	argv_array_push(&argv, name);
+	strvec_push(&argv, pgm);
+	strvec_push(&argv, name);
 
 	if (one && two) {
 		add_external_diff_name(o->repo, &argv, name, one);
 		if (!other)
 			add_external_diff_name(o->repo, &argv, name, two);
 		else {
 			add_external_diff_name(o->repo, &argv, other, two);
-			argv_array_push(&argv, other);
-			argv_array_push(&argv, xfrm_msg);
+			strvec_push(&argv, other);
+			strvec_push(&argv, xfrm_msg);
 		}
 	}
 
-	argv_array_pushf(&env, "GIT_DIFF_PATH_COUNTER=%d", ++o->diff_path_counter);
-	argv_array_pushf(&env, "GIT_DIFF_PATH_TOTAL=%d", q->nr);
+	strvec_pushf(&env, "GIT_DIFF_PATH_COUNTER=%d", ++o->diff_path_counter);
+	strvec_pushf(&env, "GIT_DIFF_PATH_TOTAL=%d", q->nr);
 
 	diff_free_filespec_data(one);
 	diff_free_filespec_data(two);
 	if (run_command_v_opt_cd_env(argv.argv, RUN_USING_SHELL, NULL, env.argv))
 		die(_("external diff died, stopping at %s"), name);
 
 	remove_tempfile();
-	argv_array_clear(&argv);
-	argv_array_clear(&env);
+	strvec_clear(&argv);
+	strvec_clear(&env);
 }
 
 static int similarity_index(struct diff_filepair *p)
environment.c +4 -4
index 75fe5f4c56..00fe20e496 100644
@@ -156,14 +156,14 @@ static char *expand_namespace(const char *raw_namespace)
  * Wrapper of getenv() that returns a strdup value. This value is kept
  * in argv to be freed later.
  */
-static const char *getenv_safe(struct argv_array *argv, const char *name)
+static const char *getenv_safe(struct strvec *argv, const char *name)
 {
 	const char *value = getenv(name);
 
 	if (!value)
 		return NULL;
 
-	argv_array_push(argv, value);
+	strvec_push(argv, value);
 	return argv->argv[argv->argc - 1];
 }
 
@@ -172,15 +172,15 @@ void setup_git_env(const char *git_dir)
 	const char *shallow_file;
 	const char *replace_ref_base;
 	struct set_gitdir_args args = { NULL };
-	struct argv_array to_free = ARGV_ARRAY_INIT;
+	struct strvec to_free = STRVEC_INIT;
 
 	args.commondir = getenv_safe(&to_free, GIT_COMMON_DIR_ENVIRONMENT);
 	args.object_dir = getenv_safe(&to_free, DB_ENVIRONMENT);
 	args.graft_file = getenv_safe(&to_free, GRAFT_ENVIRONMENT);
 	args.index_file = getenv_safe(&to_free, INDEX_ENVIRONMENT);
 	args.alternate_db = getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT);
 	repo_set_gitdir(the_repository, git_dir, &args);
-	argv_array_clear(&to_free);
+	strvec_clear(&to_free);
 
 	if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
 		read_replace_refs = 0;
exec-cmd.c +5 -5
index bb24c2f3bc..0f8e888424 100644
@@ -320,16 +320,16 @@ void setup_path(void)
 	strbuf_release(&new_path);
 }
 
-const char **prepare_git_cmd(struct argv_array *out, const char **argv)
+const char **prepare_git_cmd(struct strvec *out, const char **argv)
 {
-	argv_array_push(out, "git");
-	argv_array_pushv(out, argv);
+	strvec_push(out, "git");
+	strvec_pushv(out, argv);
 	return out->argv;
 }
 
 int execv_git_cmd(const char **argv)
 {
-	struct argv_array nargv = ARGV_ARRAY_INIT;
+	struct strvec nargv = STRVEC_INIT;
 
 	prepare_git_cmd(&nargv, argv);
 	trace_argv_printf(nargv.argv, "trace: exec:");
@@ -339,7 +339,7 @@ int execv_git_cmd(const char **argv)
 
 	trace_printf("trace: exec failed: %s\n", strerror(errno));
 
-	argv_array_clear(&nargv);
+	strvec_clear(&nargv);
 	return -1;
 }
 
fast-import.c +2 -2
index 0dfa14dc8c..ce47794db6 100644
@@ -843,9 +843,9 @@ static int loosen_small_pack(const struct packed_git *p)
 	unpack.in = p->pack_fd;
 	unpack.git_cmd = 1;
 	unpack.stdout_to_stderr = 1;
-	argv_array_push(&unpack.args, "unpack-objects");
+	strvec_push(&unpack.args, "unpack-objects");
 	if (!show_stats)
-		argv_array_push(&unpack.args, "-q");
+		strvec_push(&unpack.args, "-q");
 
 	return run_command(&unpack);
 }
fetch-pack.c +17 -17
index 80fb3bd899..7aa5dfbdad 100644
@@ -835,30 +835,30 @@ static int get_pack(struct fetch_pack_args *args,
 	}
 
 	if (alternate_shallow_file) {
-		argv_array_push(&cmd.args, "--shallow-file");
-		argv_array_push(&cmd.args, alternate_shallow_file);
+		strvec_push(&cmd.args, "--shallow-file");
+		strvec_push(&cmd.args, alternate_shallow_file);
 	}
 
 	if (do_keep || args->from_promisor) {
 		if (pack_lockfiles)
 			cmd.out = -1;
 		cmd_name = "index-pack";
-		argv_array_push(&cmd.args, cmd_name);
-		argv_array_push(&cmd.args, "--stdin");
+		strvec_push(&cmd.args, cmd_name);
+		strvec_push(&cmd.args, "--stdin");
 		if (!args->quiet && !args->no_progress)
-			argv_array_push(&cmd.args, "-v");
+			strvec_push(&cmd.args, "-v");
 		if (args->use_thin_pack)
-			argv_array_push(&cmd.args, "--fix-thin");
+			strvec_push(&cmd.args, "--fix-thin");
 		if (do_keep && (args->lock_pack || unpack_limit)) {
 			char hostname[HOST_NAME_MAX + 1];
 			if (xgethostname(hostname, sizeof(hostname)))
 				xsnprintf(hostname, sizeof(hostname), "localhost");
-			argv_array_pushf(&cmd.args,
+			strvec_pushf(&cmd.args,
 					"--keep=fetch-pack %"PRIuMAX " on %s",
 					(uintmax_t)getpid(), hostname);
 		}
 		if (only_packfile && args->check_self_contained_and_connected)
-			argv_array_push(&cmd.args, "--check-self-contained-and-connected");
+			strvec_push(&cmd.args, "--check-self-contained-and-connected");
 		else
 			/*
 			 * We cannot perform any connectivity checks because
@@ -873,18 +873,18 @@ static int get_pack(struct fetch_pack_args *args,
 		 * us.
 		 */
 		if (!(do_keep && pack_lockfiles) && args->from_promisor)
-			argv_array_push(&cmd.args, "--promisor");
+			strvec_push(&cmd.args, "--promisor");
 	}
 	else {
 		cmd_name = "unpack-objects";
-		argv_array_push(&cmd.args, cmd_name);
+		strvec_push(&cmd.args, cmd_name);
 		if (args->quiet || args->no_progress)
-			argv_array_push(&cmd.args, "-q");
+			strvec_push(&cmd.args, "-q");
 		args->check_self_contained_and_connected = 0;
 	}
 
 	if (pass_header)
-		argv_array_pushf(&cmd.args, "--pack_header=%"PRIu32",%"PRIu32,
+		strvec_pushf(&cmd.args, "--pack_header=%"PRIu32",%"PRIu32,
 				 ntohl(header.hdr_version),
 				 ntohl(header.hdr_entries));
 	if (fetch_fsck_objects >= 0
@@ -898,9 +898,9 @@ static int get_pack(struct fetch_pack_args *args,
 			 * checks both broken objects and links, but we only
 			 * want to check for broken objects.
 			 */
-			argv_array_push(&cmd.args, "--fsck-objects");
+			strvec_push(&cmd.args, "--fsck-objects");
 		else
-			argv_array_pushf(&cmd.args, "--strict%s",
+			strvec_pushf(&cmd.args, "--strict%s",
 					 fsck_msg_types.buf);
 	}
 
@@ -1652,11 +1652,11 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
 		const char *uri = packfile_uris.items[i].string +
 			the_hash_algo->hexsz + 1;
 
-		argv_array_push(&cmd.args, "http-fetch");
-		argv_array_pushf(&cmd.args, "--packfile=%.*s",
+		strvec_push(&cmd.args, "http-fetch");
+		strvec_pushf(&cmd.args, "--packfile=%.*s",
 				 (int) the_hash_algo->hexsz,
 				 packfile_uris.items[i].string);
-		argv_array_push(&cmd.args, uri);
+		strvec_push(&cmd.args, uri);
 		cmd.git_cmd = 1;
 		cmd.no_stdin = 1;
 		cmd.out = -1;
fsmonitor.c +3 -3
index 932bd9012d..e3c982e814 100644
@@ -146,9 +146,9 @@ static int query_fsmonitor(int version, const char *last_update, struct strbuf *
 	if (!core_fsmonitor)
 		return -1;
 
-	argv_array_push(&cp.args, core_fsmonitor);
-	argv_array_pushf(&cp.args, "%d", version);
-	argv_array_pushf(&cp.args, "%s", last_update);
+	strvec_push(&cp.args, core_fsmonitor);
+	strvec_pushf(&cp.args, "%d", version);
+	strvec_pushf(&cp.args, "%s", last_update);
 	cp.use_shell = 1;
 	cp.dir = get_git_work_tree();
 
git.c +11 -11
index 6cd887bb0c..258035cfb1 100644
@@ -349,8 +349,8 @@ static int handle_alias(int *argcp, const char ***argv)
 			child.clean_on_exit = 1;
 			child.wait_after_clean = 1;
 			child.trace2_child_class = "shell_alias";
-			argv_array_push(&child.args, alias_string + 1);
-			argv_array_pushv(&child.args, (*argv) + 1);
+			strvec_push(&child.args, alias_string + 1);
+			strvec_pushv(&child.args, (*argv) + 1);
 
 			trace2_cmd_alias(alias_command, child.args.argv);
 			trace2_cmd_list_config();
@@ -646,7 +646,7 @@ static void strip_extension(const char **argv)
 
 static void handle_builtin(int argc, const char **argv)
 {
-	struct argv_array args = ARGV_ARRAY_INIT;
+	struct strvec args = STRVEC_INIT;
 	const char *cmd;
 	struct cmd_struct *builtin;
 
@@ -661,9 +661,9 @@ static void handle_builtin(int argc, const char **argv)
 		argv[0] = cmd = "help";
 
 		for (i = 0; i < argc; i++) {
-			argv_array_push(&args, argv[i]);
+			strvec_push(&args, argv[i]);
 			if (!i)
-				argv_array_push(&args, "--exclude-guides");
+				strvec_push(&args, "--exclude-guides");
 		}
 
 		argc++;
@@ -673,7 +673,7 @@ static void handle_builtin(int argc, const char **argv)
 	builtin = get_builtin(cmd);
 	if (builtin)
 		exit(run_builtin(builtin, argc, argv));
-	argv_array_clear(&args);
+	strvec_clear(&args);
 }
 
 static void execv_dashed_external(const char **argv)
@@ -688,8 +688,8 @@ static void execv_dashed_external(const char **argv)
 		use_pager = check_pager_config(argv[0]);
 	commit_pager_choice();
 
-	argv_array_pushf(&cmd.args, "git-%s", argv[0]);
-	argv_array_pushv(&cmd.args, argv + 1);
+	strvec_pushf(&cmd.args, "git-%s", argv[0]);
+	strvec_pushv(&cmd.args, argv + 1);
 	cmd.clean_on_exit = 1;
 	cmd.wait_after_clean = 1;
 	cmd.silent_exec_failure = 1;
@@ -741,7 +741,7 @@ static int run_argv(int *argcp, const char ***argv)
 		if (!done_alias)
 			handle_builtin(*argcp, *argv);
 		else if (get_builtin(**argv)) {
-			struct argv_array args = ARGV_ARRAY_INIT;
+			struct strvec args = STRVEC_INIT;
 			int i;
 
 			/*
@@ -758,9 +758,9 @@ static int run_argv(int *argcp, const char ***argv)
 
 			commit_pager_choice();
 
-			argv_array_push(&args, "git");
+			strvec_push(&args, "git");
 			for (i = 0; i < *argcp; i++)
-				argv_array_push(&args, (*argv)[i]);
+				strvec_push(&args, (*argv)[i]);
 
 			trace_argv_printf(args.argv, "trace: exec:");
 
gpg-interface.c +4 -4
index 2d538bcd6e..cf56fe838f 100644
@@ -282,9 +282,9 @@ static int verify_signed_buffer(const char *payload, size_t payload_size,
 	if (!fmt)
 		BUG("bad signature '%s'", signature);
 
-	argv_array_push(&gpg.args, fmt->program);
-	argv_array_pushv(&gpg.args, fmt->verify_args);
-	argv_array_pushl(&gpg.args,
+	strvec_push(&gpg.args, fmt->program);
+	strvec_pushv(&gpg.args, fmt->verify_args);
+	strvec_pushl(&gpg.args,
 			 "--status-fd=1",
 			 "--verify", temp->filename.buf, "-",
 			 NULL);
@@ -434,7 +434,7 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
 	size_t i, j, bottom;
 	struct strbuf gpg_status = STRBUF_INIT;
 
-	argv_array_pushl(&gpg.args,
+	strvec_pushl(&gpg.args,
 			 use_format->program,
 			 "--status-fd=2",
 			 "-bsau", signing_key,
graph.c +5 -5
index 96af8f605a..09c9cc968c 100644
@@ -82,7 +82,7 @@ static void graph_show_line_prefix(const struct diff_options *diffopt)
 static const char **column_colors;
 static unsigned short column_colors_max;
 
-static void parse_graph_colors_config(struct argv_array *colors, const char *string)
+static void parse_graph_colors_config(struct strvec *colors, const char *string)
 {
 	const char *end, *start;
 
@@ -93,13 +93,13 @@ static void parse_graph_colors_config(struct argv_array *colors, const char *str
 		char color[COLOR_MAXLEN];
 
 		if (!color_parse_mem(start, comma - start, color))
-			argv_array_push(colors, color);
+			strvec_push(colors, color);
 		else
 			warning(_("ignore invalid color '%.*s' in log.graphColors"),
 				(int)(comma - start), start);
 		start = comma + 1;
 	}
-	argv_array_push(colors, GIT_COLOR_RESET);
+	strvec_push(colors, GIT_COLOR_RESET);
 }
 
 void graph_set_column_colors(const char **colors, unsigned short colors_max)
@@ -350,8 +350,8 @@ struct git_graph *graph_init(struct rev_info *opt)
 			graph_set_column_colors(column_colors_ansi,
 						column_colors_ansi_max);
 		} else {
-			static struct argv_array custom_colors = ARGV_ARRAY_INIT;
-			argv_array_clear(&custom_colors);
+			static struct strvec custom_colors = STRVEC_INIT;
+			strvec_clear(&custom_colors);
 			parse_graph_colors_config(&custom_colors, string);
 			free(string);
 			/* graph_set_column_colors takes a max-index, not a count */
http-backend.c +2 -2
index 6a42badf33..92fd62f73f 100644
@@ -477,9 +477,9 @@ static void run_service(const char **argv, int buffer_input)
 		host = "(none)";
 
 	if (!getenv("GIT_COMMITTER_NAME"))
-		argv_array_pushf(&cld.env_array, "GIT_COMMITTER_NAME=%s", user);
+		strvec_pushf(&cld.env_array, "GIT_COMMITTER_NAME=%s", user);
 	if (!getenv("GIT_COMMITTER_EMAIL"))
-		argv_array_pushf(&cld.env_array,
+		strvec_pushf(&cld.env_array,
 				 "GIT_COMMITTER_EMAIL=%s@http.%s", user, host);
 
 	cld.argv = argv;
http-push.c +6 -6
index 3a47921cc3..e1deea6fe4 100644
@@ -1846,7 +1846,7 @@ int cmd_main(int argc, const char **argv)
 
 	new_refs = 0;
 	for (ref = remote_refs; ref; ref = ref->next) {
-		struct argv_array commit_argv = ARGV_ARRAY_INIT;
+		struct strvec commit_argv = STRVEC_INIT;
 
 		if (!ref->peer_ref)
 			continue;
@@ -1924,11 +1924,11 @@ int cmd_main(int argc, const char **argv)
 		}
 
 		/* Set up revision info for this refspec */
-		argv_array_push(&commit_argv, ""); /* ignored */
-		argv_array_push(&commit_argv, "--objects");
-		argv_array_push(&commit_argv, oid_to_hex(&ref->new_oid));
+		strvec_push(&commit_argv, ""); /* ignored */
+		strvec_push(&commit_argv, "--objects");
+		strvec_push(&commit_argv, oid_to_hex(&ref->new_oid));
 		if (!push_all && !is_null_oid(&ref->old_oid))
-			argv_array_pushf(&commit_argv, "^%s",
+			strvec_pushf(&commit_argv, "^%s",
 					 oid_to_hex(&ref->old_oid));
 		repo_init_revisions(the_repository, &revs, setup_git_directory());
 		setup_revisions(commit_argv.argc, commit_argv.argv, &revs, NULL);
@@ -1961,7 +1961,7 @@ int cmd_main(int argc, const char **argv)
 			printf("%s %s\n", !rc ? "ok" : "error", ref->name);
 		unlock_remote(ref_lock);
 		check_locks();
-		argv_array_clear(&commit_argv);
+		strvec_clear(&commit_argv);
 	}
 
 	/* Update remote server info if appropriate */
http.c +3 -3
index 3b12843a5b..268a1e9744 100644
@@ -2270,12 +2270,12 @@ int finish_http_pack_request(struct http_pack_request *preq)
 
 	tmpfile_fd = xopen(preq->tmpfile.buf, O_RDONLY);
 
-	argv_array_push(&ip.args, "index-pack");
-	argv_array_push(&ip.args, "--stdin");
+	strvec_push(&ip.args, "index-pack");
+	strvec_push(&ip.args, "--stdin");
 	ip.git_cmd = 1;
 	ip.in = tmpfile_fd;
 	if (preq->generate_keep) {
-		argv_array_pushf(&ip.args, "--keep=git %"PRIuMAX,
+		strvec_pushf(&ip.args, "--keep=git %"PRIuMAX,
 				 (uintmax_t)getpid());
 		ip.out = 0;
 	} else {
imap-send.c +1 -1
index 52737546f3..5764dd812c 100644
@@ -976,7 +976,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, char *f
 
 		imap_info("Starting tunnel '%s'... ", srvc->tunnel);
 
-		argv_array_push(&tunnel.args, srvc->tunnel);
+		strvec_push(&tunnel.args, srvc->tunnel);
 		tunnel.use_shell = 1;
 		tunnel.in = -1;
 		tunnel.out = -1;
line-log.c +3 -3
index 05d077b8e7..bf73ea95ac 100644
@@ -758,12 +758,12 @@ static void parse_pathspec_from_ranges(struct pathspec *pathspec,
 				       struct line_log_data *range)
 {
 	struct line_log_data *r;
-	struct argv_array array = ARGV_ARRAY_INIT;
+	struct strvec array = STRVEC_INIT;
 	const char **paths;
 
 	for (r = range; r; r = r->next)
-		argv_array_push(&array, r->path);
-	paths = argv_array_detach(&array);
+		strvec_push(&array, r->path);
+	paths = strvec_detach(&array);
 
 	parse_pathspec(pathspec, 0, PATHSPEC_PREFER_FULL, "", paths);
 	/* strings are now owned by pathspec */
ls-refs.c +5 -5
index 98fb19092a..8192c949f4 100644
@@ -11,7 +11,7 @@
  * Check if one of the prefixes is a prefix of the ref.
  * If no prefixes were provided, all refs match.
  */
-static int ref_match(const struct argv_array *prefixes, const char *refname)
+static int ref_match(const struct strvec *prefixes, const char *refname)
 {
 	int i;
 
@@ -31,7 +31,7 @@ static int ref_match(const struct argv_array *prefixes, const char *refname)
 struct ls_refs_data {
 	unsigned peel;
 	unsigned symrefs;
-	struct argv_array prefixes;
+	struct strvec prefixes;
 };
 
 static int send_ref(const char *refname, const struct object_id *oid,
@@ -84,7 +84,7 @@ static int ls_refs_config(const char *var, const char *value, void *data)
 	return parse_hide_refs_config(var, value, "uploadpack");
 }
 
-int ls_refs(struct repository *r, struct argv_array *keys,
+int ls_refs(struct repository *r, struct strvec *keys,
 	    struct packet_reader *request)
 {
 	struct ls_refs_data data;
@@ -102,7 +102,7 @@ int ls_refs(struct repository *r, struct argv_array *keys,
 		else if (!strcmp("symrefs", arg))
 			data.symrefs = 1;
 		else if (skip_prefix(arg, "ref-prefix ", &out))
-			argv_array_push(&data.prefixes, out);
+			strvec_push(&data.prefixes, out);
 	}
 
 	if (request->status != PACKET_READ_FLUSH)
@@ -111,6 +111,6 @@ int ls_refs(struct repository *r, struct argv_array *keys,
 	head_ref_namespaced(send_ref, &data);
 	for_each_namespaced_ref(send_ref, &data);
 	packet_flush(1);
-	argv_array_clear(&data.prefixes);
+	strvec_clear(&data.prefixes);
 	return 0;
 }
Signature · 1 line
2.28.0.rc2.475.g53c7e1c7f4
author
#7 lore raw

PATCH 7/11 strvec: convert remaining callers away from argv_array name

In reply to Jeff King

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.

---
 merge.c                     |  16 ++--
 midx.c                      |  12 +--
 pager.c                     |   8 +-
 parse-options-cb.c          |   6 +-
 pathspec.c                  |   6 +-
 quote.c                     |   4 +-
 range-diff.c                |  10 +-
 range-diff.h                |   2 +-
 ref-filter.c                |   6 +-
 refs.c                      |   6 +-
 refspec.c                   |   4 +-
 remote-curl.c               |  86 ++++++++---------
 remote-testsvn.c            |   8 +-
 remote.c                    |  12 +--
 revision.c                  |  14 +--
 run-command.c               |  50 +++++-----
 run-command.h               |  10 +-
 send-pack.c                 |  18 ++--
 sequencer.c                 | 112 +++++++++++------------
 serve.c                     |  12 +--
 sha1-file.c                 |  14 +--
 sub-process.c               |   2 +-
 submodule.c                 | 178 ++++++++++++++++++------------------
 t/helper/test-run-command.c |  36 ++++----
 tmp-objdir.c                |  16 ++--
 transport-helper.c          |  30 +++---
 transport-internal.h        |   2 +-
 transport.c                 |  12 +--
 transport.h                 |   2 +-
 unpack-trees.c              |  10 +-
 unpack-trees.h              |   2 +-
 upload-pack.c               |  48 +++++-----
 wt-status.c                 |  16 ++--
 33 files changed, 385 insertions(+), 385 deletions(-)
merge.c +8 -8
index aa36de2f64..a05b054faa 100644
@@ -19,22 +19,22 @@ int try_merge_command(struct repository *r,
 		      const char **xopts, struct commit_list *common,
 		      const char *head_arg, struct commit_list *remotes)
 {
-	struct argv_array args = ARGV_ARRAY_INIT;
+	struct strvec args = STRVEC_INIT;
 	int i, ret;
 	struct commit_list *j;
 
-	argv_array_pushf(&args, "merge-%s", strategy);
+	strvec_pushf(&args, "merge-%s", strategy);
 	for (i = 0; i < xopts_nr; i++)
-		argv_array_pushf(&args, "--%s", xopts[i]);
+		strvec_pushf(&args, "--%s", xopts[i]);
 	for (j = common; j; j = j->next)
-		argv_array_push(&args, merge_argument(j->item));
-	argv_array_push(&args, "--");
-	argv_array_push(&args, head_arg);
+		strvec_push(&args, merge_argument(j->item));
+	strvec_push(&args, "--");
+	strvec_push(&args, head_arg);
 	for (j = remotes; j; j = j->next)
-		argv_array_push(&args, merge_argument(j->item));
+		strvec_push(&args, merge_argument(j->item));
 
 	ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
-	argv_array_clear(&args);
+	strvec_clear(&args);
 
 	discard_index(r->index);
 	if (repo_read_index(r) < 0)
midx.c +6 -6
index 6d1584ca51..a5fb797ede 100644
@@ -1408,21 +1408,21 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
 	repo_config_get_bool(r, "repack.usedeltabaseoffset", &delta_base_offset);
 	repo_config_get_bool(r, "repack.usedeltaislands", &use_delta_islands);
 
-	argv_array_push(&cmd.args, "pack-objects");
+	strvec_push(&cmd.args, "pack-objects");
 
 	strbuf_addstr(&base_name, object_dir);
 	strbuf_addstr(&base_name, "/pack/pack");
-	argv_array_push(&cmd.args, base_name.buf);
+	strvec_push(&cmd.args, base_name.buf);
 
 	if (delta_base_offset)
-		argv_array_push(&cmd.args, "--delta-base-offset");
+		strvec_push(&cmd.args, "--delta-base-offset");
 	if (use_delta_islands)
-		argv_array_push(&cmd.args, "--delta-islands");
+		strvec_push(&cmd.args, "--delta-islands");
 
 	if (flags & MIDX_PROGRESS)
-		argv_array_push(&cmd.args, "--progress");
+		strvec_push(&cmd.args, "--progress");
 	else
-		argv_array_push(&cmd.args, "-q");
+		strvec_push(&cmd.args, "-q");
 
 	strbuf_release(&base_name);
 
pager.c +4 -4
index 41446d4f05..ee435de675 100644
@@ -68,7 +68,7 @@ const char *git_pager(int stdout_is_tty)
 	return pager;
 }
 
-static void setup_pager_env(struct argv_array *env)
+static void setup_pager_env(struct strvec *env)
 {
 	const char **argv;
 	int i;
@@ -88,7 +88,7 @@ static void setup_pager_env(struct argv_array *env)
 		*cp = '\0';
 		if (!getenv(argv[i])) {
 			*cp = '=';
-			argv_array_push(env, argv[i]);
+			strvec_push(env, argv[i]);
 		}
 	}
 	free(pager_env);
@@ -97,7 +97,7 @@ static void setup_pager_env(struct argv_array *env)
 
 void prepare_pager_args(struct child_process *pager_process, const char *pager)
 {
-	argv_array_push(&pager_process->args, pager);
+	strvec_push(&pager_process->args, pager);
 	pager_process->use_shell = 1;
 	setup_pager_env(&pager_process->env_array);
 	pager_process->trace2_child_class = "pager";
@@ -126,7 +126,7 @@ void setup_pager(void)
 	/* spawn the pager */
 	prepare_pager_args(&pager_process, pager);
 	pager_process.in = -1;
-	argv_array_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
+	strvec_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
 	if (start_command(&pager_process))
 		return;
 
parse-options-cb.c +3 -3
index 7cba96454c..d9d3b0819f 100644
@@ -275,19 +275,19 @@ int parse_opt_passthru(const struct option *opt, const char *arg, int unset)
 
 /**
  * For an option opt, recreate the command-line option, appending it to
- * opt->value which must be a argv_array. This is useful when we need to pass
+ * opt->value which must be a strvec. This is useful when we need to pass
  * the command-line option, which can be specified multiple times, to another
  * command.
  */
 int parse_opt_passthru_argv(const struct option *opt, const char *arg, int unset)
 {
 	static struct strbuf sb = STRBUF_INIT;
-	struct argv_array *opt_value = opt->value;
+	struct strvec *opt_value = opt->value;
 
 	if (recreate_opt(&sb, opt, arg, unset) < 0)
 		return -1;
 
-	argv_array_push(opt_value, sb.buf);
+	strvec_push(opt_value, sb.buf);
 
 	return 0;
 }
pathspec.c +3 -3
index 57c9b58418..c303126f37 100644
@@ -624,7 +624,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
 			 unsigned flags, const char *prefix,
 			 const char *file, int nul_term_line)
 {
-	struct argv_array parsed_file = ARGV_ARRAY_INIT;
+	struct strvec parsed_file = STRVEC_INIT;
 	strbuf_getline_fn getline_fn = nul_term_line ? strbuf_getline_nul :
 						       strbuf_getline;
 	struct strbuf buf = STRBUF_INIT;
@@ -643,7 +643,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
 				die(_("line is badly quoted: %s"), buf.buf);
 			strbuf_swap(&buf, &unquoted);
 		}
-		argv_array_push(&parsed_file, buf.buf);
+		strvec_push(&parsed_file, buf.buf);
 		strbuf_reset(&buf);
 	}
 
@@ -653,7 +653,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
 		fclose(in);
 
 	parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.argv);
-	argv_array_clear(&parsed_file);
+	strvec_clear(&parsed_file);
 }
 
 void copy_pathspec(struct pathspec *dst, const struct pathspec *src)
quote.c +2 -2
index 10b383cc1d..ced0245e80 100644
@@ -172,7 +172,7 @@ char *sq_dequote(char *arg)
 
 static int sq_dequote_to_argv_internal(char *arg,
 				       const char ***argv, int *nr, int *alloc,
-				       struct argv_array *array)
+				       struct strvec *array)
 {
 	char *next = arg;
 
@@ -187,7 +187,7 @@ static int sq_dequote_to_argv_internal(char *arg,
 			(*argv)[(*nr)++] = dequoted;
 		}
 		if (array)
-			argv_array_push(array, dequoted);
+			strvec_push(array, dequoted);
 	} while (next);
 
 	return 0;
range-diff.c +5 -5
index b4d1d56445..3a0eb70c89 100644
@@ -41,7 +41,7 @@ static size_t find_end_of_line(char *buffer, unsigned long size)
  * as struct object_id (will need to be free()d).
  */
 static int read_patches(const char *range, struct string_list *list,
-			const struct argv_array *other_arg)
+			const struct strvec *other_arg)
 {
 	struct child_process cp = CHILD_PROCESS_INIT;
 	struct strbuf buf = STRBUF_INIT, contents = STRBUF_INIT;
@@ -51,7 +51,7 @@ static int read_patches(const char *range, struct string_list *list,
 	int offset, len;
 	size_t size;
 
-	argv_array_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
+	strvec_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
 			"--reverse", "--date-order", "--decorate=no",
 			"--no-prefix",
 			/*
@@ -67,8 +67,8 @@ static int read_patches(const char *range, struct string_list *list,
 			"--notes",
 			NULL);
 	if (other_arg)
-		argv_array_pushv(&cp.args, other_arg->argv);
-	argv_array_push(&cp.args, range);
+		strvec_pushv(&cp.args, other_arg->argv);
+	strvec_push(&cp.args, range);
 	cp.out = -1;
 	cp.no_stdin = 1;
 	cp.git_cmd = 1;
@@ -523,7 +523,7 @@ static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data)
 int show_range_diff(const char *range1, const char *range2,
 		    int creation_factor, int dual_color,
 		    const struct diff_options *diffopt,
-		    const struct argv_array *other_arg)
+		    const struct strvec *other_arg)
 {
 	int res = 0;
 
range-diff.h +1 -1
index 916f18bcd7..583ced2e8e 100644
@@ -14,6 +14,6 @@
 int show_range_diff(const char *range1, const char *range2,
 		    int creation_factor, int dual_color,
 		    const struct diff_options *diffopt,
-		    const struct argv_array *other_arg);
+		    const struct strvec *other_arg);
 
 #endif
ref-filter.c +3 -3
index 81c4399da9..7f013851ed 100644
@@ -1914,15 +1914,15 @@ static void find_longest_prefixes_1(struct string_list *out,
 static void find_longest_prefixes(struct string_list *out,
 				  const char **patterns)
 {
-	struct argv_array sorted = ARGV_ARRAY_INIT;
+	struct strvec sorted = STRVEC_INIT;
 	struct strbuf prefix = STRBUF_INIT;
 
-	argv_array_pushv(&sorted, patterns);
+	strvec_pushv(&sorted, patterns);
 	QSORT(sorted.argv, sorted.argc, qsort_strcmp);
 
 	find_longest_prefixes_1(out, &prefix, sorted.argv, sorted.argc);
 
-	argv_array_clear(&sorted);
+	strvec_clear(&sorted);
 	strbuf_release(&prefix);
 }
 
refs.c +3 -3
index 0067926262..d8d3b10fbd 100644
@@ -553,13 +553,13 @@ int refname_match(const char *abbrev_name, const char *full_name)
  * Given a 'prefix' expand it by the rules in 'ref_rev_parse_rules' and add
  * the results to 'prefixes'
  */
-void expand_ref_prefix(struct argv_array *prefixes, const char *prefix)
+void expand_ref_prefix(struct strvec *prefixes, const char *prefix)
 {
 	const char **p;
 	int len = strlen(prefix);
 
 	for (p = ref_rev_parse_rules; *p; p++)
-		argv_array_pushf(prefixes, *p, len, prefix);
+		strvec_pushf(prefixes, *p, len, prefix);
 }
 
 char *repo_default_branch_name(struct repository *r)
@@ -2037,7 +2037,7 @@ static int run_transaction_hook(struct ref_transaction *transaction,
 		return ret;
 	}
 
-	argv_array_pushl(&proc.args, hook, state, NULL);
+	strvec_pushl(&proc.args, hook, state, NULL);
 	proc.in = -1;
 	proc.stdout_to_stderr = 1;
 	proc.trace2_hook_name = "reference-transaction";
refspec.c +2 -2
index f9fb67d295..6f317d6b44 100644
@@ -202,7 +202,7 @@ int valid_fetch_refspec(const char *fetch_refspec_str)
 }
 
 void refspec_ref_prefixes(const struct refspec *rs,
-			  struct argv_array *ref_prefixes)
+			  struct strvec *ref_prefixes)
 {
 	int i;
 	for (i = 0; i < rs->nr; i++) {
@@ -221,7 +221,7 @@ void refspec_ref_prefixes(const struct refspec *rs,
 		if (prefix) {
 			if (item->pattern) {
 				const char *glob = strchr(prefix, '*');
-				argv_array_pushf(ref_prefixes, "%.*s",
+				strvec_pushf(ref_prefixes, "%.*s",
 						 (int)(glob - prefix),
 						 prefix);
 			} else {
remote-curl.c +43 -43

171 lines not on this page · raw message

remote-testsvn.c +4 -4
index 809b290d45..636b2b62a6 100644
@@ -198,10 +198,10 @@ static int cmd_import(const char *line)
 			die_errno("Couldn't open svn dump file %s.", url);
 	} else {
 		svndump_proc.out = -1;
-		argv_array_push(&svndump_proc.args, command);
-		argv_array_push(&svndump_proc.args, "dump");
-		argv_array_push(&svndump_proc.args, url);
-		argv_array_pushf(&svndump_proc.args, "-r%u:HEAD", startrev);
+		strvec_push(&svndump_proc.args, command);
+		strvec_push(&svndump_proc.args, "dump");
+		strvec_push(&svndump_proc.args, url);
+		strvec_pushf(&svndump_proc.args, "-r%u:HEAD", startrev);
 
 		code = start_command(&svndump_proc);
 		if (code)
remote.c +6 -6
index ba1a386d98..13b097866c 100644
@@ -1885,7 +1885,7 @@ static int stat_branch_pair(const char *branch_name, const char *base,
 	struct object_id oid;
 	struct commit *ours, *theirs;
 	struct rev_info revs;
-	struct argv_array argv = ARGV_ARRAY_INIT;
+	struct strvec argv = STRVEC_INIT;
 
 	/* Cannot stat if what we used to build on no longer exists */
 	if (read_ref(base, &oid))
@@ -1911,12 +1911,12 @@ static int stat_branch_pair(const char *branch_name, const char *base,
 		BUG("stat_branch_pair: invalid abf '%d'", abf);
 
 	/* Run "rev-list --left-right ours...theirs" internally... */
-	argv_array_push(&argv, ""); /* ignored */
-	argv_array_push(&argv, "--left-right");
-	argv_array_pushf(&argv, "%s...%s",
+	strvec_push(&argv, ""); /* ignored */
+	strvec_push(&argv, "--left-right");
+	strvec_pushf(&argv, "%s...%s",
 			 oid_to_hex(&ours->object.oid),
 			 oid_to_hex(&theirs->object.oid));
-	argv_array_push(&argv, "--");
+	strvec_push(&argv, "--");
 
 	repo_init_revisions(the_repository, &revs, NULL);
 	setup_revisions(argv.argc, argv.argv, &revs, NULL);
@@ -1938,7 +1938,7 @@ static int stat_branch_pair(const char *branch_name, const char *base,
 	clear_commit_marks(ours, ALL_REV_FLAGS);
 	clear_commit_marks(theirs, ALL_REV_FLAGS);
 
-	argv_array_clear(&argv);
+	strvec_clear(&argv);
 	return 1;
 }
 
revision.c +7 -7
index 07e16ed44b..e144132ae9 100644
@@ -2073,14 +2073,14 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
 }
 
 static void read_pathspec_from_stdin(struct strbuf *sb,
-				     struct argv_array *prune)
+				     struct strvec *prune)
 {
 	while (strbuf_getline(sb, stdin) != EOF)
-		argv_array_push(prune, sb->buf);
+		strvec_push(prune, sb->buf);
 }
 
 static void read_revisions_from_stdin(struct rev_info *revs,
-				      struct argv_array *prune)
+				      struct strvec *prune)
 {
 	struct strbuf sb;
 	int seen_dashdash = 0;
@@ -2675,7 +2675,7 @@ static void NORETURN diagnose_missing_default(const char *def)
 int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *opt)
 {
 	int i, flags, left, seen_dashdash, got_rev_arg = 0, revarg_opt;
-	struct argv_array prune_data = ARGV_ARRAY_INIT;
+	struct strvec prune_data = STRVEC_INIT;
 	const char *submodule = NULL;
 	int seen_end_of_options = 0;
 
@@ -2694,7 +2694,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
 			argv[i] = NULL;
 			argc = i;
 			if (argv[i + 1])
-				argv_array_pushv(&prune_data, argv + i + 1);
+				strvec_pushv(&prune_data, argv + i + 1);
 			seen_dashdash = 1;
 			break;
 		}
@@ -2760,7 +2760,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
 			for (j = i; j < argc; j++)
 				verify_filename(revs->prefix, argv[j], j == i);
 
-			argv_array_pushv(&prune_data, argv + i);
+			strvec_pushv(&prune_data, argv + i);
 			break;
 		}
 		else
@@ -2785,7 +2785,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
 		parse_pathspec(&revs->prune_data, 0, 0,
 			       revs->prefix, prune_data.argv);
 	}
-	argv_array_clear(&prune_data);
+	strvec_clear(&prune_data);
 
 	if (revs->def == NULL)
 		revs->def = opt ? opt->def : NULL;
run-command.c +25 -25

147 lines not on this page · raw message

run-command.h +5 -5
index f5e05d38d2..8b9bfaef16 100644
@@ -52,15 +52,15 @@ struct child_process {
 	 * Note that the ownership of the memory pointed to by .argv stays with the
 	 * caller, but it should survive until `finish_command` completes. If the
 	 * .argv member is NULL, `start_command` will point it at the .args
-	 * `argv_array` (so you may use one or the other, but you must use exactly
+	 * `strvec` (so you may use one or the other, but you must use exactly
 	 * one). The memory in .args will be cleaned up automatically during
 	 * `finish_command` (or during `start_command` when it is unsuccessful).
 	 *
 	 */
 	const char **argv;
 
-	struct argv_array args;
-	struct argv_array env_array;
+	struct strvec args;
+	struct strvec env_array;
 	pid_t pid;
 
 	int trace2_child_id;
@@ -107,7 +107,7 @@ struct child_process {
 	 *   variable that will be removed from the child process's environment.
 	 *
 	 * If the .env member is NULL, `start_command` will point it at the
-	 * .env_array `argv_array` (so you may use one or the other, but not both).
+	 * .env_array `strvec` (so you may use one or the other, but not both).
 	 * The memory in .env_array will be cleaned up automatically during
 	 * `finish_command` (or during `start_command` when it is unsuccessful).
 	 */
@@ -134,7 +134,7 @@ struct child_process {
 	void *clean_on_exit_handler_cbdata;
 };
 
-#define CHILD_PROCESS_INIT { NULL, ARGV_ARRAY_INIT, ARGV_ARRAY_INIT }
+#define CHILD_PROCESS_INIT { NULL, STRVEC_INIT, STRVEC_INIT }
 
 /**
  * The functions: child_process_init, start_command, finish_command,
send-pack.c +9 -9
index d671ab5d05..632f1580ca 100644
@@ -68,20 +68,20 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc
 	int i;
 	int rc;
 
-	argv_array_push(&po.args, "pack-objects");
-	argv_array_push(&po.args, "--all-progress-implied");
-	argv_array_push(&po.args, "--revs");
-	argv_array_push(&po.args, "--stdout");
+	strvec_push(&po.args, "pack-objects");
+	strvec_push(&po.args, "--all-progress-implied");
+	strvec_push(&po.args, "--revs");
+	strvec_push(&po.args, "--stdout");
 	if (args->use_thin_pack)
-		argv_array_push(&po.args, "--thin");
+		strvec_push(&po.args, "--thin");
 	if (args->use_ofs_delta)
-		argv_array_push(&po.args, "--delta-base-offset");
+		strvec_push(&po.args, "--delta-base-offset");
 	if (args->quiet || !args->progress)
-		argv_array_push(&po.args, "-q");
+		strvec_push(&po.args, "-q");
 	if (args->progress)
-		argv_array_push(&po.args, "--progress");
+		strvec_push(&po.args, "--progress");
 	if (is_repository_shallow(the_repository))
-		argv_array_push(&po.args, "--shallow");
+		strvec_push(&po.args, "--shallow");
 	po.in = -1;
 	po.out = args->stateless_rpc ? -1 : fd;
 	po.git_cmd = 1;
sequencer.c +56 -56

228 lines not on this page · raw message

serve.c +6 -6
index 8d9a345b3d..523a9be32d 100644
@@ -56,7 +56,7 @@ struct protocol_capability {
 	 * This field should be NULL for capabilities which are not commands.
 	 */
 	int (*command)(struct repository *r,
-		       struct argv_array *keys,
+		       struct strvec *keys,
 		       struct packet_reader *request);
 };
 
@@ -142,7 +142,7 @@ static int is_command(const char *key, struct protocol_capability **command)
 	return 0;
 }
 
-int has_capability(const struct argv_array *keys, const char *capability,
+int has_capability(const struct strvec *keys, const char *capability,
 		   const char **value)
 {
 	int i;
@@ -162,7 +162,7 @@ int has_capability(const struct argv_array *keys, const char *capability,
 	return 0;
 }
 
-static void check_algorithm(struct repository *r, struct argv_array *keys)
+static void check_algorithm(struct repository *r, struct strvec *keys)
 {
 	int client = GIT_HASH_SHA1, server = hash_algo_by_ptr(r->hash_algo);
 	const char *algo_name;
@@ -187,7 +187,7 @@ static int process_request(void)
 {
 	enum request_state state = PROCESS_REQUEST_KEYS;
 	struct packet_reader reader;
-	struct argv_array keys = ARGV_ARRAY_INIT;
+	struct strvec keys = STRVEC_INIT;
 	struct protocol_capability *command = NULL;
 
 	packet_reader_init(&reader, 0, NULL, 0,
@@ -211,7 +211,7 @@ static int process_request(void)
 			/* collect request; a sequence of keys and values */
 			if (is_command(reader.line, &command) ||
 			    is_valid_capability(reader.line))
-				argv_array_push(&keys, reader.line);
+				strvec_push(&keys, reader.line);
 			else
 				die("unknown capability '%s'", reader.line);
 
@@ -254,7 +254,7 @@ static int process_request(void)
 
 	command->command(the_repository, &keys, &reader);
 
-	argv_array_clear(&keys);
+	strvec_clear(&keys);
 	return 0;
 }
 
sha1-file.c +7 -7
index ccd34dd9e8..a7f7a14898 100644
@@ -763,18 +763,18 @@ static void fill_alternate_refs_command(struct child_process *cmd,
 	if (!git_config_get_value("core.alternateRefsCommand", &value)) {
 		cmd->use_shell = 1;
 
-		argv_array_push(&cmd->args, value);
-		argv_array_push(&cmd->args, repo_path);
+		strvec_push(&cmd->args, value);
+		strvec_push(&cmd->args, repo_path);
 	} else {
 		cmd->git_cmd = 1;
 
-		argv_array_pushf(&cmd->args, "--git-dir=%s", repo_path);
-		argv_array_push(&cmd->args, "for-each-ref");
-		argv_array_push(&cmd->args, "--format=%(objectname)");
+		strvec_pushf(&cmd->args, "--git-dir=%s", repo_path);
+		strvec_push(&cmd->args, "for-each-ref");
+		strvec_push(&cmd->args, "--format=%(objectname)");
 
 		if (!git_config_get_value("core.alternateRefsPrefixes", &value)) {
-			argv_array_push(&cmd->args, "--");
-			argv_array_split(&cmd->args, value);
+			strvec_push(&cmd->args, "--");
+			strvec_split(&cmd->args, value);
 		}
 	}
 
sub-process.c +1 -1
index 1b1af9dcbd..dfa790d3ff 100644
@@ -84,7 +84,7 @@ int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, co
 	process = &entry->process;
 
 	child_process_init(process);
-	argv_array_push(&process->args, cmd);
+	strvec_push(&process->args, cmd);
 	process->use_shell = 1;
 	process->in = -1;
 	process->out = -1;
submodule.c +89 -89

457 lines not on this page · raw message

t/helper/test-run-command.c +18 -18
index 8d3f6d5a5e..67dde56962 100644
@@ -31,7 +31,7 @@ static int parallel_next(struct child_process *cp,
 	if (number_callbacks >= 4)
 		return 0;
 
-	argv_array_pushv(&cp->args, d->argv);
+	strvec_pushv(&cp->args, d->argv);
 	strbuf_addstr(err, "preloaded output of a child\n");
 	number_callbacks++;
 	return 1;
@@ -72,19 +72,19 @@ static int next_test(struct child_process *cp, struct strbuf *err, void *cb,
 		return 0;
 
 	test = suite->tests.items[suite->next++].string;
-	argv_array_pushl(&cp->args, "sh", test, NULL);
+	strvec_pushl(&cp->args, "sh", test, NULL);
 	if (suite->quiet)
-		argv_array_push(&cp->args, "--quiet");
+		strvec_push(&cp->args, "--quiet");
 	if (suite->immediate)
-		argv_array_push(&cp->args, "-i");
+		strvec_push(&cp->args, "-i");
 	if (suite->verbose)
-		argv_array_push(&cp->args, "-v");
+		strvec_push(&cp->args, "-v");
 	if (suite->verbose_log)
-		argv_array_push(&cp->args, "-V");
+		strvec_push(&cp->args, "-V");
 	if (suite->trace)
-		argv_array_push(&cp->args, "-x");
+		strvec_push(&cp->args, "-x");
 	if (suite->write_junit_xml)
-		argv_array_push(&cp->args, "--write-junit-xml");
+		strvec_push(&cp->args, "--write-junit-xml");
 
 	strbuf_addf(err, "Output of '%s':\n", test);
 	*task_cb = (void *)test;
@@ -220,7 +220,7 @@ static int quote_stress_test(int argc, const char **argv)
 	char special[] = ".?*\\^_\"'`{}()[]<>@~&+:;$%"; // \t\r\n\a";
 	int i, j, k, trials = 100, skip = 0, msys2 = 0;
 	struct strbuf out = STRBUF_INIT;
-	struct argv_array args = ARGV_ARRAY_INIT;
+	struct strvec args = STRVEC_INIT;
 	struct option options[] = {
 		OPT_INTEGER('n', "trials", &trials, "Number of trials"),
 		OPT_INTEGER('s', "skip", &skip, "Skip <n> trials"),
@@ -241,20 +241,20 @@ static int quote_stress_test(int argc, const char **argv)
 		size_t arg_count, arg_offset;
 		int ret = 0;
 
-		argv_array_clear(&args);
+		strvec_clear(&args);
 		if (msys2)
-			argv_array_pushl(&args, "sh", "-c",
+			strvec_pushl(&args, "sh", "-c",
 					 "printf %s\\\\0 \"$@\"", "skip", NULL);
 		else
-			argv_array_pushl(&args, "test-tool", "run-command",
+			strvec_pushl(&args, "test-tool", "run-command",
 					 "quote-echo", NULL);
 		arg_offset = args.argc;
 
 		if (argc > 0) {
 			trials = 1;
 			arg_count = argc;
 			for (j = 0; j < arg_count; j++)
-				argv_array_push(&args, argv[j]);
+				strvec_push(&args, argv[j]);
 		} else {
 			arg_count = 1 + (my_random() % 5);
 			for (j = 0; j < arg_count; j++) {
@@ -268,7 +268,7 @@ static int quote_stress_test(int argc, const char **argv)
 						ARRAY_SIZE(special)];
 				buf[arg_len] = '\0';
 
-				argv_array_push(&args, buf);
+				strvec_push(&args, buf);
 			}
 		}
 
@@ -301,7 +301,7 @@ static int quote_stress_test(int argc, const char **argv)
 					(int)j, args.argv[j + arg_offset]);
 
 			strbuf_release(&out);
-			argv_array_clear(&args);
+			strvec_clear(&args);
 
 			return ret;
 		}
@@ -311,7 +311,7 @@ static int quote_stress_test(int argc, const char **argv)
 	}
 
 	strbuf_release(&out);
-	argv_array_clear(&args);
+	strvec_clear(&args);
 
 	return 0;
 }
@@ -338,7 +338,7 @@ static int inherit_handle(const char *argv0)
 	xsnprintf(path, sizeof(path), "out-XXXXXX");
 	tmp = xmkstemp(path);
 
-	argv_array_pushl(&cp.args,
+	strvec_pushl(&cp.args,
 			 "test-tool", argv0, "inherited-handle-child", NULL);
 	cp.in = -1;
 	cp.no_stdout = cp.no_stderr = 1;
@@ -391,7 +391,7 @@ int cmd__run_command(int argc, const char **argv)
 	while (!strcmp(argv[1], "env")) {
 		if (!argv[2])
 			die("env specifier without a value");
-		argv_array_push(&proc.env_array, argv[2]);
+		strvec_push(&proc.env_array, argv[2]);
 		argv += 2;
 		argc -= 2;
 	}
tmp-objdir.c +8 -8
index 06924a7875..e78e481d8e 100644
@@ -10,7 +10,7 @@
 
 struct tmp_objdir {
 	struct strbuf path;
-	struct argv_array env;
+	struct strvec env;
 };
 
 /*
@@ -24,7 +24,7 @@ static struct tmp_objdir *the_tmp_objdir;
 static void tmp_objdir_free(struct tmp_objdir *t)
 {
 	strbuf_release(&t->path);
-	argv_array_clear(&t->env);
+	strvec_clear(&t->env);
 	free(t);
 }
 
@@ -79,7 +79,7 @@ static void remove_tmp_objdir_on_signal(int signo)
  * separated by PATH_SEP (which is what separate values in
  * GIT_ALTERNATE_OBJECT_DIRECTORIES).
  */
-static void env_append(struct argv_array *env, const char *key, const char *val)
+static void env_append(struct strvec *env, const char *key, const char *val)
 {
 	struct strbuf quoted = STRBUF_INIT;
 	const char *old;
@@ -97,16 +97,16 @@ static void env_append(struct argv_array *env, const char *key, const char *val)
 
 	old = getenv(key);
 	if (!old)
-		argv_array_pushf(env, "%s=%s", key, val);
+		strvec_pushf(env, "%s=%s", key, val);
 	else
-		argv_array_pushf(env, "%s=%s%c%s", key, old, PATH_SEP, val);
+		strvec_pushf(env, "%s=%s%c%s", key, old, PATH_SEP, val);
 
 	strbuf_release(&quoted);
 }
 
-static void env_replace(struct argv_array *env, const char *key, const char *val)
+static void env_replace(struct strvec *env, const char *key, const char *val)
 {
-	argv_array_pushf(env, "%s=%s", key, val);
+	strvec_pushf(env, "%s=%s", key, val);
 }
 
 static int setup_tmp_objdir(const char *root)
@@ -131,7 +131,7 @@ struct tmp_objdir *tmp_objdir_create(void)
 
 	t = xmalloc(sizeof(*t));
 	strbuf_init(&t->path, 0);
-	argv_array_init(&t->env);
+	strvec_init(&t->env);
 
 	strbuf_addf(&t->path, "%s/incoming-XXXXXX", get_object_directory());
 
transport-helper.c +15 -15
index 441763fd7c..dcd4adf444 100644
@@ -128,14 +128,14 @@ static struct child_process *get_helper(struct transport *transport)
 	helper->in = -1;
 	helper->out = -1;
 	helper->err = 0;
-	argv_array_pushf(&helper->args, "git-remote-%s", data->name);
-	argv_array_push(&helper->args, transport->remote->name);
-	argv_array_push(&helper->args, remove_ext_force(transport->url));
+	strvec_pushf(&helper->args, "git-remote-%s", data->name);
+	strvec_push(&helper->args, transport->remote->name);
+	strvec_push(&helper->args, remove_ext_force(transport->url));
 	helper->git_cmd = 0;
 	helper->silent_exec_failure = 1;
 
 	if (have_git_dir())
-		argv_array_pushf(&helper->env_array, "%s=%s",
+		strvec_pushf(&helper->env_array, "%s=%s",
 				 GIT_DIR_ENVIRONMENT, get_git_dir());
 
 	helper->trace2_child_class = helper->args.argv[0]; /* "remote-<name>" */
@@ -439,13 +439,13 @@ static int get_importer(struct transport *transport, struct child_process *fasti
 	int cat_blob_fd, code;
 	child_process_init(fastimport);
 	fastimport->in = xdup(helper->out);
-	argv_array_push(&fastimport->args, "fast-import");
-	argv_array_push(&fastimport->args, "--allow-unsafe-features");
-	argv_array_push(&fastimport->args, debug ? "--stats" : "--quiet");
+	strvec_push(&fastimport->args, "fast-import");
+	strvec_push(&fastimport->args, "--allow-unsafe-features");
+	strvec_push(&fastimport->args, debug ? "--stats" : "--quiet");
 
 	if (data->bidi_import) {
 		cat_blob_fd = xdup(helper->in);
-		argv_array_pushf(&fastimport->args, "--cat-blob-fd=%d", cat_blob_fd);
+		strvec_pushf(&fastimport->args, "--cat-blob-fd=%d", cat_blob_fd);
 	}
 	fastimport->git_cmd = 1;
 
@@ -466,17 +466,17 @@ static int get_exporter(struct transport *transport,
 	/* we need to duplicate helper->in because we want to use it after
 	 * fastexport is done with it. */
 	fastexport->out = dup(helper->in);
-	argv_array_push(&fastexport->args, "fast-export");
-	argv_array_push(&fastexport->args, "--use-done-feature");
-	argv_array_push(&fastexport->args, data->signed_tags ?
+	strvec_push(&fastexport->args, "fast-export");
+	strvec_push(&fastexport->args, "--use-done-feature");
+	strvec_push(&fastexport->args, data->signed_tags ?
 		"--signed-tags=verbatim" : "--signed-tags=warn-strip");
 	if (data->export_marks)
-		argv_array_pushf(&fastexport->args, "--export-marks=%s.tmp", data->export_marks);
+		strvec_pushf(&fastexport->args, "--export-marks=%s.tmp", data->export_marks);
 	if (data->import_marks)
-		argv_array_pushf(&fastexport->args, "--import-marks=%s", data->import_marks);
+		strvec_pushf(&fastexport->args, "--import-marks=%s", data->import_marks);
 
 	for (i = 0; i < revlist_args->nr; i++)
-		argv_array_push(&fastexport->args, revlist_args->items[i].string);
+		strvec_push(&fastexport->args, revlist_args->items[i].string);
 
 	fastexport->git_cmd = 1;
 	return start_command(fastexport);
@@ -1082,7 +1082,7 @@ static int has_attribute(const char *attrs, const char *attr)
 }
 
 static struct ref *get_refs_list(struct transport *transport, int for_push,
-				 const struct argv_array *ref_prefixes)
+				 const struct strvec *ref_prefixes)
 {
 	get_helper(transport);
 
transport-internal.h +1 -1
index 284784a2a6..27c9daffc4 100644
@@ -30,7 +30,7 @@ struct transport_vtable {
 	 * in the ref's old_sha1 field; otherwise it should be all 0.
 	 **/
 	struct ref *(*get_refs_list)(struct transport *transport, int for_push,
-				     const struct argv_array *ref_prefixes);
+				     const struct strvec *ref_prefixes);
 
 	/**
 	 * Fetch the objects for the given refs. Note that this gets
transport.c +6 -6
index b41386eccb..2d4fd851dc 100644
@@ -127,7 +127,7 @@ struct bundle_transport_data {
 
 static struct ref *get_refs_from_bundle(struct transport *transport,
 					int for_push,
-					const struct argv_array *ref_prefixes)
+					const struct strvec *ref_prefixes)
 {
 	struct bundle_transport_data *data = transport->data;
 	struct ref *result = NULL;
@@ -283,7 +283,7 @@ static void die_if_server_options(struct transport *transport)
  * remote refs.
  */
 static struct ref *handshake(struct transport *transport, int for_push,
-			     const struct argv_array *ref_prefixes,
+			     const struct strvec *ref_prefixes,
 			     int must_list_refs)
 {
 	struct git_transport_data *data = transport->data;
@@ -327,7 +327,7 @@ static struct ref *handshake(struct transport *transport, int for_push,
 }
 
 static struct ref *get_refs_via_connect(struct transport *transport, int for_push,
-					const struct argv_array *ref_prefixes)
+					const struct strvec *ref_prefixes)
 {
 	return handshake(transport, for_push, ref_prefixes, 1);
 }
@@ -1153,7 +1153,7 @@ int transport_push(struct repository *r,
 		int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
 		int pretend = flags & TRANSPORT_PUSH_DRY_RUN;
 		int push_ret, ret, err;
-		struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
+		struct strvec ref_prefixes = STRVEC_INIT;
 
 		if (check_push_refs(local_refs, rs) < 0)
 			return -1;
@@ -1165,7 +1165,7 @@ int transport_push(struct repository *r,
 							       &ref_prefixes);
 		trace2_region_leave("transport_push", "get_refs_list", r);
 
-		argv_array_clear(&ref_prefixes);
+		strvec_clear(&ref_prefixes);
 
 		if (flags & TRANSPORT_PUSH_ALL)
 			match_flags |= MATCH_REFS_ALL;
@@ -1281,7 +1281,7 @@ int transport_push(struct repository *r,
 }
 
 const struct ref *transport_get_remote_refs(struct transport *transport,
-					    const struct argv_array *ref_prefixes)
+					    const struct strvec *ref_prefixes)
 {
 	if (!transport->got_remote_refs) {
 		transport->remote_refs =
transport.h +1 -1
index b3c30133ea..1be4013dec 100644
@@ -243,7 +243,7 @@ int transport_push(struct repository *repo,
  * ref_prefixes.
  */
 const struct ref *transport_get_remote_refs(struct transport *transport,
-					    const struct argv_array *ref_prefixes);
+					    const struct strvec *ref_prefixes);
 
 /*
  * Fetch the hash algorithm used by a remote.
unpack-trees.c +5 -5
index 65c3395f0f..323280dd48 100644
@@ -106,7 +106,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
 	const char **msgs = opts->msgs;
 	const char *msg;
 
-	argv_array_init(&opts->msgs_to_free);
+	strvec_init(&opts->msgs_to_free);
 
 	if (!strcmp(cmd, "checkout"))
 		msg = advice_commit_before_merge
@@ -124,7 +124,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
 			  "Please commit your changes or stash them before you %s.")
 		      : _("Your local changes to the following files would be overwritten by %s:\n%%s");
 	msgs[ERROR_WOULD_OVERWRITE] = msgs[ERROR_NOT_UPTODATE_FILE] =
-		argv_array_pushf(&opts->msgs_to_free, msg, cmd, cmd);
+		strvec_pushf(&opts->msgs_to_free, msg, cmd, cmd);
 
 	msgs[ERROR_NOT_UPTODATE_DIR] =
 		_("Updating the following directories would lose untracked files in them:\n%s");
@@ -145,7 +145,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
 			  "Please move or remove them before you %s.")
 		      : _("The following untracked working tree files would be removed by %s:\n%%s");
 	msgs[ERROR_WOULD_LOSE_UNTRACKED_REMOVED] =
-		argv_array_pushf(&opts->msgs_to_free, msg, cmd, cmd);
+		strvec_pushf(&opts->msgs_to_free, msg, cmd, cmd);
 
 	if (!strcmp(cmd, "checkout"))
 		msg = advice_commit_before_merge
@@ -163,7 +163,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
 			  "Please move or remove them before you %s.")
 		      : _("The following untracked working tree files would be overwritten by %s:\n%%s");
 	msgs[ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN] =
-		argv_array_pushf(&opts->msgs_to_free, msg, cmd, cmd);
+		strvec_pushf(&opts->msgs_to_free, msg, cmd, cmd);
 
 	/*
 	 * Special case: ERROR_BIND_OVERLAP refers to a pair of paths, we
@@ -189,7 +189,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
 
 void clear_unpack_trees_porcelain(struct unpack_trees_options *opts)
 {
-	argv_array_clear(&opts->msgs_to_free);
+	strvec_clear(&opts->msgs_to_free);
 	memset(opts->msgs, 0, sizeof(opts->msgs));
 }
 
unpack-trees.h +1 -1
index f8a904a05b..2e87875b15 100644
@@ -70,7 +70,7 @@ struct unpack_trees_options {
 	struct pathspec *pathspec;
 	merge_fn_t fn;
 	const char *msgs[NB_UNPACK_TREES_WARNING_TYPES];
-	struct argv_array msgs_to_free;
+	struct strvec msgs_to_free;
 	/*
 	 * Store error messages in an array, each case
 	 * corresponding to a error message type
upload-pack.c +24 -24

102 lines not on this page · raw message

wt-status.c +8 -8
index 9817161da4..60d4e847a5 100644
@@ -913,17 +913,17 @@ static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncom
 	struct strbuf summary = STRBUF_INIT;
 	char *summary_content;
 
-	argv_array_pushf(&sm_summary.env_array, "GIT_INDEX_FILE=%s",
+	strvec_pushf(&sm_summary.env_array, "GIT_INDEX_FILE=%s",
 			 s->index_file);
 
-	argv_array_push(&sm_summary.args, "submodule");
-	argv_array_push(&sm_summary.args, "summary");
-	argv_array_push(&sm_summary.args, uncommitted ? "--files" : "--cached");
-	argv_array_push(&sm_summary.args, "--for-status");
-	argv_array_push(&sm_summary.args, "--summary-limit");
-	argv_array_pushf(&sm_summary.args, "%d", s->submodule_summary);
+	strvec_push(&sm_summary.args, "submodule");
+	strvec_push(&sm_summary.args, "summary");
+	strvec_push(&sm_summary.args, uncommitted ? "--files" : "--cached");
+	strvec_push(&sm_summary.args, "--for-status");
+	strvec_push(&sm_summary.args, "--summary-limit");
+	strvec_pushf(&sm_summary.args, "%d", s->submodule_summary);
 	if (!uncommitted)
-		argv_array_push(&sm_summary.args, s->amend ? "HEAD^" : "HEAD");
+		strvec_push(&sm_summary.args, s->amend ? "HEAD^" : "HEAD");
 
 	sm_summary.git_cmd = 1;
 	sm_summary.no_stdin = 1;
Signature · 1 line
2.28.0.rc2.475.g53c7e1c7f4
author
#8 lore raw

PATCH 8/11 strvec: fix indentation in renamed calls

In reply to Jeff King

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.

---
 add-interactive.c           | 10 ++++-----
 add-patch.c                 | 10 ++++-----
 bisect.c                    |  2 +-
 builtin/bisect--helper.c    |  2 +-
 builtin/describe.c          |  8 +++----
 builtin/difftool.c          | 12 +++++------
 builtin/fetch.c             |  2 +-
 builtin/gc.c                |  2 +-
 builtin/pull.c              |  6 +++---
 builtin/rebase.c            | 14 ++++++-------
 builtin/receive-pack.c      | 42 ++++++++++++++++++-------------------
 builtin/repack.c            |  8 +++----
 builtin/stash.c             | 38 ++++++++++++++++-----------------
 builtin/submodule--helper.c | 20 +++++++++---------
 builtin/worktree.c          | 18 ++++++++--------
 bundle.c                    | 10 ++++-----
 connect.c                   |  7 ++++---
 connected.c                 |  2 +-
 daemon.c                    |  6 +++---
 fetch-pack.c                | 12 +++++------
 gpg-interface.c             | 14 ++++++-------
 http-backend.c              |  2 +-
 http-push.c                 |  2 +-
 http.c                      |  2 +-
 range-diff.c                | 28 ++++++++++++-------------
 refspec.c                   |  4 ++--
 remote-curl.c               |  8 +++----
 remote.c                    |  4 ++--
 sequencer.c                 |  8 +++----
 submodule.c                 | 30 +++++++++++++-------------
 t/helper/test-run-command.c |  6 +++---
 transport-helper.c          |  2 +-
 upload-pack.c               |  3 +--
 wt-status.c                 |  3 +--
 34 files changed, 173 insertions(+), 174 deletions(-)
add-interactive.c +5 -5
index b345777d0c..458f3a3e69 100644
@@ -941,7 +941,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps,
 		for (i = 0; i < files->items.nr; i++)
 			if (files->selected[i])
 				strvec_push(&args,
-						files->items.items[i].string);
+					    files->items.items[i].string);
 		parse_pathspec(&ps_selected,
 			       PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
 			       PATHSPEC_LITERAL_PATH, "", args.argv);
@@ -979,13 +979,13 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
 		struct strvec args = STRVEC_INIT;
 
 		strvec_pushl(&args, "git", "diff", "-p", "--cached",
-				 oid_to_hex(!is_initial ? &oid :
-					    s->r->hash_algo->empty_tree),
-				 "--", NULL);
+			     oid_to_hex(!is_initial ? &oid :
+					s->r->hash_algo->empty_tree),
+			     "--", NULL);
 		for (i = 0; i < files->items.nr; i++)
 			if (files->selected[i])
 				strvec_push(&args,
-						files->items.items[i].string);
+					    files->items.items[i].string);
 		res = run_command_v_opt(args.argv, 0);
 		strvec_clear(&args);
 	}
add-patch.c +5 -5
index 3c91ae52ae..8c0772803b 100644
@@ -291,7 +291,7 @@ static void setup_child_process(struct add_p_state *s,
 
 	cp->git_cmd = 1;
 	strvec_pushf(&cp->env_array,
-			 INDEX_ENVIRONMENT "=%s", s->s.r->index_file);
+		     INDEX_ENVIRONMENT "=%s", s->s.r->index_file);
 }
 
 static int parse_range(const char **p,
@@ -386,10 +386,10 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 	if (s->revision) {
 		struct object_id oid;
 		strvec_push(&args,
-				/* could be on an unborn branch */
-				!strcmp("HEAD", s->revision) &&
-				get_oid("HEAD", &oid) ?
-				empty_tree_oid_hex() : s->revision);
+			    /* could be on an unborn branch */
+			    !strcmp("HEAD", s->revision) &&
+			    get_oid("HEAD", &oid) ?
+			    empty_tree_oid_hex() : s->revision);
 	}
 	color_arg_index = args.argc;
 	/* Use `--no-color` explicitly, just in case `diff.color = always`. */
bisect.c +1 -1
index 3e50b51c11..99ff694960 100644
@@ -644,7 +644,7 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs,
 	strvec_pushf(&rev_argv, bad_format, oid_to_hex(current_bad_oid));
 	for (i = 0; i < good_revs.nr; i++)
 		strvec_pushf(&rev_argv, good_format,
-				 oid_to_hex(good_revs.oid + i));
+			     oid_to_hex(good_revs.oid + i));
 	strvec_push(&rev_argv, "--");
 	if (read_paths)
 		read_bisect_paths(&rev_argv);
builtin/bisect--helper.c +1 -1
index 9815e78871..dd52878413 100644
@@ -529,7 +529,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
 			struct strvec argv = STRVEC_INIT;
 
 			strvec_pushl(&argv, "checkout", start_head.buf,
-					 "--", NULL);
+				     "--", NULL);
 			if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
 				res = error(_("checking out '%s' failed."
 						 " Try 'git bisect start "
builtin/describe.c +4 -4
index ff3c169fa9..e3cac8002c 100644
@@ -505,8 +505,8 @@ static void describe_blob(struct object_id oid, struct strbuf *dst)
 	struct process_commit_data pcd = { null_oid, oid, dst, &revs};
 
 	strvec_pushl(&args, "internal: The first arg is not parsed",
-		"--objects", "--in-commit-order", "--reverse", "HEAD",
-		NULL);
+		     "--objects", "--in-commit-order", "--reverse", "HEAD",
+		     NULL);
 
 	repo_init_revisions(the_repository, &revs, NULL);
 	if (setup_revisions(args.argc, args.argv, &revs, NULL) > 1)
@@ -598,8 +598,8 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 
 		strvec_init(&args);
 		strvec_pushl(&args, "name-rev",
-				 "--peel-tag", "--name-only", "--no-undefined",
-				 NULL);
+			     "--peel-tag", "--name-only", "--no-undefined",
+			     NULL);
 		if (always)
 			strvec_push(&args, "--always");
 		if (!all) {
builtin/difftool.c +6 -6
index 40c4d7b6b6..5ac021a1d4 100644
@@ -211,9 +211,9 @@ static void changed_files(struct hashmap *result, const char *index_path,
 	env[0] = index_env.buf;
 
 	strvec_pushl(&update_index.args,
-			 "--git-dir", git_dir, "--work-tree", workdir,
-			 "update-index", "--really-refresh", "-q",
-			 "--unmerged", NULL);
+		     "--git-dir", git_dir, "--work-tree", workdir,
+		     "update-index", "--really-refresh", "-q",
+		     "--unmerged", NULL);
 	update_index.no_stdin = 1;
 	update_index.no_stdout = 1;
 	update_index.no_stderr = 1;
@@ -226,8 +226,8 @@ static void changed_files(struct hashmap *result, const char *index_path,
 	run_command(&update_index);
 
 	strvec_pushl(&diff_files.args,
-			 "--git-dir", git_dir, "--work-tree", workdir,
-			 "diff-files", "--name-only", "-z", NULL);
+		     "--git-dir", git_dir, "--work-tree", workdir,
+		     "diff-files", "--name-only", "-z", NULL);
 	diff_files.no_stdin = 1;
 	diff_files.git_cmd = 1;
 	diff_files.use_shell = 0;
@@ -394,7 +394,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
 	child.dir = prefix;
 	child.out = -1;
 	strvec_pushl(&child.args, "diff", "--raw", "--no-abbrev", "-z",
-			 NULL);
+		     NULL);
 	for (i = 0; i < argc; i++)
 		strvec_push(&child.args, argv[i]);
 	if (start_command(&child))
builtin/fetch.c +1 -1
index cc636188ad..c2e7afeb6a 100644
@@ -1601,7 +1601,7 @@ static int fetch_multiple(struct string_list *list, int max_children)
 	}
 
 	strvec_pushl(&argv, "fetch", "--append", "--no-auto-gc",
-			"--no-write-commit-graph", NULL);
+		     "--no-write-commit-graph", NULL);
 	add_options_to_argv(&argv);
 
 	if (max_children != 1 && list->nr != 1) {
builtin/gc.c +1 -1
index 89742e159e..98719800a3 100644
@@ -662,7 +662,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
 				strvec_push(&prune, "--no-progress");
 			if (has_promisor_remote())
 				strvec_push(&prune,
-						"--exclude-promisor-objects");
+					    "--exclude-promisor-objects");
 			if (run_command_v_opt(prune.argv, RUN_GIT_CMD))
 				die(FAILED_RUN, prune.argv[0]);
 		}
builtin/pull.c +3 -3
index 8a8d30e1dc..dae8766646 100644
@@ -638,7 +638,7 @@ static int rebase_submodules(void)
 	cp.git_cmd = 1;
 	cp.no_stdin = 1;
 	strvec_pushl(&cp.args, "submodule", "update",
-				   "--recursive", "--rebase", NULL);
+		     "--recursive", "--rebase", NULL);
 	argv_push_verbosity(&cp.args);
 
 	return run_command(&cp);
@@ -651,7 +651,7 @@ static int update_submodules(void)
 	cp.git_cmd = 1;
 	cp.no_stdin = 1;
 	strvec_pushl(&cp.args, "submodule", "update",
-				   "--recursive", "--checkout", NULL);
+		     "--recursive", "--checkout", NULL);
 	argv_push_verbosity(&cp.args);
 
 	return run_command(&cp);
@@ -802,7 +802,7 @@ static int get_rebase_fork_point(struct object_id *fork_point, const char *repo,
 		return -1;
 
 	strvec_pushl(&cp.args, "merge-base", "--fork-point",
-			remote_branch, curr_branch->name, NULL);
+		     remote_branch, curr_branch->name, NULL);
 	cp.no_stdin = 1;
 	cp.no_stderr = 1;
 	cp.git_cmd = 1;
builtin/rebase.c +7 -7
index fb56b9e263..35aeb8effc 100644
@@ -348,7 +348,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
 	strvec_pushl(&make_script_args, "", revisions, NULL);
 	if (opts->restrict_revision)
 		strvec_pushf(&make_script_args, "^%s",
-				 oid_to_hex(&opts->restrict_revision->object.oid));
+			     oid_to_hex(&opts->restrict_revision->object.oid));
 
 	ret = sequencer_make_script(the_repository, &todo_list.buf,
 				    make_script_args.argc, make_script_args.argv,
@@ -858,17 +858,17 @@ static int run_am(struct rebase_options *opts)
 
 	format_patch.git_cmd = 1;
 	strvec_pushl(&format_patch.args, "format-patch", "-k", "--stdout",
-			 "--full-index", "--cherry-pick", "--right-only",
-			 "--src-prefix=a/", "--dst-prefix=b/", "--no-renames",
-			 "--no-cover-letter", "--pretty=mboxrd", "--topo-order",
-			 "--no-base", NULL);
+		     "--full-index", "--cherry-pick", "--right-only",
+		     "--src-prefix=a/", "--dst-prefix=b/", "--no-renames",
+		     "--no-cover-letter", "--pretty=mboxrd", "--topo-order",
+		     "--no-base", NULL);
 	if (opts->git_format_patch_opt.len)
 		strvec_split(&format_patch.args,
-				 opts->git_format_patch_opt.buf);
+			     opts->git_format_patch_opt.buf);
 	strvec_push(&format_patch.args, revisions.buf);
 	if (opts->restrict_revision)
 		strvec_pushf(&format_patch.args, "^%s",
-				 oid_to_hex(&opts->restrict_revision->object.oid));
+			     oid_to_hex(&opts->restrict_revision->object.oid));
 
 	status = run_command(&format_patch);
 	if (status) {
builtin/receive-pack.c +21 -21

94 lines not on this page · raw message

builtin/repack.c +4 -4
index 7435ee9af1..04c5ceaf7e 100644
@@ -366,7 +366,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 		strvec_push(&cmd.args, "--honor-pack-keep");
 	for (i = 0; i < keep_pack_list.nr; i++)
 		strvec_pushf(&cmd.args, "--keep-pack=%s",
-				 keep_pack_list.items[i].string);
+			     keep_pack_list.items[i].string);
 	strvec_push(&cmd.args, "--non-empty");
 	strvec_push(&cmd.args, "--all");
 	strvec_push(&cmd.args, "--reflog");
@@ -388,12 +388,12 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 		if (existing_packs.nr && delete_redundant) {
 			if (unpack_unreachable) {
 				strvec_pushf(&cmd.args,
-						"--unpack-unreachable=%s",
-						unpack_unreachable);
+					     "--unpack-unreachable=%s",
+					     unpack_unreachable);
 				strvec_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
 			} else if (pack_everything & LOOSEN_UNREACHABLE) {
 				strvec_push(&cmd.args,
-						"--unpack-unreachable");
+					    "--unpack-unreachable");
 			} else if (keep_unreachable) {
 				strvec_push(&cmd.args, "--keep-unreachable");
 				strvec_push(&cmd.args, "--pack-loose-unreachable");
builtin/stash.c +19 -19
index 05c086e54c..bfdbafae89 100644
@@ -336,7 +336,7 @@ static int get_newly_staged(struct strbuf *out, struct object_id *c_tree)
 	 */
 	cp.git_cmd = 1;
 	strvec_pushl(&cp.args, "diff-index", "--cached", "--name-only",
-			 "--diff-filter=A", NULL);
+		     "--diff-filter=A", NULL);
 	strvec_push(&cp.args, c_tree_hex);
 	return pipe_command(&cp, NULL, 0, out, 0, NULL, 0);
 }
@@ -368,7 +368,7 @@ static int restore_untracked(struct object_id *u_tree)
 	strvec_push(&cp.args, "read-tree");
 	strvec_push(&cp.args, oid_to_hex(u_tree));
 	strvec_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
-			 stash_index_path.buf);
+		     stash_index_path.buf);
 	if (run_command(&cp)) {
 		remove_path(stash_index_path.buf);
 		return -1;
@@ -378,7 +378,7 @@ static int restore_untracked(struct object_id *u_tree)
 	cp.git_cmd = 1;
 	strvec_pushl(&cp.args, "checkout-index", "--all", NULL);
 	strvec_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
-			 stash_index_path.buf);
+		     stash_index_path.buf);
 
 	res = run_command(&cp);
 	remove_path(stash_index_path.buf);
@@ -500,9 +500,9 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
 		cp.git_cmd = 1;
 		cp.dir = prefix;
 		strvec_pushf(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT"=%s",
-				 absolute_path(get_git_work_tree()));
+			     absolute_path(get_git_work_tree()));
 		strvec_pushf(&cp.env_array, GIT_DIR_ENVIRONMENT"=%s",
-				 absolute_path(get_git_dir()));
+			     absolute_path(get_git_dir()));
 		strvec_push(&cp.args, "status");
 		run_command(&cp);
 	}
@@ -547,7 +547,7 @@ static int do_drop_stash(struct stash_info *info, int quiet)
 
 	cp_reflog.git_cmd = 1;
 	strvec_pushl(&cp_reflog.args, "reflog", "delete", "--updateref",
-			 "--rewrite", NULL);
+		     "--rewrite", NULL);
 	strvec_push(&cp_reflog.args, info->revision.buf);
 	ret = run_command(&cp_reflog);
 	if (!ret) {
@@ -693,7 +693,7 @@ static int list_stash(int argc, const char **argv, const char *prefix)
 
 	cp.git_cmd = 1;
 	strvec_pushl(&cp.args, "log", "--format=%gd: %gs", "-g",
-			 "--first-parent", "-m", NULL);
+		     "--first-parent", "-m", NULL);
 	strvec_pushv(&cp.args, argv);
 	strvec_push(&cp.args, ref_stash);
 	strvec_push(&cp.args, "--");
@@ -961,7 +961,7 @@ static int save_untracked_files(struct stash_info *info, struct strbuf *msg,
 
 	cp_upd_index.git_cmd = 1;
 	strvec_pushl(&cp_upd_index.args, "update-index", "-z", "--add",
-			 "--remove", "--stdin", NULL);
+		     "--remove", "--stdin", NULL);
 	strvec_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
 			 stash_index_path.buf);
 
@@ -1005,7 +1005,7 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps,
 	cp_read_tree.git_cmd = 1;
 	strvec_pushl(&cp_read_tree.args, "read-tree", "HEAD", NULL);
 	strvec_pushf(&cp_read_tree.env_array, "GIT_INDEX_FILE=%s",
-			 stash_index_path.buf);
+		     stash_index_path.buf);
 	if (run_command(&cp_read_tree)) {
 		ret = -1;
 		goto done;
@@ -1035,7 +1035,7 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps,
 
 	cp_diff_tree.git_cmd = 1;
 	strvec_pushl(&cp_diff_tree.args, "diff-tree", "-p", "-U1", "HEAD",
-			 oid_to_hex(&info->w_tree), "--", NULL);
+		     oid_to_hex(&info->w_tree), "--", NULL);
 	if (pipe_command(&cp_diff_tree, NULL, 0, out_patch, 0, NULL, 0)) {
 		ret = -1;
 		goto done;
@@ -1089,10 +1089,10 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps
 
 	cp_upd_index.git_cmd = 1;
 	strvec_pushl(&cp_upd_index.args, "update-index",
-			 "--ignore-skip-worktree-entries",
-			 "-z", "--add", "--remove", "--stdin", NULL);
+		     "--ignore-skip-worktree-entries",
+		     "-z", "--add", "--remove", "--stdin", NULL);
 	strvec_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
-			 stash_index_path.buf);
+		     stash_index_path.buf);
 
 	if (pipe_command(&cp_upd_index, diff_output.buf, diff_output.len,
 			 NULL, 0, NULL, 0)) {
@@ -1343,7 +1343,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
 
 			cp.git_cmd = 1;
 			strvec_pushl(&cp.args, "clean", "--force",
-					 "--quiet", "-d", NULL);
+				     "--quiet", "-d", NULL);
 			if (include_untracked == INCLUDE_ALL_FILES)
 				strvec_push(&cp.args, "-x");
 			if (run_command(&cp)) {
@@ -1373,8 +1373,8 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
 
 			cp_diff.git_cmd = 1;
 			strvec_pushl(&cp_diff.args, "diff-index", "-p",
-					 "--cached", "--binary", "HEAD", "--",
-					 NULL);
+				     "--cached", "--binary", "HEAD", "--",
+				     NULL);
 			add_pathspecs(&cp_diff.args, ps);
 			if (pipe_command(&cp_diff, NULL, 0, &out, 0, NULL, 0)) {
 				ret = -1;
@@ -1383,7 +1383,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
 
 			cp_apply.git_cmd = 1;
 			strvec_pushl(&cp_apply.args, "apply", "--index",
-					 "-R", NULL);
+				     "-R", NULL);
 			if (pipe_command(&cp_apply, out.buf, out.len, NULL, 0,
 					 NULL, 0)) {
 				ret = -1;
@@ -1393,7 +1393,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
 			struct child_process cp = CHILD_PROCESS_INIT;
 			cp.git_cmd = 1;
 			strvec_pushl(&cp.args, "reset", "--hard", "-q",
-					 "--no-recurse-submodules", NULL);
+				     "--no-recurse-submodules", NULL);
 			if (run_command(&cp)) {
 				ret = -1;
 				goto done;
@@ -1405,7 +1405,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
 
 			cp.git_cmd = 1;
 			strvec_pushl(&cp.args, "checkout", "--no-overlay",
-					 oid_to_hex(&info.i_tree), "--", NULL);
+				     oid_to_hex(&info.i_tree), "--", NULL);
 			if (!ps->nr)
 				strvec_push(&cp.args, ":/");
 			else
builtin/submodule--helper.c +10 -10
index 7705e8eabf..665db1ffed 100644
@@ -499,7 +499,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
 		strvec_pushf(&cp.env_array, "sm_path=%s", path);
 		strvec_pushf(&cp.env_array, "displaypath=%s", displaypath);
 		strvec_pushf(&cp.env_array, "sha1=%s",
-				oid_to_hex(ce_oid));
+			     oid_to_hex(ce_oid));
 		strvec_pushf(&cp.env_array, "toplevel=%s", toplevel);
 
 		/*
@@ -513,7 +513,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
 		 */
 		sq_quote_buf(&sb, path);
 		strvec_pushf(&cp.args, "path=%s; %s",
-				 sb.buf, info->argv[0]);
+			     sb.buf, info->argv[0]);
 		strbuf_release(&sb);
 		free(toplevel);
 	} else {
@@ -537,7 +537,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
 		strvec_pushl(&cpr.args, "--super-prefix", NULL);
 		strvec_pushf(&cpr.args, "%s/", displaypath);
 		strvec_pushl(&cpr.args, "submodule--helper", "foreach", "--recursive",
-				NULL);
+			     NULL);
 
 		if (info->quiet)
 			strvec_push(&cpr.args, "--quiet");
@@ -810,8 +810,8 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
 	strbuf_release(&buf);
 
 	strvec_pushl(&diff_files_args, "diff-files",
-			 "--ignore-submodules=dirty", "--quiet", "--",
-			 path, NULL);
+		     "--ignore-submodules=dirty", "--quiet", "--",
+		     path, NULL);
 
 	git_config(git_diff_basic_config, NULL);
 
@@ -852,7 +852,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
 		strvec_push(&cpr.args, "--super-prefix");
 		strvec_pushf(&cpr.args, "%s/", displaypath);
 		strvec_pushl(&cpr.args, "submodule--helper", "status",
-				 "--recursive", NULL);
+			     "--recursive", NULL);
 
 		if (flags & OPT_CACHED)
 			strvec_push(&cpr.args, "--cached");
@@ -996,7 +996,7 @@ static void sync_submodule(const char *path, const char *prefix,
 	cp.git_cmd = 1;
 	cp.dir = path;
 	strvec_pushl(&cp.args, "submodule--helper",
-			 "print-default-remote", NULL);
+		     "print-default-remote", NULL);
 
 	strbuf_reset(&sb);
 	if (capture_command(&cp, &sb, 0))
@@ -1024,7 +1024,7 @@ static void sync_submodule(const char *path, const char *prefix,
 		strvec_push(&cpr.args, "--super-prefix");
 		strvec_pushf(&cpr.args, "%s/", displaypath);
 		strvec_pushl(&cpr.args, "submodule--helper", "sync",
-				 "--recursive", NULL);
+			     "--recursive", NULL);
 
 		if (flags & OPT_QUIET)
 			strvec_push(&cpr.args, "--quiet");
@@ -1128,7 +1128,7 @@ static void deinit_submodule(const char *path, const char *prefix,
 			struct child_process cp_rm = CHILD_PROCESS_INIT;
 			cp_rm.git_cmd = 1;
 			strvec_pushl(&cp_rm.args, "rm", "-qn",
-					 path, NULL);
+				     path, NULL);
 
 			if (run_command(&cp_rm))
 				die(_("Submodule work tree '%s' contains local "
@@ -1251,7 +1251,7 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
 		struct string_list_item *item;
 		for_each_string_list_item(item, reference)
 			strvec_pushl(&cp.args, "--reference",
-					 item->string, NULL);
+				     item->string, NULL);
 	}
 	if (dissociate)
 		strvec_push(&cp.args, "--dissociate");
builtin/worktree.c +9 -9
index 3c483c23d4..be5d84f0a0 100644
@@ -414,10 +414,10 @@ static int add_worktree(const char *path, const char *refname,
 
 	if (!is_branch)
 		strvec_pushl(&cp.args, "update-ref", "HEAD",
-				 oid_to_hex(&commit->object.oid), NULL);
+			     oid_to_hex(&commit->object.oid), NULL);
 	else {
 		strvec_pushl(&cp.args, "symbolic-ref", "HEAD",
-				 symref.buf, NULL);
+			     symref.buf, NULL);
 		if (opts->quiet)
 			strvec_push(&cp.args, "--quiet");
 	}
@@ -466,9 +466,9 @@ static int add_worktree(const char *path, const char *refname,
 			cp.argv = NULL;
 			cp.trace2_hook_name = "post-checkout";
 			strvec_pushl(&cp.args, absolute_path(hook),
-					 oid_to_hex(&null_oid),
-					 oid_to_hex(&commit->object.oid),
-					 "1", NULL);
+				     oid_to_hex(&null_oid),
+				     oid_to_hex(&commit->object.oid),
+				     "1", NULL);
 			ret = run_command(&cp);
 		}
 	}
@@ -936,13 +936,13 @@ static void check_clean_worktree(struct worktree *wt,
 	validate_no_submodules(wt);
 
 	strvec_pushf(&child_env, "%s=%s/.git",
-			 GIT_DIR_ENVIRONMENT, wt->path);
+		     GIT_DIR_ENVIRONMENT, wt->path);
 	strvec_pushf(&child_env, "%s=%s",
-			 GIT_WORK_TREE_ENVIRONMENT, wt->path);
+		     GIT_WORK_TREE_ENVIRONMENT, wt->path);
 	memset(&cp, 0, sizeof(cp));
 	strvec_pushl(&cp.args, "status",
-			 "--porcelain", "--ignore-submodules=none",
-			 NULL);
+		     "--porcelain", "--ignore-submodules=none",
+		     NULL);
 	cp.env = child_env.argv;
 	cp.git_cmd = 1;
 	cp.dir = wt->path;
bundle.c +5 -5
index 709b2abc9c..565d05367f 100644
@@ -275,9 +275,9 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *
 	int i;
 
 	strvec_pushl(&pack_objects.args,
-			 "pack-objects",
-			 "--stdout", "--thin", "--delta-base-offset",
-			 NULL);
+		     "pack-objects",
+		     "--stdout", "--thin", "--delta-base-offset",
+		     NULL);
 	strvec_pushv(&pack_objects.args, pack_options->argv);
 	pack_objects.in = -1;
 	pack_objects.out = bundle_fd;
@@ -322,8 +322,8 @@ static int compute_and_write_prerequisites(int bundle_fd,
 	int i;
 
 	strvec_pushl(&rls.args,
-			 "rev-list", "--boundary", "--pretty=oneline",
-			 NULL);
+		     "rev-list", "--boundary", "--pretty=oneline",
+		     NULL);
 	for (i = 1; i < argc; i++)
 		strvec_push(&rls.args, argv[i]);
 	rls.out = -1;
connect.c +4 -3
index 9b453fe792..3299ea956a 100644
@@ -1208,7 +1208,7 @@ static void push_ssh_options(struct strvec *args, struct strvec *env,
 		strvec_push(args, "-o");
 		strvec_push(args, "SendEnv=" GIT_PROTOCOL_ENVIRONMENT);
 		strvec_pushf(env, GIT_PROTOCOL_ENVIRONMENT "=version=%d",
-				 version);
+			     version);
 	}
 
 	if (flags & CONNECT_IPV4) {
@@ -1397,8 +1397,9 @@ struct child_process *git_connect(int fd[2], const char *url,
 			transport_check_allowed("file");
 			conn->trace2_child_class = "transport/file";
 			if (version > 0) {
-				strvec_pushf(&conn->env_array, GIT_PROTOCOL_ENVIRONMENT "=version=%d",
-						 version);
+				strvec_pushf(&conn->env_array,
+					     GIT_PROTOCOL_ENVIRONMENT "=version=%d",
+					     version);
 			}
 		}
 		strvec_push(&conn->args, cmd.buf);
connected.c +1 -1
index 96b47879d3..21c1ebe9fb 100644
@@ -106,7 +106,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
 	strvec_push(&rev_list.args, "--alternate-refs");
 	if (opt->progress)
 		strvec_pushf(&rev_list.args, "--progress=%s",
-				 _("Checking connectivity"));
+			     _("Checking connectivity"));
 
 	rev_list.git_cmd = 1;
 	rev_list.env = opt->env;
daemon.c +3 -3
index cea5f5354f..0dec89fa02 100644
@@ -665,7 +665,7 @@ static void parse_extra_args(struct hostinfo *hi, struct strvec *env,
 	if (git_protocol.len > 0) {
 		loginfo("Extended attribute \"protocol\": %s", git_protocol.buf);
 		strvec_pushf(env, GIT_PROTOCOL_ENVIRONMENT "=%s",
-				 git_protocol.buf);
+			     git_protocol.buf);
 	}
 	strbuf_release(&git_protocol);
 }
@@ -915,15 +915,15 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
 		inet_ntop(addr->sa_family, &sin_addr->sin_addr, buf, sizeof(buf));
 		strvec_pushf(&cld.env_array, "REMOTE_ADDR=%s", buf);
 		strvec_pushf(&cld.env_array, "REMOTE_PORT=%d",
-				 ntohs(sin_addr->sin_port));
+			     ntohs(sin_addr->sin_port));
 #ifndef NO_IPV6
 	} else if (addr->sa_family == AF_INET6) {
 		char buf[128] = "";
 		struct sockaddr_in6 *sin6_addr = (void *) addr;
 		inet_ntop(AF_INET6, &sin6_addr->sin6_addr, buf, sizeof(buf));
 		strvec_pushf(&cld.env_array, "REMOTE_ADDR=[%s]", buf);
 		strvec_pushf(&cld.env_array, "REMOTE_PORT=%d",
-				 ntohs(sin6_addr->sin6_port));
+			     ntohs(sin6_addr->sin6_port));
 #endif
 	}
 
fetch-pack.c +6 -6
index 7aa5dfbdad..7f20eca4f8 100644
@@ -854,8 +854,8 @@ static int get_pack(struct fetch_pack_args *args,
 			if (xgethostname(hostname, sizeof(hostname)))
 				xsnprintf(hostname, sizeof(hostname), "localhost");
 			strvec_pushf(&cmd.args,
-					"--keep=fetch-pack %"PRIuMAX " on %s",
-					(uintmax_t)getpid(), hostname);
+				     "--keep=fetch-pack %"PRIuMAX " on %s",
+				     (uintmax_t)getpid(), hostname);
 		}
 		if (only_packfile && args->check_self_contained_and_connected)
 			strvec_push(&cmd.args, "--check-self-contained-and-connected");
@@ -885,7 +885,7 @@ static int get_pack(struct fetch_pack_args *args,
 
 	if (pass_header)
 		strvec_pushf(&cmd.args, "--pack_header=%"PRIu32",%"PRIu32,
-				 ntohl(header.hdr_version),
+			     ntohl(header.hdr_version),
 				 ntohl(header.hdr_entries));
 	if (fetch_fsck_objects >= 0
 	    ? fetch_fsck_objects
@@ -901,7 +901,7 @@ static int get_pack(struct fetch_pack_args *args,
 			strvec_push(&cmd.args, "--fsck-objects");
 		else
 			strvec_pushf(&cmd.args, "--strict%s",
-					 fsck_msg_types.buf);
+				     fsck_msg_types.buf);
 	}
 
 	cmd.in = demux.out;
@@ -1654,8 +1654,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
 
 		strvec_push(&cmd.args, "http-fetch");
 		strvec_pushf(&cmd.args, "--packfile=%.*s",
-				 (int) the_hash_algo->hexsz,
-				 packfile_uris.items[i].string);
+			     (int) the_hash_algo->hexsz,
+			     packfile_uris.items[i].string);
 		strvec_push(&cmd.args, uri);
 		cmd.git_cmd = 1;
 		cmd.no_stdin = 1;
gpg-interface.c +7 -7
index cf56fe838f..b499270836 100644
@@ -285,9 +285,9 @@ static int verify_signed_buffer(const char *payload, size_t payload_size,
 	strvec_push(&gpg.args, fmt->program);
 	strvec_pushv(&gpg.args, fmt->verify_args);
 	strvec_pushl(&gpg.args,
-			 "--status-fd=1",
-			 "--verify", temp->filename.buf, "-",
-			 NULL);
+		     "--status-fd=1",
+		     "--verify", temp->filename.buf, "-",
+		     NULL);
 
 	if (!gpg_status)
 		gpg_status = &buf;
@@ -435,10 +435,10 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
 	struct strbuf gpg_status = STRBUF_INIT;
 
 	strvec_pushl(&gpg.args,
-			 use_format->program,
-			 "--status-fd=2",
-			 "-bsau", signing_key,
-			 NULL);
+		     use_format->program,
+		     "--status-fd=2",
+		     "-bsau", signing_key,
+		     NULL);
 
 	bottom = signature->len;
 
http-backend.c +1 -1
index 92fd62f73f..a03b4bae22 100644
@@ -480,7 +480,7 @@ static void run_service(const char **argv, int buffer_input)
 		strvec_pushf(&cld.env_array, "GIT_COMMITTER_NAME=%s", user);
 	if (!getenv("GIT_COMMITTER_EMAIL"))
 		strvec_pushf(&cld.env_array,
-				 "GIT_COMMITTER_EMAIL=%s@http.%s", user, host);
+			     "GIT_COMMITTER_EMAIL=%s@http.%s", user, host);
 
 	cld.argv = argv;
 	if (buffer_input || gzipped_request || req_len >= 0)
http-push.c +1 -1
index e1deea6fe4..31911aa345 100644
@@ -1929,7 +1929,7 @@ int cmd_main(int argc, const char **argv)
 		strvec_push(&commit_argv, oid_to_hex(&ref->new_oid));
 		if (!push_all && !is_null_oid(&ref->old_oid))
 			strvec_pushf(&commit_argv, "^%s",
-					 oid_to_hex(&ref->old_oid));
+				     oid_to_hex(&ref->old_oid));
 		repo_init_revisions(the_repository, &revs, setup_git_directory());
 		setup_revisions(commit_argv.argc, commit_argv.argv, &revs, NULL);
 		revs.edge_hint = 0; /* just in case */
http.c +1 -1
index 268a1e9744..8b23a546af 100644
@@ -2276,7 +2276,7 @@ int finish_http_pack_request(struct http_pack_request *preq)
 	ip.in = tmpfile_fd;
 	if (preq->generate_keep) {
 		strvec_pushf(&ip.args, "--keep=git %"PRIuMAX,
-				 (uintmax_t)getpid());
+			     (uintmax_t)getpid());
 		ip.out = 0;
 	} else {
 		ip.no_stdout = 1;
range-diff.c +14 -14
index 3a0eb70c89..831c490bf2 100644
@@ -52,20 +52,20 @@ static int read_patches(const char *range, struct string_list *list,
 	size_t size;
 
 	strvec_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
-			"--reverse", "--date-order", "--decorate=no",
-			"--no-prefix",
-			/*
-			 * Choose indicators that are not used anywhere
-			 * else in diffs, but still look reasonable
-			 * (e.g. will not be confusing when debugging)
-			 */
-			"--output-indicator-new=>",
-			"--output-indicator-old=<",
-			"--output-indicator-context=#",
-			"--no-abbrev-commit",
-			"--pretty=medium",
-			"--notes",
-			NULL);
+		     "--reverse", "--date-order", "--decorate=no",
+		     "--no-prefix",
+		     /*
+		      * Choose indicators that are not used anywhere
+		      * else in diffs, but still look reasonable
+		      * (e.g. will not be confusing when debugging)
+		      */
+		     "--output-indicator-new=>",
+		     "--output-indicator-old=<",
+		     "--output-indicator-context=#",
+		     "--no-abbrev-commit",
+		     "--pretty=medium",
+		     "--notes",
+		     NULL);
 	if (other_arg)
 		strvec_pushv(&cp.args, other_arg->argv);
 	strvec_push(&cp.args, range);
refspec.c +2 -2
index 6f317d6b44..f10ef284ce 100644
@@ -222,8 +222,8 @@ void refspec_ref_prefixes(const struct refspec *rs,
 			if (item->pattern) {
 				const char *glob = strchr(prefix, '*');
 				strvec_pushf(ref_prefixes, "%.*s",
-						 (int)(glob - prefix),
-						 prefix);
+					     (int)(glob - prefix),
+					     prefix);
 			} else {
 				expand_ref_prefix(ref_prefixes, prefix);
 			}
remote-curl.c +4 -4
index 85ce4f7e6f..7feaddc003 100644
@@ -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);
remote.c +2 -2
index 13b097866c..b4665fe5a3 100644
@@ -1914,8 +1914,8 @@ static int stat_branch_pair(const char *branch_name, const char *base,
 	strvec_push(&argv, ""); /* ignored */
 	strvec_push(&argv, "--left-right");
 	strvec_pushf(&argv, "%s...%s",
-			 oid_to_hex(&ours->object.oid),
-			 oid_to_hex(&theirs->object.oid));
+		     oid_to_hex(&ours->object.oid),
+		     oid_to_hex(&theirs->object.oid));
 	strvec_push(&argv, "--");
 
 	repo_init_revisions(the_repository, &revs, NULL);
sequencer.c +4 -4
index 80c770968a..31a2b1ab55 100644
@@ -3133,7 +3133,7 @@ static int do_exec(struct repository *r, const char *command_line)
 	child_argv[0] = command_line;
 	strvec_pushf(&child_env, "GIT_DIR=%s", absolute_path(get_git_dir()));
 	strvec_pushf(&child_env, "GIT_WORK_TREE=%s",
-			 absolute_path(get_git_work_tree()));
+		     absolute_path(get_git_work_tree()));
 	status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL,
 					  child_env.argv);
 
@@ -3552,7 +3552,7 @@ static int do_merge(struct repository *r,
 			strvec_push(&cmd.args, strategy);
 			for (k = 0; k < opts->xopts_nr; k++)
 				strvec_pushf(&cmd.args,
-						 "-X%s", opts->xopts[k]);
+					     "-X%s", opts->xopts[k]);
 		}
 		strvec_push(&cmd.args, "--no-edit");
 		strvec_push(&cmd.args, "--no-ff");
@@ -3566,7 +3566,7 @@ static int do_merge(struct repository *r,
 		/* Add the tips to be merged */
 		for (j = to_merge; j; j = j->next)
 			strvec_push(&cmd.args,
-					oid_to_hex(&j->item->object.oid));
+				    oid_to_hex(&j->item->object.oid));
 
 		strbuf_release(&ref_name);
 		unlink(git_path_cherry_pick_head(r));
@@ -3695,7 +3695,7 @@ void create_autostash(struct repository *r, const char *path,
 		struct object_id oid;
 
 		strvec_pushl(&stash.args,
-				 "stash", "create", "autostash", NULL);
+			     "stash", "create", "autostash", NULL);
 		stash.git_cmd = 1;
 		stash.no_stdin = 1;
 		strbuf_reset(&buf);
submodule.c +15 -15
index 5c9447422d..fb96d595b0 100644
@@ -495,7 +495,7 @@ void prepare_submodule_repo_env(struct strvec *out)
 {
 	prepare_submodule_repo_env_no_git_dir(out);
 	strvec_pushf(out, "%s=%s", GIT_DIR_ENVIRONMENT,
-			 DEFAULT_GIT_DIR_ENVIRONMENT);
+		     DEFAULT_GIT_DIR_ENVIRONMENT);
 }
 
 static void prepare_submodule_repo_env_in_gitdir(struct strvec *out)
@@ -687,14 +687,14 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
 
 	if (o->flags.reverse_diff) {
 		strvec_pushf(&cp.args, "--src-prefix=%s%s/",
-				 o->b_prefix, path);
+			     o->b_prefix, path);
 		strvec_pushf(&cp.args, "--dst-prefix=%s%s/",
-				 o->a_prefix, path);
+			     o->a_prefix, path);
 	} else {
 		strvec_pushf(&cp.args, "--src-prefix=%s%s/",
-				 o->a_prefix, path);
+			     o->a_prefix, path);
 		strvec_pushf(&cp.args, "--dst-prefix=%s%s/",
-				 o->b_prefix, path);
+			     o->b_prefix, path);
 	}
 	strvec_push(&cp.args, oid_to_hex(old_oid));
 	/*
@@ -1062,7 +1062,7 @@ static int push_submodule(const char *path,
 			const struct string_list_item *item;
 			for_each_string_list_item(item, push_options)
 				strvec_pushf(&cp.args, "--push-option=%s",
-						 item->string);
+					     item->string);
 		}
 
 		if (remote->origin != REMOTE_UNCONFIGURED) {
@@ -1780,7 +1780,7 @@ int bad_to_remove_submodule(const char *path, unsigned flags)
 		return 1;
 
 	strvec_pushl(&cp.args, "status", "--porcelain",
-				   "--ignore-submodules=none", NULL);
+		     "--ignore-submodules=none", NULL);
 
 	if (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED)
 		strvec_push(&cp.args, "-uno");
@@ -1847,7 +1847,7 @@ static int submodule_has_dirty_index(const struct submodule *sub)
 
 	cp.git_cmd = 1;
 	strvec_pushl(&cp.args, "diff-index", "--quiet",
-				   "--cached", "HEAD", NULL);
+		     "--cached", "HEAD", NULL);
 	cp.no_stdin = 1;
 	cp.no_stdout = 1;
 	cp.dir = sub->path;
@@ -1867,7 +1867,7 @@ static void submodule_reset_index(const char *path)
 	cp.dir = path;
 
 	strvec_pushf(&cp.args, "--super-prefix=%s%s/",
-				   get_super_prefix_or_empty(), path);
+		     get_super_prefix_or_empty(), path);
 	strvec_pushl(&cp.args, "read-tree", "-u", "--reset", NULL);
 
 	strvec_push(&cp.args, empty_tree_oid_hex());
@@ -1948,7 +1948,7 @@ int submodule_move_head(const char *path,
 	cp.dir = path;
 
 	strvec_pushf(&cp.args, "--super-prefix=%s%s/",
-			get_super_prefix_or_empty(), path);
+		     get_super_prefix_or_empty(), path);
 	strvec_pushl(&cp.args, "read-tree", "--recurse-submodules", NULL);
 
 	if (flags & SUBMODULE_MOVE_HEAD_DRY_RUN)
@@ -1981,7 +1981,7 @@ int submodule_move_head(const char *path,
 
 			prepare_submodule_repo_env(&cp.env_array);
 			strvec_pushl(&cp.args, "update-ref", "HEAD",
-					 "--no-deref", new_head, NULL);
+				     "--no-deref", new_head, NULL);
 
 			if (run_command(&cp)) {
 				ret = -1;
@@ -2158,8 +2158,8 @@ void absorb_git_dir_into_superproject(const char *path,
 		cp.git_cmd = 1;
 		cp.no_stdin = 1;
 		strvec_pushl(&cp.args, "--super-prefix", sb.buf,
-					   "submodule--helper",
-					   "absorb-git-dirs", NULL);
+			     "submodule--helper",
+			     "absorb-git-dirs", NULL);
 		prepare_submodule_repo_env(&cp.env_array);
 		if (run_command(&cp))
 			die(_("could not recurse into submodule '%s'"), path);
@@ -2197,8 +2197,8 @@ int get_superproject_working_tree(struct strbuf *buf)
 	strvec_pop(&cp.env_array);
 
 	strvec_pushl(&cp.args, "--literal-pathspecs", "-C", "..",
-			"ls-files", "-z", "--stage", "--full-name", "--",
-			subpath, NULL);
+		     "ls-files", "-z", "--stage", "--full-name", "--",
+		     subpath, NULL);
 	strbuf_reset(&sb);
 
 	cp.no_stdin = 1;
t/helper/test-run-command.c +3 -3
index 67dde56962..726835fcc2 100644
@@ -244,10 +244,10 @@ static int quote_stress_test(int argc, const char **argv)
 		strvec_clear(&args);
 		if (msys2)
 			strvec_pushl(&args, "sh", "-c",
-					 "printf %s\\\\0 \"$@\"", "skip", NULL);
+				     "printf %s\\\\0 \"$@\"", "skip", NULL);
 		else
 			strvec_pushl(&args, "test-tool", "run-command",
-					 "quote-echo", NULL);
+				     "quote-echo", NULL);
 		arg_offset = args.argc;
 
 		if (argc > 0) {
@@ -339,7 +339,7 @@ static int inherit_handle(const char *argv0)
 	tmp = xmkstemp(path);
 
 	strvec_pushl(&cp.args,
-			 "test-tool", argv0, "inherited-handle-child", NULL);
+		     "test-tool", argv0, "inherited-handle-child", NULL);
 	cp.in = -1;
 	cp.no_stdout = cp.no_stderr = 1;
 	if (start_command(&cp) < 0)
transport-helper.c +1 -1
index dcd4adf444..ae8011e9d5 100644
@@ -136,7 +136,7 @@ static struct child_process *get_helper(struct transport *transport)
 
 	if (have_git_dir())
 		strvec_pushf(&helper->env_array, "%s=%s",
-				 GIT_DIR_ENVIRONMENT, get_git_dir());
+			     GIT_DIR_ENVIRONMENT, get_git_dir());
 
 	helper->trace2_child_class = helper->args.argv[0]; /* "remote-<name>" */
 
upload-pack.c +1 -2
index 1b0e1fca1a..4a7918e04e 100644
@@ -301,8 +301,7 @@ static void create_pack_file(struct upload_pack_data *pack_data,
 			strvec_pushf(&pack_objects.args, "--filter=%s", buf.buf);
 			strbuf_release(&buf);
 		} else {
-			strvec_pushf(&pack_objects.args, "--filter=%s",
-					 spec);
+			strvec_pushf(&pack_objects.args, "--filter=%s", spec);
 		}
 	}
 	if (uri_protocols) {
wt-status.c +1 -2
index 60d4e847a5..8454662c90 100644
@@ -913,8 +913,7 @@ static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncom
 	struct strbuf summary = STRBUF_INIT;
 	char *summary_content;
 
-	strvec_pushf(&sm_summary.env_array, "GIT_INDEX_FILE=%s",
-			 s->index_file);
+	strvec_pushf(&sm_summary.env_array, "GIT_INDEX_FILE=%s", s->index_file);
 
 	strvec_push(&sm_summary.args, "submodule");
 	strvec_push(&sm_summary.args, "summary");
Signature · 1 line
2.28.0.rc2.475.g53c7e1c7f4
#9 lore raw

Re: [PATCH 08/11] strvec: fix indentation in renamed calls

Quoted 5 lines · Jeff King

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_.*,$'

I haven't seen this before. Some sort of alias that lets you open each grep spot in an editor?

#10 lore raw

Re: [PATCH 08/11] strvec: fix indentation in renamed calls

Quoted 9 lines · Jacob Keller
Quoted 5 lines · Jeff King

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_.*,$'

I haven't seen this before. Some sort of alias that lets you open each grep spot in an editor?

in contrib/

author
#11 lore raw

PATCH 9/11 strvec: update documention to avoid argv_array

In reply to Jeff King

There were a few mentions of argv_array in a non-code file which didn't get picked up in the previous commits (note that even comments in code files were already covered because of the mechanical conversion via perl).

---
 Documentation/technical/api-parse-options.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/technical/api-parse-options.txt +2 -2
index 2e2e7c10c6..5a60bbfa7f 100644
@@ -232,9 +232,9 @@ There are some macros to easily define options:
 	will be overwritten, so this should only be used for options where
 	the last one specified on the command line wins.
 
-`OPT_PASSTHRU_ARGV(short, long, &argv_array_var, arg_str, description, flags)`::
+`OPT_PASSTHRU_ARGV(short, long, &strvec_var, arg_str, description, flags)`::
 	Introduce an option where all instances of it on the command-line will
-	be reconstructed into an argv_array. This is useful when you need to
+	be reconstructed into a strvec. This is useful when you need to
 	pass the command-line option, which can be specified multiple times,
 	to another command.
 
Signature · 1 line
2.28.0.rc2.475.g53c7e1c7f4
author
#12 lore raw

PATCH 10/11 strvec: drop argv_array compatibility layer

In reply to Jeff King

There are no callers which need it anymore. Any topics in flight will need to be updated as they get merged in (but the compiler will make that quite clear).

---
 strvec.h | 13 -------------
 1 file changed, 13 deletions(-)
strvec.h +0 -13
index 4be39c8a48..bd35de1ce4 100644
@@ -86,17 +86,4 @@ void strvec_clear(struct strvec *);
  */
 const char **strvec_detach(struct strvec *);
 
-/* compatibility for historic argv_array interface */
-#define argv_array strvec
-#define ARGV_ARRAY_INIT STRVEC_INIT
-#define argv_array_init strvec_init
-#define argv_array_push strvec_push
-#define argv_array_pushf strvec_pushf
-#define argv_array_pushl strvec_pushl
-#define argv_array_pushv strvec_pushv
-#define argv_array_pop strvec_pop
-#define argv_array_split strvec_split
-#define argv_array_clear strvec_clear
-#define argv_array_detach strvec_detach
-
 #endif /* STRVEC_H */
Signature · 1 line
2.28.0.rc2.475.g53c7e1c7f4
#13 lore raw

Re: [PATCH 10/11] strvec: drop argv_array compatibility layer

Quoted 21 lines · Jeff King

There are no callers which need it anymore. Any topics in flight will need to be updated as they get merged in (but the compiler will make that quite clear).

---
 strvec.h | 13 -------------
 1 file changed, 13 deletions(-)
strvec.h +0 -4
index 4be39c8a48..bd35de1ce4 100644
@@ -86,17 +86,4 @@ void strvec_clear(struct strvec *);
  */
 const char **strvec_detach(struct strvec *);
 
-/* compatibility for historic argv_array interface */
-#define argv_array strvec
-#define ARGV_ARRAY_INIT STRVEC_INIT
-#define argv_array_init strvec_init

strvec.h void strvec_clear(struct strvec *); · line 89

Quoted 10 lines
strvec.h +0 -9
-#define argv_array_push strvec_push
-#define argv_array_pushf strvec_pushf
-#define argv_array_pushl strvec_pushl
-#define argv_array_pushv strvec_pushv
-#define argv_array_pop strvec_pop
-#define argv_array_split strvec_split
-#define argv_array_clear strvec_clear
-#define argv_array_detach strvec_detach
-
 #endif /* STRVEC_H */

It was more painful than I would have thought to merge this topic, as we seem to have gained quite a few new calling sites (it shows how popular and useful this API is). Hopefully some of the merge conflict resolutions would be resurrected automatically from the rerere database ;-)

author
#14 lore raw

Re: [PATCH 10/11] strvec: drop argv_array compatibility layer

Quoted 5 lines · Junio C Hamano

It was more painful than I would have thought to merge this topic, as we seem to have gained quite a few new calling sites (it shows how popular and useful this API is). Hopefully some of the merge conflict resolutions would be resurrected automatically from the rerere database ;-)

I'm not too surprised; it made a little chaos with my personal topics, too. I'm happy to help with resolutions, but it looks like you've already merged it to "seen", which means the worst of it is mostly over.

I did specifically wait on it until until after a release, but I think we pretty much always have topics in flight these days. There is no quiet time. :)

If I swap out the final patch with "s/items/v/" that may cause a _little_ more trouble, but perhaps not quite as much (only some of the sites access the fields directly).

-Peff

author
#15 lore raw

Re: [PATCH 10/11] strvec: drop argv_array compatibility layer

Quoted 11 lines · Jeff King
Quoted 5 lines · Junio C Hamano

It was more painful than I would have thought to merge this topic, as we seem to have gained quite a few new calling sites (it shows how popular and useful this API is). Hopefully some of the merge conflict resolutions would be resurrected automatically from the rerere database ;-)

I'm not too surprised; it made a little chaos with my personal topics, too. I'm happy to help with resolutions, but it looks like you've already merged it to "seen", which means the worst of it is mostly over.

Worse than the resolutions are all the new calls which needed to be fixed up. I know your scripts keep a fix-up commit for this, but I don't think you publish it. :) I repeated the process as a cross-check and got a byte-for-byte identical result to what you have at the tip of "seen".

Quoted 3 lines

If I swap out the final patch with "s/items/v/" that may cause a _little_ more trouble, but perhaps not quite as much (only some of the sites access the fields directly).

Here's the "v" version, which can replace the top patch. I'll follow-up with some notes on merging to "seen".

-- >8 --
Subject: [PATCH] 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.

---
 add-interactive.c           |  4 ++--
 add-patch.c                 |  8 +++----
 bisect.c                    |  2 +-
 builtin/add.c               |  2 +-
 builtin/am.c                | 16 +++++++-------
 builtin/annotate.c          |  2 +-
 builtin/bisect--helper.c    |  4 ++--
 builtin/clone.c             |  4 ++--
 builtin/commit.c            |  2 +-
 builtin/describe.c          |  6 ++---
 builtin/difftool.c          |  2 +-
 builtin/fetch.c             |  6 ++---
 builtin/gc.c                | 24 ++++++++++----------
 builtin/pack-objects.c      |  2 +-
 builtin/pull.c              | 16 +++++++-------
 builtin/rebase.c            | 16 +++++++-------
 builtin/receive-pack.c      | 14 ++++++------
 builtin/remote.c            |  4 ++--
 builtin/replace.c           |  2 +-
 builtin/show-branch.c       |  8 +++----
 builtin/stash.c             |  8 +++----
 builtin/submodule--helper.c |  6 ++---
 builtin/upload-archive.c    |  4 ++--
 builtin/worktree.c          |  6 ++---
 bundle.c                    |  2 +-
 commit.c                    |  2 +-
 connect.c                   | 16 +++++++-------
 daemon.c                    |  8 +++----
 diff.c                      |  2 +-
 environment.c               |  2 +-
 exec-cmd.c                  |  6 ++---
 git.c                       | 10 ++++-----
 graph.c                     |  4 ++--
 http-push.c                 |  2 +-
 ls-refs.c                   |  6 ++---
 merge.c                     |  2 +-
 pathspec.c                  |  2 +-
 range-diff.c                |  2 +-
 ref-filter.c                |  4 ++--
 remote-curl.c               |  6 ++---
 remote.c                    |  2 +-
 revision.c                  |  4 ++--
 run-command.c               | 20 ++++++++---------
 sequencer.c                 |  4 ++--
 serve.c                     |  6 ++---
 strvec.c                    | 44 ++++++++++++++++++-------------------
 strvec.h                    | 20 ++++++++---------
 submodule.c                 | 14 ++++++------
 t/helper/test-run-command.c |  8 +++----
 tmp-objdir.c                |  2 +-
 transport-helper.c          |  2 +-
 upload-pack.c               |  2 +-
 52 files changed, 186 insertions(+), 186 deletions(-)
add-interactive.c +2 -2
index 458f3a3e69..555c4abf32 100644
@@ -944,7 +944,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps,
 					    files->items.items[i].string);
 		parse_pathspec(&ps_selected,
 			       PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
-			       PATHSPEC_LITERAL_PATH, "", args.argv);
+			       PATHSPEC_LITERAL_PATH, "", args.v);
 		res = run_add_p(s->r, ADD_P_ADD, NULL, &ps_selected);
 		strvec_clear(&args);
 		clear_pathspec(&ps_selected);
@@ -986,7 +986,7 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
 			if (files->selected[i])
 				strvec_push(&args,
 					    files->items.items[i].string);
-		res = run_command_v_opt(args.argv, 0);
+		res = run_command_v_opt(args.v, 0);
 		strvec_clear(&args);
 	}
 
add-patch.c +4 -4
index 8c0772803b..0f68eb665e 100644
@@ -391,14 +391,14 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 			    get_oid("HEAD", &oid) ?
 			    empty_tree_oid_hex() : s->revision);
 	}
-	color_arg_index = args.argc;
+	color_arg_index = args.nr;
 	/* Use `--no-color` explicitly, just in case `diff.color = always`. */
 	strvec_pushl(&args, "--no-color", "-p", "--", NULL);
 	for (i = 0; i < ps->nr; i++)
 		strvec_push(&args, ps->items[i].original);
 
 	setup_child_process(s, &cp, NULL);
-	cp.argv = args.argv;
+	cp.argv = args.v;
 	res = capture_command(&cp, plain, 0);
 	if (res) {
 		strvec_clear(&args);
@@ -415,8 +415,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 		const char *diff_filter = s->s.interactive_diff_filter;
 
 		setup_child_process(s, &colored_cp, NULL);
-		xsnprintf((char *)args.argv[color_arg_index], 8, "--color");
-		colored_cp.argv = args.argv;
+		xsnprintf((char *)args.v[color_arg_index], 8, "--color");
+		colored_cp.argv = args.v;
 		colored = &s->colored;
 		res = capture_command(&colored_cp, colored, 0);
 		strvec_clear(&args);
bisect.c +1 -1
index 99ff694960..6959fb8aad 100644
@@ -649,7 +649,7 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs,
 	if (read_paths)
 		read_bisect_paths(&rev_argv);
 
-	setup_revisions(rev_argv.argc, rev_argv.argv, revs, NULL);
+	setup_revisions(rev_argv.nr, rev_argv.v, revs, NULL);
 	/* XXX leak rev_argv, as "revs" may still be pointing to it */
 }
 
builtin/add.c +1 -1
index 6185dd12a8..ab39a60a0d 100644
@@ -228,7 +228,7 @@ int run_add_interactive(const char *revision, const char *patch_mode,
 		/* pass original pathspec, to be re-parsed */
 		strvec_push(&argv, pathspec->items[i].original);
 
-	status = run_command_v_opt(argv.argv, RUN_GIT_CMD);
+	status = run_command_v_opt(argv.v, RUN_GIT_CMD);
 	strvec_clear(&argv);
 	return status;
 }
builtin/am.c +8 -8
index 992ab3ca27..dd4e6c2d9b 100644
@@ -812,7 +812,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
 	strbuf_release(&sb);
 	free(series_dir_buf);
 
-	ret = split_mail_conv(stgit_patch_to_mail, state, patches.argv, keep_cr);
+	ret = split_mail_conv(stgit_patch_to_mail, state, patches.v, keep_cr);
 
 	strvec_clear(&patches);
 	return ret;
@@ -1002,7 +1002,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
 	}
 	write_state_text(state, "scissors", str);
 
-	sq_quote_argv(&sb, state->git_apply_opts.argv);
+	sq_quote_argv(&sb, state->git_apply_opts.v);
 	write_state_text(state, "apply-opt", sb.buf);
 
 	if (state->rebasing)
@@ -1401,9 +1401,9 @@ static int run_apply(const struct am_state *state, const char *index_file)
 		BUG("init_apply_state() failed");
 
 	strvec_push(&apply_opts, "apply");
-	strvec_pushv(&apply_opts, state->git_apply_opts.argv);
+	strvec_pushv(&apply_opts, state->git_apply_opts.v);
 
-	opts_left = apply_parse_options(apply_opts.argc, apply_opts.argv,
+	opts_left = apply_parse_options(apply_opts.nr, apply_opts.v,
 					&apply_state, &force_apply, &options,
 					NULL);
 
@@ -1428,7 +1428,7 @@ static int run_apply(const struct am_state *state, const char *index_file)
 
 	strvec_push(&apply_paths, am_path(state, "patch"));
 
-	res = apply_all_patches(&apply_state, apply_paths.argc, apply_paths.argv, options);
+	res = apply_all_patches(&apply_state, apply_paths.nr, apply_paths.v, options);
 
 	strvec_clear(&apply_paths);
 	strvec_clear(&apply_opts);
@@ -1455,7 +1455,7 @@ static int build_fake_ancestor(const struct am_state *state, const char *index_f
 
 	cp.git_cmd = 1;
 	strvec_push(&cp.args, "apply");
-	strvec_pushv(&cp.args, state->git_apply_opts.argv);
+	strvec_pushv(&cp.args, state->git_apply_opts.v);
 	strvec_pushf(&cp.args, "--build-fake-ancestor=%s", index_file);
 	strvec_push(&cp.args, am_path(state, "patch"));
 
@@ -2376,10 +2376,10 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 				strvec_push(&paths, mkpath("%s/%s", prefix, argv[i]));
 		}
 
-		if (state.interactive && !paths.argc)
+		if (state.interactive && !paths.nr)
 			die(_("interactive mode requires patches on the command line"));
 
-		am_setup(&state, patch_format, paths.argv, keep_cr);
+		am_setup(&state, patch_format, paths.v, keep_cr);
 
 		strvec_clear(&paths);
 	}
builtin/annotate.c +1 -1
index 7b7ecd366d..58ff977a23 100644
@@ -18,5 +18,5 @@ int cmd_annotate(int argc, const char **argv, const char *prefix)
 		strvec_push(&args, argv[i]);
 	}
 
-	return cmd_blame(args.argc, args.argv, prefix);
+	return cmd_blame(args.nr, args.v, prefix);
 }
builtin/bisect--helper.c +2 -2
index dd52878413..b46de0489e 100644
@@ -168,7 +168,7 @@ static int bisect_reset(const char *commit)
 		struct strvec argv = STRVEC_INIT;
 
 		strvec_pushl(&argv, "checkout", branch.buf, "--", NULL);
-		if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
+		if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
 			error(_("could not check out original"
 				" HEAD '%s'. Try 'git bisect"
 				" reset <commit>'."), branch.buf);
@@ -530,7 +530,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
 
 			strvec_pushl(&argv, "checkout", start_head.buf,
 				     "--", NULL);
-			if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
+			if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
 				res = error(_("checking out '%s' failed."
 						 " Try 'git bisect start "
 						 "<valid-branch>'."),
builtin/clone.c +2 -2
index e26bd82dc4..fccc814a54 100644
@@ -752,7 +752,7 @@ static int git_sparse_checkout_init(const char *repo)
 	 */
 	core_apply_sparse_checkout = 1;
 
-	if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
+	if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
 		error(_("failed to initialize sparse-checkout"));
 		result = 1;
 	}
@@ -844,7 +844,7 @@ static int checkout(int submodule_progress)
 					       "--single-branch" :
 					       "--no-single-branch");
 
-		err = run_command_v_opt(args.argv, RUN_GIT_CMD);
+		err = run_command_v_opt(args.v, RUN_GIT_CMD);
 		strvec_clear(&args);
 	}
 
builtin/commit.c +1 -1
index c3f4067537..69ac78d5e5 100644
@@ -1008,7 +1008,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		struct strvec env = STRVEC_INIT;
 
 		strvec_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
-		if (launch_editor(git_path_commit_editmsg(), NULL, env.argv)) {
+		if (launch_editor(git_path_commit_editmsg(), NULL, env.v)) {
 			fprintf(stderr,
 			_("Please supply the message using either -m or -F option.\n"));
 			exit(1);
builtin/describe.c +3 -3
index e3cac8002c..7668591d57 100644
@@ -509,7 +509,7 @@ static void describe_blob(struct object_id oid, struct strbuf *dst)
 		     NULL);
 
 	repo_init_revisions(the_repository, &revs, NULL);
-	if (setup_revisions(args.argc, args.argv, &revs, NULL) > 1)
+	if (setup_revisions(args.nr, args.v, &revs, NULL) > 1)
 		BUG("setup_revisions could not handle all args?");
 
 	if (prepare_revision_walk(&revs))
@@ -613,7 +613,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 			strvec_pushv(&args, argv);
 		else
 			strvec_push(&args, "HEAD");
-		return cmd_name_rev(args.argc, args.argv, prefix);
+		return cmd_name_rev(args.nr, args.v, prefix);
 	}
 
 	hashmap_init(&names, commit_name_neq, NULL, 0);
@@ -659,7 +659,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 
 			repo_init_revisions(the_repository, &revs, prefix);
 			strvec_pushv(&args, diff_index_args);
-			if (setup_revisions(args.argc, args.argv, &revs, NULL) != 1)
+			if (setup_revisions(args.nr, args.v, &revs, NULL) != 1)
 				BUG("malformed internal diff-index command line");
 			result = run_diff_index(&revs, 0);
 
builtin/difftool.c +1 -1
index 5ac021a1d4..7ac432b881 100644
@@ -683,7 +683,7 @@ static int run_file_diff(int prompt, const char *prefix,
 	strvec_push(&args, "diff");
 	for (i = 0; i < argc; i++)
 		strvec_push(&args, argv[i]);
-	ret = run_command_v_opt_cd_env(args.argv, RUN_GIT_CMD, prefix, env);
+	ret = run_command_v_opt_cd_env(args.v, RUN_GIT_CMD, prefix, env);
 	exit(ret);
 }
 
builtin/fetch.c +3 -3
index c2e7afeb6a..c49f0e9752 100644
@@ -1354,7 +1354,7 @@ static int do_fetch(struct transport *transport,
 
 	if (tags == TAGS_SET || tags == TAGS_DEFAULT) {
 		must_list_refs = 1;
-		if (ref_prefixes.argc)
+		if (ref_prefixes.nr)
 			strvec_push(&ref_prefixes, "refs/tags/");
 	}
 
@@ -1605,7 +1605,7 @@ static int fetch_multiple(struct string_list *list, int max_children)
 	add_options_to_argv(&argv);
 
 	if (max_children != 1 && list->nr != 1) {
-		struct parallel_fetch_state state = { argv.argv, list, 0, 0 };
+		struct parallel_fetch_state state = { argv.v, list, 0, 0 };
 
 		strvec_push(&argv, "--end-of-options");
 		result = run_processes_parallel_tr2(max_children,
@@ -1623,7 +1623,7 @@ static int fetch_multiple(struct string_list *list, int max_children)
 			strvec_push(&argv, name);
 			if (verbosity >= 0)
 				printf(_("Fetching %s\n"), name);
-			if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
+			if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
 				error(_("Could not fetch %s"), name);
 				result = 1;
 			}
builtin/gc.c +12 -12
index 98719800a3..aafa0946f5 100644
@@ -514,11 +514,11 @@ static void gc_before_repack(void)
 	if (done++)
 		return;
 
-	if (pack_refs && run_command_v_opt(pack_refs_cmd.argv, RUN_GIT_CMD))
-		die(FAILED_RUN, pack_refs_cmd.argv[0]);
+	if (pack_refs && run_command_v_opt(pack_refs_cmd.v, RUN_GIT_CMD))
+		die(FAILED_RUN, pack_refs_cmd.v[0]);
 
-	if (prune_reflogs && run_command_v_opt(reflog.argv, RUN_GIT_CMD))
-		die(FAILED_RUN, reflog.argv[0]);
+	if (prune_reflogs && run_command_v_opt(reflog.v, RUN_GIT_CMD))
+		die(FAILED_RUN, reflog.v[0]);
 }
 
 int cmd_gc(int argc, const char **argv, const char *prefix)
@@ -653,8 +653,8 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
 
 	if (!repository_format_precious_objects) {
 		close_object_store(the_repository->objects);
-		if (run_command_v_opt(repack.argv, RUN_GIT_CMD))
-			die(FAILED_RUN, repack.argv[0]);
+		if (run_command_v_opt(repack.v, RUN_GIT_CMD))
+			die(FAILED_RUN, repack.v[0]);
 
 		if (prune_expire) {
 			strvec_push(&prune, prune_expire);
@@ -663,19 +663,19 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
 			if (has_promisor_remote())
 				strvec_push(&prune,
 					    "--exclude-promisor-objects");
-			if (run_command_v_opt(prune.argv, RUN_GIT_CMD))
-				die(FAILED_RUN, prune.argv[0]);
+			if (run_command_v_opt(prune.v, RUN_GIT_CMD))
+				die(FAILED_RUN, prune.v[0]);
 		}
 	}
 
 	if (prune_worktrees_expire) {
 		strvec_push(&prune_worktrees, prune_worktrees_expire);
-		if (run_command_v_opt(prune_worktrees.argv, RUN_GIT_CMD))
-			die(FAILED_RUN, prune_worktrees.argv[0]);
+		if (run_command_v_opt(prune_worktrees.v, RUN_GIT_CMD))
+			die(FAILED_RUN, prune_worktrees.v[0]);
 	}
 
-	if (run_command_v_opt(rerere.argv, RUN_GIT_CMD))
-		die(FAILED_RUN, rerere.argv[0]);
+	if (run_command_v_opt(rerere.v, RUN_GIT_CMD))
+		die(FAILED_RUN, rerere.v[0]);
 
 	report_garbage = report_pack_garbage;
 	reprepare_packed_git(the_repository);
builtin/pack-objects.c +1 -1
index 323f8bce80..f00ae80796 100644
@@ -3704,7 +3704,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 	if (!use_internal_rev_list)
 		read_object_list_from_stdin();
 	else {
-		get_object_list(rp.argc, rp.argv);
+		get_object_list(rp.nr, rp.v);
 		strvec_clear(&rp);
 	}
 	cleanup_preferred_base();
builtin/pull.c +8 -8
index dae8766646..015f6ded0b 100644
@@ -584,14 +584,14 @@ static int run_fetch(const char *repo, const char **refspecs)
 		strvec_push(&args, "--no-show-forced-updates");
 	if (set_upstream)
 		strvec_push(&args, set_upstream);
-	strvec_pushv(&args, opt_fetch.argv);
+	strvec_pushv(&args, opt_fetch.v);
 
 	if (repo) {
 		strvec_push(&args, repo);
 		strvec_pushv(&args, refspecs);
 	} else if (*refspecs)
 		BUG("refspecs without repo?");
-	ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
+	ret = run_command_v_opt(args.v, RUN_GIT_CMD);
 	strvec_clear(&args);
 	return ret;
 }
@@ -691,8 +691,8 @@ static int run_merge(void)
 		strvec_push(&args, opt_ff);
 	if (opt_verify_signatures)
 		strvec_push(&args, opt_verify_signatures);
-	strvec_pushv(&args, opt_strategies.argv);
-	strvec_pushv(&args, opt_strategy_opts.argv);
+	strvec_pushv(&args, opt_strategies.v);
+	strvec_pushv(&args, opt_strategy_opts.v);
 	if (opt_gpg_sign)
 		strvec_push(&args, opt_gpg_sign);
 	if (opt_autostash == 0)
@@ -703,7 +703,7 @@ static int run_merge(void)
 		strvec_push(&args, "--allow-unrelated-histories");
 
 	strvec_push(&args, "FETCH_HEAD");
-	ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
+	ret = run_command_v_opt(args.v, RUN_GIT_CMD);
 	strvec_clear(&args);
 	return ret;
 }
@@ -882,8 +882,8 @@ static int run_rebase(const struct object_id *curr_head,
 		strvec_push(&args, "--interactive");
 	if (opt_diffstat)
 		strvec_push(&args, opt_diffstat);
-	strvec_pushv(&args, opt_strategies.argv);
-	strvec_pushv(&args, opt_strategy_opts.argv);
+	strvec_pushv(&args, opt_strategies.v);
+	strvec_pushv(&args, opt_strategy_opts.v);
 	if (opt_gpg_sign)
 		strvec_push(&args, opt_gpg_sign);
 	if (opt_autostash == 0)
@@ -902,7 +902,7 @@ static int run_rebase(const struct object_id *curr_head,
 	else
 		strvec_push(&args, oid_to_hex(merge_head));
 
-	ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
+	ret = run_command_v_opt(args.v, RUN_GIT_CMD);
 	strvec_clear(&args);
 	return ret;
 }
builtin/rebase.c +8 -8
index 35aeb8effc..dadb52fa92 100644
@@ -351,7 +351,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
 			     oid_to_hex(&opts->restrict_revision->object.oid));
 
 	ret = sequencer_make_script(the_repository, &todo_list.buf,
-				    make_script_args.argc, make_script_args.argv,
+				    make_script_args.nr, make_script_args.v,
 				    flags);
 
 	if (ret)
@@ -900,7 +900,7 @@ static int run_am(struct rebase_options *opts)
 		return status;
 	}
 
-	strvec_pushv(&am.args, opts->git_am_opts.argv);
+	strvec_pushv(&am.args, opts->git_am_opts.v);
 	strvec_push(&am.args, "--rebasing");
 	strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
 	strvec_push(&am.args, "--patch-format=mboxrd");
@@ -969,7 +969,7 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action)
 	add_var(&script_snippet, "revisions", opts->revisions);
 	add_var(&script_snippet, "restrict_revision", opts->restrict_revision ?
 		oid_to_hex(&opts->restrict_revision->object.oid) : NULL);
-	sq_quote_argv_pretty(&buf, opts->git_am_opts.argv);
+	sq_quote_argv_pretty(&buf, opts->git_am_opts.v);
 	add_var(&script_snippet, "git_am_opt", buf.buf);
 	strbuf_release(&buf);
 	add_var(&script_snippet, "verbose",
@@ -1625,8 +1625,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		allow_preemptive_ff = 0;
 	}
 
-	for (i = 0; i < options.git_am_opts.argc; i++) {
-		const char *option = options.git_am_opts.argv[i], *p;
+	for (i = 0; i < options.git_am_opts.nr; i++) {
+		const char *option = options.git_am_opts.v[i], *p;
 		if (!strcmp(option, "--committer-date-is-author-date") ||
 		    !strcmp(option, "--ignore-date") ||
 		    !strcmp(option, "--whitespace=fix") ||
@@ -1721,10 +1721,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	if (isatty(2) && options.flags & REBASE_NO_QUIET)
 		strbuf_addstr(&options.git_format_patch_opt, " --progress");
 
-	if (options.git_am_opts.argc || options.type == REBASE_APPLY) {
+	if (options.git_am_opts.nr || options.type == REBASE_APPLY) {
 		/* all am options except -q are compatible only with --apply */
-		for (i = options.git_am_opts.argc - 1; i >= 0; i--)
-			if (strcmp(options.git_am_opts.argv[i], "-q"))
+		for (i = options.git_am_opts.nr - 1; i >= 0; i--)
+			if (strcmp(options.git_am_opts.v[i], "-q"))
 				break;
 
 		if (i >= 0) {
builtin/receive-pack.c +7 -7
index 1fc69cf5bc..439f29d6c7 100644
@@ -950,7 +950,7 @@ static const char *push_to_deploy(unsigned char *sha1,
 	struct child_process child = CHILD_PROCESS_INIT;
 
 	child.argv = update_refresh;
-	child.env = env->argv;
+	child.env = env->v;
 	child.dir = work_tree;
 	child.no_stdin = 1;
 	child.stdout_to_stderr = 1;
@@ -961,7 +961,7 @@ static const char *push_to_deploy(unsigned char *sha1,
 	/* run_command() does not clean up completely; reinitialize */
 	child_process_init(&child);
 	child.argv = diff_files;
-	child.env = env->argv;
+	child.env = env->v;
 	child.dir = work_tree;
 	child.no_stdin = 1;
 	child.stdout_to_stderr = 1;
@@ -974,7 +974,7 @@ static const char *push_to_deploy(unsigned char *sha1,
 
 	child_process_init(&child);
 	child.argv = diff_index;
-	child.env = env->argv;
+	child.env = env->v;
 	child.no_stdin = 1;
 	child.no_stdout = 1;
 	child.stdout_to_stderr = 0;
@@ -985,7 +985,7 @@ static const char *push_to_deploy(unsigned char *sha1,
 	read_tree[3] = hash_to_hex(sha1);
 	child_process_init(&child);
 	child.argv = read_tree;
-	child.env = env->argv;
+	child.env = env->v;
 	child.dir = work_tree;
 	child.no_stdin = 1;
 	child.no_stdout = 1;
@@ -1004,7 +1004,7 @@ static const char *push_to_checkout(unsigned char *hash,
 				    const char *work_tree)
 {
 	strvec_pushf(env, "GIT_WORK_TREE=%s", absolute_path(work_tree));
-	if (run_hook_le(env->argv, push_to_checkout_hook,
+	if (run_hook_le(env->v, push_to_checkout_hook,
 			hash_to_hex(hash), NULL))
 		return "push-to-checkout hook declined";
 	else
@@ -1205,11 +1205,11 @@ static void run_update_post_hook(struct command *commands)
 	for (cmd = commands; cmd; cmd = cmd->next) {
 		if (cmd->error_string || cmd->did_not_exist)
 			continue;
-		if (!proc.args.argc)
+		if (!proc.args.nr)
 			strvec_push(&proc.args, hook);
 		strvec_push(&proc.args, cmd->ref_name);
 	}
-	if (!proc.args.argc)
+	if (!proc.args.nr)
 		return;
 
 	proc.no_stdin = 1;
builtin/remote.c +2 -2
index a3b33c2c88..c8240e9fcd 100644
@@ -1470,15 +1470,15 @@ static int update(int argc, const char **argv)
 	for (i = 1; i < argc; i++)
 		strvec_push(&fetch_argv, argv[i]);
 
-	if (strcmp(fetch_argv.argv[fetch_argv.argc-1], "default") == 0) {
+	if (strcmp(fetch_argv.v[fetch_argv.nr-1], "default") == 0) {
 		git_config(get_remote_default, &default_defined);
 		if (!default_defined) {
 			strvec_pop(&fetch_argv);
 			strvec_push(&fetch_argv, "--all");
 		}
 	}
 
-	retval = run_command_v_opt(fetch_argv.argv, RUN_GIT_CMD);
+	retval = run_command_v_opt(fetch_argv.v, RUN_GIT_CMD);
 	strvec_clear(&fetch_argv);
 	return retval;
 }
builtin/replace.c +1 -1
index 7bc5d66ed9..cd48765911 100644
@@ -513,7 +513,7 @@ static int convert_graft_file(int force)
 			continue;
 
 		strvec_split(&args, buf.buf);
-		if (args.argc && create_graft(args.argc, args.argv, force, 1))
+		if (args.nr && create_graft(args.nr, args.v, force, 1))
 			strbuf_addf(&err, "\n\t%s", buf.buf);
 		strvec_clear(&args);
 	}
builtin/show-branch.c +4 -4
index 4c918ce90d..7eae5f3801 100644
@@ -561,7 +561,7 @@ static int git_show_branch_config(const char *var, const char *value, void *cb)
 		 * default_arg is now passed to parse_options(), so we need to
 		 * mimic the real argv a bit better.
 		 */
-		if (!default_args.argc)
+		if (!default_args.nr)
 			strvec_push(&default_args, "show-branch");
 		strvec_push(&default_args, value);
 		return 0;
@@ -684,9 +684,9 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 	git_config(git_show_branch_config, NULL);
 
 	/* If nothing is specified, try the default first */
-	if (ac == 1 && default_args.argc) {
-		ac = default_args.argc;
-		av = default_args.argv;
+	if (ac == 1 && default_args.nr) {
+		ac = default_args.nr;
+		av = default_args.v;
 	}
 
 	ac = parse_options(ac, av, prefix, builtin_show_branch_options,
builtin/stash.c +4 -4
index bfdbafae89..10d87630cd 100644
@@ -745,7 +745,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
 			strvec_push(&revision_args, argv[i]);
 	}
 
-	ret = get_stash_info(&info, stash_args.argc, stash_args.argv);
+	ret = get_stash_info(&info, stash_args.nr, stash_args.v);
 	strvec_clear(&stash_args);
 	if (ret)
 		return -1;
@@ -754,7 +754,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
 	 * The config settings are applied only if there are not passed
 	 * any options.
 	 */
-	if (revision_args.argc == 1) {
+	if (revision_args.nr == 1) {
 		if (show_stat)
 			rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT;
 
@@ -767,7 +767,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
 		}
 	}
 
-	argc = setup_revisions(revision_args.argc, revision_args.argv, &rev, NULL);
+	argc = setup_revisions(revision_args.nr, revision_args.v, &rev, NULL);
 	if (argc > 1) {
 		free_stash_info(&info);
 		usage_with_options(git_stash_show_usage, options);
@@ -1611,5 +1611,5 @@ int cmd_stash(int argc, const char **argv, const char *prefix)
 	/* Assume 'stash push' */
 	strvec_push(&args, "push");
 	strvec_pushv(&args, argv);
-	return !!push_stash(args.argc, args.argv, prefix, 1);
+	return !!push_stash(args.nr, args.v, prefix, 1);
 }
builtin/submodule--helper.c +3 -3
index 665db1ffed..df135abbf1 100644
@@ -817,9 +817,9 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
 
 	repo_init_revisions(the_repository, &rev, NULL);
 	rev.abbrev = 0;
-	diff_files_args.argc = setup_revisions(diff_files_args.argc,
-					       diff_files_args.argv,
-					       &rev, NULL);
+	diff_files_args.nr = setup_revisions(diff_files_args.nr,
+					     diff_files_args.v,
+					     &rev, NULL);
 	diff_files_result = run_diff_files(&rev, 0);
 
 	if (!diff_result_code(&rev.diffopt, diff_files_result)) {
builtin/upload-archive.c +2 -2
index f02bb0ea15..24654b4c9b 100644
@@ -36,7 +36,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
 		char *buf = packet_read_line(0, NULL);
 		if (!buf)
 			break;	/* got a flush */
-		if (sent_argv.argc > MAX_ARGS)
+		if (sent_argv.nr > MAX_ARGS)
 			die("Too many options (>%d)", MAX_ARGS - 1);
 
 		if (!starts_with(buf, arg_cmd))
@@ -45,7 +45,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
 	}
 
 	/* parse all options sent by the client */
-	return write_archive(sent_argv.argc, sent_argv.argv, prefix,
+	return write_archive(sent_argv.nr, sent_argv.v, prefix,
 			     the_repository, NULL, 1);
 }
 
builtin/worktree.c +3 -3
index be5d84f0a0..378f332b5d 100644
@@ -422,7 +422,7 @@ static int add_worktree(const char *path, const char *refname,
 			strvec_push(&cp.args, "--quiet");
 	}
 
-	cp.env = child_env.argv;
+	cp.env = child_env.v;
 	ret = run_command(&cp);
 	if (ret)
 		goto done;
@@ -433,7 +433,7 @@ static int add_worktree(const char *path, const char *refname,
 		strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
 		if (opts->quiet)
 			strvec_push(&cp.args, "--quiet");
-		cp.env = child_env.argv;
+		cp.env = child_env.v;
 		ret = run_command(&cp);
 		if (ret)
 			goto done;
@@ -943,7 +943,7 @@ static void check_clean_worktree(struct worktree *wt,
 	strvec_pushl(&cp.args, "status",
 		     "--porcelain", "--ignore-submodules=none",
 		     NULL);
-	cp.env = child_env.argv;
+	cp.env = child_env.v;
 	cp.git_cmd = 1;
 	cp.dir = wt->path;
 	cp.out = -1;
bundle.c +1 -1
index 565d05367f..7ef9c3a7c3 100644
@@ -278,7 +278,7 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *
 		     "pack-objects",
 		     "--stdout", "--thin", "--delta-base-offset",
 		     NULL);
-	strvec_pushv(&pack_objects.args, pack_options->argv);
+	strvec_pushv(&pack_objects.args, pack_options->v);
 	pack_objects.in = -1;
 	pack_objects.out = bundle_fd;
 	pack_objects.git_cmd = 1;
commit.c +1 -1
index a5176a25bd..4ce8cb38d5 100644
@@ -1643,7 +1643,7 @@ int run_commit_hook(int editor_is_used, const char *index_file,
 		strvec_push(&hook_env, "GIT_EDITOR=:");
 
 	va_start(args, name);
-	ret = run_hook_ve(hook_env.argv,name, args);
+	ret = run_hook_ve(hook_env.v, name, args);
 	va_end(args);
 	strvec_clear(&hook_env);
 
connect.c +8 -8
index 3299ea956a..0b6aba177e 100644
@@ -70,9 +70,9 @@ int server_supports_v2(const char *c, int die_on_error)
 {
 	int i;
 
-	for (i = 0; i < server_capabilities_v2.argc; i++) {
+	for (i = 0; i < server_capabilities_v2.nr; i++) {
 		const char *out;
-		if (skip_prefix(server_capabilities_v2.argv[i], c, &out) &&
+		if (skip_prefix(server_capabilities_v2.v[i], c, &out) &&
 		    (!*out || *out == '='))
 			return 1;
 	}
@@ -87,9 +87,9 @@ int server_feature_v2(const char *c, const char **v)
 {
 	int i;
 
-	for (i = 0; i < server_capabilities_v2.argc; i++) {
+	for (i = 0; i < server_capabilities_v2.nr; i++) {
 		const char *out;
-		if (skip_prefix(server_capabilities_v2.argv[i], c, &out) &&
+		if (skip_prefix(server_capabilities_v2.v[i], c, &out) &&
 		    (*out == '=')) {
 			*v = out + 1;
 			return 1;
@@ -103,9 +103,9 @@ int server_supports_feature(const char *c, const char *feature,
 {
 	int i;
 
-	for (i = 0; i < server_capabilities_v2.argc; i++) {
+	for (i = 0; i < server_capabilities_v2.nr; i++) {
 		const char *out;
-		if (skip_prefix(server_capabilities_v2.argv[i], c, &out) &&
+		if (skip_prefix(server_capabilities_v2.v[i], c, &out) &&
 		    (!*out || *(out++) == '=')) {
 			if (parse_feature_request(out, feature))
 				return 1;
@@ -488,9 +488,9 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
 	if (!for_push)
 		packet_write_fmt(fd_out, "peel\n");
 	packet_write_fmt(fd_out, "symrefs\n");
-	for (i = 0; ref_prefixes && i < ref_prefixes->argc; i++) {
+	for (i = 0; ref_prefixes && i < ref_prefixes->nr; i++) {
 		packet_write_fmt(fd_out, "ref-prefix %s\n",
-				 ref_prefixes->argv[i]);
+				 ref_prefixes->v[i]);
 	}
 	packet_flush(fd_out);
 
daemon.c +4 -4
index 0dec89fa02..2ab7ea82eb 100644
@@ -482,7 +482,7 @@ static int upload_pack(const struct strvec *env)
 	strvec_pushl(&cld.args, "upload-pack", "--strict", NULL);
 	strvec_pushf(&cld.args, "--timeout=%u", timeout);
 
-	strvec_pushv(&cld.env_array, env->argv);
+	strvec_pushv(&cld.env_array, env->v);
 
 	return run_service_command(&cld);
 }
@@ -492,7 +492,7 @@ static int upload_archive(const struct strvec *env)
 	struct child_process cld = CHILD_PROCESS_INIT;
 	strvec_push(&cld.args, "upload-archive");
 
-	strvec_pushv(&cld.env_array, env->argv);
+	strvec_pushv(&cld.env_array, env->v);
 
 	return run_service_command(&cld);
 }
@@ -502,7 +502,7 @@ static int receive_pack(const struct strvec *env)
 	struct child_process cld = CHILD_PROCESS_INIT;
 	strvec_push(&cld.args, "receive-pack");
 
-	strvec_pushv(&cld.env_array, env->argv);
+	strvec_pushv(&cld.env_array, env->v);
 
 	return run_service_command(&cld);
 }
@@ -927,7 +927,7 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
 #endif
 	}
 
-	cld.argv = cld_argv.argv;
+	cld.argv = cld_argv.v;
 	cld.in = incoming;
 	cld.out = dup(incoming);
 
diff.c +1 -1
index f1a3758922..f9709de7b4 100644
@@ -4239,7 +4239,7 @@ static void run_external_diff(const char *pgm,
 
 	diff_free_filespec_data(one);
 	diff_free_filespec_data(two);
-	if (run_command_v_opt_cd_env(argv.argv, RUN_USING_SHELL, NULL, env.argv))
+	if (run_command_v_opt_cd_env(argv.v, RUN_USING_SHELL, NULL, env.v))
 		die(_("external diff died, stopping at %s"), name);
 
 	remove_tempfile();
environment.c +1 -1
index 00fe20e496..52e0c979ba 100644
@@ -164,7 +164,7 @@ static const char *getenv_safe(struct strvec *argv, const char *name)
 		return NULL;
 
 	strvec_push(argv, value);
-	return argv->argv[argv->argc - 1];
+	return argv->v[argv->nr - 1];
 }
 
 void setup_git_env(const char *git_dir)
exec-cmd.c +3 -3
index 0f8e888424..eeb2ee52b8 100644
@@ -324,18 +324,18 @@ const char **prepare_git_cmd(struct strvec *out, const char **argv)
 {
 	strvec_push(out, "git");
 	strvec_pushv(out, argv);
-	return out->argv;
+	return out->v;
 }
 
 int execv_git_cmd(const char **argv)
 {
 	struct strvec nargv = STRVEC_INIT;
 
 	prepare_git_cmd(&nargv, argv);
-	trace_argv_printf(nargv.argv, "trace: exec:");
+	trace_argv_printf(nargv.v, "trace: exec:");
 
 	/* execvp() can only ever return if it fails */
-	sane_execvp("git", (char **)nargv.argv);
+	sane_execvp("git", (char **)nargv.v);
 
 	trace_printf("trace: exec failed: %s\n", strerror(errno));
 
git.c +5 -5
index 258035cfb1..8bd1d7551d 100644
@@ -352,7 +352,7 @@ static int handle_alias(int *argcp, const char ***argv)
 			strvec_push(&child.args, alias_string + 1);
 			strvec_pushv(&child.args, (*argv) + 1);
 
-			trace2_cmd_alias(alias_command, child.args.argv);
+			trace2_cmd_alias(alias_command, child.args.v);
 			trace2_cmd_list_config();
 			trace2_cmd_list_env_vars();
 			trace2_cmd_name("_run_shell_alias_");
@@ -667,7 +667,7 @@ static void handle_builtin(int argc, const char **argv)
 		}
 
 		argc++;
-		argv = args.argv;
+		argv = args.v;
 	}
 
 	builtin = get_builtin(cmd);
@@ -701,7 +701,7 @@ static void execv_dashed_external(const char **argv)
 	 * The code in run_command() logs trace2 child_start/child_exit
 	 * events, so we do not need to report exec/exec_result events here.
 	 */
-	trace_argv_printf(cmd.args.argv, "trace: exec:");
+	trace_argv_printf(cmd.args.v, "trace: exec:");
 
 	/*
 	 * If we fail because the command is not found, it is
@@ -762,13 +762,13 @@ static int run_argv(int *argcp, const char ***argv)
 			for (i = 0; i < *argcp; i++)
 				strvec_push(&args, (*argv)[i]);
 
-			trace_argv_printf(args.argv, "trace: exec:");
+			trace_argv_printf(args.v, "trace: exec:");
 
 			/*
 			 * if we fail because the command is not found, it is
 			 * OK to return. Otherwise, we just pass along the status code.
 			 */
-			i = run_command_v_opt_tr2(args.argv, RUN_SILENT_EXEC_FAILURE |
+			i = run_command_v_opt_tr2(args.v, RUN_SILENT_EXEC_FAILURE |
 						  RUN_CLEAN_ON_EXIT | RUN_WAIT_AFTER_CLEAN, "git_alias");
 			if (i >= 0 || errno != ENOENT)
 				exit(i);
graph.c +2 -2
index 09c9cc968c..c128ad0cce 100644
@@ -355,8 +355,8 @@ struct git_graph *graph_init(struct rev_info *opt)
 			parse_graph_colors_config(&custom_colors, string);
 			free(string);
 			/* graph_set_column_colors takes a max-index, not a count */
-			graph_set_column_colors(custom_colors.argv,
-						custom_colors.argc - 1);
+			graph_set_column_colors(custom_colors.v,
+						custom_colors.nr - 1);
 		}
 	}
 
http-push.c +1 -1
index 31911aa345..6a4a43e07f 100644
@@ -1931,7 +1931,7 @@ int cmd_main(int argc, const char **argv)
 			strvec_pushf(&commit_argv, "^%s",
 				     oid_to_hex(&ref->old_oid));
 		repo_init_revisions(the_repository, &revs, setup_git_directory());
-		setup_revisions(commit_argv.argc, commit_argv.argv, &revs, NULL);
+		setup_revisions(commit_argv.nr, commit_argv.v, &revs, NULL);
 		revs.edge_hint = 0; /* just in case */
 
 		/* Generate a list of objects that need to be pushed */
ls-refs.c +3 -3
index 8192c949f4..a1e0b473e4 100644
@@ -15,11 +15,11 @@ static int ref_match(const struct strvec *prefixes, const char *refname)
 {
 	int i;
 
-	if (!prefixes->argc)
+	if (!prefixes->nr)
 		return 1; /* no restriction */
 
-	for (i = 0; i < prefixes->argc; i++) {
-		const char *prefix = prefixes->argv[i];
+	for (i = 0; i < prefixes->nr; i++) {
+		const char *prefix = prefixes->v[i];
 
 		if (starts_with(refname, prefix))
 			return 1;
merge.c +1 -1
index a05b054faa..753e461659 100644
@@ -33,7 +33,7 @@ int try_merge_command(struct repository *r,
 	for (j = remotes; j; j = j->next)
 		strvec_push(&args, merge_argument(j->item));
 
-	ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
+	ret = run_command_v_opt(args.v, RUN_GIT_CMD);
 	strvec_clear(&args);
 
 	discard_index(r->index);
pathspec.c +1 -1
index c303126f37..7a229d8d22 100644
@@ -652,7 +652,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
 	if (in != stdin)
 		fclose(in);
 
-	parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.argv);
+	parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.v);
 	strvec_clear(&parsed_file);
 }
 
range-diff.c +1 -1
index 831c490bf2..24dc435e48 100644
@@ -67,7 +67,7 @@ static int read_patches(const char *range, struct string_list *list,
 		     "--notes",
 		     NULL);
 	if (other_arg)
-		strvec_pushv(&cp.args, other_arg->argv);
+		strvec_pushv(&cp.args, other_arg->v);
 	strvec_push(&cp.args, range);
 	cp.out = -1;
 	cp.no_stdin = 1;
ref-filter.c +2 -2
index 7f013851ed..0d3a56b79b 100644
@@ -1918,9 +1918,9 @@ static void find_longest_prefixes(struct string_list *out,
 	struct strbuf prefix = STRBUF_INIT;
 
 	strvec_pushv(&sorted, patterns);
-	QSORT(sorted.argv, sorted.argc, qsort_strcmp);
+	QSORT(sorted.v, sorted.nr, qsort_strcmp);
 
-	find_longest_prefixes_1(out, &prefix, sorted.argv, sorted.argc);
+	find_longest_prefixes_1(out, &prefix, sorted.v, sorted.nr);
 
 	strvec_clear(&sorted);
 	strbuf_release(&prefix);
remote-curl.c +3 -3
index 7feaddc003..41c3ac5c92 100644
@@ -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);
 
remote.c +1 -1
index b4665fe5a3..c5ed74f91c 100644
@@ -1919,7 +1919,7 @@ static int stat_branch_pair(const char *branch_name, const char *base,
 	strvec_push(&argv, "--");
 
 	repo_init_revisions(the_repository, &revs, NULL);
-	setup_revisions(argv.argc, argv.argv, &revs, NULL);
+	setup_revisions(argv.nr, argv.v, &revs, NULL);
 	if (prepare_revision_walk(&revs))
 		die(_("revision walk setup failed"));
 
revision.c +2 -2
index e144132ae9..bc69f19141 100644
@@ -2767,7 +2767,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
 			got_rev_arg = 1;
 	}
 
-	if (prune_data.argc) {
+	if (prune_data.nr) {
 		/*
 		 * If we need to introduce the magic "a lone ':' means no
 		 * pathspec whatsoever", here is the place to do so.
@@ -2783,7 +2783,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
 		 * }
 		 */
 		parse_pathspec(&revs->prune_data, 0, 0,
-			       revs->prefix, prune_data.argv);
+			       revs->prefix, prune_data.v);
 	}
 	strvec_clear(&prune_data);
 
run-command.c +10 -10
index b9630a1b5f..cc9c3296ba 100644
@@ -287,7 +287,7 @@ static const char **prepare_shell_cmd(struct strvec *out, const char **argv)
 	}
 
 	strvec_pushv(out, argv);
-	return out->argv;
+	return out->v;
 }
 
 #ifndef GIT_WINDOWS_NATIVE
@@ -426,11 +426,11 @@ static int prepare_cmd(struct strvec *out, const struct child_process *cmd)
 	 * there are dir separator characters, we have exec attempt to invoke
 	 * the command directly.
 	 */
-	if (!has_dir_sep(out->argv[1])) {
-		char *program = locate_in_PATH(out->argv[1]);
+	if (!has_dir_sep(out->v[1])) {
+		char *program = locate_in_PATH(out->v[1]);
 		if (program) {
-			free((char *)out->argv[1]);
-			out->argv[1] = program;
+			free((char *)out->v[1]);
+			out->v[1] = program;
 		} else {
 			strvec_clear(out);
 			errno = ENOENT;
@@ -672,9 +672,9 @@ int start_command(struct child_process *cmd)
 	char *str;
 
 	if (!cmd->argv)
-		cmd->argv = cmd->args.argv;
+		cmd->argv = cmd->args.v;
 	if (!cmd->env)
-		cmd->env = cmd->env_array.argv;
+		cmd->env = cmd->env_array.v;
 
 	/*
 	 * In case of errors we must keep the promise to close FDs
@@ -846,10 +846,10 @@ int start_command(struct child_process *cmd)
 		 * be used in the event exec failed with ENOEXEC at which point
 		 * we will try to interpret the command using 'sh'.
 		 */
-		execve(argv.argv[1], (char *const *) argv.argv + 1,
+		execve(argv.v[1], (char *const *) argv.v + 1,
 		       (char *const *) childenv);
 		if (errno == ENOEXEC)
-			execve(argv.argv[0], (char *const *) argv.argv,
+			execve(argv.v[0], (char *const *) argv.v,
 			       (char *const *) childenv);
 
 		if (errno == ENOENT) {
@@ -1874,7 +1874,7 @@ int run_auto_gc(int quiet)
 	strvec_pushl(&argv_gc_auto, "gc", "--auto", NULL);
 	if (quiet)
 		strvec_push(&argv_gc_auto, "--quiet");
-	status = run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
+	status = run_command_v_opt(argv_gc_auto.v, RUN_GIT_CMD);
 	strvec_clear(&argv_gc_auto);
 	return status;
 }
sequencer.c +2 -2
index 31a2b1ab55..cc3f8fa88e 100644
@@ -2761,7 +2761,7 @@ static int reset_merge(const struct object_id *oid)
 	if (!is_null_oid(oid))
 		strvec_push(&argv, oid_to_hex(oid));
 
-	ret = run_command_v_opt(argv.argv, RUN_GIT_CMD);
+	ret = run_command_v_opt(argv.v, RUN_GIT_CMD);
 	strvec_clear(&argv);
 
 	return ret;
@@ -3135,7 +3135,7 @@ static int do_exec(struct repository *r, const char *command_line)
 	strvec_pushf(&child_env, "GIT_WORK_TREE=%s",
 		     absolute_path(get_git_work_tree()));
 	status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL,
-					  child_env.argv);
+					  child_env.v);
 
 	/* force re-reading of the cache */
 	if (discard_index(r->index) < 0 || repo_read_index(r) < 0)
serve.c +3 -3
index 523a9be32d..f6341206c4 100644
@@ -146,9 +146,9 @@ int has_capability(const struct strvec *keys, const char *capability,
 		   const char **value)
 {
 	int i;
-	for (i = 0; i < keys->argc; i++) {
+	for (i = 0; i < keys->nr; i++) {
 		const char *out;
-		if (skip_prefix(keys->argv[i], capability, &out) &&
+		if (skip_prefix(keys->v[i], capability, &out) &&
 		    (!*out || *out == '=')) {
 			if (value) {
 				if (*out == '=')
@@ -223,7 +223,7 @@ static int process_request(void)
 			 * If no command and no keys were given then the client
 			 * wanted to terminate the connection.
 			 */
-			if (!keys.argc)
+			if (!keys.nr)
 				return 1;
 
 			/*
strvec.c +22 -22

94 lines not on this page · raw message

strvec.h +10 -10
index bd35de1ce4..fdcad75b45 100644
@@ -2,10 +2,10 @@
 #define STRVEC_H
 
 /**
- * The argv-array API allows one to dynamically build and store
- * NULL-terminated lists.  An argv-array maintains the invariant that the
- * `argv` member always points to a non-NULL array, and that the array is
- * always NULL-terminated at the element pointed to by `argv[argc]`. This
+ * The strvec API allows one to dynamically build and store
+ * NULL-terminated arrays of strings. A strvec maintains the invariant that the
+ * `items` member always points to a non-NULL array, and that the array is
+ * always NULL-terminated at the element pointed to by `items[nr]`. This
  * makes the result suitable for passing to functions expecting to receive
  * argv from main().
  *
@@ -22,15 +22,15 @@ extern const char *empty_strvec[];
 
 /**
  * A single array. This should be initialized by assignment from
- * `STRVEC_INIT`, or by calling `strvec_init`. The `argv`
- * member contains the actual array; the `argc` member contains the
+ * `STRVEC_INIT`, or by calling `strvec_init`. The `items`
+ * member contains the actual array; the `nr` member contains the
  * number of elements in the array, not including the terminating
  * NULL.
  */
 struct strvec {
-	const char **argv;
-	size_t argc;
-	size_t alloc;
+	const char **v;
+	int nr;
+	int alloc;
 };
 
 #define STRVEC_INIT { empty_strvec, 0, 0 }
@@ -78,7 +78,7 @@ void strvec_split(struct strvec *, const char *);
 void strvec_clear(struct strvec *);
 
 /**
- * Disconnect the `argv` member from the `strvec` struct and
+ * Disconnect the `items` member from the `strvec` struct and
  * return it. The caller is responsible for freeing the memory used
  * by the array, and by the strings it references. After detaching,
  * the `strvec` is in a reinitialized state and can be pushed
submodule.c +7 -7
index fb96d595b0..a52b93a87f 100644
@@ -269,7 +269,7 @@ int is_submodule_active(struct repository *repo, const char *path)
 			strvec_push(&args, item->string);
 		}
 
-		parse_pathspec(&ps, 0, 0, NULL, args.argv);
+		parse_pathspec(&ps, 0, 0, NULL, args.v);
 		ret = match_pathspec(repo->index, &ps, path, strlen(path), 0, NULL, 1);
 
 		strvec_clear(&args);
@@ -842,7 +842,7 @@ static void collect_changed_submodules(struct repository *r,
 	const struct commit *commit;
 
 	repo_init_revisions(r, &rev, NULL);
-	setup_revisions(argv->argc, argv->argv, &rev, NULL);
+	setup_revisions(argv->nr, argv->v, &rev, NULL);
 	if (prepare_revision_walk(&rev))
 		die(_("revision walk setup failed"));
 
@@ -1014,7 +1014,7 @@ int find_unpushed_submodules(struct repository *r,
 	struct string_list_item *name;
 	struct strvec argv = STRVEC_INIT;
 
-	/* argv.argv[0] will be ignored by setup_revisions */
+	/* argv.v[0] will be ignored by setup_revisions */
 	strvec_push(&argv, "find_unpushed_submodules");
 	oid_array_for_each_unique(commits, append_oid_to_argv, &argv);
 	strvec_push(&argv, "--not");
@@ -1453,7 +1453,7 @@ static int get_next_submodule(struct child_process *cp,
 				strbuf_addf(err, _("Fetching submodule %s%s\n"),
 					    spf->prefix, ce->name);
 			strvec_init(&cp->args);
-			strvec_pushv(&cp->args, spf->args.argv);
+			strvec_pushv(&cp->args, spf->args.v);
 			strvec_push(&cp->args, default_argv);
 			strvec_push(&cp->args, "--submodule-prefix");
 
@@ -1501,7 +1501,7 @@ static int get_next_submodule(struct child_process *cp,
 		cp->dir = task->repo->gitdir;
 
 		strvec_init(&cp->args);
-		strvec_pushv(&cp->args, spf->args.argv);
+		strvec_pushv(&cp->args, spf->args.v);
 		strvec_push(&cp->args, "on-demand");
 		strvec_push(&cp->args, "--submodule-prefix");
 		strvec_push(&cp->args, submodule_prefix.buf);
@@ -1619,8 +1619,8 @@ int fetch_populated_submodules(struct repository *r,
 		die(_("index file corrupt"));
 
 	strvec_push(&spf.args, "fetch");
-	for (i = 0; i < options->argc; i++)
-		strvec_push(&spf.args, options->argv[i]);
+	for (i = 0; i < options->nr; i++)
+		strvec_push(&spf.args, options->v[i]);
 	strvec_push(&spf.args, "--recurse-submodules-default");
 	/* default value, "--submodule-prefix" and its value are added later */
 
t/helper/test-run-command.c +4 -4
index 726835fcc2..7ae03dc712 100644
@@ -248,7 +248,7 @@ static int quote_stress_test(int argc, const char **argv)
 		else
 			strvec_pushl(&args, "test-tool", "run-command",
 				     "quote-echo", NULL);
-		arg_offset = args.argc;
+		arg_offset = args.nr;
 
 		if (argc > 0) {
 			trials = 1;
@@ -275,13 +275,13 @@ static int quote_stress_test(int argc, const char **argv)
 		if (i < skip)
 			continue;
 
-		cp.argv = args.argv;
+		cp.argv = args.v;
 		strbuf_reset(&out);
 		if (pipe_command(&cp, NULL, 0, &out, 0, NULL, 0) < 0)
 			return error("Failed to spawn child process");
 
 		for (j = 0, k = 0; j < arg_count; j++) {
-			const char *arg = args.argv[j + arg_offset];
+			const char *arg = args.v[j + arg_offset];
 
 			if (strcmp(arg, out.buf + k))
 				ret = error("incorrectly quoted arg: '%s', "
@@ -298,7 +298,7 @@ static int quote_stress_test(int argc, const char **argv)
 			fprintf(stderr, "Trial #%d failed. Arguments:\n", i);
 			for (j = 0; j < arg_count; j++)
 				fprintf(stderr, "arg #%d: '%s'\n",
-					(int)j, args.argv[j + arg_offset]);
+					(int)j, args.v[j + arg_offset]);
 
 			strbuf_release(&out);
 			strvec_clear(&args);
tmp-objdir.c +1 -1
index e78e481d8e..42ed4db5d3 100644
@@ -283,7 +283,7 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)
 {
 	if (!t)
 		return NULL;
-	return t->env.argv;
+	return t->env.v;
 }
 
 void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)
transport-helper.c +1 -1
index ae8011e9d5..defafbf4c1 100644
@@ -138,7 +138,7 @@ static struct child_process *get_helper(struct transport *transport)
 		strvec_pushf(&helper->env_array, "%s=%s",
 			     GIT_DIR_ENVIRONMENT, get_git_dir());
 
-	helper->trace2_child_class = helper->args.argv[0]; /* "remote-<name>" */
+	helper->trace2_child_class = helper->args.v[0]; /* "remote-<name>" */
 
 	code = start_command(helper);
 	if (code < 0 && errno == ENOENT)
upload-pack.c +1 -1
index 4a7918e04e..db8c6509fe 100644
@@ -897,7 +897,7 @@ static int send_shallow_list(struct upload_pack_data *data)
 			struct object *o = data->want_obj.objects[i].item;
 			strvec_push(&av, oid_to_hex(&o->oid));
 		}
-		deepen_by_rev_list(data, av.argc, av.argv);
+		deepen_by_rev_list(data, av.nr, av.v);
 		strvec_clear(&av);
 		ret = 1;
 	} else {
Signature · 1 line
2.28.0.465.g6cda80caa8
author
#16 lore raw

Re: [PATCH 10/11] strvec: drop argv_array compatibility layer

Quoted 6 lines · Jeff King
Quoted 3 lines

If I swap out the final patch with "s/items/v/" that may cause a _little_ more trouble, but perhaps not quite as much (only some of the sites access the fields directly).

Here's the "v" version, which can replace the top patch. I'll follow-up with some notes on merging to "seen".

And here's a diff between your current "seen" tip and what I get by merging in this updated version and then doing any necessary resolution or fixups on top. I'll leave it as an exercise for how you might want to pull the content across. :)

I do note that most of the new call-sites are ones that would be better off using child_process.args, and reviewers (myself and others) have suggested that. So those direct uses of the "argv" member may go away anyway.

---

add-interactive.c +2 -2
index 659289905c..555c4abf32 100644
@@ -944,7 +944,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps,
 					    files->items.items[i].string);
 		parse_pathspec(&ps_selected,
 			       PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
-			       PATHSPEC_LITERAL_PATH, "", args.items);
+			       PATHSPEC_LITERAL_PATH, "", args.v);
 		res = run_add_p(s->r, ADD_P_ADD, NULL, &ps_selected);
 		strvec_clear(&args);
 		clear_pathspec(&ps_selected);
@@ -986,7 +986,7 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
 			if (files->selected[i])
 				strvec_push(&args,
 					    files->items.items[i].string);
-		res = run_command_v_opt(args.items, 0);
+		res = run_command_v_opt(args.v, 0);
 		strvec_clear(&args);
 	}
 
add-patch.c +3 -3
index df170d29ef..0f68eb665e 100644
@@ -398,7 +398,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 		strvec_push(&args, ps->items[i].original);
 
 	setup_child_process(s, &cp, NULL);
-	cp.argv = args.items;
+	cp.argv = args.v;
 	res = capture_command(&cp, plain, 0);
 	if (res) {
 		strvec_clear(&args);
@@ -415,8 +415,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 		const char *diff_filter = s->s.interactive_diff_filter;
 
 		setup_child_process(s, &colored_cp, NULL);
-		xsnprintf((char *)args.items[color_arg_index], 8, "--color");
-		colored_cp.argv = args.items;
+		xsnprintf((char *)args.v[color_arg_index], 8, "--color");
+		colored_cp.argv = args.v;
 		colored = &s->colored;
 		res = capture_command(&colored_cp, colored, 0);
 		strvec_clear(&args);
bisect.c +1 -1
index 9ca3c5c52e..5c7710034a 100644
@@ -649,7 +649,7 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs,
 	if (read_paths)
 		read_bisect_paths(&rev_argv);
 
-	setup_revisions(rev_argv.nr, rev_argv.items, revs, NULL);
+	setup_revisions(rev_argv.nr, rev_argv.v, revs, NULL);
 	/* XXX leak rev_argv, as "revs" may still be pointing to it */
 }
 
builtin/add.c +1 -1
index eb6457da05..ab39a60a0d 100644
@@ -228,7 +228,7 @@ int run_add_interactive(const char *revision, const char *patch_mode,
 		/* pass original pathspec, to be re-parsed */
 		strvec_push(&argv, pathspec->items[i].original);
 
-	status = run_command_v_opt(argv.items, RUN_GIT_CMD);
+	status = run_command_v_opt(argv.v, RUN_GIT_CMD);
 	strvec_clear(&argv);
 	return status;
 }
builtin/am.c +7 -7
index 2ca363f72e..68e9d17379 100644
@@ -812,7 +812,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
 	strbuf_release(&sb);
 	free(series_dir_buf);
 
-	ret = split_mail_conv(stgit_patch_to_mail, state, patches.items, keep_cr);
+	ret = split_mail_conv(stgit_patch_to_mail, state, patches.v, keep_cr);
 
 	strvec_clear(&patches);
 	return ret;
@@ -1002,7 +1002,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
 	}
 	write_state_text(state, "scissors", str);
 
-	sq_quote_argv(&sb, state->git_apply_opts.items);
+	sq_quote_argv(&sb, state->git_apply_opts.v);
 	write_state_text(state, "apply-opt", sb.buf);
 
 	if (state->rebasing)
@@ -1401,9 +1401,9 @@ static int run_apply(const struct am_state *state, const char *index_file)
 		BUG("init_apply_state() failed");
 
 	strvec_push(&apply_opts, "apply");
-	strvec_pushv(&apply_opts, state->git_apply_opts.items);
+	strvec_pushv(&apply_opts, state->git_apply_opts.v);
 
-	opts_left = apply_parse_options(apply_opts.nr, apply_opts.items,
+	opts_left = apply_parse_options(apply_opts.nr, apply_opts.v,
 					&apply_state, &force_apply, &options,
 					NULL);
 
@@ -1428,7 +1428,7 @@ static int run_apply(const struct am_state *state, const char *index_file)
 
 	strvec_push(&apply_paths, am_path(state, "patch"));
 
-	res = apply_all_patches(&apply_state, apply_paths.nr, apply_paths.items, options);
+	res = apply_all_patches(&apply_state, apply_paths.nr, apply_paths.v, options);
 
 	strvec_clear(&apply_paths);
 	strvec_clear(&apply_opts);
@@ -1455,7 +1455,7 @@ static int build_fake_ancestor(const struct am_state *state, const char *index_f
 
 	cp.git_cmd = 1;
 	strvec_push(&cp.args, "apply");
-	strvec_pushv(&cp.args, state->git_apply_opts.items);
+	strvec_pushv(&cp.args, state->git_apply_opts.v);
 	strvec_pushf(&cp.args, "--build-fake-ancestor=%s", index_file);
 	strvec_push(&cp.args, am_path(state, "patch"));
 
@@ -2379,7 +2379,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 		if (state.interactive && !paths.nr)
 			die(_("interactive mode requires patches on the command line"));
 
-		am_setup(&state, patch_format, paths.items, keep_cr);
+		am_setup(&state, patch_format, paths.v, keep_cr);
 
 		strvec_clear(&paths);
 	}
builtin/annotate.c +1 -1
index b9ab710740..58ff977a23 100644
@@ -18,5 +18,5 @@ int cmd_annotate(int argc, const char **argv, const char *prefix)
 		strvec_push(&args, argv[i]);
 	}
 
-	return cmd_blame(args.nr, args.items, prefix);
+	return cmd_blame(args.nr, args.v, prefix);
 }
builtin/bisect--helper.c +2 -2
index 272c303ee4..0ba43f71ff 100644
@@ -204,7 +204,7 @@ static int bisect_reset(const char *commit)
 		struct strvec argv = STRVEC_INIT;
 
 		strvec_pushl(&argv, "checkout", branch.buf, "--", NULL);
-		if (run_command_v_opt(argv.items, RUN_GIT_CMD)) {
+		if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
 			error(_("could not check out original"
 				" HEAD '%s'. Try 'git bisect"
 				" reset <commit>'."), branch.buf);
@@ -707,7 +707,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int no_checkou
 
 			strvec_pushl(&argv, "checkout", start_head.buf,
 				     "--", NULL);
-			if (run_command_v_opt(argv.items, RUN_GIT_CMD)) {
+			if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
 				res = error(_("checking out '%s' failed."
 						 " Try 'git bisect start "
 						 "<valid-branch>'."),
builtin/clone.c +2 -2
index 0bd57a9124..b087ee40c2 100644
@@ -752,7 +752,7 @@ static int git_sparse_checkout_init(const char *repo)
 	 */
 	core_apply_sparse_checkout = 1;
 
-	if (run_command_v_opt(argv.items, RUN_GIT_CMD)) {
+	if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
 		error(_("failed to initialize sparse-checkout"));
 		result = 1;
 	}
@@ -844,7 +844,7 @@ static int checkout(int submodule_progress)
 					       "--single-branch" :
 					       "--no-single-branch");
 
-		err = run_command_v_opt(args.items, RUN_GIT_CMD);
+		err = run_command_v_opt(args.v, RUN_GIT_CMD);
 		strvec_clear(&args);
 	}
 
builtin/commit.c +1 -1
index 9705bfb0cf..f9b0a0c05d 100644
@@ -1008,7 +1008,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		struct strvec env = STRVEC_INIT;
 
 		strvec_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
-		if (launch_editor(git_path_commit_editmsg(), NULL, env.items)) {
+		if (launch_editor(git_path_commit_editmsg(), NULL, env.v)) {
 			fprintf(stderr,
 			_("Please supply the message using either -m or -F option.\n"));
 			exit(1);
builtin/describe.c +3 -3
index 85c1504065..7668591d57 100644
@@ -509,7 +509,7 @@ static void describe_blob(struct object_id oid, struct strbuf *dst)
 		     NULL);
 
 	repo_init_revisions(the_repository, &revs, NULL);
-	if (setup_revisions(args.nr, args.items, &revs, NULL) > 1)
+	if (setup_revisions(args.nr, args.v, &revs, NULL) > 1)
 		BUG("setup_revisions could not handle all args?");
 
 	if (prepare_revision_walk(&revs))
@@ -613,7 +613,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 			strvec_pushv(&args, argv);
 		else
 			strvec_push(&args, "HEAD");
-		return cmd_name_rev(args.nr, args.items, prefix);
+		return cmd_name_rev(args.nr, args.v, prefix);
 	}
 
 	hashmap_init(&names, commit_name_neq, NULL, 0);
@@ -659,7 +659,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 
 			repo_init_revisions(the_repository, &revs, prefix);
 			strvec_pushv(&args, diff_index_args);
-			if (setup_revisions(args.nr, args.items, &revs, NULL) != 1)
+			if (setup_revisions(args.nr, args.v, &revs, NULL) != 1)
 				BUG("malformed internal diff-index command line");
 			result = run_diff_index(&revs, 0);
 
builtin/difftool.c +1 -1
index 78ea697325..7ac432b881 100644
@@ -683,7 +683,7 @@ static int run_file_diff(int prompt, const char *prefix,
 	strvec_push(&args, "diff");
 	for (i = 0; i < argc; i++)
 		strvec_push(&args, argv[i]);
-	ret = run_command_v_opt_cd_env(args.items, RUN_GIT_CMD, prefix, env);
+	ret = run_command_v_opt_cd_env(args.v, RUN_GIT_CMD, prefix, env);
 	exit(ret);
 }
 
builtin/fetch.c +2 -2
index 4c6d7c4428..ee52ae734e 100644
@@ -1616,7 +1616,7 @@ static int fetch_multiple(struct string_list *list, int max_children)
 	add_options_to_argv(&argv);
 
 	if (max_children != 1 && list->nr != 1) {
-		struct parallel_fetch_state state = { argv.items, list, 0, 0 };
+		struct parallel_fetch_state state = { argv.v, list, 0, 0 };
 
 		strvec_push(&argv, "--end-of-options");
 		result = run_processes_parallel_tr2(max_children,
@@ -1634,7 +1634,7 @@ static int fetch_multiple(struct string_list *list, int max_children)
 			strvec_push(&argv, name);
 			if (verbosity >= 0)
 				printf(_("Fetching %s\n"), name);
-			if (run_command_v_opt(argv.items, RUN_GIT_CMD)) {
+			if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
 				error(_("Could not fetch %s"), name);
 				result = 1;
 			}
builtin/gc.c +21 -21

122 lines not on this page · raw message

builtin/pack-objects.c +1 -1
index 0de05ee567..fac58865da 100644
@@ -3737,7 +3737,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 	if (!use_internal_rev_list)
 		read_object_list_from_stdin();
 	else {
-		get_object_list(rp.nr, rp.items);
+		get_object_list(rp.nr, rp.v);
 		strvec_clear(&rp);
 	}
 	cleanup_preferred_base();
builtin/pull.c +8 -8
index 4c66db1468..5ef3434e1f 100644
@@ -585,14 +585,14 @@ static int run_fetch(const char *repo, const char **refspecs)
 		strvec_push(&args, "--no-show-forced-updates");
 	if (set_upstream)
 		strvec_push(&args, set_upstream);
-	strvec_pushv(&args, opt_fetch.items);
+	strvec_pushv(&args, opt_fetch.v);
 
 	if (repo) {
 		strvec_push(&args, repo);
 		strvec_pushv(&args, refspecs);
 	} else if (*refspecs)
 		BUG("refspecs without repo?");
-	ret = run_command_v_opt(args.items, RUN_GIT_CMD);
+	ret = run_command_v_opt(args.v, RUN_GIT_CMD);
 	strvec_clear(&args);
 	return ret;
 }
@@ -692,8 +692,8 @@ static int run_merge(void)
 		strvec_push(&args, opt_ff);
 	if (opt_verify_signatures)
 		strvec_push(&args, opt_verify_signatures);
-	strvec_pushv(&args, opt_strategies.items);
-	strvec_pushv(&args, opt_strategy_opts.items);
+	strvec_pushv(&args, opt_strategies.v);
+	strvec_pushv(&args, opt_strategy_opts.v);
 	if (opt_gpg_sign)
 		strvec_push(&args, opt_gpg_sign);
 	if (opt_autostash == 0)
@@ -704,7 +704,7 @@ static int run_merge(void)
 		strvec_push(&args, "--allow-unrelated-histories");
 
 	strvec_push(&args, "FETCH_HEAD");
-	ret = run_command_v_opt(args.items, RUN_GIT_CMD);
+	ret = run_command_v_opt(args.v, RUN_GIT_CMD);
 	strvec_clear(&args);
 	return ret;
 }
@@ -883,8 +883,8 @@ static int run_rebase(const struct object_id *curr_head,
 		strvec_push(&args, "--interactive");
 	if (opt_diffstat)
 		strvec_push(&args, opt_diffstat);
-	strvec_pushv(&args, opt_strategies.items);
-	strvec_pushv(&args, opt_strategy_opts.items);
+	strvec_pushv(&args, opt_strategies.v);
+	strvec_pushv(&args, opt_strategy_opts.v);
 	if (opt_gpg_sign)
 		strvec_push(&args, opt_gpg_sign);
 	if (opt_autostash == 0)
@@ -903,7 +903,7 @@ static int run_rebase(const struct object_id *curr_head,
 	else
 		strvec_push(&args, oid_to_hex(merge_head));
 
-	ret = run_command_v_opt(args.items, RUN_GIT_CMD);
+	ret = run_command_v_opt(args.v, RUN_GIT_CMD);
 	strvec_clear(&args);
 	return ret;
 }
builtin/rebase.c +5 -5
index 3a9d6672f2..eeca53382f 100644
@@ -357,7 +357,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
 			     oid_to_hex(&opts->restrict_revision->object.oid));
 
 	ret = sequencer_make_script(the_repository, &todo_list.buf,
-				    make_script_args.nr, make_script_args.items,
+				    make_script_args.nr, make_script_args.v,
 				    flags);
 
 	if (ret)
@@ -906,7 +906,7 @@ static int run_am(struct rebase_options *opts)
 		return status;
 	}
 
-	strvec_pushv(&am.args, opts->git_am_opts.items);
+	strvec_pushv(&am.args, opts->git_am_opts.v);
 	strvec_push(&am.args, "--rebasing");
 	strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
 	strvec_push(&am.args, "--patch-format=mboxrd");
@@ -975,7 +975,7 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action)
 	add_var(&script_snippet, "revisions", opts->revisions);
 	add_var(&script_snippet, "restrict_revision", opts->restrict_revision ?
 		oid_to_hex(&opts->restrict_revision->object.oid) : NULL);
-	sq_quote_argv_pretty(&buf, opts->git_am_opts.items);
+	sq_quote_argv_pretty(&buf, opts->git_am_opts.v);
 	add_var(&script_snippet, "git_am_opt", buf.buf);
 	strbuf_release(&buf);
 	add_var(&script_snippet, "verbose",
@@ -1636,7 +1636,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		options.flags |= REBASE_FORCE;
 
 	for (i = 0; i < options.git_am_opts.nr; i++) {
-		const char *option = options.git_am_opts.items[i], *p;
+		const char *option = options.git_am_opts.v[i], *p;
 		if (!strcmp(option, "--whitespace=fix") ||
 		    !strcmp(option, "--whitespace=strip"))
 			allow_preemptive_ff = 0;
@@ -1749,7 +1749,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	if (options.git_am_opts.nr || options.type == REBASE_APPLY) {
 		/* all am options except -q are compatible only with --apply */
 		for (i = options.git_am_opts.nr - 1; i >= 0; i--)
-			if (strcmp(options.git_am_opts.items[i], "-q"))
+			if (strcmp(options.git_am_opts.v[i], "-q"))
 				break;
 
 		if (i >= 0) {
builtin/receive-pack.c +5 -5
index 1158d184f5..b9615e8441 100644
@@ -1252,7 +1252,7 @@ static const char *push_to_deploy(unsigned char *sha1,
 	struct child_process child = CHILD_PROCESS_INIT;
 
 	child.argv = update_refresh;
-	child.env = env->items;
+	child.env = env->v;
 	child.dir = work_tree;
 	child.no_stdin = 1;
 	child.stdout_to_stderr = 1;
@@ -1263,7 +1263,7 @@ static const char *push_to_deploy(unsigned char *sha1,
 	/* run_command() does not clean up completely; reinitialize */
 	child_process_init(&child);
 	child.argv = diff_files;
-	child.env = env->items;
+	child.env = env->v;
 	child.dir = work_tree;
 	child.no_stdin = 1;
 	child.stdout_to_stderr = 1;
@@ -1276,7 +1276,7 @@ static const char *push_to_deploy(unsigned char *sha1,
 
 	child_process_init(&child);
 	child.argv = diff_index;
-	child.env = env->items;
+	child.env = env->v;
 	child.no_stdin = 1;
 	child.no_stdout = 1;
 	child.stdout_to_stderr = 0;
@@ -1287,7 +1287,7 @@ static const char *push_to_deploy(unsigned char *sha1,
 	read_tree[3] = hash_to_hex(sha1);
 	child_process_init(&child);
 	child.argv = read_tree;
-	child.env = env->items;
+	child.env = env->v;
 	child.dir = work_tree;
 	child.no_stdin = 1;
 	child.no_stdout = 1;
@@ -1306,7 +1306,7 @@ static const char *push_to_checkout(unsigned char *hash,
 				    const char *work_tree)
 {
 	strvec_pushf(env, "GIT_WORK_TREE=%s", absolute_path(work_tree));
-	if (run_hook_le(env->items, push_to_checkout_hook,
+	if (run_hook_le(env->v, push_to_checkout_hook,
 			hash_to_hex(hash), NULL))
 		return "push-to-checkout hook declined";
 	else
builtin/remote.c +2 -2
index 9a98e77a5e..c8240e9fcd 100644
@@ -1470,15 +1470,15 @@ static int update(int argc, const char **argv)
 	for (i = 1; i < argc; i++)
 		strvec_push(&fetch_argv, argv[i]);
 
-	if (strcmp(fetch_argv.items[fetch_argv.nr-1], "default") == 0) {
+	if (strcmp(fetch_argv.v[fetch_argv.nr-1], "default") == 0) {
 		git_config(get_remote_default, &default_defined);
 		if (!default_defined) {
 			strvec_pop(&fetch_argv);
 			strvec_push(&fetch_argv, "--all");
 		}
 	}
 
-	retval = run_command_v_opt(fetch_argv.items, RUN_GIT_CMD);
+	retval = run_command_v_opt(fetch_argv.v, RUN_GIT_CMD);
 	strvec_clear(&fetch_argv);
 	return retval;
 }
builtin/replace.c +1 -1
index 038b7f874b..cd48765911 100644
@@ -513,7 +513,7 @@ static int convert_graft_file(int force)
 			continue;
 
 		strvec_split(&args, buf.buf);
-		if (args.nr && create_graft(args.nr, args.items, force, 1))
+		if (args.nr && create_graft(args.nr, args.v, force, 1))
 			strbuf_addf(&err, "\n\t%s", buf.buf);
 		strvec_clear(&args);
 	}
builtin/show-branch.c +1 -1
index de27703297..7eae5f3801 100644
@@ -686,7 +686,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 	/* If nothing is specified, try the default first */
 	if (ac == 1 && default_args.nr) {
 		ac = default_args.nr;
-		av = default_args.items;
+		av = default_args.v;
 	}
 
 	ac = parse_options(ac, av, prefix, builtin_show_branch_options,
builtin/stash.c +3 -3
index 0134c6b0d6..10d87630cd 100644
@@ -745,7 +745,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
 			strvec_push(&revision_args, argv[i]);
 	}
 
-	ret = get_stash_info(&info, stash_args.nr, stash_args.items);
+	ret = get_stash_info(&info, stash_args.nr, stash_args.v);
 	strvec_clear(&stash_args);
 	if (ret)
 		return -1;
@@ -767,7 +767,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
 		}
 	}
 
-	argc = setup_revisions(revision_args.nr, revision_args.items, &rev, NULL);
+	argc = setup_revisions(revision_args.nr, revision_args.v, &rev, NULL);
 	if (argc > 1) {
 		free_stash_info(&info);
 		usage_with_options(git_stash_show_usage, options);
@@ -1611,5 +1611,5 @@ int cmd_stash(int argc, const char **argv, const char *prefix)
 	/* Assume 'stash push' */
 	strvec_push(&args, "push");
 	strvec_pushv(&args, argv);
-	return !!push_stash(args.nr, args.items, prefix, 1);
+	return !!push_stash(args.nr, args.v, prefix, 1);
 }
builtin/submodule--helper.c +1 -1
index 6bbed9f92a..df135abbf1 100644
@@ -818,7 +818,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
 	repo_init_revisions(the_repository, &rev, NULL);
 	rev.abbrev = 0;
 	diff_files_args.nr = setup_revisions(diff_files_args.nr,
-					     diff_files_args.items,
+					     diff_files_args.v,
 					     &rev, NULL);
 	diff_files_result = run_diff_files(&rev, 0);
 
builtin/upload-archive.c +1 -1
index 8ded611092..24654b4c9b 100644
@@ -45,7 +45,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
 	}
 
 	/* parse all options sent by the client */
-	return write_archive(sent_argv.nr, sent_argv.items, prefix,
+	return write_archive(sent_argv.nr, sent_argv.v, prefix,
 			     the_repository, NULL, 1);
 }
 
builtin/verify-pack.c +1 -1
index 9a5b787912..ef24e11243 100644
@@ -40,7 +40,7 @@ static int verify_one_pack(const char *path, unsigned int flags, const char *has
 		strbuf_addstr(&arg, ".pack");
 	strvec_push(&argv, arg.buf);
 
-	index_pack.argv = argv.items;
+	index_pack.argv = argv.v;
 	index_pack.git_cmd = 1;
 
 	err = run_command(&index_pack);
builtin/worktree.c +3 -3
index 1d6b9455da..378f332b5d 100644
@@ -422,7 +422,7 @@ static int add_worktree(const char *path, const char *refname,
 			strvec_push(&cp.args, "--quiet");
 	}
 
-	cp.env = child_env.items;
+	cp.env = child_env.v;
 	ret = run_command(&cp);
 	if (ret)
 		goto done;
@@ -433,7 +433,7 @@ static int add_worktree(const char *path, const char *refname,
 		strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
 		if (opts->quiet)
 			strvec_push(&cp.args, "--quiet");
-		cp.env = child_env.items;
+		cp.env = child_env.v;
 		ret = run_command(&cp);
 		if (ret)
 			goto done;
@@ -943,7 +943,7 @@ static void check_clean_worktree(struct worktree *wt,
 	strvec_pushl(&cp.args, "status",
 		     "--porcelain", "--ignore-submodules=none",
 		     NULL);
-	cp.env = child_env.items;
+	cp.env = child_env.v;
 	cp.git_cmd = 1;
 	cp.dir = wt->path;
 	cp.out = -1;
bundle.c +1 -1
index 762177e1fd..47e478c9a5 100644
@@ -304,7 +304,7 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *
 		     "pack-objects",
 		     "--stdout", "--thin", "--delta-base-offset",
 		     NULL);
-	strvec_pushv(&pack_objects.args, pack_options->items);
+	strvec_pushv(&pack_objects.args, pack_options->v);
 	pack_objects.in = -1;
 	pack_objects.out = bundle_fd;
 	pack_objects.git_cmd = 1;
commit.c +1 -1
index c8fd6931a6..4ce8cb38d5 100644
@@ -1643,7 +1643,7 @@ int run_commit_hook(int editor_is_used, const char *index_file,
 		strvec_push(&hook_env, "GIT_EDITOR=:");
 
 	va_start(args, name);
-	ret = run_hook_ve(hook_env.items, name, args);
+	ret = run_hook_ve(hook_env.v, name, args);
 	va_end(args);
 	strvec_clear(&hook_env);
 
connect.c +4 -4
index e3a08179d4..0b6aba177e 100644
@@ -72,7 +72,7 @@ int server_supports_v2(const char *c, int die_on_error)
 
 	for (i = 0; i < server_capabilities_v2.nr; i++) {
 		const char *out;
-		if (skip_prefix(server_capabilities_v2.items[i], c, &out) &&
+		if (skip_prefix(server_capabilities_v2.v[i], c, &out) &&
 		    (!*out || *out == '='))
 			return 1;
 	}
@@ -89,7 +89,7 @@ int server_feature_v2(const char *c, const char **v)
 
 	for (i = 0; i < server_capabilities_v2.nr; i++) {
 		const char *out;
-		if (skip_prefix(server_capabilities_v2.items[i], c, &out) &&
+		if (skip_prefix(server_capabilities_v2.v[i], c, &out) &&
 		    (*out == '=')) {
 			*v = out + 1;
 			return 1;
@@ -105,7 +105,7 @@ int server_supports_feature(const char *c, const char *feature,
 
 	for (i = 0; i < server_capabilities_v2.nr; i++) {
 		const char *out;
-		if (skip_prefix(server_capabilities_v2.items[i], c, &out) &&
+		if (skip_prefix(server_capabilities_v2.v[i], c, &out) &&
 		    (!*out || *(out++) == '=')) {
 			if (parse_feature_request(out, feature))
 				return 1;
@@ -490,7 +490,7 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
 	packet_write_fmt(fd_out, "symrefs\n");
 	for (i = 0; ref_prefixes && i < ref_prefixes->nr; i++) {
 		packet_write_fmt(fd_out, "ref-prefix %s\n",
-				 ref_prefixes->items[i]);
+				 ref_prefixes->v[i]);
 	}
 	packet_flush(fd_out);
 
daemon.c +4 -4
index ee66002a6f..2ab7ea82eb 100644
@@ -482,7 +482,7 @@ static int upload_pack(const struct strvec *env)
 	strvec_pushl(&cld.args, "upload-pack", "--strict", NULL);
 	strvec_pushf(&cld.args, "--timeout=%u", timeout);
 
-	strvec_pushv(&cld.env_array, env->items);
+	strvec_pushv(&cld.env_array, env->v);
 
 	return run_service_command(&cld);
 }
@@ -492,7 +492,7 @@ static int upload_archive(const struct strvec *env)
 	struct child_process cld = CHILD_PROCESS_INIT;
 	strvec_push(&cld.args, "upload-archive");
 
-	strvec_pushv(&cld.env_array, env->items);
+	strvec_pushv(&cld.env_array, env->v);
 
 	return run_service_command(&cld);
 }
@@ -502,7 +502,7 @@ static int receive_pack(const struct strvec *env)
 	struct child_process cld = CHILD_PROCESS_INIT;
 	strvec_push(&cld.args, "receive-pack");
 
-	strvec_pushv(&cld.env_array, env->items);
+	strvec_pushv(&cld.env_array, env->v);
 
 	return run_service_command(&cld);
 }
@@ -927,7 +927,7 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
 #endif
 	}
 
-	cld.argv = cld_argv.items;
+	cld.argv = cld_argv.v;
 	cld.in = incoming;
 	cld.out = dup(incoming);
 
diff.c +1 -1
index fb5462c532..f9709de7b4 100644
@@ -4239,7 +4239,7 @@ static void run_external_diff(const char *pgm,
 
 	diff_free_filespec_data(one);
 	diff_free_filespec_data(two);
-	if (run_command_v_opt_cd_env(argv.items, RUN_USING_SHELL, NULL, env.items))
+	if (run_command_v_opt_cd_env(argv.v, RUN_USING_SHELL, NULL, env.v))
 		die(_("external diff died, stopping at %s"), name);
 
 	remove_tempfile();
environment.c +1 -1
index 449a46995d..52e0c979ba 100644
@@ -164,7 +164,7 @@ static const char *getenv_safe(struct strvec *argv, const char *name)
 		return NULL;
 
 	strvec_push(argv, value);
-	return argv->items[argv->nr - 1];
+	return argv->v[argv->nr - 1];
 }
 
 void setup_git_env(const char *git_dir)
exec-cmd.c +3 -3
index d657c025c2..eeb2ee52b8 100644
@@ -324,18 +324,18 @@ const char **prepare_git_cmd(struct strvec *out, const char **argv)
 {
 	strvec_push(out, "git");
 	strvec_pushv(out, argv);
-	return out->items;
+	return out->v;
 }
 
 int execv_git_cmd(const char **argv)
 {
 	struct strvec nargv = STRVEC_INIT;
 
 	prepare_git_cmd(&nargv, argv);
-	trace_argv_printf(nargv.items, "trace: exec:");
+	trace_argv_printf(nargv.v, "trace: exec:");
 
 	/* execvp() can only ever return if it fails */
-	sane_execvp("git", (char **)nargv.items);
+	sane_execvp("git", (char **)nargv.v);
 
 	trace_printf("trace: exec failed: %s\n", strerror(errno));
 
git.c +5 -5
index 0b2c5531ae..866ee11a2a 100644
@@ -357,7 +357,7 @@ static int handle_alias(int *argcp, const char ***argv)
 			strvec_push(&child.args, alias_string + 1);
 			strvec_pushv(&child.args, (*argv) + 1);
 
-			trace2_cmd_alias(alias_command, child.args.items);
+			trace2_cmd_alias(alias_command, child.args.v);
 			trace2_cmd_list_config();
 			trace2_cmd_list_env_vars();
 			trace2_cmd_name("_run_shell_alias_");
@@ -674,7 +674,7 @@ static void handle_builtin(int argc, const char **argv)
 		}
 
 		argc++;
-		argv = args.items;
+		argv = args.v;
 	}
 
 	builtin = get_builtin(cmd);
@@ -708,7 +708,7 @@ static void execv_dashed_external(const char **argv)
 	 * The code in run_command() logs trace2 child_start/child_exit
 	 * events, so we do not need to report exec/exec_result events here.
 	 */
-	trace_argv_printf(cmd.args.items, "trace: exec:");
+	trace_argv_printf(cmd.args.v, "trace: exec:");
 
 	/*
 	 * If we fail because the command is not found, it is
@@ -769,13 +769,13 @@ static int run_argv(int *argcp, const char ***argv)
 			for (i = 0; i < *argcp; i++)
 				strvec_push(&args, (*argv)[i]);
 
-			trace_argv_printf(args.items, "trace: exec:");
+			trace_argv_printf(args.v, "trace: exec:");
 
 			/*
 			 * if we fail because the command is not found, it is
 			 * OK to return. Otherwise, we just pass along the status code.
 			 */
-			i = run_command_v_opt_tr2(args.items, RUN_SILENT_EXEC_FAILURE |
+			i = run_command_v_opt_tr2(args.v, RUN_SILENT_EXEC_FAILURE |
 						  RUN_CLEAN_ON_EXIT | RUN_WAIT_AFTER_CLEAN, "git_alias");
 			if (i >= 0 || errno != ENOENT)
 				exit(i);
graph.c +1 -1
index 1d68fffa24..c128ad0cce 100644
@@ -355,7 +355,7 @@ struct git_graph *graph_init(struct rev_info *opt)
 			parse_graph_colors_config(&custom_colors, string);
 			free(string);
 			/* graph_set_column_colors takes a max-index, not a count */
-			graph_set_column_colors(custom_colors.items,
+			graph_set_column_colors(custom_colors.v,
 						custom_colors.nr - 1);
 		}
 	}
http-push.c +1 -1
index c4e3825609..6a4a43e07f 100644
@@ -1931,7 +1931,7 @@ int cmd_main(int argc, const char **argv)
 			strvec_pushf(&commit_argv, "^%s",
 				     oid_to_hex(&ref->old_oid));
 		repo_init_revisions(the_repository, &revs, setup_git_directory());
-		setup_revisions(commit_argv.nr, commit_argv.items, &revs, NULL);
+		setup_revisions(commit_argv.nr, commit_argv.v, &revs, NULL);
 		revs.edge_hint = 0; /* just in case */
 
 		/* Generate a list of objects that need to be pushed */
ls-refs.c +1 -1
index e6b8c9cf8e..a1e0b473e4 100644
@@ -19,7 +19,7 @@ static int ref_match(const struct strvec *prefixes, const char *refname)
 		return 1; /* no restriction */
 
 	for (i = 0; i < prefixes->nr; i++) {
-		const char *prefix = prefixes->items[i];
+		const char *prefix = prefixes->v[i];
 
 		if (starts_with(refname, prefix))
 			return 1;
merge.c +1 -1
index bcfb9dcf8a..753e461659 100644
@@ -33,7 +33,7 @@ int try_merge_command(struct repository *r,
 	for (j = remotes; j; j = j->next)
 		strvec_push(&args, merge_argument(j->item));
 
-	ret = run_command_v_opt(args.items, RUN_GIT_CMD);
+	ret = run_command_v_opt(args.v, RUN_GIT_CMD);
 	strvec_clear(&args);
 
 	discard_index(r->index);
pathspec.c +1 -1
index 75378f49d1..7a229d8d22 100644
@@ -652,7 +652,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
 	if (in != stdin)
 		fclose(in);
 
-	parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.items);
+	parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.v);
 	strvec_clear(&parsed_file);
 }
 
range-diff.c +1 -1
index 3fa3ac6cb5..24dc435e48 100644
@@ -67,7 +67,7 @@ static int read_patches(const char *range, struct string_list *list,
 		     "--notes",
 		     NULL);
 	if (other_arg)
-		strvec_pushv(&cp.args, other_arg->items);
+		strvec_pushv(&cp.args, other_arg->v);
 	strvec_push(&cp.args, range);
 	cp.out = -1;
 	cp.no_stdin = 1;
ref-filter.c +2 -2
index 5b2a7684a1..d0e6ab525c 100644
@@ -1923,9 +1923,9 @@ static void find_longest_prefixes(struct string_list *out,
 	struct strbuf prefix = STRBUF_INIT;
 
 	strvec_pushv(&sorted, patterns);
-	QSORT(sorted.items, sorted.nr, qsort_strcmp);
+	QSORT(sorted.v, sorted.nr, qsort_strcmp);
 
-	find_longest_prefixes_1(out, &prefix, sorted.items, sorted.nr);
+	find_longest_prefixes_1(out, &prefix, sorted.v, sorted.nr);
 
 	strvec_clear(&sorted);
 	strbuf_release(&prefix);
remote-curl.c +3 -3
index 8a2f461824..62b3a45cde 100644
@@ -1194,7 +1194,7 @@ static int fetch_git(struct discovery *heads,
 	rpc.service_name = "git-upload-pack",
 	rpc.gzip_request = 1;
 
-	err = rpc_service(&rpc, heads, args.items, &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);
@@ -1329,7 +1329,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.items, &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);
@@ -1370,7 +1370,7 @@ static void parse_push(struct strbuf *buf)
 			break;
 	} while (1);
 
-	ret = push(specs.nr, specs.items);
+	ret = push(specs.nr, specs.v);
 	printf("\n");
 	fflush(stdout);
 
remote.c +1 -1
index cc4b77ead6..d9af0018af 100644
@@ -1969,7 +1969,7 @@ static int stat_branch_pair(const char *branch_name, const char *base,
 	strvec_push(&argv, "--");
 
 	repo_init_revisions(the_repository, &revs, NULL);
-	setup_revisions(argv.nr, argv.items, &revs, NULL);
+	setup_revisions(argv.nr, argv.v, &revs, NULL);
 	if (prepare_revision_walk(&revs))
 		die(_("revision walk setup failed"));
 
revision.c +1 -1
index 358cc77c5c..3f909604e2 100644
@@ -2807,7 +2807,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
 		 * }
 		 */
 		parse_pathspec(&revs->prune_data, 0, 0,
-			       revs->prefix, prune_data.items);
+			       revs->prefix, prune_data.v);
 	}
 	strvec_clear(&prune_data);
 
run-command.c +10 -10
index 26f24e4459..30f1dfe3c5 100644
@@ -287,7 +287,7 @@ static const char **prepare_shell_cmd(struct strvec *out, const char **argv)
 	}
 
 	strvec_pushv(out, argv);
-	return out->items;
+	return out->v;
 }
 
 #ifndef GIT_WINDOWS_NATIVE
@@ -426,11 +426,11 @@ static int prepare_cmd(struct strvec *out, const struct child_process *cmd)
 	 * there are dir separator characters, we have exec attempt to invoke
 	 * the command directly.
 	 */
-	if (!has_dir_sep(out->items[1])) {
-		char *program = locate_in_PATH(out->items[1]);
+	if (!has_dir_sep(out->v[1])) {
+		char *program = locate_in_PATH(out->v[1]);
 		if (program) {
-			free((char *)out->items[1]);
-			out->items[1] = program;
+			free((char *)out->v[1]);
+			out->v[1] = program;
 		} else {
 			strvec_clear(out);
 			errno = ENOENT;
@@ -672,9 +672,9 @@ int start_command(struct child_process *cmd)
 	char *str;
 
 	if (!cmd->argv)
-		cmd->argv = cmd->args.items;
+		cmd->argv = cmd->args.v;
 	if (!cmd->env)
-		cmd->env = cmd->env_array.items;
+		cmd->env = cmd->env_array.v;
 
 	/*
 	 * In case of errors we must keep the promise to close FDs
@@ -846,10 +846,10 @@ int start_command(struct child_process *cmd)
 		 * be used in the event exec failed with ENOEXEC at which point
 		 * we will try to interpret the command using 'sh'.
 		 */
-		execve(argv.items[1], (char *const *) argv.items + 1,
+		execve(argv.v[1], (char *const *) argv.v + 1,
 		       (char *const *) childenv);
 		if (errno == ENOEXEC)
-			execve(argv.items[0], (char *const *) argv.items,
+			execve(argv.v[0], (char *const *) argv.v,
 			       (char *const *) childenv);
 
 		if (errno == ENOENT) {
@@ -1877,7 +1877,7 @@ int run_auto_maintenance(int quiet)
 	else
 		strvec_push(&argv_gc_auto, "--no-quiet");
 
-	status = run_command_v_opt(argv_gc_auto.items, RUN_GIT_CMD);
+	status = run_command_v_opt(argv_gc_auto.v, RUN_GIT_CMD);
 	strvec_clear(&argv_gc_auto);
 	return status;
 }
sequencer.c +3 -4
index 10c83d0914..6b1795a844 100644
@@ -871,8 +871,7 @@ static const char *author_date_from_env_array(const struct strvec *env)
 	const char *date;
 
 	for (i = 0; i < env->nr; i++)
-		if (skip_prefix(env->items[i],
-				"GIT_AUTHOR_DATE=", &date))
+		if (skip_prefix(env->v[i], "GIT_AUTHOR_DATE=", &date))
 			return date;
 	/*
 	 * If GIT_AUTHOR_DATE is missing we should have already errored out when
@@ -2855,7 +2854,7 @@ static int reset_merge(const struct object_id *oid)
 	if (!is_null_oid(oid))
 		strvec_push(&argv, oid_to_hex(oid));
 
-	ret = run_command_v_opt(argv.items, RUN_GIT_CMD);
+	ret = run_command_v_opt(argv.v, RUN_GIT_CMD);
 	strvec_clear(&argv);
 
 	return ret;
@@ -3229,7 +3228,7 @@ static int do_exec(struct repository *r, const char *command_line)
 	strvec_pushf(&child_env, "GIT_WORK_TREE=%s",
 		     absolute_path(get_git_work_tree()));
 	status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL,
-					  child_env.items);
+					  child_env.v);
 
 	/* force re-reading of the cache */
 	if (discard_index(r->index) < 0 || repo_read_index(r) < 0)
serve.c +1 -1
index 0db929beff..f6341206c4 100644
@@ -148,7 +148,7 @@ int has_capability(const struct strvec *keys, const char *capability,
 	int i;
 	for (i = 0; i < keys->nr; i++) {
 		const char *out;
-		if (skip_prefix(keys->items[i], capability, &out) &&
+		if (skip_prefix(keys->v[i], capability, &out) &&
 		    (!*out || *out == '=')) {
 			if (value) {
 				if (*out == '=')
strvec.c +15 -15
index 0e17597f80..21dce0a7a4 100644
@@ -6,25 +6,25 @@ const char *empty_strvec[] = { NULL };
 
 void strvec_init(struct strvec *array)
 {
-	array->items = empty_strvec;
+	array->v = empty_strvec;
 	array->nr = 0;
 	array->alloc = 0;
 }
 
 static void strvec_push_nodup(struct strvec *array, const char *value)
 {
-	if (array->items == empty_strvec)
-		array->items = NULL;
+	if (array->v == empty_strvec)
+		array->v = NULL;
 
-	ALLOC_GROW(array->items, array->nr + 2, array->alloc);
-	array->items[array->nr++] = value;
-	array->items[array->nr] = NULL;
+	ALLOC_GROW(array->v, array->nr + 2, array->alloc);
+	array->v[array->nr++] = value;
+	array->v[array->nr] = NULL;
 }
 
 const char *strvec_push(struct strvec *array, const char *value)
 {
 	strvec_push_nodup(array, xstrdup(value));
-	return array->items[array->nr - 1];
+	return array->v[array->nr - 1];
 }
 
 const char *strvec_pushf(struct strvec *array, const char *fmt, ...)
@@ -37,7 +37,7 @@ const char *strvec_pushf(struct strvec *array, const char *fmt, ...)
 	va_end(ap);
 
 	strvec_push_nodup(array, strbuf_detach(&v, NULL));
-	return array->items[array->nr - 1];
+	return array->v[array->nr - 1];
 }
 
 void strvec_pushl(struct strvec *array, ...)
@@ -61,8 +61,8 @@ void strvec_pop(struct strvec *array)
 {
 	if (!array->nr)
 		return;
-	free((char *)array->items[array->nr - 1]);
-	array->items[array->nr - 1] = NULL;
+	free((char *)array->v[array->nr - 1]);
+	array->v[array->nr - 1] = NULL;
 	array->nr--;
 }
 
@@ -88,21 +88,21 @@ void strvec_split(struct strvec *array, const char *to_split)
 
 void strvec_clear(struct strvec *array)
 {
-	if (array->items != empty_strvec) {
+	if (array->v != empty_strvec) {
 		int i;
 		for (i = 0; i < array->nr; i++)
-			free((char *)array->items[i]);
-		free(array->items);
+			free((char *)array->v[i]);
+		free(array->v);
 	}
 	strvec_init(array);
 }
 
 const char **strvec_detach(struct strvec *array)
 {
-	if (array->items == empty_strvec)
+	if (array->v == empty_strvec)
 		return xcalloc(1, sizeof(const char *));
 	else {
-		const char **ret = array->items;
+		const char **ret = array->v;
 		strvec_init(array);
 		return ret;
 	}
strvec.h +1 -1
index fda1c81c86..fdcad75b45 100644
@@ -28,7 +28,7 @@ extern const char *empty_strvec[];
  * NULL.
  */
 struct strvec {
-	const char **items;
+	const char **v;
 	int nr;
 	int alloc;
 };
submodule.c +6 -6
index 51fdb9c365..48d6dea78d 100644
@@ -269,7 +269,7 @@ int is_submodule_active(struct repository *repo, const char *path)
 			strvec_push(&args, item->string);
 		}
 
-		parse_pathspec(&ps, 0, 0, NULL, args.items);
+		parse_pathspec(&ps, 0, 0, NULL, args.v);
 		ret = match_pathspec(repo->index, &ps, path, strlen(path), 0, NULL, 1);
 
 		strvec_clear(&args);
@@ -842,7 +842,7 @@ static void collect_changed_submodules(struct repository *r,
 	const struct commit *commit;
 
 	repo_init_revisions(r, &rev, NULL);
-	setup_revisions(argv->nr, argv->items, &rev, NULL);
+	setup_revisions(argv->nr, argv->v, &rev, NULL);
 	if (prepare_revision_walk(&rev))
 		die(_("revision walk setup failed"));
 
@@ -1014,7 +1014,7 @@ int find_unpushed_submodules(struct repository *r,
 	struct string_list_item *name;
 	struct strvec argv = STRVEC_INIT;
 
-	/* argv.items[0] will be ignored by setup_revisions */
+	/* argv.v[0] will be ignored by setup_revisions */
 	strvec_push(&argv, "find_unpushed_submodules");
 	oid_array_for_each_unique(commits, append_oid_to_argv, &argv);
 	strvec_push(&argv, "--not");
@@ -1453,7 +1453,7 @@ static int get_next_submodule(struct child_process *cp,
 				strbuf_addf(err, _("Fetching submodule %s%s\n"),
 					    spf->prefix, ce->name);
 			strvec_init(&cp->args);
-			strvec_pushv(&cp->args, spf->args.items);
+			strvec_pushv(&cp->args, spf->args.v);
 			strvec_push(&cp->args, default_argv);
 			strvec_push(&cp->args, "--submodule-prefix");
 
@@ -1501,7 +1501,7 @@ static int get_next_submodule(struct child_process *cp,
 		cp->dir = task->repo->gitdir;
 
 		strvec_init(&cp->args);
-		strvec_pushv(&cp->args, spf->args.items);
+		strvec_pushv(&cp->args, spf->args.v);
 		strvec_push(&cp->args, "on-demand");
 		strvec_push(&cp->args, "--submodule-prefix");
 		strvec_push(&cp->args, submodule_prefix.buf);
@@ -1620,7 +1620,7 @@ int fetch_populated_submodules(struct repository *r,
 
 	strvec_push(&spf.args, "fetch");
 	for (i = 0; i < options->nr; i++)
-		strvec_push(&spf.args, options->items[i]);
+		strvec_push(&spf.args, options->v[i]);
 	strvec_push(&spf.args, "--recurse-submodules-default");
 	/* default value, "--submodule-prefix" and its value are added later */
 
t/helper/test-run-command.c +3 -3
index 605135be42..7ae03dc712 100644
@@ -275,13 +275,13 @@ static int quote_stress_test(int argc, const char **argv)
 		if (i < skip)
 			continue;
 
-		cp.argv = args.items;
+		cp.argv = args.v;
 		strbuf_reset(&out);
 		if (pipe_command(&cp, NULL, 0, &out, 0, NULL, 0) < 0)
 			return error("Failed to spawn child process");
 
 		for (j = 0, k = 0; j < arg_count; j++) {
-			const char *arg = args.items[j + arg_offset];
+			const char *arg = args.v[j + arg_offset];
 
 			if (strcmp(arg, out.buf + k))
 				ret = error("incorrectly quoted arg: '%s', "
@@ -298,7 +298,7 @@ static int quote_stress_test(int argc, const char **argv)
 			fprintf(stderr, "Trial #%d failed. Arguments:\n", i);
 			for (j = 0; j < arg_count; j++)
 				fprintf(stderr, "arg #%d: '%s'\n",
-					(int)j, args.items[j + arg_offset]);
+					(int)j, args.v[j + arg_offset]);
 
 			strbuf_release(&out);
 			strvec_clear(&args);
tmp-objdir.c +1 -1
index e21bef6cca..42ed4db5d3 100644
@@ -283,7 +283,7 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)
 {
 	if (!t)
 		return NULL;
-	return t->env.items;
+	return t->env.v;
 }
 
 void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)
transport-helper.c +1 -1
index 51b72a224d..0029ba18bd 100644
@@ -138,7 +138,7 @@ static struct child_process *get_helper(struct transport *transport)
 		strvec_pushf(&helper->env_array, "%s=%s",
 			     GIT_DIR_ENVIRONMENT, get_git_dir());
 
-	helper->trace2_child_class = helper->args.items[0]; /* "remote-<name>" */
+	helper->trace2_child_class = helper->args.v[0]; /* "remote-<name>" */
 
 	code = start_command(helper);
 	if (code < 0 && errno == ENOENT)
upload-pack.c +1 -1
index bf677df48c..dd37000b23 100644
@@ -906,7 +906,7 @@ static int send_shallow_list(struct upload_pack_data *data)
 			struct object *o = data->want_obj.objects[i].item;
 			strvec_push(&av, oid_to_hex(&o->oid));
 		}
-		deepen_by_rev_list(data, av.nr, av.items);
+		deepen_by_rev_list(data, av.nr, av.v);
 		strvec_clear(&av);
 		ret = 1;
 	} else {
#17 lore raw

Re: [PATCH 10/11] strvec: drop argv_array compatibility layer

Quoted 9 lines · Jeff King

And here's a diff between your current "seen" tip and what I get by merging in this updated version and then doing any necessary resolution or fixups on top. I'll leave it as an exercise for how you might want to pull the content across. :)

I do note that most of the new call-sites are ones that would be better off using child_process.args, and reviewers (myself and others) have suggested that. So those direct uses of the "argv" member may go away anyway.

Yup, I do not think we should spend too much cycles on this at this point, as Stolee's topic and others that add new callsites are likely to be rerolled at least one more time.

It is tempting to declare that these 11 patches are now perfect and we'll stop the world and fast-track it down to 'master', while discarding any and all topics in flight that changes anything related to argv-array, and then we ask authors of these discarded topics to send in a rebase on top of the 'master' with strvec API already in. But I somehow think we do not have to take such a drastic measure to adjust the world around this topic ;-)

#18 lore raw

Re: [PATCH 10/11] strvec: drop argv_array compatibility layer

Quoted 7 lines · Junio C Hamano
Quoted 5 lines · Jeff King

And here's a diff between your current "seen" tip and what I get by merging in this updated version and then doing any necessary resolution or fixups on top. I'll leave it as an exercise for how you might want to pull the content across. :)

Quoted 8 lines
Quoted 4 lines

I do note that most of the new call-sites are ones that would be better off using child_process.args, and reviewers (myself and others) have suggested that. So those direct uses of the "argv" member may go away anyway.

Yup, I do not think we should spend too much cycles on this at this point, as Stolee's topic and others that add new callsites are likely to be rerolled at least one more time.

Yes, I immediately thought that my topic would cause some headache for this conversion. However, I'm happy to rebase onto 'master' if this topic is merging quickly.

Quoted 7 lines

It is tempting to declare that these 11 patches are now perfect and we'll stop the world and fast-track it down to 'master', while discarding any and all topics in flight that changes anything related to argv-array, and then we ask authors of these discarded topics to send in a rebase on top of the 'master' with strvec API already in. But I somehow think we do not have to take such a drastic measure to adjust the world around this topic ;-)

I'll keep an eye out for how you plan to resolve this.

Thanks,
-Stolee

#19 lore raw

Re: [PATCH 10/11] strvec: drop argv_array compatibility layer

In reply to Jeff King
Quoted 3 lines · Jeff King

Worse than the resolutions are all the new calls which needed to be fixed up. I know your scripts keep a fix-up commit for this, but I don't think you publish it.

They are found in refs/merge-fix/$topicname, and the broken-out mirror repository https://github.com/gitster/git/ should have them.

author
#20 lore raw

Re: [PATCH 10/11] strvec: drop argv_array compatibility layer

Quoted 8 lines · Junio C Hamano
Quoted 3 lines · Jeff King

Worse than the resolutions are all the new calls which needed to be fixed up. I know your scripts keep a fix-up commit for this, but I don't think you publish it.

They are found in refs/merge-fix/$topicname, and the broken-out mirror repository https://github.com/gitster/git/ should have them.

Oh indeed. I stupidly looked in my refs/remotes, but of course I didn't set up a refspec to fetch them. :)

-Peff

author
#21 lore raw

PATCH 11/11 strvec: rename struct fields

In reply to Jeff King

The "argc" and "argv" names made sense when the struct was argv_array, but now they're just confusing. Let's rename them to our usual "nr" and "items" (which we use for string_list, as well as many ALLOC_GROW() arrays).

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.

---
I'm actually not that fond of "items". I almost went with just:

const char **v;

as the variable name which contains it usually provides sufficient context. But I worried that people would consider that too inscrutable.

 add-interactive.c           |  4 ++--
 add-patch.c                 |  8 +++----
 bisect.c                    |  2 +-
 builtin/add.c               |  2 +-
 builtin/am.c                | 16 +++++++-------
 builtin/annotate.c          |  2 +-
 builtin/bisect--helper.c    |  4 ++--
 builtin/clone.c             |  4 ++--
 builtin/commit.c            |  2 +-
 builtin/describe.c          |  6 ++---
 builtin/difftool.c          |  2 +-
 builtin/fetch.c             |  6 ++---
 builtin/gc.c                | 24 ++++++++++----------
 builtin/pack-objects.c      |  2 +-
 builtin/pull.c              | 16 +++++++-------
 builtin/rebase.c            | 16 +++++++-------
 builtin/receive-pack.c      | 14 ++++++------
 builtin/remote.c            |  4 ++--
 builtin/replace.c           |  2 +-
 builtin/show-branch.c       |  8 +++----
 builtin/stash.c             |  8 +++----
 builtin/submodule--helper.c |  6 ++---
 builtin/upload-archive.c    |  4 ++--
 builtin/worktree.c          |  6 ++---
 bundle.c                    |  2 +-
 commit.c                    |  2 +-
 connect.c                   | 16 +++++++-------
 daemon.c                    |  8 +++----
 diff.c                      |  2 +-
 environment.c               |  2 +-
 exec-cmd.c                  |  6 ++---
 git.c                       | 10 ++++-----
 graph.c                     |  4 ++--
 http-push.c                 |  2 +-
 ls-refs.c                   |  6 ++---
 merge.c                     |  2 +-
 pathspec.c                  |  2 +-
 range-diff.c                |  2 +-
 ref-filter.c                |  4 ++--
 remote-curl.c               |  6 ++---
 remote.c                    |  2 +-
 revision.c                  |  4 ++--
 run-command.c               | 20 ++++++++---------
 sequencer.c                 |  4 ++--
 serve.c                     |  6 ++---
 strvec.c                    | 44 ++++++++++++++++++-------------------
 strvec.h                    | 20 ++++++++---------
 submodule.c                 | 14 ++++++------
 t/helper/test-run-command.c |  8 +++----
 tmp-objdir.c                |  2 +-
 transport-helper.c          |  2 +-
 upload-pack.c               |  2 +-
 52 files changed, 186 insertions(+), 186 deletions(-)
add-interactive.c +2 -2
index 458f3a3e69..659289905c 100644
@@ -944,7 +944,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps,
 					    files->items.items[i].string);
 		parse_pathspec(&ps_selected,
 			       PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
-			       PATHSPEC_LITERAL_PATH, "", args.argv);
+			       PATHSPEC_LITERAL_PATH, "", args.items);
 		res = run_add_p(s->r, ADD_P_ADD, NULL, &ps_selected);
 		strvec_clear(&args);
 		clear_pathspec(&ps_selected);
@@ -986,7 +986,7 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
 			if (files->selected[i])
 				strvec_push(&args,
 					    files->items.items[i].string);
-		res = run_command_v_opt(args.argv, 0);
+		res = run_command_v_opt(args.items, 0);
 		strvec_clear(&args);
 	}
 
add-patch.c +4 -4
index 8c0772803b..df170d29ef 100644
@@ -391,14 +391,14 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 			    get_oid("HEAD", &oid) ?
 			    empty_tree_oid_hex() : s->revision);
 	}
-	color_arg_index = args.argc;
+	color_arg_index = args.nr;
 	/* Use `--no-color` explicitly, just in case `diff.color = always`. */
 	strvec_pushl(&args, "--no-color", "-p", "--", NULL);
 	for (i = 0; i < ps->nr; i++)
 		strvec_push(&args, ps->items[i].original);
 
 	setup_child_process(s, &cp, NULL);
-	cp.argv = args.argv;
+	cp.argv = args.items;
 	res = capture_command(&cp, plain, 0);
 	if (res) {
 		strvec_clear(&args);
@@ -415,8 +415,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
 		const char *diff_filter = s->s.interactive_diff_filter;
 
 		setup_child_process(s, &colored_cp, NULL);
-		xsnprintf((char *)args.argv[color_arg_index], 8, "--color");
-		colored_cp.argv = args.argv;
+		xsnprintf((char *)args.items[color_arg_index], 8, "--color");
+		colored_cp.argv = args.items;
 		colored = &s->colored;
 		res = capture_command(&colored_cp, colored, 0);
 		strvec_clear(&args);
bisect.c +1 -1
index 99ff694960..5d4ba23ba7 100644
@@ -649,7 +649,7 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs,
 	if (read_paths)
 		read_bisect_paths(&rev_argv);
 
-	setup_revisions(rev_argv.argc, rev_argv.argv, revs, NULL);
+	setup_revisions(rev_argv.nr, rev_argv.items, revs, NULL);
 	/* XXX leak rev_argv, as "revs" may still be pointing to it */
 }
 
builtin/add.c +1 -1
index 6185dd12a8..eb6457da05 100644
@@ -228,7 +228,7 @@ int run_add_interactive(const char *revision, const char *patch_mode,
 		/* pass original pathspec, to be re-parsed */
 		strvec_push(&argv, pathspec->items[i].original);
 
-	status = run_command_v_opt(argv.argv, RUN_GIT_CMD);
+	status = run_command_v_opt(argv.items, RUN_GIT_CMD);
 	strvec_clear(&argv);
 	return status;
 }
builtin/am.c +8 -8
index 992ab3ca27..3f2adb3822 100644
@@ -812,7 +812,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
 	strbuf_release(&sb);
 	free(series_dir_buf);
 
-	ret = split_mail_conv(stgit_patch_to_mail, state, patches.argv, keep_cr);
+	ret = split_mail_conv(stgit_patch_to_mail, state, patches.items, keep_cr);
 
 	strvec_clear(&patches);
 	return ret;
@@ -1002,7 +1002,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
 	}
 	write_state_text(state, "scissors", str);
 
-	sq_quote_argv(&sb, state->git_apply_opts.argv);
+	sq_quote_argv(&sb, state->git_apply_opts.items);
 	write_state_text(state, "apply-opt", sb.buf);
 
 	if (state->rebasing)
@@ -1401,9 +1401,9 @@ static int run_apply(const struct am_state *state, const char *index_file)
 		BUG("init_apply_state() failed");
 
 	strvec_push(&apply_opts, "apply");
-	strvec_pushv(&apply_opts, state->git_apply_opts.argv);
+	strvec_pushv(&apply_opts, state->git_apply_opts.items);
 
-	opts_left = apply_parse_options(apply_opts.argc, apply_opts.argv,
+	opts_left = apply_parse_options(apply_opts.nr, apply_opts.items,
 					&apply_state, &force_apply, &options,
 					NULL);
 
@@ -1428,7 +1428,7 @@ static int run_apply(const struct am_state *state, const char *index_file)
 
 	strvec_push(&apply_paths, am_path(state, "patch"));
 
-	res = apply_all_patches(&apply_state, apply_paths.argc, apply_paths.argv, options);
+	res = apply_all_patches(&apply_state, apply_paths.nr, apply_paths.items, options);
 
 	strvec_clear(&apply_paths);
 	strvec_clear(&apply_opts);
@@ -1455,7 +1455,7 @@ static int build_fake_ancestor(const struct am_state *state, const char *index_f
 
 	cp.git_cmd = 1;
 	strvec_push(&cp.args, "apply");
-	strvec_pushv(&cp.args, state->git_apply_opts.argv);
+	strvec_pushv(&cp.args, state->git_apply_opts.items);
 	strvec_pushf(&cp.args, "--build-fake-ancestor=%s", index_file);
 	strvec_push(&cp.args, am_path(state, "patch"));
 
@@ -2376,10 +2376,10 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 				strvec_push(&paths, mkpath("%s/%s", prefix, argv[i]));
 		}
 
-		if (state.interactive && !paths.argc)
+		if (state.interactive && !paths.nr)
 			die(_("interactive mode requires patches on the command line"));
 
-		am_setup(&state, patch_format, paths.argv, keep_cr);
+		am_setup(&state, patch_format, paths.items, keep_cr);
 
 		strvec_clear(&paths);
 	}
builtin/annotate.c +1 -1
index 7b7ecd366d..b9ab710740 100644
@@ -18,5 +18,5 @@ int cmd_annotate(int argc, const char **argv, const char *prefix)
 		strvec_push(&args, argv[i]);
 	}
 
-	return cmd_blame(args.argc, args.argv, prefix);
+	return cmd_blame(args.nr, args.items, prefix);
 }
builtin/bisect--helper.c +2 -2
index dd52878413..945641ea54 100644
@@ -168,7 +168,7 @@ static int bisect_reset(const char *commit)
 		struct strvec argv = STRVEC_INIT;
 
 		strvec_pushl(&argv, "checkout", branch.buf, "--", NULL);
-		if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
+		if (run_command_v_opt(argv.items, RUN_GIT_CMD)) {
 			error(_("could not check out original"
 				" HEAD '%s'. Try 'git bisect"
 				" reset <commit>'."), branch.buf);
@@ -530,7 +530,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
 
 			strvec_pushl(&argv, "checkout", start_head.buf,
 				     "--", NULL);
-			if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
+			if (run_command_v_opt(argv.items, RUN_GIT_CMD)) {
 				res = error(_("checking out '%s' failed."
 						 " Try 'git bisect start "
 						 "<valid-branch>'."),
builtin/clone.c +2 -2
index e26bd82dc4..e9712c383c 100644
@@ -752,7 +752,7 @@ static int git_sparse_checkout_init(const char *repo)
 	 */
 	core_apply_sparse_checkout = 1;
 
-	if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
+	if (run_command_v_opt(argv.items, RUN_GIT_CMD)) {
 		error(_("failed to initialize sparse-checkout"));
 		result = 1;
 	}
@@ -844,7 +844,7 @@ static int checkout(int submodule_progress)
 					       "--single-branch" :
 					       "--no-single-branch");
 
-		err = run_command_v_opt(args.argv, RUN_GIT_CMD);
+		err = run_command_v_opt(args.items, RUN_GIT_CMD);
 		strvec_clear(&args);
 	}
 
builtin/commit.c +1 -1
index c3f4067537..01105ce8b0 100644
@@ -1008,7 +1008,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		struct strvec env = STRVEC_INIT;
 
 		strvec_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
-		if (launch_editor(git_path_commit_editmsg(), NULL, env.argv)) {
+		if (launch_editor(git_path_commit_editmsg(), NULL, env.items)) {
 			fprintf(stderr,
 			_("Please supply the message using either -m or -F option.\n"));
 			exit(1);
builtin/describe.c +3 -3
index e3cac8002c..85c1504065 100644
@@ -509,7 +509,7 @@ static void describe_blob(struct object_id oid, struct strbuf *dst)
 		     NULL);
 
 	repo_init_revisions(the_repository, &revs, NULL);
-	if (setup_revisions(args.argc, args.argv, &revs, NULL) > 1)
+	if (setup_revisions(args.nr, args.items, &revs, NULL) > 1)
 		BUG("setup_revisions could not handle all args?");
 
 	if (prepare_revision_walk(&revs))
@@ -613,7 +613,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 			strvec_pushv(&args, argv);
 		else
 			strvec_push(&args, "HEAD");
-		return cmd_name_rev(args.argc, args.argv, prefix);
+		return cmd_name_rev(args.nr, args.items, prefix);
 	}
 
 	hashmap_init(&names, commit_name_neq, NULL, 0);
@@ -659,7 +659,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 
 			repo_init_revisions(the_repository, &revs, prefix);
 			strvec_pushv(&args, diff_index_args);
-			if (setup_revisions(args.argc, args.argv, &revs, NULL) != 1)
+			if (setup_revisions(args.nr, args.items, &revs, NULL) != 1)
 				BUG("malformed internal diff-index command line");
 			result = run_diff_index(&revs, 0);
 
builtin/difftool.c +1 -1
index 5ac021a1d4..78ea697325 100644
@@ -683,7 +683,7 @@ static int run_file_diff(int prompt, const char *prefix,
 	strvec_push(&args, "diff");
 	for (i = 0; i < argc; i++)
 		strvec_push(&args, argv[i]);
-	ret = run_command_v_opt_cd_env(args.argv, RUN_GIT_CMD, prefix, env);
+	ret = run_command_v_opt_cd_env(args.items, RUN_GIT_CMD, prefix, env);
 	exit(ret);
 }
 
builtin/fetch.c +3 -3
index c2e7afeb6a..7953a1a25b 100644
@@ -1354,7 +1354,7 @@ static int do_fetch(struct transport *transport,
 
 	if (tags == TAGS_SET || tags == TAGS_DEFAULT) {
 		must_list_refs = 1;
-		if (ref_prefixes.argc)
+		if (ref_prefixes.nr)
 			strvec_push(&ref_prefixes, "refs/tags/");
 	}
 
@@ -1605,7 +1605,7 @@ static int fetch_multiple(struct string_list *list, int max_children)
 	add_options_to_argv(&argv);
 
 	if (max_children != 1 && list->nr != 1) {
-		struct parallel_fetch_state state = { argv.argv, list, 0, 0 };
+		struct parallel_fetch_state state = { argv.items, list, 0, 0 };
 
 		strvec_push(&argv, "--end-of-options");
 		result = run_processes_parallel_tr2(max_children,
@@ -1623,7 +1623,7 @@ static int fetch_multiple(struct string_list *list, int max_children)
 			strvec_push(&argv, name);
 			if (verbosity >= 0)
 				printf(_("Fetching %s\n"), name);
-			if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
+			if (run_command_v_opt(argv.items, RUN_GIT_CMD)) {
 				error(_("Could not fetch %s"), name);
 				result = 1;
 			}
builtin/gc.c +12 -12
index 98719800a3..10346e0465 100644
@@ -514,11 +514,11 @@ static void gc_before_repack(void)
 	if (done++)
 		return;
 
-	if (pack_refs && run_command_v_opt(pack_refs_cmd.argv, RUN_GIT_CMD))
-		die(FAILED_RUN, pack_refs_cmd.argv[0]);
+	if (pack_refs && run_command_v_opt(pack_refs_cmd.items, RUN_GIT_CMD))
+		die(FAILED_RUN, pack_refs_cmd.items[0]);
 
-	if (prune_reflogs && run_command_v_opt(reflog.argv, RUN_GIT_CMD))
-		die(FAILED_RUN, reflog.argv[0]);
+	if (prune_reflogs && run_command_v_opt(reflog.items, RUN_GIT_CMD))
+		die(FAILED_RUN, reflog.items[0]);
 }
 
 int cmd_gc(int argc, const char **argv, const char *prefix)
@@ -653,8 +653,8 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
 
 	if (!repository_format_precious_objects) {
 		close_object_store(the_repository->objects);
-		if (run_command_v_opt(repack.argv, RUN_GIT_CMD))
-			die(FAILED_RUN, repack.argv[0]);
+		if (run_command_v_opt(repack.items, RUN_GIT_CMD))
+			die(FAILED_RUN, repack.items[0]);
 
 		if (prune_expire) {
 			strvec_push(&prune, prune_expire);
@@ -663,19 +663,19 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
 			if (has_promisor_remote())
 				strvec_push(&prune,
 					    "--exclude-promisor-objects");
-			if (run_command_v_opt(prune.argv, RUN_GIT_CMD))
-				die(FAILED_RUN, prune.argv[0]);
+			if (run_command_v_opt(prune.items, RUN_GIT_CMD))
+				die(FAILED_RUN, prune.items[0]);
 		}
 	}
 
 	if (prune_worktrees_expire) {
 		strvec_push(&prune_worktrees, prune_worktrees_expire);
-		if (run_command_v_opt(prune_worktrees.argv, RUN_GIT_CMD))
-			die(FAILED_RUN, prune_worktrees.argv[0]);
+		if (run_command_v_opt(prune_worktrees.items, RUN_GIT_CMD))
+			die(FAILED_RUN, prune_worktrees.items[0]);
 	}
 
-	if (run_command_v_opt(rerere.argv, RUN_GIT_CMD))
-		die(FAILED_RUN, rerere.argv[0]);
+	if (run_command_v_opt(rerere.items, RUN_GIT_CMD))
+		die(FAILED_RUN, rerere.items[0]);
 
 	report_garbage = report_pack_garbage;
 	reprepare_packed_git(the_repository);
builtin/pack-objects.c +1 -1
index 323f8bce80..492a61aed0 100644
@@ -3704,7 +3704,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 	if (!use_internal_rev_list)
 		read_object_list_from_stdin();
 	else {
-		get_object_list(rp.argc, rp.argv);
+		get_object_list(rp.nr, rp.items);
 		strvec_clear(&rp);
 	}
 	cleanup_preferred_base();
builtin/pull.c +8 -8
index dae8766646..858b492af3 100644
@@ -584,14 +584,14 @@ static int run_fetch(const char *repo, const char **refspecs)
 		strvec_push(&args, "--no-show-forced-updates");
 	if (set_upstream)
 		strvec_push(&args, set_upstream);
-	strvec_pushv(&args, opt_fetch.argv);
+	strvec_pushv(&args, opt_fetch.items);
 
 	if (repo) {
 		strvec_push(&args, repo);
 		strvec_pushv(&args, refspecs);
 	} else if (*refspecs)
 		BUG("refspecs without repo?");
-	ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
+	ret = run_command_v_opt(args.items, RUN_GIT_CMD);
 	strvec_clear(&args);
 	return ret;
 }
@@ -691,8 +691,8 @@ static int run_merge(void)
 		strvec_push(&args, opt_ff);
 	if (opt_verify_signatures)
 		strvec_push(&args, opt_verify_signatures);
-	strvec_pushv(&args, opt_strategies.argv);
-	strvec_pushv(&args, opt_strategy_opts.argv);
+	strvec_pushv(&args, opt_strategies.items);
+	strvec_pushv(&args, opt_strategy_opts.items);
 	if (opt_gpg_sign)
 		strvec_push(&args, opt_gpg_sign);
 	if (opt_autostash == 0)
@@ -703,7 +703,7 @@ static int run_merge(void)
 		strvec_push(&args, "--allow-unrelated-histories");
 
 	strvec_push(&args, "FETCH_HEAD");
-	ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
+	ret = run_command_v_opt(args.items, RUN_GIT_CMD);
 	strvec_clear(&args);
 	return ret;
 }
@@ -882,8 +882,8 @@ static int run_rebase(const struct object_id *curr_head,
 		strvec_push(&args, "--interactive");
 	if (opt_diffstat)
 		strvec_push(&args, opt_diffstat);
-	strvec_pushv(&args, opt_strategies.argv);
-	strvec_pushv(&args, opt_strategy_opts.argv);
+	strvec_pushv(&args, opt_strategies.items);
+	strvec_pushv(&args, opt_strategy_opts.items);
 	if (opt_gpg_sign)
 		strvec_push(&args, opt_gpg_sign);
 	if (opt_autostash == 0)
@@ -902,7 +902,7 @@ static int run_rebase(const struct object_id *curr_head,
 	else
 		strvec_push(&args, oid_to_hex(merge_head));
 
-	ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
+	ret = run_command_v_opt(args.items, RUN_GIT_CMD);
 	strvec_clear(&args);
 	return ret;
 }
builtin/rebase.c +8 -8
index 35aeb8effc..494107a648 100644
@@ -351,7 +351,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
 			     oid_to_hex(&opts->restrict_revision->object.oid));
 
 	ret = sequencer_make_script(the_repository, &todo_list.buf,
-				    make_script_args.argc, make_script_args.argv,
+				    make_script_args.nr, make_script_args.items,
 				    flags);
 
 	if (ret)
@@ -900,7 +900,7 @@ static int run_am(struct rebase_options *opts)
 		return status;
 	}
 
-	strvec_pushv(&am.args, opts->git_am_opts.argv);
+	strvec_pushv(&am.args, opts->git_am_opts.items);
 	strvec_push(&am.args, "--rebasing");
 	strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
 	strvec_push(&am.args, "--patch-format=mboxrd");
@@ -969,7 +969,7 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action)
 	add_var(&script_snippet, "revisions", opts->revisions);
 	add_var(&script_snippet, "restrict_revision", opts->restrict_revision ?
 		oid_to_hex(&opts->restrict_revision->object.oid) : NULL);
-	sq_quote_argv_pretty(&buf, opts->git_am_opts.argv);
+	sq_quote_argv_pretty(&buf, opts->git_am_opts.items);
 	add_var(&script_snippet, "git_am_opt", buf.buf);
 	strbuf_release(&buf);
 	add_var(&script_snippet, "verbose",
@@ -1625,8 +1625,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		allow_preemptive_ff = 0;
 	}
 
-	for (i = 0; i < options.git_am_opts.argc; i++) {
-		const char *option = options.git_am_opts.argv[i], *p;
+	for (i = 0; i < options.git_am_opts.nr; i++) {
+		const char *option = options.git_am_opts.items[i], *p;
 		if (!strcmp(option, "--committer-date-is-author-date") ||
 		    !strcmp(option, "--ignore-date") ||
 		    !strcmp(option, "--whitespace=fix") ||
@@ -1721,10 +1721,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	if (isatty(2) && options.flags & REBASE_NO_QUIET)
 		strbuf_addstr(&options.git_format_patch_opt, " --progress");
 
-	if (options.git_am_opts.argc || options.type == REBASE_APPLY) {
+	if (options.git_am_opts.nr || options.type == REBASE_APPLY) {
 		/* all am options except -q are compatible only with --apply */
-		for (i = options.git_am_opts.argc - 1; i >= 0; i--)
-			if (strcmp(options.git_am_opts.argv[i], "-q"))
+		for (i = options.git_am_opts.nr - 1; i >= 0; i--)
+			if (strcmp(options.git_am_opts.items[i], "-q"))
 				break;
 
 		if (i >= 0) {
builtin/receive-pack.c +7 -7
index 1fc69cf5bc..8747a4e91f 100644
@@ -950,7 +950,7 @@ static const char *push_to_deploy(unsigned char *sha1,
 	struct child_process child = CHILD_PROCESS_INIT;
 
 	child.argv = update_refresh;
-	child.env = env->argv;
+	child.env = env->items;
 	child.dir = work_tree;
 	child.no_stdin = 1;
 	child.stdout_to_stderr = 1;
@@ -961,7 +961,7 @@ static const char *push_to_deploy(unsigned char *sha1,
 	/* run_command() does not clean up completely; reinitialize */
 	child_process_init(&child);
 	child.argv = diff_files;
-	child.env = env->argv;
+	child.env = env->items;
 	child.dir = work_tree;
 	child.no_stdin = 1;
 	child.stdout_to_stderr = 1;
@@ -974,7 +974,7 @@ static const char *push_to_deploy(unsigned char *sha1,
 
 	child_process_init(&child);
 	child.argv = diff_index;
-	child.env = env->argv;
+	child.env = env->items;
 	child.no_stdin = 1;
 	child.no_stdout = 1;
 	child.stdout_to_stderr = 0;
@@ -985,7 +985,7 @@ static const char *push_to_deploy(unsigned char *sha1,
 	read_tree[3] = hash_to_hex(sha1);
 	child_process_init(&child);
 	child.argv = read_tree;
-	child.env = env->argv;
+	child.env = env->items;
 	child.dir = work_tree;
 	child.no_stdin = 1;
 	child.no_stdout = 1;
@@ -1004,7 +1004,7 @@ static const char *push_to_checkout(unsigned char *hash,
 				    const char *work_tree)
 {
 	strvec_pushf(env, "GIT_WORK_TREE=%s", absolute_path(work_tree));
-	if (run_hook_le(env->argv, push_to_checkout_hook,
+	if (run_hook_le(env->items, push_to_checkout_hook,
 			hash_to_hex(hash), NULL))
 		return "push-to-checkout hook declined";
 	else
@@ -1205,11 +1205,11 @@ static void run_update_post_hook(struct command *commands)
 	for (cmd = commands; cmd; cmd = cmd->next) {
 		if (cmd->error_string || cmd->did_not_exist)
 			continue;
-		if (!proc.args.argc)
+		if (!proc.args.nr)
 			strvec_push(&proc.args, hook);
 		strvec_push(&proc.args, cmd->ref_name);
 	}
-	if (!proc.args.argc)
+	if (!proc.args.nr)
 		return;
 
 	proc.no_stdin = 1;
builtin/remote.c +2 -2
index a3b33c2c88..9a98e77a5e 100644
@@ -1470,15 +1470,15 @@ static int update(int argc, const char **argv)
 	for (i = 1; i < argc; i++)
 		strvec_push(&fetch_argv, argv[i]);
 
-	if (strcmp(fetch_argv.argv[fetch_argv.argc-1], "default") == 0) {
+	if (strcmp(fetch_argv.items[fetch_argv.nr-1], "default") == 0) {
 		git_config(get_remote_default, &default_defined);
 		if (!default_defined) {
 			strvec_pop(&fetch_argv);
 			strvec_push(&fetch_argv, "--all");
 		}
 	}
 
-	retval = run_command_v_opt(fetch_argv.argv, RUN_GIT_CMD);
+	retval = run_command_v_opt(fetch_argv.items, RUN_GIT_CMD);
 	strvec_clear(&fetch_argv);
 	return retval;
 }
builtin/replace.c +1 -1
index 7bc5d66ed9..038b7f874b 100644
@@ -513,7 +513,7 @@ static int convert_graft_file(int force)
 			continue;
 
 		strvec_split(&args, buf.buf);
-		if (args.argc && create_graft(args.argc, args.argv, force, 1))
+		if (args.nr && create_graft(args.nr, args.items, force, 1))
 			strbuf_addf(&err, "\n\t%s", buf.buf);
 		strvec_clear(&args);
 	}
builtin/show-branch.c +4 -4
index 4c918ce90d..de27703297 100644
@@ -561,7 +561,7 @@ static int git_show_branch_config(const char *var, const char *value, void *cb)
 		 * default_arg is now passed to parse_options(), so we need to
 		 * mimic the real argv a bit better.
 		 */
-		if (!default_args.argc)
+		if (!default_args.nr)
 			strvec_push(&default_args, "show-branch");
 		strvec_push(&default_args, value);
 		return 0;
@@ -684,9 +684,9 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 	git_config(git_show_branch_config, NULL);
 
 	/* If nothing is specified, try the default first */
-	if (ac == 1 && default_args.argc) {
-		ac = default_args.argc;
-		av = default_args.argv;
+	if (ac == 1 && default_args.nr) {
+		ac = default_args.nr;
+		av = default_args.items;
 	}
 
 	ac = parse_options(ac, av, prefix, builtin_show_branch_options,
builtin/stash.c +4 -4
index bfdbafae89..0134c6b0d6 100644
@@ -745,7 +745,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
 			strvec_push(&revision_args, argv[i]);
 	}
 
-	ret = get_stash_info(&info, stash_args.argc, stash_args.argv);
+	ret = get_stash_info(&info, stash_args.nr, stash_args.items);
 	strvec_clear(&stash_args);
 	if (ret)
 		return -1;
@@ -754,7 +754,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
 	 * The config settings are applied only if there are not passed
 	 * any options.
 	 */
-	if (revision_args.argc == 1) {
+	if (revision_args.nr == 1) {
 		if (show_stat)
 			rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT;
 
@@ -767,7 +767,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
 		}
 	}
 
-	argc = setup_revisions(revision_args.argc, revision_args.argv, &rev, NULL);
+	argc = setup_revisions(revision_args.nr, revision_args.items, &rev, NULL);
 	if (argc > 1) {
 		free_stash_info(&info);
 		usage_with_options(git_stash_show_usage, options);
@@ -1611,5 +1611,5 @@ int cmd_stash(int argc, const char **argv, const char *prefix)
 	/* Assume 'stash push' */
 	strvec_push(&args, "push");
 	strvec_pushv(&args, argv);
-	return !!push_stash(args.argc, args.argv, prefix, 1);
+	return !!push_stash(args.nr, args.items, prefix, 1);
 }
builtin/submodule--helper.c +3 -3
index 665db1ffed..6bbed9f92a 100644
@@ -817,9 +817,9 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
 
 	repo_init_revisions(the_repository, &rev, NULL);
 	rev.abbrev = 0;
-	diff_files_args.argc = setup_revisions(diff_files_args.argc,
-					       diff_files_args.argv,
-					       &rev, NULL);
+	diff_files_args.nr = setup_revisions(diff_files_args.nr,
+					     diff_files_args.items,
+					     &rev, NULL);
 	diff_files_result = run_diff_files(&rev, 0);
 
 	if (!diff_result_code(&rev.diffopt, diff_files_result)) {
builtin/upload-archive.c +2 -2
index f02bb0ea15..8ded611092 100644
@@ -36,7 +36,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
 		char *buf = packet_read_line(0, NULL);
 		if (!buf)
 			break;	/* got a flush */
-		if (sent_argv.argc > MAX_ARGS)
+		if (sent_argv.nr > MAX_ARGS)
 			die("Too many options (>%d)", MAX_ARGS - 1);
 
 		if (!starts_with(buf, arg_cmd))
@@ -45,7 +45,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
 	}
 
 	/* parse all options sent by the client */
-	return write_archive(sent_argv.argc, sent_argv.argv, prefix,
+	return write_archive(sent_argv.nr, sent_argv.items, prefix,
 			     the_repository, NULL, 1);
 }
 
builtin/worktree.c +3 -3
index be5d84f0a0..1d6b9455da 100644
@@ -422,7 +422,7 @@ static int add_worktree(const char *path, const char *refname,
 			strvec_push(&cp.args, "--quiet");
 	}
 
-	cp.env = child_env.argv;
+	cp.env = child_env.items;
 	ret = run_command(&cp);
 	if (ret)
 		goto done;
@@ -433,7 +433,7 @@ static int add_worktree(const char *path, const char *refname,
 		strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
 		if (opts->quiet)
 			strvec_push(&cp.args, "--quiet");
-		cp.env = child_env.argv;
+		cp.env = child_env.items;
 		ret = run_command(&cp);
 		if (ret)
 			goto done;
@@ -943,7 +943,7 @@ static void check_clean_worktree(struct worktree *wt,
 	strvec_pushl(&cp.args, "status",
 		     "--porcelain", "--ignore-submodules=none",
 		     NULL);
-	cp.env = child_env.argv;
+	cp.env = child_env.items;
 	cp.git_cmd = 1;
 	cp.dir = wt->path;
 	cp.out = -1;
bundle.c +1 -1
index 565d05367f..2ba2277ef0 100644
@@ -278,7 +278,7 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *
 		     "pack-objects",
 		     "--stdout", "--thin", "--delta-base-offset",
 		     NULL);
-	strvec_pushv(&pack_objects.args, pack_options->argv);
+	strvec_pushv(&pack_objects.args, pack_options->items);
 	pack_objects.in = -1;
 	pack_objects.out = bundle_fd;
 	pack_objects.git_cmd = 1;
commit.c +1 -1
index a5176a25bd..c8fd6931a6 100644
@@ -1643,7 +1643,7 @@ int run_commit_hook(int editor_is_used, const char *index_file,
 		strvec_push(&hook_env, "GIT_EDITOR=:");
 
 	va_start(args, name);
-	ret = run_hook_ve(hook_env.argv,name, args);
+	ret = run_hook_ve(hook_env.items, name, args);
 	va_end(args);
 	strvec_clear(&hook_env);
 
connect.c +8 -8
index 3299ea956a..e3a08179d4 100644
@@ -70,9 +70,9 @@ int server_supports_v2(const char *c, int die_on_error)
 {
 	int i;
 
-	for (i = 0; i < server_capabilities_v2.argc; i++) {
+	for (i = 0; i < server_capabilities_v2.nr; i++) {
 		const char *out;
-		if (skip_prefix(server_capabilities_v2.argv[i], c, &out) &&
+		if (skip_prefix(server_capabilities_v2.items[i], c, &out) &&
 		    (!*out || *out == '='))
 			return 1;
 	}
@@ -87,9 +87,9 @@ int server_feature_v2(const char *c, const char **v)
 {
 	int i;
 
-	for (i = 0; i < server_capabilities_v2.argc; i++) {
+	for (i = 0; i < server_capabilities_v2.nr; i++) {
 		const char *out;
-		if (skip_prefix(server_capabilities_v2.argv[i], c, &out) &&
+		if (skip_prefix(server_capabilities_v2.items[i], c, &out) &&
 		    (*out == '=')) {
 			*v = out + 1;
 			return 1;
@@ -103,9 +103,9 @@ int server_supports_feature(const char *c, const char *feature,
 {
 	int i;
 
-	for (i = 0; i < server_capabilities_v2.argc; i++) {
+	for (i = 0; i < server_capabilities_v2.nr; i++) {
 		const char *out;
-		if (skip_prefix(server_capabilities_v2.argv[i], c, &out) &&
+		if (skip_prefix(server_capabilities_v2.items[i], c, &out) &&
 		    (!*out || *(out++) == '=')) {
 			if (parse_feature_request(out, feature))
 				return 1;
@@ -488,9 +488,9 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
 	if (!for_push)
 		packet_write_fmt(fd_out, "peel\n");
 	packet_write_fmt(fd_out, "symrefs\n");
-	for (i = 0; ref_prefixes && i < ref_prefixes->argc; i++) {
+	for (i = 0; ref_prefixes && i < ref_prefixes->nr; i++) {
 		packet_write_fmt(fd_out, "ref-prefix %s\n",
-				 ref_prefixes->argv[i]);
+				 ref_prefixes->items[i]);
 	}
 	packet_flush(fd_out);
 
daemon.c +4 -4
index 0dec89fa02..ee66002a6f 100644
@@ -482,7 +482,7 @@ static int upload_pack(const struct strvec *env)
 	strvec_pushl(&cld.args, "upload-pack", "--strict", NULL);
 	strvec_pushf(&cld.args, "--timeout=%u", timeout);
 
-	strvec_pushv(&cld.env_array, env->argv);
+	strvec_pushv(&cld.env_array, env->items);
 
 	return run_service_command(&cld);
 }
@@ -492,7 +492,7 @@ static int upload_archive(const struct strvec *env)
 	struct child_process cld = CHILD_PROCESS_INIT;
 	strvec_push(&cld.args, "upload-archive");
 
-	strvec_pushv(&cld.env_array, env->argv);
+	strvec_pushv(&cld.env_array, env->items);
 
 	return run_service_command(&cld);
 }
@@ -502,7 +502,7 @@ static int receive_pack(const struct strvec *env)
 	struct child_process cld = CHILD_PROCESS_INIT;
 	strvec_push(&cld.args, "receive-pack");
 
-	strvec_pushv(&cld.env_array, env->argv);
+	strvec_pushv(&cld.env_array, env->items);
 
 	return run_service_command(&cld);
 }
@@ -927,7 +927,7 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
 #endif
 	}
 
-	cld.argv = cld_argv.argv;
+	cld.argv = cld_argv.items;
 	cld.in = incoming;
 	cld.out = dup(incoming);
 
diff.c +1 -1
index f1a3758922..fb5462c532 100644
@@ -4239,7 +4239,7 @@ static void run_external_diff(const char *pgm,
 
 	diff_free_filespec_data(one);
 	diff_free_filespec_data(two);
-	if (run_command_v_opt_cd_env(argv.argv, RUN_USING_SHELL, NULL, env.argv))
+	if (run_command_v_opt_cd_env(argv.items, RUN_USING_SHELL, NULL, env.items))
 		die(_("external diff died, stopping at %s"), name);
 
 	remove_tempfile();
environment.c +1 -1
index 00fe20e496..449a46995d 100644
@@ -164,7 +164,7 @@ static const char *getenv_safe(struct strvec *argv, const char *name)
 		return NULL;
 
 	strvec_push(argv, value);
-	return argv->argv[argv->argc - 1];
+	return argv->items[argv->nr - 1];
 }
 
 void setup_git_env(const char *git_dir)
exec-cmd.c +3 -3
index 0f8e888424..d657c025c2 100644
@@ -324,18 +324,18 @@ const char **prepare_git_cmd(struct strvec *out, const char **argv)
 {
 	strvec_push(out, "git");
 	strvec_pushv(out, argv);
-	return out->argv;
+	return out->items;
 }
 
 int execv_git_cmd(const char **argv)
 {
 	struct strvec nargv = STRVEC_INIT;
 
 	prepare_git_cmd(&nargv, argv);
-	trace_argv_printf(nargv.argv, "trace: exec:");
+	trace_argv_printf(nargv.items, "trace: exec:");
 
 	/* execvp() can only ever return if it fails */
-	sane_execvp("git", (char **)nargv.argv);
+	sane_execvp("git", (char **)nargv.items);
 
 	trace_printf("trace: exec failed: %s\n", strerror(errno));
 
git.c +5 -5
index 258035cfb1..832688ca23 100644
@@ -352,7 +352,7 @@ static int handle_alias(int *argcp, const char ***argv)
 			strvec_push(&child.args, alias_string + 1);
 			strvec_pushv(&child.args, (*argv) + 1);
 
-			trace2_cmd_alias(alias_command, child.args.argv);
+			trace2_cmd_alias(alias_command, child.args.items);
 			trace2_cmd_list_config();
 			trace2_cmd_list_env_vars();
 			trace2_cmd_name("_run_shell_alias_");
@@ -667,7 +667,7 @@ static void handle_builtin(int argc, const char **argv)
 		}
 
 		argc++;
-		argv = args.argv;
+		argv = args.items;
 	}
 
 	builtin = get_builtin(cmd);
@@ -701,7 +701,7 @@ static void execv_dashed_external(const char **argv)
 	 * The code in run_command() logs trace2 child_start/child_exit
 	 * events, so we do not need to report exec/exec_result events here.
 	 */
-	trace_argv_printf(cmd.args.argv, "trace: exec:");
+	trace_argv_printf(cmd.args.items, "trace: exec:");
 
 	/*
 	 * If we fail because the command is not found, it is
@@ -762,13 +762,13 @@ static int run_argv(int *argcp, const char ***argv)
 			for (i = 0; i < *argcp; i++)
 				strvec_push(&args, (*argv)[i]);
 
-			trace_argv_printf(args.argv, "trace: exec:");
+			trace_argv_printf(args.items, "trace: exec:");
 
 			/*
 			 * if we fail because the command is not found, it is
 			 * OK to return. Otherwise, we just pass along the status code.
 			 */
-			i = run_command_v_opt_tr2(args.argv, RUN_SILENT_EXEC_FAILURE |
+			i = run_command_v_opt_tr2(args.items, RUN_SILENT_EXEC_FAILURE |
 						  RUN_CLEAN_ON_EXIT | RUN_WAIT_AFTER_CLEAN, "git_alias");
 			if (i >= 0 || errno != ENOENT)
 				exit(i);
graph.c +2 -2
index 09c9cc968c..1d68fffa24 100644
@@ -355,8 +355,8 @@ struct git_graph *graph_init(struct rev_info *opt)
 			parse_graph_colors_config(&custom_colors, string);
 			free(string);
 			/* graph_set_column_colors takes a max-index, not a count */
-			graph_set_column_colors(custom_colors.argv,
-						custom_colors.argc - 1);
+			graph_set_column_colors(custom_colors.items,
+						custom_colors.nr - 1);
 		}
 	}
 
http-push.c +1 -1
index 31911aa345..c4e3825609 100644
@@ -1931,7 +1931,7 @@ int cmd_main(int argc, const char **argv)
 			strvec_pushf(&commit_argv, "^%s",
 				     oid_to_hex(&ref->old_oid));
 		repo_init_revisions(the_repository, &revs, setup_git_directory());
-		setup_revisions(commit_argv.argc, commit_argv.argv, &revs, NULL);
+		setup_revisions(commit_argv.nr, commit_argv.items, &revs, NULL);
 		revs.edge_hint = 0; /* just in case */
 
 		/* Generate a list of objects that need to be pushed */
ls-refs.c +3 -3
index 8192c949f4..e6b8c9cf8e 100644
@@ -15,11 +15,11 @@ static int ref_match(const struct strvec *prefixes, const char *refname)
 {
 	int i;
 
-	if (!prefixes->argc)
+	if (!prefixes->nr)
 		return 1; /* no restriction */
 
-	for (i = 0; i < prefixes->argc; i++) {
-		const char *prefix = prefixes->argv[i];
+	for (i = 0; i < prefixes->nr; i++) {
+		const char *prefix = prefixes->items[i];
 
 		if (starts_with(refname, prefix))
 			return 1;
merge.c +1 -1
index a05b054faa..bcfb9dcf8a 100644
@@ -33,7 +33,7 @@ int try_merge_command(struct repository *r,
 	for (j = remotes; j; j = j->next)
 		strvec_push(&args, merge_argument(j->item));
 
-	ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
+	ret = run_command_v_opt(args.items, RUN_GIT_CMD);
 	strvec_clear(&args);
 
 	discard_index(r->index);
pathspec.c +1 -1
index c303126f37..75378f49d1 100644
@@ -652,7 +652,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,
 	if (in != stdin)
 		fclose(in);
 
-	parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.argv);
+	parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.items);
 	strvec_clear(&parsed_file);
 }
 
range-diff.c +1 -1
index 831c490bf2..3fa3ac6cb5 100644
@@ -67,7 +67,7 @@ static int read_patches(const char *range, struct string_list *list,
 		     "--notes",
 		     NULL);
 	if (other_arg)
-		strvec_pushv(&cp.args, other_arg->argv);
+		strvec_pushv(&cp.args, other_arg->items);
 	strvec_push(&cp.args, range);
 	cp.out = -1;
 	cp.no_stdin = 1;
ref-filter.c +2 -2
index 7f013851ed..9d29271478 100644
@@ -1918,9 +1918,9 @@ static void find_longest_prefixes(struct string_list *out,
 	struct strbuf prefix = STRBUF_INIT;
 
 	strvec_pushv(&sorted, patterns);
-	QSORT(sorted.argv, sorted.argc, qsort_strcmp);
+	QSORT(sorted.items, sorted.nr, qsort_strcmp);
 
-	find_longest_prefixes_1(out, &prefix, sorted.argv, sorted.argc);
+	find_longest_prefixes_1(out, &prefix, sorted.items, sorted.nr);
 
 	strvec_clear(&sorted);
 	strbuf_release(&prefix);
remote-curl.c +3 -3
index 7feaddc003..564da05648 100644
@@ -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.items, &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.items, &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.items);
 	printf("\n");
 	fflush(stdout);
 
remote.c +1 -1
index b4665fe5a3..370bd07dc3 100644
@@ -1919,7 +1919,7 @@ static int stat_branch_pair(const char *branch_name, const char *base,
 	strvec_push(&argv, "--");
 
 	repo_init_revisions(the_repository, &revs, NULL);
-	setup_revisions(argv.argc, argv.argv, &revs, NULL);
+	setup_revisions(argv.nr, argv.items, &revs, NULL);
 	if (prepare_revision_walk(&revs))
 		die(_("revision walk setup failed"));
 
revision.c +2 -2
index e144132ae9..d645487646 100644
@@ -2767,7 +2767,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
 			got_rev_arg = 1;
 	}
 
-	if (prune_data.argc) {
+	if (prune_data.nr) {
 		/*
 		 * If we need to introduce the magic "a lone ':' means no
 		 * pathspec whatsoever", here is the place to do so.
@@ -2783,7 +2783,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
 		 * }
 		 */
 		parse_pathspec(&revs->prune_data, 0, 0,
-			       revs->prefix, prune_data.argv);
+			       revs->prefix, prune_data.items);
 	}
 	strvec_clear(&prune_data);
 
run-command.c +10 -10
index b9630a1b5f..30104a4ee1 100644
@@ -287,7 +287,7 @@ static const char **prepare_shell_cmd(struct strvec *out, const char **argv)
 	}
 
 	strvec_pushv(out, argv);
-	return out->argv;
+	return out->items;
 }
 
 #ifndef GIT_WINDOWS_NATIVE
@@ -426,11 +426,11 @@ static int prepare_cmd(struct strvec *out, const struct child_process *cmd)
 	 * there are dir separator characters, we have exec attempt to invoke
 	 * the command directly.
 	 */
-	if (!has_dir_sep(out->argv[1])) {
-		char *program = locate_in_PATH(out->argv[1]);
+	if (!has_dir_sep(out->items[1])) {
+		char *program = locate_in_PATH(out->items[1]);
 		if (program) {
-			free((char *)out->argv[1]);
-			out->argv[1] = program;
+			free((char *)out->items[1]);
+			out->items[1] = program;
 		} else {
 			strvec_clear(out);
 			errno = ENOENT;
@@ -672,9 +672,9 @@ int start_command(struct child_process *cmd)
 	char *str;
 
 	if (!cmd->argv)
-		cmd->argv = cmd->args.argv;
+		cmd->argv = cmd->args.items;
 	if (!cmd->env)
-		cmd->env = cmd->env_array.argv;
+		cmd->env = cmd->env_array.items;
 
 	/*
 	 * In case of errors we must keep the promise to close FDs
@@ -846,10 +846,10 @@ int start_command(struct child_process *cmd)
 		 * be used in the event exec failed with ENOEXEC at which point
 		 * we will try to interpret the command using 'sh'.
 		 */
-		execve(argv.argv[1], (char *const *) argv.argv + 1,
+		execve(argv.items[1], (char *const *) argv.items + 1,
 		       (char *const *) childenv);
 		if (errno == ENOEXEC)
-			execve(argv.argv[0], (char *const *) argv.argv,
+			execve(argv.items[0], (char *const *) argv.items,
 			       (char *const *) childenv);
 
 		if (errno == ENOENT) {
@@ -1874,7 +1874,7 @@ int run_auto_gc(int quiet)
 	strvec_pushl(&argv_gc_auto, "gc", "--auto", NULL);
 	if (quiet)
 		strvec_push(&argv_gc_auto, "--quiet");
-	status = run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
+	status = run_command_v_opt(argv_gc_auto.items, RUN_GIT_CMD);
 	strvec_clear(&argv_gc_auto);
 	return status;
 }
sequencer.c +2 -2
index 31a2b1ab55..c1bcd64080 100644
@@ -2761,7 +2761,7 @@ static int reset_merge(const struct object_id *oid)
 	if (!is_null_oid(oid))
 		strvec_push(&argv, oid_to_hex(oid));
 
-	ret = run_command_v_opt(argv.argv, RUN_GIT_CMD);
+	ret = run_command_v_opt(argv.items, RUN_GIT_CMD);
 	strvec_clear(&argv);
 
 	return ret;
@@ -3135,7 +3135,7 @@ static int do_exec(struct repository *r, const char *command_line)
 	strvec_pushf(&child_env, "GIT_WORK_TREE=%s",
 		     absolute_path(get_git_work_tree()));
 	status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL,
-					  child_env.argv);
+					  child_env.items);
 
 	/* force re-reading of the cache */
 	if (discard_index(r->index) < 0 || repo_read_index(r) < 0)
serve.c +3 -3
index 523a9be32d..0db929beff 100644
@@ -146,9 +146,9 @@ int has_capability(const struct strvec *keys, const char *capability,
 		   const char **value)
 {
 	int i;
-	for (i = 0; i < keys->argc; i++) {
+	for (i = 0; i < keys->nr; i++) {
 		const char *out;
-		if (skip_prefix(keys->argv[i], capability, &out) &&
+		if (skip_prefix(keys->items[i], capability, &out) &&
 		    (!*out || *out == '=')) {
 			if (value) {
 				if (*out == '=')
@@ -223,7 +223,7 @@ static int process_request(void)
 			 * If no command and no keys were given then the client
 			 * wanted to terminate the connection.
 			 */
-			if (!keys.argc)
+			if (!keys.nr)
 				return 1;
 
 			/*
strvec.c +22 -22

94 lines not on this page · raw message

strvec.h +10 -10
index bd35de1ce4..fda1c81c86 100644
@@ -2,10 +2,10 @@
 #define STRVEC_H
 
 /**
- * The argv-array API allows one to dynamically build and store
- * NULL-terminated lists.  An argv-array maintains the invariant that the
- * `argv` member always points to a non-NULL array, and that the array is
- * always NULL-terminated at the element pointed to by `argv[argc]`. This
+ * The strvec API allows one to dynamically build and store
+ * NULL-terminated arrays of strings. A strvec maintains the invariant that the
+ * `items` member always points to a non-NULL array, and that the array is
+ * always NULL-terminated at the element pointed to by `items[nr]`. This
  * makes the result suitable for passing to functions expecting to receive
  * argv from main().
  *
@@ -22,15 +22,15 @@ extern const char *empty_strvec[];
 
 /**
  * A single array. This should be initialized by assignment from
- * `STRVEC_INIT`, or by calling `strvec_init`. The `argv`
- * member contains the actual array; the `argc` member contains the
+ * `STRVEC_INIT`, or by calling `strvec_init`. The `items`
+ * member contains the actual array; the `nr` member contains the
  * number of elements in the array, not including the terminating
  * NULL.
  */
 struct strvec {
-	const char **argv;
-	size_t argc;
-	size_t alloc;
+	const char **items;
+	int nr;
+	int alloc;
 };
 
 #define STRVEC_INIT { empty_strvec, 0, 0 }
@@ -78,7 +78,7 @@ void strvec_split(struct strvec *, const char *);
 void strvec_clear(struct strvec *);
 
 /**
- * Disconnect the `argv` member from the `strvec` struct and
+ * Disconnect the `items` member from the `strvec` struct and
  * return it. The caller is responsible for freeing the memory used
  * by the array, and by the strings it references. After detaching,
  * the `strvec` is in a reinitialized state and can be pushed
submodule.c +7 -7
index fb96d595b0..d9bc9c4696 100644
@@ -269,7 +269,7 @@ int is_submodule_active(struct repository *repo, const char *path)
 			strvec_push(&args, item->string);
 		}
 
-		parse_pathspec(&ps, 0, 0, NULL, args.argv);
+		parse_pathspec(&ps, 0, 0, NULL, args.items);
 		ret = match_pathspec(repo->index, &ps, path, strlen(path), 0, NULL, 1);
 
 		strvec_clear(&args);
@@ -842,7 +842,7 @@ static void collect_changed_submodules(struct repository *r,
 	const struct commit *commit;
 
 	repo_init_revisions(r, &rev, NULL);
-	setup_revisions(argv->argc, argv->argv, &rev, NULL);
+	setup_revisions(argv->nr, argv->items, &rev, NULL);
 	if (prepare_revision_walk(&rev))
 		die(_("revision walk setup failed"));
 
@@ -1014,7 +1014,7 @@ int find_unpushed_submodules(struct repository *r,
 	struct string_list_item *name;
 	struct strvec argv = STRVEC_INIT;
 
-	/* argv.argv[0] will be ignored by setup_revisions */
+	/* argv.items[0] will be ignored by setup_revisions */
 	strvec_push(&argv, "find_unpushed_submodules");
 	oid_array_for_each_unique(commits, append_oid_to_argv, &argv);
 	strvec_push(&argv, "--not");
@@ -1453,7 +1453,7 @@ static int get_next_submodule(struct child_process *cp,
 				strbuf_addf(err, _("Fetching submodule %s%s\n"),
 					    spf->prefix, ce->name);
 			strvec_init(&cp->args);
-			strvec_pushv(&cp->args, spf->args.argv);
+			strvec_pushv(&cp->args, spf->args.items);
 			strvec_push(&cp->args, default_argv);
 			strvec_push(&cp->args, "--submodule-prefix");
 
@@ -1501,7 +1501,7 @@ static int get_next_submodule(struct child_process *cp,
 		cp->dir = task->repo->gitdir;
 
 		strvec_init(&cp->args);
-		strvec_pushv(&cp->args, spf->args.argv);
+		strvec_pushv(&cp->args, spf->args.items);
 		strvec_push(&cp->args, "on-demand");
 		strvec_push(&cp->args, "--submodule-prefix");
 		strvec_push(&cp->args, submodule_prefix.buf);
@@ -1619,8 +1619,8 @@ int fetch_populated_submodules(struct repository *r,
 		die(_("index file corrupt"));
 
 	strvec_push(&spf.args, "fetch");
-	for (i = 0; i < options->argc; i++)
-		strvec_push(&spf.args, options->argv[i]);
+	for (i = 0; i < options->nr; i++)
+		strvec_push(&spf.args, options->items[i]);
 	strvec_push(&spf.args, "--recurse-submodules-default");
 	/* default value, "--submodule-prefix" and its value are added later */
 
t/helper/test-run-command.c +4 -4
index 726835fcc2..605135be42 100644
@@ -248,7 +248,7 @@ static int quote_stress_test(int argc, const char **argv)
 		else
 			strvec_pushl(&args, "test-tool", "run-command",
 				     "quote-echo", NULL);
-		arg_offset = args.argc;
+		arg_offset = args.nr;
 
 		if (argc > 0) {
 			trials = 1;
@@ -275,13 +275,13 @@ static int quote_stress_test(int argc, const char **argv)
 		if (i < skip)
 			continue;
 
-		cp.argv = args.argv;
+		cp.argv = args.items;
 		strbuf_reset(&out);
 		if (pipe_command(&cp, NULL, 0, &out, 0, NULL, 0) < 0)
 			return error("Failed to spawn child process");
 
 		for (j = 0, k = 0; j < arg_count; j++) {
-			const char *arg = args.argv[j + arg_offset];
+			const char *arg = args.items[j + arg_offset];
 
 			if (strcmp(arg, out.buf + k))
 				ret = error("incorrectly quoted arg: '%s', "
@@ -298,7 +298,7 @@ static int quote_stress_test(int argc, const char **argv)
 			fprintf(stderr, "Trial #%d failed. Arguments:\n", i);
 			for (j = 0; j < arg_count; j++)
 				fprintf(stderr, "arg #%d: '%s'\n",
-					(int)j, args.argv[j + arg_offset]);
+					(int)j, args.items[j + arg_offset]);
 
 			strbuf_release(&out);
 			strvec_clear(&args);
tmp-objdir.c +1 -1
index e78e481d8e..e21bef6cca 100644
@@ -283,7 +283,7 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)
 {
 	if (!t)
 		return NULL;
-	return t->env.argv;
+	return t->env.items;
 }
 
 void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)
transport-helper.c +1 -1
index ae8011e9d5..8abdf09faa 100644
@@ -138,7 +138,7 @@ static struct child_process *get_helper(struct transport *transport)
 		strvec_pushf(&helper->env_array, "%s=%s",
 			     GIT_DIR_ENVIRONMENT, get_git_dir());
 
-	helper->trace2_child_class = helper->args.argv[0]; /* "remote-<name>" */
+	helper->trace2_child_class = helper->args.items[0]; /* "remote-<name>" */
 
 	code = start_command(helper);
 	if (code < 0 && errno == ENOENT)
upload-pack.c +1 -1
index 4a7918e04e..5783e23dcb 100644
@@ -897,7 +897,7 @@ static int send_shallow_list(struct upload_pack_data *data)
 			struct object *o = data->want_obj.objects[i].item;
 			strvec_push(&av, oid_to_hex(&o->oid));
 		}
-		deepen_by_rev_list(data, av.argc, av.argv);
+		deepen_by_rev_list(data, av.nr, av.items);
 		strvec_clear(&av);
 		ret = 1;
 	} else {
Signature · 1 line
2.28.0.rc2.475.g53c7e1c7f4
#22 lore raw

Re: [PATCH 11/11] strvec: rename struct fields

Quoted 9 lines · Jeff King

The "argc" and "argv" names made sense when the struct was argv_array, but now they're just confusing. Let's rename them to our usual "nr" and "items" (which we use for string_list, as well as many ALLOC_GROW() arrays).

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.

Quoted 8 lines

---
I'm actually not that fond of "items". I almost went with just:

const char **v;

as the variable name which contains it usually provides sufficient context. But I worried that people would consider that too inscrutable.

I'd agree that v[] is a good name. If it is too short, I can live with item[], but not with items[]. Clearly we are mostly accessing one element at a time much more often than treating the set as a whole, so signaling "there are multiple things in the set" with a plural name is much less important than being able to say item[4] to name the 4th item in the collection.

#23 lore raw

Re: [PATCH 11/11] strvec: rename struct fields

Quoted 9 lines · Junio C Hamano
Quoted 6 lines

I'm actually not that fond of "items". I almost went with just:

const char **v;

as the variable name which contains it usually provides sufficient context. But I worried that people would consider that too inscrutable.

I'd agree that v[] is a good name. If it is too short, I can live with item[], but not with items[]....

What are individual component of a vector called? An element? If so, elem[] would be much better name than item[].

#24 lore raw

Re: [PATCH 11/11] strvec: rename struct fields

Quoted 7 lines · Junio C Hamano
Quoted 4 lines · Junio C Hamano
Quoted 4 lines

I'm actually not that fond of "items". I almost went with just:

const char **v;

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

as the variable name which contains it usually provides sufficient context. But I worried that people would consider that too inscrutable.

I'd agree that v[] is a good name. If it is too short, I can live with item[], but not with items[]....

What are individual component of a vector called? An element? If so, elem[] would be much better name than item[].

Individual components of a string vector or a string array are strings, so "str" if we abbreviate "string" to "str".

Using "str" would be consistent with oid_array where the individual component is called "oid" as it is defined this way:

struct oid_array {
        struct object_id *oid;
        size_t nr;
        size_t alloc;
        int sorted;
};
author
#25 lore raw

Re: [PATCH 11/11] strvec: rename struct fields

Quoted 12 lines · Christian Couder
Quoted 5 lines
Quoted 2 lines

I'd agree that v[] is a good name. If it is too short, I can live with item[], but not with items[]....

What are individual component of a vector called? An element? If so, elem[] would be much better name than item[].

Individual components of a string vector or a string array are strings, so "str" if we abbreviate "string" to "str".

Using "str" would be consistent with oid_array where the individual component is called "oid" as it is defined this way:

Quoted 6 lines
struct oid_array {
        struct object_id *oid;
        size_t nr;
        size_t alloc;
        int sorted;
};

Yeah, I agree "str" is a reasonable name, and probably better than "elem" or "items". I do still like the super-concise "v" better, though.

-Peff

#26 lore raw

Re: [PATCH 11/11] strvec: rename struct fields

Quoted 10 lines · Jeff King
Quoted 9 lines

Using "str" would be consistent with oid_array where the individual component is called "oid" as it is defined this way:

struct oid_array {
        struct object_id *oid;
        size_t nr;
        size_t alloc;
        int sorted;
};
Quoted 2 lines

Yeah, I agree "str" is a reasonable name, and probably better than "elem" or "items". I do still like the super-concise "v" better, though.

One problem with names like "str", "string", and "oid" is that it leads to this stupid pattern:

    struct oid_array *oid;
    oid_to_hex(oid->oid[0], ...);

We know the thing is object name by the pointer variable having the name oid already---there is no need to repeat we are talking about oid again with the field name.

So, "str" being consistent with "oid_array" is not necessarily a plus.

Ultra-concise v[] that stands for value, or e[] that stands for element, do not share this problem.

One plus about the redundant field name is that it is easier to run

    grep -E -e "([.]|->)oid"

but I do not know how important that is.

author
#27 lore raw

Re: [PATCH 11/11] strvec: rename struct fields

In reply to Junio C Hamano
Quoted 7 lines · Junio C Hamano
Quoted 6 lines

I'm actually not that fond of "items". I almost went with just:

const char **v;

as the variable name which contains it usually provides sufficient context. But I worried that people would consider that too inscrutable.

Quoted 6 lines

I'd agree that v[] is a good name. If it is too short, I can live with item[], but not with items[]. Clearly we are mostly accessing one element at a time much more often than treating the set as a whole, so signaling "there are multiple things in the set" with a plural name is much less important than being able to say item[4] to name the 4th item in the collection.

I'd worry that "item" versus string_list "items" would be unfriendly (though I am not opposed to changing string_list to match).

Your "elem" suggestion from elsewhere may be better still, but if you are OK with "v", that is my preference. I'll see if anybody else chimes in, but if not, then I'd probably switch to that. :)

-Peff

#28 lore raw
In reply to Jeff King
Quoted 29 lines · Jeff King

The argv_array data type has turned out to be useful in our code base, but the name isn't very good. From patch 2 of this series:

The name "argv-array" isn't very good, because it describes what the data type can be used for (program argument arrays), not what it actually is (a dynamically-growing string array that maintains a NULL-terminator invariant). This leads to people being hesitant to use it for other cases where it would actually be a good fit. The existing name is also clunky to use. It's overly long, and the name often leads to saying things like "argv.argv" (i.e., the field names overlap with variable names, since they're describing the use, not the type). Let's give it a more neutral name.

This has bugged me for a while, so I decided to finally fix it. It wasn't _too_ painful, though I'm sure there will be a little fallout with topics in flight.

I tried to split out the mechanical bits into their own patches to make reviewing easier. Patches 5-7 really could be a single patch, but they're too big for the mailing list. I'm OK to leave them separate, or they could be squashed together.

We could stop at patch 9 for now and allow topics in flight to catch up before removing the compat layers. But the struct field renaming has to happen as a single step, so it will be a pain whenever we do it. If we're going to go this route, I'd just as soon do it all now and deal with other topics as they get merged.

Quoted 12 lines

[01/11]: argv-array: use size_t for count and alloc [02/11]: argv-array: rename to strvec
[03/11]: strvec: rename files from argv-array to strvec [04/11]: quote: rename sq_dequote_to_argv_array to mention strvec [05/11]: strvec: convert builtin/ callers away from argv_array name [06/11]: strvec: convert more callers away from argv_array name [07/11]: strvec: convert remaining callers away from argv_array name [08/11]: strvec: fix indentation in renamed calls [09/11]: strvec: update documention to avoid argv_array [10/11]: strvec: drop argv_array compatibility layer [11/11]: strvec: rename struct fields

I like this. It definitely helps to name the API after what it does.

One thing I thought I would see but I guess we simply don't have one is a technical doc that details the strvec. I guess we just never had one for argv_array? Probably worth adding one at some point.

Thanks,
Jake

author
#29 lore raw
Quoted 3 lines · Jacob Keller

One thing I thought I would see but I guess we simply don't have one is a technical doc that details the strvec. I guess we just never had one for argv_array? Probably worth adding one at some point.

It all got moved into the header file in 971b1f24a2 (argv-array: move doc to argv-array.h, 2019-11-17). It got the same s/argv_array/strvec/ as the code in patch 2. I think what's there is pretty reasonable, but patches welcome if you have suggestions about what could be added. :)

-Peff

#30 lore raw
In reply to Jeff King
Quoted 8 lines · Jeff King

The argv_array data type has turned out to be useful in our code base, but the name isn't very good. From patch 2 of this series:

The name "argv-array" isn't very good, because it describes what the data type can be used for (program argument arrays), not what it actually is (a dynamically-growing string array that maintains a NULL-terminator invariant).

I cannot help but notice that you still use "array" when describing what it is. You actually use "string array" to describe what it is, and at the same time say that the name should describe what it is. So I would expect after the above sentence that you would rename it to "string_array" or "str_array".

In patch 2 you also say:

Quoted 2 lines

I settled on "strvec" because "vector" is the name for a dynamic array type in many programming languages.

in which you also use "array" to describe it.

Quoted 3 lines

"strarray" would work, too, but it's
longer and a bit more awkward to say (and don't we all say these things in our mind as we type them?).

It's longer than "strarray" by 2 characters only.

Also we still use "array" in "oid_array" which is very similar to this. And the implementation is based on the ALLOC_GROW macro which uses the REALLOC_ARRAY macro.

We also use ALLOC_ARRAY, FLEX_ARRAY, CALLOC_ARRAY, COPY_ARRAY and MOVE_ARRAY macros.

So if you don't like the "array" part of the name, are you going to also change "oid_array" into "oidvec" and for example "REALLOC_ARRAY" into "REALLOC_VEC" or "REALLOC_VECTOR"?

If you want to change only "argv_array" (and not also "oid_array", "REALLOC_ARRAY" and perhaps other *_ARRAY macros) into something else, then I think it would be better to be consistent with them.

#31 lore raw
Quoted 5 lines · Christian Couder
Quoted 3 lines

"strarray" would work, too, but it's
longer and a bit more awkward to say (and don't we all say these things in our mind as we type them?).

It's longer than "strarray" by 2 characters only.

Sorry, I mean it's shorter than "strarray" by 2 characters only.

#32 lore raw
In reply to Christian Couder
Quoted 7 lines · Christian Couder

I would expect after the above sentence that you would rename it to "string_array" or "str_array".
[...]
Also we still use "array" in "oid_array" which is very similar to this. And the implementation is based on the ALLOC_GROW macro which uses the REALLOC_ARRAY macro.

Quoted 6 lines

We also use ALLOC_ARRAY, FLEX_ARRAY, CALLOC_ARRAY, COPY_ARRAY and MOVE_ARRAY macros.
[...]
If you want to change only "argv_array" (and not also "oid_array", "REALLOC_ARRAY" and perhaps other *_ARRAY macros) into something else, then I think it would be better to be consistent with them.

Dipping my toe into the bikeshed paint bucket...

Naming consistency is certainly a valid concern, and if this was a public API I might agree that such consistency should outweigh some other concerns, however, this is a private, project-specific API in which convenience and concision weigh more heavily in my opinion. There is value in succinctness, not just when writing code (by having to type less), but also when reading it, for the same reason that we use short and sweet variable and function names. To wit: short, well chosen, idiomatic names let the structure of the code show through (often) at-a-glance, whereas long names force us to laboriously read code, making it harder to discern the overall structure and logic.

There is also value[1] in having "vec" (or "v") in the name as opposed to "array", specifically because this isn't just an array of strings; it is a NULL-terminated vector of strings. Thus, it is suitable for functions which accept such a datatype, which often have "v" in their names, as well (for instance, execv()).

On the topic of a "terminated array": As a NULL-terminated array of strings, the name "strvec" provides naming consistency and fits nicely alongside the name "strbuf", a NUL-terminated array of characters, while also sharing the relative concision of that name.

In my opinion, the name "strvec" is a good and reasonably succinct compromise between other names, such as "strv"[2] and "strs"[3], proposed previously. It gets my "+1".

[1]: https://lore.kernel.org/git/[email protected]/
[2]: https://lore.kernel.org/git/[email protected]/
[3]: https://lore.kernel.org/git/CAPig+cS+G-xC51n-Ud0Wbmcc-zeHBM3-5WQQAFm9gwm9LNk3Gg@mail.gmail.com/

author
#33 lore raw
In reply to Christian Couder
Quoted 10 lines · Christian Couder
Quoted 8 lines · Jeff King

The argv_array data type has turned out to be useful in our code base, but the name isn't very good. From patch 2 of this series:

The name "argv-array" isn't very good, because it describes what the data type can be used for (program argument arrays), not what it actually is (a dynamically-growing string array that maintains a NULL-terminator invariant).

Quoted 5 lines

I cannot help but notice that you still use "array" when describing what it is. You actually use "string array" to describe what it is, and at the same time say that the name should describe what it is. So I would expect after the above sentence that you would rename it to "string_array" or "str_array".

I think one thing that leads me to "vec" is the "v" from "argv", which implies the NULL-terminator (though of course that's _not_ implied by "vector" in other languages). None of the other "array" types have that feature, and it's an important one here.

Quoted 5 lines
Quoted 3 lines

"strarray" would work, too, but it's
longer and a bit more awkward to say (and don't we all say these things in our mind as we type them?).

It's longer than "strarray" by 2 characters only.

Yeah, I agree the length between the two is not super important. Mostly I find it harder to read and say. That's obviously subjective, but I do think counts for something.

We use an underscore for "oid_array" (which I think makes sense because it's awkward to concatenate directly a word that starts with a vowel and has multiple syllables). That makes it inconsistent with oidmap and oidset. Likewise, I was hoping for consistency with strbuf here.

Quoted 6 lines

Also we still use "array" in "oid_array" which is very similar to this. And the implementation is based on the ALLOC_GROW macro which uses the REALLOC_ARRAY macro.

We also use ALLOC_ARRAY, FLEX_ARRAY, CALLOC_ARRAY, COPY_ARRAY and MOVE_ARRAY macros.

Those macro names are pretty bulky, but I think it matters a lot less because they're used a lot less. The type name here is prepended to all of the "method" functions like strvec_pushf(), etc.

Quoted 3 lines

So if you don't like the "array" part of the name, are you going to also change "oid_array" into "oidvec" and for example "REALLOC_ARRAY" into "REALLOC_VEC" or "REALLOC_VECTOR"?

I hadn't planned on it, just because I think the cost of changing versus the benefit is not that high. If I were designing from scratch, I'd definitely consider oidvec (but probably not REALLOC_VEC for the reasons above).

I think the cost of changing away from argv_array _is_ worth it, and once we're doing that, we can choose between the alternatives without paying an extra cost.

Quoted 3 lines

If you want to change only "argv_array" (and not also "oid_array", "REALLOC_ARRAY" and perhaps other *_ARRAY macros) into something else, then I think it would be better to be consistent with them.

I definitely sympathize with the consistency argument, and I don't think 'str_array" is the end of the world. But I think there are many dimensions of inconsistency already, so without renaming every data structure, we're going to be inconsistent with something. Mostly I just subjectively find strvec easier to read, say, and type, and I don't think the inconsistencies are so glaring that it's a problem.

-Peff

#34 lore raw
In reply to Jeff King

Am 28.07.20 um 22:21 schrieb Jeff King:

Quoted 13 lines

The argv_array data type has turned out to be useful in our code base, but the name isn't very good. From patch 2 of this series:

The name "argv-array" isn't very good, because it describes what the data type can be used for (program argument arrays), not what it actually is (a dynamically-growing string array that maintains a NULL-terminator invariant). This leads to people being hesitant to use it for other cases where it would actually be a good fit. The existing name is also clunky to use. It's overly long, and the name often leads to saying things like "argv.argv" (i.e., the field names overlap with variable names, since they're describing the use, not the type). Let's give it a more neutral name.

Quoted 3 lines

This has bugged me for a while, so I decided to finally fix it. It wasn't _too_ painful, though I'm sure there will be a little fallout with topics in flight.

Just as this landed in master now, https://lobste.rs/ decided to link to
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2493.pdf, which is a paper about reserved identifiers in C. It contains a nice overview.

Anyway, 7.31 of C11 says: "All external names described below are reserved no matter what headers are included by the program." And 7.31.13 goes on: "Function names that begin with str, mem, or wcs and a lowercase letter may be added to the declarations in the <string.h> header." So the names of the strvec functions are reserved.

Also how about using Coccinelle and patience to reduce the impact of such a change next time? I.e. adding the new thing, providing a semantic patch for converting old code, waiting a reasonable amount of time after the last conversion was necessary and then removing the old thing.

René

#35 lore raw
Quoted 28 lines · René Scharfe

Am 28.07.20 um 22:21 schrieb Jeff King:

Quoted 13 lines

The argv_array data type has turned out to be useful in our code base, but the name isn't very good. From patch 2 of this series:

The name "argv-array" isn't very good, because it describes what the data type can be used for (program argument arrays), not what it actually is (a dynamically-growing string array that maintains a NULL-terminator invariant). This leads to people being hesitant to use it for other cases where it would actually be a good fit. The existing name is also clunky to use. It's overly long, and the name often leads to saying things like "argv.argv" (i.e., the field names overlap with variable names, since they're describing the use, not the type). Let's give it a more neutral name.

Quoted 3 lines

This has bugged me for a while, so I decided to finally fix it. It wasn't _too_ painful, though I'm sure there will be a little fallout with topics in flight.

Just as this landed in master now, https://lobste.rs/ decided to link to
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2493.pdf, which is a paper about reserved identifiers in C. It contains a nice overview.

Anyway, 7.31 of C11 says: "All external names described below are reserved no matter what headers are included by the program." And 7.31.13 goes on: "Function names that begin with str, mem, or wcs and a lowercase letter may be added to the declarations in the <string.h> header." So the names of the strvec functions are reserved.

Quoted 5 lines

Also how about using Coccinelle and patience to reduce the impact of such a change next time? I.e. adding the new thing, providing a semantic patch for converting old code, waiting a reasonable amount of time after the last conversion was necessary and then removing the old thing.

I don't think that this is a bad idea at all, but I'm also totally fine with the approach that Peff took here. (Bear in mind that I'm saying this as someone who didn't have any topics that used argv_array, and so didn't have to do any conversion effort ;-)).

I worry a little bit about providing too long a grace period where we have to worry about not introducing new uses of argv_array, and still having to deal with some (perhaps less) fall-out later down the line.

For this change, I think it was perfectly fine to just rip the bandaid off.

Quoted 1 line

René

Thanks,
Taylor

#36 lore raw
In reply to René Scharfe
Quoted 3 lines · René Scharfe

7.31.13 goes on: "Function names that begin with str, mem, or wcs and a lowercase letter may be added to the declarations in the <string.h> header." So the names of the strvec functions are reserved.

Ugh, strbuf functions are reserved, too?

#37 lore raw
Quoted 8 lines · Junio C Hamano
Quoted 3 lines · René Scharfe

7.31.13 goes on: "Function names that begin with str, mem, or wcs and a lowercase letter may be added to the declarations in the <string.h> header." So the names of the strvec functions are reserved.

Ugh, strbuf functions are reserved, too?

At least that paper is proposing a better solution in the long term...

#38 lore raw
Quoted 11 lines · Jacob Keller
Quoted 8 lines · Junio C Hamano
Quoted 3 lines · René Scharfe

7.31.13 goes on: "Function names that begin with str, mem, or wcs and a lowercase letter may be added to the declarations in the <string.h> header." So the names of the strvec functions are reserved.

Ugh, strbuf functions are reserved, too?

At least that paper is proposing a better solution in the long term...

I am not sure what the "potentially" really buys to our fellow developers. At least we are not folks "targeting a specific version of the standard"; we care about the future standards, too X-<.

#39 lore raw
In reply to Junio C Hamano

Hi,

Quoted 7 lines · Junio C Hamano
Quoted 3 lines · René Scharfe

7.31.13 goes on: "Function names that begin with str, mem, or wcs and a lowercase letter may be added to the declarations in the <string.h> header." So the names of the strvec functions are reserved.

Ugh, strbuf functions are reserved, too?

We could try to implement the very patient approach proposed by René and rename strbuf to git_buf :-)

Ciao,
Dscho

author
#40 lore raw
In reply to René Scharfe
Quoted 8 lines · René Scharfe
Quoted 3 lines

This has bugged me for a while, so I decided to finally fix it. It wasn't _too_ painful, though I'm sure there will be a little fallout with topics in flight.

Just as this landed in master now, https://lobste.rs/ decided to link to
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2493.pdf, which is a paper about reserved identifiers in C. It contains a nice overview.

Quoted 5 lines

Anyway, 7.31 of C11 says: "All external names described below are reserved no matter what headers are included by the program." And 7.31.13 goes on: "Function names that begin with str, mem, or wcs and a lowercase letter may be added to the declarations in the <string.h> header." So the names of the strvec functions are reserved.

It was the same in C99. I think this is one of those cases where we need to worry less about what the standard says and more about what the real world does. As long as we're ready for C25 or whatever to add "strvec" and we accept that we'll need to change the name then, I'm not particularly concerned. A compiler that starts warning about "str" functions in the meantime would be impractical I think (forget strbuf, stuff like strip_extension() would be illegal).

Quoted 5 lines

Also how about using Coccinelle and patience to reduce the impact of such a change next time? I.e. adding the new thing, providing a semantic patch for converting old code, waiting a reasonable amount of time after the last conversion was necessary and then removing the old thing.

So I almost sent a rant about Coccinelle along with this series. :)

Debian unstable now ships coccinelle 1.0.8, and it's unbelievably slow compared to 1.0.4. Running "make coccicheck" is currently at 80 minutes of CPU time running each script in parallel, with none of them down. They're also all consuming 6GB of RAM each, so I'm killing them all.

I got somewhere similar when I was working on this series, got fed up, and then just did the whole thing with grep, which was easier. I'm open to the idea that a slower transition might have helped topics in flight catch up, but it also would have prolonged the pain. So I dunno.

-Peff

author
#41 lore raw
Quoted 4 lines · Jeff King

Debian unstable now ships coccinelle 1.0.8, and it's unbelievably slow compared to 1.0.4. Running "make coccicheck" is currently at 80 minutes of CPU time running each script in parallel, with none of them down. They're also all consuming 6GB of RAM each, so I'm killing them all.

This seems to be related to setting SPATCH_BATCH_SIZE to "0". It used to make things go much faster (if you had enough memory), but now seems to just consume tons of CPU. Setting it to "1" finishes the whole thing in ~13 minutes of CPU (~2m wall-clock).

So that's at least a path forward, but in general I have been frustrated with operational aspects of coccinelle like this.

-Peff

#42 lore raw

Am 12.08.20 um 17:10 schrieb Jeff King:

Quoted 11 lines · Jeff King
Quoted 5 lines

Debian unstable now ships coccinelle 1.0.8, and it's unbelievably slow compared to 1.0.4. Running "make coccicheck" is currently at 80 minutes of CPU time running each script in parallel, with none of them down. They're also all consuming 6GB of RAM each, so I'm killing them all.

This seems to be related to setting SPATCH_BATCH_SIZE to "0". It used to make things go much faster (if you had enough memory), but now seems to just consume tons of CPU. Setting it to "1" finishes the whole thing in ~13 minutes of CPU (~2m wall-clock).

This bit me as well, and I settled with SPATCH_BATCH_SIZE = 10. With MAKEFLAGS += -j3 I get these number, which are quite similar to yours (except I don't dare use more cores due to cooling issues..):

real 4m12,393s
user 12m15,447s
sys 0m10,418s

Quoted 2 lines

So that's at least a path forward, but in general I have been frustrated with operational aspects of coccinelle like this.

And I was a bit shocked when Coccinelle's testing package became unmaintained for a while and I had to compile it from source.

And yes, coccicheck is quite heavy. When I merge all .cocci files into one I get:

real 2m7,164s
user 2m5,389s
sys 0m1,572s

Nice. With spatch -j3 I get basically the same numbers, though. Hmm.

René

author
#43 lore raw
Quoted 5 lines · René Scharfe
Quoted 4 lines

This seems to be related to setting SPATCH_BATCH_SIZE to "0". It used to make things go much faster (if you had enough memory), but now seems to just consume tons of CPU. Setting it to "1" finishes the whole thing in ~13 minutes of CPU (~2m wall-clock).

Quoted 7 lines

This bit me as well, and I settled with SPATCH_BATCH_SIZE = 10. With MAKEFLAGS += -j3 I get these number, which are quite similar to yours (except I don't dare use more cores due to cooling issues..):

real 4m12,393s
user 12m15,447s
sys 0m10,418s

Interestingly, that was slower for me (2m47s wall-clock, with 27m of CPU). Using "2" is slightly faster than "1". But "3" is a little less fast, and "4" is slower than "1". So...no clue what is going on.

Quoted 5 lines
Quoted 2 lines

So that's at least a path forward, but in general I have been frustrated with operational aspects of coccinelle like this.

And I was a bit shocked when Coccinelle's testing package became unmaintained for a while and I had to compile it from source.

Yeah, I've had various issues with the packaging. For a long time they had 1.0.7 in experimental, but with no python support. I wonder if it's worth starting to use python scriptlets in our coccinelle rules, as described in 4d168e742a (coccinelle: use <...> for function exclusion, 2018-08-28). They're faster and IMHO easier to understand.

Of course I tried it out and got some inscrutable errors:

SPATCH contrib/coccinelle/object_id.cocci
init_defs_builtins: /usr/bin/../lib/coccinelle/standard.h Python path configuration:

    PYTHONHOME = '/lib/x86_64-linux-gnu/..'
    PYTHONPATH = '/usr/bin/../lib/coccinelle/python'
    program name = 'python3'
    isolated = 0
    environment = 1
    user site = 1
    import site = 1
    sys._base_executable = '/usr/bin/python3'
    sys.base_prefix = '/lib/x86_64-linux-gnu/..'
    sys.base_exec_prefix = '/lib/x86_64-linux-gnu/..'
    sys.executable = '/usr/bin/python3'
    sys.prefix = '/lib/x86_64-linux-gnu/..'
    sys.exec_prefix = '/lib/x86_64-linux-gnu/..'
    sys.path = [
      '/usr/bin/../lib/coccinelle/python',
      '/lib/x86_64-linux-gnu/../lib/python38.zip',
      '/lib/x86_64-linux-gnu/../lib/python3.8',
      '/lib/x86_64-linux-gnu/../lib/python3.8/lib-dynload',
    ]

Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Fun.

-Peff

#44 lore raw

Am 12.08.20 um 19:08 schrieb Jeff King:

Quoted 5 lines

Yeah, I've had various issues with the packaging. For a long time they had 1.0.7 in experimental, but with no python support. I wonder if it's worth starting to use python scriptlets in our coccinelle rules, as described in 4d168e742a (coccinelle: use <...> for function exclusion, 2018-08-28). They're faster and IMHO easier to understand.

The idea to use Python as a faster alternative to anything makes me a bit uneasy. That can't be right. ;-)

Quoted 6 lines

Of course I tried it out and got some inscrutable errors:

SPATCH contrib/coccinelle/object_id.cocci
init_defs_builtins: /usr/bin/../lib/coccinelle/standard.h Python path configuration:

    PYTHONHOME = '/lib/x86_64-linux-gnu/..'

This looks bogus. Can you try to unset this environment variable? Or set it to "/usr"?

Quoted 13 lines

PYTHONPATH = '/usr/bin/../lib/coccinelle/python' program name = 'python3'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/usr/bin/python3' sys.base_prefix = '/lib/x86_64-linux-gnu/..' sys.base_exec_prefix = '/lib/x86_64-linux-gnu/..' sys.executable = '/usr/bin/python3' sys.prefix = '/lib/x86_64-linux-gnu/..' sys.exec_prefix = '/lib/x86_64-linux-gnu/..' sys.path = [

Quoted 8 lines

'/usr/bin/../lib/coccinelle/python', '/lib/x86_64-linux-gnu/../lib/python38.zip', '/lib/x86_64-linux-gnu/../lib/python3.8', '/lib/x86_64-linux-gnu/../lib/python3.8/lib-dynload',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

I got this instead:

-- snip --
init_defs_builtins: /usr/bin/../lib/coccinelle/standard.h
Py.find_library: unable to find the Python library [libpython3.8m.so returned Library not found] [/usr/bin/../lib/libpython3.8m.so returned Library not found] [libpython3.8.so returned Library not found] [/usr/bin/../lib/libpython3.8.so returned Library not found] -- snap --

Then I did "sudo ln -s libpython3.8.so.1.0 libpython3.8.so" in /usr/lib/x86_64-linux-gnu, and now it seems to be happy.

René

author
#45 lore raw
Quoted 9 lines · René Scharfe

Am 12.08.20 um 19:08 schrieb Jeff King:

Quoted 5 lines

Yeah, I've had various issues with the packaging. For a long time they had 1.0.7 in experimental, but with no python support. I wonder if it's worth starting to use python scriptlets in our coccinelle rules, as described in 4d168e742a (coccinelle: use <...> for function exclusion, 2018-08-28). They're faster and IMHO easier to understand.

The idea to use Python as a faster alternative to anything makes me a bit uneasy. That can't be right. ;-)

Well, when you're comparing it to some exponential algorithm with the other technique, even a scripted language can do well. :)

I definitely remember getting big speedups back at the time of that commit. But applying the patch below, building object_id.cocci.patch actually gets a few seconds slower. So maybe something changed between the various coccinelle versions. At any rate, it doesn't seem worth pursuing further.

Quoted 9 lines
Quoted 6 lines

Of course I tried it out and got some inscrutable errors:

SPATCH contrib/coccinelle/object_id.cocci
init_defs_builtins: /usr/bin/../lib/coccinelle/standard.h Python path configuration:

    PYTHONHOME = '/lib/x86_64-linux-gnu/..'

This looks bogus. Can you try to unset this environment variable? Or set it to "/usr"?

It's not set in my environment. However, I was able to solve it by fiddling with my system python packages (I'm not sure of the exact cause; it was a case of corrected-while-testing).

-Peff