Functions
2.1 Annotated Commit
2.2 Blame
2.3 Blob
2.4 Branch
2.5 Buffer
2.6 Checkout
2.7 Cherrypick
2.8 Clone
2.9 Commit
2.10 Config
2.11 Credentials
2.12 Describe
2.13 Diff
2.14 Fetch
2.15 Filter
2.16 Errors
2.17 Graph
2.18 Ignore
2.19 Index
2.20 Indexer
2.21 Global
2.22 Merge
2.23 Message
2.24 Note
2.25 Object
2.26 Object Database
2.27 Oid
2.28 Oid Array
2.29 Packbuilder
2.30 Patch
2.31 Pathspec
2.32 Proxy
2.33 Push
2.34 Rebase
2.35 Refdb
2.36 Reference
2.37 Reflog
2.38 Refspec
2.39 Remote
2.40 Repository
2.41 Reset
2.42 Revert
2.43 Revparse
2.44 Revwalk
2.45 Signature
2.46 Stash
2.47 Status
2.48 Strarray
2.49 Submodule
2.50 Tag
2.51 Tree
2.52 Treebuilder
On this page:
git_  treebuilder_  clear
git_  treebuilder_  entrycount
git_  treebuilder_  filter
git_  treebuilder_  free
git_  treebuilder_  get
git_  treebuilder_  insert
git_  treebuilder_  new
git_  treebuilder_  remove
git_  treebuilder_  write
7.7

2.52 Treebuilder

 (require libgit2/include/treebuilder) package: libgit2

procedure

(git_treebuilder_clear bld)  void?

  bld : treebuilder?
Clear all the entires in the builder

procedure

(git_treebuilder_entrycount bld)  integer?

  bld : treebuilder?
Get the number of entries listed in a treebuilder

procedure

(git_treebuilder_filter bld filter payload)  integer?

  bld : treebuilder?
  filter : git_treebuilder_filter_cb
  payload : bytes?
Selectively remove entries in the tree

The filter callback will be called for each entry in the tree with a pointer to the entry and the provided payload; if the callback returns non-zero, the entry will be filtered (removed from the builder).

procedure

(git_treebuilder_free bld)  void?

  bld : treebuilder?
Free a tree builder

This will clear all the entries and free to builder. Failing to free the builder after you’re done using it will result in a memory leak

procedure

(git_treebuilder_get bld filename)  tree_entry?

  bld : treebuilder?
  filename : string?
Get an entry from the builder from its filename

The returned entry is owned by the builder and should not be freed manually.

procedure

(git_treebuilder_insert bld    
  filename    
  id    
  filemode)  tree_entry?
  bld : treebuilder?
  filename : string?
  id : oid?
  filemode : git_filemode_t
Add or update an entry to the builder

Insert a new entry for filename in the builder with the given attributes.

If an entry named filename already exists, its attributes will be updated with the given ones.

The optional pointer out can be used to retrieve a pointer to the newly created/updated entry. Pass NULL if you do not need it. The pointer may not be valid past the next operation in this builder. Duplicate the entry if you want to keep it.

No attempt is being made to ensure that the provided oid points to an existing git object in the object database, nor that the attributes make sense regarding the type of the pointed at object.

procedure

(git_treebuilder_new repo source)  treebuilder?

  repo : repository?
  source : tree?
Create a new tree builder.

The tree builder can be used to create or modify trees in memory and write them as tree objects to the database.

If the source parameter is not NULL, the tree builder will be initialized with the entries of the given tree.

If the source parameter is NULL, the tree builder will start with no entries and will have to be filled manually.

procedure

(git_treebuilder_remove bld filename)  integer?

  bld : treebuilder?
  filename : string?
Remove an entry from the builder by its filename

procedure

(git_treebuilder_write id bld)  integer?

  id : oid?
  bld : treebuilder?
Write the contents of the tree builder as a tree object

The tree builder will be written to the given repo, and its identifying SHA1 hash will be stored in the id pointer.