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

A single record from git's raw diff format, as produced by
`git diff-tree`, `git diff-index`, and `git diff-files` with `--raw -z`.

Each record describes one changed path:

    :<old_mode> <new_mode> <old_sha> <new_sha> <status>\0<path>\0

`status` is a single letter for the common cases:

  * `"A"` - added
  * `"D"` - deleted
  * `"M"` - modified
  * `"T"` - type changed (e.g. file to symlink)

For renames (`R`) and copies (`C`) git appends a similarity score to the
status letter (e.g. `"R100"`) and emits a SECOND NUL-terminated path. In that
case `status` holds the raw token including the score, and `path` holds the
destination (new) path. The source path is not retained in this struct.

`old_sha` / `new_sha` are all-zero when the corresponding side does not exist
(for example `old_sha` is zeroed for an added file).

# `t`

```elixir
@type t() :: %Git.DiffRawEntry{
  new_mode: String.t(),
  new_sha: String.t(),
  old_mode: String.t(),
  old_sha: String.t(),
  path: String.t(),
  status: String.t()
}
```

# `parse`

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

Parses NUL-delimited raw diff output into a list of `Git.DiffRawEntry` structs.

Any leading token that is not a metadata record is skipped. This handles the
bare commit-id header (a SHA followed by NUL) that single-argument
`git diff-tree` emits before its records.

Combined-diff records (merge output prefixed with `::`) do not match the
expected five-field shape and are skipped rather than mis-parsed.

Returns `[]` for empty input.

---

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