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 <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
d1cbe1e6d8
commit
aabc5617cd
2
cache.h
2
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,
|
int df_name_compare(const char *name1, size_t len1, int mode1,
|
||||||
const char *name2, size_t len2, int mode2);
|
const char *name2, size_t len2, int mode2);
|
||||||
int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
|
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 */
|
/* add */
|
||||||
/*
|
/*
|
||||||
|
13
read-cache.c
13
read-cache.c
@ -567,7 +567,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)
|
|||||||
return 0;
|
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;
|
int cmp;
|
||||||
|
|
||||||
@ -582,6 +583,16 @@ int cache_name_stage_compare(const char *name1, int len1, int stage1, const char
|
|||||||
return 0;
|
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,
|
static int index_name_stage_pos(struct index_state *istate,
|
||||||
const char *name, int namelen,
|
const char *name, int namelen,
|
||||||
int stage,
|
int stage,
|
||||||
|
10
tree.c
10
tree.c
@ -94,16 +94,6 @@ int read_tree(struct repository *r,
|
|||||||
return ret;
|
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 tree *lookup_tree(struct repository *r, const struct object_id *oid)
|
||||||
{
|
{
|
||||||
struct object *obj = lookup_object(r, oid);
|
struct object *obj = lookup_object(r, oid);
|
||||||
|
1
tree.h
1
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. */
|
/* Parses and returns the tree in the given ent, chasing tags and commits. */
|
||||||
struct tree *parse_tree_indirect(const struct object_id *oid);
|
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
|
#define READ_TREE_RECURSIVE 1
|
||||||
typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, void *);
|
typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, void *);
|
||||||
|
Loading…
Reference in New Issue
Block a user