21#ifndef KIGIT_MERGE_BLOB_UTILS_H
22#define KIGIT_MERGE_BLOB_UTILS_H
27#include <git2/sys/merge.h>
87template <
typename DRIVER>
89 unsigned int* aModeOut, git_buf* aMergedOut )
91 if( !aSrc || !aPathOut || !aModeOut || !aMergedOut )
94 DRIVER driver(
const_cast<git_merge_driver_source*
>( aSrc ), aMergedOut );
95 int rc = driver.Merge();
97 if( rc == 0 || rc == GIT_EMERGECONFLICT )
99 if(
const git_index_entry* oursEntry = git_merge_driver_source_ours( aSrc ) )
101 *aPathOut = oursEntry->path;
102 *aModeOut = oursEntry->mode;
int WriteToGitBuf(git_buf *aBuf, const std::string &aContent)
Allocate a libgit2-owned buffer big enough for aContent and copy the bytes plus a trailing NUL.
bool TryTrivialMerge(const MERGE_BLOBS &aBlobs, git_buf *aResult, int *aRc)
Resolve the trivial 3-way cases (identical sides, or one side unchanged from the ancestor).
int LoadMergeBlobs(const git_merge_driver_source *aSource, MERGE_BLOBS &aBlobs)
Look up the ancestor/ours/theirs blobs of a merge-driver source and decode them into aBlobs.
int ApplyMergeDriver(const git_merge_driver_source *aSrc, const char **aPathOut, unsigned int *aModeOut, git_buf *aMergedOut)
Shared libgit2 merge-driver apply callback shim.
std::string BlobToString(git_blob *aBlob)
Copy a libgit2 blob's raw bytes into a std::string.
Decoded ancestor/ours/theirs blob contents for a 3-way merge driver.
std::string ancestor
Empty when there is no common ancestor.