libgit2

git_diff_patch_get_hunk

Version:

Get the information about a hunk in a patch

Given a patch and a hunk index into the patch, this returns detailed information about that hunk. Any of the output pointers can be passed as NULL if you don't care about that particular piece of information.

Signature

int git_diff_patch_get_hunk(const git_diff_range **range, const char **header, size_t *header_len, size_t *lines_in_hunk, git_diff_patch *patch, size_t hunk_idx);

Parameters

In
range

Output pointer to git_diff_range of hunk

const char **
In
header

Output pointer to header string for hunk. Unlike the content pointer for each line, this will be NUL-terminated

size_t *
In
header_len

Output value of characters in header string

size_t *
In
lines_in_hunk

Output count of total lines in this hunk

In
patch

Input pointer to patch object

size_t
In
hunk_idx

Input index of hunk to get information about

Returns

int

0 on success, GIT_ENOTFOUND if hunk_idx out of range, < 0 on error

Versions