libgit2

git_diff_from_buffer

Version:

Read the contents of a git patch file into a git_diff object.

The diff object produced is similar to the one that would be produced if you actually produced it computationally by comparing two trees, however there may be subtle differences. For example, a patch file likely contains abbreviated object IDs, so the object IDs in a git_diff_delta produced by this function will also be abbreviated.

This function will only read patch files created by a git implementation, it will not read unified diffs produced by the diff program, nor any other types of patch files.

Signature

int git_diff_from_buffer(git_diff **out, const char *content, size_t content_len);

Parameters

In
out

A pointer to a git_diff pointer that will be allocated.

const char *
In
content

The contents of a patch file

size_t
In
content_len

The length of the patch file contents

Returns

int

0 or an error code

Versions