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

Implements the `Git.Command` behaviour for `git show-ref`.

Lists references in a local repository. Supports filtering by heads or tags,
verifying specific refs, abbreviated hashes, and dereferencing tags.

Uses the process dictionary to communicate the output mode from `args/1`
to `parse_output/2`.

# `t`

```elixir
@type t() :: %Git.Commands.ShowRef{
  abbrev: non_neg_integer() | nil,
  dereference: boolean(),
  exclude_existing: boolean(),
  hash: boolean() | non_neg_integer(),
  heads: boolean(),
  patterns: [String.t()],
  quiet: boolean(),
  tags: boolean(),
  verify: boolean()
}
```

# `args`

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

Returns the argument list for `git show-ref`.

## Examples

    iex> Git.Commands.ShowRef.args(%Git.Commands.ShowRef{})
    ["show-ref"]

    iex> Git.Commands.ShowRef.args(%Git.Commands.ShowRef{heads: true})
    ["show-ref", "--heads"]

    iex> Git.Commands.ShowRef.args(%Git.Commands.ShowRef{tags: true})
    ["show-ref", "--tags"]

    iex> Git.Commands.ShowRef.args(%Git.Commands.ShowRef{verify: true, patterns: ["refs/heads/main"]})
    ["show-ref", "--verify", "refs/heads/main"]

    iex> Git.Commands.ShowRef.args(%Git.Commands.ShowRef{hash: true})
    ["show-ref", "--hash"]

    iex> Git.Commands.ShowRef.args(%Git.Commands.ShowRef{hash: 8})
    ["show-ref", "--hash=8"]

    iex> Git.Commands.ShowRef.args(%Git.Commands.ShowRef{abbrev: 8})
    ["show-ref", "--abbrev=8"]

    iex> Git.Commands.ShowRef.args(%Git.Commands.ShowRef{dereference: true})
    ["show-ref", "-d"]

    iex> Git.Commands.ShowRef.args(%Git.Commands.ShowRef{quiet: true, verify: true, patterns: ["refs/heads/main"]})
    ["show-ref", "--verify", "-q", "refs/heads/main"]

# `parse_output`

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

Parses the output of `git show-ref`.

- Default mode (exit 0): parses "sha ref" lines into `{:ok, [%{sha, ref}]}`
- Hash mode (exit 0): returns `{:ok, [String.t()]}` of SHA values
- Verify mode (exit 0): parses "sha ref" lines; (exit 1/128): `{:ok, []}`
- Quiet+verify mode (exit 0): `{:ok, true}`; (exit 1/128): `{:ok, false}`
- Exit code 1 without verify: no matching refs = `{:ok, []}`

---

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