Git operations, delegated to a configurable backend.
In production, uses Minga.Git.System which shells out to the git
CLI. In tests, swap to Minga.Git.Stub to avoid spawning OS processes:
config :minga, git_module: Minga.Git.Stub
Summary
Types
Accepted diff options. Unknown keys, duplicate keys, and invalid values are rejected. :commit may be combined with :staged, but only when :staged is false.
A structured log entry.
A structured stash entry.
A structured status entry for one file.
Accepted status/2 options.
How much untracked-file detail git status should enumerate.
Functions
Returns ahead/behind counts relative to the upstream tracking branch.
Gets blame information for a specific line of a file.
Creates a new branch and checks it out.
Deletes a branch.
Lists all branches (local and remote).
Switches to an existing branch.
Creates a commit with the given message.
Returns the parsed merge conflict count for a tracked buffer.
Returns parsed merge conflict regions for a tracked buffer.
Returns the current branch name for a git repository.
Returns the diff for a specific file or all changes.
Computes line-level diff hunks between two lists of lines.
Discards working tree changes for a file. Destructive and irreversible.
Fetches from all remotes.
Returns gutter sign indicators (line → hunk type) for a tracked buffer.
Returns the hunk at a specific line, or nil.
Returns all diff hunks for a tracked buffer.
Returns the message of the most recent commit.
Returns recent commits as structured entries.
Finds the Repo process for a git root path, or nil if not started.
Returns modeline-ready git info (branch, hunk counts) for a tracked buffer.
Pulls from the upstream remote (fetch + merge).
Pushes the current branch to its upstream remote.
Triggers a background refresh of the Repo's cached git state.
Returns the path of a file relative to the git root.
Returns cached status entries from a running Repo process.
Returns a summary map (branch, ahead/behind, file counts) from a Repo.
Reverts a single hunk, restoring the base content for those lines.
Finds the git repository root for a file path.
Reads the HEAD version of a file from git.
Reads the staged (index) version of a file from git.
Stages specific files (equivalent to git add).
Applies a unified diff patch to the git index (staging area).
Saves current worktree changes to a stash.
Drops a stash by index.
Lists stashes for a repository.
Pops the most recent stash.
Returns a structured list of changed files with their status.
Synchronizes a tracked buffer cache with the provided content.
Returns the git tracking process for a buffer, or nil if untracked.
Unstages specific files from the index (equivalent to git reset HEAD -- <paths>).
Unstages all staged files (equivalent to git reset HEAD).
Types
Accepted diff options. Unknown keys, duplicate keys, and invalid values are rejected. :commit may be combined with :staged, but only when :staged is false.
@type diff_opts() :: [diff_opt()]
@type log_entry() :: Minga.Git.LogEntry.t()
A structured log entry.
@type stash_entry() :: Minga.Git.StashEntry.t()
A structured stash entry.
@type status_entry() :: Minga.Git.StatusEntry.t()
A structured status entry for one file.
@type status_opt() :: {:untracked_mode, untracked_mode()} | {:timeout_ms, pos_integer()}
Accepted status/2 options.
@type status_opts() :: [status_opt()]
@type untracked_mode() :: :no | :normal | :all
How much untracked-file detail git status should enumerate.
Functions
@spec ahead_behind(String.t()) :: {:ok, non_neg_integer(), non_neg_integer()} | :error
Returns ahead/behind counts relative to the upstream tracking branch.
@spec blame_line(String.t(), String.t(), non_neg_integer()) :: {:ok, String.t()} | :error
Gets blame information for a specific line of a file.
Returns {:ok, blame_text} with a human-readable blame string,
or :error if blame fails.
Creates a new branch and checks it out.
Deletes a branch.
@spec branch_list(String.t()) :: {:ok, [Minga.Git.BranchInfo.t()]} | {:error, String.t()}
Lists all branches (local and remote).
Switches to an existing branch.
Creates a commit with the given message.
Options: :amend (boolean, default false) to amend the previous commit.
@spec conflict_count(GenServer.server()) :: non_neg_integer()
Returns the parsed merge conflict count for a tracked buffer.
@spec conflicts(GenServer.server()) :: [Minga.Git.MergeConflict.Region.t()]
Returns parsed merge conflict regions for a tracked buffer.
Returns the current branch name for a git repository.
Returns {:ok, branch_name} or :error if it can't be determined
(e.g., detached HEAD, not a git repo).
Returns the diff for a specific file or all changes.
Options: :path (file path), :staged (boolean, default false), :commit (commit hash).
:commit may be combined with :staged, false; commit diffs can still be narrowed with :path.
@spec diff_lines([String.t()], [String.t()]) :: [Minga.Core.Diff.hunk()]
Computes line-level diff hunks between two lists of lines.
Discards working tree changes for a file. Destructive and irreversible.
For tracked files, runs git checkout -- <path>.
For untracked files, deletes the file.
Fetches from all remotes.
@spec gutter_signs(GenServer.server()) :: %{required(non_neg_integer()) => atom()}
Returns gutter sign indicators (line → hunk type) for a tracked buffer.
@spec hunk_at(GenServer.server(), non_neg_integer()) :: Minga.Core.Diff.hunk() | nil
Returns the hunk at a specific line, or nil.
@spec hunks(GenServer.server()) :: [Minga.Core.Diff.hunk()]
Returns all diff hunks for a tracked buffer.
Returns the message of the most recent commit.
Returns recent commits as structured entries.
Options: :count (default 10), :path (limit to file).
Finds the Repo process for a git root path, or nil if not started.
@spec modeline_info(GenServer.server()) :: Minga.Git.Buffer.modeline_info()
Returns modeline-ready git info (branch, hunk counts) for a tracked buffer.
Pulls from the upstream remote (fetch + merge).
Pushes the current branch to its upstream remote.
@spec refresh_repo(pid()) :: :ok
Triggers a background refresh of the Repo's cached git state.
Returns the path of a file relative to the git root.
@spec repo_status(pid()) :: [status_entry()]
Returns cached status entries from a running Repo process.
Returns a summary map (branch, ahead/behind, file counts) from a Repo.
@spec revert_hunk([String.t()], Minga.Core.Diff.hunk()) :: [String.t()]
Reverts a single hunk, restoring the base content for those lines.
Finds the git repository root for a file path.
Returns {:ok, root_path} if the file is inside a git repo, or
:not_git if it isn't.
Reads the HEAD version of a file from git.
Returns {:ok, content} with the file content at HEAD, or :error
if the file doesn't exist in HEAD (new file, not tracked, etc.).
Reads the staged (index) version of a file from git.
Returns {:ok, content} with the file content in the index, or :error
if the file is not staged.
Stages specific files (equivalent to git add).
Applies a unified diff patch to the git index (staging area).
Saves current worktree changes to a stash.
@spec stash_drop(String.t(), non_neg_integer()) :: :ok | {:error, String.t()}
Drops a stash by index.
@spec stash_list(String.t()) :: {:ok, [stash_entry()]} | {:error, String.t()}
Lists stashes for a repository.
Pops the most recent stash.
@spec status(String.t(), status_opts()) :: {:ok, [status_entry()]} | {:error, String.t()}
Returns a structured list of changed files with their status.
Synchronizes a tracked buffer cache with the provided content.
Returns the git tracking process for a buffer, or nil if untracked.
Composes the Tracker lookup so callers don't need to know about the Tracker → Buffer two-step.
Unstages specific files from the index (equivalent to git reset HEAD -- <paths>).
Unstages all staged files (equivalent to git reset HEAD).