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

Re: [PATCH 2/4] ref-filter: add ref-filter API

From
Junio C Hamano <gitster@pobox.com>
Date
May 23, 2015, 17:18 UTC
Message-ID
<xmqqoalbciwj.fsf@gitster.dls.corp.google.com>
In-Reply-To
<vpq8ucffj8h.fsf@anie.imag.fr>
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
Show 12 quoted lines
> But I think this could be clearer in the code (and/or comment + commit
> message). Perhaps stg like:
>
> struct ref_filter_data /* Probably not the best name */ {
>         struct ref_list list;
>         struct ref_filter filter;
> };
>
> struct ref_list {
>  	int count, alloc;
>  	struct ref_filter_item **items;
> };

If you plan to use ALLOC_GROW() API, name the bookkeeping variables "alloc" & "nr", unless you have a compelling reason to deviate from the prevailing practice.

> struct ref_filter {
> 	const char **name_patterns;
> 	/* There will be more here later */
> };
Very good suggestion.

Whatever the final name would be, it is a good idea to separate the "list of things that are operated on" and the "set of operations to be applied". That makes things conceptually cleaner; you can have multiple of the former operated on with a singleton of the latter and then their results merged, etc. etc.

And I do not think an array of things that are operated on should not be named "ref_filter_item".

Surely, the latter "set of operations to be applied" may currently be only filtering, but who says it has to stay that way? "I have a set of refs that represent my local branches I am interested in. Please map them to their corresponding @{upstream}" is a reasonable request once you have an infrastructure to represent "set of refs to be worked on" and "set of operations to apply", and at that point, the items are no longer filter-items (map-items?).

Previous: Matthieu MoyNext: Matthieu Moy
Message 18 of 24 in “Unifying git branch -l, git tag -l, and git for-each-ref”
  1. karthik nayakMay 20, 2015
  2. 1/4 for-each-ref: rename refinfo members to match similar structuresKarthik Nayak, May 20, 2015
  3. Matthieu MoyMay 20, 2015
  4. karthik nayakMay 21, 2015
  5. 2/4 ref-filter: add ref-filter APIKarthik Nayak, May 20, 2015
  6. Eric SunshineMay 20, 2015
  7. karthik nayakMay 21, 2015
  8. Eric SunshineMay 21, 2015
  9. karthik nayakMay 22, 2015
  10. Matthieu MoyMay 21, 2015
  11. karthik nayakMay 21, 2015
  12. karthik nayakMay 21, 2015
  13. Matthieu MoyMay 22, 2015
  14. karthik nayakMay 22, 2015
  15. Matthieu MoyMay 23, 2015
  16. Christian CouderMay 23, 2015
  17. Matthieu MoyMay 23, 2015
  18. Junio C HamanoMay 23, 2015
  19. Matthieu MoyMay 23, 2015
  20. Karthik NayakMay 23, 2015
  21. 3/4 for-each-ref: convert to ref-filterKarthik Nayak, May 20, 2015
  22. Junio C HamanoMay 20, 2015
  23. karthik nayakMay 21, 2015
  24. 4/4 ref-filter: move formatting/sorting options from 'for-each-ref'Karthik Nayak, May 20, 2015

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.