aboutsummaryrefslogtreecommitdiff
path: root/bisect.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2011-10-01 18:01:12 +0200
committerJunio C Hamano <gitster@pobox.com>2011-10-03 11:15:27 -0700
commit353f5657a8263bf4159d7e0450fb891df5e2b4c6 (patch)
tree0f90518dc685196e5b04c1d3f45187a3119350b3 /bisect.c
parent4a43d374fcbdea26b3596592a497a1c16f90b9e6 (diff)
downloadgit-353f5657a8263bf4159d7e0450fb891df5e2b4c6.tar.gz
git-353f5657a8263bf4159d7e0450fb891df5e2b4c6.tar.xz
bisect: use leak_pending flag
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>
Diffstat (limited to 'bisect.c')
-rw-r--r--bisect.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/bisect.c b/bisect.c
index dd7e8ed69..63cf166a6 100644
--- a/bisect.c
+++ b/bisect.c
@@ -823,12 +823,14 @@ static int check_ancestors(const char *prefix)
bisect_rev_setup(&revs, prefix, "^%s", "%s", 0);
/* Save pending objects, so they can be cleaned up later. */
- memset(&pending_copy, 0, sizeof(pending_copy));
- for (i = 0; i < revs.pending.nr; i++)
- add_object_array(revs.pending.objects[i].item,
- revs.pending.objects[i].name,
- &pending_copy);
+ pending_copy = revs.pending;
+ revs.leak_pending = 1;
+ /*
+ * bisect_common calls prepare_revision_walk right away, which
+ * (together with .leak_pending = 1) makes us the sole owner of
+ * the list of pending objects.
+ */
bisect_common(&revs);
res = (revs.commits != NULL);
@@ -837,6 +839,7 @@ static int check_ancestors(const char *prefix)
struct object *o = pending_copy.objects[i].item;
clear_commit_marks((struct commit *)o, ALL_REV_FLAGS);
}
+ free(pending_copy.objects);
return res;
}