@scolladon/tsgit 0.9.0 → 1.1.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 +116 -1
- 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-BBF8uw-f.cjs → browser-http-transport-DcG05jw3.cjs} +2 -2
- package/dist/cjs/chunks/{browser-http-transport-BBF8uw-f.cjs.map → browser-http-transport-DcG05jw3.cjs.map} +1 -1
- package/dist/cjs/chunks/context-BcoAzPuU.cjs.map +1 -1
- package/dist/cjs/chunks/error-CqLvhejR.cjs +2 -0
- package/dist/cjs/chunks/error-CqLvhejR.cjs.map +1 -0
- package/dist/cjs/chunks/index-BcxdLkNe.cjs +2 -0
- package/dist/cjs/chunks/index-BcxdLkNe.cjs.map +1 -0
- package/dist/cjs/chunks/index-D5Nd-Mks.cjs +2 -0
- package/dist/cjs/chunks/index-D5Nd-Mks.cjs.map +1 -0
- package/dist/cjs/chunks/{logger-Cz9r6yt5.cjs → logger-C8Z5BfFF.cjs} +2 -2
- package/dist/cjs/chunks/{logger-Cz9r6yt5.cjs.map → logger-C8Z5BfFF.cjs.map} +1 -1
- package/dist/cjs/chunks/memory-http-transport-Pjyme5KN.cjs +2 -0
- package/dist/cjs/chunks/memory-http-transport-Pjyme5KN.cjs.map +1 -0
- package/dist/cjs/chunks/node-http-transport-UkW5eEm3.cjs +2 -0
- package/dist/cjs/chunks/node-http-transport-UkW5eEm3.cjs.map +1 -0
- package/dist/cjs/chunks/{progress-CK7CT9vU.cjs → progress-CntEbiuo.cjs} +2 -2
- package/dist/cjs/chunks/{progress-CK7CT9vU.cjs.map → progress-CntEbiuo.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-B_jx2AKW.cjs +2 -0
- package/dist/cjs/chunks/repository-B_jx2AKW.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-CRPPmib5.js → browser-http-transport-COFgnEyq.js} +2 -2
- package/dist/esm/chunks/{browser-http-transport-CRPPmib5.js.map → browser-http-transport-COFgnEyq.js.map} +1 -1
- package/dist/esm/chunks/context-CumKOV7K.js.map +1 -1
- package/dist/esm/chunks/error-BN9rdQ33.js +2 -0
- package/dist/esm/chunks/error-BN9rdQ33.js.map +1 -0
- package/dist/esm/chunks/index-BdV37p4e.js +2 -0
- package/dist/esm/chunks/index-BdV37p4e.js.map +1 -0
- package/dist/esm/chunks/index-BkRJ9-Im.js +2 -0
- package/dist/esm/chunks/index-BkRJ9-Im.js.map +1 -0
- package/dist/esm/chunks/{logger-Cg7fUh8D.js → logger-BLZbLzva.js} +2 -2
- package/dist/esm/chunks/{logger-Cg7fUh8D.js.map → logger-BLZbLzva.js.map} +1 -1
- package/dist/esm/chunks/memory-http-transport-DRYdYgiE.js +2 -0
- package/dist/esm/chunks/memory-http-transport-DRYdYgiE.js.map +1 -0
- package/dist/esm/chunks/node-http-transport-Bp5cFZCt.js +2 -0
- package/dist/esm/chunks/node-http-transport-Bp5cFZCt.js.map +1 -0
- package/dist/esm/chunks/progress-DJU_f66N.js +2 -0
- package/dist/esm/chunks/{progress-OxUHmDV4.js.map → progress-DJU_f66N.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-DiagDiT_.js +2 -0
- package/dist/esm/chunks/repository-DiagDiT_.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 -2
- package/dist/types/adapters/browser/index.d.ts +2 -2
- package/dist/types/adapters/memory/index.d.cts +4 -2
- package/dist/types/adapters/memory/index.d.ts +4 -2
- package/dist/types/adapters/node/index.d.cts +117 -3
- package/dist/types/adapters/node/index.d.ts +117 -3
- package/dist/types/chunks/{context-Ku1aP8Ie.d.cts → context-D84z1i5F.d.cts} +39 -21
- package/dist/types/chunks/{context-C6df52Qs.d.ts → context-o5TPfMB2.d.ts} +39 -21
- package/dist/types/chunks/{diff-change-BwO75AgS.d.cts → diff-change-Bm1zvVsC.d.cts} +1 -1
- package/dist/types/chunks/{diff-change-CUWN3OSK.d.ts → diff-change-alGRzD_j.d.ts} +1 -1
- package/dist/types/chunks/{http-transport--_NdQOiw.d.cts → http-transport-DirKfK2S.d.cts} +1 -1
- package/dist/types/chunks/{http-transport--_NdQOiw.d.ts → http-transport-DirKfK2S.d.ts} +1 -1
- package/dist/types/chunks/{repository-Cv4Y0T9t.d.cts → repository-23evW2h-.d.cts} +5 -4
- package/dist/types/chunks/{repository-BBKJnr8a.d.ts → repository-BT7Xq1kJ.d.ts} +5 -4
- package/dist/types/chunks/write-tree-DNjhjS3t.d.ts +282 -0
- package/dist/types/chunks/write-tree-DVp0RJ_r.d.cts +282 -0
- package/dist/types/commands/index.d.cts +82 -36
- package/dist/types/commands/index.d.ts +82 -36
- package/dist/types/index.browser.d.cts +5 -5
- package/dist/types/index.browser.d.ts +5 -5
- package/dist/types/index.d.cts +5 -5
- package/dist/types/index.d.ts +5 -5
- package/dist/types/index.default.d.cts +5 -5
- package/dist/types/index.default.d.ts +5 -5
- package/dist/types/index.node.d.cts +5 -5
- package/dist/types/index.node.d.ts +5 -5
- 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 +223 -186
- package/dist/types/primitives/index.d.ts +223 -186
- package/dist/types/transport/index.d.cts +1 -1
- package/dist/types/transport/index.d.ts +1 -1
- package/package.json +70 -23
- 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-Cbzk-Qwz.cjs +0 -2
- package/dist/cjs/chunks/repository-Cbzk-Qwz.cjs.map +0 -1
- package/dist/esm/chunks/error-CAlAXhN3.js +0 -2
- package/dist/esm/chunks/error-CAlAXhN3.js.map +0 -1
- package/dist/esm/chunks/error-DVZkS_ub.js +0 -2
- package/dist/esm/chunks/error-DVZkS_ub.js.map +0 -1
- package/dist/esm/chunks/index-gUdap5AF.js +0 -2
- package/dist/esm/chunks/index-gUdap5AF.js.map +0 -1
- package/dist/esm/chunks/memory-http-transport-Cv1sbkCX.js +0 -2
- package/dist/esm/chunks/memory-http-transport-Cv1sbkCX.js.map +0 -1
- package/dist/esm/chunks/merge-base-opORz-S1.js +0 -2
- package/dist/esm/chunks/merge-base-opORz-S1.js.map +0 -1
- package/dist/esm/chunks/node-http-transport-CuXVJf0s.js +0 -2
- package/dist/esm/chunks/node-http-transport-CuXVJf0s.js.map +0 -1
- package/dist/esm/chunks/progress-OxUHmDV4.js +0 -2
- package/dist/esm/chunks/repository-BaEhU6zt.js +0 -2
- package/dist/esm/chunks/repository-BaEhU6zt.js.map +0 -1
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { O as ObjectId, d as FilePath, e as FileStat, b as Context, R as RefName } from './context-D84z1i5F.cjs';
|
|
2
|
+
import { A as AuthorIdentity, F as FileMode, T as TreeDiff } from './diff-change-Bm1zvVsC.cjs';
|
|
3
|
+
|
|
4
|
+
interface Blob {
|
|
5
|
+
readonly type: 'blob';
|
|
6
|
+
readonly id: ObjectId;
|
|
7
|
+
readonly content: Uint8Array;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface ExtraHeader {
|
|
11
|
+
readonly key: string;
|
|
12
|
+
readonly value: string;
|
|
13
|
+
}
|
|
14
|
+
interface CommitData {
|
|
15
|
+
readonly tree: ObjectId;
|
|
16
|
+
readonly parents: ReadonlyArray<ObjectId>;
|
|
17
|
+
readonly author: AuthorIdentity;
|
|
18
|
+
readonly committer: AuthorIdentity;
|
|
19
|
+
readonly message: string;
|
|
20
|
+
readonly gpgSignature?: string;
|
|
21
|
+
readonly extraHeaders: ReadonlyArray<ExtraHeader>;
|
|
22
|
+
}
|
|
23
|
+
interface Commit {
|
|
24
|
+
readonly type: 'commit';
|
|
25
|
+
readonly id: ObjectId;
|
|
26
|
+
readonly data: CommitData;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type ObjectType = 'blob' | 'tree' | 'commit' | 'tag';
|
|
30
|
+
|
|
31
|
+
interface TagData {
|
|
32
|
+
readonly object: ObjectId;
|
|
33
|
+
readonly objectType: ObjectType;
|
|
34
|
+
readonly tagName: string;
|
|
35
|
+
readonly tagger?: AuthorIdentity;
|
|
36
|
+
readonly message: string;
|
|
37
|
+
readonly gpgSignature?: string;
|
|
38
|
+
readonly extraHeaders: ReadonlyArray<ExtraHeader>;
|
|
39
|
+
}
|
|
40
|
+
interface Tag {
|
|
41
|
+
readonly type: 'tag';
|
|
42
|
+
readonly id: ObjectId;
|
|
43
|
+
readonly data: TagData;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface TreeEntry {
|
|
47
|
+
readonly mode: FileMode;
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly id: ObjectId;
|
|
50
|
+
}
|
|
51
|
+
interface Tree {
|
|
52
|
+
readonly type: 'tree';
|
|
53
|
+
readonly id: ObjectId;
|
|
54
|
+
readonly entries: ReadonlyArray<TreeEntry>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type GitObject = Blob | Tree | Commit | Tag;
|
|
58
|
+
|
|
59
|
+
interface IndexEntryFlags {
|
|
60
|
+
readonly assumeValid: boolean;
|
|
61
|
+
readonly extended: boolean;
|
|
62
|
+
readonly stage: 0 | 1 | 2 | 3;
|
|
63
|
+
}
|
|
64
|
+
interface IndexEntry {
|
|
65
|
+
readonly ctimeSeconds: number;
|
|
66
|
+
readonly ctimeNanoseconds: number;
|
|
67
|
+
readonly mtimeSeconds: number;
|
|
68
|
+
readonly mtimeNanoseconds: number;
|
|
69
|
+
readonly dev: number;
|
|
70
|
+
readonly ino: number;
|
|
71
|
+
readonly mode: FileMode;
|
|
72
|
+
readonly uid: number;
|
|
73
|
+
readonly gid: number;
|
|
74
|
+
readonly fileSize: number;
|
|
75
|
+
readonly id: ObjectId;
|
|
76
|
+
readonly flags: IndexEntryFlags;
|
|
77
|
+
readonly path: FilePath;
|
|
78
|
+
}
|
|
79
|
+
interface IndexExtension {
|
|
80
|
+
readonly signature: string;
|
|
81
|
+
readonly data: Uint8Array;
|
|
82
|
+
}
|
|
83
|
+
interface GitIndex {
|
|
84
|
+
readonly version: 2;
|
|
85
|
+
readonly entries: ReadonlyArray<IndexEntry>;
|
|
86
|
+
readonly extensions: ReadonlyArray<IndexExtension>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface RenameDetectOptions {
|
|
90
|
+
readonly limit?: number;
|
|
91
|
+
readonly maxSameIdDeletes?: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Primitive option shapes, walker value types, and shared constants.
|
|
96
|
+
* Defined in one location to avoid circular imports between primitive modules.
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/** Max symbolic-ref dereferences resolveRef will follow. */
|
|
100
|
+
declare const MAX_SYMBOLIC_REF_DEPTH = 5;
|
|
101
|
+
/** Max tag-peel hops resolveRef / readTree will follow when peeling. */
|
|
102
|
+
declare const MAX_PEEL_DEPTH = 5;
|
|
103
|
+
/** Max seeds walkCommits.from can contain. */
|
|
104
|
+
declare const MAX_WALK_SEEDS = 1024;
|
|
105
|
+
/** Hard cap on walkCommits' pending queue size to prevent unbounded heap growth. */
|
|
106
|
+
declare const MAX_WALK_QUEUE_SIZE: number;
|
|
107
|
+
/** Max.git/index file size readIndex will accept. */
|
|
108
|
+
declare const MAX_INDEX_BYTES: number;
|
|
109
|
+
/** Max commit message byte length createCommit will accept. */
|
|
110
|
+
declare const MAX_COMMIT_MESSAGE_BYTES: number;
|
|
111
|
+
/**
|
|
112
|
+
* Per-file size cap enforced by `add --all` before reading working-tree
|
|
113
|
+
* bytes into memory. Mirrors `MAX_CONFLICT_OUTPUT_BYTES` (256 MiB) so the
|
|
114
|
+
* write-side memory ceiling matches the read-side ceiling.
|
|
115
|
+
* See `docs/adr/032-add-all-large-file-guard.md`.
|
|
116
|
+
*/
|
|
117
|
+
declare const MAX_WORKING_TREE_BLOB_BYTES: number;
|
|
118
|
+
/**
|
|
119
|
+
* Per-file cap on `.gitignore`, `.git/info/exclude`, and the global
|
|
120
|
+
* excludesFile. 1 MiB leaves a 20× margin over real-world max-size
|
|
121
|
+
* gitignore corpora. See `docs/adr/036-gitignore-bounded-read.md`.
|
|
122
|
+
*/
|
|
123
|
+
declare const MAX_GITIGNORE_BYTES: number;
|
|
124
|
+
interface ReadObjectOptions {
|
|
125
|
+
readonly verifyHash?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Reject objects whose serialised payload exceeds this byte count, before
|
|
128
|
+
* inflating the full content into memory. Counts the raw object content
|
|
129
|
+
* (post-inflate, pre-loose-header). When unset, no cap applies.
|
|
130
|
+
*
|
|
131
|
+
* Used by `merge`'s content merger to bound peak memory when an adversarial
|
|
132
|
+
* remote ships pathologically large blobs. See `docs/design/phase-13-8-
|
|
133
|
+
* bounded-object-reads.md`.
|
|
134
|
+
*/
|
|
135
|
+
readonly maxBytes?: number;
|
|
136
|
+
}
|
|
137
|
+
interface ResolveRefOptions {
|
|
138
|
+
readonly peel?: boolean;
|
|
139
|
+
readonly maxSymbolicDepth?: number;
|
|
140
|
+
readonly maxPeelDepth?: number;
|
|
141
|
+
}
|
|
142
|
+
interface UpdateRefOptions {
|
|
143
|
+
readonly expected?: ObjectId | 'absent';
|
|
144
|
+
readonly delete?: boolean;
|
|
145
|
+
}
|
|
146
|
+
interface WalkCommitsOptions {
|
|
147
|
+
readonly from: ReadonlyArray<ObjectId>;
|
|
148
|
+
readonly until?: ReadonlyArray<ObjectId>;
|
|
149
|
+
readonly order?: 'topo' | 'first-parent';
|
|
150
|
+
readonly ignoreMissing?: boolean;
|
|
151
|
+
readonly verifyHash?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Commits whose parents must NOT be enqueued. Used for shallow boundaries
|
|
154
|
+
* . The commit itself is still yielded — only its parents are
|
|
155
|
+
* skipped. Callers that want to also skip the boundary commit pass it in
|
|
156
|
+
* `until`.
|
|
157
|
+
*/
|
|
158
|
+
readonly shallow?: ReadonlySet<ObjectId>;
|
|
159
|
+
}
|
|
160
|
+
/** Maximum `have` lines a single-round fetch will send. */
|
|
161
|
+
declare const MAX_HAVES = 256;
|
|
162
|
+
/** Hard cap on objects enumerated for a single push. design */
|
|
163
|
+
declare const MAX_PUSH_OBJECTS = 1000000;
|
|
164
|
+
interface WalkTreeEntry {
|
|
165
|
+
readonly path: FilePath;
|
|
166
|
+
readonly id: ObjectId;
|
|
167
|
+
readonly mode: FileMode;
|
|
168
|
+
}
|
|
169
|
+
interface WalkTreeOptions {
|
|
170
|
+
readonly recursive?: boolean;
|
|
171
|
+
readonly maxDepth?: number;
|
|
172
|
+
readonly maxEntries?: number;
|
|
173
|
+
}
|
|
174
|
+
interface WalkWorkingTreeEntry {
|
|
175
|
+
readonly path: FilePath;
|
|
176
|
+
readonly stat: FileStat;
|
|
177
|
+
}
|
|
178
|
+
type WalkIgnorePredicate = (path: FilePath, isDirectory: boolean) => boolean | Promise<boolean>;
|
|
179
|
+
interface WalkWorkingTreeOptions {
|
|
180
|
+
readonly maxDepth?: number;
|
|
181
|
+
readonly maxEntries?: number;
|
|
182
|
+
/**
|
|
183
|
+
* predicate. Invoked on every directory BEFORE descent
|
|
184
|
+
* (returning `true` prunes the entire subtree, skipping its `lstat`
|
|
185
|
+
* cost) and on every leaf BEFORE yielding (returning `true` drops
|
|
186
|
+
* the leaf). May be sync or async.
|
|
187
|
+
*/
|
|
188
|
+
readonly ignore?: WalkIgnorePredicate;
|
|
189
|
+
}
|
|
190
|
+
interface CreateCommitInput {
|
|
191
|
+
readonly tree: ObjectId;
|
|
192
|
+
readonly parents: ReadonlyArray<ObjectId>;
|
|
193
|
+
readonly author: AuthorIdentity;
|
|
194
|
+
readonly committer: AuthorIdentity;
|
|
195
|
+
readonly message: string;
|
|
196
|
+
readonly gpgSignature?: string;
|
|
197
|
+
readonly extraHeaders?: ReadonlyArray<ExtraHeader>;
|
|
198
|
+
}
|
|
199
|
+
type DiffTreesInput = Tree | ObjectId | undefined;
|
|
200
|
+
interface DiffTreesOptions {
|
|
201
|
+
readonly detectRenames?: boolean;
|
|
202
|
+
readonly renameOptions?: RenameDetectOptions;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
declare function createCommit(ctx: Context, input: CreateCommitInput): Promise<ObjectId>;
|
|
206
|
+
|
|
207
|
+
declare function diffTrees(ctx: Context, a: DiffTreesInput, b: DiffTreesInput, options?: DiffTreesOptions): Promise<TreeDiff>;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Compute a merge base — the first commit reachable from BOTH `a` and `b`.
|
|
211
|
+
*
|
|
212
|
+
* Algorithm: bidirectional BFS with two visited sets. After each layer
|
|
213
|
+
* advance, check the intersection. When non-empty, return the
|
|
214
|
+
* lexicographically smallest oid (deterministic tie-breaker).
|
|
215
|
+
*
|
|
216
|
+
* Returns `undefined` for unrelated histories. Documented limitation: cherry-picks
|
|
217
|
+
* and criss-cross merges may yield non-optimal bases — `recursive`-strategy
|
|
218
|
+
* multi-base resolution is v2.
|
|
219
|
+
*/
|
|
220
|
+
declare const mergeBase: (ctx: Context, a: ObjectId, b: ObjectId) => Promise<ObjectId | undefined>;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Pure path helpers composing `ctx.layout.gitDir` with known sub-paths.
|
|
224
|
+
* No I/O. No port access. Primitive step 3.
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Repository working-tree root. Returns the workDir from the current context;
|
|
229
|
+
* facade-tier code is responsible for discovery / realpath pinning
|
|
230
|
+
* at construction time. Primitives consume the already-resolved path.
|
|
231
|
+
*/
|
|
232
|
+
declare const getRepoRoot: (ctx: Context) => FilePath;
|
|
233
|
+
|
|
234
|
+
declare function readBlob(ctx: Context, id: ObjectId, options?: ReadObjectOptions): Promise<Blob>;
|
|
235
|
+
|
|
236
|
+
declare function readIndex(ctx: Context): Promise<GitIndex>;
|
|
237
|
+
|
|
238
|
+
declare function readObject(ctx: Context, id: ObjectId, options?: ReadObjectOptions): Promise<GitObject>;
|
|
239
|
+
|
|
240
|
+
declare function readTree(ctx: Context, ref: RefName | ObjectId): Promise<Tree>;
|
|
241
|
+
|
|
242
|
+
declare function resolveRef(ctx: Context, name: RefName | 'HEAD', options?: ResolveRefOptions): Promise<ObjectId>;
|
|
243
|
+
|
|
244
|
+
declare function updateRef(ctx: Context, name: RefName, newId: ObjectId, options?: UpdateRefOptions): Promise<void>;
|
|
245
|
+
|
|
246
|
+
declare function walkCommits(ctx: Context, options: WalkCommitsOptions): AsyncIterable<Commit>;
|
|
247
|
+
|
|
248
|
+
declare function walkTree(ctx: Context, treeIdOrObject: ObjectId | Tree, options?: WalkTreeOptions): AsyncIterable<WalkTreeEntry>;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Depth-first walk of the working tree starting at `ctx.layout.workDir`.
|
|
252
|
+
*
|
|
253
|
+
* Yields leaf entries (files and symlinks) as `{ path, stat }`. Directories
|
|
254
|
+
* are descended into, not yielded. `.git` at any level is skipped
|
|
255
|
+
* (case-insensitive, NTFS-trimmed). Embedded repositories (directories
|
|
256
|
+
* containing a `.git` child) are skipped entirely — yields nothing under
|
|
257
|
+
* them. Symlinks are surfaced via `lstat` (no follow); a symlink to a
|
|
258
|
+
* directory is yielded as a leaf, not descended into.
|
|
259
|
+
*
|
|
260
|
+
* The host repository's own `.git` is NOT treated as an embedded-repo
|
|
261
|
+
* marker — at the workDir root we only skip the `.git` entry itself, not
|
|
262
|
+
* the workDir.
|
|
263
|
+
*/
|
|
264
|
+
declare function walkWorkingTree(ctx: Context, options?: WalkWorkingTreeOptions): AsyncIterable<WalkWorkingTreeEntry>;
|
|
265
|
+
|
|
266
|
+
declare function writeObject(ctx: Context, object: GitObject): Promise<ObjectId>;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Write a symbolic ref atomically. Used for HEAD updates that point at a
|
|
270
|
+
* branch, branch renames affecting the current HEAD, and `clone`/`init`
|
|
271
|
+
* to set the initial HEAD.
|
|
272
|
+
*
|
|
273
|
+
* Single-level only in v1: target MUST be a direct ref name (no chained
|
|
274
|
+
* symrefs). Validation runs through `validateRefName` for both `name` and
|
|
275
|
+
* `target` — invalid inputs throw INVALID_REF before any I/O.
|
|
276
|
+
*/
|
|
277
|
+
declare const writeSymbolicRef: (ctx: Context, name: RefName, target: RefName) => Promise<void>;
|
|
278
|
+
|
|
279
|
+
declare function writeTree(ctx: Context, entries: ReadonlyArray<TreeEntry>): Promise<ObjectId>;
|
|
280
|
+
|
|
281
|
+
export { walkCommits as A, walkTree as B, walkWorkingTree as E, writeObject as F, writeSymbolicRef as H, writeTree as J, MAX_COMMIT_MESSAGE_BYTES as M, MAX_GITIGNORE_BYTES as b, MAX_HAVES as c, MAX_INDEX_BYTES as d, MAX_PEEL_DEPTH as e, MAX_PUSH_OBJECTS as f, MAX_SYMBOLIC_REF_DEPTH as g, MAX_WALK_QUEUE_SIZE as h, MAX_WALK_SEEDS as i, MAX_WORKING_TREE_BLOB_BYTES as j, createCommit as q, diffTrees as r, getRepoRoot as s, mergeBase as t, readBlob as u, readIndex as v, readObject as w, readTree as x, resolveRef as y, updateRef as z };
|
|
282
|
+
export type { CreateCommitInput as C, DiffTreesInput as D, GitIndex as G, IndexEntry as I, ReadObjectOptions as R, UpdateRefOptions as U, WalkCommitsOptions as W, DiffTreesOptions as a, ResolveRefOptions as k, WalkIgnorePredicate as l, WalkTreeEntry as m, WalkTreeOptions as n, WalkWorkingTreeEntry as o, WalkWorkingTreeOptions as p };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as AuthorIdentity, T as TreeDiff } from '../chunks/diff-change-
|
|
3
|
-
import '../chunks/http-transport
|
|
1
|
+
import { d as FilePath, b as Context, R as RefName, O as ObjectId } from '../chunks/context-D84z1i5F.cjs';
|
|
2
|
+
import { A as AuthorIdentity, T as TreeDiff } from '../chunks/diff-change-Bm1zvVsC.cjs';
|
|
3
|
+
import '../chunks/http-transport-DirKfK2S.cjs';
|
|
4
4
|
|
|
5
5
|
interface AddOptions {
|
|
6
6
|
readonly force?: boolean;
|
|
@@ -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,21 @@ type BranchResult = {
|
|
|
63
66
|
};
|
|
64
67
|
declare const branch: (ctx: Context, action: BranchAction) => Promise<BranchResult>;
|
|
65
68
|
|
|
66
|
-
interface
|
|
69
|
+
interface CheckoutSwitchOptions {
|
|
67
70
|
readonly target: string;
|
|
68
71
|
readonly detach?: boolean;
|
|
69
72
|
readonly force?: boolean;
|
|
70
73
|
}
|
|
74
|
+
interface CheckoutPathsOptions {
|
|
75
|
+
readonly paths: ReadonlyArray<string>;
|
|
76
|
+
readonly source?: 'index' | 'HEAD' | ObjectId;
|
|
77
|
+
}
|
|
78
|
+
type CheckoutOptions = CheckoutSwitchOptions | CheckoutPathsOptions;
|
|
71
79
|
interface CheckoutResult {
|
|
72
80
|
readonly branch: RefName | undefined;
|
|
73
81
|
readonly id: ObjectId;
|
|
74
82
|
readonly detached: boolean;
|
|
83
|
+
readonly changedPaths: number;
|
|
75
84
|
}
|
|
76
85
|
declare const checkout: (ctx: Context, opts: CheckoutOptions) => Promise<CheckoutResult>;
|
|
77
86
|
|
|
@@ -82,6 +91,10 @@ interface CloneOptions {
|
|
|
82
91
|
readonly url: string;
|
|
83
92
|
readonly bare?: boolean;
|
|
84
93
|
readonly initialBranch?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Shallow clone depth. When set, sends `deepen N` and persists the
|
|
96
|
+
* resulting shallow boundaries to `.git/shallow`.
|
|
97
|
+
*/
|
|
85
98
|
readonly depth?: number;
|
|
86
99
|
/** DNS resolver injected by the caller; required to enforce SSRF guards. */
|
|
87
100
|
readonly resolver?: DnsResolver;
|
|
@@ -122,6 +135,8 @@ interface CommitResult {
|
|
|
122
135
|
*/
|
|
123
136
|
declare const commit: (ctx: Context, opts: CommitOptions) => Promise<CommitResult>;
|
|
124
137
|
|
|
138
|
+
type ConflictType = 'content' | 'add-add' | 'modify-delete' | 'type-change' | 'rename-rename' | 'gitlink' | 'binary';
|
|
139
|
+
|
|
125
140
|
interface DiffOptions {
|
|
126
141
|
/** Resolve to a tree. Accepts ref name, oid, or 'HEAD'. */
|
|
127
142
|
readonly from?: string;
|
|
@@ -139,15 +154,24 @@ interface FetchOptions {
|
|
|
139
154
|
readonly remote?: string;
|
|
140
155
|
readonly refspecs?: ReadonlyArray<string>;
|
|
141
156
|
readonly prune?: boolean;
|
|
157
|
+
/** Shallow clone depth. Delegates to fetchPack's deepen path. */
|
|
158
|
+
readonly depth?: number;
|
|
159
|
+
}
|
|
160
|
+
interface FetchUpdate {
|
|
161
|
+
readonly name: RefName;
|
|
162
|
+
readonly oldId: ObjectId | undefined;
|
|
163
|
+
readonly newId: ObjectId;
|
|
142
164
|
}
|
|
143
165
|
interface FetchResult {
|
|
144
166
|
readonly remote: string;
|
|
145
167
|
readonly url: string;
|
|
146
|
-
readonly updatedRefs: ReadonlyArray<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
168
|
+
readonly updatedRefs: ReadonlyArray<FetchUpdate>;
|
|
169
|
+
/** Refs deleted because the server no longer advertises them (prune semantics). */
|
|
170
|
+
readonly prunedRefs: ReadonlyArray<RefName>;
|
|
171
|
+
/** New shallow boundaries written to `.git/shallow` during this fetch. */
|
|
172
|
+
readonly shallow: ReadonlyArray<ObjectId>;
|
|
173
|
+
/** Commits that crossed the shallow → non-shallow boundary during this fetch. */
|
|
174
|
+
readonly unshallow: ReadonlyArray<ObjectId>;
|
|
151
175
|
}
|
|
152
176
|
declare const fetch: (ctx: Context, opts?: FetchOptions) => Promise<FetchResult>;
|
|
153
177
|
|
|
@@ -167,7 +191,7 @@ interface InitResult {
|
|
|
167
191
|
*
|
|
168
192
|
* For non-bare repos, the gitDir is `<workDir>/.git`. For bare, gitDir IS the
|
|
169
193
|
* working dir — callers must construct a Context with `bare: true` for that
|
|
170
|
-
* shape
|
|
194
|
+
* shape.
|
|
171
195
|
*/
|
|
172
196
|
declare const init: (ctx: Context, opts?: InitOptions) => Promise<InitResult>;
|
|
173
197
|
|
|
@@ -200,6 +224,10 @@ interface MergeOptions {
|
|
|
200
224
|
readonly author?: AuthorIdentity;
|
|
201
225
|
readonly committer?: AuthorIdentity;
|
|
202
226
|
}
|
|
227
|
+
interface MergeConflictDescriptor {
|
|
228
|
+
readonly path: FilePath;
|
|
229
|
+
readonly type: ConflictType;
|
|
230
|
+
}
|
|
203
231
|
type MergeResult = {
|
|
204
232
|
readonly kind: 'up-to-date';
|
|
205
233
|
readonly id: ObjectId;
|
|
@@ -212,14 +240,24 @@ type MergeResult = {
|
|
|
212
240
|
readonly id: ObjectId;
|
|
213
241
|
readonly branch: RefName;
|
|
214
242
|
readonly parents: ReadonlyArray<ObjectId>;
|
|
243
|
+
} | {
|
|
244
|
+
readonly kind: 'conflict';
|
|
245
|
+
readonly conflicts: ReadonlyArray<MergeConflictDescriptor>;
|
|
246
|
+
readonly mergeHead: ObjectId;
|
|
247
|
+
readonly origHead: ObjectId;
|
|
215
248
|
};
|
|
216
249
|
/**
|
|
217
|
-
* Merge `target` into the current HEAD branch.
|
|
218
|
-
*
|
|
219
|
-
* -
|
|
220
|
-
* -
|
|
221
|
-
*
|
|
222
|
-
*
|
|
250
|
+
* Merge `target` into the current HEAD branch.
|
|
251
|
+
*
|
|
252
|
+
* - Up-to-date: target is ancestor of HEAD → no-op.
|
|
253
|
+
* - Fast-forward: HEAD is ancestor of target → branch advances.
|
|
254
|
+
* - True merge for diverged histories:.4a wired the three-way
|
|
255
|
+
* tree merge (`mergeTrees` + `mergeContent`) so a CLEAN merge commits
|
|
256
|
+
* the merged tree directly.4b persists conflict state on
|
|
257
|
+
* disk (marker files, stage-1/2/3 index entries, MERGE_HEAD /
|
|
258
|
+
* MERGE_MSG / ORIG_HEAD) and returns `{ kind: 'conflict',... }`.
|
|
259
|
+
* Resolution path: edit the marker files, `repo.add(paths)`,
|
|
260
|
+
* `repo.commit({ message })` — the resulting commit has two parents.
|
|
223
261
|
*/
|
|
224
262
|
declare const merge: (ctx: Context, opts: MergeOptions) => Promise<MergeResult>;
|
|
225
263
|
|
|
@@ -229,14 +267,17 @@ interface PushOptions {
|
|
|
229
267
|
readonly force?: boolean;
|
|
230
268
|
readonly forceWithLease?: ObjectId | 'auto';
|
|
231
269
|
}
|
|
270
|
+
interface PushedRef {
|
|
271
|
+
readonly name: RefName;
|
|
272
|
+
readonly oldId: ObjectId;
|
|
273
|
+
readonly newId: ObjectId;
|
|
274
|
+
readonly status: 'ok' | 'rejected';
|
|
275
|
+
readonly reason?: string;
|
|
276
|
+
}
|
|
232
277
|
interface PushResult {
|
|
233
278
|
readonly remote: string;
|
|
234
279
|
readonly url: string;
|
|
235
|
-
readonly pushedRefs: ReadonlyArray<
|
|
236
|
-
readonly name: RefName;
|
|
237
|
-
readonly newId: ObjectId;
|
|
238
|
-
readonly status: 'ok' | 'rejected';
|
|
239
|
-
}>;
|
|
280
|
+
readonly pushedRefs: ReadonlyArray<PushedRef>;
|
|
240
281
|
}
|
|
241
282
|
declare const push: (ctx: Context, opts?: PushOptions) => Promise<PushResult>;
|
|
242
283
|
|
|
@@ -253,13 +294,18 @@ interface ResetResult {
|
|
|
253
294
|
/**
|
|
254
295
|
* Reset HEAD (and optionally index/working tree) to `target`.
|
|
255
296
|
*
|
|
256
|
-
* - `soft`:
|
|
257
|
-
* - `mixed`: HEAD +
|
|
258
|
-
*
|
|
297
|
+
* - `soft`: HEAD only.
|
|
298
|
+
* - `mixed`: HEAD + rebuild the index from the target commit's tree
|
|
299
|
+
* (stat-cache donor strategy preserves cache for unchanged paths —
|
|
300
|
+
* ). Working tree is NOT touched.
|
|
301
|
+
* - `hard`: HEAD + index + working tree — materialise the target tree onto
|
|
302
|
+
* the working tree with `force: true`, then commit the post-write
|
|
303
|
+
* index entries. Bare repos are rejected upfront.
|
|
259
304
|
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
305
|
+
* Ordering: working tree → index → HEAD. The index lock wraps both the
|
|
306
|
+
* working-tree write AND the index commit, matching tightened
|
|
307
|
+
* pattern. A crash between the index commit and HEAD update leaves the index
|
|
308
|
+
* ahead of HEAD — same recoverable hazard as canonical git.
|
|
263
309
|
*/
|
|
264
310
|
declare const reset: (ctx: Context, opts: ResetOptions) => Promise<ResetResult>;
|
|
265
311
|
|
|
@@ -293,10 +339,10 @@ interface StatusResult {
|
|
|
293
339
|
/**
|
|
294
340
|
* Summarize the state of the working tree relative to the index, and the
|
|
295
341
|
* branch HEAD points at. Working-tree-vs-HEAD diff (Git's "staged" column)
|
|
296
|
-
* is approximated via index-vs-working-tree comparisons until
|
|
342
|
+
* is approximated via index-vs-working-tree comparisons until
|
|
297
343
|
* adds the stat-cache fast path.
|
|
298
344
|
*
|
|
299
|
-
* Progress reporting
|
|
345
|
+
* Progress reporting: emits `status:scan` start before the
|
|
300
346
|
* fan-out, updates at every 100 lstat completions, and end in a finally
|
|
301
347
|
* block so the consumer always pairs start with end. `total` is undefined
|
|
302
348
|
* — design choice that prevents revealing repository size to non-trusted
|