# `Git.Commands.Merge`
[🔗](https://github.com/joshrotenberg/git_wrapper_ex/blob/main/lib/git/commands/merge.ex#L1)

Implements the `Git.Command` behaviour for `git merge`.

Supports merging a branch, the `--no-ff` flag to force a merge commit, and
`--abort` to abort an in-progress merge.

# `t`

```elixir
@type t() :: %Git.Commands.Merge{
  abort: boolean(),
  branch: String.t() | nil,
  no_ff: boolean(),
  squash: boolean()
}
```

# `args`

```elixir
@spec args(t()) :: [String.t()]
```

Returns the argument list for `git merge`.

- When `:abort` is `true`, builds `git merge --abort`.
- Otherwise builds `git merge [--no-ff] <branch>`.

## Examples

    iex> Git.Commands.Merge.args(%Git.Commands.Merge{branch: "feature"})
    ["merge", "feature"]

    iex> Git.Commands.Merge.args(%Git.Commands.Merge{branch: "feature", no_ff: true})
    ["merge", "--no-ff", "feature"]

    iex> Git.Commands.Merge.args(%Git.Commands.Merge{abort: true})
    ["merge", "--abort"]

    iex> Git.Commands.Merge.args(%Git.Commands.Merge{branch: "feature", squash: true})
    ["merge", "--squash", "feature"]

# `parse_output`

```elixir
@spec parse_output(String.t(), non_neg_integer()) ::
  {:ok, Git.MergeResult.t()}
  | {:ok, :done}
  | {:error, {String.t(), non_neg_integer()}}
```

Parses the output of `git merge`.

For `--abort` operations (exit code 0), returns `{:ok, :done}`.
For merge operations (exit code 0), parses into a `Git.MergeResult` struct.
On failure, returns `{:error, {stdout, exit_code}}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
