fetch-pack: move --keep=* option filling to a function
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
May 16, 2022 at 20:11 UTC
1f6cf4508ed554b473bb1e5cf89df18f617fe2a2
1 file changed
+12
-8
fetch-pack.c
+12
-8
@@ -847,6 +847,16 @@ static void parse_gitmodules_oids(int fd, struct oidset *gitmodules_oids)
847
} while (1);
848
}
849
850
+static void add_index_pack_keep_option(struct strvec *args)
851
+{
852
+ char hostname[HOST_NAME_MAX + 1];
853
+
854
+ if (xgethostname(hostname, sizeof(hostname)))
855
+ xsnprintf(hostname, sizeof(hostname), "localhost");
856
+ strvec_pushf(args, "--keep=fetch-pack %"PRIuMAX " on %s",
857
+ (uintmax_t)getpid(), hostname);
858
+}
859
+
860
/*
861
* If packfile URIs were provided, pass a non-NULL pointer to index_pack_args.
862
* 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,
926
strvec_push(&cmd.args, "-v");
927
if (args->use_thin_pack)
928
strvec_push(&cmd.args, "--fix-thin");
919
- if ((do_keep || index_pack_args) && (args->lock_pack || unpack_limit)) {
920
- char hostname[HOST_NAME_MAX + 1];
921
- if (xgethostname(hostname, sizeof(hostname)))
922
- xsnprintf(hostname, sizeof(hostname), "localhost");
923
- strvec_pushf(&cmd.args,
924
- "--keep=fetch-pack %"PRIuMAX " on %s",
925
- (uintmax_t)getpid(), hostname);
926
- }
929
+ if ((do_keep || index_pack_args) && (args->lock_pack || unpack_limit))
930
+ add_index_pack_keep_option(&cmd.args);
931
if (!index_pack_args && args->check_self_contained_and_connected)
932
strvec_push(&cmd.args, "--check-self-contained-and-connected");
933
else