Skip to content

Commit 17cabd3

Browse files
pks-tgitster
authored andcommitted
fetch-pack: move fsck options into function scope
When fetching a packfile, we optionally verify received objects via the fsck subsystem. The options for those consistency checks are declared in global scope without a good reason, and they are never cleaned up. So in case the options are reused, they may accumulate more state over time. Furthermore, in subsequent changes we'll introduce a repository pointer into the structure. Obviously though, we don't have a repository available at static time, except for `the_repository`, which we don't want to use here. Refactor the code to move the options into the respective functions and properly manage their lifecycle. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent ca1db8a commit 17cabd3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

fetch-pack.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ static int server_supports_filtering;
5151
static int advertise_sid;
5252
static struct shallow_lock shallow_lock;
5353
static const char *alternate_shallow_file;
54-
static struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES;
5554
static struct strbuf fsck_msg_types = STRBUF_INIT;
5655
static struct string_list uri_protocols = STRING_LIST_INIT_DUP;
5756

@@ -1100,6 +1099,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
11001099
struct shallow_info *si,
11011100
struct string_list *pack_lockfiles)
11021101
{
1102+
struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES;
11031103
struct repository *r = the_repository;
11041104
struct ref *ref = copy_ref_list(orig_ref);
11051105
struct object_id oid;
@@ -1235,6 +1235,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
12351235
die("fsck failed");
12361236

12371237
all_done:
1238+
fsck_options_clear(&fsck_options);
12381239
if (negotiator)
12391240
negotiator->release(negotiator);
12401241
return ref;
@@ -1654,6 +1655,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
16541655
struct string_list *pack_lockfiles)
16551656
{
16561657
struct repository *r = the_repository;
1658+
struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES;
16571659
struct ref *ref = copy_ref_list(orig_ref);
16581660
enum fetch_state state = FETCH_CHECK_LOCAL;
16591661
struct oidset common = OIDSET_INIT;
@@ -1882,6 +1884,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
18821884
if (negotiator)
18831885
negotiator->release(negotiator);
18841886

1887+
fsck_options_clear(&fsck_options);
18851888
oidset_clear(&common);
18861889
return ref;
18871890
}

0 commit comments

Comments
 (0)