diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2015-11-21 12:27:03 -0500 |
|---|---|---|
| committer | Edward Thomson <ethomson@github.com> | 2016-05-26 13:01:08 -0500 |
| commit | 440e3bae10a4758d5de8d7b8699bf4c412c1a163 (patch) | |
| tree | 281ea92c4e39070bab916650ef06129ce876afc0 /src | |
| parent | 00e63b36202be18b1dd1690049f8cbb755132f1b (diff) | |
| download | libgit2-440e3bae10a4758d5de8d7b8699bf4c412c1a163.tar.gz | |
patch: `git_patch_from_patchfile` -> `git_patch_from_buffer`
Diffstat (limited to 'src')
| -rw-r--r-- | src/patch.h | 26 | ||||
| -rw-r--r-- | src/patch_parse.c | 2 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/patch.h b/src/patch.h index b818c5cbe..28fe766da 100644 --- a/src/patch.h +++ b/src/patch.h @@ -50,6 +50,32 @@ extern int git_patch_line_stats( size_t *total_dels, const git_patch *patch); +/** Options for parsing patch files. */ +typedef struct { + /** + * The length of the prefix (in path segments) for the filenames. + * This prefix will be removed when looking for files. The default is 1. + */ + uint32_t prefix_len; +} git_patch_options; + +#define GIT_PATCH_OPTIONS_INIT { 1 } + +/** + * Create a patch for a single file from the contents of a patch buffer. + * + * @param out The patch to be created + * @param contents The contents of a patch file + * @param contents_len The length of the patch file + * @param opts The git_patch_options + * @return 0 on success, <0 on failure. + */ +extern int git_patch_from_buffer( + git_patch **out, + const char *contents, + size_t contents_len, + git_patch_options *opts); + extern void git_patch_free(git_patch *patch); #endif diff --git a/src/patch_parse.c b/src/patch_parse.c index 46ecae73f..9421bb39b 100644 --- a/src/patch_parse.c +++ b/src/patch_parse.c @@ -956,7 +956,7 @@ static void patch_parsed__free(git_patch *p) git__free(patch); } -int git_patch_from_patchfile( +int git_patch_from_buffer( git_patch **out, const char *content, size_t content_len, |
