Git.Commands.ReadTree (git v0.7.0)

Copy Markdown View Source

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.

Summary

Functions

Returns the argument list for git read-tree.

Parses the output of git read-tree.

Types

t()

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

Functions

args(command)

@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(stdout, exit_code)

@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}}.