commit: introduce git_repository_commit_parents

Emulating `git commit` is clunky - identifying your commit's parents is
part of the problem. Provide a helper to give you the parents given the
current repository state.
This commit is contained in:
Edward Thomson
2023-12-22 23:17:29 +00:00
parent 198a1b209a
commit 0572884693
5 changed files with 167 additions and 0 deletions

View File

@@ -541,6 +541,24 @@ typedef int (*git_commit_create_cb)(
const git_commit *parents[],
void *payload);
/** An array of commits returned from the library */
typedef struct git_commitarray {
git_commit **commits;
size_t count;
} git_commitarray;
/**
* Free the commits contained in a commit array. This method should
* be called on `git_commitarray` objects that were provided by the
* library. Not doing so will result in a memory leak.
*
* This does not free the `git_commitarray` itself, since the library
* will never allocate that object directly itself.
*
* @param array The git_commitarray that contains commits to free
*/
GIT_EXTERN(void) git_commitarray_dispose(git_commitarray *array);
/** @} */
GIT_END_DECL
#endif