diff options
Diffstat (limited to 'src/patch_parse.c')
-rw-r--r-- | src/patch_parse.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/patch_parse.c b/src/patch_parse.c index 82d2d3e2e..44bcf8f75 100644 --- a/src/patch_parse.c +++ b/src/patch_parse.c @@ -7,6 +7,7 @@ #include "git2/patch.h" #include "patch.h" #include "patch_parse.h" +#include "diff_parse.h" #include "path.h" #define parse_err(...) \ @@ -1025,6 +1026,20 @@ void git_patch_parse_ctx_free(git_patch_parse_ctx *ctx) GIT_REFCOUNT_DEC(ctx, patch_parse_ctx_free); } +int git_patch_parsed_from_diff(git_patch **out, git_diff *d, size_t idx) +{ + git_diff_parsed *diff = (git_diff_parsed *)d; + git_patch *p; + + if ((p = git_vector_get(&diff->patches, idx)) == NULL) + return -1; + + GIT_REFCOUNT_INC(p); + *out = p; + + return 0; +} + static void patch_parsed__free(git_patch *p) { git_patch_parsed *patch = (git_patch_parsed *)p; |