UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

47 lines • 2.23 kB
import type { Repo } from './repo.ts'; import type { IndexState } from './types.ts'; import type { Files } from '../../../../workspace/files.ts'; /** What a mutation hands back to the index, before the stat cache is filled. */ export interface StagedEntry { readonly oid: string; readonly mode: number; readonly size: number; } /** * Read `.git/index` through the dispatcher. * * The index is the third thing `status` compares, and the only one that is a * single file: HEAD's tree is assembled from objects and the working tree is * walked, but staged content is one binary blob. * * An absent index is not an error. `git init` writes none until the first * `git add`, and every path is then untracked, which is what an empty table * already says. */ export declare function readIndex(repo: Repo, vfs: Files): Promise<IndexState>; /** * Replace the staged entries, leaving conflicts alone. * * The stat cache is written zeroed, which git reads as "do not trust it": it * then compares content rather than believing a size or an mtime mirage cannot * promise is meaningful. A zeroed `size` therefore means "not stated" to every * reader here, never "empty". * * @param repo the opened repository * @param staged the paths to set, mapped to what should be recorded for them * @param removed the paths to drop from the index entirely */ export declare function updateIndex(repo: Repo, staged: ReadonlyMap<string, StagedEntry>, removed?: Iterable<string>): Promise<void>; /** * Refuse a branch move while the index still records conflict stages. * * Every collision check a checkout makes reads stage 0, so a path held only as * stages 1-3 is invisible to all of them, and git refuses before it reads * either tree. The refusal is not the moving side's alone: `git switch * <current>` and `git checkout <current>` move nothing and still die on it, so * a line that answers "Already on" out of a shortcut has to ask the index * first. Pinned against git 2.50.1, where `git switch -c <new>` is the one line * that survives an unresolved index, because it writes a ref and nothing else. */ export declare function refuseUnresolved(state: IndexState): void; //# sourceMappingURL=index_file.d.ts.map