Git fork

bundle: add bundle verification options type

When `unbundle()` is invoked, fsck verification may be configured by
passing the `VERIFY_BUNDLE_FSCK` flag. This mechanism allows fsck checks
on the bundle to be enabled or disabled entirely. To facilitate more
fine-grained fsck configuration, additional context must be provided to
`unbundle()`.

Introduce the `unbundle_opts` type, which wraps the existing
`verify_bundle_flags`, to facilitate future extension of `unbundle()`
configuration. Also update `unbundle()` and its call sites to accept
this new options type instead of the flags directly. The end behavior is
functionally the same, but allows for the set of configurable options to
be extended. This is leveraged in a subsequent commit to enable fsck
message severity configuration.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Justin Tobler and committed by
Junio C Hamano
87c01003 4083a6f0

+22 -9
+1 -1
builtin/bundle.c
··· 218 218 strvec_pushl(&extra_index_pack_args, "-v", "--progress-title", 219 219 _("Unbundling objects"), NULL); 220 220 ret = !!unbundle(the_repository, &header, bundle_fd, 221 - &extra_index_pack_args, 0) || 221 + &extra_index_pack_args, NULL) || 222 222 list_bundle_refs(&header, argc, argv); 223 223 bundle_header_release(&header); 224 224
+5 -2
bundle-uri.c
··· 367 367 struct string_list_item *refname; 368 368 struct strbuf bundle_ref = STRBUF_INIT; 369 369 size_t bundle_prefix_len; 370 + struct unbundle_opts opts = { 371 + .flags = VERIFY_BUNDLE_QUIET | 372 + (fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0), 373 + }; 370 374 371 375 bundle_fd = read_bundle_header(file, &header); 372 376 if (bundle_fd < 0) { ··· 379 383 * a reachable ref pointing to the new tips, which will reach 380 384 * the prerequisite commits. 381 385 */ 382 - result = unbundle(r, &header, bundle_fd, NULL, 383 - VERIFY_BUNDLE_QUIET | (fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0)); 386 + result = unbundle(r, &header, bundle_fd, NULL, &opts); 384 387 if (result) { 385 388 result = 1; 386 389 goto cleanup;
+5 -1
bundle.c
··· 628 628 629 629 int unbundle(struct repository *r, struct bundle_header *header, 630 630 int bundle_fd, struct strvec *extra_index_pack_args, 631 - enum verify_bundle_flags flags) 631 + struct unbundle_opts *opts) 632 632 { 633 633 struct child_process ip = CHILD_PROCESS_INIT; 634 + enum verify_bundle_flags flags = 0; 635 + 636 + if (opts) 637 + flags = opts->flags; 634 638 635 639 if (verify_bundle(r, header, flags)) 636 640 return -1;
+7 -3
bundle.h
··· 39 39 int verify_bundle(struct repository *r, struct bundle_header *header, 40 40 enum verify_bundle_flags flags); 41 41 42 + struct unbundle_opts { 43 + enum verify_bundle_flags flags; 44 + }; 45 + 42 46 /** 43 47 * Unbundle after reading the header with read_bundle_header(). 44 48 * ··· 49 53 * (e.g. "-v" for verbose/progress), NULL otherwise. The provided 50 54 * "extra_index_pack_args" (if any) will be strvec_clear()'d for you. 51 55 * 52 - * Before unbundling, this method will call verify_bundle() with the 53 - * given 'flags'. 56 + * Before unbundling, this method will call verify_bundle() with 'flags' 57 + * provided in 'opts'. 54 58 */ 55 59 int unbundle(struct repository *r, struct bundle_header *header, 56 60 int bundle_fd, struct strvec *extra_index_pack_args, 57 - enum verify_bundle_flags flags); 61 + struct unbundle_opts *opts); 58 62 int list_bundle_refs(struct bundle_header *header, 59 63 int argc, const char **argv); 60 64
+4 -2
transport.c
··· 176 176 int nr_heads UNUSED, 177 177 struct ref **to_fetch UNUSED) 178 178 { 179 + struct unbundle_opts opts = { 180 + .flags = fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0, 181 + }; 179 182 struct bundle_transport_data *data = transport->data; 180 183 struct strvec extra_index_pack_args = STRVEC_INIT; 181 184 int ret; ··· 186 189 if (!data->get_refs_from_bundle_called) 187 190 get_refs_from_bundle_inner(transport); 188 191 ret = unbundle(the_repository, &data->header, data->fd, 189 - &extra_index_pack_args, 190 - fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0); 192 + &extra_index_pack_args, &opts); 191 193 transport->hash_algo = data->header.hash_algo; 192 194 193 195 strvec_clear(&extra_index_pack_args);