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

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

Loads tree contents into the index. It is the read side of the index/tree
pipeline behind `commit_tree`: read a tree into the index, adjust it (for
example with `update-index`), then `write-tree` it back out. `-m` does a
two- or three-way merge of up to three trees in the index.

# `t`

```elixir
@type t() :: %Git.Commands.ReadTree{
  merge: boolean(),
  prefix: String.t() | nil,
  reset: boolean(),
  trees: [String.t()],
  update: boolean()
}
```

# `args`

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

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

## Examples

    iex> Git.Commands.ReadTree.args(%Git.Commands.ReadTree{trees: ["HEAD"]})
    ["read-tree", "HEAD"]

    iex> Git.Commands.ReadTree.args(%Git.Commands.ReadTree{trees: ["a", "b"], merge: true, update: true})
    ["read-tree", "-m", "-u", "a", "b"]

    iex> Git.Commands.ReadTree.args(%Git.Commands.ReadTree{trees: ["t"], prefix: "sub/"})
    ["read-tree", "--prefix=sub/", "t"]

# `parse_output`

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

Parses the output of `git read-tree`.

On success (exit code 0), returns `{:ok, :done}`. On failure, returns
`{:error, {stdout, exit_code}}`.

---

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