@scolladon/tsgit 1.0.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-mZQKkInJ.js → browser-http-transport-COFgnEyq.js} +2 -2
- package/dist/esm/chunks/{browser-http-transport-mZQKkInJ.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-84ixEPbQ.js → logger-BLZbLzva.js} +2 -2
- package/dist/esm/chunks/{logger-84ixEPbQ.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-OTDhgmPO.js → progress-DJU_f66N.js} +2 -2
- package/dist/esm/chunks/{progress-OTDhgmPO.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 +1 -1
- package/dist/types/adapters/browser/index.d.ts +1 -1
- package/dist/types/adapters/memory/index.d.cts +3 -1
- package/dist/types/adapters/memory/index.d.ts +3 -1
- package/dist/types/adapters/node/index.d.cts +116 -2
- package/dist/types/adapters/node/index.d.ts +116 -2
- package/dist/types/chunks/{context-d36639-i.d.cts → context-D84z1i5F.d.cts} +36 -18
- package/dist/types/chunks/{context-CTaXSPiP.d.ts → context-o5TPfMB2.d.ts} +36 -18
- package/dist/types/chunks/{diff-change-B09vxnxy.d.cts → diff-change-Bm1zvVsC.d.cts} +1 -1
- package/dist/types/chunks/{diff-change-D7xSeCn9.d.ts → diff-change-alGRzD_j.d.ts} +1 -1
- package/dist/types/chunks/{repository-CFT9j9H6.d.cts → repository-23evW2h-.d.cts} +4 -3
- package/dist/types/chunks/{repository-ntg7eXb2.d.ts → repository-BT7Xq1kJ.d.ts} +4 -3
- 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 +81 -35
- package/dist/types/commands/index.d.ts +81 -35
- package/dist/types/index.browser.d.cts +4 -4
- package/dist/types/index.browser.d.ts +4 -4
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- 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 +223 -186
- package/dist/types/primitives/index.d.ts +223 -186
- package/package.json +37 -9
- 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/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
|
@@ -83,16 +83,16 @@ interface FileSystem {
|
|
|
83
83
|
/**
|
|
84
84
|
* Write bytes to file. Fails with FILE_EXISTS if the file already exists (exclusive create).
|
|
85
85
|
*
|
|
86
|
-
* Contract obligations
|
|
86
|
+
* Contract obligations:
|
|
87
87
|
* - **Parent-directory creation:** the adapter MUST ensure parent directories exist before the
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
88
|
+
* exclusive write. Equivalent to `mkdir -p dirname(path)` before `open(path, O_EXCL)`. If the
|
|
89
|
+
* parent is removed between the implicit mkdir and the open (e.g. concurrent `git gc` prunes
|
|
90
|
+
* the fanout), the adapter retries once: re-create the parent, re-attempt the open. On a second
|
|
91
|
+
* ENOENT the error propagates as FILE_NOT_FOUND.
|
|
92
92
|
* - **Symlink-safe ancestor check:** the adapter MUST reject writes where any ancestor directory
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
93
|
+
* of `path` is a symbolic link whose resolved target is outside the containment root. This
|
|
94
|
+
* closes the attack where an attacker replaces `objects/xx/` with a symlink pointing elsewhere.
|
|
95
|
+
* Implementation: lstat-walk the ancestor chain, or use `openat`-style relative opens.
|
|
96
96
|
*/
|
|
97
97
|
readonly writeExclusive: (path: string, data: Uint8Array) => Promise<void>;
|
|
98
98
|
/** Write UTF-8 string to file, creating parent directories as needed. */
|
|
@@ -140,7 +140,7 @@ interface FileSystem {
|
|
|
140
140
|
* - Node: `fs.open(path, O_NOFOLLOW | (mode === 'write' ? O_WRONLY : O_RDONLY))`.
|
|
141
141
|
* - Memory: rejects with `PERMISSION_DENIED` when the leaf is a memory symlink entry.
|
|
142
142
|
* - Browser OPFS: throws `UNSUPPORTED_OPERATION` (OPFS has no symlinks; callers can
|
|
143
|
-
*
|
|
143
|
+
* fall back to a plain `read`/`write` because the no-follow guarantee holds vacuously).
|
|
144
144
|
*
|
|
145
145
|
* Throws `FILE_NOT_FOUND` if the leaf does not exist (in `read` mode).
|
|
146
146
|
* Throws `PERMISSION_DENIED` if the leaf is a symlink.
|
|
@@ -212,7 +212,7 @@ interface LruCache<V> {
|
|
|
212
212
|
* `Logger` in `transport/types.ts`, which is event-based and HTTP-shaped.
|
|
213
213
|
*
|
|
214
214
|
* The facade wraps user-supplied loggers with sanitization at construction time
|
|
215
|
-
*
|
|
215
|
+
* . Implementations should be tolerant of high call
|
|
216
216
|
* frequency and MUST NOT throw — a throwing logger crashes nothing.
|
|
217
217
|
*/
|
|
218
218
|
interface Logger {
|
|
@@ -225,8 +225,8 @@ interface Logger {
|
|
|
225
225
|
declare const noopLogger: Logger;
|
|
226
226
|
/**
|
|
227
227
|
* Wrap a user-supplied logger so every `message` + every string value in the
|
|
228
|
-
* `context` object passes through `sanitize()`
|
|
229
|
-
* the sink.
|
|
228
|
+
* `context` object passes through `sanitize()` before reaching
|
|
229
|
+
* the sink. the facade applies this at construction time so no
|
|
230
230
|
* downstream caller ever feeds raw control bytes to a user-controlled sink.
|
|
231
231
|
*
|
|
232
232
|
* Methods that the user did not supply are absent on the wrapper (preserves
|
|
@@ -237,7 +237,7 @@ declare const wrapLoggerSanitizer: (logger: Logger) => Logger;
|
|
|
237
237
|
|
|
238
238
|
/**
|
|
239
239
|
* Progress reporter shape consumed by long-running commands. The facade
|
|
240
|
-
*
|
|
240
|
+
* accepts a user-supplied implementation via
|
|
241
241
|
* `OpenRepositoryOptions.progress` and plumbs it onto `Context.progress`.
|
|
242
242
|
*
|
|
243
243
|
* Reporters are synchronous and fire-and-forget. The facade wraps every call
|
|
@@ -261,20 +261,28 @@ interface ProgressReporter {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
/**
|
|
264
|
-
* Repository physical layout — where the working tree and
|
|
265
|
-
* Renamed in
|
|
264
|
+
* Repository physical layout — where the working tree and.git directory live.
|
|
265
|
+
* Renamed in from the previous `RepositoryConfig` (port-tier) to free that
|
|
266
266
|
* name for the facade-tier `RepositoryConfig` shape (auth/parallelism/etc.).
|
|
267
267
|
*/
|
|
268
268
|
interface RepositoryLayout {
|
|
269
269
|
/** Absolute path to the repository root (working tree). */
|
|
270
270
|
readonly workDir: string;
|
|
271
|
-
/** Absolute path to the
|
|
271
|
+
/** Absolute path to the.git directory (usually `${workDir}/.git`, but may differ for bare repos or worktrees). */
|
|
272
272
|
readonly gitDir: string;
|
|
273
273
|
/** Whether this is a bare repository. */
|
|
274
274
|
readonly bare: boolean;
|
|
275
|
+
/**
|
|
276
|
+
* Home directory for `~`-expansion in config-driven paths (e.g.
|
|
277
|
+
* `core.excludesFile = ~/.config/git/ignore`). Populated by the node
|
|
278
|
+
* shim from `os.homedir()`; memory adapter accepts an option; browser
|
|
279
|
+
* leaves it `undefined`. When `undefined`, loaders that need home
|
|
280
|
+
* expansion treat the source as missing.
|
|
281
|
+
*/
|
|
282
|
+
readonly homeDir?: string;
|
|
275
283
|
}
|
|
276
284
|
/**
|
|
277
|
-
* Author / committer identity
|
|
285
|
+
* Author / committer identity shape.
|
|
278
286
|
*/
|
|
279
287
|
interface AuthorIdentity {
|
|
280
288
|
readonly name: string;
|
|
@@ -292,7 +300,7 @@ type AuthStrategy = {
|
|
|
292
300
|
readonly password: string;
|
|
293
301
|
};
|
|
294
302
|
/**
|
|
295
|
-
* Facade-tier configuration.
|
|
303
|
+
* Facade-tier configuration. introduces this shape; it carries the
|
|
296
304
|
* auth/parallelism/SSRF/network options the facade plumbs into network-pipeline.
|
|
297
305
|
* All fields are optional — primitives and commands consult only the keys they need.
|
|
298
306
|
*/
|
|
@@ -304,7 +312,17 @@ interface RepositoryConfig {
|
|
|
304
312
|
readonly upstreamRef?: RefName;
|
|
305
313
|
readonly allowInsecure?: boolean;
|
|
306
314
|
readonly allowPrivateNetworks?: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Hard cap (bytes) on a single pack body buffered in memory by `fetchPack`.
|
|
317
|
+
* Server-controlled byte counts above this raise `PACK_TOO_LARGE`. Default
|
|
318
|
+
* 512 MiB. Lower it for hardened deployments that clone only small repos.
|
|
319
|
+
*/
|
|
307
320
|
readonly maxResponseBytes?: number;
|
|
321
|
+
/**
|
|
322
|
+
* Hard cap on the entry-count field declared in a received pack header.
|
|
323
|
+
* Server-controlled `uint32` values above this raise `PACK_TOO_LARGE` before
|
|
324
|
+
* `fetchPack` allocates per-entry state. Default 50_000_000.
|
|
325
|
+
*/
|
|
308
326
|
readonly maxObjectsPerPack?: number;
|
|
309
327
|
readonly detectRenames?: boolean;
|
|
310
328
|
readonly breakStaleLockMs?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { add, branch, checkout, clone, commit, diff, fetch, init, log, merge, push, reset, revParse, rm, status, tag } from '../commands/index.cjs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { f as FileSystem, H as HashService, C as Compressor, h as RepositoryConfig, L as Logger, P as ProgressReporter, b as Context } from './context-D84z1i5F.cjs';
|
|
3
|
+
import { q as createCommit, r as diffTrees, s as getRepoRoot, t as mergeBase, u as readBlob, v as readIndex, w as readObject, x as readTree, y as resolveRef, z as updateRef, A as walkCommits, B as walkTree, E as walkWorkingTree, F as writeObject, H as writeSymbolicRef, J as writeTree } from './write-tree-DVp0RJ_r.cjs';
|
|
4
4
|
import { b as HttpTransport } from './http-transport-DirKfK2S.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -12,7 +12,7 @@ type BindCtx<F> = F extends (ctx: Context, ...rest: infer A) => infer R ? (...ar
|
|
|
12
12
|
* User-facing options passed to `openRepository`. Subset of the design's
|
|
13
13
|
* `OpenRepositoryOptions` that this Step 3 implementation honors. Every field
|
|
14
14
|
* is optional; the facade fills sensible defaults. Field-level validation runs
|
|
15
|
-
* eagerly before the Repository is returned
|
|
15
|
+
* eagerly before the Repository is returned.
|
|
16
16
|
*/
|
|
17
17
|
interface OpenRepositoryOptions {
|
|
18
18
|
/** Working directory. Default: `process.cwd()` on Node, `'/'` on browser/memory. */
|
|
@@ -72,6 +72,7 @@ interface Repository {
|
|
|
72
72
|
readonly updateRef: BindCtx<typeof updateRef>;
|
|
73
73
|
readonly walkCommits: BindCtx<typeof walkCommits>;
|
|
74
74
|
readonly walkTree: BindCtx<typeof walkTree>;
|
|
75
|
+
readonly walkWorkingTree: BindCtx<typeof walkWorkingTree>;
|
|
75
76
|
readonly writeObject: BindCtx<typeof writeObject>;
|
|
76
77
|
readonly writeSymbolicRef: BindCtx<typeof writeSymbolicRef>;
|
|
77
78
|
readonly writeTree: BindCtx<typeof writeTree>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { add, branch, checkout, clone, commit, diff, fetch, init, log, merge, push, reset, revParse, rm, status, tag } from '../commands/index.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { f as FileSystem, H as HashService, C as Compressor, h as RepositoryConfig, L as Logger, P as ProgressReporter, b as Context } from './context-o5TPfMB2.js';
|
|
3
|
+
import { q as createCommit, r as diffTrees, s as getRepoRoot, t as mergeBase, u as readBlob, v as readIndex, w as readObject, x as readTree, y as resolveRef, z as updateRef, A as walkCommits, B as walkTree, E as walkWorkingTree, F as writeObject, H as writeSymbolicRef, J as writeTree } from './write-tree-DNjhjS3t.js';
|
|
4
4
|
import { b as HttpTransport } from './http-transport-DirKfK2S.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -12,7 +12,7 @@ type BindCtx<F> = F extends (ctx: Context, ...rest: infer A) => infer R ? (...ar
|
|
|
12
12
|
* User-facing options passed to `openRepository`. Subset of the design's
|
|
13
13
|
* `OpenRepositoryOptions` that this Step 3 implementation honors. Every field
|
|
14
14
|
* is optional; the facade fills sensible defaults. Field-level validation runs
|
|
15
|
-
* eagerly before the Repository is returned
|
|
15
|
+
* eagerly before the Repository is returned.
|
|
16
16
|
*/
|
|
17
17
|
interface OpenRepositoryOptions {
|
|
18
18
|
/** Working directory. Default: `process.cwd()` on Node, `'/'` on browser/memory. */
|
|
@@ -72,6 +72,7 @@ interface Repository {
|
|
|
72
72
|
readonly updateRef: BindCtx<typeof updateRef>;
|
|
73
73
|
readonly walkCommits: BindCtx<typeof walkCommits>;
|
|
74
74
|
readonly walkTree: BindCtx<typeof walkTree>;
|
|
75
|
+
readonly walkWorkingTree: BindCtx<typeof walkWorkingTree>;
|
|
75
76
|
readonly writeObject: BindCtx<typeof writeObject>;
|
|
76
77
|
readonly writeSymbolicRef: BindCtx<typeof writeSymbolicRef>;
|
|
77
78
|
readonly writeTree: BindCtx<typeof writeTree>;
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { O as ObjectId, d as FilePath, e as FileStat, b as Context, R as RefName } from './context-o5TPfMB2.js';
|
|
2
|
+
import { A as AuthorIdentity, F as FileMode, T as TreeDiff } from './diff-change-alGRzD_j.js';
|
|
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 };
|