@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
|
@@ -1,217 +1,254 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import '../chunks/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readonly id: ObjectId;
|
|
8
|
-
readonly content: Uint8Array;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface ExtraHeader {
|
|
12
|
-
readonly key: string;
|
|
13
|
-
readonly value: string;
|
|
14
|
-
}
|
|
15
|
-
interface CommitData {
|
|
16
|
-
readonly tree: ObjectId;
|
|
17
|
-
readonly parents: ReadonlyArray<ObjectId>;
|
|
18
|
-
readonly author: AuthorIdentity;
|
|
19
|
-
readonly committer: AuthorIdentity;
|
|
20
|
-
readonly message: string;
|
|
21
|
-
readonly gpgSignature?: string;
|
|
22
|
-
readonly extraHeaders: ReadonlyArray<ExtraHeader>;
|
|
23
|
-
}
|
|
24
|
-
interface Commit {
|
|
25
|
-
readonly type: 'commit';
|
|
26
|
-
readonly id: ObjectId;
|
|
27
|
-
readonly data: CommitData;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
type ObjectType = 'blob' | 'tree' | 'commit' | 'tag';
|
|
31
|
-
|
|
32
|
-
interface TagData {
|
|
33
|
-
readonly object: ObjectId;
|
|
34
|
-
readonly objectType: ObjectType;
|
|
35
|
-
readonly tagName: string;
|
|
36
|
-
readonly tagger?: AuthorIdentity;
|
|
37
|
-
readonly message: string;
|
|
38
|
-
readonly gpgSignature?: string;
|
|
39
|
-
readonly extraHeaders: ReadonlyArray<ExtraHeader>;
|
|
40
|
-
}
|
|
41
|
-
interface Tag {
|
|
42
|
-
readonly type: 'tag';
|
|
43
|
-
readonly id: ObjectId;
|
|
44
|
-
readonly data: TagData;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface TreeEntry {
|
|
48
|
-
readonly mode: FileMode;
|
|
49
|
-
readonly name: string;
|
|
50
|
-
readonly id: ObjectId;
|
|
51
|
-
}
|
|
52
|
-
interface Tree {
|
|
53
|
-
readonly type: 'tree';
|
|
54
|
-
readonly id: ObjectId;
|
|
55
|
-
readonly entries: ReadonlyArray<TreeEntry>;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
type GitObject = Blob | Tree | Commit | Tag;
|
|
59
|
-
|
|
60
|
-
interface IndexEntryFlags {
|
|
61
|
-
readonly assumeValid: boolean;
|
|
62
|
-
readonly extended: boolean;
|
|
63
|
-
readonly stage: 0 | 1 | 2 | 3;
|
|
64
|
-
}
|
|
65
|
-
interface IndexEntry {
|
|
66
|
-
readonly ctimeSeconds: number;
|
|
67
|
-
readonly ctimeNanoseconds: number;
|
|
68
|
-
readonly mtimeSeconds: number;
|
|
69
|
-
readonly mtimeNanoseconds: number;
|
|
70
|
-
readonly dev: number;
|
|
71
|
-
readonly ino: number;
|
|
72
|
-
readonly mode: FileMode;
|
|
73
|
-
readonly uid: number;
|
|
74
|
-
readonly gid: number;
|
|
75
|
-
readonly fileSize: number;
|
|
76
|
-
readonly id: ObjectId;
|
|
77
|
-
readonly flags: IndexEntryFlags;
|
|
78
|
-
readonly path: FilePath;
|
|
79
|
-
}
|
|
80
|
-
interface IndexExtension {
|
|
81
|
-
readonly signature: string;
|
|
82
|
-
readonly data: Uint8Array;
|
|
83
|
-
}
|
|
84
|
-
interface GitIndex {
|
|
85
|
-
readonly version: 2;
|
|
86
|
-
readonly entries: ReadonlyArray<IndexEntry>;
|
|
87
|
-
readonly extensions: ReadonlyArray<IndexExtension>;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
interface RenameDetectOptions {
|
|
91
|
-
readonly limit?: number;
|
|
92
|
-
readonly maxSameIdDeletes?: number;
|
|
93
|
-
}
|
|
1
|
+
import { G as GitIndex, I as IndexEntry } from '../chunks/write-tree-DVp0RJ_r.cjs';
|
|
2
|
+
export { C as CreateCommitInput, D as DiffTreesInput, a as DiffTreesOptions, M as MAX_COMMIT_MESSAGE_BYTES, b as MAX_GITIGNORE_BYTES, c as MAX_HAVES, d as MAX_INDEX_BYTES, e as MAX_PEEL_DEPTH, f as MAX_PUSH_OBJECTS, g as MAX_SYMBOLIC_REF_DEPTH, h as MAX_WALK_QUEUE_SIZE, i as MAX_WALK_SEEDS, j as MAX_WORKING_TREE_BLOB_BYTES, R as ReadObjectOptions, k as ResolveRefOptions, U as UpdateRefOptions, W as WalkCommitsOptions, l as WalkIgnorePredicate, m as WalkTreeEntry, n as WalkTreeOptions, o as WalkWorkingTreeEntry, p as WalkWorkingTreeOptions, 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 '../chunks/write-tree-DVp0RJ_r.cjs';
|
|
3
|
+
import { d as FilePath, O as ObjectId, b as Context } from '../chunks/context-D84z1i5F.cjs';
|
|
4
|
+
import { F as FileMode } from '../chunks/diff-change-Bm1zvVsC.cjs';
|
|
5
|
+
export { T as TreeDiff } from '../chunks/diff-change-Bm1zvVsC.cjs';
|
|
6
|
+
import { b as HttpTransport } from '../chunks/http-transport-DirKfK2S.cjs';
|
|
94
7
|
|
|
95
8
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
9
|
+
* Pure helper that diffs a current GitIndex against a target tree's flat
|
|
10
|
+
* entry list and emits an ordered ChangesetEntry list. No FS, no ctx; the
|
|
11
|
+
* impure write side lives in `apply-changeset.ts`.
|
|
12
|
+
*
|
|
13
|
+
* Stage-0 entries only — unmerged stages are invisible to checkout (Phase
|
|
14
|
+
* 13.1 design step 5).
|
|
98
15
|
*/
|
|
99
16
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
declare const MAX_WALK_QUEUE_SIZE: number;
|
|
108
|
-
/** Max .git/index file size readIndex will accept. */
|
|
109
|
-
declare const MAX_INDEX_BYTES: number;
|
|
110
|
-
/** Max commit message byte length createCommit will accept. */
|
|
111
|
-
declare const MAX_COMMIT_MESSAGE_BYTES: number;
|
|
112
|
-
interface ReadObjectOptions {
|
|
113
|
-
readonly verifyHash?: boolean;
|
|
114
|
-
}
|
|
115
|
-
interface ResolveRefOptions {
|
|
116
|
-
readonly peel?: boolean;
|
|
117
|
-
readonly maxSymbolicDepth?: number;
|
|
118
|
-
readonly maxPeelDepth?: number;
|
|
17
|
+
interface ChangesetEntry {
|
|
18
|
+
readonly kind: 'add' | 'update' | 'delete' | 'noop';
|
|
19
|
+
readonly path: FilePath;
|
|
20
|
+
readonly mode: FileMode;
|
|
21
|
+
readonly id: ObjectId | undefined;
|
|
22
|
+
readonly previousId: ObjectId | undefined;
|
|
23
|
+
readonly previousMode: FileMode | undefined;
|
|
119
24
|
}
|
|
120
|
-
interface
|
|
121
|
-
readonly
|
|
122
|
-
readonly
|
|
25
|
+
interface ChangesetStats {
|
|
26
|
+
readonly add: number;
|
|
27
|
+
readonly update: number;
|
|
28
|
+
readonly delete: number;
|
|
29
|
+
readonly noop: number;
|
|
123
30
|
}
|
|
124
|
-
interface
|
|
125
|
-
readonly
|
|
126
|
-
readonly
|
|
127
|
-
readonly order?: 'topo' | 'first-parent';
|
|
128
|
-
readonly ignoreMissing?: boolean;
|
|
129
|
-
readonly verifyHash?: boolean;
|
|
31
|
+
interface Changeset {
|
|
32
|
+
readonly entries: ReadonlyArray<ChangesetEntry>;
|
|
33
|
+
readonly stats: ChangesetStats;
|
|
130
34
|
}
|
|
131
|
-
interface
|
|
35
|
+
interface TargetEntry {
|
|
132
36
|
readonly path: FilePath;
|
|
133
37
|
readonly id: ObjectId;
|
|
134
38
|
readonly mode: FileMode;
|
|
135
39
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
readonly
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
readonly tree: ObjectId;
|
|
143
|
-
readonly parents: ReadonlyArray<ObjectId>;
|
|
144
|
-
readonly author: AuthorIdentity;
|
|
145
|
-
readonly committer: AuthorIdentity;
|
|
146
|
-
readonly message: string;
|
|
147
|
-
readonly gpgSignature?: string;
|
|
148
|
-
readonly extraHeaders?: ReadonlyArray<ExtraHeader>;
|
|
40
|
+
declare const computeChangeset: (currentIndex: GitIndex, targetTree: ReadonlyArray<TargetEntry>) => Changeset;
|
|
41
|
+
|
|
42
|
+
interface ApplyChangesetOpts {
|
|
43
|
+
readonly changeset: Changeset;
|
|
44
|
+
readonly force: boolean;
|
|
45
|
+
readonly workdir: string;
|
|
149
46
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
readonly
|
|
153
|
-
readonly
|
|
47
|
+
interface ApplyChangesetResult {
|
|
48
|
+
readonly writtenEntries: ReadonlyArray<IndexEntry>;
|
|
49
|
+
readonly written: number;
|
|
50
|
+
readonly deleted: number;
|
|
154
51
|
}
|
|
52
|
+
declare const applyChangeset: (ctx: Context, opts: ApplyChangesetOpts) => Promise<ApplyChangesetResult>;
|
|
155
53
|
|
|
156
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Project a target tree onto a fresh stage-0 IndexEntry list, preserving
|
|
56
|
+
* stat-cache fields from the prior index where the path's `id` AND `mode`
|
|
57
|
+
* both match (the "stat-cache donor" strategy).
|
|
58
|
+
*
|
|
59
|
+
* Pure with respect to the working tree: this primitive never calls
|
|
60
|
+
* `fs.lstat`, `fs.read`, or any working-tree-side API. It only reads git
|
|
61
|
+
* objects via `walkTree` → `readObject` for nested trees.
|
|
62
|
+
*
|
|
63
|
+
* Used by `reset --mixed` to rebuild the index from a target
|
|
64
|
+
* commit's tree. Will be re-used by `reset --hard` composed
|
|
65
|
+
* with `materializeTree` to also write the working tree.
|
|
66
|
+
*
|
|
67
|
+
* ## Preconditions
|
|
68
|
+
*
|
|
69
|
+
* `currentIndex` MUST be read under the same `acquireIndexLock` that will
|
|
70
|
+
* later commit the result. Reading the index BEFORE the lock is acquired
|
|
71
|
+
* lets a concurrent writer mutate it between the donor-map build and the
|
|
72
|
+
* commit, producing a result that reflects neither the pre-reset nor the
|
|
73
|
+
* post-reset state. See `reset.ts:rebuildIndexFromCommit` for the
|
|
74
|
+
* canonical pattern: acquire → read → build → commit → release-in-finally.
|
|
75
|
+
*/
|
|
157
76
|
|
|
158
|
-
|
|
77
|
+
interface BuildIndexFromTreeOpts {
|
|
78
|
+
readonly targetTree: ObjectId;
|
|
79
|
+
readonly currentIndex: GitIndex;
|
|
80
|
+
}
|
|
81
|
+
declare const buildIndexFromTree: (ctx: Context, opts: BuildIndexFromTreeOpts) => Promise<ReadonlyArray<IndexEntry>>;
|
|
82
|
+
|
|
83
|
+
interface BuildPackInput {
|
|
84
|
+
readonly oids: ReadonlyArray<ObjectId>;
|
|
85
|
+
}
|
|
86
|
+
interface BuildPackResult {
|
|
87
|
+
readonly bytes: Uint8Array;
|
|
88
|
+
/** Hex SHA of the pack body, also the trailer (last 20 bytes). */
|
|
89
|
+
readonly sha: string;
|
|
90
|
+
readonly objectCount: number;
|
|
91
|
+
}
|
|
92
|
+
declare const buildPack: (ctx: Context, input: BuildPackInput) => Promise<BuildPackResult>;
|
|
93
|
+
|
|
94
|
+
interface EnumeratePushObjectsInput {
|
|
95
|
+
/**
|
|
96
|
+
* Object ids the caller wants on the remote. Each MUST resolve to a
|
|
97
|
+
* commit or an annotated tag (tags are unwrapped to commits before the
|
|
98
|
+
* commit walk).
|
|
99
|
+
*/
|
|
100
|
+
readonly wants: ReadonlyArray<ObjectId>;
|
|
101
|
+
/** Object ids the remote already has (server's advertised ref tips). */
|
|
102
|
+
readonly haves: ReadonlyArray<ObjectId>;
|
|
103
|
+
/** Hard cap on objects emitted. Defaults to MAX_PUSH_OBJECTS. */
|
|
104
|
+
readonly maxObjects?: number;
|
|
105
|
+
}
|
|
106
|
+
declare function enumeratePushObjects(ctx: Context, input: EnumeratePushObjectsInput): AsyncIterable<ObjectId>;
|
|
107
|
+
|
|
108
|
+
interface FetchPackInput {
|
|
109
|
+
/** Advertised refs the caller wants. MUST be non-empty (server-side requirement). */
|
|
110
|
+
readonly wants: ReadonlyArray<ObjectId>;
|
|
111
|
+
/** Objects the caller already has (negotiation). Empty for clone, populated for fetch. */
|
|
112
|
+
readonly haves: ReadonlyArray<ObjectId>;
|
|
113
|
+
/** Negotiated capabilities (intersection of advertised + supported). */
|
|
114
|
+
readonly capabilities: ReadonlyArray<string>;
|
|
115
|
+
/** Base remote URL (the same URL passed to clone). */
|
|
116
|
+
readonly url: string;
|
|
117
|
+
/** Progress op label — clone uses 'clone:write-objects', fetch uses 'fetch:write-objects'. */
|
|
118
|
+
readonly progressOp: string;
|
|
119
|
+
/**
|
|
120
|
+
* Shallow clone depth. When set, sends `deepen N` and consumes the
|
|
121
|
+
* accompanying `shallow <oid>` / `unshallow <oid>` response block.
|
|
122
|
+
*
|
|
123
|
+
*/
|
|
124
|
+
readonly depth?: number;
|
|
125
|
+
}
|
|
126
|
+
interface FetchPackResult {
|
|
127
|
+
readonly packPath: string;
|
|
128
|
+
readonly idxPath: string;
|
|
129
|
+
readonly objectCount: number;
|
|
130
|
+
/** Hex-encoded SHA of the pack trailer; also the on-disk filename stem. */
|
|
131
|
+
readonly packSha: string;
|
|
132
|
+
/** Commits the server advertised as new shallow boundaries (empty when depth is unset). */
|
|
133
|
+
readonly shallow: ReadonlyArray<ObjectId>;
|
|
134
|
+
/** Commits the server advertised as no-longer-shallow (empty when depth is unset). */
|
|
135
|
+
readonly unshallow: ReadonlyArray<ObjectId>;
|
|
136
|
+
}
|
|
137
|
+
declare const fetchPack: (ctx: Context, transport: HttpTransport, input: FetchPackInput) => Promise<FetchPackResult>;
|
|
159
138
|
|
|
160
139
|
/**
|
|
161
|
-
*
|
|
140
|
+
* Compose `walkTree → computeChangeset → applyChangeset` to update the
|
|
141
|
+
* working tree to a target tree's contents.
|
|
142
|
+
*
|
|
143
|
+
* - Branch switch mode: `paths === undefined` — diff the entire current
|
|
144
|
+
* index against the entire target tree.
|
|
145
|
+
* - Path-restore mode: `paths !== undefined` — restrict both sides of
|
|
146
|
+
* the diff to those paths.
|
|
162
147
|
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
148
|
+
* Returns the new IndexEntry list for the caller to commit, plus
|
|
149
|
+
* written/deleted counts. The primitive does NOT commit the index — the
|
|
150
|
+
* caller decides.
|
|
166
151
|
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
152
|
+
* ## Stat-source contract for `newIndexEntries` (load-bearing for)
|
|
153
|
+
*
|
|
154
|
+
* - **Paths that were written/added** (`add` or `update` changeset entries):
|
|
155
|
+
* the IndexEntry carries **post-write `lstat`-derived stat fields**
|
|
156
|
+
* (ctime/mtime/dev/ino/uid/gid/fileSize). These reflect the file we just
|
|
157
|
+
* wrote, so the next `status` runs the fast `isStatClean` path.
|
|
158
|
+
* - **Paths whose changeset classification was `noop`** (skipped — index
|
|
159
|
+
* already matched target by `id + mode`): the IndexEntry is the caller's
|
|
160
|
+
* `currentIndex` entry verbatim. Donor stats survive across the call.
|
|
161
|
+
* - `reset --hard` therefore MUST set `forceRewriteAll: true` so every noop
|
|
162
|
+
* upgrades to update and the post-write stats land in the output. Without
|
|
163
|
+
* that, a locally-modified working-tree file that the index still records
|
|
164
|
+
* as clean would survive the reset, AND the donor stats would be stale
|
|
165
|
+
* relative to the actual disk state.
|
|
170
166
|
*/
|
|
171
|
-
|
|
167
|
+
|
|
168
|
+
interface MaterializeTreeOpts {
|
|
169
|
+
readonly targetTree: ObjectId;
|
|
170
|
+
readonly currentIndex: GitIndex;
|
|
171
|
+
readonly force?: boolean;
|
|
172
|
+
readonly paths?: ReadonlySet<FilePath>;
|
|
173
|
+
/**
|
|
174
|
+
* When true, every target-tree path is written to the working tree
|
|
175
|
+
* unconditionally — even paths the index→target diff classified as `noop`
|
|
176
|
+
* (same `id` AND `mode`). Required by `reset --hard`, where the working
|
|
177
|
+
* tree may diverge from the index (uncommitted local modifications); the
|
|
178
|
+
* standard index→target diff cannot see that drift, so noops would skip
|
|
179
|
+
* paths the caller wants overwritten. Default `false` keeps the Phase
|
|
180
|
+
* 13.1 checkout behaviour: clean files are never spuriously rewritten.
|
|
181
|
+
*/
|
|
182
|
+
readonly forceRewriteAll?: boolean;
|
|
183
|
+
}
|
|
184
|
+
interface MaterializeTreeResult {
|
|
185
|
+
readonly newIndexEntries: ReadonlyArray<IndexEntry>;
|
|
186
|
+
readonly written: number;
|
|
187
|
+
readonly deleted: number;
|
|
188
|
+
}
|
|
189
|
+
declare const materializeTree: (ctx: Context, opts: MaterializeTreeOpts) => Promise<MaterializeTreeResult>;
|
|
172
190
|
|
|
173
191
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
192
|
+
* Read `.git/shallow`. Returns an empty set when the file does not exist or
|
|
193
|
+
* contains no oids. Malformed lines are tolerated (skipped) — canonical
|
|
194
|
+
* git behaves the same; a corrupted shallow file should not block a fetch.
|
|
176
195
|
*/
|
|
177
|
-
|
|
196
|
+
declare const readShallow: (ctx: Context) => Promise<ReadonlySet<ObjectId>>;
|
|
197
|
+
interface ShallowUpdate {
|
|
198
|
+
readonly shallow: ReadonlyArray<ObjectId>;
|
|
199
|
+
readonly unshallow: ReadonlyArray<ObjectId>;
|
|
200
|
+
}
|
|
178
201
|
/**
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
202
|
+
* Apply a set of shallow / unshallow updates to `.git/shallow`. Writes
|
|
203
|
+
* atomically via lock-rename; deletes the file when the resulting set is
|
|
204
|
+
* empty.
|
|
182
205
|
*/
|
|
183
|
-
declare const
|
|
184
|
-
|
|
185
|
-
declare function readBlob(ctx: Context, id: ObjectId, options?: ReadObjectOptions): Promise<Blob>;
|
|
186
|
-
|
|
187
|
-
declare function readIndex(ctx: Context): Promise<GitIndex>;
|
|
188
|
-
|
|
189
|
-
declare function readObject(ctx: Context, id: ObjectId, options?: ReadObjectOptions): Promise<GitObject>;
|
|
190
|
-
|
|
191
|
-
declare function readTree(ctx: Context, ref: RefName | ObjectId): Promise<Tree>;
|
|
192
|
-
|
|
193
|
-
declare function resolveRef(ctx: Context, name: RefName | 'HEAD', options?: ResolveRefOptions): Promise<ObjectId>;
|
|
194
|
-
|
|
195
|
-
declare function updateRef(ctx: Context, name: RefName, newId: ObjectId, options?: UpdateRefOptions): Promise<void>;
|
|
196
|
-
|
|
197
|
-
declare function walkCommits(ctx: Context, options: WalkCommitsOptions): AsyncIterable<Commit>;
|
|
198
|
-
|
|
199
|
-
declare function walkTree(ctx: Context, treeIdOrObject: ObjectId | Tree, options?: WalkTreeOptions): AsyncIterable<WalkTreeEntry>;
|
|
200
|
-
|
|
201
|
-
declare function writeObject(ctx: Context, object: GitObject): Promise<ObjectId>;
|
|
206
|
+
declare const updateShallow: (ctx: Context, updates: ShallowUpdate) => Promise<void>;
|
|
202
207
|
|
|
203
208
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
209
|
+
* Synthesise a nested `Tree` object from a flat `GitIndex` and return the
|
|
210
|
+
* root tree's `ObjectId`. Sub-trees are written to the object store as a
|
|
211
|
+
* side-effect of the recursive descent — only stage-0 entries contribute.
|
|
212
|
+
*
|
|
213
|
+
* Used by `checkout({ paths, source: 'index' })` to restore
|
|
214
|
+
* the working tree from staged content even when the index has diverged
|
|
215
|
+
* from HEAD via `add` / `rm`. The previous placeholder fell back to
|
|
216
|
+
* HEAD's tree, which silently lost the divergence.
|
|
217
|
+
*
|
|
218
|
+
* The synthesis is the inverse of `buildIndexFromTree`:
|
|
219
|
+
* "tree → index" and "index → tree" form a round-trip identity for any
|
|
220
|
+
* stage-0-only index.
|
|
221
|
+
*
|
|
222
|
+
* Pure with respect to the working tree — never calls `fs.lstat`,
|
|
223
|
+
* `fs.read`, or any working-tree-side API. Only writes git objects via
|
|
224
|
+
* the existing `writeTree` primitive.
|
|
207
225
|
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
226
|
+
* ## Safety
|
|
227
|
+
*
|
|
228
|
+
* - **Path validation**:.7 hoisted segment-level validation into
|
|
229
|
+
* `parseIndex` (`src/domain/git-index/path-validator.ts`). Every
|
|
230
|
+
* `IndexEntry` reaching this primitive THROUGH THE CANONICAL PARSER
|
|
231
|
+
* carries a `FilePath` value already free of `..`, `.`, empty segments,
|
|
232
|
+
* and leading-slash absolute paths. However, the primitive is also
|
|
233
|
+
* reachable from callers that construct `IndexEntry` records outside
|
|
234
|
+
* the parser (test fixtures, in-memory adapters, future synthesisers).
|
|
235
|
+
* Defence-in-depth: every entry is re-validated here so the primitive
|
|
236
|
+
* stays safe even when the parser-trusted path is bypassed.
|
|
237
|
+
* - **Depth cap**: synthesis bounds recursion at `MAX_TREE_DEPTH` (4096,
|
|
238
|
+
* matching git's canonical limit). The cap is enforced at the input
|
|
239
|
+
* boundary by counting slashes — by the time recursion would catch a
|
|
240
|
+
* pathological depth, the JS engine has already exhausted its call
|
|
241
|
+
* stack. Path validation does NOT subsume this check: a path can be
|
|
242
|
+
* safe segment-by-segment (no `..`/`.`/empty) and still be 10 000
|
|
243
|
+
* levels deep.
|
|
211
244
|
*/
|
|
212
|
-
declare const writeSymbolicRef: (ctx: Context, name: RefName, target: RefName) => Promise<void>;
|
|
213
245
|
|
|
214
|
-
|
|
246
|
+
/**
|
|
247
|
+
* Public entry: pass the `entries` array directly (typically
|
|
248
|
+
* `index.entries`, but callers holding a filtered list may supply it
|
|
249
|
+
* without wrapping in a fake `GitIndex`).
|
|
250
|
+
*/
|
|
251
|
+
declare const synthesizeTreeFromIndex: (ctx: Context, entries: ReadonlyArray<IndexEntry>) => Promise<ObjectId>;
|
|
215
252
|
|
|
216
|
-
export {
|
|
217
|
-
export type {
|
|
253
|
+
export { applyChangeset, buildIndexFromTree, buildPack, computeChangeset, enumeratePushObjects, fetchPack, materializeTree, readShallow, synthesizeTreeFromIndex, updateShallow };
|
|
254
|
+
export type { ApplyChangesetOpts, ApplyChangesetResult, BuildIndexFromTreeOpts, BuildPackInput, BuildPackResult, Changeset, ChangesetEntry, ChangesetStats, EnumeratePushObjectsInput, FetchPackInput, FetchPackResult, MaterializeTreeOpts, MaterializeTreeResult };
|