Implements the Git.Command behaviour for git ls-tree.
Lists the contents of a tree object, showing the mode, type, name,
and optionally size of each object. Parses output into a list of
Git.TreeEntry structs or plain path strings when --name-only is used.
Summary
Types
Functions
Returns the argument list for git ls-tree.
The tree-ish ref is placed after flags. An optional path filter is
appended after --.
Examples
iex> Git.Commands.LsTree.args(%Git.Commands.LsTree{})
["ls-tree", "HEAD"]
iex> Git.Commands.LsTree.args(%Git.Commands.LsTree{recursive: true, long: true})
["ls-tree", "-r", "-l", "HEAD"]
iex> Git.Commands.LsTree.args(%Git.Commands.LsTree{name_only: true, ref: "main"})
["ls-tree", "--name-only", "main"]
iex> Git.Commands.LsTree.args(%Git.Commands.LsTree{path: "lib/"})
["ls-tree", "HEAD", "--", "lib/"]
iex> Git.Commands.LsTree.args(%Git.Commands.LsTree{abbrev: 8})
["ls-tree", "--abbrev=8", "HEAD"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, [Git.TreeEntry.t()] | [String.t()]} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git ls-tree.
On success (exit code 0), parses each line into a Git.TreeEntry struct.
When name_only mode was used (detected by the absence of tabs in output),
returns {:ok, [String.t()]} with just the path names.
The default format is mode type sha\tpath.
With --long, the format is mode type sha size\tpath where size
is right-justified with spaces.
Returns {:error, {stdout, exit_code}} on failure.