From cb46d630baf780412f8ca0592531880b592f0922 Mon Sep 17 00:00:00 2001 From: Antoine Delaite Date: Mon, 29 Jun 2015 17:40:30 +0200 Subject: bisect: simplify the addition of new bisect terms We create a file BISECT_TERMS in the repository .git to be read during a bisection. There's no user-interface yet, but "git bisect" works if terms other than old/new or bad/good are set in .git/BISECT_TERMS. The fonctions to be changed if we add new terms are quite few. In git-bisect.sh: check_and_set_terms bisect_voc Co-authored-by: Louis Stuber Tweaked-by: Matthieu Moy Signed-off-by: Antoine Delaite Signed-off-by: Louis Stuber Signed-off-by: Valentin Duperray Signed-off-by: Franck Jonas Signed-off-by: Lucien Kong Signed-off-by: Thomas Nguy Signed-off-by: Huynh Khoi Nguyen Nguyen Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- bisect.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'bisect.c') diff --git a/bisect.c b/bisect.c index a96e485038..857cf59aa3 100644 --- a/bisect.c +++ b/bisect.c @@ -904,6 +904,36 @@ static void show_diff_tree(const char *prefix, struct commit *commit) log_tree_commit(&opt, commit); } +/* + * The terms used for this bisect session are stored in BISECT_TERMS. + * We read them and store them to adapt the messages accordingly. + * Default is bad/good. + */ +void read_bisect_terms(const char **read_bad, const char **read_good) +{ + struct strbuf str = STRBUF_INIT; + const char *filename = git_path("BISECT_TERMS"); + FILE *fp = fopen(filename, "r"); + + if (!fp) { + if (errno == ENOENT) { + *read_bad = "bad"; + *read_good = "good"; + return; + } else { + die("could not read file '%s': %s", filename, + strerror(errno)); + } + } else { + strbuf_getline(&str, fp, '\n'); + *read_bad = strbuf_detach(&str, NULL); + strbuf_getline(&str, fp, '\n'); + *read_good = strbuf_detach(&str, NULL); + } + strbuf_release(&str); + fclose(fp); +} + /* * We use the convention that exiting with an exit code 10 means that * the bisection process finished successfully. @@ -920,8 +950,7 @@ int bisect_next_all(const char *prefix, int no_checkout) const unsigned char *bisect_rev; char bisect_rev_hex[GIT_SHA1_HEXSZ + 1]; - term_bad = "bad"; - term_good = "good"; + read_bisect_terms(&term_bad, &term_good); if (read_bisect_refs()) die("reading bisect refs failed"); -- cgit v1.2.1