libgit2

git_diff_patch_get_line_in_hunk

Version:

Get data about a line in a hunk of a patch.

Given a patch, a hunk index, and a line index in the hunk, this will return a lot of details about that line. If you pass a hunk index larger than the number of hunks or a line index larger than the number of lines in the hunk, this will return -1.

Signature

int git_diff_patch_get_line_in_hunk(char *line_origin, const char **content, size_t *content_len, int *old_lineno, int *new_lineno, git_diff_patch *patch, size_t hunk_idx, size_t line_of_hunk);

Parameters

char *
In
line_origin

A GIT_DIFF_LINE constant from above

const char **
In
content

Pointer to content of diff line, not NUL-terminated

size_t *
In
content_len

Number of characters in content

int *
In
old_lineno

Line number in old file or -1 if line is added

int *
In
new_lineno

Line number in new file or -1 if line is deleted

In
patch

The patch to look in

size_t
In
hunk_idx

The index of the hunk

size_t
In
line_of_hunk

The index of the line in the hunk

Returns

int

0 on success, < 0 on failure

Versions