Skip to content

Commit 89bd7fe

Browse files
derrickstoleegitster
authored andcommitted
bundle: add flags to verify_bundle()
The verify_bundle() method has a 'verbose' option, but we will want to extend this method to have more granular control over its output. First, replace this 'verbose' option with a new 'flags' option with a single possible value: VERIFY_BUNDLE_VERBOSE. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c23f592 commit 89bd7fe

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

builtin/bundle.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ static int cmd_bundle_verify(int argc, const char **argv, const char *prefix) {
119119
goto cleanup;
120120
}
121121
close(bundle_fd);
122-
if (verify_bundle(the_repository, &header, !quiet)) {
122+
if (verify_bundle(the_repository, &header,
123+
quiet ? 0 : VERIFY_BUNDLE_VERBOSE)) {
123124
ret = 1;
124125
goto cleanup;
125126
}
@@ -185,7 +186,7 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix)
185186
strvec_pushl(&extra_index_pack_args, "-v", "--progress-title",
186187
_("Unbundling objects"), NULL);
187188
ret = !!unbundle(the_repository, &header, bundle_fd,
188-
&extra_index_pack_args) ||
189+
&extra_index_pack_args, 0) ||
189190
list_bundle_refs(&header, argc, argv);
190191
bundle_header_release(&header);
191192
cleanup:

bundle-uri.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,12 @@ static int unbundle_from_file(struct repository *r, const char *file)
303303
if ((bundle_fd = read_bundle_header(file, &header)) < 0)
304304
return 1;
305305

306-
if ((result = unbundle(r, &header, bundle_fd, NULL)))
306+
/*
307+
* Skip the reachability walk here, since we will be adding
308+
* a reachable ref pointing to the new tips, which will reach
309+
* the prerequisite commits.
310+
*/
311+
if ((result = unbundle(r, &header, bundle_fd, NULL, 0)))
307312
return 1;
308313

309314
/*

bundle.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ static int list_refs(struct string_list *r, int argc, const char **argv)
189189

190190
int verify_bundle(struct repository *r,
191191
struct bundle_header *header,
192-
int verbose)
192+
enum verify_bundle_flags flags)
193193
{
194194
/*
195195
* Do fast check, then if any prereqs are missing then go line by line
@@ -248,7 +248,7 @@ int verify_bundle(struct repository *r,
248248
error("%s %s", oid_to_hex(oid), name);
249249
}
250250

251-
if (verbose) {
251+
if (flags & VERIFY_BUNDLE_VERBOSE) {
252252
struct string_list *r;
253253

254254
r = &header->references;
@@ -617,7 +617,8 @@ int create_bundle(struct repository *r, const char *path,
617617
}
618618

619619
int unbundle(struct repository *r, struct bundle_header *header,
620-
int bundle_fd, struct strvec *extra_index_pack_args)
620+
int bundle_fd, struct strvec *extra_index_pack_args,
621+
enum verify_bundle_flags flags)
621622
{
622623
struct child_process ip = CHILD_PROCESS_INIT;
623624
strvec_pushl(&ip.args, "index-pack", "--fix-thin", "--stdin", NULL);
@@ -631,7 +632,7 @@ int unbundle(struct repository *r, struct bundle_header *header,
631632
strvec_clear(extra_index_pack_args);
632633
}
633634

634-
if (verify_bundle(r, header, 0))
635+
if (verify_bundle(r, header, flags))
635636
return -1;
636637
ip.in = bundle_fd;
637638
ip.no_stdout = 1;

bundle.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ int read_bundle_header_fd(int fd, struct bundle_header *header,
2929
int create_bundle(struct repository *r, const char *path,
3030
int argc, const char **argv, struct strvec *pack_options,
3131
int version);
32-
int verify_bundle(struct repository *r, struct bundle_header *header, int verbose);
32+
33+
enum verify_bundle_flags {
34+
VERIFY_BUNDLE_VERBOSE = (1 << 0),
35+
};
36+
37+
int verify_bundle(struct repository *r, struct bundle_header *header,
38+
enum verify_bundle_flags flags);
3339

3440
/**
3541
* Unbundle after reading the header with read_bundle_header().
@@ -40,9 +46,13 @@ int verify_bundle(struct repository *r, struct bundle_header *header, int verbos
4046
* Provide "extra_index_pack_args" to pass any extra arguments
4147
* (e.g. "-v" for verbose/progress), NULL otherwise. The provided
4248
* "extra_index_pack_args" (if any) will be strvec_clear()'d for you.
49+
*
50+
* Before unbundling, this method will call verify_bundle() with the
51+
* given 'flags'.
4352
*/
4453
int unbundle(struct repository *r, struct bundle_header *header,
45-
int bundle_fd, struct strvec *extra_index_pack_args);
54+
int bundle_fd, struct strvec *extra_index_pack_args,
55+
enum verify_bundle_flags flags);
4656
int list_bundle_refs(struct bundle_header *header,
4757
int argc, const char **argv);
4858

transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static int fetch_refs_from_bundle(struct transport *transport,
178178
if (!data->get_refs_from_bundle_called)
179179
get_refs_from_bundle_inner(transport);
180180
ret = unbundle(the_repository, &data->header, data->fd,
181-
&extra_index_pack_args);
181+
&extra_index_pack_args, 0);
182182
transport->hash_algo = data->header.hash_algo;
183183
return ret;
184184
}

0 commit comments

Comments
 (0)