Skip to content

Commit 02eb171

Browse files
authored
Merge pull request libgit2#5731 from KOLANICH-libs/owner_accessor
patch: add owner accessor
2 parents 2ad1525 + 58d757b commit 02eb171

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

include/git2/patch.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ GIT_BEGIN_DECL
2828
*/
2929
typedef struct git_patch git_patch;
3030

31+
/**
32+
* Get the repository associated with this patch. May be NULL.
33+
*
34+
* @param patch the patch
35+
* @return a pointer to the repository
36+
*/
37+
GIT_EXTERN(git_repository *) git_patch_owner(const git_patch *patch);
38+
3139
/**
3240
* Return a patch for an entry in the diff list.
3341
*

src/patch.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ int git_patch_get_line_in_hunk(
204204
return 0;
205205
}
206206

207+
git_repository *git_patch_owner(const git_patch *patch)
208+
{
209+
return patch->repo;
210+
}
211+
207212
int git_patch_from_diff(git_patch **out, git_diff *diff, size_t idx)
208213
{
209214
GIT_ASSERT_ARG(out);

0 commit comments

Comments
 (0)