Implements the Git.Command behaviour for git merge-file.
git merge-file runs a scripted three-way file merge. It incorporates the
changes that lead from base to other into current, writing the merged
result (with conflict markers where the two sides overlap) back into the
current file. Nothing in the repository index or history is touched: this
operates purely on the three files on disk.
The process exit code carries the number of conflicts as a signal: 0 for a
clean merge, or the conflict count (clamped by git to 127). Values of 128
and above indicate a real error (bad option, missing file), not a conflict
count. parse_output/2 distinguishes the two.
Summary
Types
Functions
Returns the argument list for git merge-file.
Examples
iex> Git.Commands.MergeFile.args(%Git.Commands.MergeFile{current: "a", base: "o", other: "b"})
["merge-file", "a", "o", "b"]
iex> Git.Commands.MergeFile.args(%Git.Commands.MergeFile{current: "a", base: "o", other: "b", ours: true})
["merge-file", "--ours", "a", "o", "b"]
iex> Git.Commands.MergeFile.args(%Git.Commands.MergeFile{current: "a", base: "o", other: "b", labels: ["mine", "orig", "theirs"]})
["merge-file", "-L", "mine", "-L", "orig", "-L", "theirs", "a", "o", "b"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, non_neg_integer()} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git merge-file.
The exit code is the number of conflicts. A clean merge returns {:ok, 0};
a merge that left conflict markers in the current file returns
{:ok, count} with count > 0. Exit codes of 128 or greater are real
errors and return {:error, {stdout, exit_code}}.