Skip to content
/ git Public
forked from git/git

Commit 87c0100

Browse files
jltoblergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4083a6f commit 87c0100

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

builtin/bundle.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix)
218218
strvec_pushl(&extra_index_pack_args, "-v", "--progress-title",
219219
_("Unbundling objects"), NULL);
220220
ret = !!unbundle(the_repository, &header, bundle_fd,
221-
&extra_index_pack_args, 0) ||
221+
&extra_index_pack_args, NULL) ||
222222
list_bundle_refs(&header, argc, argv);
223223
bundle_header_release(&header);
224224

bundle-uri.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ static int unbundle_from_file(struct repository *r, const char *file)
367367
struct string_list_item *refname;
368368
struct strbuf bundle_ref = STRBUF_INIT;
369369
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+
};
370374

371375
bundle_fd = read_bundle_header(file, &header);
372376
if (bundle_fd < 0) {
@@ -379,8 +383,7 @@ static int unbundle_from_file(struct repository *r, const char *file)
379383
* a reachable ref pointing to the new tips, which will reach
380384
* the prerequisite commits.
381385
*/
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);
384387
if (result) {
385388
result = 1;
386389
goto cleanup;

bundle.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -628,9 +628,13 @@ int create_bundle(struct repository *r, const char *path,
628628

629629
int unbundle(struct repository *r, struct bundle_header *header,
630630
int bundle_fd, struct strvec *extra_index_pack_args,
631-
enum verify_bundle_flags flags)
631+
struct unbundle_opts *opts)
632632
{
633633
struct child_process ip = CHILD_PROCESS_INIT;
634+
enum verify_bundle_flags flags = 0;
635+
636+
if (opts)
637+
flags = opts->flags;
634638

635639
if (verify_bundle(r, header, flags))
636640
return -1;

bundle.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ enum verify_bundle_flags {
3939
int verify_bundle(struct repository *r, struct bundle_header *header,
4040
enum verify_bundle_flags flags);
4141

42+
struct unbundle_opts {
43+
enum verify_bundle_flags flags;
44+
};
45+
4246
/**
4347
* Unbundle after reading the header with read_bundle_header().
4448
*
@@ -49,12 +53,12 @@ int verify_bundle(struct repository *r, struct bundle_header *header,
4953
* (e.g. "-v" for verbose/progress), NULL otherwise. The provided
5054
* "extra_index_pack_args" (if any) will be strvec_clear()'d for you.
5155
*
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'.
5458
*/
5559
int unbundle(struct repository *r, struct bundle_header *header,
5660
int bundle_fd, struct strvec *extra_index_pack_args,
57-
enum verify_bundle_flags flags);
61+
struct unbundle_opts *opts);
5862
int list_bundle_refs(struct bundle_header *header,
5963
int argc, const char **argv);
6064

transport.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ static int fetch_refs_from_bundle(struct transport *transport,
176176
int nr_heads UNUSED,
177177
struct ref **to_fetch UNUSED)
178178
{
179+
struct unbundle_opts opts = {
180+
.flags = fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0,
181+
};
179182
struct bundle_transport_data *data = transport->data;
180183
struct strvec extra_index_pack_args = STRVEC_INIT;
181184
int ret;
@@ -186,8 +189,7 @@ static int fetch_refs_from_bundle(struct transport *transport,
186189
if (!data->get_refs_from_bundle_called)
187190
get_refs_from_bundle_inner(transport);
188191
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);
191193
transport->hash_algo = data->header.hash_algo;
192194

193195
strvec_clear(&extra_index_pack_args);

0 commit comments

Comments
 (0)