Skip to content

Commit baa1591

Browse files
jltoblergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 05596e9 commit baa1591

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

t/t5607-clone-bundle.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ test_expect_success 'clone bundle with different fsckObjects configurations' '
171171
172172
test_must_fail git -c transfer.fsckObjects=true \
173173
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 &&
174181
test_grep "missingEmail" err
175182
'
176183

transport.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "branch.h"
2020
#include "url.h"
2121
#include "submodule.h"
22+
#include "strbuf.h"
2223
#include "string-list.h"
2324
#include "oid-array.h"
2425
#include "sigchain.h"
@@ -172,6 +173,19 @@ static struct ref *get_refs_from_bundle(struct transport *transport,
172173
return result;
173174
}
174175

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+
175189
static int fetch_refs_from_bundle(struct transport *transport,
176190
int nr_heads UNUSED,
177191
struct ref **to_fetch UNUSED)
@@ -181,18 +195,24 @@ static int fetch_refs_from_bundle(struct transport *transport,
181195
};
182196
struct bundle_transport_data *data = transport->data;
183197
struct strvec extra_index_pack_args = STRVEC_INIT;
198+
struct strbuf msg_types = STRBUF_INIT;
184199
int ret;
185200

186201
if (transport->progress)
187202
strvec_push(&extra_index_pack_args, "-v");
188203

189204
if (!data->get_refs_from_bundle_called)
190205
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+
191210
ret = unbundle(the_repository, &data->header, data->fd,
192211
&extra_index_pack_args, &opts);
193212
transport->hash_algo = data->header.hash_algo;
194213

195214
strvec_clear(&extra_index_pack_args);
215+
strbuf_release(&msg_types);
196216
return ret;
197217
}
198218

0 commit comments

Comments
 (0)