bisect: store good revisions in a "sha1_array"
This will make it easier to use good revisions for checking merge bases later. To simplify the code, a new "sha1_array_push" function is also introduced. And while at it we move the earlier part of the code to fill the argv that is passed to "setup_revisions", so that all this code is now completely after "read_bisect_refs". Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
May 9, 2009 at 17:55 UTC
fad2d31d62277eced9aa7fc187ae3b97e72895bb
1 file changed
+19
-7
bisect.c
+19
-7
@@ -15,6 +15,7 @@ struct sha1_array {
15
int sha1_alloc;
16
};
17
18
+static struct sha1_array good_revs;
19
static struct sha1_array skipped_revs;
20
21
static const char **rev_argv;
@@ -418,18 +419,22 @@ static void rev_argv_push(const unsigned char *sha1, const char *format)
419
rev_argv[rev_argv_nr++] = strbuf_detach(&buf, NULL);
420
}
421
422
+static void sha1_array_push(struct sha1_array *array,
423
+ const unsigned char *sha1)
424
+{
425
+ ALLOC_GROW(array->sha1, array->sha1_nr + 1, array->sha1_alloc);
426
+ hashcpy(array->sha1[array->sha1_nr++], sha1);
427
+}
428
+
429
static int register_ref(const char *refname, const unsigned char *sha1,
430
int flags, void *cb_data)
431
{
432
if (!strcmp(refname, "bad")) {
433
current_bad_sha1 = sha1;
426
- rev_argv_push(sha1, "%s");
434
} else if (!prefixcmp(refname, "good-")) {
428
- rev_argv_push(sha1, "^%s");
435
+ sha1_array_push(&good_revs, sha1);
436
} else if (!prefixcmp(refname, "skip-")) {
430
- ALLOC_GROW(skipped_revs.sha1, skipped_revs.sha1_nr + 1,
431
- skipped_revs.sha1_alloc);
432
- hashcpy(skipped_revs.sha1[skipped_revs.sha1_nr++], sha1);
437
+ sha1_array_push(&skipped_revs, sha1);
438
}
439
440
return 0;
@@ -524,16 +529,23 @@ struct commit_list *filter_skipped(struct commit_list *list,
529
530
static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
531
{
532
+ int i;
533
+
534
init_revisions(revs, prefix);
535
revs->abbrev = 0;
536
revs->commit_format = CMIT_FMT_UNSPECIFIED;
537
538
+ if (read_bisect_refs())
539
+ die("reading bisect refs failed");
540
+
541
/* argv[0] will be ignored by setup_revisions */
542
ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
543
rev_argv[rev_argv_nr++] = xstrdup("bisect_rev_setup");
544
535
- if (read_bisect_refs())
536
- die("reading bisect refs failed");
545
+ rev_argv_push(current_bad_sha1, "%s");
546
+
547
+ for (i = 0; i < good_revs.sha1_nr; i++)
548
+ rev_argv_push(good_revs.sha1[i], "^%s");
549
550
ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
551
rev_argv[rev_argv_nr++] = xstrdup("--");