Shell out to git for file-state queries.
All functions assume the current working directory is inside a git
worktree. Errors from the underlying git invocation surface as
{:error, {exit_code, stderr}}.
Summary
Functions
All tracked files via git ls-files.
Files modified in worktree since index, scoped to candidates.
Used to detect what a hook mutated.
Files changed between two refs (used for post-checkout).
Files touched by the HEAD commit (used for post-commit).
Return absolute path of .git/hooks/ honoring core.hooksPath + worktrees.
Files changed by the last merge (used for post-merge).
Parse pre-push stdin and return files changed across all pushed refs.
Re-stage files via git add.
List files staged for commit.
Return repo root via git rev-parse --show-toplevel.
Types
@type diff_filter() :: String.t()
git --diff-filter status letters (e.g. "ACMR").
@type git_error() :: {:error, {non_neg_integer(), String.t()}}
Functions
@spec all_files() :: {:ok, [GitHoox.path()]} | git_error()
All tracked files via git ls-files.
@spec changed_in_worktree([GitHoox.path()]) :: [GitHoox.path()]
Files modified in worktree since index, scoped to candidates.
Used to detect what a hook mutated.
@spec diff_files(String.t(), String.t()) :: {:ok, [GitHoox.path()]} | git_error()
Files changed between two refs (used for post-checkout).
@spec files_in_head() :: {:ok, [GitHoox.path()]} | git_error()
Files touched by the HEAD commit (used for post-commit).
Return absolute path of .git/hooks/ honoring core.hooksPath + worktrees.
@spec merge_files() :: {:ok, [GitHoox.path()]} | git_error()
Files changed by the last merge (used for post-merge).
@spec push_files(String.t() | nil) :: {:ok, [GitHoox.path()]}
Parse pre-push stdin and return files changed across all pushed refs.
Stdin format per githooks(5):
<local_ref> <local_sha> <remote_ref> <remote_sha> per line.
@spec restage([GitHoox.path()]) :: :ok | git_error()
Re-stage files via git add.
@spec staged_files(keyword()) :: {:ok, [GitHoox.path()]} | git_error()
List files staged for commit.
Options
:filter—--diff-filterletters. Default"ACMR"(skip deletes).
Return repo root via git rev-parse --show-toplevel.