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