]> git.ipfire.org Git - thirdparty/git.git/commitdiff
cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c
authorElijah Newren <newren@gmail.com>
Sat, 22 Apr 2023 20:17:21 +0000 (20:17 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Apr 2023 19:47:32 +0000 (12:47 -0700)
Since cmp_cache_name_compare() was comparing cache_entry structs, it
was associated with the cache rather than with trees.  Move the
function.  As a side effect, we can make cache_name_stage_compare()
static as well.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
read-cache.c
tree.c
tree.h

diff --git a/cache.h b/cache.h
index 7a46f300d9b033f5e8df84f8b5b70770833a9c7c..502e4c0b11add890969a2234af51420f3bb5668c 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -562,7 +562,7 @@ int base_name_compare(const char *name1, size_t len1, int mode1,
 int df_name_compare(const char *name1, size_t len1, int mode1,
                    const char *name2, size_t len2, int mode2);
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
+int cmp_cache_name_compare(const void *a_, const void *b_);
 
 /* add */
 /*
index 206c003e558d63089664c950ed9cccc95ab344a0..8f00da4bf7acf86e006fa0b0b6527abd3fecb897 100644 (file)
@@ -567,7 +567,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)
        return 0;
 }
 
-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)
+static int cache_name_stage_compare(const char *name1, int len1, int stage1,
+                                   const char *name2, int len2, int stage2)
 {
        int cmp;
 
@@ -582,6 +583,16 @@ int cache_name_stage_compare(const char *name1, int len1, int stage1, const char
        return 0;
 }
 
+int cmp_cache_name_compare(const void *a_, const void *b_)
+{
+       const struct cache_entry *ce1, *ce2;
+
+       ce1 = *((const struct cache_entry **)a_);
+       ce2 = *((const struct cache_entry **)b_);
+       return cache_name_stage_compare(ce1->name, ce1->ce_namelen, ce_stage(ce1),
+                                 ce2->name, ce2->ce_namelen, ce_stage(ce2));
+}
+
 static int index_name_stage_pos(struct index_state *istate,
                                const char *name, int namelen,
                                int stage,
diff --git a/tree.c b/tree.c
index e9d51ce2e00c00bf2ae7e2bee8daf69cb809620a..896b7f4776bf95a1fa9caf32db3d0e156362c820 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -94,16 +94,6 @@ int read_tree(struct repository *r,
        return ret;
 }
 
-int cmp_cache_name_compare(const void *a_, const void *b_)
-{
-       const struct cache_entry *ce1, *ce2;
-
-       ce1 = *((const struct cache_entry **)a_);
-       ce2 = *((const struct cache_entry **)b_);
-       return cache_name_stage_compare(ce1->name, ce1->ce_namelen, ce_stage(ce1),
-                                 ce2->name, ce2->ce_namelen, ce_stage(ce2));
-}
-
 struct tree *lookup_tree(struct repository *r, const struct object_id *oid)
 {
        struct object *obj = lookup_object(r, oid);
diff --git a/tree.h b/tree.h
index 0499ad01aa7ee62ff02afa7bd8bcb6acd44ca144..8e3c6d441cc8b7965c471900deece76aa7f2f73b 100644 (file)
--- a/tree.h
+++ b/tree.h
@@ -29,7 +29,6 @@ void free_tree_buffer(struct tree *tree);
 /* Parses and returns the tree in the given ent, chasing tags and commits. */
 struct tree *parse_tree_indirect(const struct object_id *oid);
 
-int cmp_cache_name_compare(const void *a_, const void *b_);
 
 #define READ_TREE_RECURSIVE 1
 typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, void *);