diff options
| author | Edward Thomson <ethomson@microsoft.com> | 2014-04-08 17:18:47 -0700 |
|---|---|---|
| committer | Edward Thomson <ethomson@github.com> | 2016-05-26 11:36:11 -0500 |
| commit | d34f68261ef95b517944d4fa89ee13b4a68d3cb4 (patch) | |
| tree | 686b92a0e7174b891bd4e5a61e480acfc1be5002 /include/git2 | |
| parent | 7cb904ba4443c22ff5396769b7d07a7f329c0102 (diff) | |
| download | libgit2-d34f68261ef95b517944d4fa89ee13b4a68d3cb4.tar.gz | |
Patch parsing from patch files
Diffstat (limited to 'include/git2')
| -rw-r--r-- | include/git2/diff.h | 14 | ||||
| -rw-r--r-- | include/git2/patch.h | 13 |
2 files changed, 21 insertions, 6 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h index c35701a46..f3bb337b7 100644 --- a/include/git2/diff.h +++ b/include/git2/diff.h @@ -448,6 +448,8 @@ typedef int (*git_diff_file_cb)( float progress, void *payload); +#define GIT_DIFF_HUNK_HEADER_SIZE 128 + /** * When producing a binary diff, the binary data returned will be * either the deflated full ("literal") contents of the file, or @@ -499,12 +501,12 @@ typedef int(*git_diff_binary_cb)( * Structure describing a hunk of a diff. */ typedef struct { - 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 */ + 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[GIT_DIFF_HUNK_HEADER_SIZE]; /** Header text, NUL-byte terminated */ } git_diff_hunk; /** diff --git a/include/git2/patch.h b/include/git2/patch.h index 790cb74fc..aa8729c9c 100644 --- a/include/git2/patch.h +++ b/include/git2/patch.h @@ -267,6 +267,19 @@ GIT_EXTERN(int) git_patch_to_buf( git_buf *out, git_patch *patch); +/** + * Create a patch from the contents of a patch file. + * + * @param out The patch to be created + * @param patchfile The contents of a patch file + * @param patchfile_len The length of the patch file + * @return 0 on success, <0 on failure. + */ +GIT_EXTERN(int) git_patch_from_patchfile( + git_patch **out, + const char *patchfile, + size_t patchfile_len); + GIT_END_DECL /**@}*/ |
