Implements the Git.Command behaviour for git cat-file.
Provides content or type/size information for repository objects. Supports pretty-printing object contents, querying object type or size, and checking whether an object exists.
Interactive and batch modes are intentionally not supported because they require stdin interaction which cannot be driven programmatically.
Summary
Types
Functions
Returns the argument list for git cat-file.
Builds the argument list from the struct fields. Exactly one of the mode
flags (:type, :size, :print, :exists) should be set, or none for
the default pretty-print behaviour.
Examples
iex> Git.Commands.CatFile.args(%Git.Commands.CatFile{object: "HEAD", type: true})
["cat-file", "-t", "HEAD"]
iex> Git.Commands.CatFile.args(%Git.Commands.CatFile{object: "HEAD", size: true})
["cat-file", "-s", "HEAD"]
iex> Git.Commands.CatFile.args(%Git.Commands.CatFile{object: "HEAD", print: true})
["cat-file", "-p", "HEAD"]
iex> Git.Commands.CatFile.args(%Git.Commands.CatFile{object: "HEAD", exists: true})
["cat-file", "-e", "HEAD"]
iex> Git.Commands.CatFile.args(%Git.Commands.CatFile{object: "HEAD", textconv: true})
["cat-file", "--textconv", "HEAD"]
iex> Git.Commands.CatFile.args(%Git.Commands.CatFile{object: "HEAD", filters: true})
["cat-file", "--filters", "HEAD"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, atom()} | {:ok, integer()} | {:ok, String.t()} | {:ok, boolean()} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git cat-file.
- For
:typemode, returns{:ok, atom}where atom is one of:blob,:tree,:commit, or:tag. - For
:sizemode, returns{:ok, integer}. - For
:printmode (including textconv and filters), returns{:ok, String.t()}. - For
:existsmode, exit code 0 returns{:ok, true}and exit code 1 returns{:ok, false}(not an error).