bundle.c: remove the_repository references
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Nov 10, 2018 at 06:49 UTC
74ae4b638d0acf6ab155422152d7ad98fdbe6f6b
4 files changed
+24
-20
builtin/bundle.c
+4
-3
@@ -40,7 +40,7 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
40
usage(builtin_bundle_usage);
41
return 1;
42
}
43
- if (verify_bundle(&header, 1))
43
+ if (verify_bundle(the_repository, &header, 1))
44
return 1;
45
fprintf(stderr, _("%s is okay\n"), bundle_file);
46
return 0;
@@ -56,11 +56,12 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
56
}
57
if (!startup_info->have_repository)
58
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);
61
} else if (!strcmp(cmd, "unbundle")) {
62
if (!startup_info->have_repository)
63
die(_("Need a repository to unbundle."));
63
- return !!unbundle(&header, bundle_fd, 0) ||
64
+ return !!unbundle(the_repository, &header, bundle_fd, 0) ||
65
list_bundle_refs(&header, argc, argv);
66
} else
67
usage(builtin_bundle_usage);
bundle.c
+14
-12
@@ -127,7 +127,9 @@ static int list_refs(struct ref_list *r, int argc, const char **argv)
127
/* Remember to update object flag allocation in object.h */
128
#define PREREQ_MARK (1u<<16)
129
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)
133
{
134
/*
135
* 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)
142
int i, ret = 0, req_nr;
143
const char *message = _("Repository lacks these prerequisite commits:");
144
143
- repo_init_revisions(the_repository, &revs, NULL);
145
+ repo_init_revisions(r, &revs, NULL);
146
for (i = 0; i < p->nr; i++) {
147
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);
149
if (o) {
150
o->flags |= PREREQ_MARK;
151
add_pending_object(&revs, o, e->name);
@@ -168,7 +170,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
170
171
for (i = 0; i < p->nr; i++) {
172
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);
174
assert(o); /* otherwise we'd have returned early */
175
if (o->flags & SHOWN)
176
continue;
@@ -180,7 +182,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
182
/* Clean up objects used, as they will be reused. */
183
for (i = 0; i < p->nr; i++) {
184
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);
186
if (commit)
187
clear_commit_marks(commit, ALL_REV_FLAGS);
188
}
@@ -375,8 +377,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
377
* in terms of a tag (e.g. v2.0 from the range
378
* "v1.0..v2.0")?
379
*/
378
- struct commit *one = lookup_commit_reference(the_repository,
379
- &oid);
380
+ struct commit *one = lookup_commit_reference(revs->repo, &oid);
381
struct object *obj;
382
383
if (e->item == &(one->object)) {
@@ -409,8 +410,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
410
return ref_count;
411
}
412
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)
415
{
416
struct lock_file lock = LOCK_INIT;
417
int bundle_fd = -1;
@@ -441,7 +442,7 @@ int create_bundle(struct bundle_header *header, const char *path,
442
443
/* init revs to list objects for pack-objects later */
444
save_commit_buffer = 0;
444
- repo_init_revisions(the_repository, &revs, NULL);
445
+ repo_init_revisions(r, &revs, NULL);
446
447
/* write prerequisites */
448
if (compute_and_write_prerequisites(bundle_fd, &revs, argc, argv))
@@ -482,7 +483,8 @@ err:
483
return -1;
484
}
485
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)
488
{
489
const char *argv_index_pack[] = {"index-pack",
490
"--fix-thin", "--stdin", NULL, NULL};
@@ -491,7 +493,7 @@ int unbundle(struct bundle_header *header, int bundle_fd, int flags)
493
if (flags & BUNDLE_VERBOSE)
494
argv_index_pack[3] = "-v";
495
494
- if (verify_bundle(header, 0))
496
+ if (verify_bundle(r, header, 0))
497
return -1;
498
ip.argv = argv_index_pack;
499
ip.in = bundle_fd;
bundle.h
+5
-4
@@ -18,11 +18,12 @@ struct bundle_header {
18
19
int is_bundle(const char *path, int quiet);
20
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);
24
#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);
27
int list_bundle_refs(struct bundle_header *header,
28
int argc, const char **argv);
29
transport.c
+1
-1
@@ -154,7 +154,7 @@ static int fetch_refs_from_bundle(struct transport *transport,
154
int nr_heads, struct ref **to_fetch)
155
{
156
struct bundle_transport_data *data = transport->data;
157
- return unbundle(&data->header, data->fd,
157
+ return unbundle(the_repository, &data->header, data->fd,
158
transport->progress ? BUNDLE_VERBOSE : 0);
159
}
160