mirror of
https://git.proxmox.com/git/libgit2
synced 2026-01-21 22:41:27 +00:00
tree: Naming conventions
This commit is contained in:
parent
eb27088462
commit
9d0011fd83
@ -143,7 +143,7 @@ GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry);
|
||||
* @param entry a tree entry
|
||||
* @return GIT_SUCCESS or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_tree_entry_2object(git_object **object_out, git_repository *repo, const git_tree_entry *entry);
|
||||
GIT_EXTERN(int) git_tree_entry_to_object(git_object **object_out, git_repository *repo, const git_tree_entry *entry);
|
||||
|
||||
/**
|
||||
* Write a tree to the ODB from the index file
|
||||
|
||||
@ -939,7 +939,7 @@ static int read_tree_cb(const char *root, git_tree_entry *tentry, void *data)
|
||||
git_index_entry *entry = NULL;
|
||||
git_buf path = GIT_BUF_INIT;
|
||||
|
||||
if (entry_is_tree(tentry))
|
||||
if (git_tree_entry__is_tree(tentry))
|
||||
return 0;
|
||||
|
||||
if (git_buf_joinpath(&path, root, tentry->filename) < 0)
|
||||
|
||||
@ -178,7 +178,7 @@ static tree_iterator_frame *tree_iterator__alloc_frame(
|
||||
|
||||
if (start && *start) {
|
||||
tf->start = start;
|
||||
tf->index = git_tree_entry_prefix_position(tree, start);
|
||||
tf->index = git_tree__prefix_position(tree, start);
|
||||
}
|
||||
|
||||
return tf;
|
||||
@ -192,7 +192,7 @@ static int tree_iterator__expand_tree(tree_iterator *ti)
|
||||
tree_iterator_frame *tf;
|
||||
char *relpath;
|
||||
|
||||
while (te != NULL && entry_is_tree(te)) {
|
||||
while (te != NULL && git_tree_entry__is_tree(te)) {
|
||||
if (git_buf_joinpath(&ti->path, ti->path.ptr, te->filename) < 0)
|
||||
return -1;
|
||||
|
||||
@ -252,7 +252,7 @@ static int tree_iterator__advance(
|
||||
git_buf_rtruncate_at_char(&ti->path, '/');
|
||||
}
|
||||
|
||||
if (te && entry_is_tree(te))
|
||||
if (te && git_tree_entry__is_tree(te))
|
||||
error = tree_iterator__expand_tree(ti);
|
||||
|
||||
if (!error)
|
||||
@ -288,7 +288,7 @@ static int tree_iterator__reset(git_iterator *self)
|
||||
|
||||
if (ti->stack)
|
||||
ti->stack->index =
|
||||
git_tree_entry_prefix_position(ti->stack->tree, ti->base.start);
|
||||
git_tree__prefix_position(ti->stack->tree, ti->base.start);
|
||||
|
||||
git_buf_clear(&ti->path);
|
||||
|
||||
|
||||
13
src/tree.c
13
src/tree.c
@ -31,8 +31,8 @@ static int entry_sort_cmp(const void *a, const void *b)
|
||||
const git_tree_entry *entry_b = (const git_tree_entry *)(b);
|
||||
|
||||
return git_path_cmp(
|
||||
entry_a->filename, entry_a->filename_len, entry_is_tree(entry_a),
|
||||
entry_b->filename, entry_b->filename_len, entry_is_tree(entry_b));
|
||||
entry_a->filename, entry_a->filename_len, git_tree_entry__is_tree(entry_a),
|
||||
entry_b->filename, entry_b->filename_len, git_tree_entry__is_tree(entry_b));
|
||||
}
|
||||
|
||||
|
||||
@ -170,7 +170,10 @@ git_otype git_tree_entry_type(const git_tree_entry *entry)
|
||||
return GIT_OBJ_BLOB;
|
||||
}
|
||||
|
||||
int git_tree_entry_2object(git_object **object_out, git_repository *repo, const git_tree_entry *entry)
|
||||
int git_tree_entry_to_object(
|
||||
git_object **object_out,
|
||||
git_repository *repo,
|
||||
const git_tree_entry *entry)
|
||||
{
|
||||
assert(entry && object_out);
|
||||
return git_object_lookup(object_out, repo, &entry->oid, GIT_OBJ_ANY);
|
||||
@ -195,7 +198,7 @@ const git_tree_entry *git_tree_entry_byindex(git_tree *tree, unsigned int idx)
|
||||
return git_vector_get(&tree->entries, idx);
|
||||
}
|
||||
|
||||
int git_tree_entry_prefix_position(git_tree *tree, const char *path)
|
||||
int git_tree__prefix_position(git_tree *tree, const char *path)
|
||||
{
|
||||
git_vector *entries = &tree->entries;
|
||||
struct tree_key_search ksearch;
|
||||
@ -730,7 +733,7 @@ static int tree_walk_post(
|
||||
if (callback(path->ptr, entry, payload) < 0)
|
||||
continue;
|
||||
|
||||
if (entry_is_tree(entry)) {
|
||||
if (git_tree_entry__is_tree(entry)) {
|
||||
git_tree *subtree;
|
||||
size_t path_len = git_buf_len(path);
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ struct git_treebuilder {
|
||||
};
|
||||
|
||||
|
||||
GIT_INLINE(unsigned int) entry_is_tree(const struct git_tree_entry *e)
|
||||
GIT_INLINE(bool) git_tree_entry__is_tree(const struct git_tree_entry *e)
|
||||
{
|
||||
return (S_ISDIR(e->attr) && !S_ISGITLINK(e->attr));
|
||||
}
|
||||
@ -45,7 +45,7 @@ int git_tree__parse(git_tree *tree, git_odb_object *obj);
|
||||
* @param prefix the beginning of a path to find in the tree.
|
||||
* @return index of the first item at or after the given prefix.
|
||||
*/
|
||||
int git_tree_entry_prefix_position(git_tree *tree, const char *prefix);
|
||||
int git_tree__prefix_position(git_tree *tree, const char *prefix);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -67,7 +67,7 @@ void test_object_tree_read__two(void)
|
||||
|
||||
cl_assert_equal_s(git_tree_entry_name(entry), "README");
|
||||
|
||||
cl_git_pass(git_tree_entry_2object(&obj, g_repo, entry));
|
||||
cl_git_pass(git_tree_entry_to_object(&obj, g_repo, entry));
|
||||
cl_assert(obj != NULL);
|
||||
|
||||
git_object_free(obj);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user