git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Teng Long <dyroneteng@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v1 1/1] list-objects.c: traverse_trees_and_blobs: rename and tree-wide
Date: Wed, 11 Aug 2021 11:00:00 -0700	[thread overview]
Message-ID: <xmqqsfzf980v.fsf@gitster.g> (raw)
In-Reply-To: <b6f3b15253d44c9250f59b53aafe471edda9f4b7.1628670288.git.dyroneteng@gmail.com> (Teng Long's message of "Wed, 11 Aug 2021 17:07:14 +0800")

Teng Long <dyroneteng@gmail.com> writes:

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

Sorry but I do not quite get the " and tree-wide" part of the title.

> 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.


[Footnote]

*1* The call to it at the end is meant to sweep anything
leftover---we will not discover any tag while in the main loop of
the caller that iterates over commits (as they cannot contain any
tag in there).



> Signed-off-by: Teng Long <dyroneteng@gmail.com>
> ---
>  list-objects.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/list-objects.c b/list-objects.c
> index 7f404677d5..37a37fc502 100644
> --- a/list-objects.c
> +++ b/list-objects.c
> @@ -334,7 +334,7 @@ static void add_pending_tree(struct rev_info *revs, struct tree *tree)
>  	add_pending_object(revs, &tree->object, "");
>  }
>  
> -static void traverse_trees_and_blobs(struct traversal_context *ctx,
> +static void traverse_trees_and_blobs_and_tags(struct traversal_context *ctx,
>  				     struct strbuf *base)
>  {
>  	int i;
> @@ -407,9 +407,9 @@ static void do_traverse(struct traversal_context *ctx)
>  			 * needs a reallocation for each commit. Can we pass the
>  			 * tree directory without allocation churn?
>  			 */
> -			traverse_trees_and_blobs(ctx, &csp);
> +			traverse_trees_and_blobs_and_tags(ctx, &csp);
>  	}
> -	traverse_trees_and_blobs(ctx, &csp);
> +	traverse_trees_and_blobs_and_tags(ctx, &csp);
>  	strbuf_release(&csp);
>  }

  reply	other threads:[~2021-08-11 18:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11  9:07 [PATCH v1 0/1] traverse_trees_and_blobs: rename and tree-wide Teng Long
2021-08-11  9:07 ` [PATCH v1 1/1] list-objects.c: " Teng Long
2021-08-11 18:00   ` Junio C Hamano [this message]
2021-08-11 19:11     ` Jeff King
2021-08-12  8:05       ` Teng Long
2021-08-12  7:54     ` Teng Long
2021-08-12  8:47 ` [PATCH v2 0/1] list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits" Teng Long
2021-08-12  8:47   ` [PATCH v2 1/1] " Teng Long
2021-08-12  8:59   ` [PATCH v3 0/1] " Teng Long
2021-08-12  8:59     ` [PATCH v3 1/1] " Teng Long
2021-08-12 19:24       ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqsfzf980v.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=dyroneteng@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).