diff mbox series

[v5,18/18] tree-entry.h API: rename tree_entry_extract() to tree_entry_extract_mode()

Message ID patch-18.19-e961a0e8b5b-20210331T190531Z-avarab@gmail.com (mailing list archive)
State New, archived
Headers show
Series tree-walk.h: slimmed down | expand

Commit Message

Ævar Arnfjörð Bjarmason March 31, 2021, 7:09 p.m. UTC
As with the recent split of the get_tree_entry() function, rename the
tree_entry_extract() function to *_mode() in preparation for adding
other variants of it.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 fsck.c        | 2 +-
 match-trees.c | 4 ++--
 tree-diff.c   | 4 ++--
 tree-walk.c   | 2 +-
 tree-walk.h   | 8 ++++----
 5 files changed, 10 insertions(+), 10 deletions(-)

Comments

Junio C Hamano April 1, 2021, 8:49 p.m. UTC | #1
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> As with the recent split of the get_tree_entry() function, rename the
> tree_entry_extract() function to *_mode() in preparation for adding
> other variants of it.

I do not see a value in this approach over optionally accepting
NULL, for the same reason why splitting get_tree_entry() does not
show a value over optionally accepting NULL.  At least at this point
in the series.

There might be future changes that would benefit from having
separate functions, but I do not see how they cannot work with an
updated version of existing helper functions that optionally can
take NULL as "don't care" when they can with a different function
with one fewer parameter.
diff mbox series

Patch

diff --git a/fsck.c b/fsck.c
index e3030f3b358..b1d802cc30a 100644
--- a/fsck.c
+++ b/fsck.c
@@ -673,7 +673,7 @@  static int fsck_tree(const struct object_id *oid,
 		const char *name, *backslash;
 		const struct object_id *oid;
 
-		oid = tree_entry_extract(&desc, &name, &mode);
+		oid = tree_entry_extract_mode(&desc, &name, &mode);
 
 		has_null_sha1 |= is_null_oid(oid);
 		has_full_path |= !!strchr(name, '/');
diff --git a/match-trees.c b/match-trees.c
index 240922f7080..23ff89be2b2 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -146,7 +146,7 @@  static void match_trees(const struct object_id *hash1,
 		unsigned short mode;
 		int score;
 
-		elem = tree_entry_extract(&one, &path, &mode);
+		elem = tree_entry_extract_mode(&one, &path, &mode);
 		if (!S_ISDIR(mode))
 			goto next;
 		score = score_trees(elem, hash2);
@@ -202,7 +202,7 @@  static int splice_tree(const struct object_id *oid1, const char *prefix,
 		unsigned short mode;
 		int len = tree_entry_len(&desc.entry);
 
-		tree_entry_extract(&desc, &name, &mode);
+		tree_entry_extract_mode(&desc, &name, &mode);
 		if (len == toplen &&
 		    !memcmp(name, prefix, toplen)) {
 			if (!S_ISDIR(mode))
diff --git a/tree-diff.c b/tree-diff.c
index b7a76cc2620..31f8a9331b1 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -196,7 +196,7 @@  static struct combine_diff_path *emit_path(struct combine_diff_path *p,
 
 	if (t) {
 		/* path present in resulting tree */
-		oid = tree_entry_extract(t, &path, &mode);
+		oid = tree_entry_extract_mode(t, &path, &mode);
 		pathlen = tree_entry_len(&t->entry);
 		isdir = S_ISDIR(mode);
 	} else {
@@ -207,7 +207,7 @@  static struct combine_diff_path *emit_path(struct combine_diff_path *p,
 		 * 1) all modes for tp[i]=tp[imin] should be the same wrt
 		 *    S_ISDIR, thanks to base_name_compare().
 		 */
-		tree_entry_extract(&tp[imin], &path, &mode);
+		tree_entry_extract_mode(&tp[imin], &path, &mode);
 		pathlen = tree_entry_len(&tp[imin].entry);
 
 		isdir = S_ISDIR(mode);
diff --git a/tree-walk.c b/tree-walk.c
index d0dc0c35318..533cb6a26b4 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -567,7 +567,7 @@  static int find_tree_entry(struct repository *r, struct tree_desc *t,
 		struct object_id oid;
 		int entrylen, cmp;
 
-		oidcpy(&oid, tree_entry_extract(t, &entry, mode));
+		oidcpy(&oid, tree_entry_extract_mode(t, &entry, mode));
 		entrylen = tree_entry_len(&t->entry);
 		update_tree_entry(t);
 		if (entrylen > namelen)
diff --git a/tree-walk.h b/tree-walk.h
index 52eb0d6b5b3..ec1d6927205 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -44,11 +44,11 @@  struct tree_desc {
  * "struct name_entry" you'd like. You always need a pointer to an
  * appropriate variable to fill in (NULL won't do!):
  *
- * tree_entry_extract(): const char *path, unsigned int mode
+ * tree_entry_extract_mode(): const char *path, unsigned int mode
  */
-static inline const struct object_id *tree_entry_extract(struct tree_desc *desc,
-							 const char **pathp,
-							 unsigned short *modep)
+static inline const struct object_id *tree_entry_extract_mode(struct tree_desc *desc,
+							      const char **pathp,
+							      unsigned short *modep)
 {
 	*pathp = desc->entry.path;
 	*modep = desc->entry.mode;