{"thread":{"id":"48291","subject":"[PATCH] Create 'bisect_flags' parameter in find_bisection() in preparation of passing multiple options","startedAt":"2018-04-15T08:59:13Z","lastAt":"2018-04-20T12:23:27Z","messageCount":9,"participants":["Harald Nordgren","Christian Couder","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"344709","messageId":"20180415085841.1269-1-haraldnordgren@gmail.com","threadId":"48291","inReplyTo":null,"subject":"[PATCH] Create 'bisect_flags' parameter in find_bisection() in preparation of passing multiple options","fromName":"Harald Nordgren","fromEmail":"haraldnordgren@gmail.com","sentAt":"2018-04-15T08:58:41Z","receivedAt":"2018-04-15T08:59:13Z","isPatch":true,"sender":{"key":"haraldnordgren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9569897?v=4"},"body":"---\n\nNotes:\n    Preperatory patch to enable either Tiago Botelho's or my patch, to do bisection on first parents / merge commits\n\n bisect.c           | 21 ++++++++++++---------\n bisect.h           |  5 +++--\n builtin/rev-list.c |  6 +++---\n 3 files changed, 18 insertions(+), 14 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex a579b50884..d85550fd89 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -254,7 +254,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n\n  */\n static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\t\t\t\t     int nr, int *weights,\n-\t\t\t\t\t     int find_all)\n+\t\t\t\t\t     int bisect_flags)\n {\n \tint n, counted;\n \tstruct commit_list *p;\n@@ -313,7 +313,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\tclear_distance(list);\n \n \t\t/* Does it happen to be at exactly half-way? */\n-\t\tif (!find_all && halfway(p, nr))\n+\t\tif (!(bisect_flags & BISECT_FIND_ALL) && halfway(p, nr))\n \t\t\treturn p;\n \t\tcounted++;\n \t}\n@@ -351,21 +351,21 @@ static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\t\t\tweight_set(p, weight(q));\n \n \t\t\t/* Does it happen to be at exactly half-way? */\n-\t\t\tif (!find_all && halfway(p, nr))\n+\t\t\tif (!(bisect_flags & BISECT_FIND_ALL) && halfway(p, nr))\n \t\t\t\treturn p;\n \t\t}\n \t}\n \n \tshow_list(\"bisection 2 counted all\", counted, nr, list);\n \n-\tif (!find_all)\n+\tif (!(bisect_flags & BISECT_FIND_ALL))\n \t\treturn best_bisection(list, nr);\n \telse\n \t\treturn best_bisection_sorted(list, nr);\n }\n \n void find_bisection(struct commit_list **commit_list, int *reaches,\n-\t\t    int *all, int find_all)\n+\t\t    int *all, int bisect_flags)\n {\n \tint nr, on_list;\n \tstruct commit_list *list, *p, *best, *next, *last;\n@@ -400,9 +400,9 @@ void find_bisection(struct commit_list **commit_list, int *reaches,\n \tweights = xcalloc(on_list, sizeof(*weights));\n \n \t/* Do the real work of finding bisection commit. */\n-\tbest = do_find_bisection(list, nr, weights, find_all);\n+\tbest = do_find_bisection(list, nr, weights, bisect_flags);\n \tif (best) {\n-\t\tif (!find_all) {\n+\t\tif (!(bisect_flags & BISECT_FIND_ALL)) {\n \t\t\tlist->item = best->item;\n \t\t\tfree_commit_list(list->next);\n \t\t\tbest = list;\n@@ -942,7 +942,7 @@ int bisect_next_all(const char *prefix, int no_checkout)\n {\n \tstruct rev_info revs;\n \tstruct commit_list *tried;\n-\tint reaches = 0, all = 0, nr, steps;\n+\tint reaches = 0, all = 0, bisect_flags = 0, nr, steps;\n \tstruct object_id *bisect_rev;\n \tchar *steps_msg;\n \n@@ -957,7 +957,10 @@ int bisect_next_all(const char *prefix, int no_checkout)\n \n \tbisect_common(&revs);\n \n-\tfind_bisection(&revs.commits, &reaches, &all, !!skipped_revs.nr);\n+\tif (skipped_revs.nr)\n+\t\tbisect_flags |= BISECT_FIND_ALL;\n+\n+\tfind_bisection(&revs.commits, &reaches, &all, bisect_flags);\n \trevs.commits = managed_skipped(revs.commits, &tried);\n \n \tif (!revs.commits) {\ndiff --git a/bisect.h b/bisect.h\nindex a5d9248a47..d46b078871 100644\n--- a/bisect.h\n+++ b/bisect.h\n@@ -6,10 +6,10 @@\n  * commits that the best commit reaches. `all` will be the count of\n  * non-SAMETREE commits. If nothing is found, `list` will be NULL.\n  * Otherwise, it will be either all non-SAMETREE commits or the single\n- * best commit, as chosen by `find_all`.\n+ * best commit, as chosen by flag `BISECT_FIND_ALL`.\n  */\n extern void find_bisection(struct commit_list **list, int *reaches, int *all,\n-\t\t\t   int find_all);\n+\t\t\t   int bisect_flags);\n \n extern struct commit_list *filter_skipped(struct commit_list *list,\n \t\t\t\t\t  struct commit_list **tried,\n@@ -19,6 +19,7 @@ extern struct commit_list *filter_skipped(struct commit_list *list,\n \n #define BISECT_SHOW_ALL\t\t(1<<0)\n #define REV_LIST_QUIET\t\t(1<<1)\n+#define BISECT_FIND_ALL\t\t(1<<2)\n \n struct rev_list_info {\n \tstruct rev_info *revs;\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex fadd3ec14c..88700e897d 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -360,7 +360,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \tint i;\n \tint bisect_list = 0;\n \tint bisect_show_vars = 0;\n-\tint bisect_find_all = 0;\n+\tint bisect_flags = 0;\n \tint use_bitmap_index = 0;\n \tconst char *show_progress = NULL;\n \n@@ -426,7 +426,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tif (!strcmp(arg, \"--bisect-all\")) {\n \t\t\tbisect_list = 1;\n-\t\t\tbisect_find_all = 1;\n+\t\t\tbisect_flags |= BISECT_FIND_ALL;\n \t\t\tinfo.flags |= BISECT_SHOW_ALL;\n \t\t\trevs.show_decorations = 1;\n \t\t\tcontinue;\n@@ -538,7 +538,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \tif (bisect_list) {\n \t\tint reaches, all;\n \n-\t\tfind_bisection(&revs.commits, &reaches, &all, bisect_find_all);\n+\t\tfind_bisection(&revs.commits, &reaches, &all, bisect_flags);\n \n \t\tif (bisect_show_vars)\n \t\t\treturn show_bisect_vars(&info, reaches, all);\n-- \n2.14.3 (Apple Git-98)\n\n"},{"id":"344710","messageId":"CAP8UFD3uz0kQ7s6MyRG=hXg8tYbu7QbRNqMZPstrtmXBZ6eTCg@mail.gmail.com","threadId":"48291","inReplyTo":"20180415085841.1269-1-haraldnordgren@gmail.com","subject":"Re: [PATCH] Create 'bisect_flags' parameter in find_bisection() in preparation of passing multiple options","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2018-04-15T09:55:16Z","receivedAt":"2018-04-15T09:55:29Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Hi,\n\nOn Sun, Apr 15, 2018 at 10:58 AM, Harald Nordgren\n<haraldnordgren@gmail.com> wrote:\n> ---\n>\n> Notes:\n>     Preperatory patch to enable either Tiago Botelho's or my patch, to do bisection on first parents / merge commits\n\nIt would be nice if you could move some part of the above note into\nthe commit message (above the ---). For example:\n\n\"Make it possible to implement bisecting only on first parents or on\nmerge commits by passing flags to find_bisection(), instead of just a\nfind_all boolean\".\n\nWhile at it maybe the subject line of the commit message could start\nwith \"bisect: create 'bisect_flags' parameter ...\" so that we can\nquickly tell which area of the code it is about.\n\n>  bisect.c           | 21 ++++++++++++---------\n>  bisect.h           |  5 +++--\n>  builtin/rev-list.c |  6 +++---\n>  3 files changed, 18 insertions(+), 14 deletions(-)\n>\n> diff --git a/bisect.c b/bisect.c\n> index a579b50884..d85550fd89 100644\n> --- a/bisect.c\n> +++ b/bisect.c\n> @@ -254,7 +254,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n\n>   */\n>  static struct commit_list *do_find_bisection(struct commit_list *list,\n>                                              int nr, int *weights,\n> -                                            int find_all)\n> +                                            int bisect_flags)\n\nI think it's better to use \"unsigned int\" rather than just \"int\" for flags.\n\n>  {\n>         int n, counted;\n>         struct commit_list *p;\n\n[...]\n\n> @@ -19,6 +19,7 @@ extern struct commit_list *filter_skipped(struct commit_list *list,\n>\n>  #define BISECT_SHOW_ALL                (1<<0)\n>  #define REV_LIST_QUIET         (1<<1)\n> +#define BISECT_FIND_ALL                (1<<2)\n\nIs BISECT_FIND_ALL really related to the other flags, or is this\nmixing rev list flags with bisect flags?\n\nThanks for working on this,\nChristian.\n"},{"id":"344711","messageId":"20180415104438.2046-1-haraldnordgren@gmail.com","threadId":"48291","inReplyTo":"20180415085841.1269-1-haraldnordgren@gmail.com","subject":"[PATCH v2] Make it possible to implement bisecting only on first parents or on merge commits by passing flags to find_bisection(), instead of just a find_all boolean","fromName":"Harald Nordgren","fromEmail":"haraldnordgren@gmail.com","sentAt":"2018-04-15T10:44:38Z","receivedAt":"2018-04-15T10:45:01Z","isPatch":true,"sender":{"key":"haraldnordgren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9569897?v=4"},"body":"Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n---\n\nNotes:\n    Updates according to Christian Couder's code review\n\n bisect.c           | 20 ++++++++++++--------\n bisect.h           |  6 ++++--\n builtin/rev-list.c |  6 +++---\n 3 files changed, 19 insertions(+), 13 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex a579b50884..19dac7491d 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -254,7 +254,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n\n  */\n static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\t\t\t\t     int nr, int *weights,\n-\t\t\t\t\t     int find_all)\n+\t\t\t\t\t     unsigned int bisect_flags)\n {\n \tint n, counted;\n \tstruct commit_list *p;\n@@ -313,7 +313,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\tclear_distance(list);\n \n \t\t/* Does it happen to be at exactly half-way? */\n-\t\tif (!find_all && halfway(p, nr))\n+\t\tif (!(bisect_flags & BISECT_FIND_ALL) && halfway(p, nr))\n \t\t\treturn p;\n \t\tcounted++;\n \t}\n@@ -351,21 +351,21 @@ static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\t\t\tweight_set(p, weight(q));\n \n \t\t\t/* Does it happen to be at exactly half-way? */\n-\t\t\tif (!find_all && halfway(p, nr))\n+\t\t\tif (!(bisect_flags & BISECT_FIND_ALL) && halfway(p, nr))\n \t\t\t\treturn p;\n \t\t}\n \t}\n \n \tshow_list(\"bisection 2 counted all\", counted, nr, list);\n \n-\tif (!find_all)\n+\tif (!(bisect_flags & BISECT_FIND_ALL))\n \t\treturn best_bisection(list, nr);\n \telse\n \t\treturn best_bisection_sorted(list, nr);\n }\n \n void find_bisection(struct commit_list **commit_list, int *reaches,\n-\t\t    int *all, int find_all)\n+\t\t    int *all, unsigned int bisect_flags)\n {\n \tint nr, on_list;\n \tstruct commit_list *list, *p, *best, *next, *last;\n@@ -400,9 +400,9 @@ void find_bisection(struct commit_list **commit_list, int *reaches,\n \tweights = xcalloc(on_list, sizeof(*weights));\n \n \t/* Do the real work of finding bisection commit. */\n-\tbest = do_find_bisection(list, nr, weights, find_all);\n+\tbest = do_find_bisection(list, nr, weights, bisect_flags);\n \tif (best) {\n-\t\tif (!find_all) {\n+\t\tif (!(bisect_flags & BISECT_FIND_ALL)) {\n \t\t\tlist->item = best->item;\n \t\t\tfree_commit_list(list->next);\n \t\t\tbest = list;\n@@ -943,6 +943,7 @@ int bisect_next_all(const char *prefix, int no_checkout)\n \tstruct rev_info revs;\n \tstruct commit_list *tried;\n \tint reaches = 0, all = 0, nr, steps;\n+\tunsigned int bisect_flags = 0;\n \tstruct object_id *bisect_rev;\n \tchar *steps_msg;\n \n@@ -957,7 +958,10 @@ int bisect_next_all(const char *prefix, int no_checkout)\n \n \tbisect_common(&revs);\n \n-\tfind_bisection(&revs.commits, &reaches, &all, !!skipped_revs.nr);\n+\tif (skipped_revs.nr)\n+\t\tbisect_flags |= BISECT_FIND_ALL;\n+\n+\tfind_bisection(&revs.commits, &reaches, &all, bisect_flags);\n \trevs.commits = managed_skipped(revs.commits, &tried);\n \n \tif (!revs.commits) {\ndiff --git a/bisect.h b/bisect.h\nindex a5d9248a47..8efe243a34 100644\n--- a/bisect.h\n+++ b/bisect.h\n@@ -1,15 +1,17 @@\n #ifndef BISECT_H\n #define BISECT_H\n \n+#define BISECT_FIND_ALL\t\t(1u<<0)\n+\n /*\n  * Find bisection. If something is found, `reaches` will be the number of\n  * commits that the best commit reaches. `all` will be the count of\n  * non-SAMETREE commits. If nothing is found, `list` will be NULL.\n  * Otherwise, it will be either all non-SAMETREE commits or the single\n- * best commit, as chosen by `find_all`.\n+ * best commit, as chosen by flag `BISECT_FIND_ALL`.\n  */\n extern void find_bisection(struct commit_list **list, int *reaches, int *all,\n-\t\t\t   int find_all);\n+\t\t\t   unsigned int bisect_flags);\n \n extern struct commit_list *filter_skipped(struct commit_list *list,\n \t\t\t\t\t  struct commit_list **tried,\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex fadd3ec14c..22c3d479fb 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -360,8 +360,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \tint i;\n \tint bisect_list = 0;\n \tint bisect_show_vars = 0;\n-\tint bisect_find_all = 0;\n \tint use_bitmap_index = 0;\n+\tunsigned int bisect_flags = 0;\n \tconst char *show_progress = NULL;\n \n \tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n@@ -426,7 +426,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tif (!strcmp(arg, \"--bisect-all\")) {\n \t\t\tbisect_list = 1;\n-\t\t\tbisect_find_all = 1;\n+\t\t\tbisect_flags |= BISECT_FIND_ALL;\n \t\t\tinfo.flags |= BISECT_SHOW_ALL;\n \t\t\trevs.show_decorations = 1;\n \t\t\tcontinue;\n@@ -538,7 +538,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \tif (bisect_list) {\n \t\tint reaches, all;\n \n-\t\tfind_bisection(&revs.commits, &reaches, &all, bisect_find_all);\n+\t\tfind_bisection(&revs.commits, &reaches, &all, bisect_flags);\n \n \t\tif (bisect_show_vars)\n \t\t\treturn show_bisect_vars(&info, reaches, all);\n-- \n2.14.3 (Apple Git-98)\n\n"},{"id":"344714","messageId":"CAP8UFD0gwLZ8NzpRKb3qz=QkKbTNLjwBVnEd0QGCxAGtCDo=Xg@mail.gmail.com","threadId":"48291","inReplyTo":"20180415104438.2046-1-haraldnordgren@gmail.com","subject":"Re: [PATCH v2] Make it possible to implement bisecting only on first parents or on merge commits by passing flags to find_bisection(), instead of just a find_all boolean","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2018-04-15T13:35:48Z","receivedAt":"2018-04-15T13:35:53Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Sun, Apr 15, 2018 at 12:44 PM, Harald Nordgren\n<haraldnordgren@gmail.com> wrote:\n> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n> ---\n>\n> Notes:\n>     Updates according to Christian Couder's code review\n\nAbout the commit message (its first line and its body), I was\nsuggesting a patch like the following:\n\nFrom 3a0ced0953ccc6038a43885d98a507eb18c19e42 Mon Sep 17 00:00:00 2001\nFrom: Harald Nordgren <haraldnordgren@gmail.com>\nDate: Sun, 15 Apr 2018 12:44:38 +0200\nSubject: [PATCH] bisect: create 'bisect_flags' parameter in find_bisection()\n\nMake it possible to implement bisecting only on first parents or on\nmerge commits by passing flags to find_bisection(), instead of just\na 'find_all' boolean.\n\nSigned-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n---\n bisect.c           | 20 ++++++++++++--------\n bisect.h           |  6 ++++--\n builtin/rev-list.c |  6 +++---\n 3 files changed, 19 insertions(+), 13 deletions(-)\n...\n\nThe rest of the patch looks good to me.\n\nThanks!\n"},{"id":"344715","messageId":"20180415134925.6203-1-haraldnordgren@gmail.com","threadId":"48291","inReplyTo":"20180415085841.1269-1-haraldnordgren@gmail.com","subject":"[PATCH v3] bisect: create 'bisect_flags' parameter in find_bisection()","fromName":"Harald Nordgren","fromEmail":"haraldnordgren@gmail.com","sentAt":"2018-04-15T13:49:25Z","receivedAt":"2018-04-15T13:49:47Z","isPatch":true,"sender":{"key":"haraldnordgren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9569897?v=4"},"body":"Make it possible to implement bisecting only on first parents or on\nmerge commits by passing flags to find_bisection(), instead of just\na 'find_all' boolean.\n\nSigned-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n---\n\nNotes:\n    Updating commit message\n\n bisect.c           | 20 ++++++++++++--------\n bisect.h           |  6 ++++--\n builtin/rev-list.c |  6 +++---\n 3 files changed, 19 insertions(+), 13 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex a579b50884..19dac7491d 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -254,7 +254,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n\n  */\n static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\t\t\t\t     int nr, int *weights,\n-\t\t\t\t\t     int find_all)\n+\t\t\t\t\t     unsigned int bisect_flags)\n {\n \tint n, counted;\n \tstruct commit_list *p;\n@@ -313,7 +313,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\tclear_distance(list);\n \n \t\t/* Does it happen to be at exactly half-way? */\n-\t\tif (!find_all && halfway(p, nr))\n+\t\tif (!(bisect_flags & BISECT_FIND_ALL) && halfway(p, nr))\n \t\t\treturn p;\n \t\tcounted++;\n \t}\n@@ -351,21 +351,21 @@ static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\t\t\tweight_set(p, weight(q));\n \n \t\t\t/* Does it happen to be at exactly half-way? */\n-\t\t\tif (!find_all && halfway(p, nr))\n+\t\t\tif (!(bisect_flags & BISECT_FIND_ALL) && halfway(p, nr))\n \t\t\t\treturn p;\n \t\t}\n \t}\n \n \tshow_list(\"bisection 2 counted all\", counted, nr, list);\n \n-\tif (!find_all)\n+\tif (!(bisect_flags & BISECT_FIND_ALL))\n \t\treturn best_bisection(list, nr);\n \telse\n \t\treturn best_bisection_sorted(list, nr);\n }\n \n void find_bisection(struct commit_list **commit_list, int *reaches,\n-\t\t    int *all, int find_all)\n+\t\t    int *all, unsigned int bisect_flags)\n {\n \tint nr, on_list;\n \tstruct commit_list *list, *p, *best, *next, *last;\n@@ -400,9 +400,9 @@ void find_bisection(struct commit_list **commit_list, int *reaches,\n \tweights = xcalloc(on_list, sizeof(*weights));\n \n \t/* Do the real work of finding bisection commit. */\n-\tbest = do_find_bisection(list, nr, weights, find_all);\n+\tbest = do_find_bisection(list, nr, weights, bisect_flags);\n \tif (best) {\n-\t\tif (!find_all) {\n+\t\tif (!(bisect_flags & BISECT_FIND_ALL)) {\n \t\t\tlist->item = best->item;\n \t\t\tfree_commit_list(list->next);\n \t\t\tbest = list;\n@@ -943,6 +943,7 @@ int bisect_next_all(const char *prefix, int no_checkout)\n \tstruct rev_info revs;\n \tstruct commit_list *tried;\n \tint reaches = 0, all = 0, nr, steps;\n+\tunsigned int bisect_flags = 0;\n \tstruct object_id *bisect_rev;\n \tchar *steps_msg;\n \n@@ -957,7 +958,10 @@ int bisect_next_all(const char *prefix, int no_checkout)\n \n \tbisect_common(&revs);\n \n-\tfind_bisection(&revs.commits, &reaches, &all, !!skipped_revs.nr);\n+\tif (skipped_revs.nr)\n+\t\tbisect_flags |= BISECT_FIND_ALL;\n+\n+\tfind_bisection(&revs.commits, &reaches, &all, bisect_flags);\n \trevs.commits = managed_skipped(revs.commits, &tried);\n \n \tif (!revs.commits) {\ndiff --git a/bisect.h b/bisect.h\nindex a5d9248a47..8efe243a34 100644\n--- a/bisect.h\n+++ b/bisect.h\n@@ -1,15 +1,17 @@\n #ifndef BISECT_H\n #define BISECT_H\n \n+#define BISECT_FIND_ALL\t\t(1u<<0)\n+\n /*\n  * Find bisection. If something is found, `reaches` will be the number of\n  * commits that the best commit reaches. `all` will be the count of\n  * non-SAMETREE commits. If nothing is found, `list` will be NULL.\n  * Otherwise, it will be either all non-SAMETREE commits or the single\n- * best commit, as chosen by `find_all`.\n+ * best commit, as chosen by flag `BISECT_FIND_ALL`.\n  */\n extern void find_bisection(struct commit_list **list, int *reaches, int *all,\n-\t\t\t   int find_all);\n+\t\t\t   unsigned int bisect_flags);\n \n extern struct commit_list *filter_skipped(struct commit_list *list,\n \t\t\t\t\t  struct commit_list **tried,\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex fadd3ec14c..22c3d479fb 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -360,8 +360,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \tint i;\n \tint bisect_list = 0;\n \tint bisect_show_vars = 0;\n-\tint bisect_find_all = 0;\n \tint use_bitmap_index = 0;\n+\tunsigned int bisect_flags = 0;\n \tconst char *show_progress = NULL;\n \n \tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n@@ -426,7 +426,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tif (!strcmp(arg, \"--bisect-all\")) {\n \t\t\tbisect_list = 1;\n-\t\t\tbisect_find_all = 1;\n+\t\t\tbisect_flags |= BISECT_FIND_ALL;\n \t\t\tinfo.flags |= BISECT_SHOW_ALL;\n \t\t\trevs.show_decorations = 1;\n \t\t\tcontinue;\n@@ -538,7 +538,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \tif (bisect_list) {\n \t\tint reaches, all;\n \n-\t\tfind_bisection(&revs.commits, &reaches, &all, bisect_find_all);\n+\t\tfind_bisection(&revs.commits, &reaches, &all, bisect_flags);\n \n \t\tif (bisect_show_vars)\n \t\t\treturn show_bisect_vars(&info, reaches, all);\n-- \n2.14.3 (Apple Git-98)\n\n"},{"id":"344856","messageId":"xmqq1sfewpcn.fsf@gitster-ct.c.googlers.com","threadId":"48291","inReplyTo":"20180415134925.6203-1-haraldnordgren@gmail.com","subject":"Re: [PATCH v3] bisect: create 'bisect_flags' parameter in find_bisection()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-04-17T02:15:04Z","receivedAt":"2018-04-17T02:15:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Harald Nordgren <haraldnordgren@gmail.com> writes:\n\n> Make it possible to implement bisecting only on first parents or on\n> merge commits by passing flags to find_bisection(), instead of just\n> a 'find_all' boolean.\n>\n> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n> ---\n>\n> Notes:\n>     Updating commit message\n\nLooks like a reasonable preparatory step *if* we want to later be\nable to pass other options down the same callchain.  It would be\nnice to have the second step that this praparatory step is meant to\nhelp as a follow-up (or 2/2 of a two-patch series, where this one is\n1/2) not in too distant future.\n"},{"id":"345009","messageId":"nycvar.QRO.7.76.6.1804182228210.4241@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz","threadId":"48291","inReplyTo":"20180415134925.6203-1-haraldnordgren@gmail.com","subject":"Re: [PATCH v3] bisect: create 'bisect_flags' parameter in find_bisection()","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-04-18T20:31:26Z","receivedAt":"2018-04-18T20:31:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Harald,\n\nOn Sun, 15 Apr 2018, Harald Nordgren wrote:\n\n> Make it possible to implement bisecting only on first parents or on\n> merge commits by passing flags to find_bisection(), instead of just\n> a 'find_all' boolean.\n> \n> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n\nVery nice. Just two little suggestions:\n\n> diff --git a/bisect.c b/bisect.c\n> index a579b50884..19dac7491d 100644\n> --- a/bisect.c\n> +++ b/bisect.c\n> @@ -254,7 +254,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n\n>   */\n>  static struct commit_list *do_find_bisection(struct commit_list *list,\n>  \t\t\t\t\t     int nr, int *weights,\n> -\t\t\t\t\t     int find_all)\n> +\t\t\t\t\t     unsigned int bisect_flags)\n\nFor flags, we frequently seem to use the type `unsigned` (which is the\nsame as `unsigned int`, just shorter).\n\n>  {\n>  \tint n, counted;\n>  \tstruct commit_list *p;\n> @@ -313,7 +313,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,\n>  \t\tclear_distance(list);\n>  \n>  \t\t/* Does it happen to be at exactly half-way? */\n> -\t\tif (!find_all && halfway(p, nr))\n> +\t\tif (!(bisect_flags & BISECT_FIND_ALL) && halfway(p, nr))\n\nRather than expanding the short & sweet `find_all` to `(bisect_flags &\nBISECT_FIND_ALL)` in three places in this function, I would rather just\ndefine this local variable in the beginning:\n\n\tunsigned int find_all = bisect_flags & BISECT_FIND_ALL;\n\nThis would also reduce the size of the diff.\n\nAll in all, very nice!\n\nCiao,\nJohannes\n\nP.S.: I fully agree with Junio and eagerly await what comes next ;-)\n"},{"id":"345016","messageId":"20180418210535.1862-1-haraldnordgren@gmail.com","threadId":"48291","inReplyTo":"20180415085841.1269-1-haraldnordgren@gmail.com","subject":"[PATCH v4] bisect: create 'bisect_flags' parameter in find_bisection()","fromName":"Harald Nordgren","fromEmail":"haraldnordgren@gmail.com","sentAt":"2018-04-18T21:05:35Z","receivedAt":"2018-04-18T21:05:51Z","isPatch":true,"sender":{"key":"haraldnordgren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9569897?v=4"},"body":"Make it possible to implement bisecting only on first parents or on\nmerge commits by passing flags to find_bisection(), instead of just\na 'find_all' boolean.\n\nSigned-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n---\n\nNotes:\n    Use unsigned type and cache flag value\n\n bisect.c           | 15 ++++++++++-----\n bisect.h           |  6 ++++--\n builtin/rev-list.c |  6 +++---\n 3 files changed, 17 insertions(+), 10 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex a579b50884..4eafc8262b 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -254,9 +254,10 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n\n  */\n static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\t\t\t\t     int nr, int *weights,\n-\t\t\t\t\t     int find_all)\n+\t\t\t\t\t     unsigned bisect_flags)\n {\n \tint n, counted;\n+\tunsigned find_all = bisect_flags & BISECT_FIND_ALL;\n \tstruct commit_list *p;\n \n \tcounted = 0;\n@@ -365,7 +366,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,\n }\n \n void find_bisection(struct commit_list **commit_list, int *reaches,\n-\t\t    int *all, int find_all)\n+\t\t    int *all, unsigned bisect_flags)\n {\n \tint nr, on_list;\n \tstruct commit_list *list, *p, *best, *next, *last;\n@@ -400,9 +401,9 @@ void find_bisection(struct commit_list **commit_list, int *reaches,\n \tweights = xcalloc(on_list, sizeof(*weights));\n \n \t/* Do the real work of finding bisection commit. */\n-\tbest = do_find_bisection(list, nr, weights, find_all);\n+\tbest = do_find_bisection(list, nr, weights, bisect_flags);\n \tif (best) {\n-\t\tif (!find_all) {\n+\t\tif (!(bisect_flags & BISECT_FIND_ALL)) {\n \t\t\tlist->item = best->item;\n \t\t\tfree_commit_list(list->next);\n \t\t\tbest = list;\n@@ -943,6 +944,7 @@ int bisect_next_all(const char *prefix, int no_checkout)\n \tstruct rev_info revs;\n \tstruct commit_list *tried;\n \tint reaches = 0, all = 0, nr, steps;\n+\tunsigned bisect_flags = 0;\n \tstruct object_id *bisect_rev;\n \tchar *steps_msg;\n \n@@ -957,7 +959,10 @@ int bisect_next_all(const char *prefix, int no_checkout)\n \n \tbisect_common(&revs);\n \n-\tfind_bisection(&revs.commits, &reaches, &all, !!skipped_revs.nr);\n+\tif (skipped_revs.nr)\n+\t\tbisect_flags |= BISECT_FIND_ALL;\n+\n+\tfind_bisection(&revs.commits, &reaches, &all, bisect_flags);\n \trevs.commits = managed_skipped(revs.commits, &tried);\n \n \tif (!revs.commits) {\ndiff --git a/bisect.h b/bisect.h\nindex a5d9248a47..1d40a33ad2 100644\n--- a/bisect.h\n+++ b/bisect.h\n@@ -1,15 +1,17 @@\n #ifndef BISECT_H\n #define BISECT_H\n \n+#define BISECT_FIND_ALL\t\t(1u<<0)\n+\n /*\n  * Find bisection. If something is found, `reaches` will be the number of\n  * commits that the best commit reaches. `all` will be the count of\n  * non-SAMETREE commits. If nothing is found, `list` will be NULL.\n  * Otherwise, it will be either all non-SAMETREE commits or the single\n- * best commit, as chosen by `find_all`.\n+ * best commit, as chosen by flag `BISECT_FIND_ALL`.\n  */\n extern void find_bisection(struct commit_list **list, int *reaches, int *all,\n-\t\t\t   int find_all);\n+\t\t\t   unsigned bisect_flags);\n \n extern struct commit_list *filter_skipped(struct commit_list *list,\n \t\t\t\t\t  struct commit_list **tried,\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex fadd3ec14c..8752f5bbed 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -360,8 +360,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \tint i;\n \tint bisect_list = 0;\n \tint bisect_show_vars = 0;\n-\tint bisect_find_all = 0;\n \tint use_bitmap_index = 0;\n+\tunsigned bisect_flags = 0;\n \tconst char *show_progress = NULL;\n \n \tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n@@ -426,7 +426,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tif (!strcmp(arg, \"--bisect-all\")) {\n \t\t\tbisect_list = 1;\n-\t\t\tbisect_find_all = 1;\n+\t\t\tbisect_flags |= BISECT_FIND_ALL;\n \t\t\tinfo.flags |= BISECT_SHOW_ALL;\n \t\t\trevs.show_decorations = 1;\n \t\t\tcontinue;\n@@ -538,7 +538,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \tif (bisect_list) {\n \t\tint reaches, all;\n \n-\t\tfind_bisection(&revs.commits, &reaches, &all, bisect_find_all);\n+\t\tfind_bisection(&revs.commits, &reaches, &all, bisect_flags);\n \n \t\tif (bisect_show_vars)\n \t\t\treturn show_bisect_vars(&info, reaches, all);\n-- \n2.14.3 (Apple Git-98)\n\n"},{"id":"345220","messageId":"nycvar.QRO.7.76.6.1804201422390.4241@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz","threadId":"48291","inReplyTo":"20180418210535.1862-1-haraldnordgren@gmail.com","subject":"Re: [PATCH v4] bisect: create 'bisect_flags' parameter in find_bisection()","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-04-20T12:23:04Z","receivedAt":"2018-04-20T12:23:27Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Harald,\n\nOn Wed, 18 Apr 2018, Harald Nordgren wrote:\n\n> Make it possible to implement bisecting only on first parents or on\n> merge commits by passing flags to find_bisection(), instead of just\n> a 'find_all' boolean.\n> \n> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n> ---\n> \n> Notes:\n>     Use unsigned type and cache flag value\n\nThis version looks good to me.\n\nThanks,\nJohannes\n"}]}