Skip to content

Commit aabc561

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d1cbe1e commit aabc561

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ int base_name_compare(const char *name1, size_t len1, int mode1,
562562
int df_name_compare(const char *name1, size_t len1, int mode1,
563563
const char *name2, size_t len2, int mode2);
564564
int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
565-
int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
565+
int cmp_cache_name_compare(const void *a_, const void *b_);
566566

567567
/* add */
568568
/*

read-cache.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)
567567
return 0;
568568
}
569569

570-
int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)
570+
static int cache_name_stage_compare(const char *name1, int len1, int stage1,
571+
const char *name2, int len2, int stage2)
571572
{
572573
int cmp;
573574

@@ -582,6 +583,16 @@ int cache_name_stage_compare(const char *name1, int len1, int stage1, const char
582583
return 0;
583584
}
584585

586+
int cmp_cache_name_compare(const void *a_, const void *b_)
587+
{
588+
const struct cache_entry *ce1, *ce2;
589+
590+
ce1 = *((const struct cache_entry **)a_);
591+
ce2 = *((const struct cache_entry **)b_);
592+
return cache_name_stage_compare(ce1->name, ce1->ce_namelen, ce_stage(ce1),
593+
ce2->name, ce2->ce_namelen, ce_stage(ce2));
594+
}
595+
585596
static int index_name_stage_pos(struct index_state *istate,
586597
const char *name, int namelen,
587598
int stage,

tree.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,6 @@ int read_tree(struct repository *r,
9494
return ret;
9595
}
9696

97-
int cmp_cache_name_compare(const void *a_, const void *b_)
98-
{
99-
const struct cache_entry *ce1, *ce2;
100-
101-
ce1 = *((const struct cache_entry **)a_);
102-
ce2 = *((const struct cache_entry **)b_);
103-
return cache_name_stage_compare(ce1->name, ce1->ce_namelen, ce_stage(ce1),
104-
ce2->name, ce2->ce_namelen, ce_stage(ce2));
105-
}
106-
10797
struct tree *lookup_tree(struct repository *r, const struct object_id *oid)
10898
{
10999
struct object *obj = lookup_object(r, oid);

tree.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ void free_tree_buffer(struct tree *tree);
2929
/* Parses and returns the tree in the given ent, chasing tags and commits. */
3030
struct tree *parse_tree_indirect(const struct object_id *oid);
3131

32-
int cmp_cache_name_compare(const void *a_, const void *b_);
3332

3433
#define READ_TREE_RECURSIVE 1
3534
typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, void *);

0 commit comments

Comments
 (0)