Skip to content

Commit d0cbc75

Browse files
blanetgitster
authored andcommitted
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 <[email protected]> Helped-by: Patrick Steinhardt <[email protected]> Signed-off-by: Xing Xin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3079026 commit d0cbc75

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

fetch-pack.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -954,12 +954,7 @@ static int get_pack(struct fetch_pack_args *args,
954954
strvec_push(&cmd.args, alternate_shallow_file);
955955
}
956956

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();
963958

964959
if (do_keep || args->from_promisor || index_pack_args || fsck_objects) {
965960
if (pack_lockfiles || fsck_objects)
@@ -2046,6 +2041,16 @@ static const struct object_id *iterate_ref_map(void *cb_data)
20462041
return &ref->old_oid;
20472042
}
20482043

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+
20492054
struct ref *fetch_pack(struct fetch_pack_args *args,
20502055
int fd[],
20512056
const struct ref *ref,

fetch-pack.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,9 @@ void negotiate_using_fetch(const struct oid_array *negotiation_tips,
101101
*/
102102
int report_unmatched_refs(struct ref **sought, int nr_sought);
103103

104+
/*
105+
* Return true if checks for broken objects in received pack are required.
106+
*/
107+
int fetch_pack_fsck_objects(void);
108+
104109
#endif

0 commit comments

Comments
 (0)