summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/diff.h31
-rw-r--r--include/git2/patch.h17
2 files changed, 23 insertions, 25 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h
index f1572cbd5..ed9f71355 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -385,10 +385,12 @@ typedef int (*git_diff_file_cb)(
*/
typedef struct git_diff_hunk git_diff_hunk;
struct git_diff_hunk {
- int old_start; /** Starting line number in old_file */
- int old_lines; /** Number of lines in old_file */
- int new_start; /** Starting line number in new_file */
- int new_lines; /** Number of lines in new_file */
+ int old_start; /** Starting line number in old_file */
+ int old_lines; /** Number of lines in old_file */
+ int new_start; /** Starting line number in new_file */
+ int new_lines; /** Number of lines in new_file */
+ size_t header_len; /** Number of bytes in header text */
+ char header[128]; /** Header text, NUL-byte terminated */
};
/**
@@ -397,8 +399,6 @@ struct git_diff_hunk {
typedef int (*git_diff_hunk_cb)(
const git_diff_delta *delta,
const git_diff_hunk *hunk,
- const char *header,
- size_t header_len,
void *payload);
/**
@@ -429,6 +429,19 @@ typedef enum {
} git_diff_line_t;
/**
+ * Structure describing a line (or data span) of a diff.
+ */
+typedef struct git_diff_line git_diff_line;
+struct git_diff_line {
+ char origin; /** A git_diff_line_t value */
+ int old_lineno; /** Line number in old file or -1 for added line */
+ int new_lineno; /** Line number in new file or -1 for deleted line */
+ int num_lines; /** Number of newline characters in content */
+ size_t content_len; /** Number of bytes of data */
+ const char *content; /** Pointer to diff text, not NUL-byte terminated */
+};
+
+/**
* When iterating over a diff, callback that will be made per text diff
* line. In this context, the provided range will be NULL.
*
@@ -438,10 +451,8 @@ typedef enum {
*/
typedef int (*git_diff_line_cb)(
const git_diff_delta *delta, /** delta that contains this data */
- const git_diff_hunk *hunk, /** range of lines containing this data */
- char line_origin, /** git_diff_t value from above */
- const char *content, /** diff data - not NUL terminated */
- size_t content_len, /** number of bytes of diff data */
+ const git_diff_hunk *hunk, /** hunk containing this data */
+ const git_diff_line *line, /** line data */
void *payload); /** user reference data */
/**
diff --git a/include/git2/patch.h b/include/git2/patch.h
index 9836245de..6a6ad92d7 100644
--- a/include/git2/patch.h
+++ b/include/git2/patch.h
@@ -150,9 +150,6 @@ GIT_EXTERN(int) git_patch_line_stats(
* as NULL if you don't care about that particular piece of information.
*
* @param out Output pointer to git_diff_hunk of hunk
- * @param header Output pointer to header string for hunk. Unlike the
- * content pointer for each line, this will be NUL-terminated
- * @param header_len Output value of characters in header string
* @param lines_in_hunk Output count of total lines in this hunk
* @param patch Input pointer to patch object
* @param hunk_idx Input index of hunk to get information about
@@ -160,8 +157,6 @@ GIT_EXTERN(int) git_patch_line_stats(
*/
GIT_EXTERN(int) git_patch_get_hunk(
const git_diff_hunk **out,
- const char **header,
- size_t *header_len,
size_t *lines_in_hunk,
git_patch *patch,
size_t hunk_idx);
@@ -185,22 +180,14 @@ GIT_EXTERN(int) git_patch_num_lines_in_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.
*
- * @param line_origin A GIT_DIFF_LINE constant from above
- * @param content Pointer to content of diff line, not NUL-terminated
- * @param content_len Number of characters in content
- * @param old_lineno Line number in old file or -1 if line is added
- * @param new_lineno Line number in new file or -1 if line is deleted
+ * @param out The git_diff_line data for this line
* @param patch The patch to look in
* @param hunk_idx The index of the hunk
* @param line_of_hunk The index of the line in the hunk
* @return 0 on success, <0 on failure
*/
GIT_EXTERN(int) git_patch_get_line_in_hunk(
- char *line_origin,
- const char **content,
- size_t *content_len,
- int *old_lineno,
- int *new_lineno,
+ const git_diff_line **out,
git_patch *patch,
size_t hunk_idx,
size_t line_of_hunk);