git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v1 0/1] traverse_trees_and_blobs: rename and tree-wide
@ 2021-08-11  9:07 Teng Long
  2021-08-11  9:07 ` [PATCH v1 1/1] list-objects.c: " 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
  0 siblings, 2 replies; 11+ messages in thread
From: Teng Long @ 2021-08-11  9:07 UTC (permalink / raw)
  To: dyroneteng; +Cc: git

Teng Long (1):
  list-objects.c: traverse_trees_and_blobs: rename and tree-wide

 list-objects.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.32.0.dirty


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v1 1/1] list-objects.c: traverse_trees_and_blobs: rename and tree-wide
  2021-08-11  9:07 [PATCH v1 0/1] traverse_trees_and_blobs: rename and tree-wide Teng Long
@ 2021-08-11  9:07 ` Teng Long
  2021-08-11 18:00   ` Junio C Hamano
  2021-08-12  8:47 ` [PATCH v2 0/1] list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits" Teng Long
  1 sibling, 1 reply; 11+ messages in thread
From: Teng Long @ 2021-08-11  9:07 UTC (permalink / raw)
  To: dyroneteng; +Cc: git

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

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);
 }
 
-- 
2.32.0.dirty


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 1/1] list-objects.c: traverse_trees_and_blobs: rename and tree-wide
  2021-08-11  9:07 ` [PATCH v1 1/1] list-objects.c: " Teng Long
@ 2021-08-11 18:00   ` Junio C Hamano
  2021-08-11 19:11     ` Jeff King
  2021-08-12  7:54     ` Teng Long
  0 siblings, 2 replies; 11+ messages in thread
From: Junio C Hamano @ 2021-08-11 18:00 UTC (permalink / raw)
  To: Teng Long; +Cc: git

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);
>  }

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 1/1] list-objects.c: traverse_trees_and_blobs: rename and tree-wide
  2021-08-11 18:00   ` Junio C Hamano
@ 2021-08-11 19:11     ` Jeff King
  2021-08-12  8:05       ` Teng Long
  2021-08-12  7:54     ` Teng Long
  1 sibling, 1 reply; 11+ messages in thread
From: Jeff King @ 2021-08-11 19:11 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Teng Long, git

On Wed, Aug 11, 2021 at 11:00:00AM -0700, Junio C Hamano wrote:

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 1/1] list-objects.c: traverse_trees_and_blobs: rename and tree-wide
  2021-08-11 18:00   ` Junio C Hamano
  2021-08-11 19:11     ` Jeff King
@ 2021-08-12  7:54     ` Teng Long
  1 sibling, 0 replies; 11+ messages in thread
From: Teng Long @ 2021-08-12  7:54 UTC (permalink / raw)
  To: gitster; +Cc: dyroneteng, git

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

I may have some misunderstandings about "tree-wide".
Sorry, it will be resolved in the next patch.

>>s/trees_and_blobs/non_commits/ will result in a name that is much
>>shorter and to the point, I think.

Agree and thanks for explanation.

Will follow your suggestion in next patch.

I don't know why I didn't think of this naming at the time (*headwalls*).

In fact, I discovered this problem while contributing packfile-uris
related features (thinking about excluding tag objects), and finally
said to myself "So you are here" (although it didn't take so much effort),
So I decide to make this patch.

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

Some doubts.

I think at the object relationship level: tag> commit> tree> blob

The tag is on top because of the annotated tag. So, why the tag is
in `revs->pending` to deal? I understand it should be the opposite?
A commit should pending to a tag, at least equal.

Maybe my understanding is wrong, if so, why this way?

Thank you.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 1/1] list-objects.c: traverse_trees_and_blobs: rename and tree-wide
  2021-08-11 19:11     ` Jeff King
@ 2021-08-12  8:05       ` Teng Long
  0 siblings, 0 replies; 11+ messages in thread
From: Teng Long @ 2021-08-12  8:05 UTC (permalink / raw)
  To: peff; +Cc: dyroneteng, git, gitster

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

On the basis of understanding the relationship between git objects,
`traverse_commit_list` is understandable, for me.

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

Agree.

It’s interesting to read your reply, because of learning a lot of
abbreviations.

Thank you.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 0/1] list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits"
  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-12  8:47 ` Teng Long
  2021-08-12  8:47   ` [PATCH v2 1/1] " Teng Long
  2021-08-12  8:59   ` [PATCH v3 0/1] " Teng Long
  1 sibling, 2 replies; 11+ messages in thread
From: Teng Long @ 2021-08-12  8:47 UTC (permalink / raw)
  To: dyroneteng; +Cc: git, peff

Teng Long (1):
  list-objects.c: rename "traverse_trees_and_blobs" to
    "traverse_non_commits"

 list-objects.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Range-diff against v1:
1:  b6f3b15253 ! 1:  2d19f0901c list-objects.c: traverse_trees_and_blobs: rename and tree-wide
    @@ Metadata
     Author: Teng Long <dyroneteng@gmail.com>
     
      ## Commit message ##
    -    list-objects.c: traverse_trees_and_blobs: rename and tree-wide
    +    list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits"
     
         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`.
    +    rename it to `traverse_non_commits`.
     
         Signed-off-by: Teng Long <dyroneteng@gmail.com>
     
    @@ list-objects.c: static void add_pending_tree(struct rev_info *revs, struct tree
      }
      
     -static void traverse_trees_and_blobs(struct traversal_context *ctx,
    -+static void traverse_trees_and_blobs_and_tags(struct traversal_context *ctx,
    ++static void traverse_non_commits(struct traversal_context *ctx,
      				     struct strbuf *base)
      {
      	int i;
    @@ list-objects.c: static void do_traverse(struct traversal_context *ctx)
      			 * tree directory without allocation churn?
      			 */
     -			traverse_trees_and_blobs(ctx, &csp);
    -+			traverse_trees_and_blobs_and_tags(ctx, &csp);
    ++			traverse_non_commits(ctx, &csp);
      	}
     -	traverse_trees_and_blobs(ctx, &csp);
    -+	traverse_trees_and_blobs_and_tags(ctx, &csp);
    ++	traverse_non_commits(ctx, &csp);
      	strbuf_release(&csp);
      }
      
-- 
2.32.0.1.g4c9ac18d93.dirty


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 1/1] list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits"
  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   ` Teng Long
  2021-08-12  8:59   ` [PATCH v3 0/1] " Teng Long
  1 sibling, 0 replies; 11+ messages in thread
From: Teng Long @ 2021-08-12  8:47 UTC (permalink / raw)
  To: dyroneteng; +Cc: git, peff

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

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..edaf1f5d64 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_non_commits(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_non_commits(ctx, &csp);
 	}
-	traverse_trees_and_blobs(ctx, &csp);
+	traverse_non_commits(ctx, &csp);
 	strbuf_release(&csp);
 }
 
-- 
2.32.0.1.g4c9ac18d93.dirty


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v3 0/1] list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits"
  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   ` Teng Long
  2021-08-12  8:59     ` [PATCH v3 1/1] " Teng Long
  1 sibling, 1 reply; 11+ messages in thread
From: Teng Long @ 2021-08-12  8:59 UTC (permalink / raw)
  To: dyroneteng; +Cc: git, peff

Patch-v3 fix the indent problem in v2.


Teng Long (1):
  list-objects.c: rename "traverse_trees_and_blobs" to
    "traverse_non_commits"

 list-objects.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Range-diff against v2:
1:  2d19f0901c ! 1:  8548aa8bb1 list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits"
    @@ list-objects.c: static void add_pending_tree(struct rev_info *revs, struct tree
      }
      
     -static void traverse_trees_and_blobs(struct traversal_context *ctx,
    +-				     struct strbuf *base)
     +static void traverse_non_commits(struct traversal_context *ctx,
    - 				     struct strbuf *base)
    ++				 struct strbuf *base)
      {
      	int i;
    + 
     @@ list-objects.c: static void do_traverse(struct traversal_context *ctx)
      			 * needs a reallocation for each commit. Can we pass the
      			 * tree directory without allocation churn?
-- 
2.32.0.1.g4c9ac18d93.dirty


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 1/1] list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits"
  2021-08-12  8:59   ` [PATCH v3 0/1] " Teng Long
@ 2021-08-12  8:59     ` Teng Long
  2021-08-12 19:24       ` Jeff King
  0 siblings, 1 reply; 11+ messages in thread
From: Teng Long @ 2021-08-12  8:59 UTC (permalink / raw)
  To: dyroneteng; +Cc: git, peff

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

Signed-off-by: Teng Long <dyroneteng@gmail.com>
---
 list-objects.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/list-objects.c b/list-objects.c
index 7f404677d5..11d97ac380 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -334,8 +334,8 @@ 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,
-				     struct strbuf *base)
+static void traverse_non_commits(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_non_commits(ctx, &csp);
 	}
-	traverse_trees_and_blobs(ctx, &csp);
+	traverse_non_commits(ctx, &csp);
 	strbuf_release(&csp);
 }
 
-- 
2.32.0.1.g4c9ac18d93.dirty


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 1/1] list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits"
  2021-08-12  8:59     ` [PATCH v3 1/1] " Teng Long
@ 2021-08-12 19:24       ` Jeff King
  0 siblings, 0 replies; 11+ messages in thread
From: Jeff King @ 2021-08-12 19:24 UTC (permalink / raw)
  To: Teng Long; +Cc: git

On Thu, Aug 12, 2021 at 04:59:31PM +0800, Teng Long wrote:

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

Thanks, this version looks good to me.

-Peff

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-08-12 19:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).