Commit 9d0011fd by Vicent Martí

tree: Naming conventions

parent eb270884
...@@ -143,7 +143,7 @@ GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry); ...@@ -143,7 +143,7 @@ GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry);
* @param entry a tree entry * @param entry a tree entry
* @return GIT_SUCCESS or an error code * @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 * 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) ...@@ -939,7 +939,7 @@ static int read_tree_cb(const char *root, git_tree_entry *tentry, void *data)
git_index_entry *entry = NULL; git_index_entry *entry = NULL;
git_buf path = GIT_BUF_INIT; git_buf path = GIT_BUF_INIT;
if (entry_is_tree(tentry)) if (git_tree_entry__is_tree(tentry))
return 0; return 0;
if (git_buf_joinpath(&path, root, tentry->filename) < 0) if (git_buf_joinpath(&path, root, tentry->filename) < 0)
......
...@@ -178,7 +178,7 @@ static tree_iterator_frame *tree_iterator__alloc_frame( ...@@ -178,7 +178,7 @@ static tree_iterator_frame *tree_iterator__alloc_frame(
if (start && *start) { if (start && *start) {
tf->start = start; tf->start = start;
tf->index = git_tree_entry_prefix_position(tree, start); tf->index = git_tree__prefix_position(tree, start);
} }
return tf; return tf;
...@@ -192,7 +192,7 @@ static int tree_iterator__expand_tree(tree_iterator *ti) ...@@ -192,7 +192,7 @@ static int tree_iterator__expand_tree(tree_iterator *ti)
tree_iterator_frame *tf; tree_iterator_frame *tf;
char *relpath; 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) if (git_buf_joinpath(&ti->path, ti->path.ptr, te->filename) < 0)
return -1; return -1;
...@@ -252,7 +252,7 @@ static int tree_iterator__advance( ...@@ -252,7 +252,7 @@ static int tree_iterator__advance(
git_buf_rtruncate_at_char(&ti->path, '/'); 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); error = tree_iterator__expand_tree(ti);
if (!error) if (!error)
...@@ -288,7 +288,7 @@ static int tree_iterator__reset(git_iterator *self) ...@@ -288,7 +288,7 @@ static int tree_iterator__reset(git_iterator *self)
if (ti->stack) if (ti->stack)
ti->stack->index = 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); git_buf_clear(&ti->path);
......
...@@ -31,8 +31,8 @@ static int entry_sort_cmp(const void *a, const void *b) ...@@ -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); const git_tree_entry *entry_b = (const git_tree_entry *)(b);
return git_path_cmp( return git_path_cmp(
entry_a->filename, entry_a->filename_len, entry_is_tree(entry_a), entry_a->filename, entry_a->filename_len, git_tree_entry__is_tree(entry_a),
entry_b->filename, entry_b->filename_len, entry_is_tree(entry_b)); 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) ...@@ -170,7 +170,10 @@ git_otype git_tree_entry_type(const git_tree_entry *entry)
return GIT_OBJ_BLOB; 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); assert(entry && object_out);
return git_object_lookup(object_out, repo, &entry->oid, GIT_OBJ_ANY); 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) ...@@ -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); 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; git_vector *entries = &tree->entries;
struct tree_key_search ksearch; struct tree_key_search ksearch;
...@@ -730,7 +733,7 @@ static int tree_walk_post( ...@@ -730,7 +733,7 @@ static int tree_walk_post(
if (callback(path->ptr, entry, payload) < 0) if (callback(path->ptr, entry, payload) < 0)
continue; continue;
if (entry_is_tree(entry)) { if (git_tree_entry__is_tree(entry)) {
git_tree *subtree; git_tree *subtree;
size_t path_len = git_buf_len(path); size_t path_len = git_buf_len(path);
......
...@@ -30,7 +30,7 @@ struct git_treebuilder { ...@@ -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)); return (S_ISDIR(e->attr) && !S_ISGITLINK(e->attr));
} }
...@@ -45,7 +45,7 @@ int git_tree__parse(git_tree *tree, git_odb_object *obj); ...@@ -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. * @param prefix the beginning of a path to find in the tree.
* @return index of the first item at or after the given prefix. * @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 #endif
...@@ -67,7 +67,7 @@ void test_object_tree_read__two(void) ...@@ -67,7 +67,7 @@ void test_object_tree_read__two(void)
cl_assert_equal_s(git_tree_entry_name(entry), "README"); 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); cl_assert(obj != NULL);
git_object_free(obj); git_object_free(obj);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment