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