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

Implements the `Git.Command` behaviour for `git write-tree`.

Records the current index as a tree object and returns its SHA. This is the
plumbing counterpart to `Git.Commands.CommitTree`: `write-tree` produces the
tree SHA that `commit-tree` turns into a commit, so together they build a
commit without touching HEAD or the working tree.

# `t`

```elixir
@type t() :: %Git.Commands.WriteTree{missing_ok: boolean(), prefix: String.t() | nil}
```

# `args`

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

Returns the argument list for `git write-tree`.

## Examples

    iex> Git.Commands.WriteTree.args(%Git.Commands.WriteTree{})
    ["write-tree"]

    iex> Git.Commands.WriteTree.args(%Git.Commands.WriteTree{prefix: "lib"})
    ["write-tree", "--prefix=lib"]

    iex> Git.Commands.WriteTree.args(%Git.Commands.WriteTree{missing_ok: true})
    ["write-tree", "--missing-ok"]

# `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 write-tree`.

On success (exit code 0), returns `{:ok, sha}` with the trimmed tree SHA.
On failure, returns `{:error, {stdout, exit_code}}`.

---

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