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

Re: [PATCH v3 3/3] ref-filter: allow merged and no-merged filters

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 13, 2020, 21:56 UTC
Message-ID
<xmqqo8m9mjcb.fsf@gitster.c.googlers.com>
In-Reply-To
<CAPig+cTNp84Dm=0n-Bb9o=1nZNDFRE20XDWUPJT8yjdefv15rA@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 24 quoted lines
>> +       struct commit_list *check_reachable_list = reachable ?
>> +               ref_cbdata->filter->reachable_from :
>> +               ref_cbdata->filter->unreachable_from;
>> +
>> +       if (!check_reachable_list)
>> +               return;
>
> Rather than adding a boolean 'reachable' parameter to the function
> signature, you could instead directly pass in the `struct commit_list
> *` upon which to operate, which would allow you to drop the ternary
> operator here, and...
>
>> @@ -2322,8 +2337,8 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int
>> -       if (filter->merge_commit)
>> -               do_merge_filter(&ref_cbdata);
>> +       do_merge_filter(&ref_cbdata, 1);
>> +       do_merge_filter(&ref_cbdata, 0);
>
> ... make the callers a bit less opaque by eliminating the
> less-than-meaningful 0-or-1, and making it obvious which list is being
> consulted:
>
>     do_merge_filter(&ref_cbdata, ref_cbdata->filter->reachable_from);
>     do_merge_filter(&ref_cbdata, ref_cbdata->filter->unreachable_from);
There is this code in do_merge_filter(), though.
		if (is_merged == reachable)
 			array->items[array->nr++] = array->items[i];
 		else
 			free_array_item(item);

This is a body of the loop that runs over (surviving) tips of ref, after painting the commits from the tips of refs (interesting) and the [un]reachable_from commits (uninteresting). The temporary variable is_merged signals if the tip after revision walk is painted uninteresting, i.e. some of the [un]reachable_from commits reach the tip.

If 'reachable' and 'is_merged' are the same, that means either
 (1) the tip is reachable from some commit given as --merged
     <commit>; or
 (2) the tip is NOT reachable from any commit given as --no-merged
     <commit>
which means it survives this round of filtering.
By losing the 'reachable' bit, you make this switch impossible.

I do not mind making the 0/1 a symbolic constant between do_emreg_filter() and filter_refs() for enhanced readability, though.

Thanks.
Previous: Eric SunshineNext: Eric Sunshine
Message 18 of 36 in “ref-filter: allow merged and no-merged filters”
  1. ref-filter: allow merged and no-merged filtersAaron Lipman, Sep 8, 2020
  2. Junio C HamanoSep 8, 2020
  3. Aaron LipmanSep 8, 2020
  4. Junio C HamanoSep 9, 2020
  5. 0/2 git branch: allow combining merged and no-merged filtersAaron Lipman, Sep 11, 2020
  6. 1/2 t3201: test multiple branch filter combinationsAaron Lipman, Sep 11, 2020
  7. 2/2 ref-filter: allow merged and no-merged filtersAaron Lipman, Sep 11, 2020
  8. Junio C HamanoSep 11, 2020
  9. 0/3 git branch: allow combining merged and no-merged filtersAaron Lipman, Sep 13, 2020
  10. 1/3 t3201: test multiple branch filter combinationsAaron Lipman, Sep 13, 2020
  11. Eric SunshineSep 13, 2020
  12. Junio C HamanoSep 14, 2020
  13. 2/3 Doc: cover multiple contains/no-contains filtersAaron Lipman, Sep 13, 2020
  14. Eric SunshineSep 13, 2020
  15. Junio C HamanoSep 14, 2020
  16. 3/3 ref-filter: allow merged and no-merged filtersAaron Lipman, Sep 13, 2020
  17. Eric SunshineSep 13, 2020
  18. Junio C HamanoSep 13, 2020
  19. Eric SunshineSep 13, 2020
  20. 0/3 git branch: allow combining merged and no-merged filtersAaron Lipman, Sep 16, 2020
  21. 1/3 t3201: test multiple branch filter combinationsAaron Lipman, Sep 16, 2020
  22. 2/3 Doc: cover multiple contains/no-contains filtersAaron Lipman, Sep 16, 2020
  23. Junio C HamanoSep 16, 2020
  24. 3/3 ref-filter: allow merged and no-merged filtersAaron Lipman, Sep 16, 2020
  25. Junio C HamanoSep 16, 2020
  26. Eric SunshineSep 16, 2020
  27. 0/2 ref-filter: merged & no-merged touch-upsAaron Lipman, Sep 18, 2020
  28. 1/2 ref-filter: refactor do_merge_filter()Aaron Lipman, Sep 18, 2020
  29. Eric SunshineSep 18, 2020
  30. Eric SunshineSep 18, 2020
  31. Junio C HamanoSep 18, 2020
  32. 2/2 Doc: prefer more specific file nameAaron Lipman, Sep 18, 2020
  33. Eric SunshineSep 18, 2020
  34. 0/2 ref-filter: merged & no-merged touch-upsAaron Lipman, Sep 18, 2020
  35. 1/2 ref-filter: make internal reachable-filter API more preciseAaron Lipman, Sep 18, 2020
  36. 2/2 Doc: prefer more specific file nameAaron Lipman, Sep 18, 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.