From aabc5617cdfb29ccf98048b0d99cae2a811df51f Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Sat, 22 Apr 2023 20:17:21 +0000 Subject: cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c 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 Signed-off-by: Junio C Hamano --- read-cache.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'read-cache.c') diff --git a/read-cache.c b/read-cache.c index 206c003e55..8f00da4bf7 100644 --- a/read-cache.c +++ b/read-cache.c @@ -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, -- cgit v1.2.3