# `Juggernaut.Plan.Git`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/plan/git.ex#L1)

The git queries the planner needs, run in the project root through a runner function
(`run/2` by default; tests pass their own). Paths are relative to the project root
(`--relative`), so a project in a subdirectory of its repository works.

Every failure is a usage error (exit 2): git missing, not a repository, or a ref that
does not resolve. Nothing falls back silently to another scope.

# `runner`

```elixir
@type runner() :: ([String.t()], Path.t() -&gt; {:ok, String.t()} | {:error, String.t()})
```

# `changed_files`

```elixir
@spec changed_files(runner(), Path.t(), String.t()) ::
  {:ok, [String.t()]} | {:error, Juggernaut.Error.t()}
```

Files changed since `base` (committed or not), relative to `root`.

# `diff`

```elixir
@spec diff(runner(), Path.t(), String.t(), [String.t()]) ::
  {:ok, String.t()} | {:error, Juggernaut.Error.t()}
```

The `-U0` diff of the working tree against `base` for `paths`.

# `merge_base`

```elixir
@spec merge_base(runner(), Path.t(), String.t()) ::
  {:ok, String.t()} | {:error, Juggernaut.Error.t()}
```

The merge base of `ref` and `HEAD`.

# `run`

```elixir
@spec run([String.t()], Path.t()) :: {:ok, String.t()} | {:error, String.t()}
```

Runs git with `args` in `root`. Success returns stdout alone: git writes warnings (such
as core.autocrlf's "LF will be replaced by CRLF") to stderr, and merged into stdout they
would corrupt the `-z` path listings, so they pass through to the terminal instead. On
failure git runs again with stderr captured, for its message.

# `untracked`

```elixir
@spec untracked(runner(), Path.t()) ::
  {:ok, [String.t()]} | {:error, Juggernaut.Error.t()}
```

Untracked, not ignored files, relative to `root`.

---

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