fetch-pack: expose fsckObjects configuration logic

Currently, we can use "transfer.fsckObjects" and the more specific "fetch.fsckObjects" to control checks for broken objects in received packs during fetches. However, these configurations were only acknowledged by `fetch-pack.c:get_pack` and did not take effect in direct bundle fetches or fetches with _bundle-uri_ enabled. This commit exposes the fetch-then-transfer configuration logic by adding a new function `fetch_pack_fsck_objects` in fetch-pack.h. This new function is used to replace the assignment for `fsck_objects` in `fetch-pack.c:get_pack`. In the next commit, this function will also be used to extend fsck support for bundle-involved fetches. Helped-by: Junio C Hamano <gitster@pobox.com> Helped-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Xing Xin <xingxin.xx@bytedance.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Xing Xin committed Jun 19, 2024 at 04:07 UTC d0cbc75680405c85ecc3f91b12ac29b1a05a3fcf
2 files changed +16 -6
fetch-pack.c
+11 -6
@@ -954,12 +954,7 @@ static int get_pack(struct fetch_pack_args *args,
954 strvec_push(&cmd.args, alternate_shallow_file);
955 }
956
957 - if (fetch_fsck_objects >= 0
958 - ? fetch_fsck_objects
959 - : transfer_fsck_objects >= 0
960 - ? transfer_fsck_objects
961 - : 0)
962 - fsck_objects = 1;
957 + fsck_objects = fetch_pack_fsck_objects();
958
959 if (do_keep || args->from_promisor || index_pack_args || fsck_objects) {
960 if (pack_lockfiles || fsck_objects)
@@ -2046,6 +2041,16 @@ static const struct object_id *iterate_ref_map(void *cb_data)
2041 return &ref->old_oid;
2042 }
2043
2044 +int fetch_pack_fsck_objects(void)
2045 +{
2046 + fetch_pack_setup();
2047 + if (fetch_fsck_objects >= 0)
2048 + return fetch_fsck_objects;
2049 + if (transfer_fsck_objects >= 0)
2050 + return transfer_fsck_objects;
2051 + return 0;
2052 +}
2053 +
2054 struct ref *fetch_pack(struct fetch_pack_args *args,
2055 int fd[],
2056 const struct ref *ref,
fetch-pack.h
+5
@@ -101,4 +101,9 @@ void negotiate_using_fetch(const struct oid_array *negotiation_tips,
101 */
102 int report_unmatched_refs(struct ref **sought, int nr_sought);
103
104 +/*
105 + * Return true if checks for broken objects in received pack are required.
106 + */
107 +int fetch_pack_fsck_objects(void);
108 +
109 #endif