| Christian Couder | a2ad79c | 2009-03-26 04:55:24 | [diff] [blame] | 1 | #ifndef BISECT_H |
| 2 | #define BISECT_H |
| 3 | |
| Elijah Newren | ef3ca95 | 2018-08-15 17:54:05 | [diff] [blame] | 4 | struct commit_list; |
| Nguyễn Thái Ngọc Duy | 69d2cfe | 2018-11-10 05:48:59 | [diff] [blame] | 5 | struct repository; |
| René Scharfe | 48af1fd | 2022-01-18 12:46:32 | [diff] [blame] | 6 | struct object_id; |
| Elijah Newren | ef3ca95 | 2018-08-15 17:54:05 | [diff] [blame] | 7 | |
| Martin Ågren | 24d707f | 2017-11-05 20:24:28 | [diff] [blame] | 8 | /* |
| 9 | * Find bisection. If something is found, `reaches` will be the number of |
| 10 | * commits that the best commit reaches. `all` will be the count of |
| 11 | * non-SAMETREE commits. If nothing is found, `list` will be NULL. |
| 12 | * Otherwise, it will be either all non-SAMETREE commits or the single |
| 13 | * best commit, as chosen by `find_all`. |
| 14 | */ |
| Denton Liu | 5545442 | 2019-04-29 08:28:14 | [diff] [blame] | 15 | void find_bisection(struct commit_list **list, int *reaches, int *all, |
| Aaron Lipman | ad464a4 | 2020-08-07 21:58:38 | [diff] [blame] | 16 | unsigned bisect_flags); |
| Christian Couder | a2ad79c | 2009-03-26 04:55:24 | [diff] [blame] | 17 | |
| Denton Liu | 5545442 | 2019-04-29 08:28:14 | [diff] [blame] | 18 | struct commit_list *filter_skipped(struct commit_list *list, |
| Denton Liu | ad6dad0 | 2019-04-29 08:28:23 | [diff] [blame] | 19 | struct commit_list **tried, |
| 20 | int show_all, |
| 21 | int *count, |
| 22 | int *skipped_first); |
| Christian Couder | 9518864 | 2009-03-26 04:55:49 | [diff] [blame] | 23 | |
| Christian Couder | 37c4c38 | 2009-03-29 09:55:43 | [diff] [blame] | 24 | #define BISECT_SHOW_ALL (1<<0) |
| Nguyễn Thái Ngọc Duy | 9899372 | 2012-02-28 14:00:00 | [diff] [blame] | 25 | #define REV_LIST_QUIET (1<<1) |
| Christian Couder | 37c4c38 | 2009-03-29 09:55:43 | [diff] [blame] | 26 | |
| Aaron Lipman | ad464a4 | 2020-08-07 21:58:38 | [diff] [blame] | 27 | #define FIND_BISECTION_ALL (1u<<0) |
| 28 | #define FIND_BISECTION_FIRST_PARENT_ONLY (1u<<1) |
| 29 | |
| Christian Couder | d797257 | 2009-04-06 20:28:00 | [diff] [blame] | 30 | struct rev_list_info { |
| 31 | struct rev_info *revs; |
| Nguyễn Thái Ngọc Duy | 9899372 | 2012-02-28 14:00:00 | [diff] [blame] | 32 | int flags; |
| Christian Couder | d797257 | 2009-04-06 20:28:00 | [diff] [blame] | 33 | int show_timestamp; |
| 34 | int hdr_termination; |
| 35 | const char *header_prefix; |
| 36 | }; |
| 37 | |
| Miriam Rubio | 680e8a0 | 2020-02-17 08:40:32 | [diff] [blame] | 38 | /* |
| 39 | * enum bisect_error represents the following return codes: |
| 40 | * BISECT_OK: success code. Internally, it means that next |
| 41 | * commit has been found (and possibly checked out) and it |
| 42 | * should be tested. |
| 43 | * BISECT_FAILED error code: default error code. |
| Pranit Bauva | ce58b5d | 2020-02-17 08:40:34 | [diff] [blame] | 44 | * BISECT_ONLY_SKIPPED_LEFT error code: only skipped |
| 45 | * commits left to be tested. |
| Pranit Bauva | 6c69f22 | 2020-02-17 08:40:39 | [diff] [blame] | 46 | * BISECT_MERGE_BASE_CHECK error code: merge base check failed. |
| 47 | * BISECT_NO_TESTABLE_COMMIT error code: no testable commit found. |
| 48 | * BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND early success code: |
| 49 | * first term_bad commit found. |
| Pranit Bauva | cdd4dc2 | 2020-02-17 08:40:36 | [diff] [blame] | 50 | * BISECT_INTERNAL_SUCCESS_MERGE_BASE early success |
| 51 | * code: found merge base that should be tested. |
| Pranit Bauva | 6c69f22 | 2020-02-17 08:40:39 | [diff] [blame] | 52 | * Early success codes BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND and |
| 53 | * BISECT_INTERNAL_SUCCESS_MERGE_BASE should be only internal codes. |
| Miriam Rubio | 680e8a0 | 2020-02-17 08:40:32 | [diff] [blame] | 54 | */ |
| 55 | enum bisect_error { |
| 56 | BISECT_OK = 0, |
| Pranit Bauva | ce58b5d | 2020-02-17 08:40:34 | [diff] [blame] | 57 | BISECT_FAILED = -1, |
| Pranit Bauva | cdd4dc2 | 2020-02-17 08:40:36 | [diff] [blame] | 58 | BISECT_ONLY_SKIPPED_LEFT = -2, |
| Pranit Bauva | 9ec598e | 2020-02-17 08:40:38 | [diff] [blame] | 59 | BISECT_MERGE_BASE_CHECK = -3, |
| Pranit Bauva | 6c69f22 | 2020-02-17 08:40:39 | [diff] [blame] | 60 | BISECT_NO_TESTABLE_COMMIT = -4, |
| 61 | BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND = -10, |
| Pranit Bauva | cdd4dc2 | 2020-02-17 08:40:36 | [diff] [blame] | 62 | BISECT_INTERNAL_SUCCESS_MERGE_BASE = -11 |
| Miriam Rubio | 680e8a0 | 2020-02-17 08:40:32 | [diff] [blame] | 63 | }; |
| 64 | |
| Chris Down | 0cf1def | 2022-05-11 18:00:09 | [diff] [blame] | 65 | /* |
| 66 | * Stores how many good/bad commits we have stored for a bisect. nr_bad can |
| 67 | * only be 0 or 1. |
| 68 | */ |
| 69 | struct bisect_state { |
| 70 | unsigned int nr_good; |
| 71 | unsigned int nr_bad; |
| 72 | }; |
| 73 | |
| Aaron Lipman | be5fe20 | 2020-08-07 21:58:36 | [diff] [blame] | 74 | enum bisect_error bisect_next_all(struct repository *r, const char *prefix); |
| Christian Couder | 1bf072e | 2009-03-26 04:55:54 | [diff] [blame] | 75 | |
| Denton Liu | 5545442 | 2019-04-29 08:28:14 | [diff] [blame] | 76 | int estimate_bisect_steps(int all); |
| Christian Couder | 1c87654 | 2009-04-19 09:55:38 | [diff] [blame] | 77 | |
| Denton Liu | 5545442 | 2019-04-29 08:28:14 | [diff] [blame] | 78 | void read_bisect_terms(const char **bad, const char **good); |
| Antoine Delaite | cb46d63 | 2015-06-29 15:40:30 | [diff] [blame] | 79 | |
| Denton Liu | 5545442 | 2019-04-29 08:28:14 | [diff] [blame] | 80 | int bisect_clean_state(void); |
| Pranit Bauva | fb71a32 | 2017-09-29 06:49:39 | [diff] [blame] | 81 | |
| René Scharfe | 48af1fd | 2022-01-18 12:46:32 | [diff] [blame] | 82 | enum bisect_error bisect_checkout(const struct object_id *bisect_rev, |
| 83 | int no_checkout); |
| 84 | |
| Christian Couder | a2ad79c | 2009-03-26 04:55:24 | [diff] [blame] | 85 | #endif |