aboutsummaryrefslogtreecommitdiff
path: root/fetch-pack.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-03-23 16:02:53 +0100
committerJunio C Hamano <gitster@pobox.com>2026-03-23 08:33:10 -0700
commitf22360902621e0807a1c0a77476e3e4d323c708d (patch)
treead15abf7edc06866b913901a3de9aee6b31218a3 /fetch-pack.c
parent17cabd369b5cb96bee9577f49247ef95d07058a7 (diff)
downloadgit-f22360902621e0807a1c0a77476e3e4d323c708d.tar.xz
fsck: initialize fsck options via a function
We initialize the `struct fsck_options` via a set of macros, often in global scope. In the next commit though we're about to introduce a new repository field to the options that must be initialized, and naturally we don't have a repo other than `the_repository` available in this scope. Refactor the code to instead intrdouce a new `fsck_options_init()` function that initializes the options for us and move initialization into function scope. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fetch-pack.c')
-rw-r--r--fetch-pack.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fetch-pack.c b/fetch-pack.c
index ec5abb92b5..7339162368 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1099,7 +1099,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
struct shallow_info *si,
struct string_list *pack_lockfiles)
{
- struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES;
+ struct fsck_options fsck_options = { 0 };
struct repository *r = the_repository;
struct ref *ref = copy_ref_list(orig_ref);
struct object_id oid;
@@ -1228,6 +1228,8 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
alternate_shallow_file = setup_temporary_shallow(si->shallow);
} else
alternate_shallow_file = NULL;
+
+ fsck_options_init(&fsck_options, FSCK_OPTIONS_MISSING_GITMODULES);
if (get_pack(args, fd, pack_lockfiles, NULL, sought, nr_sought,
&fsck_options.gitmodules_found))
die(_("git fetch-pack: fetch failed."));
@@ -1655,7 +1657,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
struct string_list *pack_lockfiles)
{
struct repository *r = the_repository;
- struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES;
+ struct fsck_options fsck_options;
struct ref *ref = copy_ref_list(orig_ref);
enum fetch_state state = FETCH_CHECK_LOCAL;
struct oidset common = OIDSET_INIT;
@@ -1673,6 +1675,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
struct strvec index_pack_args = STRVEC_INIT;
const char *promisor_remote_config;
+ fsck_options_init(&fsck_options, FSCK_OPTIONS_MISSING_GITMODULES);
+
if (server_feature_v2("promisor-remote", &promisor_remote_config))
promisor_remote_reply(promisor_remote_config, NULL);