2.51 Tree
(require libgit2/include/tree) | package: libgit2 |
procedure
(git_tree_create_updated out repo baseline nupdates updates) → integer? out : oid? repo : repository? baseline : tree? nupdates : integer? updates : tree_update?
Given the baseline perform the changes described in the list of updates and create a new tree.
This function is optimized for common file/directory addition, removal and replacement in trees. It is much more efficient than reading the tree into a git_index and modifying that, but in exchange it is not as flexible.
Deleting and adding the same entry is undefined behaviour, changing a tree to a blob or viceversa is not supported.
This returns a git_tree_entry that is owned by the git_tree. You don’t have to free it, but you must not use it after the git_tree is released.
Warning: this must examine every entry in the tree, so it is not fast.
procedure
tree : tree? idx : integer?
This returns a git_tree_entry that is owned by the git_tree. You don’t have to free it, but you must not use it after the git_tree is released.
procedure
tree : tree? filename : string?
This returns a git_tree_entry that is owned by the git_tree. You don’t have to free it, but you must not use it after the git_tree is released.
procedure
root : tree? path : string?
Unlike the other lookup functions, the returned tree entry is owned by the user and must be freed explicitly with git_tree_entry_free().
procedure
(git_tree_entry_cmp e1 e2) → integer?
e1 : tree_entry? e2 : tree_entry?
Create a copy of a tree entry. The returned copy is owned by the user, and must be freed explicitly with git_tree_entry_free().
This function does not perform any normalization and is only useful if you need to be able to recreate the original tree object.
procedure
(git_tree_entry_free entry) → void?
entry : tree_entry?
IMPORTANT: This function is only needed for tree entries owned by the user, such as the ones returned by git_tree_entry_dup() or git_tree_entry_bypath().
procedure
(git_tree_entry_name entry) → string?
entry : tree_entry?
procedure
(git_tree_entry_to_object repo entry) → object?
repo : repository? entry : tree_entry?
You must call git_object_free() on the object when you are done with it.
procedure
(git_tree_entrycount tree) → integer?
tree : tree?
procedure
(git_tree_free tree) → void?
tree : tree?
You can no longer use the git_tree pointer after this call.
IMPORTANT: You MUST call this method when you stop using a tree to release memory. Failure to do so will cause a memory leak.
procedure
repo : repository? id : oid? len : integer?
procedure
(git_tree_walk tree mode callback payload) → integer?
tree : tree? mode : git_treewalk_mode callback : git_treewalk_cb payload : bytes?
The entries will be traversed in the specified order, children subtrees will be automatically loaded as required, and the callback will be called once per entry with the current (relative) root for the entry and the entry data itself.
If the callback returns a positive value, the passed entry will be skipped on the traversal (in pre mode). A negative value stops the walk.