Re: [PATCH] Create 'bisect_flags' parameter in find_bisection() in preparation of passing multiple options

2018-04-15 Thread Christian Couder
Hi,

On Sun, Apr 15, 2018 at 10:58 AM, Harald Nordgren
 wrote:
> ---
>
> Notes:
> Preperatory patch to enable either Tiago Botelho's or my patch, to do 
> bisection on first parents / merge commits

It would be nice if you could move some part of the above note into
the commit message (above the ---). For example:

"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".

While at it maybe the subject line of the commit message could start
with "bisect: create 'bisect_flags' parameter ..." so that we can
quickly tell which area of the code it is about.

>  bisect.c   | 21 -
>  bisect.h   |  5 +++--
>  builtin/rev-list.c |  6 +++---
>  3 files changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/bisect.c b/bisect.c
> index a579b50884..d85550fd89 100644
> --- a/bisect.c
> +++ b/bisect.c
> @@ -254,7 +254,7 @@ static struct commit_list *best_bisection_sorted(struct 
> commit_list *list, int n
>   */
>  static struct commit_list *do_find_bisection(struct commit_list *list,
>  int nr, int *weights,
> -int find_all)
> +int bisect_flags)

I think it's better to use "unsigned int" rather than just "int" for flags.

>  {
> int n, counted;
> struct commit_list *p;

[...]

> @@ -19,6 +19,7 @@ extern struct commit_list *filter_skipped(struct 
> commit_list *list,
>
>  #define BISECT_SHOW_ALL(1<<0)
>  #define REV_LIST_QUIET (1<<1)
> +#define BISECT_FIND_ALL(1<<2)

Is BISECT_FIND_ALL really related to the other flags, or is this
mixing rev list flags with bisect flags?

Thanks for working on this,
Christian.


[PATCH] Create 'bisect_flags' parameter in find_bisection() in preparation of passing multiple options

2018-04-15 Thread Harald Nordgren
---

Notes:
Preperatory patch to enable either Tiago Botelho's or my patch, to do 
bisection on first parents / merge commits

 bisect.c   | 21 -
 bisect.h   |  5 +++--
 builtin/rev-list.c |  6 +++---
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/bisect.c b/bisect.c
index a579b50884..d85550fd89 100644
--- a/bisect.c
+++ b/bisect.c
@@ -254,7 +254,7 @@ static struct commit_list *best_bisection_sorted(struct 
commit_list *list, int n
  */
 static struct commit_list *do_find_bisection(struct commit_list *list,
 int nr, int *weights,
-int find_all)
+int bisect_flags)
 {
int n, counted;
struct commit_list *p;
@@ -313,7 +313,7 @@ static struct commit_list *do_find_bisection(struct 
commit_list *list,
clear_distance(list);
 
/* Does it happen to be at exactly half-way? */
-   if (!find_all && halfway(p, nr))
+   if (!(bisect_flags & BISECT_FIND_ALL) && halfway(p, nr))
return p;
counted++;
}
@@ -351,21 +351,21 @@ static struct commit_list *do_find_bisection(struct 
commit_list *list,
weight_set(p, weight(q));
 
/* Does it happen to be at exactly half-way? */
-   if (!find_all && halfway(p, nr))
+   if (!(bisect_flags & BISECT_FIND_ALL) && halfway(p, nr))
return p;
}
}
 
show_list("bisection 2 counted all", counted, nr, list);
 
-   if (!find_all)
+   if (!(bisect_flags & BISECT_FIND_ALL))
return best_bisection(list, nr);
else
return best_bisection_sorted(list, nr);
 }
 
 void find_bisection(struct commit_list **commit_list, int *reaches,
-   int *all, int find_all)
+   int *all, int bisect_flags)
 {
int nr, on_list;
struct commit_list *list, *p, *best, *next, *last;
@@ -400,9 +400,9 @@ void find_bisection(struct commit_list **commit_list, int 
*reaches,
weights = xcalloc(on_list, sizeof(*weights));
 
/* Do the real work of finding bisection commit. */
-   best = do_find_bisection(list, nr, weights, find_all);
+   best = do_find_bisection(list, nr, weights, bisect_flags);
if (best) {
-   if (!find_all) {
+   if (!(bisect_flags & BISECT_FIND_ALL)) {
list->item = best->item;
free_commit_list(list->next);
best = list;
@@ -942,7 +942,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
 {
struct rev_info revs;
struct commit_list *tried;
-   int reaches = 0, all = 0, nr, steps;
+   int reaches = 0, all = 0, bisect_flags = 0, nr, steps;
struct object_id *bisect_rev;
char *steps_msg;
 
@@ -957,7 +957,10 @@ int bisect_next_all(const char *prefix, int no_checkout)
 
bisect_common();
 
-   find_bisection(, , , !!skipped_revs.nr);
+   if (skipped_revs.nr)
+   bisect_flags |= BISECT_FIND_ALL;
+
+   find_bisection(, , , bisect_flags);
revs.commits = managed_skipped(revs.commits, );
 
if (!revs.commits) {
diff --git a/bisect.h b/bisect.h
index a5d9248a47..d46b078871 100644
--- a/bisect.h
+++ b/bisect.h
@@ -6,10 +6,10 @@
  * 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`.
+ * best commit, as chosen by flag `BISECT_FIND_ALL`.
  */
 extern void find_bisection(struct commit_list **list, int *reaches, int *all,
-  int find_all);
+  int bisect_flags);
 
 extern struct commit_list *filter_skipped(struct commit_list *list,
  struct commit_list **tried,
@@ -19,6 +19,7 @@ extern struct commit_list *filter_skipped(struct commit_list 
*list,
 
 #define BISECT_SHOW_ALL(1<<0)
 #define REV_LIST_QUIET (1<<1)
+#define BISECT_FIND_ALL(1<<2)
 
 struct rev_list_info {
struct rev_info *revs;
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index fadd3ec14c..88700e897d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -360,7 +360,7 @@ int cmd_rev_list(int argc, const char **argv, const char 
*prefix)
int i;
int bisect_list = 0;
int bisect_show_vars = 0;
-   int bisect_find_all = 0;
+   int bisect_flags = 0;
int use_bitmap_index = 0;
const char *show_progress = NULL;
 
@@ -426,7 +426,7 @@ int cmd_rev_list(int argc, const char **argv, const char 
*prefix)
}