All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>, Elijah Newren <newren@gmail.com>
Subject: [PATCH v2] tree-walk.h: fix incorrect API comment
Date: Fri, 02 May 2025 19:19:11 +0000	[thread overview]
Message-ID: <pull.1912.v2.git.1746213551473.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1912.git.1745941503913.gitgitgadget@gmail.com>

From: Elijah Newren <newren@gmail.com>

When commit 50ddb089ff68 (tree-walk.c: remove the_repo from
get_tree_entry(), 2019-06-27) added an extra parameter to
get_tree_entry(), it did not fix the ordering comment about the meaning
of the parameters.  Rather than just changing "third"->"fourth" and
"fourth"->"fifth", give the paramemters meaningful names (or actually,
just take the existing names from the get_tree_entry() definition in the
tree-walk.c file) and while at it, tweak the rest of the description to
incorporate the other parameter names as well.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
    tree-walk.h: fix incorrect API comment
    
    Changes since v1:
    
     * Updated the documentation to explain that oid and mode are output
       parameters, and slightly tweaked the description further.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1912%2Fnewren%2Ffix-tree-walk-api-comment-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1912/newren/fix-tree-walk-api-comment-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1912

Range-diff vs v1:

 1:  6375bc7d351 ! 1:  a47aceb6394 tree-walk.h: fix incorrect API comment
     @@ Commit message
          of the parameters.  Rather than just changing "third"->"fourth" and
          "fourth"->"fifth", give the paramemters meaningful names (or actually,
          just take the existing names from the get_tree_entry() definition in the
     -    tree-walk.c file) and strike the comment.
     +    tree-walk.c file) and while at it, tweak the rest of the description to
     +    incorporate the other parameter names as well.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
       ## tree-walk.h ##
      @@ tree-walk.h: struct traverse_info {
     + };
       
       /**
     -  * Find an entry in a tree given a pathname and the sha1 of a tree to
     +- * Find an entry in a tree given a pathname and the sha1 of a tree to
      - * search. Returns 0 if the entry is found and -1 otherwise. The third
      - * and fourth parameters are set to the entry's sha1 and mode respectively.
     -+ * search. Returns 0 if the entry is found and -1 otherwise.
     -  */
     +- */
      -int get_tree_entry(struct repository *, const struct object_id *, const char *, struct object_id *, unsigned short *);
     ++ * Walk trees starting with "tree_oid" to find the entry for "name", and
     ++ * return the the object name and the mode of the found entry via the
     ++ * "oid" and "mode" parameters.  Return 0 if the entry is found, and -1
     ++ * otherwise.
     ++ */
      +int get_tree_entry(struct repository *repo, const struct object_id *tree_oid,
      +		   const char *name, struct object_id *oid,
      +		   unsigned short *mode);


 tree-walk.h | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tree-walk.h b/tree-walk.h
index aaea689f9ae..29a55328bd9 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -176,11 +176,14 @@ struct traverse_info {
 };
 
 /**
- * Find an entry in a tree given a pathname and the sha1 of a tree to
- * search. Returns 0 if the entry is found and -1 otherwise. The third
- * and fourth parameters are set to the entry's sha1 and mode respectively.
- */
-int get_tree_entry(struct repository *, const struct object_id *, const char *, struct object_id *, unsigned short *);
+ * Walk trees starting with "tree_oid" to find the entry for "name", and
+ * return the the object name and the mode of the found entry via the
+ * "oid" and "mode" parameters.  Return 0 if the entry is found, and -1
+ * otherwise.
+ */
+int get_tree_entry(struct repository *repo, const struct object_id *tree_oid,
+		   const char *name, struct object_id *oid,
+		   unsigned short *mode);
 
 /**
  * Generate the full pathname of a tree entry based from the root of the

base-commit: f65182a99e545d2f2bc22e6c1c2da192133b16a3
-- 
gitgitgadget

      parent reply	other threads:[~2025-05-02 19:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-29 15:45 [PATCH] tree-walk.h: fix incorrect API comment Elijah Newren via GitGitGadget
2025-04-29 17:01 ` Junio C Hamano
2025-05-02 19:19 ` Elijah Newren via GitGitGadget [this message]

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=pull.1912.v2.git.1746213551473.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.