summaryrefslogtreecommitdiff
path: root/bundle.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-12-25 18:46:14 +0100
committerJunio C Hamano <gitster@pobox.com>2017-12-28 13:50:05 -0800
commit63647391e6c306363dcb61d160c84cc601912efb (patch)
treefa1fec16eabad8fb9d8efd368c96b205cee24b3d /bundle.c
parent148f14ab5e066bb95a9f0bc00380ca98369555dd (diff)
downloadgit-63647391e6c306363dcb61d160c84cc601912efb.tar.gz
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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'bundle.c')
-rw-r--r--bundle.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/bundle.c b/bundle.c
index c092d5d68f..0d07202f8c 100644
--- a/bundle.c
+++ b/bundle.c
@@ -134,7 +134,6 @@ int verify_bundle(struct bundle_header *header, int verbose)
struct ref_list *p = &header->prerequisites;
struct rev_info revs;
const char *argv[] = {NULL, "--all", NULL};
- struct object_array refs;
struct commit *commit;
int i, ret = 0, req_nr;
const char *message = _("Repository lacks these prerequisite commits:");
@@ -157,14 +156,6 @@ int verify_bundle(struct bundle_header *header, int verbose)
req_nr = revs.pending.nr;
setup_revisions(2, argv, &revs, NULL);
- /* Save pending objects, so they can be cleaned up later. */
- refs = revs.pending;
- revs.leak_pending = 1;
-
- /*
- * prepare_revision_walk (together with .leak_pending = 1) makes us
- * the sole owner of the list of pending objects.
- */
if (prepare_revision_walk(&revs))
die(_("revision walk setup failed"));
@@ -173,18 +164,24 @@ int verify_bundle(struct bundle_header *header, int verbose)
if (commit->object.flags & PREREQ_MARK)
i--;
- for (i = 0; i < req_nr; i++)
- if (!(refs.objects[i].item->flags & SHOWN)) {
- if (++ret == 1)
- error("%s", message);
- error("%s %s", oid_to_hex(&refs.objects[i].item->oid),
- refs.objects[i].name);
- }
+ for (i = 0; i < p->nr; i++) {
+ struct ref_list_entry *e = p->list + i;
+ struct object *o = parse_object(&e->oid);
+ assert(o); /* otherwise we'd have returned early */
+ if (o->flags & SHOWN)
+ continue;
+ if (++ret == 1)
+ error("%s", message);
+ error("%s %s", oid_to_hex(&e->oid), e->name);
+ }
/* Clean up objects used, as they will be reused. */
- clear_commit_marks_for_object_array(&refs, ALL_REV_FLAGS);
-
- object_array_clear(&refs);
+ for (i = 0; i < p->nr; i++) {
+ struct ref_list_entry *e = p->list + i;
+ commit = lookup_commit_reference_gently(&e->oid, 1);
+ if (commit)
+ clear_commit_marks(commit, ALL_REV_FLAGS);
+ }
if (verbose) {
struct ref_list *r;