GitCli (fnord v0.9.29)
View SourceWrapper for direct git CLI calls.
Covers repo classification (is_git_repo?/0, worktree_root/0),
branch reporting (current_branch/0, default_branch/1), tree
enumeration for indexing (ls_tree/2, show_blob/3), gitignore
resolution (ignored_files/1), and formatted user-facing messages
(git_info/0).
Note: default_branch/1 resolves the project's indexing branch
with a strict fallback chain (origin/HEAD → main → master → nil).
For the looser worktree-root resolution that falls back to the
current branch, see GitCli.Worktree.default_base_branch/1.
Summary
Functions
Returns the repository's default branch for indexing purposes
Returns an empty map if root is nil, otherwise behaves as before.
Lists every blob in branch's tree as {blob_sha, rel_path} pairs.
The blob sha is git's content-addressed hash and is stable across
clones and checkouts, so it's usable as a freshness key for the
indexer.
Returns the content of rel_path as it exists on branch, or an
error tuple if git rejects the request (missing file, invalid branch,
etc.). Content is returned as a binary; binaries that aren't valid
UTF-8 are still returned — callers decide how to handle them.
Functions
@spec current_branch() :: String.t() | nil
Returns the repository's default branch for indexing purposes:
origin/HEAD- the remote's declared default (usually main).- Local
mainormaster, in that order. nil- do not silently fall back to the current branch, since that would makefnord indexon a feature branch index the feature branch rather than the project's canonical source.
Callers fall back to filesystem-mode indexing when this returns nil, so the user still gets their working tree indexed; they just won't get default-branch semantics.
@spec git_info() :: String.t()
Returns an empty map if root is nil, otherwise behaves as before.
@spec is_git_repo?() :: boolean()
Lists every blob in branch's tree as {blob_sha, rel_path} pairs.
The blob sha is git's content-addressed hash and is stable across
clones and checkouts, so it's usable as a freshness key for the
indexer.
Returns the content of rel_path as it exists on branch, or an
error tuple if git rejects the request (missing file, invalid branch,
etc.). Content is returned as a binary; binaries that aren't valid
UTF-8 are still returned — callers decide how to handle them.