Skip to content

Commit 148f14a

Browse files
rscharfegitster
authored andcommitted
bisect: 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 only use it for remembering the commits whose marks we have to clear after checking if all of the good ones are ancestors of the bad one. This is easy, though: We need to do that for the bad and good commits, of course. Let check_good_are_ancestors_of_bad() create and own the array of bad and good commits, and use it to clear the commit marks as well. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4ad315f commit 148f14a

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

bisect.c

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -784,11 +784,9 @@ static void handle_skipped_merge_base(const struct object_id *mb)
784784
* - If one is "skipped", we can't know but we should warn.
785785
* - If we don't know, we should check it out and ask the user to test.
786786
*/
787-
static void check_merge_bases(int no_checkout)
787+
static void check_merge_bases(int rev_nr, struct commit **rev, int no_checkout)
788788
{
789789
struct commit_list *result;
790-
int rev_nr;
791-
struct commit **rev = get_bad_and_good_commits(&rev_nr);
792790

793791
result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1);
794792

@@ -806,34 +804,21 @@ static void check_merge_bases(int no_checkout)
806804
}
807805
}
808806

809-
free(rev);
810807
free_commit_list(result);
811808
}
812809

813-
static int check_ancestors(const char *prefix)
810+
static int check_ancestors(int rev_nr, struct commit **rev, const char *prefix)
814811
{
815812
struct rev_info revs;
816-
struct object_array pending_copy;
817813
int res;
818814

819815
bisect_rev_setup(&revs, prefix, "^%s", "%s", 0);
820816

821-
/* Save pending objects, so they can be cleaned up later. */
822-
pending_copy = revs.pending;
823-
revs.leak_pending = 1;
824-
825-
/*
826-
* bisect_common calls prepare_revision_walk right away, which
827-
* (together with .leak_pending = 1) makes us the sole owner of
828-
* the list of pending objects.
829-
*/
830817
bisect_common(&revs);
831818
res = (revs.commits != NULL);
832819

833820
/* Clean up objects used, as they will be reused. */
834-
clear_commit_marks_for_object_array(&pending_copy, ALL_REV_FLAGS);
835-
836-
object_array_clear(&pending_copy);
821+
clear_commit_marks_many(rev_nr, rev, ALL_REV_FLAGS);
837822

838823
return res;
839824
}
@@ -850,7 +835,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
850835
{
851836
char *filename = git_pathdup("BISECT_ANCESTORS_OK");
852837
struct stat st;
853-
int fd;
838+
int fd, rev_nr;
839+
struct commit **rev;
854840

855841
if (!current_bad_oid)
856842
die(_("a %s revision is needed"), term_bad);
@@ -864,8 +850,10 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
864850
goto done;
865851

866852
/* Check if all good revs are ancestor of the bad rev. */
867-
if (check_ancestors(prefix))
868-
check_merge_bases(no_checkout);
853+
rev = get_bad_and_good_commits(&rev_nr);
854+
if (check_ancestors(rev_nr, rev, prefix))
855+
check_merge_bases(rev_nr, rev, no_checkout);
856+
free(rev);
869857

870858
/* Create file BISECT_ANCESTORS_OK. */
871859
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);

0 commit comments

Comments
 (0)