@matheusbsbs / matheus-bagliano / commits / 3755ccdb65
Fork 0

bisect: implement "rev_argv_push" to fill an argv with revs

This patch is a minor clean up right now, but the new function will evolve and be used more later. 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 3755ccdb65a3bcaa1d55a6b4ec9c47eab0501baa
1 file changed +11 -8
bisect.c
+11 -8
@@ -409,20 +409,23 @@ struct commit_list *find_bisection(struct commit_list *list,
409 return best;
410 }
411
412 +static void rev_argv_push(const unsigned char *sha1, const char *format)
413 +{
414 + struct strbuf buf = STRBUF_INIT;
415 +
416 + strbuf_addf(&buf, format, sha1_to_hex(sha1));
417 + ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
418 + rev_argv[rev_argv_nr++] = strbuf_detach(&buf, NULL);
419 +}
420 +
421 static int register_ref(const char *refname, const unsigned char *sha1,
422 int flags, void *cb_data)
423 {
424 if (!strcmp(refname, "bad")) {
416 - ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
425 current_bad_sha1 = sha1;
418 - rev_argv[rev_argv_nr++] = xstrdup(sha1_to_hex(sha1));
426 + rev_argv_push(sha1, "%s");
427 } else if (!prefixcmp(refname, "good-")) {
420 - const char *hex = sha1_to_hex(sha1);
421 - char *good = xmalloc(strlen(hex) + 2);
422 - *good = '^';
423 - memcpy(good + 1, hex, strlen(hex) + 1);
424 - ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
425 - rev_argv[rev_argv_nr++] = good;
428 + rev_argv_push(sha1, "^%s");
429 } else if (!prefixcmp(refname, "skip-")) {
430 ALLOC_GROW(skipped_revs.sha1, skipped_revs.sha1_nr + 1,
431 skipped_revs.sha1_alloc);