vendor/libgit2/src/patch_parse.c in rugged-0.25.0b7 vs vendor/libgit2/src/patch_parse.c in rugged-0.25.0b8

- old
+ new

@@ -5,10 +5,11 @@ * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/patch.h" #include "patch.h" #include "patch_parse.h" +#include "diff_parse.h" #include "path.h" #define parse_err(...) \ ( giterr_set(GITERR_PATCH, __VA_ARGS__), -1 ) @@ -1021,9 +1022,23 @@ } 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;