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

Re: [PATCH v6 10/11] for-each-ref: introduce filter_refs()

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 8, 2015, 18:15 UTC
Message-ID
<xmqqd216awxz.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1433673373-16441-1-git-send-email-karthik.188@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 9 quoted lines
> +/*
> + * API for filtering a set of refs. The refs are provided and iterated
> + * over using the for_each_ref_fn(). The refs are stored into and filtered
> + * based on the ref_filter_cbdata structure.
> + */
> +int filter_refs(int (for_each_ref_fn)(each_ref_fn, void *), struct ref_filter_cbdata *data)
> +{
> +	return for_each_ref_fn(ref_filter_handler, data);
> +}

I do not think it is such a good idea to allow API callers to specify for-each-ref-fn directly. See my message in an earlier review.

I also think ref_filter_cbdata is an implementation detail of filter_refs and may not have to be exposed to the API callers. It probably is more sensible for them to pass

 - an array of refs to receive filtered results (your ref_array thing)
 - the criteria to use when filtering (your ref_filter thing)

as two separate parameters to this function, together with other parameters that lets you (meaning the implementation of filter_refs()) to decide which for-each-ref iterator to call, e.g. do you want to use raw iteration? do you want to iterate only over refs/heads? etc.

In other words, the caller of this API should not have to know that you (meaning the implementation of filter_refs()) are internally using for_each_ref() API.

Previous: Karthik NayakNext: Karthik Nayak
Message 17 of 24 in “create ref-filter from for-each-ref”
  1. 0/11 create ref-filter from for-each-refKarthik Nayak, Jun 6, 2015
  2. 01/11 for-each-ref: extract helper functions out of grab_single_ref()Karthik Nayak, Jun 6, 2015
  3. 02/11 for-each-ref: clean up codeKarthik Nayak, Jun 6, 2015
  4. 03/11 for-each-ref: rename 'refinfo' to 'ref_array_item'Karthik Nayak, Jun 6, 2015
  5. 04/11 for-each-ref: introduce new structures for better organisationKarthik Nayak, Jun 6, 2015
  6. 05/11 for-each-ref: introduce 'ref_array_clear()'Karthik Nayak, Jun 6, 2015
  7. 06/11 for-each-ref: rename some functions and make them publicKarthik Nayak, Jun 6, 2015
  8. 07/11 for-each-ref: rename variables called sort to sortingKarthik Nayak, Jun 6, 2015
  9. 08/11 ref-filter: add 'ref-filter.h'Karthik Nayak, Jun 6, 2015
  10. 09/11 ref-filter: move code from 'for-each-ref'Karthik Nayak, Jun 6, 2015
  11. 09/11 ref-filter: move code from 'for-each-ref'Karthik Nayak, Jun 7, 2015
  12. Matthieu MoyJun 8, 2015
  13. Karthik NayakJun 8, 2015
  14. Junio C HamanoJun 8, 2015
  15. 10/11 for-each-ref: introduce filter_refs()Karthik Nayak, Jun 6, 2015
  16. 10/11 for-each-ref: introduce filter_refs()Karthik Nayak, Jun 7, 2015
  17. Junio C HamanoJun 8, 2015
  18. Karthik NayakJun 8, 2015
  19. 11/11 ref-filter: make 'ref_array_item' use a FLEX_ARRAY for refnameKarthik Nayak, Jun 6, 2015
  20. Junio C HamanoJun 8, 2015
  21. Karthik NayakJun 8, 2015
  22. Karthik NayakJun 7, 2015
  23. Matthieu MoyJun 8, 2015
  24. Karthik NayakJun 8, 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.