git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 3/3] bisect: combine args passed to find_bisection()

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 30, 2020, 04:32 UTC
Message-ID
<xmqqr1st7hdd.fsf@gitster.c.googlers.com>
In-Reply-To
<20200730002735.87655-4-alipman88@gmail.com>
Aaron Lipman <alipman88@gmail.com> writes:
> Now that find_bisection() accepts multiple boolean arguments, these may
> be combined into a single unsigned integer in order to declutter some of
> the code in bisect.c

I'd rather call them "flags" without "bisect_". If we are passing two sets of flags, one set about "bisect" and the other set about something else, it would make quite a lot of sense to call the first set "bisect_flags", but what we are seeing here is not like that.

Show 6 quoted lines
> +	if (read_first_parent_option())
> +		bisect_flags |= BISECT_FIRST_PARENT;
> +
> +	if (!!skipped_revs.nr)
> +		bisect_flags |= BISECT_FIND_ALL;
> +

You do not care what kind of "true" you are feeding "if()", so I do not think you would want to keep !! prefix here. Older API into find_bisection() may wanted to say "pass 1 to find_all", in which case, normalizing with !! prefix may have made perfect sense, but that no longer holds here.

> +
> +	revs.first_parent_only = !!(bisect_flags & BISECT_FIRST_PARENT);

On the other hand, this !! may make sense; especially since .first_parent_only could just be a one-bit unsigned bitfield.

Show 6 quoted lines
>  	revs.limited = 1;
>  
>  	bisect_common(&revs);
>  
> -	find_bisection(&revs.commits, &reaches, &all, !!skipped_revs.nr, first_parent_only);
> +	find_bisection(&revs.commits, &reaches, &all, bisect_flags);
Show 6 quoted lines
> @@ -23,6 +23,9 @@ 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		(1u<<0)
> +#define BISECT_FIRST_PARENT	(1u<<1)

The set of bits to go to your "bisect_flags" are only these two new ones, and the existing BISECT_SHOW_ALL does not belong to it (it is a bit in rev_list_info.flags), but it is not apparent. I wonder if there is a good way to help readers easily tell these two sets apart. These are flags passed to find_bisection(), so perhaps

    #define FIND_BISECTION_ALL (1U<<0)
    #define FIND_BISECTION_FIRST_PARENT_ONLY (1U<<1)
    unsigned flags = 0;
    if (first_parent)
	flags |= FIND_BISECTION_FIRST_PARENT_ONLY;
    ...
    find_bisection(..., flags);
would be a reasonable compromise?
Thanks.
Previous: Aaron LipmanNext: Junio C Hamano
Message 12 of 42 in “Introduce --first-parent flag for git bisect”
  1. 0/3 Introduce --first-parent flag for git bisectAaron Lipman via GitGitGadget, Jul 28, 2020
  2. 1/3 rev-list: allow bisect and first-parent flagsAaron Lipman via GitGitGadget, Jul 28, 2020
  3. Junio C HamanoJul 28, 2020
  4. Junio C HamanoJul 28, 2020
  5. 2/3 bisect: introduce first-parent flagAaron Lipman via GitGitGadget, Jul 28, 2020
  6. 3/3 bisect: combine args passed to find_bisection()Aaron Lipman via GitGitGadget, Jul 28, 2020
  7. 0/3 Introduce --first-parent flag for git bisectAaron Lipman, Jul 30, 2020
  8. 1/3 rev-list: allow bisect and first-parent flagsAaron Lipman, Jul 30, 2020
  9. 2/3 bisect: introduce first-parent flagAaron Lipman, Jul 30, 2020
  10. Junio C HamanoJul 30, 2020
  11. 3/3 bisect: combine args passed to find_bisection()Aaron Lipman, Jul 30, 2020
  12. Junio C HamanoJul 30, 2020
  13. Junio C HamanoJul 30, 2020
  14. 0/4 Introduce --first-parent flag for git bisectAaron Lipman, Aug 1, 2020
  15. 1/4 rev-list: allow bisect and first-parent flagsAaron Lipman, Aug 1, 2020
  16. 3/4 bisect: combine args passed to find_bisection()Aaron Lipman, Aug 1, 2020
  17. Martin ÅgrenAug 1, 2020
  18. 4/4 bisect: consistent style for git bisect run testsAaron Lipman, Aug 1, 2020
  19. Martin ÅgrenAug 1, 2020
  20. 2/4 bisect: introduce first-parent flagAaron Lipman, Aug 1, 2020
  21. Junio C HamanoAug 1, 2020
  22. 0/5 Introduce --first-parent flag for git bisectAaron Lipman, Aug 4, 2020
  23. 1/5 t6030: modernize "git bisect run" testsAaron Lipman, Aug 4, 2020
  24. Christian CouderAug 5, 2020
  25. 2/5 rev-list: allow bisect and first-parent flagsAaron Lipman, Aug 4, 2020
  26. Eric SunshineAug 5, 2020
  27. 3/5 cmd_bisect__helper: defer parsing no-checkout flagAaron Lipman, Aug 4, 2020
  28. 4/5 bisect: introduce first-parent flagAaron Lipman, Aug 4, 2020
  29. 5/5 bisect: combine args passed to find_bisection()Aaron Lipman, Aug 4, 2020
  30. Junio C HamanoAug 4, 2020
  31. Christian CouderAug 5, 2020
  32. Junio C HamanoAug 7, 2020
  33. Eric SunshineAug 7, 2020
  34. Junio C HamanoAug 7, 2020
  35. Eric SunshineAug 7, 2020
  36. Martin ÅgrenAug 5, 2020
  37. 0/5 Introduce --first-parent flag for git bisectAaron Lipman, Aug 7, 2020
  38. 1/5 t6030: modernize "git bisect run" testsAaron Lipman, Aug 7, 2020
  39. 2/5 rev-list: allow bisect and first-parent flagsAaron Lipman, Aug 7, 2020
  40. 3/5 cmd_bisect__helper: defer parsing no-checkout flagAaron Lipman, Aug 7, 2020
  41. 5/5 bisect: combine args passed to find_bisection()Aaron Lipman, Aug 7, 2020
  42. 4/5 bisect: introduce first-parent flagAaron Lipman, Aug 7, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.