transport: propagate fsck configuration during bundle fetch

When fetching directly from a bundle, fsck message severity configuration is not propagated to the underlying git-index-pack(1). It is only capable of enabling or disabling fsck checks entirely. This does not align with the fsck behavior for fetches through git-fetch-pack(1). Use the fsck config parsing from fetch-pack to populate fsck message severity configuration and wire it through to `unbundle()` to enable the same fsck verification as done through fetch-pack. Signed-off-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Justin Tobler committed Nov 27, 2024 at 17:33 UTC baa159137be36965e03192528b001ffc39b8352f
2 files changed +27
t/t5607-clone-bundle.sh
+7
@@ -171,6 +171,13 @@ test_expect_success 'clone bundle with different fsckObjects configurations' '
171
172 test_must_fail git -c transfer.fsckObjects=true \
173 clone bundle-fsck/bad.bundle bundle-transfer-fsck 2>err &&
174 + test_grep "missingEmail" err &&
175 +
176 + git -c fetch.fsckObjects=true -c fetch.fsck.missingEmail=ignore \
177 + clone bundle-fsck/bad.bundle bundle-fsck-ignore &&
178 +
179 + test_must_fail git -c fetch.fsckObjects=true -c fetch.fsck.missingEmail=error \
180 + clone bundle-fsck/bad.bundle bundle-fsck-error 2>err &&
181 test_grep "missingEmail" err
182 '
183
transport.c
+20
@@ -19,6 +19,7 @@
19 #include "branch.h"
20 #include "url.h"
21 #include "submodule.h"
22 +#include "strbuf.h"
23 #include "string-list.h"
24 #include "oid-array.h"
25 #include "sigchain.h"
@@ -172,6 +173,19 @@ static struct ref *get_refs_from_bundle(struct transport *transport,
173 return result;
174 }
175
176 +static int fetch_fsck_config_cb(const char *var, const char *value,
177 + const struct config_context *ctx UNUSED, void *cb)
178 +{
179 + struct strbuf *msg_types = cb;
180 + int ret;
181 +
182 + ret = fetch_pack_fsck_config(var, value, msg_types);
183 + if (ret > 0)
184 + return 0;
185 +
186 + return ret;
187 +}
188 +
189 static int fetch_refs_from_bundle(struct transport *transport,
190 int nr_heads UNUSED,
191 struct ref **to_fetch UNUSED)
@@ -181,6 +195,7 @@ static int fetch_refs_from_bundle(struct transport *transport,
195 };
196 struct bundle_transport_data *data = transport->data;
197 struct strvec extra_index_pack_args = STRVEC_INIT;
198 + struct strbuf msg_types = STRBUF_INIT;
199 int ret;
200
201 if (transport->progress)
@@ -188,11 +203,16 @@ static int fetch_refs_from_bundle(struct transport *transport,
203
204 if (!data->get_refs_from_bundle_called)
205 get_refs_from_bundle_inner(transport);
206 +
207 + git_config(fetch_fsck_config_cb, &msg_types);
208 + opts.fsck_msg_types = msg_types.buf;
209 +
210 ret = unbundle(the_repository, &data->header, data->fd,
211 &extra_index_pack_args, &opts);
212 transport->hash_algo = data->header.hash_algo;
213
214 strvec_clear(&extra_index_pack_args);
215 + strbuf_release(&msg_types);
216 return ret;
217 }
218