libgit2

git_diff_tree_to_workdir

Version:

Create a diff between a tree and the working directory.

The tree you provide will be used for the "old_file" side of the delta, and the working directory will be used for the "new_file" side.

This is not the same as git diff <treeish> or `git diff-index

<treeish>. Those commands use information from the index, whereas this function strictly returns the differences between the tree and the files in the working directory, regardless of the state of the index. Use git_diff_tree_to_workdir_with_index` to emulate those commands.

To see difference between this and git_diff_tree_to_workdir_with_index, consider the example of a staged file deletion where the file has then been put back into the working dir and further modified. The tree-to-workdir diff for that file is 'modified', but git diff would show status 'deleted' since there is a staged delete.

Signature

int git_diff_tree_to_workdir(git_diff **diff, git_repository *repo, git_tree *old_tree, const git_diff_options *opts);

Parameters

In
diff

A pointer to a git_diff pointer that will be allocated.

In
repo

The repository containing the tree.

In
old_tree

A git_tree object to diff from, or NULL for empty tree.

In
opts

Structure with options to influence diff or NULL for defaults.

Returns

int

0 or an error code.

Versions