Skip to content

Commit 6364739

Browse files
rscharfegitster
authored andcommitted
bundle: avoid using the rev_info flag leak_pending
The leak_pending flag is so awkward to use that multiple comments had to be added around each occurrence. We use it for remembering the prerequisites for the bundle. That is easy, though: We have the ref_list named "prerequisites" in the header for just that purpose. Use this original list of prerequisites to check if all of them are present and to clear their commit marks afterward. The two new loops are intentionally kept similar to the first one in the function. Calling parse_object() a second time is expected be quick and successful in each case -- any errors should have been handled in the first round. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 148f14a commit 6364739

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

bundle.c

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ int verify_bundle(struct bundle_header *header, int verbose)
134134
struct ref_list *p = &header->prerequisites;
135135
struct rev_info revs;
136136
const char *argv[] = {NULL, "--all", NULL};
137-
struct object_array refs;
138137
struct commit *commit;
139138
int i, ret = 0, req_nr;
140139
const char *message = _("Repository lacks these prerequisite commits:");
@@ -157,14 +156,6 @@ int verify_bundle(struct bundle_header *header, int verbose)
157156
req_nr = revs.pending.nr;
158157
setup_revisions(2, argv, &revs, NULL);
159158

160-
/* Save pending objects, so they can be cleaned up later. */
161-
refs = revs.pending;
162-
revs.leak_pending = 1;
163-
164-
/*
165-
* prepare_revision_walk (together with .leak_pending = 1) makes us
166-
* the sole owner of the list of pending objects.
167-
*/
168159
if (prepare_revision_walk(&revs))
169160
die(_("revision walk setup failed"));
170161

@@ -173,18 +164,24 @@ int verify_bundle(struct bundle_header *header, int verbose)
173164
if (commit->object.flags & PREREQ_MARK)
174165
i--;
175166

176-
for (i = 0; i < req_nr; i++)
177-
if (!(refs.objects[i].item->flags & SHOWN)) {
178-
if (++ret == 1)
179-
error("%s", message);
180-
error("%s %s", oid_to_hex(&refs.objects[i].item->oid),
181-
refs.objects[i].name);
182-
}
167+
for (i = 0; i < p->nr; i++) {
168+
struct ref_list_entry *e = p->list + i;
169+
struct object *o = parse_object(&e->oid);
170+
assert(o); /* otherwise we'd have returned early */
171+
if (o->flags & SHOWN)
172+
continue;
173+
if (++ret == 1)
174+
error("%s", message);
175+
error("%s %s", oid_to_hex(&e->oid), e->name);
176+
}
183177

184178
/* Clean up objects used, as they will be reused. */
185-
clear_commit_marks_for_object_array(&refs, ALL_REV_FLAGS);
186-
187-
object_array_clear(&refs);
179+
for (i = 0; i < p->nr; i++) {
180+
struct ref_list_entry *e = p->list + i;
181+
commit = lookup_commit_reference_gently(&e->oid, 1);
182+
if (commit)
183+
clear_commit_marks(commit, ALL_REV_FLAGS);
184+
}
188185

189186
if (verbose) {
190187
struct ref_list *r;

0 commit comments

Comments
 (0)