On this page:
git_  tree_  create_  updated
git_  tree_  dup
git_  tree_  entry_  byid
git_  tree_  entry_  byindex
git_  tree_  entry_  byname
git_  tree_  entry_  bypath
git_  tree_  entry_  cmp
git_  tree_  entry_  dup
git_  tree_  entry_  filemode
git_  tree_  entry_  filemode_  raw
git_  tree_  entry_  free
git_  tree_  entry_  id
git_  tree_  entry_  name
git_  tree_  entry_  to_  object
git_  tree_  entry_  type
git_  tree_  entrycount
git_  tree_  free
git_  tree_  id
git_  tree_  lookup
git_  tree_  lookup_  prefix
git_  tree_  owner
git_  tree_  walk
8.12

48 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?
Create a tree based on another one with the specified modifications

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.

procedure

(git_tree_dup source)  tree?

  source : tree?
Create an in-memory copy of a tree. The copy must be explicitly free’d or it will leak.

procedure

(git_tree_entry_byid tree id)  tree_entry?

  tree : tree?
  id : oid?
Lookup a tree entry by SHA value.

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

(git_tree_entry_byindex tree idx)  tree_entry?

  tree : tree?
  idx : integer?
Lookup a tree entry by its position in the tree

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

(git_tree_entry_byname tree filename)  tree_entry?

  tree : tree?
  filename : string?
Lookup a tree entry by its filename

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

(git_tree_entry_bypath root path)  tree_entry?

  root : tree?
  path : string?
Retrieve a tree entry contained in a tree or in any of its subtrees, given its relative path.

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?
Compare two tree entries

procedure

(git_tree_entry_dup source)  tree_entry?

  source : tree_entry?
Duplicate a 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().

procedure

(git_tree_entry_filemode entry)  git_filemode_t

  entry : tree_entry?
Get the UNIX file attributes of a tree entry

procedure

(git_tree_entry_filemode_raw entry)  git_filemode_t

  entry : tree_entry?
Get the raw UNIX file attributes of a tree entry

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?
Free a user-owned 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_id entry)  oid?

  entry : tree_entry?
Get the id of the object pointed by the entry

procedure

(git_tree_entry_name entry)  string?

  entry : tree_entry?
Get the filename of a tree entry

procedure

(git_tree_entry_to_object repo entry)  object?

  repo : repository?
  entry : tree_entry?
Convert a tree entry to the git_object it points to.

You must call git_object_free() on the object when you are done with it.

procedure

(git_tree_entry_type entry)  git_otype

  entry : tree_entry?
Get the type of the object pointed by the entry

procedure

(git_tree_entrycount tree)  integer?

  tree : tree?
Get the number of entries listed in a tree

procedure

(git_tree_free tree)  void?

  tree : tree?
Close an open 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

(git_tree_id tree)  oid?

  tree : tree?
Get the id of a tree.

procedure

(git_tree_lookup repo id)  tree?

  repo : repository?
  id : oid?
Lookup a tree object from the repository.

procedure

(git_tree_lookup_prefix repo id len)  tree?

  repo : repository?
  id : oid?
  len : integer?
Lookup a tree object from the repository, given a prefix of its identifier (short id).

procedure

(git_tree_owner tree)  repository?

  tree : tree?
Get the repository that contains the tree.

procedure

(git_tree_walk tree mode callback payload)  integer?

  tree : tree?
  mode : git_treewalk_mode
  callback : git_treewalk_cb
  payload : bytes?
Traverse the entries in a tree and its subtrees in post or pre order.

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.