Expand description
Git integration for Vix.
Two layers:
- Pure logic (unit-tested, no I/O):
parse_statusturnsgit status --porcelainoutput intoFileStatusrows, anddiff_markscomputes per-line editor-gutterLineMarks between the committed text and the current buffer (via thesimilarcrate). - Runners (shell out to the
gitCLI):is_repo,branch,status,head_blob, and the staging/commit helpers. Using the user’s owngitmeans credential helpers, SSH agents, and hooks all behave exactly as on the command line.
Structs§
- Blame
Line - One line’s
git blameattribution: the short commit hash, author name,YYYY-MM-DDauthored date, and the commit summary. - File
Status - One changed path from
git status, with its staged (index) and unstaged (working-tree) change, if any. - Hunk
- A contiguous changed region between the committed text and the current buffer, for hunk navigation and revert.
- LogEntry
- One
git logrow. - LogPanel
- A commit-list overlay:
log/file_logentries, a highlighted row, and a scroll offset.
Enums§
- Change
- A kind of change to a file (in the index or the working tree).
- Line
Mark - A per-line change marker for the editor’s diff gutter.
- LogScope
- Where a
LogPanel’s entries came from, and what its Enter should diff against.
Functions§
- blame_
line git blamefor a single 1-based line of a repo-relative path, parsed into aBlameLine.Nonewhen not a repo, the path is untracked, or on error.- branch
- The current branch name, or
Nonewhen detached / not a repo. A detached HEAD yields the short commit hash via the caller’s discretion (hereNone). - checkout
- Check out an existing branch (
git switch <branch>). ReturnsOk(())on success, or the captured stderr on failure (e.g. a conflicting dirty tree). - commit
- Commit the staged changes with
message. ReturnsOk(())on success, or the captured stderr on failure (e.g. nothing staged, hook rejected). - commit_
amend - Amend the previous commit, folding in currently-staged changes and keeping
its message (
git commit --amend --no-edit). - commit_
count - The number of commits reachable from HEAD (
git rev-list --count HEAD), orNonewhen not a repo or there are no commits yet. - commit_
signing_ needs_ tty - Whether committing in
dirwould sign with a terminal pinentry, which cannot run under Vix’s raw-mode screen (T570):commit.gpgsignis true, the signing format is GPG, and the user’sgpg-agent.confselects a curses/tty pinentry. - create_
branch - Create a new branch and switch to it (
git switch -c <name>). ReturnsOk(())on success, or the captured stderr on failure (e.g. the name already exists or is invalid). - diff_
marks - Compute per-line gutter marks between the committed text (
head) and the current buffer (current), keyed by current line index (0-based). - file_
log - The
maxmost recent commits touchingrel_path, following renames (Git → File History). - head_
blob - The committed (
HEAD) contents of a repo-relative path, orNoneif the path is not in HEAD (newly added/untracked) or on any error. - hunks
- Group the line diff between committed text (
head) and the current buffer intoHunks — maximal runs of adjacent changed lines — in current-line order. Pairs withdiff_marks(which colors individual gutter lines). - index_
blob - The staged (index) version of
rel_path(git show :path), trailing newline preserved.Nonewhen the file is not in the index. - is_
dirty - Whether the working tree has any staged or unstaged changes (incl. untracked).
- is_repo
- Whether
diris inside a git working tree. - local_
branches - The local branch names, current branch first when it can be determined.
- log
- The repository’s
maxmost recent commits onHEAD(Git → Log). - parse_
blame_ porcelain - Parse one entry of
git blame --line-porcelainoutput into aBlameLine. ReturnsNoneif no header (hash) line is present. - parse_
status - Parse
git status --porcelain(v1) output into oneFileStatusper path. - pinentry_
wants_ tty - Whether a
gpg-agent.confselects a terminal-based pinentry (pinentry-curses,pinentry-tty): the lastpinentry-programline wins. Such a program draws on and reads from/dev/ttydirectly, so running it under Vix’s raw-mode screen corrupts the display and steals keystrokes (T570). - resolve_
short_ sha - Resolve
revision(a branch, tag, or any commit-ish) to its abbreviated hash (git rev-parse --short), for titling an Open File at Revision tab.Nonewhen it doesn’t resolve or fails the ref-name validation. - show_
commit - A commit’s own unified diff (
git show <sha>), or just the part touchingrel_pathwhen given.Noneon any failure, including an invalidsha(rejected before shelling out, the same guardcheckoutuses). - show_
file_ at rel_path’s content atrevision(git show <revision>:<rel_path>, e.g. Git → Open File at Revision…).Nonewhenrevisiondoesn’t resolve, the path isn’t in that tree, orrevisionfails the same validationcheckoutapplies to a ref name.- stage
- Stage a path (
git add -- <path>). - stage_
all - Stage every change in the working tree (
git add -A). - stage_
content - Replace the index entry for
rel_pathwith exactlycontent(used to stage a single hunk): hash the content into a blob and point the index at it, keeping the working tree untouched. - staged_
diff - The staged diff (
git diff --staged), for feeding to an AI commit-message generator (T125) —Noneon any failure, or when nothing is staged (an empty diff is not useful context and would only prompt a generic reply). - stash_
pop - Restore the most recent stash (
git stash pop). - stash_
push - Stash the working tree and index (
git stash push). - status
- The changed files reported by
git status --porcelain. - unstage
- Unstage a path (
git restore --staged -- <path>).