From 58d757b1d36f5744e969852a54d34990a44c6389 Mon Sep 17 00:00:00 2001 From: Jason Haslam Date: Mon, 14 Nov 2016 16:52:33 -0700 Subject: patch: add owner accessor --- include/git2/patch.h | 8 ++++++++ src/patch.c | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/include/git2/patch.h b/include/git2/patch.h index b177798e6..fde9659e7 100644 --- a/include/git2/patch.h +++ b/include/git2/patch.h @@ -28,6 +28,14 @@ GIT_BEGIN_DECL */ typedef struct git_patch git_patch; +/** + * Get the repository associated with this patch. May be NULL. + * + * @param patch the patch + * @return a pointer to the repository + */ +GIT_EXTERN(git_repository *) git_patch_owner(const git_patch *patch); + /** * Return a patch for an entry in the diff list. * diff --git a/src/patch.c b/src/patch.c index 8f8bd7a08..f02c928de 100644 --- a/src/patch.c +++ b/src/patch.c @@ -204,6 +204,11 @@ int git_patch_get_line_in_hunk( return 0; } +git_repository *git_patch_owner(const git_patch *patch) +{ + return patch->repo; +} + int git_patch_from_diff(git_patch **out, git_diff *diff, size_t idx) { GIT_ASSERT_ARG(out); -- cgit v1.2.1