GitRepo.mergeMsg

Retrieve the merge message for this repository.

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.

Note: Remember to remove the merge message file after you create the commit, by calling removeMergeMsg. Use mergeMsgExists if you want to explicitly check for the existence of the merge message file.

Note: This function returns an empty string when the message file is empty, but returns null if the message file cannot be found.

struct GitRepo
@property
string
mergeMsg
(
)

Examples

1 // write a merge message file and verify it can be read
2 auto repo = initRepo(_userRepo, OpenBare.yes);
3 scope(exit) rmdirRecurse(_userRepo);
4 
5 string msgPath = buildPath(repo.path, "MERGE_MSG");
6 
7 string msg = "merge this";
8 std.file.write(msgPath, msg);
9 assert(repo.mergeMsg == msg);
10 
11 msg = "";
12 std.file.write(msgPath, msg);
13 assert(repo.mergeMsg !is null && repo.mergeMsg == msg);

Meta