Implements the Git.Command behaviour for git blame.
Always uses --porcelain output format internally for reliable,
machine-readable parsing. The output is parsed into a list of
Git.BlameEntry structs.
Supports line ranges, specific revisions, email display, date formatting, reverse blame, first-parent following, encoding, and root commit handling.
Summary
Types
Functions
Returns the argument list for git blame.
Always includes --porcelain for reliable parsing regardless of the
:porcelain struct field. The :file field is required and appended
at the end of the argument list.
Examples
iex> Git.Commands.Blame.args(%Git.Commands.Blame{file: "lib/app.ex"})
["blame", "--porcelain", "lib/app.ex"]
iex> Git.Commands.Blame.args(%Git.Commands.Blame{file: "lib/app.ex", lines: "1,5"})
["blame", "--porcelain", "-L", "1,5", "lib/app.ex"]
iex> Git.Commands.Blame.args(%Git.Commands.Blame{file: "lib/app.ex", rev: "HEAD~1"})
["blame", "--porcelain", "HEAD~1", "--", "lib/app.ex"]
iex> Git.Commands.Blame.args(%Git.Commands.Blame{file: "lib/app.ex", show_email: true})
["blame", "--porcelain", "-e", "lib/app.ex"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, [Git.BlameEntry.t()]} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git blame --porcelain.
On success (exit code 0), parses the porcelain output into a list of
Git.BlameEntry structs. Each entry contains the commit SHA,
author information, line numbers, and the actual line content.
Returns {:ok, [BlameEntry.t()]} on success or
{:error, {stdout, exit_code}} on failure.