@scolladon/tsgit 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -137
- package/dist/cjs/adapters/browser/index.cjs +1 -1
- package/dist/cjs/adapters/browser/index.cjs.map +1 -1
- package/dist/cjs/adapters/memory/index.cjs +1 -1
- package/dist/cjs/adapters/memory/index.cjs.map +1 -1
- package/dist/cjs/adapters/node/index.cjs +1 -1
- package/dist/cjs/adapters/node/index.cjs.map +1 -1
- package/dist/cjs/chunks/browser-http-transport-D4NH-8oJ.cjs +2 -0
- package/dist/cjs/chunks/browser-http-transport-D4NH-8oJ.cjs.map +1 -0
- package/dist/cjs/chunks/context-BcoAzPuU.cjs.map +1 -1
- package/dist/cjs/chunks/error-CDLOBdNU.cjs +2 -0
- package/dist/cjs/chunks/error-CDLOBdNU.cjs.map +1 -0
- package/dist/cjs/chunks/index-BVArBKuk.cjs +2 -0
- package/dist/cjs/chunks/index-BVArBKuk.cjs.map +1 -0
- package/dist/cjs/chunks/index-DE9HSiWf.cjs +2 -0
- package/dist/cjs/chunks/index-DE9HSiWf.cjs.map +1 -0
- package/dist/cjs/chunks/{logger-Cz9r6yt5.cjs → logger-CVG0zcPH.cjs} +2 -2
- package/dist/cjs/chunks/{logger-Cz9r6yt5.cjs.map → logger-CVG0zcPH.cjs.map} +1 -1
- package/dist/cjs/chunks/memory-http-transport-DXwDGKtR.cjs +2 -0
- package/dist/cjs/chunks/memory-http-transport-DXwDGKtR.cjs.map +1 -0
- package/dist/cjs/chunks/node-http-transport-vrbnNEDb.cjs +2 -0
- package/dist/cjs/chunks/node-http-transport-vrbnNEDb.cjs.map +1 -0
- package/dist/cjs/chunks/{progress-CK7CT9vU.cjs → progress-Bj2w-90A.cjs} +2 -2
- package/dist/cjs/chunks/{progress-CK7CT9vU.cjs.map → progress-Bj2w-90A.cjs.map} +1 -1
- package/dist/cjs/chunks/readable-stream-MTA6D0Zh.cjs +2 -0
- package/dist/cjs/chunks/readable-stream-MTA6D0Zh.cjs.map +1 -0
- package/dist/cjs/chunks/repository-BJwTSiGf.cjs +2 -0
- package/dist/cjs/chunks/repository-BJwTSiGf.cjs.map +1 -0
- package/dist/cjs/commands/index.cjs +1 -1
- package/dist/cjs/index.browser.cjs +1 -1
- package/dist/cjs/index.browser.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.default.cjs +1 -1
- package/dist/cjs/index.default.cjs.map +1 -1
- package/dist/cjs/index.node.cjs +1 -1
- package/dist/cjs/index.node.cjs.map +1 -1
- package/dist/cjs/operators/index.cjs +1 -1
- package/dist/cjs/operators/index.cjs.map +1 -1
- package/dist/cjs/primitives/index.cjs +1 -1
- package/dist/cjs/primitives/index.cjs.map +1 -1
- package/dist/cjs/transport/index.cjs.map +1 -1
- package/dist/esm/adapters/browser/index.js +1 -1
- package/dist/esm/adapters/browser/index.js.map +1 -1
- package/dist/esm/adapters/memory/index.js +1 -1
- package/dist/esm/adapters/memory/index.js.map +1 -1
- package/dist/esm/adapters/node/index.js +1 -1
- package/dist/esm/adapters/node/index.js.map +1 -1
- package/dist/esm/chunks/browser-http-transport-DL8bkNdg.js +2 -0
- package/dist/esm/chunks/browser-http-transport-DL8bkNdg.js.map +1 -0
- package/dist/esm/chunks/context-CumKOV7K.js.map +1 -1
- package/dist/esm/chunks/error-MOmSzp9Z.js +2 -0
- package/dist/esm/chunks/error-MOmSzp9Z.js.map +1 -0
- package/dist/esm/chunks/index-BjmofbKE.js +2 -0
- package/dist/esm/chunks/index-BjmofbKE.js.map +1 -0
- package/dist/esm/chunks/index-Jh5R-UmU.js +2 -0
- package/dist/esm/chunks/index-Jh5R-UmU.js.map +1 -0
- package/dist/esm/chunks/{logger-84ixEPbQ.js → logger-DP2cCpvL.js} +2 -2
- package/dist/esm/chunks/{logger-84ixEPbQ.js.map → logger-DP2cCpvL.js.map} +1 -1
- package/dist/esm/chunks/memory-http-transport-COJU6VOL.js +2 -0
- package/dist/esm/chunks/memory-http-transport-COJU6VOL.js.map +1 -0
- package/dist/esm/chunks/node-http-transport-DYCFIJbc.js +2 -0
- package/dist/esm/chunks/node-http-transport-DYCFIJbc.js.map +1 -0
- package/dist/esm/chunks/{progress-OTDhgmPO.js → progress-NePjO3Kd.js} +2 -2
- package/dist/esm/chunks/{progress-OTDhgmPO.js.map → progress-NePjO3Kd.js.map} +1 -1
- package/dist/esm/chunks/readable-stream-CGuf8k1J.js +2 -0
- package/dist/esm/chunks/readable-stream-CGuf8k1J.js.map +1 -0
- package/dist/esm/chunks/repository-Cs-dbHqO.js +2 -0
- package/dist/esm/chunks/repository-Cs-dbHqO.js.map +1 -0
- package/dist/esm/commands/index.js +1 -1
- package/dist/esm/index.browser.js +1 -1
- package/dist/esm/index.browser.js.map +1 -1
- package/dist/esm/index.default.js +1 -1
- package/dist/esm/index.default.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.node.js +1 -1
- package/dist/esm/index.node.js.map +1 -1
- package/dist/esm/operators/index.js +1 -1
- package/dist/esm/operators/index.js.map +1 -1
- package/dist/esm/primitives/index.js +1 -1
- package/dist/esm/primitives/index.js.map +1 -1
- package/dist/esm/transport/index.js.map +1 -1
- package/dist/types/adapters/browser/index.d.cts +2 -1
- package/dist/types/adapters/browser/index.d.ts +2 -1
- package/dist/types/adapters/memory/index.d.cts +23 -2
- package/dist/types/adapters/memory/index.d.ts +23 -2
- package/dist/types/adapters/node/index.d.cts +178 -3
- package/dist/types/adapters/node/index.d.ts +178 -3
- package/dist/types/chunks/{context-CTaXSPiP.d.ts → context-BORy7yXb.d.ts} +133 -20
- package/dist/types/chunks/{context-d36639-i.d.cts → context-CMrHCVwK.d.cts} +133 -20
- package/dist/types/chunks/reflog-entry-BIf-zt__.d.cts +331 -0
- package/dist/types/chunks/reflog-entry-D9P2hCgv.d.ts +331 -0
- package/dist/types/chunks/{repository-CFT9j9H6.d.cts → repository-BqibvTOu.d.cts} +23 -4
- package/dist/types/chunks/{repository-ntg7eXb2.d.ts → repository-C4rN09Am.d.ts} +23 -4
- package/dist/types/chunks/write-tree-B8G6kgTy.d.cts +154 -0
- package/dist/types/chunks/write-tree-BXCDChvv.d.ts +154 -0
- package/dist/types/commands/index.d.cts +229 -37
- package/dist/types/commands/index.d.ts +229 -37
- package/dist/types/index.browser.d.cts +4 -4
- package/dist/types/index.browser.d.ts +4 -4
- package/dist/types/index.d.cts +4 -4
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.default.d.cts +4 -4
- package/dist/types/index.default.d.ts +4 -4
- package/dist/types/index.node.d.cts +4 -4
- package/dist/types/index.node.d.ts +4 -4
- package/dist/types/operators/index.d.cts +17 -1
- package/dist/types/operators/index.d.ts +17 -1
- package/dist/types/primitives/index.d.cts +393 -171
- package/dist/types/primitives/index.d.ts +393 -171
- package/package.json +76 -10
- package/dist/cjs/chunks/browser-http-transport-BBF8uw-f.cjs +0 -2
- package/dist/cjs/chunks/browser-http-transport-BBF8uw-f.cjs.map +0 -1
- package/dist/cjs/chunks/error-DL4SHCBJ.cjs +0 -2
- package/dist/cjs/chunks/error-DL4SHCBJ.cjs.map +0 -1
- package/dist/cjs/chunks/error-DN8Vnwr4.cjs +0 -2
- package/dist/cjs/chunks/error-DN8Vnwr4.cjs.map +0 -1
- package/dist/cjs/chunks/index-iUd-bwwm.cjs +0 -2
- package/dist/cjs/chunks/index-iUd-bwwm.cjs.map +0 -1
- package/dist/cjs/chunks/memory-http-transport-DGll7Af4.cjs +0 -2
- package/dist/cjs/chunks/memory-http-transport-DGll7Af4.cjs.map +0 -1
- package/dist/cjs/chunks/merge-base-DlGWnkxP.cjs +0 -2
- package/dist/cjs/chunks/merge-base-DlGWnkxP.cjs.map +0 -1
- package/dist/cjs/chunks/node-http-transport-CuOgJlws.cjs +0 -2
- package/dist/cjs/chunks/node-http-transport-CuOgJlws.cjs.map +0 -1
- package/dist/cjs/chunks/repository-Cfo6Bj8T.cjs +0 -2
- package/dist/cjs/chunks/repository-Cfo6Bj8T.cjs.map +0 -1
- package/dist/esm/chunks/browser-http-transport-mZQKkInJ.js +0 -2
- package/dist/esm/chunks/browser-http-transport-mZQKkInJ.js.map +0 -1
- package/dist/esm/chunks/error-CnIcr6IG.js +0 -2
- package/dist/esm/chunks/error-CnIcr6IG.js.map +0 -1
- package/dist/esm/chunks/error-DTEP18A3.js +0 -2
- package/dist/esm/chunks/error-DTEP18A3.js.map +0 -1
- package/dist/esm/chunks/index-CJc-SKMj.js +0 -2
- package/dist/esm/chunks/index-CJc-SKMj.js.map +0 -1
- package/dist/esm/chunks/memory-http-transport-BmHjaEWj.js +0 -2
- package/dist/esm/chunks/memory-http-transport-BmHjaEWj.js.map +0 -1
- package/dist/esm/chunks/merge-base-DmuOYxfP.js +0 -2
- package/dist/esm/chunks/merge-base-DmuOYxfP.js.map +0 -1
- package/dist/esm/chunks/node-http-transport-Bz3noIS3.js +0 -2
- package/dist/esm/chunks/node-http-transport-Bz3noIS3.js.map +0 -1
- package/dist/esm/chunks/repository-qcX3-LkP.js +0 -2
- package/dist/esm/chunks/repository-qcX3-LkP.js.map +0 -1
- package/dist/types/chunks/diff-change-B09vxnxy.d.cts +0 -59
- package/dist/types/chunks/diff-change-D7xSeCn9.d.ts +0 -59
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { O as ObjectId, d as FilePath, b as Context, R as RefName, h as HookName } from './context-BORy7yXb.js';
|
|
2
|
+
import { F as FileMode, a as CatFileBatchOptions, C as CatFileBatchEntry, c as CreateCommitInput, D as DiffTreesInput, d as DiffTreesOptions, s as TreeDiff, R as ReadObjectOptions, B as Blob, G as GitObject, T as Tree, r as ResolveRefOptions, U as UpdateRefOptions, W as WalkCommitsOptions, b as Commit, v as WalkSubmodulesOptions, S as SubmoduleEntry, x as WalkTreeOptions, w as WalkTreeEntry, z as WalkWorkingTreeOptions, y as WalkWorkingTreeEntry, t as TreeEntry } from './reflog-entry-D9P2hCgv.js';
|
|
3
|
+
|
|
4
|
+
interface IndexEntryFlags {
|
|
5
|
+
readonly assumeValid: boolean;
|
|
6
|
+
readonly stage: 0 | 1 | 2 | 3;
|
|
7
|
+
/** Index v3 extended flag — the path is intentionally absent from the working tree. */
|
|
8
|
+
readonly skipWorktree: boolean;
|
|
9
|
+
/** Index v3 extended flag — `git add -N` placeholder. Modelled for faithful round-tripping. */
|
|
10
|
+
readonly intentToAdd: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface IndexEntry {
|
|
13
|
+
readonly ctimeSeconds: number;
|
|
14
|
+
readonly ctimeNanoseconds: number;
|
|
15
|
+
readonly mtimeSeconds: number;
|
|
16
|
+
readonly mtimeNanoseconds: number;
|
|
17
|
+
readonly dev: number;
|
|
18
|
+
readonly ino: number;
|
|
19
|
+
readonly mode: FileMode;
|
|
20
|
+
readonly uid: number;
|
|
21
|
+
readonly gid: number;
|
|
22
|
+
readonly fileSize: number;
|
|
23
|
+
readonly id: ObjectId;
|
|
24
|
+
readonly flags: IndexEntryFlags;
|
|
25
|
+
readonly path: FilePath;
|
|
26
|
+
}
|
|
27
|
+
interface IndexExtension {
|
|
28
|
+
readonly signature: string;
|
|
29
|
+
readonly data: Uint8Array;
|
|
30
|
+
}
|
|
31
|
+
interface GitIndex {
|
|
32
|
+
readonly version: 2 | 3;
|
|
33
|
+
readonly entries: ReadonlyArray<IndexEntry>;
|
|
34
|
+
readonly extensions: ReadonlyArray<IndexExtension>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare function catFileBatch(ctx: Context, ids: AsyncIterable<ObjectId> | Iterable<ObjectId>, options?: CatFileBatchOptions): AsyncIterable<CatFileBatchEntry>;
|
|
38
|
+
|
|
39
|
+
declare function createCommit(ctx: Context, input: CreateCommitInput): Promise<ObjectId>;
|
|
40
|
+
|
|
41
|
+
declare function diffTrees(ctx: Context, a: DiffTreesInput, b: DiffTreesInput, options?: DiffTreesOptions): Promise<TreeDiff>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Compute a merge base — the first commit reachable from BOTH `a` and `b`.
|
|
45
|
+
*
|
|
46
|
+
* Algorithm: bidirectional BFS with two visited sets. After each layer
|
|
47
|
+
* advance, check the intersection. When non-empty, return the
|
|
48
|
+
* lexicographically smallest oid (deterministic tie-breaker).
|
|
49
|
+
*
|
|
50
|
+
* Returns `undefined` for unrelated histories. Documented limitation: cherry-picks
|
|
51
|
+
* and criss-cross merges may yield non-optimal bases — `recursive`-strategy
|
|
52
|
+
* multi-base resolution is v2.
|
|
53
|
+
*/
|
|
54
|
+
declare const mergeBase: (ctx: Context, a: ObjectId, b: ObjectId) => Promise<ObjectId | undefined>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Pure path helpers composing `ctx.layout.gitDir` with known sub-paths.
|
|
58
|
+
* No I/O. No port access. Primitive step 3.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Repository working-tree root. Returns the workDir from the current context;
|
|
63
|
+
* facade-tier code is responsible for discovery / realpath pinning
|
|
64
|
+
* at construction time. Primitives consume the already-resolved path.
|
|
65
|
+
*/
|
|
66
|
+
declare const getRepoRoot: (ctx: Context) => FilePath;
|
|
67
|
+
declare const sparseCheckoutPath: (gitDir: string) => string;
|
|
68
|
+
|
|
69
|
+
declare function readBlob(ctx: Context, id: ObjectId, options?: ReadObjectOptions): Promise<Blob>;
|
|
70
|
+
|
|
71
|
+
declare function readIndex(ctx: Context): Promise<GitIndex>;
|
|
72
|
+
|
|
73
|
+
declare function readObject(ctx: Context, id: ObjectId, options?: ReadObjectOptions): Promise<GitObject>;
|
|
74
|
+
|
|
75
|
+
declare function readTree(ctx: Context, ref: RefName | ObjectId): Promise<Tree>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The single reflog *writer*. Self-contained: reads config, applies the gate,
|
|
79
|
+
* resolves identity, sanitises the message, and appends one entry. Callers
|
|
80
|
+
* supply only a human-readable message.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Append a reflog entry for `ref` if logging applies. A no-op when the gate is
|
|
85
|
+
* closed for `ref` — once a reflog file exists every update appends to it,
|
|
86
|
+
* otherwise the `core.logAllRefUpdates` prefix rule decides.
|
|
87
|
+
*/
|
|
88
|
+
declare function recordRefUpdate(ctx: Context, ref: RefName, oldId: ObjectId, newId: ObjectId, message: string): Promise<void>;
|
|
89
|
+
|
|
90
|
+
declare function resolveRef(ctx: Context, name: RefName | 'HEAD', options?: ResolveRefOptions): Promise<ObjectId>;
|
|
91
|
+
|
|
92
|
+
/** Optional arguments and stdin a caller threads into a hook invocation. */
|
|
93
|
+
interface HookInput {
|
|
94
|
+
readonly args?: ReadonlyArray<string>;
|
|
95
|
+
readonly stdin?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Run a named git hook through `ctx.hooks`. A no-op when no `HookRunner` is
|
|
99
|
+
* wired (browser, or opted out), when the hook file is absent / not executable
|
|
100
|
+
* (`skipped`), or when the hook exits 0. Throws `HOOK_FAILED` on a non-zero
|
|
101
|
+
* exit.
|
|
102
|
+
*/
|
|
103
|
+
declare const runHook: (ctx: Context, name: HookName, input?: HookInput) => Promise<void>;
|
|
104
|
+
|
|
105
|
+
declare function updateRef(ctx: Context, name: RefName, newId: ObjectId, options: UpdateRefOptions): Promise<void>;
|
|
106
|
+
|
|
107
|
+
declare function walkCommits(ctx: Context, options: WalkCommitsOptions): AsyncIterable<Commit>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Yield every gitlink reachable in `ref`'s tree, joined with its `.gitmodules`
|
|
111
|
+
* metadata. With `recursive: true`, descend into each nested submodule whose
|
|
112
|
+
* absorbed gitdir (`${gitDir}/modules/<name>`) is locally available; nested
|
|
113
|
+
* yields carry `depth >= 1` and a `parent` path. Uninitialised / missing /
|
|
114
|
+
* cyclic nested submodules contribute their own entry but no children — the
|
|
115
|
+
* absence of further yields is the signal, matching `git submodule status
|
|
116
|
+
* --recursive`.
|
|
117
|
+
*/
|
|
118
|
+
declare function walkSubmodules(ctx: Context, options?: WalkSubmodulesOptions): AsyncIterable<SubmoduleEntry>;
|
|
119
|
+
|
|
120
|
+
declare function walkTree(ctx: Context, treeIdOrObject: ObjectId | Tree, options?: WalkTreeOptions): AsyncIterable<WalkTreeEntry>;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Depth-first walk of the working tree starting at `ctx.layout.workDir`.
|
|
124
|
+
*
|
|
125
|
+
* Yields leaf entries (files and symlinks) as `{ path, stat }`. Directories
|
|
126
|
+
* are descended into, not yielded. `.git` at any level is skipped
|
|
127
|
+
* (case-insensitive, NTFS-trimmed). Embedded repositories (directories
|
|
128
|
+
* containing a `.git` child) are skipped entirely — yields nothing under
|
|
129
|
+
* them. Symlinks are surfaced via `lstat` (no follow); a symlink to a
|
|
130
|
+
* directory is yielded as a leaf, not descended into.
|
|
131
|
+
*
|
|
132
|
+
* The host repository's own `.git` is NOT treated as an embedded-repo
|
|
133
|
+
* marker — at the workDir root we only skip the `.git` entry itself, not
|
|
134
|
+
* the workDir.
|
|
135
|
+
*/
|
|
136
|
+
declare function walkWorkingTree(ctx: Context, options?: WalkWorkingTreeOptions): AsyncIterable<WalkWorkingTreeEntry>;
|
|
137
|
+
|
|
138
|
+
declare function writeObject(ctx: Context, object: GitObject): Promise<ObjectId>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Write a symbolic ref atomically. Used for HEAD updates that point at a
|
|
142
|
+
* branch, branch renames affecting the current HEAD, and `clone`/`init`
|
|
143
|
+
* to set the initial HEAD.
|
|
144
|
+
*
|
|
145
|
+
* Single-level only in v1: target MUST be a direct ref name (no chained
|
|
146
|
+
* symrefs). Validation runs through `validateRefName` for both `name` and
|
|
147
|
+
* `target` — invalid inputs throw INVALID_REF before any I/O.
|
|
148
|
+
*/
|
|
149
|
+
declare const writeSymbolicRef: (ctx: Context, name: RefName, target: RefName) => Promise<void>;
|
|
150
|
+
|
|
151
|
+
declare function writeTree(ctx: Context, entries: ReadonlyArray<TreeEntry>): Promise<ObjectId>;
|
|
152
|
+
|
|
153
|
+
export { createCommit as a, readIndex as b, catFileBatch as c, diffTrees as d, readObject as e, readTree as f, getRepoRoot as g, recordRefUpdate as h, resolveRef as i, runHook as j, walkSubmodules as k, walkTree as l, mergeBase as m, walkWorkingTree as n, writeObject as o, writeSymbolicRef as p, writeTree as q, readBlob as r, sparseCheckoutPath as s, updateRef as u, walkCommits as w };
|
|
154
|
+
export type { GitIndex as G, HookInput as H, IndexEntry as I };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as FilePath, b as Context, R as RefName, O as ObjectId } from '../chunks/context-
|
|
2
|
-
import { A as AuthorIdentity,
|
|
1
|
+
import { d as FilePath, b as Context, R as RefName, O as ObjectId, m as PromisorRemote } from '../chunks/context-CMrHCVwK.cjs';
|
|
2
|
+
import { C as CatFileBatchEntry, A as AuthorIdentity, s as TreeDiff, q as ReflogEntry, S as SubmoduleEntry } from '../chunks/reflog-entry-BIf-zt__.cjs';
|
|
3
3
|
import '../chunks/http-transport-DirKfK2S.cjs';
|
|
4
4
|
|
|
5
5
|
interface AddOptions {
|
|
@@ -13,14 +13,17 @@ interface AddResult {
|
|
|
13
13
|
readonly removed: ReadonlyArray<FilePath>;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
* 1. Repo + bare + pending-op preflight checks.
|
|
18
|
-
* 2. Path validation for every input (no I/O on rejection).
|
|
19
|
-
* 3. Read working-tree contents → write blob → produce IndexEntry.
|
|
20
|
-
* 4. Atomically replace `.git/index` under the index lock.
|
|
16
|
+
* Stage paths in the index. Two modes:
|
|
21
17
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
18
|
+
* - **Literal-path mode** (`paths` non-empty, `all` falsy): every path is
|
|
19
|
+
* validated, read, hashed, and staged. Missing paths reject the whole call.
|
|
20
|
+
* - **Bulk mode** (`paths` empty, `all === true`): walk the working tree,
|
|
21
|
+
* stage every modified/new tracked file plus every untracked, non-ignored
|
|
22
|
+
* file. Files missing from disk but present in the prior index land in
|
|
23
|
+
* `removed`. `.git` and embedded repositories are skipped.
|
|
24
|
+
*
|
|
25
|
+
* Both modes acquire `.git/index.lock` once, read the existing index under
|
|
26
|
+
* the lock, and commit a single replacement — no partial writes.
|
|
24
27
|
*/
|
|
25
28
|
declare const add: (ctx: Context, paths: ReadonlyArray<string>, opts?: AddOptions) => Promise<AddResult>;
|
|
26
29
|
|
|
@@ -63,15 +66,45 @@ type BranchResult = {
|
|
|
63
66
|
};
|
|
64
67
|
declare const branch: (ctx: Context, action: BranchAction) => Promise<BranchResult>;
|
|
65
68
|
|
|
66
|
-
|
|
69
|
+
type ConflictType = 'content' | 'add-add' | 'modify-delete' | 'type-change' | 'rename-rename' | 'gitlink' | 'binary';
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Tier-1 `catFile` command — wraps the streaming `catFileBatch` primitive in
|
|
73
|
+
* a request/response shape matching the other v2 commands (`submodules`,
|
|
74
|
+
* `log`, `reflog`). String ids are coerced at the boundary via
|
|
75
|
+
* `ObjectId.from`, which throws `INVALID_OBJECT_ID` on malformed input
|
|
76
|
+
* before any read happens.
|
|
77
|
+
*
|
|
78
|
+
* For streaming use cases, callers reach for `repo.primitives.catFileBatch`
|
|
79
|
+
* directly — see `docs/design/cat-file-batch.md` §2.
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
interface CatFileInput {
|
|
83
|
+
readonly ids: ReadonlyArray<ObjectId | string>;
|
|
84
|
+
/** Per-object byte cap; forwarded to the underlying `readObject` call. */
|
|
85
|
+
readonly maxBytes?: number;
|
|
86
|
+
}
|
|
87
|
+
interface CatFileResult {
|
|
88
|
+
readonly kind: 'batch';
|
|
89
|
+
readonly entries: ReadonlyArray<CatFileBatchEntry>;
|
|
90
|
+
}
|
|
91
|
+
declare const catFile: (ctx: Context, opts: CatFileInput) => Promise<CatFileResult>;
|
|
92
|
+
|
|
93
|
+
interface CheckoutSwitchOptions {
|
|
67
94
|
readonly target: string;
|
|
68
95
|
readonly detach?: boolean;
|
|
69
96
|
readonly force?: boolean;
|
|
70
97
|
}
|
|
98
|
+
interface CheckoutPathsOptions {
|
|
99
|
+
readonly paths: ReadonlyArray<string>;
|
|
100
|
+
readonly source?: 'index' | 'HEAD' | ObjectId;
|
|
101
|
+
}
|
|
102
|
+
type CheckoutOptions = CheckoutSwitchOptions | CheckoutPathsOptions;
|
|
71
103
|
interface CheckoutResult {
|
|
72
104
|
readonly branch: RefName | undefined;
|
|
73
105
|
readonly id: ObjectId;
|
|
74
106
|
readonly detached: boolean;
|
|
107
|
+
readonly changedPaths: number;
|
|
75
108
|
}
|
|
76
109
|
declare const checkout: (ctx: Context, opts: CheckoutOptions) => Promise<CheckoutResult>;
|
|
77
110
|
|
|
@@ -82,11 +115,21 @@ interface CloneOptions {
|
|
|
82
115
|
readonly url: string;
|
|
83
116
|
readonly bare?: boolean;
|
|
84
117
|
readonly initialBranch?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Shallow clone depth. When set, sends `deepen N` and persists the
|
|
120
|
+
* resulting shallow boundaries to `.git/shallow`.
|
|
121
|
+
*/
|
|
85
122
|
readonly depth?: number;
|
|
86
123
|
/** DNS resolver injected by the caller; required to enforce SSRF guards. */
|
|
87
124
|
readonly resolver?: DnsResolver;
|
|
88
125
|
readonly allowInsecure?: boolean;
|
|
89
126
|
readonly allowPrivateNetworks?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Partial-clone object filter (`blob:none`, `blob:limit=<n>`, `tree:<n>`).
|
|
129
|
+
* When set, the server omits the filtered objects, a promisor remote is
|
|
130
|
+
* recorded in `.git/config`, and omitted objects are lazy-fetched on read.
|
|
131
|
+
*/
|
|
132
|
+
readonly filter?: string;
|
|
90
133
|
}
|
|
91
134
|
interface CloneResult {
|
|
92
135
|
readonly path: FilePath;
|
|
@@ -104,6 +147,8 @@ interface CommitOptions {
|
|
|
104
147
|
readonly committer?: AuthorIdentity;
|
|
105
148
|
readonly allowEmpty?: boolean;
|
|
106
149
|
readonly allowEmptyMessage?: boolean;
|
|
150
|
+
/** Skip the `pre-commit` and `commit-msg` hooks (git's `--no-verify`). */
|
|
151
|
+
readonly noVerify?: boolean;
|
|
107
152
|
}
|
|
108
153
|
interface CommitResult {
|
|
109
154
|
readonly id: ObjectId;
|
|
@@ -139,18 +184,51 @@ interface FetchOptions {
|
|
|
139
184
|
readonly remote?: string;
|
|
140
185
|
readonly refspecs?: ReadonlyArray<string>;
|
|
141
186
|
readonly prune?: boolean;
|
|
187
|
+
/** Shallow clone depth. Delegates to fetchPack's deepen path. */
|
|
188
|
+
readonly depth?: number;
|
|
189
|
+
}
|
|
190
|
+
interface FetchUpdate {
|
|
191
|
+
readonly name: RefName;
|
|
192
|
+
readonly oldId: ObjectId | undefined;
|
|
193
|
+
readonly newId: ObjectId;
|
|
142
194
|
}
|
|
143
195
|
interface FetchResult {
|
|
144
196
|
readonly remote: string;
|
|
145
197
|
readonly url: string;
|
|
146
|
-
readonly updatedRefs: ReadonlyArray<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
198
|
+
readonly updatedRefs: ReadonlyArray<FetchUpdate>;
|
|
199
|
+
/** Refs deleted because the server no longer advertises them (prune semantics). */
|
|
200
|
+
readonly prunedRefs: ReadonlyArray<RefName>;
|
|
201
|
+
/** New shallow boundaries written to `.git/shallow` during this fetch. */
|
|
202
|
+
readonly shallow: ReadonlyArray<ObjectId>;
|
|
203
|
+
/** Commits that crossed the shallow → non-shallow boundary during this fetch. */
|
|
204
|
+
readonly unshallow: ReadonlyArray<ObjectId>;
|
|
151
205
|
}
|
|
152
206
|
declare const fetch: (ctx: Context, opts?: FetchOptions) => Promise<FetchResult>;
|
|
153
207
|
|
|
208
|
+
interface FetchMissingOptions {
|
|
209
|
+
/** Object ids to fetch. Ones already present locally are skipped. */
|
|
210
|
+
readonly oids: ReadonlyArray<ObjectId>;
|
|
211
|
+
}
|
|
212
|
+
interface FetchMissingResult {
|
|
213
|
+
/** The promisor remote the objects were fetched from. */
|
|
214
|
+
readonly remote: string;
|
|
215
|
+
/** Objects the caller asked for. */
|
|
216
|
+
readonly requested: number;
|
|
217
|
+
/** Objects that were missing locally and got fetched. */
|
|
218
|
+
readonly fetched: number;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Fetch the named objects from the repository's promisor remote. Throws
|
|
222
|
+
* `NO_PROMISOR_REMOTE` when the repository is not a partial clone.
|
|
223
|
+
*/
|
|
224
|
+
declare const fetchMissing: (ctx: Context, opts: FetchMissingOptions) => Promise<FetchMissingResult>;
|
|
225
|
+
/**
|
|
226
|
+
* `PromisorRemote` port implementation — the seam `readObject` calls on a
|
|
227
|
+
* miss. A non-partial repository yields `attempted: false` (rather than
|
|
228
|
+
* throwing) so `readObject` falls through to its normal `OBJECT_NOT_FOUND`.
|
|
229
|
+
*/
|
|
230
|
+
declare const createPromisorRemote: (ctx: Context) => PromisorRemote;
|
|
231
|
+
|
|
154
232
|
interface InitOptions {
|
|
155
233
|
readonly initialBranch?: string;
|
|
156
234
|
readonly bare?: boolean;
|
|
@@ -167,7 +245,7 @@ interface InitResult {
|
|
|
167
245
|
*
|
|
168
246
|
* For non-bare repos, the gitDir is `<workDir>/.git`. For bare, gitDir IS the
|
|
169
247
|
* working dir — callers must construct a Context with `bare: true` for that
|
|
170
|
-
* shape
|
|
248
|
+
* shape.
|
|
171
249
|
*/
|
|
172
250
|
declare const init: (ctx: Context, opts?: InitOptions) => Promise<InitResult>;
|
|
173
251
|
|
|
@@ -200,6 +278,10 @@ interface MergeOptions {
|
|
|
200
278
|
readonly author?: AuthorIdentity;
|
|
201
279
|
readonly committer?: AuthorIdentity;
|
|
202
280
|
}
|
|
281
|
+
interface MergeConflictDescriptor {
|
|
282
|
+
readonly path: FilePath;
|
|
283
|
+
readonly type: ConflictType;
|
|
284
|
+
}
|
|
203
285
|
type MergeResult = {
|
|
204
286
|
readonly kind: 'up-to-date';
|
|
205
287
|
readonly id: ObjectId;
|
|
@@ -212,14 +294,24 @@ type MergeResult = {
|
|
|
212
294
|
readonly id: ObjectId;
|
|
213
295
|
readonly branch: RefName;
|
|
214
296
|
readonly parents: ReadonlyArray<ObjectId>;
|
|
297
|
+
} | {
|
|
298
|
+
readonly kind: 'conflict';
|
|
299
|
+
readonly conflicts: ReadonlyArray<MergeConflictDescriptor>;
|
|
300
|
+
readonly mergeHead: ObjectId;
|
|
301
|
+
readonly origHead: ObjectId;
|
|
215
302
|
};
|
|
216
303
|
/**
|
|
217
|
-
* Merge `target` into the current HEAD branch.
|
|
218
|
-
*
|
|
219
|
-
* -
|
|
220
|
-
* -
|
|
221
|
-
*
|
|
222
|
-
*
|
|
304
|
+
* Merge `target` into the current HEAD branch.
|
|
305
|
+
*
|
|
306
|
+
* - Up-to-date: target is ancestor of HEAD → no-op.
|
|
307
|
+
* - Fast-forward: HEAD is ancestor of target → branch advances.
|
|
308
|
+
* - True merge for diverged histories:.4a wired the three-way
|
|
309
|
+
* tree merge (`mergeTrees` + `mergeContent`) so a CLEAN merge commits
|
|
310
|
+
* the merged tree directly.4b persists conflict state on
|
|
311
|
+
* disk (marker files, stage-1/2/3 index entries, MERGE_HEAD /
|
|
312
|
+
* MERGE_MSG / ORIG_HEAD) and returns `{ kind: 'conflict',... }`.
|
|
313
|
+
* Resolution path: edit the marker files, `repo.add(paths)`,
|
|
314
|
+
* `repo.commit({ message })` — the resulting commit has two parents.
|
|
223
315
|
*/
|
|
224
316
|
declare const merge: (ctx: Context, opts: MergeOptions) => Promise<MergeResult>;
|
|
225
317
|
|
|
@@ -228,18 +320,64 @@ interface PushOptions {
|
|
|
228
320
|
readonly refspecs?: ReadonlyArray<string>;
|
|
229
321
|
readonly force?: boolean;
|
|
230
322
|
readonly forceWithLease?: ObjectId | 'auto';
|
|
323
|
+
/** Skip the `pre-push` hook (git's `--no-verify`). */
|
|
324
|
+
readonly noVerify?: boolean;
|
|
325
|
+
}
|
|
326
|
+
interface PushedRef {
|
|
327
|
+
readonly name: RefName;
|
|
328
|
+
readonly oldId: ObjectId;
|
|
329
|
+
readonly newId: ObjectId;
|
|
330
|
+
readonly status: 'ok' | 'rejected';
|
|
331
|
+
readonly reason?: string;
|
|
231
332
|
}
|
|
232
333
|
interface PushResult {
|
|
233
334
|
readonly remote: string;
|
|
234
335
|
readonly url: string;
|
|
235
|
-
readonly pushedRefs: ReadonlyArray<
|
|
236
|
-
readonly name: RefName;
|
|
237
|
-
readonly newId: ObjectId;
|
|
238
|
-
readonly status: 'ok' | 'rejected';
|
|
239
|
-
}>;
|
|
336
|
+
readonly pushedRefs: ReadonlyArray<PushedRef>;
|
|
240
337
|
}
|
|
241
338
|
declare const push: (ctx: Context, opts?: PushOptions) => Promise<PushResult>;
|
|
242
339
|
|
|
340
|
+
type ReflogAction = {
|
|
341
|
+
readonly action?: 'show';
|
|
342
|
+
readonly ref?: string;
|
|
343
|
+
} | {
|
|
344
|
+
readonly action: 'exists';
|
|
345
|
+
readonly ref: string;
|
|
346
|
+
} | {
|
|
347
|
+
readonly action: 'delete';
|
|
348
|
+
readonly ref: string;
|
|
349
|
+
readonly index: number;
|
|
350
|
+
readonly rewrite?: boolean;
|
|
351
|
+
} | {
|
|
352
|
+
readonly action: 'expire';
|
|
353
|
+
readonly ref?: string;
|
|
354
|
+
readonly all?: boolean;
|
|
355
|
+
readonly expire?: string;
|
|
356
|
+
readonly expireUnreachable?: string;
|
|
357
|
+
};
|
|
358
|
+
/** One reflog entry as `show` presents it: newest-first, with a selector. */
|
|
359
|
+
interface ReflogShowEntry {
|
|
360
|
+
readonly index: number;
|
|
361
|
+
readonly selector: string;
|
|
362
|
+
readonly entry: ReflogEntry;
|
|
363
|
+
}
|
|
364
|
+
type ReflogResult = {
|
|
365
|
+
readonly kind: 'show';
|
|
366
|
+
readonly ref: RefName;
|
|
367
|
+
readonly entries: ReadonlyArray<ReflogShowEntry>;
|
|
368
|
+
} | {
|
|
369
|
+
readonly kind: 'exists';
|
|
370
|
+
readonly exists: boolean;
|
|
371
|
+
} | {
|
|
372
|
+
readonly kind: 'expire';
|
|
373
|
+
readonly removed: number;
|
|
374
|
+
readonly kept: number;
|
|
375
|
+
} | {
|
|
376
|
+
readonly kind: 'delete';
|
|
377
|
+
readonly removed: ReflogEntry;
|
|
378
|
+
};
|
|
379
|
+
declare const reflog: (ctx: Context, opts?: ReflogAction) => Promise<ReflogResult>;
|
|
380
|
+
|
|
243
381
|
type ResetMode = 'soft' | 'mixed' | 'hard';
|
|
244
382
|
interface ResetOptions {
|
|
245
383
|
readonly mode: ResetMode;
|
|
@@ -253,13 +391,18 @@ interface ResetResult {
|
|
|
253
391
|
/**
|
|
254
392
|
* Reset HEAD (and optionally index/working tree) to `target`.
|
|
255
393
|
*
|
|
256
|
-
* - `soft`:
|
|
257
|
-
* - `mixed`: HEAD +
|
|
258
|
-
*
|
|
394
|
+
* - `soft`: HEAD only.
|
|
395
|
+
* - `mixed`: HEAD + rebuild the index from the target commit's tree
|
|
396
|
+
* (stat-cache donor strategy preserves cache for unchanged paths —
|
|
397
|
+
* ). Working tree is NOT touched.
|
|
398
|
+
* - `hard`: HEAD + index + working tree — materialise the target tree onto
|
|
399
|
+
* the working tree with `force: true`, then commit the post-write
|
|
400
|
+
* index entries. Bare repos are rejected upfront.
|
|
259
401
|
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
402
|
+
* Ordering: working tree → index → HEAD. The index lock wraps both the
|
|
403
|
+
* working-tree write AND the index commit, matching tightened
|
|
404
|
+
* pattern. A crash between the index commit and HEAD update leaves the index
|
|
405
|
+
* ahead of HEAD — same recoverable hazard as canonical git.
|
|
263
406
|
*/
|
|
264
407
|
declare const reset: (ctx: Context, opts: ResetOptions) => Promise<ResetResult>;
|
|
265
408
|
|
|
@@ -278,6 +421,37 @@ interface RmResult {
|
|
|
278
421
|
*/
|
|
279
422
|
declare const rm: (ctx: Context, paths: ReadonlyArray<string>, opts?: RmOptions) => Promise<RmResult>;
|
|
280
423
|
|
|
424
|
+
type SparseCheckoutAction = {
|
|
425
|
+
readonly action: 'list';
|
|
426
|
+
} | {
|
|
427
|
+
readonly action: 'set';
|
|
428
|
+
readonly patterns: ReadonlyArray<string>;
|
|
429
|
+
readonly cone?: boolean;
|
|
430
|
+
readonly force?: boolean;
|
|
431
|
+
} | {
|
|
432
|
+
readonly action: 'add';
|
|
433
|
+
readonly patterns: ReadonlyArray<string>;
|
|
434
|
+
readonly force?: boolean;
|
|
435
|
+
} | {
|
|
436
|
+
readonly action: 'reapply';
|
|
437
|
+
readonly force?: boolean;
|
|
438
|
+
} | {
|
|
439
|
+
readonly action: 'disable';
|
|
440
|
+
readonly force?: boolean;
|
|
441
|
+
};
|
|
442
|
+
type SparseCheckoutResult = {
|
|
443
|
+
readonly kind: 'list';
|
|
444
|
+
readonly cone: boolean;
|
|
445
|
+
readonly patterns: ReadonlyArray<string>;
|
|
446
|
+
} | {
|
|
447
|
+
readonly kind: 'applied';
|
|
448
|
+
readonly cone: boolean;
|
|
449
|
+
readonly materialized: number;
|
|
450
|
+
readonly removed: number;
|
|
451
|
+
readonly retained: ReadonlyArray<FilePath>;
|
|
452
|
+
};
|
|
453
|
+
declare const sparseCheckout: (ctx: Context, opts: SparseCheckoutAction) => Promise<SparseCheckoutResult>;
|
|
454
|
+
|
|
281
455
|
type ChangeKind = 'modified' | 'added' | 'deleted' | 'untracked';
|
|
282
456
|
interface ChangeEntry {
|
|
283
457
|
readonly kind: ChangeKind;
|
|
@@ -293,10 +467,10 @@ interface StatusResult {
|
|
|
293
467
|
/**
|
|
294
468
|
* Summarize the state of the working tree relative to the index, and the
|
|
295
469
|
* branch HEAD points at. Working-tree-vs-HEAD diff (Git's "staged" column)
|
|
296
|
-
* is approximated via index-vs-working-tree comparisons until
|
|
470
|
+
* is approximated via index-vs-working-tree comparisons until
|
|
297
471
|
* adds the stat-cache fast path.
|
|
298
472
|
*
|
|
299
|
-
* Progress reporting
|
|
473
|
+
* Progress reporting: emits `status:scan` start before the
|
|
300
474
|
* fan-out, updates at every 100 lstat completions, and end in a finally
|
|
301
475
|
* block so the consumer always pairs start with end. `total` is undefined
|
|
302
476
|
* — design choice that prevents revealing repository size to non-trusted
|
|
@@ -304,6 +478,24 @@ interface StatusResult {
|
|
|
304
478
|
*/
|
|
305
479
|
declare const status: (ctx: Context) => Promise<StatusResult>;
|
|
306
480
|
|
|
481
|
+
type SubmodulesAction = {
|
|
482
|
+
readonly action?: 'list';
|
|
483
|
+
/** Tree-ish to walk. Default: `'HEAD'`. */
|
|
484
|
+
readonly ref?: string;
|
|
485
|
+
/** Descend into nested submodules' own `.gitmodules`. Default: `false`. */
|
|
486
|
+
readonly recursive?: boolean;
|
|
487
|
+
/**
|
|
488
|
+
* Cap on recursion depth. Default: `MAX_SUBMODULE_DEPTH`. Entries at exactly
|
|
489
|
+
* this depth are yielded but not recursed into.
|
|
490
|
+
*/
|
|
491
|
+
readonly maxDepth?: number;
|
|
492
|
+
};
|
|
493
|
+
type SubmodulesResult = {
|
|
494
|
+
readonly kind: 'list';
|
|
495
|
+
readonly entries: ReadonlyArray<SubmoduleEntry>;
|
|
496
|
+
};
|
|
497
|
+
declare const submodules: (ctx: Context, opts?: SubmodulesAction) => Promise<SubmodulesResult>;
|
|
498
|
+
|
|
307
499
|
type TagAction = {
|
|
308
500
|
readonly kind: 'list';
|
|
309
501
|
} | {
|
|
@@ -332,5 +524,5 @@ type TagResult = {
|
|
|
332
524
|
};
|
|
333
525
|
declare const tag: (ctx: Context, action: TagAction) => Promise<TagResult>;
|
|
334
526
|
|
|
335
|
-
export { add, branch, checkout, clone, commit, diff, fetch, init, log, merge, push, reset, revParse, rm, status, tag };
|
|
336
|
-
export type { AddOptions, AddResult, BranchAction, BranchInfo, BranchResult, ChangeEntry, ChangeKind, CheckoutOptions, CheckoutResult, CloneOptions, CloneResult, CommitOptions, CommitResult, DiffOptions, FetchOptions, FetchResult, InitOptions, InitResult, LogEntry, LogOptions, MergeOptions, MergeResult, PushOptions, PushResult, ResetMode, ResetOptions, ResetResult, RmOptions, RmResult, StatusResult, TagAction, TagInfo, TagResult };
|
|
527
|
+
export { CatFileBatchEntry, SubmoduleEntry, add, branch, catFile, checkout, clone, commit, createPromisorRemote, diff, fetch, fetchMissing, init, log, merge, push, reflog, reset, revParse, rm, sparseCheckout, status, submodules, tag };
|
|
528
|
+
export type { AddOptions, AddResult, BranchAction, BranchInfo, BranchResult, CatFileInput, CatFileResult, ChangeEntry, ChangeKind, CheckoutOptions, CheckoutResult, CloneOptions, CloneResult, CommitOptions, CommitResult, DiffOptions, FetchMissingOptions, FetchMissingResult, FetchOptions, FetchResult, InitOptions, InitResult, LogEntry, LogOptions, MergeOptions, MergeResult, PushOptions, PushResult, ReflogAction, ReflogResult, ReflogShowEntry, ResetMode, ResetOptions, ResetResult, RmOptions, RmResult, SparseCheckoutAction, SparseCheckoutResult, StatusResult, SubmodulesAction, SubmodulesResult, TagAction, TagInfo, TagResult };
|