/** * Git side of the diff view: parsing unified diff text, and loading the two things the panel can * show from a repository. * * changes everything not yet committed: staged, unstaged and untracked files in one list, with * git status's two-letter code for each (`M `, ` M`, `MM`, `??`) * branch what the current branch changed since it left its base branch (`main...HEAD`; the * base is the remote's default branch, as /pr finds it) * * All git commands are run with execFile and an argument array, never through a shell, and with * --no-optional-locks so looking never blocks the user's own git. */ export interface DiffLine { kind: "add" | "del" | "ctx" | "note"; text: string; oldNo?: number; newNo?: number; } export interface Hunk { /** The `@@ -a,b +c,d @@ context` line. */ header: string; lines: DiffLine[]; /** The hunk's lines exactly as git wrote them, header first. */ raw: string[]; } export interface FileDiff { path: string; oldPath?: string; /** Two characters for the file list: git status's XY for changes, "M " style for a branch. */ code: string; status: "A" | "M" | "D" | "R"; binary: boolean; added: number; removed: number; /** The lines before the first hunk (`diff --git`, `index`, `---`, `+++`). */ header: string[]; hunks: Hunk[]; /** Why there is no text to show (too large, a symlink, unreadable). */ note?: string; } export interface Loaded { files: FileDiff[]; /** A message to show in place of an empty list, or under a full one. */ note?: string; /** A failure to show instead of the list. */ error?: string; /** Dim text next to the source tabs, e.g. "main...HEAD ยท 3 commits". */ meta?: string; /** What the branch source compares against ("origin/develop"); the Branch tab names it. */ base?: string; } /** * Parse unified diff text (`git diff`, or `diff -u` with `---`/`+++` headers) into files and hunks. * A hunk ends when its line counts from the `@@` header are used up, so a blank context line that * lost its leading space does not end it early. A line that starts with `@@ ` or `diff --git ` * ends it too, whatever the counts say: a body line always starts with a space, `+`, `-` or `\`, * so this makes a diff with wrong counts (from a hand-built or model-written patch) still split * into the right hunks and files. */ export declare function parseUnifiedDiff(text: string): FileDiff[]; export interface StatusEntry { xy: string; path: string; orig?: string; } /** Parse `git status --porcelain=v1 -z`. A rename or copy is followed by its origin as its own entry. */ export declare function parseStatus(out: string): StatusEntry[]; /** Staged, unstaged and untracked changes in one list, like `git status` with the diffs attached. */ export declare function loadChanges(cwd: string): Promise; /** What the current branch changed since it left its base: `git diff ...HEAD`. */ export declare function loadBranch(cwd: string): Promise;