@matheusbsbs / matheus-bagliano / commits / 3b437b0dab
Fork 0

bisect: implement "read_bisect_paths" to read paths in "$GIT_DIR/BISECT_NAMES"

This is needed because "git bisect--helper" must read bisect paths in "$GIT_DIR/BISECT_NAMES", so that a bisection can be performed only on commits that touches paths in this file. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Mar 26, 2009 at 05:55 UTC 3b437b0dabfdff12d5dd78b9bb55a0be4e2da51c
1 file changed +46 -9
bisect.c
+46 -9
@@ -4,6 +4,7 @@
4 #include "revision.h"
5 #include "refs.h"
6 #include "list-objects.h"
7 +#include "quote.h"
8 #include "sha1-lookup.h"
9 #include "bisect.h"
10
@@ -424,6 +425,32 @@ static int read_bisect_refs(void)
425 return for_each_ref_in("refs/bisect/", register_ref, NULL);
426 }
427
428 +void read_bisect_paths(void)
429 +{
430 + struct strbuf str = STRBUF_INIT;
431 + const char *filename = git_path("BISECT_NAMES");
432 + FILE *fp = fopen(filename, "r");
433 +
434 + if (!fp)
435 + die("Could not open file '%s': %s", filename, strerror(errno));
436 +
437 + while (strbuf_getline(&str, fp, '\n') != EOF) {
438 + char *quoted;
439 + int res;
440 +
441 + strbuf_trim(&str);
442 + quoted = strbuf_detach(&str, NULL);
443 + res = sq_dequote_to_argv(quoted, &rev_argv,
444 + &rev_argv_nr, &rev_argv_alloc);
445 + if (res)
446 + die("Badly quoted content in file '%s': %s",
447 + filename, quoted);
448 + }
449 +
450 + strbuf_release(&str);
451 + fclose(fp);
452 +}
453 +
454 static int skipcmp(const void *a, const void *b)
455 {
456 return hashcmp(a, b);
@@ -479,14 +506,11 @@ struct commit_list *filter_skipped(struct commit_list *list,
506 return filtered;
507 }
508
482 -int bisect_next_vars(const char *prefix)
509 +static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
510 {
484 - struct rev_info revs;
485 - int reaches = 0, all = 0;
486 -
487 - init_revisions(&revs, prefix);
488 - revs.abbrev = 0;
489 - revs.commit_format = CMIT_FMT_UNSPECIFIED;
511 + init_revisions(revs, prefix);
512 + revs->abbrev = 0;
513 + revs->commit_format = CMIT_FMT_UNSPECIFIED;
514
515 /* argv[0] will be ignored by setup_revisions */
516 ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
@@ -498,9 +522,22 @@ int bisect_next_vars(const char *prefix)
522 ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
523 rev_argv[rev_argv_nr++] = xstrdup("--");
524
501 - setup_revisions(rev_argv_nr, rev_argv, &revs, NULL);
525 + read_bisect_paths();
526 +
527 + ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
528 + rev_argv[rev_argv_nr++] = NULL;
529 +
530 + setup_revisions(rev_argv_nr, rev_argv, revs, NULL);
531 +
532 + revs->limited = 1;
533 +}
534 +
535 +int bisect_next_vars(const char *prefix)
536 +{
537 + struct rev_info revs;
538 + int reaches = 0, all = 0;
539
503 - revs.limited = 1;
540 + bisect_rev_setup(&revs, prefix);
541
542 if (prepare_revision_walk(&revs))
543 die("revision walk setup failed");