summaryrefslogtreecommitdiff
path: root/builtin/gc.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2020-07-28 16:24:27 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-07-28 15:02:18 -0700
commit22f9b7f3f59549735a480042a4b9ce292eedfae0 (patch)
treeaf564ca6084c9790ea99dd60291d7aa9f854fecb /builtin/gc.c
parentquote: rename sq_dequote_to_argv_array to mention strvec (diff)
downloadtgif-22f9b7f3f59549735a480042a4b9ce292eedfae0.tar.xz
strvec: convert builtin/ callers away from argv_array name
We eventually want to drop the argv_array name and just use strvec consistently. There's no particular reason we have to do it all at once, or care about interactions between converted and unconverted bits. Because of our preprocessor compat layer, the names are interchangeable to the compiler (so even a definition and declaration using different names is OK). This patch converts all of the 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. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/gc.c')
-rw-r--r--builtin/gc.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/builtin/gc.c b/builtin/gc.c
index 27951ee061..89742e159e 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -50,12 +50,12 @@ static const char *prune_worktrees_expire = "3.months.ago";
static unsigned long big_pack_threshold;
static unsigned long max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE;
-static struct argv_array pack_refs_cmd = ARGV_ARRAY_INIT;
-static struct argv_array reflog = ARGV_ARRAY_INIT;
-static struct argv_array repack = ARGV_ARRAY_INIT;
-static struct argv_array prune = ARGV_ARRAY_INIT;
-static struct argv_array prune_worktrees = ARGV_ARRAY_INIT;
-static struct argv_array rerere = ARGV_ARRAY_INIT;
+static struct strvec pack_refs_cmd = STRVEC_INIT;
+static struct strvec reflog = STRVEC_INIT;
+static struct strvec repack = STRVEC_INIT;
+static struct strvec prune = STRVEC_INIT;
+static struct strvec prune_worktrees = STRVEC_INIT;
+static struct strvec rerere = STRVEC_INIT;
static struct tempfile *pidfile;
static struct lock_file log_lock;
@@ -311,18 +311,18 @@ static uint64_t estimate_repack_memory(struct packed_git *pack)
static int keep_one_pack(struct string_list_item *item, void *data)
{
- argv_array_pushf(&repack, "--keep-pack=%s", basename(item->string));
+ strvec_pushf(&repack, "--keep-pack=%s", basename(item->string));
return 0;
}
static void add_repack_all_option(struct string_list *keep_pack)
{
if (prune_expire && !strcmp(prune_expire, "now"))
- argv_array_push(&repack, "-a");
+ strvec_push(&repack, "-a");
else {
- argv_array_push(&repack, "-A");
+ strvec_push(&repack, "-A");
if (prune_expire)
- argv_array_pushf(&repack, "--unpack-unreachable=%s", prune_expire);
+ strvec_pushf(&repack, "--unpack-unreachable=%s", prune_expire);
}
if (keep_pack)
@@ -331,7 +331,7 @@ static void add_repack_all_option(struct string_list *keep_pack)
static void add_repack_incremental_option(void)
{
- argv_array_push(&repack, "--no-write-bitmap-index");
+ strvec_push(&repack, "--no-write-bitmap-index");
}
static int need_to_gc(void)
@@ -552,12 +552,12 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
if (argc == 2 && !strcmp(argv[1], "-h"))
usage_with_options(builtin_gc_usage, builtin_gc_options);
- argv_array_pushl(&pack_refs_cmd, "pack-refs", "--all", "--prune", NULL);
- argv_array_pushl(&reflog, "reflog", "expire", "--all", NULL);
- argv_array_pushl(&repack, "repack", "-d", "-l", NULL);
- argv_array_pushl(&prune, "prune", "--expire", NULL);
- argv_array_pushl(&prune_worktrees, "worktree", "prune", "--expire", NULL);
- argv_array_pushl(&rerere, "rerere", "gc", NULL);
+ strvec_pushl(&pack_refs_cmd, "pack-refs", "--all", "--prune", NULL);
+ strvec_pushl(&reflog, "reflog", "expire", "--all", NULL);
+ strvec_pushl(&repack, "repack", "-d", "-l", NULL);
+ strvec_pushl(&prune, "prune", "--expire", NULL);
+ strvec_pushl(&prune_worktrees, "worktree", "prune", "--expire", NULL);
+ strvec_pushl(&rerere, "rerere", "gc", NULL);
/* default expiry time, overwritten in gc_config */
gc_config();
@@ -576,14 +576,14 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
die(_("failed to parse prune expiry value %s"), prune_expire);
if (aggressive) {
- argv_array_push(&repack, "-f");
+ strvec_push(&repack, "-f");
if (aggressive_depth > 0)
- argv_array_pushf(&repack, "--depth=%d", aggressive_depth);
+ strvec_pushf(&repack, "--depth=%d", aggressive_depth);
if (aggressive_window > 0)
- argv_array_pushf(&repack, "--window=%d", aggressive_window);
+ strvec_pushf(&repack, "--window=%d", aggressive_window);
}
if (quiet)
- argv_array_push(&repack, "-q");
+ strvec_push(&repack, "-q");
if (auto_gc) {
/*
@@ -657,11 +657,11 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
die(FAILED_RUN, repack.argv[0]);
if (prune_expire) {
- argv_array_push(&prune, prune_expire);
+ strvec_push(&prune, prune_expire);
if (quiet)
- argv_array_push(&prune, "--no-progress");
+ strvec_push(&prune, "--no-progress");
if (has_promisor_remote())
- argv_array_push(&prune,
+ strvec_push(&prune,
"--exclude-promisor-objects");
if (run_command_v_opt(prune.argv, RUN_GIT_CMD))
die(FAILED_RUN, prune.argv[0]);
@@ -669,7 +669,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
}
if (prune_worktrees_expire) {
- argv_array_push(&prune_worktrees, 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]);
}