Skip to content

Commit 1f6cf45

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a6e65fb commit 1f6cf45

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

fetch-pack.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,16 @@ static void parse_gitmodules_oids(int fd, struct oidset *gitmodules_oids)
847847
} while (1);
848848
}
849849

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+
850860
/*
851861
* If packfile URIs were provided, pass a non-NULL pointer to index_pack_args.
852862
* 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,
916926
strvec_push(&cmd.args, "-v");
917927
if (args->use_thin_pack)
918928
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);
927931
if (!index_pack_args && args->check_self_contained_and_connected)
928932
strvec_push(&cmd.args, "--check-self-contained-and-connected");
929933
else

0 commit comments

Comments
 (0)