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

Implements the `Git.Command` behaviour for `git range-diff`.

Compares two sequences of commits (revision ranges). Supports both
the two-range form (`range1 range2`) and the three-argument form
(`rev1 rev2 rev3`).

# `t`

```elixir
@type t() :: %Git.Commands.RangeDiff{
  creation_factor: non_neg_integer() | nil,
  left_only: boolean(),
  no_dual_color: boolean(),
  no_notes: boolean(),
  no_patch: boolean(),
  range1: String.t() | nil,
  range2: String.t() | nil,
  rev1: String.t() | nil,
  rev2: String.t() | nil,
  rev3: String.t() | nil,
  right_only: boolean(),
  stat: boolean()
}
```

# `args`

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

Returns the argument list for `git range-diff`.

Builds `git range-diff [flags] range1 range2` when `range1` and `range2`
are set, or `git range-diff [flags] rev1 rev2 rev3` when the three-argument
form is used.

## Examples

    iex> Git.Commands.RangeDiff.args(%Git.Commands.RangeDiff{range1: "main..topic-v1", range2: "main..topic-v2"})
    ["range-diff", "main..topic-v1", "main..topic-v2"]

    iex> Git.Commands.RangeDiff.args(%Git.Commands.RangeDiff{rev1: "main", rev2: "topic-v1", rev3: "topic-v2"})
    ["range-diff", "main", "topic-v1", "topic-v2"]

    iex> Git.Commands.RangeDiff.args(%Git.Commands.RangeDiff{range1: "main..v1", range2: "main..v2", stat: true})
    ["range-diff", "--stat", "main..v1", "main..v2"]

    iex> Git.Commands.RangeDiff.args(%Git.Commands.RangeDiff{range1: "a..b", range2: "a..c", creation_factor: 50})
    ["range-diff", "--creation-factor=50", "a..b", "a..c"]

# `parse_output`

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

Parses the output of `git range-diff`.

On success (exit code 0), returns `{:ok, raw_output}` as a string.
Range-diff output contains color codes and varying formats, so returning
the raw string is the practical choice.
On failure, returns `{:error, {stdout, exit_code}}`.

---

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