# `GitHoox.Git`
[🔗](https://github.com/sgerrand/git_hoox/blob/v0.1.0/lib/git_hoox/git.ex#L1)

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}}`.

# `diff_filter`

```elixir
@type diff_filter() :: String.t()
```

git --diff-filter status letters (e.g. "ACMR").

# `git_error`

```elixir
@type git_error() :: {:error, {non_neg_integer(), String.t()}}
```

# `all_files`

```elixir
@spec all_files() :: {:ok, [GitHoox.path()]} | git_error()
```

All tracked files via `git ls-files`.

# `changed_in_worktree`

```elixir
@spec changed_in_worktree([GitHoox.path()]) :: [GitHoox.path()]
```

Files modified in worktree since index, scoped to `candidates`.
Used to detect what a hook mutated.

# `diff_files`

```elixir
@spec diff_files(String.t(), String.t()) :: {:ok, [GitHoox.path()]} | git_error()
```

Files changed between two refs (used for post-checkout).

# `files_in_head`

```elixir
@spec files_in_head() :: {:ok, [GitHoox.path()]} | git_error()
```

Files touched by the HEAD commit (used for post-commit).

# `hooks_dir`

```elixir
@spec hooks_dir() :: {:ok, Path.t()} | git_error()
```

Return absolute path of `.git/hooks/` honoring core.hooksPath + worktrees.

# `merge_files`

```elixir
@spec merge_files() :: {:ok, [GitHoox.path()]} | git_error()
```

Files changed by the last merge (used for post-merge).

# `push_files`

```elixir
@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.

# `restage`

```elixir
@spec restage([GitHoox.path()]) :: :ok | git_error()
```

Re-stage files via `git add`.

# `staged_files`

```elixir
@spec staged_files(keyword()) :: {:ok, [GitHoox.path()]} | git_error()
```

List files staged for commit.

## Options

  * `:filter` — `--diff-filter` letters. Default `"ACMR"` (skip deletes).

# `toplevel`

```elixir
@spec toplevel() :: {:ok, Path.t()} | git_error()
```

Return repo root via `git rev-parse --show-toplevel`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
