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

Re: [PATCH v1 1/1] list-objects.c: traverse_trees_and_blobs: rename and tree-wide

From
Jeff King <peff@peff.net>
Date
Aug 11, 2021, 19:11 UTC
Message-ID
<YRQg+IJ3cxb3Vk+c@coredump.intra.peff.net>
In-Reply-To
<xmqqsfzf980v.fsf@gitster.g>
On Wed, Aug 11, 2021 at 11:00:00AM -0700, Junio C Hamano wrote:
Show 20 quoted lines
> > Function `traverse_trees_and_blobs` not only works on trees and blobs,
> > but also on tags, the function name is somewhat misleading. This commit
> > rename it to `traverse_trees_and_blobs_and_tags`.
> 
> This looks pretty much "Meh" to me.
> 
> The current name might mislead people that we are limited to only
> two types, but I doubt the risk of misleading is worth reducing with
> such an overly long name.  The original is long enough X-<.
> 
> When we introduced it at 91904f56 (list-objects.c: factor out
> traverse_trees_and_blobs, 2017-11-02), we may have been better to
> call it traverse_non_commits().  The idea of traverse_commit_list(),
> which is its primary caller, is for its main loop to iterate over
> commits and process them one by one in each iteration, and process
> objects of other types discovered therein by calling this function
> once per each commit [*1*].
> 
> s/trees_and_blobs/non_commits/ will result in a name that is much
> shorter and to the point, I think.
FWIW, I was about reply and suggest the exact same name. :)

As something internal to list-objects.c, I don't think it matters all that much either way. The name "traverse_commit_list()" is IMHO more likely to confuse. It is public within the project, and of course traverses any type of object. So "traverse_objects()" or something may be more accurate.

OTOH I do not find it all that confusing, and it may not be worth the disruption to the code base.

-Peff
Previous: Junio C HamanoNext: Teng Long
Message 4 of 11 in “traverse_trees_and_blobs: rename and tree-wide”
  1. 0/1 traverse_trees_and_blobs: rename and tree-wideTeng Long, Aug 11, 2021
  2. 1/1 list-objects.c: traverse_trees_and_blobs: rename and tree-wideTeng Long, Aug 11, 2021
  3. Junio C HamanoAug 11, 2021
  4. Jeff KingAug 11, 2021
  5. Teng LongAug 12, 2021
  6. Teng LongAug 12, 2021
  7. 0/1 list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits"Teng Long, Aug 12, 2021
  8. 1/1 list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits"Teng Long, Aug 12, 2021
  9. 0/1 list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits"Teng Long, Aug 12, 2021
  10. 1/1 list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits"Teng Long, Aug 12, 2021
  11. Jeff KingAug 12, 2021

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.