Skip to content

Commit 74ae4b6

Browse files
pcloudsgitster
authored andcommitted
bundle.c: remove the_repository references
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4edce17 commit 74ae4b6

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

builtin/bundle.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
4040
usage(builtin_bundle_usage);
4141
return 1;
4242
}
43-
if (verify_bundle(&header, 1))
43+
if (verify_bundle(the_repository, &header, 1))
4444
return 1;
4545
fprintf(stderr, _("%s is okay\n"), bundle_file);
4646
return 0;
@@ -56,11 +56,12 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
5656
}
5757
if (!startup_info->have_repository)
5858
die(_("Need a repository to create a bundle."));
59-
return !!create_bundle(&header, bundle_file, argc, argv);
59+
return !!create_bundle(the_repository, &header,
60+
bundle_file, argc, argv);
6061
} else if (!strcmp(cmd, "unbundle")) {
6162
if (!startup_info->have_repository)
6263
die(_("Need a repository to unbundle."));
63-
return !!unbundle(&header, bundle_fd, 0) ||
64+
return !!unbundle(the_repository, &header, bundle_fd, 0) ||
6465
list_bundle_refs(&header, argc, argv);
6566
} else
6667
usage(builtin_bundle_usage);

bundle.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ static int list_refs(struct ref_list *r, int argc, const char **argv)
127127
/* Remember to update object flag allocation in object.h */
128128
#define PREREQ_MARK (1u<<16)
129129

130-
int verify_bundle(struct bundle_header *header, int verbose)
130+
int verify_bundle(struct repository *r,
131+
struct bundle_header *header,
132+
int verbose)
131133
{
132134
/*
133135
* Do fast check, then if any prereqs are missing then go line by line
@@ -140,10 +142,10 @@ int verify_bundle(struct bundle_header *header, int verbose)
140142
int i, ret = 0, req_nr;
141143
const char *message = _("Repository lacks these prerequisite commits:");
142144

143-
repo_init_revisions(the_repository, &revs, NULL);
145+
repo_init_revisions(r, &revs, NULL);
144146
for (i = 0; i < p->nr; i++) {
145147
struct ref_list_entry *e = p->list + i;
146-
struct object *o = parse_object(the_repository, &e->oid);
148+
struct object *o = parse_object(r, &e->oid);
147149
if (o) {
148150
o->flags |= PREREQ_MARK;
149151
add_pending_object(&revs, o, e->name);
@@ -168,7 +170,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
168170

169171
for (i = 0; i < p->nr; i++) {
170172
struct ref_list_entry *e = p->list + i;
171-
struct object *o = parse_object(the_repository, &e->oid);
173+
struct object *o = parse_object(r, &e->oid);
172174
assert(o); /* otherwise we'd have returned early */
173175
if (o->flags & SHOWN)
174176
continue;
@@ -180,7 +182,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
180182
/* Clean up objects used, as they will be reused. */
181183
for (i = 0; i < p->nr; i++) {
182184
struct ref_list_entry *e = p->list + i;
183-
commit = lookup_commit_reference_gently(the_repository, &e->oid, 1);
185+
commit = lookup_commit_reference_gently(r, &e->oid, 1);
184186
if (commit)
185187
clear_commit_marks(commit, ALL_REV_FLAGS);
186188
}
@@ -375,8 +377,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
375377
* in terms of a tag (e.g. v2.0 from the range
376378
* "v1.0..v2.0")?
377379
*/
378-
struct commit *one = lookup_commit_reference(the_repository,
379-
&oid);
380+
struct commit *one = lookup_commit_reference(revs->repo, &oid);
380381
struct object *obj;
381382

382383
if (e->item == &(one->object)) {
@@ -409,8 +410,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
409410
return ref_count;
410411
}
411412

412-
int create_bundle(struct bundle_header *header, const char *path,
413-
int argc, const char **argv)
413+
int create_bundle(struct repository *r, struct bundle_header *header,
414+
const char *path, int argc, const char **argv)
414415
{
415416
struct lock_file lock = LOCK_INIT;
416417
int bundle_fd = -1;
@@ -441,7 +442,7 @@ int create_bundle(struct bundle_header *header, const char *path,
441442

442443
/* init revs to list objects for pack-objects later */
443444
save_commit_buffer = 0;
444-
repo_init_revisions(the_repository, &revs, NULL);
445+
repo_init_revisions(r, &revs, NULL);
445446

446447
/* write prerequisites */
447448
if (compute_and_write_prerequisites(bundle_fd, &revs, argc, argv))
@@ -482,7 +483,8 @@ int create_bundle(struct bundle_header *header, const char *path,
482483
return -1;
483484
}
484485

485-
int unbundle(struct bundle_header *header, int bundle_fd, int flags)
486+
int unbundle(struct repository *r, struct bundle_header *header,
487+
int bundle_fd, int flags)
486488
{
487489
const char *argv_index_pack[] = {"index-pack",
488490
"--fix-thin", "--stdin", NULL, NULL};
@@ -491,7 +493,7 @@ int unbundle(struct bundle_header *header, int bundle_fd, int flags)
491493
if (flags & BUNDLE_VERBOSE)
492494
argv_index_pack[3] = "-v";
493495

494-
if (verify_bundle(header, 0))
496+
if (verify_bundle(r, header, 0))
495497
return -1;
496498
ip.argv = argv_index_pack;
497499
ip.in = bundle_fd;

bundle.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ struct bundle_header {
1818

1919
int is_bundle(const char *path, int quiet);
2020
int read_bundle_header(const char *path, struct bundle_header *header);
21-
int create_bundle(struct bundle_header *header, const char *path,
22-
int argc, const char **argv);
23-
int verify_bundle(struct bundle_header *header, int verbose);
21+
int create_bundle(struct repository *r, struct bundle_header *header,
22+
const char *path, int argc, const char **argv);
23+
int verify_bundle(struct repository *r, struct bundle_header *header, int verbose);
2424
#define BUNDLE_VERBOSE 1
25-
int unbundle(struct bundle_header *header, int bundle_fd, int flags);
25+
int unbundle(struct repository *r, struct bundle_header *header,
26+
int bundle_fd, int flags);
2627
int list_bundle_refs(struct bundle_header *header,
2728
int argc, const char **argv);
2829

transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static int fetch_refs_from_bundle(struct transport *transport,
154154
int nr_heads, struct ref **to_fetch)
155155
{
156156
struct bundle_transport_data *data = transport->data;
157-
return unbundle(&data->header, data->fd,
157+
return unbundle(the_repository, &data->header, data->fd,
158158
transport->progress ? BUNDLE_VERBOSE : 0);
159159
}
160160

0 commit comments

Comments
 (0)