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

Re: [PATCH 3/4] for-each-ref: convert to ref-filter

From
Junio C Hamano <gitster@pobox.com>
Date
May 20, 2015, 23:50 UTC
Message-ID
<xmqqvbfmlsfu.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1432127904-21070-3-git-send-email-karthik.188@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
> convert 'for-each-ref' to use the common API provided by 'ref-filter'.
Start a sentence with capital?

More importantly, the above is misleading, as if you invented a new ref-filter API and made for-each-ref build on that new infrastructure.

This series is in a form that is very unfriendly to reviewers. The previous step did not introduce any callers to ref-filter, so for the purpose of review, it needs to be read together with this step anyway.

And when reading these patches that way, what this half is really doing is to move the code from for-each-ref to ref-filter, but it does unnecessary or unrelated renaming of a handful of symbols. It makes it even harder to compare and contrast the original code that was in the original for-each-ref and moved code that ends up in the new ref-filter. Don't do that.

You would probably want to organize them in these two steps instead:
 * Rename symbols as necessary while all the code is still in
   for-each-ref. Do not create ref-filter in this step. Justify it
   along the lines of "some symbol names were fine while they were
   file scope static implementation detail of for-each-ref, but we
   will make the machinery available from other commands by moving
   it to a library-ish place, so rename X to foo_X to clarify that
   this is about foo (which is now necessary as it is not specific
   to for-each-ref"...
 * If you want to do other tweaks like wrapping refs & num_refs into
   a single structure, do so while the code is still in
   for-each-ref.  You can do that in the same patch as the above
   (i.e. it's just part of preparatory step for a move).
 * Create ref-filter by _moving_ code from for-each-ref. Do not
   touch these moved lines in this step. You would need to add
   include at the top of for-each-ref and ref-filter, of course.
Show 5 quoted lines
> -	for_each_rawref(grab_single_ref, &cbdata);
> -	refs = cbdata.grab_array;
> -	num_refs = cbdata.grab_cnt;
> +	refs.name_patterns = argv;
> +	for_each_rawref(ref_filter_add, &refs);

I think ref_filter_add() may be misnamed as a public API function. grab_single_ref() was OK only because it was an implementation dtail, but if you are making it public, the name should make it clear that it is meant to be used as a for_each_*ref() callback function. Otherwise people may be tempted to add random parameter to it in the future, but the signature of that function is dictated by for_each_*ref() API.

Previous: Karthik NayakNext: karthik nayak
Message 22 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.