# `Git.Diff`
[🔗](https://github.com/joshrotenberg/git_wrapper_ex/blob/main/lib/git/diff.ex#L1)

Parsed representation of `git diff` output.

When used with `--stat`, contains a list of per-file stats. The `raw` field
always holds the full stdout from git, regardless of whether `--stat` was used.

# `t`

```elixir
@type t() :: %Git.Diff{
  files: [Git.DiffFile.t()],
  raw: String.t(),
  total_deletions: non_neg_integer(),
  total_insertions: non_neg_integer()
}
```

# `parse`

```elixir
@spec parse(String.t()) :: t()
```

Parses the output of `git diff --stat` into a `Git.Diff` struct.

The stat format looks like:

    lib/foo.ex | 10 ++++------
    lib/bar.ex |  5 +++++
    2 files changed, 7 insertions(+), 5 deletions(-)

Binary files appear as:

    image.png | Bin 0 -> 1234 bytes

The summary line is used for `total_insertions` and `total_deletions`.
If the output is a full patch (no `--stat`), the `files` list will be empty
and `raw` will contain the patch text.

## Examples

    iex> output = " foo.ex | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n"
    iex> diff = Git.Diff.parse(output)
    iex> diff.total_insertions
    1

---

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