Commit 58d757b1d36f5744e969852a54d34990a44c6389

Jason Haslam 2016-11-14T16:52:33

patch: add owner accessor

diff --git a/include/git2/patch.h b/include/git2/patch.h
index b177798..fde9659 100644
--- a/include/git2/patch.h
+++ b/include/git2/patch.h
@@ -29,6 +29,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.
  *
  * The `git_patch` is a newly created object contains the text diffs
diff --git a/src/patch.c b/src/patch.c
index 8f8bd7a..f02c928 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);