Skip to content

Reference

import { /* ... */ } from 'git-edge';
threeWayMerge(repo: Repo, sourceRef: string, targetRef: string, opts?: MergeOpts): Promise<MergeResult>
ParameterTypeDescription
opts.message?stringDefault `Merge ${sourceRef} into ${targetRef}`.
opts.authorName?stringDefault "Git Edge".
opts.authorEmail?stringDefault "git-edge@local".

Returns: Promise<{ commitOid: string }>

Object-level three-way merge — no worktree. Throws GitMergeConflictError on unresolved content conflicts. See Three-way merge for the full decision tree.

functionanalyzeMerge
analyzeMerge(repo: Repo, sourceRef: string, targetRef: string): Promise<MergeAnalysis>

Returns: Promise<{ canMerge; fastForward; diverged }>

Cheap pre-merge ancestry check — doesn’t walk trees or detect content conflicts. See Analyzing a merge for the canMerge: false error-propagation contract.

createParsedObjectCache(options?: ParsedObjectCacheOptions): ParsedObjectStore
ParameterTypeDescription
options.maxSize?numberByte budget via JSON.stringify length. Default 256 MiB.
options.ttl?numberEntry TTL in ms. Default 1 hour.

Returns: ParsedObjectStore

A generic in-memory LRU for any JS value, keyed however you like. See the parsed-object cache guide.

ParsedObjectStore — the returned interface:

interface ParsedObjectStore {
get<T extends object>(key: string): T | null;
set<T extends object>(key: string, value: T): void;
delete(key: string): void;
invalidatePrefix(prefix: string): void;
}
functiongetRepoCache
getRepoCache(ownerKey: string, repoName: string): object

Returns: object

The long-lived isomorphic-git packfile cache for a repo, created on first access. See Repo cache & init.

invalidateRepoCache(ownerKey: string, repoName: string): void

Drops a repo’s cached packfile state — call after any out-of-process storage rewrite.

functioninitBareRepo
initBareRepo(repo: Repo, defaultBranch?: string): Promise<void>
ParameterTypeDescription
defaultBranch?stringDefault "main".

Thin wrapper over git.init({ ...repo, bare: true }).

estimateRepoSize(repo: Repo, stat: (path: string) => Promise<{ size: number }>, list: (path: string) => Promise<string[]>): Promise<number>

Returns: Promise<number>

Sums .pack/loose-object file sizes under objects/. Can be expensive against remote storage — see the caution in Repo cache & init.

class GitEdgeError extends Error

Base class for every error this package throws.

class GitMergeConflictError extends GitEdgeError

Thrown only by threeWayMerge. Carries conflictingPaths: string[].

Export Shape
Repo { fs: FsClient; gitdir: string; cache?: object }
MergeOpts { message?, authorName?, authorEmail? }
MergeResult { commitOid: string }
MergeAnalysis { canMerge: boolean; fastForward: boolean; diverged: boolean }
ParsedObjectCacheOptions { maxSize?: number; ttl?: number }