libgit2

git_repository_message

Version:

Retrieve git's prepared message

Operations such as git revert/cherry-pick/merge with the -n option stop just short of creating a commit with the changes and save their prepared message in .git/MERGE_MSG so the next git-commit execution can present it to the user for them to amend if they wish.

Use this function to get the contents of this file. Don't forget to remove the file after you create the commit.

If the repository message exists and there are no errors reading it, this returns the bytes needed to store the message in memory (i.e. message file size plus one terminating NUL byte). That value is returned even if out is NULL or len is shorter than the necessary size.

The out buffer will always be NUL terminated, even if truncation occurs.

Signature

int git_repository_message(char *out, size_t len, git_repository *repo);

Parameters

char *
In
out

Buffer to write data into or NULL to just read required size

size_t
In
len

Length of out buffer in bytes

In
repo

Repository to read prepared message from

Returns

int

GIT_ENOTFOUND if no message exists, other value < 0 for other errors, or total bytes in message (may be > len) on success

Versions