summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-02-01 10:07:00 +0000
committerGitHub <noreply@github.com>2021-02-01 10:07:00 +0000
commit02eb1711283473c1f2e8dba6005467ef8e275855 (patch)
treeb3faf9c8ee1be81b57a94317b9c11e22b0d56e94
parent2ad1525099e430827d901e52cd0dd580ce1b7a8f (diff)
parent58d757b1d36f5744e969852a54d34990a44c6389 (diff)
downloadlibgit2-02eb1711283473c1f2e8dba6005467ef8e275855.tar.gz
Merge pull request #5731 from KOLANICH-libs/owner_accessor
patch: add owner accessor
-rw-r--r--include/git2/patch.h8
-rw-r--r--src/patch.c5
2 files changed, 13 insertions, 0 deletions
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
@@ -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 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);