bundle: use leak_pending flag
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Sat, 1 Oct 2011 16:02:36 +0000 (18:02 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 Oct 2011 18:15:31 +0000 (11:15 -0700)
Instead of creating a copy of the list of pending objects, copy the
struct object_array that points to it, turn on leak_pending, and thus
cause prepare_revision_walk to leave it to us. And free it once
we're done.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bundle.c
index f48fd7d4c1c706b68e879e4dfabdd3fb8597a328..26cc9ab50732ff96e4a94f81c563d9bd589fe2b6 100644 (file)
--- a/bundle.c
+++ b/bundle.c
@@ -122,11 +122,8 @@ int verify_bundle(struct bundle_header *header, int verbose)
        req_nr = revs.pending.nr;
        setup_revisions(2, argv, &revs, NULL);
 
-       memset(&refs, 0, sizeof(struct object_array));
-       for (i = 0; i < revs.pending.nr; i++) {
-               struct object_array_entry *e = revs.pending.objects + i;
-               add_object_array(e->item, e->name, &refs);
-       }
+       refs = revs.pending;
+       revs.leak_pending = 1;
 
        if (prepare_revision_walk(&revs))
                die("revision walk setup failed");
@@ -146,6 +143,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
 
        for (i = 0; i < refs.nr; i++)
                clear_commit_marks((struct commit *)refs.objects[i].item, -1);
+       free(refs.objects);
 
        if (verbose) {
                struct ref_list *r;