libgit2

git_tree_create_updated

Version:

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.

Signature

int git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseline, size_t nupdates, const git_tree_update *updates);

Parameters

In
out

id of the new tree

In
repo

the repository in which to create the tree, must be the same as for baseline

In
baseline

the tree to base these changes on

size_t
In
nupdates

the number of elements in the update list

In
updates

the list of updates to perform

Returns

int

0 or an error code

Versions