libgit2/libgit2 — pull request #1592 by ethomson (2013-05-17 19:47:28+00:00)
Title: merge setup

This is the next pull request to add merge functionality: setup the various merge metadata files when you start a merge. My goal is to not necessarily expose this publicly. Thus this is sort of an odd PR that doesn't add any functionality. However it seemed like a logical chunk of code to bring over.

This PR writes the following files:

- `ORIG_HEAD`, simply the current oid of `HEAD` for when you begin a merge.
- `MERGE_HEAD`, simply the oids of each "head" being merged in to the current branch
- `MERGE_MODE`, any flags to the merge, for example "no-ff" for no-fast-forward.
- `MERGE_MSG`, a description of the items being merged in, in a really ridiculous format.

I went for strict compatibility with core git on the `MERGE_MSG` file, despite the fact that it probably isn't necessarily . I don't think that anybody should expect the `MERGE_MSG` file to follow a particular format, however we do *try* to parse that file and decorate commit messages based on the contents.

This introduces a new opaque type (`git_merge_head`) which is intended to be used as the input to merge. This provides data about the commit being merged in, as well as where it comes from (in a textual description.) This textual data is used for writing both the `MERGE_MSG` file, and is expected to be used later in the merge process when writing conflicts. (The diff3 file contains the branch name / description in the markers, in some conflicts, files are written with the branch name appended.)