[PATCH 4/8] fetch-pack: move --keep=* option filling to a function
- From
Ævar Arnfjörð Bjarmason via GitGitGadget <gitgitgadget@gmail.com>
- Date
- May 16, 2022, 20:11 UTC
- Message-ID
- <dd7eb99cfaa4bdf787e0af414a0232e7f74730fb.1652731865.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1233.git.1652731865.gitgitgadget@gmail.com>
From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= <avarab@gmail.com>
Move the populating of the --keep=* option argument to "index-pack" to a static function, a subsequent commit will make use of it in another function.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Derrick Stolee <derrickstolee@github.com> --- fetch-pack.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/fetch-pack.c b/fetch-pack.c index d0aa3a5c229..b1d90d1914f 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -847,6 +847,16 @@ static void parse_gitmodules_oids(int fd, struct oidset *gitmodules_oids) } while (1); } +static void add_index_pack_keep_option(struct strvec *args) +{ + char hostname[HOST_NAME_MAX + 1]; + + if (xgethostname(hostname, sizeof(hostname))) + xsnprintf(hostname, sizeof(hostname), "localhost"); + strvec_pushf(args, "--keep=fetch-pack %"PRIuMAX " on %s", + (uintmax_t)getpid(), hostname); +} + /* * If packfile URIs were provided, pass a non-NULL pointer to index_pack_args. * The strings to pass as the --index-pack-arg arguments to http-fetch will be @@ -916,14 +926,8 @@ static int get_pack(struct fetch_pack_args *args, strvec_push(&cmd.args, "-v"); if (args->use_thin_pack) strvec_push(&cmd.args, "--fix-thin"); - if ((do_keep || index_pack_args) && (args->lock_pack || unpack_limit)) { - char hostname[HOST_NAME_MAX + 1]; - if (xgethostname(hostname, sizeof(hostname))) - xsnprintf(hostname, sizeof(hostname), "localhost"); - strvec_pushf(&cmd.args, - "--keep=fetch-pack %"PRIuMAX " on %s", - (uintmax_t)getpid(), hostname); - } + if ((do_keep || index_pack_args) && (args->lock_pack || unpack_limit)) + add_index_pack_keep_option(&cmd.args); if (!index_pack_args && args->check_self_contained_and_connected) strvec_push(&cmd.args, "--check-self-contained-and-connected"); else
-- gitgitgadget