Implements the Git.Command behaviour for git diff-index.
Compares a tree-ish to the index and the working tree (or, with :cached,
to the index only). Output is requested with --raw -z and parsed into
Git.DiffRawEntry structs.
With :quiet the command runs as a dirty-check: git exits 1 when there are
differences, which is treated as a signal rather than an error. In that mode
the wrapper returns a boolean instead of a list of entries.
Summary
Types
Functions
Returns the argument list for git diff-index.
Options:
:tree_ish- the tree-ish to compare against (default"HEAD"):cached- adds--cachedto compare against the index only:quiet- adds--quietfor a dirty-check (exit 1 = differences)
Examples
iex> Git.Commands.DiffIndex.args(%Git.Commands.DiffIndex{})
["diff-index", "--raw", "-z", "HEAD"]
iex> Git.Commands.DiffIndex.args(%Git.Commands.DiffIndex{cached: true})
["diff-index", "--raw", "-z", "--cached", "HEAD"]
iex> Git.Commands.DiffIndex.args(%Git.Commands.DiffIndex{quiet: true})
["diff-index", "--quiet", "HEAD"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, [Git.DiffRawEntry.t()] | boolean()} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git diff-index.
In raw mode (the default), returns {:ok, [Git.DiffRawEntry.t()]} on exit
code 0 and {:error, {stdout, exit_code}} otherwise.
In quiet mode, exit code 0 means no differences ({:ok, false}) and exit
code 1 means differences were found ({:ok, true}). Any other exit code is
a real git error and returns {:error, {stdout, exit_code}}.