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

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

Finds commits in the current branch (or `head`) that have not yet been
applied to `upstream`. Each commit is marked with `+` (not applied) or
`-` (already applied upstream, i.e. an equivalent patch exists).

# `t`

```elixir
@type t() :: %Git.Commands.Cherry{
  head: String.t() | nil,
  limit: String.t() | nil,
  upstream: String.t() | nil,
  verbose: boolean()
}
```

# `args`

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

Builds the argument list for `git cherry`.

## Examples

    iex> Git.Commands.Cherry.args(%Git.Commands.Cherry{upstream: "main"})
    ["cherry", "main"]

    iex> Git.Commands.Cherry.args(%Git.Commands.Cherry{upstream: "main", verbose: true})
    ["cherry", "-v", "main"]

    iex> Git.Commands.Cherry.args(%Git.Commands.Cherry{upstream: "main", head: "feature"})
    ["cherry", "main", "feature"]

    iex> Git.Commands.Cherry.args(%Git.Commands.Cherry{upstream: "main", head: "feature", limit: "v1.0"})
    ["cherry", "main", "feature", "v1.0"]

# `parse_output`

```elixir
@spec parse_output(String.t(), non_neg_integer()) ::
  {:ok, [Git.CherryEntry.t()]} | {:error, {String.t(), non_neg_integer()}}
```

Parses the output of `git cherry`.

Returns `{:ok, [%Git.CherryEntry{}]}` on success (exit code 0).
An empty output produces an empty list.

---

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