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

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

Updates the object name stored in a ref safely. Supports conditional
updates (compare-and-swap), reflog messages, and deletion.

# `t`

```elixir
@type t() :: %Git.Commands.UpdateRef{
  create_reflog: boolean(),
  delete: boolean(),
  message: String.t() | nil,
  new_value: String.t() | nil,
  no_deref: boolean(),
  old_value: String.t() | nil,
  ref: String.t() | nil
}
```

# `args`

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

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

## Examples

    iex> Git.Commands.UpdateRef.args(%Git.Commands.UpdateRef{ref: "refs/heads/main", new_value: "abc123"})
    ["update-ref", "refs/heads/main", "abc123"]

    iex> Git.Commands.UpdateRef.args(%Git.Commands.UpdateRef{ref: "refs/heads/main", new_value: "abc123", old_value: "def456"})
    ["update-ref", "refs/heads/main", "abc123", "def456"]

    iex> Git.Commands.UpdateRef.args(%Git.Commands.UpdateRef{ref: "refs/heads/main", new_value: "abc123", message: "reset"})
    ["update-ref", "-m", "reset", "refs/heads/main", "abc123"]

    iex> Git.Commands.UpdateRef.args(%Git.Commands.UpdateRef{ref: "refs/heads/old", delete: true})
    ["update-ref", "-d", "refs/heads/old"]

    iex> Git.Commands.UpdateRef.args(%Git.Commands.UpdateRef{ref: "HEAD", new_value: "abc123", no_deref: true})
    ["update-ref", "--no-deref", "HEAD", "abc123"]

    iex> Git.Commands.UpdateRef.args(%Git.Commands.UpdateRef{ref: "refs/heads/main", new_value: "abc123", create_reflog: true})
    ["update-ref", "--create-reflog", "refs/heads/main", "abc123"]

# `parse_output`

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

Parses the output of `git update-ref`.

Always returns `{:ok, :done}` on success (exit code 0) since
`git update-ref` produces no meaningful output.
On failure, returns `{:error, {stdout, exit_code}}`.

---

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