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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Dec 25, 2017 at 18:45 UTC
148f14ab5e066bb95a9f0bc00380ca98369555dd
1 file changed
+9
-21
bisect.c
+9
-21
@@ -784,11 +784,9 @@ static void handle_skipped_merge_base(const struct object_id *mb)
784
* - If one is "skipped", we can't know but we should warn.
785
* - If we don't know, we should check it out and ask the user to test.
786
*/
787
-static void check_merge_bases(int no_checkout)
787
+static void check_merge_bases(int rev_nr, struct commit **rev, int no_checkout)
788
{
789
struct commit_list *result;
790
- int rev_nr;
791
- struct commit **rev = get_bad_and_good_commits(&rev_nr);
790
791
result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1);
792
@@ -806,34 +804,21 @@ static void check_merge_bases(int no_checkout)
804
}
805
}
806
809
- free(rev);
807
free_commit_list(result);
808
}
809
813
-static int check_ancestors(const char *prefix)
810
+static int check_ancestors(int rev_nr, struct commit **rev, const char *prefix)
811
{
812
struct rev_info revs;
816
- struct object_array pending_copy;
813
int res;
814
815
bisect_rev_setup(&revs, prefix, "^%s", "%s", 0);
816
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
- */
817
bisect_common(&revs);
818
res = (revs.commits != NULL);
819
820
/* 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);
822
823
return res;
824
}
@@ -850,7 +835,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
835
{
836
char *filename = git_pathdup("BISECT_ANCESTORS_OK");
837
struct stat st;
853
- int fd;
838
+ int fd, rev_nr;
839
+ struct commit **rev;
840
841
if (!current_bad_oid)
842
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)
850
goto done;
851
852
/* 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);
857
858
/* Create file BISECT_ANCESTORS_OK. */
859
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);