/** Reading a repository: status, branches, remotes. Nothing here changes anything. */ export interface RepoStatus { branch?: string; /** The tracked branch ("origin/feat"); absent when there is none or it no longer exists. */ upstream?: string; /** The tracked branch's name when it was deleted on the remote (git status says "[gone]"). */ gone?: string; ahead: number; behind: number; staged: number; unstaged: number; untracked: number; conflicted: number; } /** Parse `git status --porcelain=v1 --branch`. */ export declare function parseStatus(out: string): RepoStatus; /** * The paths `git add -A` would stage, as git status lists them (one per file, also inside new * directories), for showing before anything is staged. Undefined when git could not say. */ export declare function changedPaths(cwd: string): Promise; /** A saved copy of the index: call `staged` after your own staging, and `restore` to undo it. */ export interface IndexSnapshot { /** Note what the index holds after the staging, so `restore` can tell if anything else changed it since. */ staged(): Promise; /** Put the index back as it was. Resolves false, leaving it alone, when something else changed it since `staged`. */ restore(): Promise; } /** * Save the index (the staging area) so a command that stages files can undo that if it is * dropped. The index file itself is copied, because `git write-tree` and `read-tree` would lose * entries added with `git add -N`. It is put back with git's own lock file (`index.lock`), so it * cannot collide with a git command running at the same time. Undefined when it cannot be read. */ export declare function saveIndex(cwd: string): Promise; export declare function repoStatus(cwd: string): Promise; /** The current branch, or undefined when HEAD is detached. */ export declare function currentBranch(cwd: string): Promise; export declare function refExists(cwd: string, ref: string): Promise; /** The remote a branch publishes to: its upstream's remote, else origin, else the first remote. */ export declare function remoteName(cwd: string, upstream?: string): Promise; /** * The branch changes are normally merged into: the remote's HEAD (so a repository whose default is * develop or trunk works), else main or master on the remote, else main or master locally. */ export declare function defaultBranch(cwd: string, remote?: string): Promise; /** The ref to compare with for a base branch: the remote's copy when there is one (a local copy can be stale), else the local branch. */ export declare function compareRef(cwd: string, remote: string, base: string): Promise; /** The remote and branch a local branch tracks, from its git config; undefined when it tracks nothing. */ export declare function trackedBranch(cwd: string, branch: string): Promise<{ remote: string; branch: string; } | undefined>; /** Commits on each side of `HEAD` and `ref`: how many only HEAD has (ahead) and only `ref` has (behind). */ export declare function aheadBehind(cwd: string, ref: string): Promise<{ ahead: number; behind: number; } | undefined>; /** The host of a remote URL: https, ssh:// and scp-style (git@host:path) forms. */ export declare function remoteHost(url: string): string | undefined; /** Local branch names other than `except`, most recently used first. */ export declare function localBranches(cwd: string, except?: string): Promise; /** True when `cwd` is inside a git work tree. */ export declare function isRepo(cwd: string): Promise;