2009-03-26 07:55:24 +03:00
|
|
|
#ifndef BISECT_H
|
|
|
|
#define BISECT_H
|
2018-08-15 20:54:05 +03:00
|
|
|
|
|
|
|
struct commit_list;
|
2018-11-10 08:48:59 +03:00
|
|
|
struct repository;
|
bisect--helper: double-check run command on exit code 126 and 127
When a run command cannot be executed or found, shells return exit code
126 or 127, respectively. Valid run commands are allowed to return
these codes as well to indicate bad revisions, though, for historical
reasons. This means typos can cause bogus bisect runs that go over the
full distance and end up reporting invalid results.
The best solution would be to reserve exit codes 126 and 127, like
71b0251cdd (Bisect run: "skip" current commit if script exit code is
125., 2007-10-26) did for 125, and abort bisect run when we get them.
That might be inconvenient for those who relied on the documentation
stating that 126 and 127 can be used for bad revisions, though.
The workaround used by this patch is to run the command on a known-good
revision and abort if we still get the same error code. This adds one
step to runs with scripts that use exit codes 126 and 127, but keeps
them supported, with one exception: It won't work with commands that
cannot recognize the (manually marked) known-good revision as such.
Run commands that use low exit codes are unaffected. Typos are reported
after executing the missing command twice and three checkouts (the first
step, the known good revision and back to the revision of the first
step).
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-01-18 15:46:32 +03:00
|
|
|
struct object_id;
|
2009-03-26 07:55:24 +03:00
|
|
|
|
2017-11-05 23:24:28 +03:00
|
|
|
/*
|
|
|
|
* Find bisection. If something is found, `reaches` will be the number of
|
|
|
|
* commits that the best commit reaches. `all` will be the count of
|
|
|
|
* non-SAMETREE commits. If nothing is found, `list` will be NULL.
|
|
|
|
* Otherwise, it will be either all non-SAMETREE commits or the single
|
|
|
|
* best commit, as chosen by `find_all`.
|
|
|
|
*/
|
2019-04-29 11:28:14 +03:00
|
|
|
void find_bisection(struct commit_list **list, int *reaches, int *all,
|
2020-08-08 00:58:38 +03:00
|
|
|
unsigned bisect_flags);
|
2009-03-26 07:55:24 +03:00
|
|
|
|
2019-04-29 11:28:14 +03:00
|
|
|
struct commit_list *filter_skipped(struct commit_list *list,
|
2019-04-29 11:28:23 +03:00
|
|
|
struct commit_list **tried,
|
|
|
|
int show_all,
|
|
|
|
int *count,
|
|
|
|
int *skipped_first);
|
2009-03-26 07:55:49 +03:00
|
|
|
|
2009-03-29 13:55:43 +04:00
|
|
|
#define BISECT_SHOW_ALL (1<<0)
|
2012-02-28 18:00:00 +04:00
|
|
|
#define REV_LIST_QUIET (1<<1)
|
2009-03-29 13:55:43 +04:00
|
|
|
|
2020-08-08 00:58:38 +03:00
|
|
|
#define FIND_BISECTION_ALL (1u<<0)
|
|
|
|
#define FIND_BISECTION_FIRST_PARENT_ONLY (1u<<1)
|
|
|
|
|
2009-04-07 00:28:00 +04:00
|
|
|
struct rev_list_info {
|
|
|
|
struct rev_info *revs;
|
2012-02-28 18:00:00 +04:00
|
|
|
int flags;
|
2009-04-07 00:28:00 +04:00
|
|
|
int show_timestamp;
|
|
|
|
int hdr_termination;
|
|
|
|
const char *header_prefix;
|
|
|
|
};
|
|
|
|
|
2020-02-17 11:40:32 +03:00
|
|
|
/*
|
|
|
|
* enum bisect_error represents the following return codes:
|
|
|
|
* BISECT_OK: success code. Internally, it means that next
|
|
|
|
* commit has been found (and possibly checked out) and it
|
|
|
|
* should be tested.
|
|
|
|
* BISECT_FAILED error code: default error code.
|
2020-02-17 11:40:34 +03:00
|
|
|
* BISECT_ONLY_SKIPPED_LEFT error code: only skipped
|
|
|
|
* commits left to be tested.
|
2020-02-17 11:40:39 +03:00
|
|
|
* BISECT_MERGE_BASE_CHECK error code: merge base check failed.
|
|
|
|
* BISECT_NO_TESTABLE_COMMIT error code: no testable commit found.
|
|
|
|
* BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND early success code:
|
|
|
|
* first term_bad commit found.
|
2020-02-17 11:40:36 +03:00
|
|
|
* BISECT_INTERNAL_SUCCESS_MERGE_BASE early success
|
|
|
|
* code: found merge base that should be tested.
|
2020-02-17 11:40:39 +03:00
|
|
|
* Early success codes BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND and
|
|
|
|
* BISECT_INTERNAL_SUCCESS_MERGE_BASE should be only internal codes.
|
2020-02-17 11:40:32 +03:00
|
|
|
*/
|
|
|
|
enum bisect_error {
|
|
|
|
BISECT_OK = 0,
|
2020-02-17 11:40:34 +03:00
|
|
|
BISECT_FAILED = -1,
|
2020-02-17 11:40:36 +03:00
|
|
|
BISECT_ONLY_SKIPPED_LEFT = -2,
|
2020-02-17 11:40:38 +03:00
|
|
|
BISECT_MERGE_BASE_CHECK = -3,
|
2020-02-17 11:40:39 +03:00
|
|
|
BISECT_NO_TESTABLE_COMMIT = -4,
|
|
|
|
BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND = -10,
|
2020-02-17 11:40:36 +03:00
|
|
|
BISECT_INTERNAL_SUCCESS_MERGE_BASE = -11
|
2020-02-17 11:40:32 +03:00
|
|
|
};
|
|
|
|
|
bisect: output state before we are ready to compute bisection
Commit 73c6de06aff8 ("bisect: don't use invalid oid as rev when
starting") changes the behaviour of `git bisect` to consider invalid
oids as pathspecs again, as in the old shell implementation.
While that behaviour may be desirable, it can also cause confusion. For
example, while bisecting in a particular repo I encountered this:
$ git bisect start d93ff48803f0 v6.3
$
...which led to me sitting for a few moments, wondering why there's no
printout stating the first rev to check.
It turns out that the tag was actually "6.3", not "v6.3", and thus the
bisect was still silently started with only a bad rev, because
d93ff48803f0 was a valid oid and "v6.3" was silently considered to be a
pathspec.
While this behaviour may be desirable, it can be confusing, especially
with different repo conventions either using or not using "v" before
release names, or when a branch name or tag is simply misspelled on the
command line.
In order to avoid situations like this, make it more clear what we're
waiting for:
$ git bisect start d93ff48803f0 v6.3
status: waiting for good commit(s), bad commit known
We already have good output once the bisect process has begun in
earnest, so we don't need to do anything more there.
Signed-off-by: Chris Down <chris@chrisdown.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-11 21:00:09 +03:00
|
|
|
/*
|
|
|
|
* Stores how many good/bad commits we have stored for a bisect. nr_bad can
|
|
|
|
* only be 0 or 1.
|
|
|
|
*/
|
|
|
|
struct bisect_state {
|
|
|
|
unsigned int nr_good;
|
|
|
|
unsigned int nr_bad;
|
|
|
|
};
|
|
|
|
|
2020-08-08 00:58:36 +03:00
|
|
|
enum bisect_error bisect_next_all(struct repository *r, const char *prefix);
|
2009-03-26 07:55:54 +03:00
|
|
|
|
2019-04-29 11:28:14 +03:00
|
|
|
int estimate_bisect_steps(int all);
|
2009-04-19 13:55:38 +04:00
|
|
|
|
2019-04-29 11:28:14 +03:00
|
|
|
void read_bisect_terms(const char **bad, const char **good);
|
2015-06-29 18:40:30 +03:00
|
|
|
|
2019-04-29 11:28:14 +03:00
|
|
|
int bisect_clean_state(void);
|
2017-09-29 09:49:39 +03:00
|
|
|
|
bisect--helper: double-check run command on exit code 126 and 127
When a run command cannot be executed or found, shells return exit code
126 or 127, respectively. Valid run commands are allowed to return
these codes as well to indicate bad revisions, though, for historical
reasons. This means typos can cause bogus bisect runs that go over the
full distance and end up reporting invalid results.
The best solution would be to reserve exit codes 126 and 127, like
71b0251cdd (Bisect run: "skip" current commit if script exit code is
125., 2007-10-26) did for 125, and abort bisect run when we get them.
That might be inconvenient for those who relied on the documentation
stating that 126 and 127 can be used for bad revisions, though.
The workaround used by this patch is to run the command on a known-good
revision and abort if we still get the same error code. This adds one
step to runs with scripts that use exit codes 126 and 127, but keeps
them supported, with one exception: It won't work with commands that
cannot recognize the (manually marked) known-good revision as such.
Run commands that use low exit codes are unaffected. Typos are reported
after executing the missing command twice and three checkouts (the first
step, the known good revision and back to the revision of the first
step).
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-01-18 15:46:32 +03:00
|
|
|
enum bisect_error bisect_checkout(const struct object_id *bisect_rev,
|
|
|
|
int no_checkout);
|
|
|
|
|
2009-03-26 07:55:24 +03:00
|
|
|
#endif
|