Christian Couder | 1bf072e | 2009-03-26 05:55:54 +0100 | [diff] [blame] | 1 | #include "builtin.h" |
| 2 | #include "cache.h" |
| 3 | #include "parse-options.h" |
| 4 | #include "bisect.h" |
Pranit Bauva | 4ba1e5c | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 5 | #include "refs.h" |
Pranit Bauva | 5e82c3d | 2019-01-02 07:38:31 -0800 | [diff] [blame] | 6 | #include "dir.h" |
| 7 | #include "argv-array.h" |
| 8 | #include "run-command.h" |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 9 | #include "prompt.h" |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 10 | #include "quote.h" |
Christian Couder | 1bf072e | 2009-03-26 05:55:54 +0100 | [diff] [blame] | 11 | |
Pranit Bauva | ecb3f37 | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 12 | static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS") |
Pranit Bauva | b903674 | 2017-09-29 06:49:40 +0000 | [diff] [blame] | 13 | static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV") |
| 14 | static GIT_PATH_FUNC(git_path_bisect_ancestors_ok, "BISECT_ANCESTORS_OK") |
Pranit Bauva | 5e82c3d | 2019-01-02 07:38:31 -0800 | [diff] [blame] | 15 | static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START") |
| 16 | static GIT_PATH_FUNC(git_path_bisect_head, "BISECT_HEAD") |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 17 | static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG") |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 18 | static GIT_PATH_FUNC(git_path_head_name, "head-name") |
| 19 | static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") |
Pranit Bauva | ecb3f37 | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 20 | |
Christian Couder | 1bf072e | 2009-03-26 05:55:54 +0100 | [diff] [blame] | 21 | static const char * const git_bisect_helper_usage[] = { |
Nguyễn Thái Ngọc Duy | 9e7bbe2 | 2012-08-20 19:31:53 +0700 | [diff] [blame] | 22 | N_("git bisect--helper --next-all [--no-checkout]"), |
Pranit Bauva | ecb3f37 | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 23 | N_("git bisect--helper --write-terms <bad_term> <good_term>"), |
Pranit Bauva | fb71a32 | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 24 | N_("git bisect--helper --bisect-clean-state"), |
Pranit Bauva | 5e82c3d | 2019-01-02 07:38:31 -0800 | [diff] [blame] | 25 | N_("git bisect--helper --bisect-reset [<commit>]"), |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 26 | N_("git bisect--helper --bisect-write [--no-log] <state> <revision> <good_term> <bad_term>"), |
Pranit Bauva | 4fbdbd5 | 2019-01-02 07:38:33 -0800 | [diff] [blame] | 27 | N_("git bisect--helper --bisect-check-and-set-terms <command> <good_term> <bad_term>"), |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 28 | N_("git bisect--helper --bisect-next-check <good_term> <bad_term> [<term>]"), |
Pranit Bauva | 450ebb7 | 2019-01-02 07:38:35 -0800 | [diff] [blame] | 29 | N_("git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]"), |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 30 | N_("git bisect--helper --bisect-start [--term-{old,good}=<term> --term-{new,bad}=<term>]" |
| 31 | "[--no-checkout] [<bad> [<good>...]] [--] [<paths>...]"), |
Christian Couder | 1bf072e | 2009-03-26 05:55:54 +0100 | [diff] [blame] | 32 | NULL |
| 33 | }; |
| 34 | |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 35 | struct bisect_terms { |
| 36 | char *term_good; |
| 37 | char *term_bad; |
| 38 | }; |
| 39 | |
| 40 | static void free_terms(struct bisect_terms *terms) |
| 41 | { |
| 42 | FREE_AND_NULL(terms->term_good); |
| 43 | FREE_AND_NULL(terms->term_bad); |
| 44 | } |
| 45 | |
| 46 | static void set_terms(struct bisect_terms *terms, const char *bad, |
| 47 | const char *good) |
| 48 | { |
| 49 | free((void *)terms->term_good); |
| 50 | terms->term_good = xstrdup(good); |
| 51 | free((void *)terms->term_bad); |
| 52 | terms->term_bad = xstrdup(bad); |
| 53 | } |
| 54 | |
Miriam Rubio | 16538bf | 2020-02-17 09:40:28 +0100 | [diff] [blame] | 55 | static const char vocab_bad[] = "bad|new"; |
| 56 | static const char vocab_good[] = "good|old"; |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 57 | |
Pranit Bauva | 4ba1e5c | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 58 | /* |
| 59 | * Check whether the string `term` belongs to the set of strings |
| 60 | * included in the variable arguments. |
| 61 | */ |
| 62 | LAST_ARG_MUST_BE_NULL |
| 63 | static int one_of(const char *term, ...) |
| 64 | { |
| 65 | int res = 0; |
| 66 | va_list matches; |
| 67 | const char *match; |
| 68 | |
| 69 | va_start(matches, term); |
| 70 | while (!res && (match = va_arg(matches, const char *))) |
| 71 | res = !strcmp(term, match); |
| 72 | va_end(matches); |
| 73 | |
| 74 | return res; |
| 75 | } |
| 76 | |
| 77 | static int check_term_format(const char *term, const char *orig_term) |
| 78 | { |
| 79 | int res; |
| 80 | char *new_term = xstrfmt("refs/bisect/%s", term); |
| 81 | |
| 82 | res = check_refname_format(new_term, 0); |
| 83 | free(new_term); |
| 84 | |
| 85 | if (res) |
| 86 | return error(_("'%s' is not a valid term"), term); |
| 87 | |
| 88 | if (one_of(term, "help", "start", "skip", "next", "reset", |
Robert P. J. Day | dbc349b | 2017-11-12 04:30:38 -0500 | [diff] [blame] | 89 | "visualize", "view", "replay", "log", "run", "terms", NULL)) |
Pranit Bauva | 4ba1e5c | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 90 | return error(_("can't use the builtin command '%s' as a term"), term); |
| 91 | |
| 92 | /* |
| 93 | * In theory, nothing prevents swapping completely good and bad, |
| 94 | * but this situation could be confusing and hasn't been tested |
| 95 | * enough. Forbid it for now. |
| 96 | */ |
| 97 | |
| 98 | if ((strcmp(orig_term, "bad") && one_of(term, "bad", "new", NULL)) || |
| 99 | (strcmp(orig_term, "good") && one_of(term, "good", "old", NULL))) |
| 100 | return error(_("can't change the meaning of the term '%s'"), term); |
| 101 | |
| 102 | return 0; |
| 103 | } |
| 104 | |
Pranit Bauva | ecb3f37 | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 105 | static int write_terms(const char *bad, const char *good) |
| 106 | { |
| 107 | FILE *fp = NULL; |
| 108 | int res; |
| 109 | |
| 110 | if (!strcmp(bad, good)) |
| 111 | return error(_("please use two different terms")); |
| 112 | |
| 113 | if (check_term_format(bad, "bad") || check_term_format(good, "good")) |
| 114 | return -1; |
| 115 | |
| 116 | fp = fopen(git_path_bisect_terms(), "w"); |
| 117 | if (!fp) |
| 118 | return error_errno(_("could not open the file BISECT_TERMS")); |
| 119 | |
| 120 | res = fprintf(fp, "%s\n%s\n", bad, good); |
| 121 | res |= fclose(fp); |
| 122 | return (res < 0) ? -1 : 0; |
| 123 | } |
| 124 | |
Pranit Bauva | b903674 | 2017-09-29 06:49:40 +0000 | [diff] [blame] | 125 | static int is_expected_rev(const char *expected_hex) |
| 126 | { |
| 127 | struct strbuf actual_hex = STRBUF_INIT; |
| 128 | int res = 0; |
| 129 | if (strbuf_read_file(&actual_hex, git_path_bisect_expected_rev(), 0) >= 40) { |
| 130 | strbuf_trim(&actual_hex); |
| 131 | res = !strcmp(actual_hex.buf, expected_hex); |
| 132 | } |
| 133 | strbuf_release(&actual_hex); |
| 134 | return res; |
| 135 | } |
| 136 | |
| 137 | static void check_expected_revs(const char **revs, int rev_nr) |
| 138 | { |
| 139 | int i; |
| 140 | |
| 141 | for (i = 0; i < rev_nr; i++) { |
| 142 | if (!is_expected_rev(revs[i])) { |
| 143 | unlink_or_warn(git_path_bisect_ancestors_ok()); |
| 144 | unlink_or_warn(git_path_bisect_expected_rev()); |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | |
Pranit Bauva | 5e82c3d | 2019-01-02 07:38:31 -0800 | [diff] [blame] | 149 | static int bisect_reset(const char *commit) |
| 150 | { |
| 151 | struct strbuf branch = STRBUF_INIT; |
| 152 | |
| 153 | if (!commit) { |
| 154 | if (strbuf_read_file(&branch, git_path_bisect_start(), 0) < 1) { |
| 155 | printf(_("We are not bisecting.\n")); |
| 156 | return 0; |
| 157 | } |
| 158 | strbuf_rtrim(&branch); |
| 159 | } else { |
| 160 | struct object_id oid; |
| 161 | |
| 162 | if (get_oid_commit(commit, &oid)) |
| 163 | return error(_("'%s' is not a valid commit"), commit); |
| 164 | strbuf_addstr(&branch, commit); |
| 165 | } |
| 166 | |
| 167 | if (!file_exists(git_path_bisect_head())) { |
| 168 | struct argv_array argv = ARGV_ARRAY_INIT; |
| 169 | |
| 170 | argv_array_pushl(&argv, "checkout", branch.buf, "--", NULL); |
| 171 | if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) { |
Tanushree Tumane | 51a0a4e | 2019-12-09 11:56:47 +0100 | [diff] [blame] | 172 | error(_("could not check out original" |
| 173 | " HEAD '%s'. Try 'git bisect" |
| 174 | " reset <commit>'."), branch.buf); |
Pranit Bauva | 5e82c3d | 2019-01-02 07:38:31 -0800 | [diff] [blame] | 175 | strbuf_release(&branch); |
| 176 | argv_array_clear(&argv); |
Tanushree Tumane | 51a0a4e | 2019-12-09 11:56:47 +0100 | [diff] [blame] | 177 | return -1; |
Pranit Bauva | 5e82c3d | 2019-01-02 07:38:31 -0800 | [diff] [blame] | 178 | } |
| 179 | argv_array_clear(&argv); |
| 180 | } |
| 181 | |
| 182 | strbuf_release(&branch); |
| 183 | return bisect_clean_state(); |
| 184 | } |
| 185 | |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 186 | static void log_commit(FILE *fp, char *fmt, const char *state, |
| 187 | struct commit *commit) |
| 188 | { |
| 189 | struct pretty_print_context pp = {0}; |
| 190 | struct strbuf commit_msg = STRBUF_INIT; |
| 191 | char *label = xstrfmt(fmt, state); |
| 192 | |
| 193 | format_commit_message(commit, "%s", &commit_msg, &pp); |
| 194 | |
| 195 | fprintf(fp, "# %s: [%s] %s\n", label, oid_to_hex(&commit->object.oid), |
| 196 | commit_msg.buf); |
| 197 | |
| 198 | strbuf_release(&commit_msg); |
| 199 | free(label); |
| 200 | } |
| 201 | |
| 202 | static int bisect_write(const char *state, const char *rev, |
| 203 | const struct bisect_terms *terms, int nolog) |
| 204 | { |
| 205 | struct strbuf tag = STRBUF_INIT; |
| 206 | struct object_id oid; |
| 207 | struct commit *commit; |
| 208 | FILE *fp = NULL; |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 209 | int res = 0; |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 210 | |
| 211 | if (!strcmp(state, terms->term_bad)) { |
| 212 | strbuf_addf(&tag, "refs/bisect/%s", state); |
| 213 | } else if (one_of(state, terms->term_good, "skip", NULL)) { |
| 214 | strbuf_addf(&tag, "refs/bisect/%s-%s", state, rev); |
| 215 | } else { |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 216 | res = error(_("Bad bisect_write argument: %s"), state); |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 217 | goto finish; |
| 218 | } |
| 219 | |
| 220 | if (get_oid(rev, &oid)) { |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 221 | res = error(_("couldn't get the oid of the rev '%s'"), rev); |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 222 | goto finish; |
| 223 | } |
| 224 | |
| 225 | if (update_ref(NULL, tag.buf, &oid, NULL, 0, |
| 226 | UPDATE_REFS_MSG_ON_ERR)) { |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 227 | res = -1; |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 228 | goto finish; |
| 229 | } |
| 230 | |
| 231 | fp = fopen(git_path_bisect_log(), "a"); |
| 232 | if (!fp) { |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 233 | res = error_errno(_("couldn't open the file '%s'"), git_path_bisect_log()); |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 234 | goto finish; |
| 235 | } |
| 236 | |
| 237 | commit = lookup_commit_reference(the_repository, &oid); |
| 238 | log_commit(fp, "%s", state, commit); |
| 239 | |
| 240 | if (!nolog) |
| 241 | fprintf(fp, "git bisect %s %s\n", state, rev); |
| 242 | |
| 243 | finish: |
| 244 | if (fp) |
| 245 | fclose(fp); |
| 246 | strbuf_release(&tag); |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 247 | return res; |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 248 | } |
| 249 | |
Pranit Bauva | 4fbdbd5 | 2019-01-02 07:38:33 -0800 | [diff] [blame] | 250 | static int check_and_set_terms(struct bisect_terms *terms, const char *cmd) |
| 251 | { |
| 252 | int has_term_file = !is_empty_or_missing_file(git_path_bisect_terms()); |
| 253 | |
| 254 | if (one_of(cmd, "skip", "start", "terms", NULL)) |
| 255 | return 0; |
| 256 | |
| 257 | if (has_term_file && strcmp(cmd, terms->term_bad) && |
| 258 | strcmp(cmd, terms->term_good)) |
| 259 | return error(_("Invalid command: you're currently in a " |
| 260 | "%s/%s bisect"), terms->term_bad, |
| 261 | terms->term_good); |
| 262 | |
| 263 | if (!has_term_file) { |
| 264 | if (one_of(cmd, "bad", "good", NULL)) { |
| 265 | set_terms(terms, "bad", "good"); |
| 266 | return write_terms(terms->term_bad, terms->term_good); |
| 267 | } |
| 268 | if (one_of(cmd, "new", "old", NULL)) { |
| 269 | set_terms(terms, "new", "old"); |
| 270 | return write_terms(terms->term_bad, terms->term_good); |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | return 0; |
| 275 | } |
| 276 | |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 277 | static int mark_good(const char *refname, const struct object_id *oid, |
| 278 | int flag, void *cb_data) |
| 279 | { |
| 280 | int *m_good = (int *)cb_data; |
| 281 | *m_good = 0; |
| 282 | return 1; |
| 283 | } |
| 284 | |
Tanushree Tumane | 7c5cea7 | 2019-12-14 09:11:24 +0100 | [diff] [blame] | 285 | static const char need_bad_and_good_revision_warning[] = |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 286 | N_("You need to give me at least one %s and %s revision.\n" |
| 287 | "You can use \"git bisect %s\" and \"git bisect %s\" for that."); |
| 288 | |
Tanushree Tumane | 7c5cea7 | 2019-12-14 09:11:24 +0100 | [diff] [blame] | 289 | static const char need_bisect_start_warning[] = |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 290 | N_("You need to start by \"git bisect start\".\n" |
| 291 | "You then need to give me at least one %s and %s revision.\n" |
| 292 | "You can use \"git bisect %s\" and \"git bisect %s\" for that."); |
| 293 | |
Tanushree Tumane | bfacfce | 2020-02-17 09:40:31 +0100 | [diff] [blame] | 294 | static int decide_next(const struct bisect_terms *terms, |
| 295 | const char *current_term, int missing_good, |
| 296 | int missing_bad) |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 297 | { |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 298 | if (!missing_good && !missing_bad) |
Tanushree Tumane | bfacfce | 2020-02-17 09:40:31 +0100 | [diff] [blame] | 299 | return 0; |
| 300 | if (!current_term) |
| 301 | return -1; |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 302 | |
| 303 | if (missing_good && !missing_bad && |
| 304 | !strcmp(current_term, terms->term_good)) { |
| 305 | char *yesno; |
| 306 | /* |
| 307 | * have bad (or new) but not good (or old). We could bisect |
| 308 | * although this is less optimum. |
| 309 | */ |
| 310 | warning(_("bisecting only with a %s commit"), terms->term_bad); |
| 311 | if (!isatty(0)) |
Tanushree Tumane | bfacfce | 2020-02-17 09:40:31 +0100 | [diff] [blame] | 312 | return 0; |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 313 | /* |
| 314 | * TRANSLATORS: Make sure to include [Y] and [n] in your |
| 315 | * translation. The program will only accept English input |
| 316 | * at this point. |
| 317 | */ |
| 318 | yesno = git_prompt(_("Are you sure [Y/n]? "), PROMPT_ECHO); |
| 319 | if (starts_with(yesno, "N") || starts_with(yesno, "n")) |
Tanushree Tumane | bfacfce | 2020-02-17 09:40:31 +0100 | [diff] [blame] | 320 | return -1; |
| 321 | return 0; |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 322 | } |
| 323 | |
Tanushree Tumane | bfacfce | 2020-02-17 09:40:31 +0100 | [diff] [blame] | 324 | if (!is_empty_or_missing_file(git_path_bisect_start())) |
| 325 | return error(_(need_bad_and_good_revision_warning), |
| 326 | vocab_bad, vocab_good, vocab_bad, vocab_good); |
| 327 | else |
| 328 | return error(_(need_bisect_start_warning), |
| 329 | vocab_good, vocab_bad, vocab_good, vocab_bad); |
| 330 | } |
| 331 | |
| 332 | static int bisect_next_check(const struct bisect_terms *terms, |
| 333 | const char *current_term) |
| 334 | { |
| 335 | int missing_good = 1, missing_bad = 1; |
| 336 | char *bad_ref = xstrfmt("refs/bisect/%s", terms->term_bad); |
| 337 | char *good_glob = xstrfmt("%s-*", terms->term_good); |
| 338 | |
| 339 | if (ref_exists(bad_ref)) |
| 340 | missing_bad = 0; |
| 341 | |
| 342 | for_each_glob_ref_in(mark_good, good_glob, "refs/bisect/", |
| 343 | (void *) &missing_good); |
| 344 | |
| 345 | free(good_glob); |
| 346 | free(bad_ref); |
| 347 | |
| 348 | return decide_next(terms, current_term, missing_good, missing_bad); |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 349 | } |
| 350 | |
Pranit Bauva | 450ebb7 | 2019-01-02 07:38:35 -0800 | [diff] [blame] | 351 | static int get_terms(struct bisect_terms *terms) |
| 352 | { |
| 353 | struct strbuf str = STRBUF_INIT; |
| 354 | FILE *fp = NULL; |
| 355 | int res = 0; |
| 356 | |
| 357 | fp = fopen(git_path_bisect_terms(), "r"); |
| 358 | if (!fp) { |
| 359 | res = -1; |
| 360 | goto finish; |
| 361 | } |
| 362 | |
| 363 | free_terms(terms); |
| 364 | strbuf_getline_lf(&str, fp); |
| 365 | terms->term_bad = strbuf_detach(&str, NULL); |
| 366 | strbuf_getline_lf(&str, fp); |
| 367 | terms->term_good = strbuf_detach(&str, NULL); |
| 368 | |
| 369 | finish: |
| 370 | if (fp) |
| 371 | fclose(fp); |
| 372 | strbuf_release(&str); |
| 373 | return res; |
| 374 | } |
| 375 | |
| 376 | static int bisect_terms(struct bisect_terms *terms, const char *option) |
| 377 | { |
| 378 | if (get_terms(terms)) |
| 379 | return error(_("no terms defined")); |
| 380 | |
| 381 | if (option == NULL) { |
| 382 | printf(_("Your current terms are %s for the old state\n" |
| 383 | "and %s for the new state.\n"), |
| 384 | terms->term_good, terms->term_bad); |
| 385 | return 0; |
| 386 | } |
| 387 | if (one_of(option, "--term-good", "--term-old", NULL)) |
| 388 | printf("%s\n", terms->term_good); |
| 389 | else if (one_of(option, "--term-bad", "--term-new", NULL)) |
| 390 | printf("%s\n", terms->term_bad); |
| 391 | else |
| 392 | return error(_("invalid argument %s for 'git bisect terms'.\n" |
| 393 | "Supported options are: " |
| 394 | "--term-good|--term-old and " |
| 395 | "--term-bad|--term-new."), option); |
| 396 | |
| 397 | return 0; |
| 398 | } |
| 399 | |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 400 | static int bisect_append_log_quoted(const char **argv) |
| 401 | { |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 402 | int res = 0; |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 403 | FILE *fp = fopen(git_path_bisect_log(), "a"); |
| 404 | struct strbuf orig_args = STRBUF_INIT; |
| 405 | |
| 406 | if (!fp) |
| 407 | return -1; |
| 408 | |
| 409 | if (fprintf(fp, "git bisect start") < 1) { |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 410 | res = -1; |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 411 | goto finish; |
| 412 | } |
| 413 | |
| 414 | sq_quote_argv(&orig_args, argv); |
| 415 | if (fprintf(fp, "%s\n", orig_args.buf) < 1) |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 416 | res = -1; |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 417 | |
| 418 | finish: |
| 419 | fclose(fp); |
| 420 | strbuf_release(&orig_args); |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 421 | return res; |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | static int bisect_start(struct bisect_terms *terms, int no_checkout, |
| 425 | const char **argv, int argc) |
| 426 | { |
| 427 | int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0; |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 428 | int flags, pathspec_pos, res = 0; |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 429 | struct string_list revs = STRING_LIST_INIT_DUP; |
| 430 | struct string_list states = STRING_LIST_INIT_DUP; |
| 431 | struct strbuf start_head = STRBUF_INIT; |
| 432 | struct strbuf bisect_names = STRBUF_INIT; |
| 433 | struct object_id head_oid; |
| 434 | struct object_id oid; |
| 435 | const char *head; |
| 436 | |
| 437 | if (is_bare_repository()) |
| 438 | no_checkout = 1; |
| 439 | |
| 440 | /* |
| 441 | * Check for one bad and then some good revisions |
| 442 | */ |
| 443 | for (i = 0; i < argc; i++) { |
| 444 | if (!strcmp(argv[i], "--")) { |
| 445 | has_double_dash = 1; |
| 446 | break; |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | for (i = 0; i < argc; i++) { |
| 451 | const char *arg = argv[i]; |
| 452 | if (!strcmp(argv[i], "--")) { |
| 453 | break; |
| 454 | } else if (!strcmp(arg, "--no-checkout")) { |
| 455 | no_checkout = 1; |
| 456 | } else if (!strcmp(arg, "--term-good") || |
| 457 | !strcmp(arg, "--term-old")) { |
Carlo Marcelo Arenas Belón | 4d9005f | 2020-05-20 16:26:27 -0700 | [diff] [blame] | 458 | i++; |
| 459 | if (argc <= i) |
| 460 | return error(_("'' is not a valid term")); |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 461 | must_write_terms = 1; |
| 462 | free((void *) terms->term_good); |
Carlo Marcelo Arenas Belón | 4d9005f | 2020-05-20 16:26:27 -0700 | [diff] [blame] | 463 | terms->term_good = xstrdup(argv[i]); |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 464 | } else if (skip_prefix(arg, "--term-good=", &arg) || |
| 465 | skip_prefix(arg, "--term-old=", &arg)) { |
| 466 | must_write_terms = 1; |
| 467 | free((void *) terms->term_good); |
| 468 | terms->term_good = xstrdup(arg); |
| 469 | } else if (!strcmp(arg, "--term-bad") || |
| 470 | !strcmp(arg, "--term-new")) { |
Carlo Marcelo Arenas Belón | 4d9005f | 2020-05-20 16:26:27 -0700 | [diff] [blame] | 471 | i++; |
| 472 | if (argc <= i) |
| 473 | return error(_("'' is not a valid term")); |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 474 | must_write_terms = 1; |
| 475 | free((void *) terms->term_bad); |
Carlo Marcelo Arenas Belón | 4d9005f | 2020-05-20 16:26:27 -0700 | [diff] [blame] | 476 | terms->term_bad = xstrdup(argv[i]); |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 477 | } else if (skip_prefix(arg, "--term-bad=", &arg) || |
| 478 | skip_prefix(arg, "--term-new=", &arg)) { |
| 479 | must_write_terms = 1; |
| 480 | free((void *) terms->term_bad); |
| 481 | terms->term_bad = xstrdup(arg); |
Carlo Marcelo Arenas Belón | 4d9005f | 2020-05-20 16:26:27 -0700 | [diff] [blame] | 482 | } else if (starts_with(arg, "--")) { |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 483 | return error(_("unrecognized option: '%s'"), arg); |
| 484 | } else { |
| 485 | char *commit_id = xstrfmt("%s^{commit}", arg); |
| 486 | if (get_oid(commit_id, &oid) && has_double_dash) |
| 487 | die(_("'%s' does not appear to be a valid " |
| 488 | "revision"), arg); |
| 489 | |
| 490 | string_list_append(&revs, oid_to_hex(&oid)); |
| 491 | free(commit_id); |
| 492 | } |
| 493 | } |
| 494 | pathspec_pos = i; |
| 495 | |
| 496 | /* |
| 497 | * The user ran "git bisect start <sha1> <sha1>", hence did not |
| 498 | * explicitly specify the terms, but we are already starting to |
| 499 | * set references named with the default terms, and won't be able |
| 500 | * to change afterwards. |
| 501 | */ |
| 502 | if (revs.nr) |
| 503 | must_write_terms = 1; |
| 504 | for (i = 0; i < revs.nr; i++) { |
| 505 | if (bad_seen) { |
| 506 | string_list_append(&states, terms->term_good); |
| 507 | } else { |
| 508 | bad_seen = 1; |
| 509 | string_list_append(&states, terms->term_bad); |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | /* |
| 514 | * Verify HEAD |
| 515 | */ |
| 516 | head = resolve_ref_unsafe("HEAD", 0, &head_oid, &flags); |
| 517 | if (!head) |
| 518 | if (get_oid("HEAD", &head_oid)) |
| 519 | return error(_("bad HEAD - I need a HEAD")); |
| 520 | |
| 521 | /* |
| 522 | * Check if we are bisecting |
| 523 | */ |
| 524 | if (!is_empty_or_missing_file(git_path_bisect_start())) { |
| 525 | /* Reset to the rev from where we started */ |
| 526 | strbuf_read_file(&start_head, git_path_bisect_start(), 0); |
| 527 | strbuf_trim(&start_head); |
| 528 | if (!no_checkout) { |
| 529 | struct argv_array argv = ARGV_ARRAY_INIT; |
| 530 | |
| 531 | argv_array_pushl(&argv, "checkout", start_head.buf, |
| 532 | "--", NULL); |
| 533 | if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) { |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 534 | res = error(_("checking out '%s' failed." |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 535 | " Try 'git bisect start " |
| 536 | "<valid-branch>'."), |
| 537 | start_head.buf); |
| 538 | goto finish; |
| 539 | } |
| 540 | } |
| 541 | } else { |
| 542 | /* Get the rev from where we start. */ |
| 543 | if (!get_oid(head, &head_oid) && |
| 544 | !starts_with(head, "refs/heads/")) { |
| 545 | strbuf_reset(&start_head); |
| 546 | strbuf_addstr(&start_head, oid_to_hex(&head_oid)); |
| 547 | } else if (!get_oid(head, &head_oid) && |
| 548 | skip_prefix(head, "refs/heads/", &head)) { |
| 549 | /* |
| 550 | * This error message should only be triggered by |
| 551 | * cogito usage, and cogito users should understand |
| 552 | * it relates to cg-seek. |
| 553 | */ |
| 554 | if (!is_empty_or_missing_file(git_path_head_name())) |
| 555 | return error(_("won't bisect on cg-seek'ed tree")); |
| 556 | strbuf_addstr(&start_head, head); |
| 557 | } else { |
| 558 | return error(_("bad HEAD - strange symbolic ref")); |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | /* |
| 563 | * Get rid of any old bisect state. |
| 564 | */ |
| 565 | if (bisect_clean_state()) |
| 566 | return -1; |
| 567 | |
| 568 | /* |
| 569 | * In case of mistaken revs or checkout error, or signals received, |
| 570 | * "bisect_auto_next" below may exit or misbehave. |
| 571 | * We have to trap this to be able to clean up using |
| 572 | * "bisect_clean_state". |
| 573 | */ |
| 574 | |
| 575 | /* |
| 576 | * Write new start state |
| 577 | */ |
| 578 | write_file(git_path_bisect_start(), "%s\n", start_head.buf); |
| 579 | |
| 580 | if (no_checkout) { |
Johannes Schindelin | 7877ac3 | 2019-05-21 10:50:21 -0700 | [diff] [blame] | 581 | if (get_oid(start_head.buf, &oid) < 0) { |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 582 | res = error(_("invalid ref: '%s'"), start_head.buf); |
Johannes Schindelin | 7877ac3 | 2019-05-21 10:50:21 -0700 | [diff] [blame] | 583 | goto finish; |
| 584 | } |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 585 | if (update_ref(NULL, "BISECT_HEAD", &oid, NULL, 0, |
| 586 | UPDATE_REFS_MSG_ON_ERR)) { |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 587 | res = -1; |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 588 | goto finish; |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | if (pathspec_pos < argc - 1) |
| 593 | sq_quote_argv(&bisect_names, argv + pathspec_pos); |
| 594 | write_file(git_path_bisect_names(), "%s\n", bisect_names.buf); |
| 595 | |
| 596 | for (i = 0; i < states.nr; i++) |
| 597 | if (bisect_write(states.items[i].string, |
| 598 | revs.items[i].string, terms, 1)) { |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 599 | res = -1; |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 600 | goto finish; |
| 601 | } |
| 602 | |
| 603 | if (must_write_terms && write_terms(terms->term_bad, |
| 604 | terms->term_good)) { |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 605 | res = -1; |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 606 | goto finish; |
| 607 | } |
| 608 | |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 609 | res = bisect_append_log_quoted(argv); |
| 610 | if (res) |
| 611 | res = -1; |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 612 | |
| 613 | finish: |
| 614 | string_list_clear(&revs, 0); |
| 615 | string_list_clear(&states, 0); |
| 616 | strbuf_release(&start_head); |
| 617 | strbuf_release(&bisect_names); |
Tanushree Tumane | 292731c | 2020-02-17 09:40:29 +0100 | [diff] [blame] | 618 | return res; |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 619 | } |
| 620 | |
Christian Couder | 1bf072e | 2009-03-26 05:55:54 +0100 | [diff] [blame] | 621 | int cmd_bisect__helper(int argc, const char **argv, const char *prefix) |
| 622 | { |
Pranit Bauva | 4ba1e5c | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 623 | enum { |
| 624 | NEXT_ALL = 1, |
Pranit Bauva | fb71a32 | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 625 | WRITE_TERMS, |
Pranit Bauva | b903674 | 2017-09-29 06:49:40 +0000 | [diff] [blame] | 626 | BISECT_CLEAN_STATE, |
Pranit Bauva | 5e82c3d | 2019-01-02 07:38:31 -0800 | [diff] [blame] | 627 | CHECK_EXPECTED_REVS, |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 628 | BISECT_RESET, |
Pranit Bauva | 4fbdbd5 | 2019-01-02 07:38:33 -0800 | [diff] [blame] | 629 | BISECT_WRITE, |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 630 | CHECK_AND_SET_TERMS, |
Pranit Bauva | 450ebb7 | 2019-01-02 07:38:35 -0800 | [diff] [blame] | 631 | BISECT_NEXT_CHECK, |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 632 | BISECT_TERMS, |
| 633 | BISECT_START |
Pranit Bauva | 4ba1e5c | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 634 | } cmdmode = 0; |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 635 | int no_checkout = 0, res = 0, nolog = 0; |
Christian Couder | 1bf072e | 2009-03-26 05:55:54 +0100 | [diff] [blame] | 636 | struct option options[] = { |
Pranit Bauva | 9e1c84d | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 637 | OPT_CMDMODE(0, "next-all", &cmdmode, |
| 638 | N_("perform 'git bisect next'"), NEXT_ALL), |
Pranit Bauva | ecb3f37 | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 639 | OPT_CMDMODE(0, "write-terms", &cmdmode, |
| 640 | N_("write the terms to .git/BISECT_TERMS"), WRITE_TERMS), |
Pranit Bauva | fb71a32 | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 641 | OPT_CMDMODE(0, "bisect-clean-state", &cmdmode, |
| 642 | N_("cleanup the bisection state"), BISECT_CLEAN_STATE), |
Pranit Bauva | b903674 | 2017-09-29 06:49:40 +0000 | [diff] [blame] | 643 | OPT_CMDMODE(0, "check-expected-revs", &cmdmode, |
| 644 | N_("check for expected revs"), CHECK_EXPECTED_REVS), |
Pranit Bauva | 5e82c3d | 2019-01-02 07:38:31 -0800 | [diff] [blame] | 645 | OPT_CMDMODE(0, "bisect-reset", &cmdmode, |
| 646 | N_("reset the bisection state"), BISECT_RESET), |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 647 | OPT_CMDMODE(0, "bisect-write", &cmdmode, |
| 648 | N_("write out the bisection state in BISECT_LOG"), BISECT_WRITE), |
Pranit Bauva | 4fbdbd5 | 2019-01-02 07:38:33 -0800 | [diff] [blame] | 649 | OPT_CMDMODE(0, "check-and-set-terms", &cmdmode, |
| 650 | N_("check and set terms in a bisection state"), CHECK_AND_SET_TERMS), |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 651 | OPT_CMDMODE(0, "bisect-next-check", &cmdmode, |
| 652 | N_("check whether bad or good terms exist"), BISECT_NEXT_CHECK), |
Pranit Bauva | 450ebb7 | 2019-01-02 07:38:35 -0800 | [diff] [blame] | 653 | OPT_CMDMODE(0, "bisect-terms", &cmdmode, |
| 654 | N_("print out the bisect terms"), BISECT_TERMS), |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 655 | OPT_CMDMODE(0, "bisect-start", &cmdmode, |
| 656 | N_("start the bisect session"), BISECT_START), |
Stefan Beller | d5d09d4 | 2013-08-03 13:51:19 +0200 | [diff] [blame] | 657 | OPT_BOOL(0, "no-checkout", &no_checkout, |
| 658 | N_("update BISECT_HEAD instead of checking out the current commit")), |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 659 | OPT_BOOL(0, "no-log", &nolog, |
Jean-Noël Avila | 32ceace | 2019-02-11 07:44:53 +0100 | [diff] [blame] | 660 | N_("no log for BISECT_WRITE")), |
Christian Couder | 1bf072e | 2009-03-26 05:55:54 +0100 | [diff] [blame] | 661 | OPT_END() |
| 662 | }; |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 663 | struct bisect_terms terms = { .term_good = NULL, .term_bad = NULL }; |
Christian Couder | 1bf072e | 2009-03-26 05:55:54 +0100 | [diff] [blame] | 664 | |
Stephen Boyd | 3778292 | 2009-05-23 11:53:12 -0700 | [diff] [blame] | 665 | argc = parse_options(argc, argv, prefix, options, |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 666 | git_bisect_helper_usage, |
| 667 | PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_UNKNOWN); |
Christian Couder | 1bf072e | 2009-03-26 05:55:54 +0100 | [diff] [blame] | 668 | |
Pranit Bauva | 9e1c84d | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 669 | if (!cmdmode) |
Christian Couder | 1bf072e | 2009-03-26 05:55:54 +0100 | [diff] [blame] | 670 | usage_with_options(git_bisect_helper_usage, options); |
| 671 | |
Pranit Bauva | 9e1c84d | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 672 | switch (cmdmode) { |
| 673 | case NEXT_ALL: |
Pranit Bauva | 45b6370 | 2020-02-17 09:40:37 +0100 | [diff] [blame] | 674 | res = bisect_next_all(the_repository, prefix, no_checkout); |
| 675 | break; |
Pranit Bauva | ecb3f37 | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 676 | case WRITE_TERMS: |
Pranit Bauva | 4ba1e5c | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 677 | if (argc != 2) |
Pranit Bauva | ecb3f37 | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 678 | return error(_("--write-terms requires two arguments")); |
| 679 | return write_terms(argv[0], argv[1]); |
Pranit Bauva | fb71a32 | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 680 | case BISECT_CLEAN_STATE: |
| 681 | if (argc != 0) |
| 682 | return error(_("--bisect-clean-state requires no arguments")); |
| 683 | return bisect_clean_state(); |
Pranit Bauva | b903674 | 2017-09-29 06:49:40 +0000 | [diff] [blame] | 684 | case CHECK_EXPECTED_REVS: |
| 685 | check_expected_revs(argv, argc); |
| 686 | return 0; |
Pranit Bauva | 5e82c3d | 2019-01-02 07:38:31 -0800 | [diff] [blame] | 687 | case BISECT_RESET: |
| 688 | if (argc > 1) |
| 689 | return error(_("--bisect-reset requires either no argument or a commit")); |
| 690 | return !!bisect_reset(argc ? argv[0] : NULL); |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 691 | case BISECT_WRITE: |
| 692 | if (argc != 4 && argc != 5) |
| 693 | return error(_("--bisect-write requires either 4 or 5 arguments")); |
| 694 | set_terms(&terms, argv[3], argv[2]); |
| 695 | res = bisect_write(argv[0], argv[1], &terms, nolog); |
| 696 | break; |
Pranit Bauva | 4fbdbd5 | 2019-01-02 07:38:33 -0800 | [diff] [blame] | 697 | case CHECK_AND_SET_TERMS: |
| 698 | if (argc != 3) |
| 699 | return error(_("--check-and-set-terms requires 3 arguments")); |
| 700 | set_terms(&terms, argv[2], argv[1]); |
| 701 | res = check_and_set_terms(&terms, argv[0]); |
| 702 | break; |
Pranit Bauva | 129a6cf | 2019-01-02 07:38:34 -0800 | [diff] [blame] | 703 | case BISECT_NEXT_CHECK: |
| 704 | if (argc != 2 && argc != 3) |
| 705 | return error(_("--bisect-next-check requires 2 or 3 arguments")); |
| 706 | set_terms(&terms, argv[1], argv[0]); |
| 707 | res = bisect_next_check(&terms, argc == 3 ? argv[2] : NULL); |
| 708 | break; |
Pranit Bauva | 450ebb7 | 2019-01-02 07:38:35 -0800 | [diff] [blame] | 709 | case BISECT_TERMS: |
| 710 | if (argc > 1) |
| 711 | return error(_("--bisect-terms requires 0 or 1 argument")); |
| 712 | res = bisect_terms(&terms, argc == 1 ? argv[0] : NULL); |
| 713 | break; |
Pranit Bauva | 06f5608 | 2019-01-02 07:38:36 -0800 | [diff] [blame] | 714 | case BISECT_START: |
| 715 | set_terms(&terms, "bad", "good"); |
| 716 | res = bisect_start(&terms, no_checkout, argv, argc); |
| 717 | break; |
Pranit Bauva | 9e1c84d | 2017-09-29 06:49:39 +0000 | [diff] [blame] | 718 | default: |
| 719 | return error("BUG: unknown subcommand '%d'", cmdmode); |
| 720 | } |
Pranit Bauva | 0f30233 | 2019-01-02 07:38:32 -0800 | [diff] [blame] | 721 | free_terms(&terms); |
Pranit Bauva | 45b6370 | 2020-02-17 09:40:37 +0100 | [diff] [blame] | 722 | |
| 723 | /* |
| 724 | * Handle early success |
| 725 | * From check_merge_bases > check_good_are_ancestors_of_bad > bisect_next_all |
| 726 | */ |
| 727 | if (res == BISECT_INTERNAL_SUCCESS_MERGE_BASE) |
| 728 | res = BISECT_OK; |
| 729 | |
Pranit Bauva | 7613ec5 | 2020-02-17 09:40:33 +0100 | [diff] [blame] | 730 | return abs(res); |
Christian Couder | 1bf072e | 2009-03-26 05:55:54 +0100 | [diff] [blame] | 731 | } |