@saflib/git
@saflib/git
Classes
| Class | Description |
|---|---|
| GitCommandError | Raised when a git plumbing command exits non-zero or produces unparseable output. Consumers should treat this as an expected, typed failure (missing ref, corrupt object, not a git repo, etc.) rather than an unexpected exception. |
Interfaces
| Interface | Description |
|---|---|
| GitCommit | One commit returned by log. |
| GitRef | - |
| GitTreeEntry | One tree entry returned by listTree (blobs only). |
| LogOptions | - |
Functions
| Function | Description |
|---|---|
| currentBranch | Short name of the branch HEAD points at (e.g. main), or null when detached. |
| isAncestor | True when maybeAncestor is an ancestor of maybeDescendant (or they are the same commit). Wraps git merge-base --is-ancestor. |
| listRefs | List local branch and tag refs via git for-each-ref. Does not include remote-tracking refs. |
| listRenames | File rename pairs from fromRef to toRef (git diff --find-renames -z --name-status --diff-filter=R). |
| listTree | List every blob at commitHash (recursive) without checking anything out. Directories / trees / commits / tags are skipped — only blob entries are returned. Paths are relative to the repo root. |
| log | Walk commits on ref (default HEAD), newest first — same order as git log. Uses --first-parent so merge commits don't fan the walk out. |
| mergeBase | Best common ancestor of two commits/refs (git merge-base <a> <b>). |
| readBlob | Read a blob's contents by hash without checking anything out. Returns the raw file text (git stores blobs without a trailing newline of its own beyond what the file itself contained). |
| readBlobs | Read many blobs in one git cat-file --batch invocation. Missing/invalid objects are omitted from the result map (caller treats as miss). |
| resolveRef | Resolve a ref (default HEAD) to a full commit hash via git rev-parse. |