@scolladon/tsgit 1.3.0 → 2.0.1
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 +3 -2
- package/dist/cjs/adapters/browser/index.cjs +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/chunks/adapter-detect-CD_LcgaH.cjs +2 -0
- package/dist/cjs/chunks/adapter-detect-CD_LcgaH.cjs.map +1 -0
- package/dist/cjs/chunks/{browser-http-transport-D4NH-8oJ.cjs → browser-http-transport-CiMRqtDS.cjs} +2 -2
- package/dist/cjs/chunks/browser-http-transport-CiMRqtDS.cjs.map +1 -0
- package/dist/cjs/chunks/error-CfjFO3x_.cjs +2 -0
- package/dist/cjs/chunks/error-CfjFO3x_.cjs.map +1 -0
- package/dist/cjs/chunks/index-BWCq_5BJ.cjs +2 -0
- package/dist/cjs/chunks/index-BWCq_5BJ.cjs.map +1 -0
- package/dist/cjs/chunks/memory-http-transport-BVL6VgB-.cjs +2 -0
- package/dist/cjs/chunks/memory-http-transport-BVL6VgB-.cjs.map +1 -0
- package/dist/cjs/chunks/node-http-transport-BvfVcf02.cjs +2 -0
- package/dist/cjs/chunks/node-http-transport-BvfVcf02.cjs.map +1 -0
- package/dist/cjs/chunks/{progress-Bj2w-90A.cjs → progress-CxU62NC1.cjs} +2 -2
- package/dist/cjs/chunks/{progress-Bj2w-90A.cjs.map → progress-CxU62NC1.cjs.map} +1 -1
- package/dist/cjs/chunks/repository-BEg2zNtx.cjs +2 -0
- package/dist/cjs/chunks/repository-BEg2zNtx.cjs.map +1 -0
- package/dist/cjs/chunks/walk-submodules-D2Sp7JEB.cjs +2 -0
- package/dist/cjs/chunks/walk-submodules-D2Sp7JEB.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.cjs.map +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/primitives/index.cjs +1 -1
- package/dist/cjs/primitives/index.cjs.map +1 -1
- package/dist/esm/adapters/browser/index.js +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/adapter-detect-DkZhhUhd.js +2 -0
- package/dist/esm/chunks/adapter-detect-DkZhhUhd.js.map +1 -0
- package/dist/esm/chunks/{browser-http-transport-DL8bkNdg.js → browser-http-transport-4rJkHcQu.js} +2 -2
- package/dist/esm/chunks/browser-http-transport-4rJkHcQu.js.map +1 -0
- package/dist/esm/chunks/error-Dc-SRSJK.js +2 -0
- package/dist/esm/chunks/error-Dc-SRSJK.js.map +1 -0
- package/dist/esm/chunks/index-jH0UMhh-.js +2 -0
- package/dist/esm/chunks/index-jH0UMhh-.js.map +1 -0
- package/dist/esm/chunks/memory-http-transport-CA1WxWBp.js +2 -0
- package/dist/esm/chunks/memory-http-transport-CA1WxWBp.js.map +1 -0
- package/dist/esm/chunks/node-http-transport-DPa2lK3T.js +2 -0
- package/dist/esm/chunks/node-http-transport-DPa2lK3T.js.map +1 -0
- package/dist/esm/chunks/progress-BZobfl7p.js +2 -0
- package/dist/esm/chunks/{progress-NePjO3Kd.js.map → progress-BZobfl7p.js.map} +1 -1
- package/dist/esm/chunks/repository-DF6ePd1x.js +2 -0
- package/dist/esm/chunks/repository-DF6ePd1x.js.map +1 -0
- package/dist/esm/chunks/walk-submodules-Dq9oGwP8.js +2 -0
- package/dist/esm/chunks/walk-submodules-Dq9oGwP8.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.js.map +1 -1
- package/dist/esm/index.node.js +1 -1
- package/dist/esm/index.node.js.map +1 -1
- package/dist/esm/primitives/index.js +1 -1
- package/dist/esm/primitives/index.js.map +1 -1
- package/dist/types/adapters/browser/index.d.cts +5 -2
- package/dist/types/adapters/browser/index.d.ts +5 -2
- package/dist/types/adapters/memory/index.d.cts +17 -2
- package/dist/types/adapters/memory/index.d.ts +17 -2
- package/dist/types/adapters/node/index.d.cts +5 -2
- package/dist/types/adapters/node/index.d.ts +5 -2
- package/dist/types/chunks/{context-BORy7yXb.d.ts → context-CCL0_F8R.d.ts} +65 -39
- package/dist/types/chunks/{context-CMrHCVwK.d.cts → context-YDw6qicq.d.cts} +65 -39
- package/dist/types/chunks/{http-transport-DirKfK2S.d.cts → http-transport--_NdQOiw.d.cts} +1 -1
- package/dist/types/chunks/{http-transport-DirKfK2S.d.ts → http-transport--_NdQOiw.d.ts} +1 -1
- package/dist/types/chunks/index-entry-DtEbVpOG.d.cts +47 -0
- package/dist/types/chunks/index-entry-UD4dvtKh.d.ts +47 -0
- package/dist/types/chunks/progress-7KKiXXfX.d.ts +405 -0
- package/dist/types/chunks/progress-By8yFaUE.d.cts +405 -0
- package/dist/types/chunks/{reflog-entry-C2Hsdobk.d.ts → reflog-entry-BbNnXCTC.d.cts} +17 -3
- package/dist/types/chunks/{reflog-entry-DNvSz7S5.d.cts → reflog-entry-CSzjnZd4.d.ts} +17 -3
- package/dist/types/chunks/{repository-DCR_3RVt.d.cts → repository-BeifCqp0.d.cts} +48 -8
- package/dist/types/chunks/{repository-DFxFeYi3.d.ts → repository-FoS_Laoy.d.ts} +48 -8
- package/dist/types/chunks/{write-tree-CuhpWKFo.d.cts → write-tree-C3oNxOlX.d.cts} +78 -46
- package/dist/types/chunks/{write-tree-Dn1LtIh7.d.ts → write-tree-DRI-LzSr.d.ts} +78 -46
- package/dist/types/commands/index.d.cts +826 -95
- package/dist/types/commands/index.d.ts +826 -95
- package/dist/types/index.browser.d.cts +7 -6
- package/dist/types/index.browser.d.ts +7 -6
- package/dist/types/index.d.cts +278 -53
- package/dist/types/index.d.ts +278 -53
- package/dist/types/index.default.d.cts +7 -6
- package/dist/types/index.default.d.ts +7 -6
- package/dist/types/index.node.d.cts +7 -6
- package/dist/types/index.node.d.ts +7 -6
- package/dist/types/primitives/index.d.cts +260 -12
- package/dist/types/primitives/index.d.ts +260 -12
- package/dist/types/transport/index.d.cts +1 -1
- package/dist/types/transport/index.d.ts +1 -1
- package/package.json +25 -18
- package/dist/cjs/chunks/browser-http-transport-D4NH-8oJ.cjs.map +0 -1
- package/dist/cjs/chunks/error-CDLOBdNU.cjs +0 -2
- package/dist/cjs/chunks/error-CDLOBdNU.cjs.map +0 -1
- package/dist/cjs/chunks/index-BVArBKuk.cjs +0 -2
- package/dist/cjs/chunks/index-BVArBKuk.cjs.map +0 -1
- package/dist/cjs/chunks/index-DE9HSiWf.cjs +0 -2
- package/dist/cjs/chunks/index-DE9HSiWf.cjs.map +0 -1
- package/dist/cjs/chunks/logger-CVG0zcPH.cjs +0 -2
- package/dist/cjs/chunks/logger-CVG0zcPH.cjs.map +0 -1
- package/dist/cjs/chunks/memory-http-transport-DXwDGKtR.cjs +0 -2
- package/dist/cjs/chunks/memory-http-transport-DXwDGKtR.cjs.map +0 -1
- package/dist/cjs/chunks/node-http-transport-vrbnNEDb.cjs +0 -2
- package/dist/cjs/chunks/node-http-transport-vrbnNEDb.cjs.map +0 -1
- package/dist/cjs/chunks/repository-BJwTSiGf.cjs +0 -2
- package/dist/cjs/chunks/repository-BJwTSiGf.cjs.map +0 -1
- package/dist/esm/chunks/browser-http-transport-DL8bkNdg.js.map +0 -1
- package/dist/esm/chunks/error-MOmSzp9Z.js +0 -2
- package/dist/esm/chunks/error-MOmSzp9Z.js.map +0 -1
- package/dist/esm/chunks/index-BjmofbKE.js +0 -2
- package/dist/esm/chunks/index-BjmofbKE.js.map +0 -1
- package/dist/esm/chunks/index-Jh5R-UmU.js +0 -2
- package/dist/esm/chunks/index-Jh5R-UmU.js.map +0 -1
- package/dist/esm/chunks/logger-DP2cCpvL.js +0 -2
- package/dist/esm/chunks/logger-DP2cCpvL.js.map +0 -1
- package/dist/esm/chunks/memory-http-transport-COJU6VOL.js +0 -2
- package/dist/esm/chunks/memory-http-transport-COJU6VOL.js.map +0 -1
- package/dist/esm/chunks/node-http-transport-DYCFIJbc.js +0 -2
- package/dist/esm/chunks/node-http-transport-DYCFIJbc.js.map +0 -1
- package/dist/esm/chunks/progress-NePjO3Kd.js +0 -2
- package/dist/esm/chunks/repository-Cs-dbHqO.js +0 -2
- package/dist/esm/chunks/repository-Cs-dbHqO.js.map +0 -1
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { G as GitIndex, I as IndexEntry } from '../chunks/
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
import {
|
|
1
|
+
import { G as GitIndex, I as IndexEntry } from '../chunks/index-entry-DtEbVpOG.cjs';
|
|
2
|
+
import { c as FilePath, O as ObjectId, b as Context, j as RefName } from '../chunks/context-YDw6qicq.cjs';
|
|
3
|
+
import { F as FileMode, b as ConfigScope, c as ConfigKey, A as AuthorIdentity, R as ReflogEntry } from '../chunks/reflog-entry-BbNnXCTC.cjs';
|
|
4
|
+
export { C as CatFileBatchEntry, d as CatFileBatchOptions, e as CreateCommitInput, D as DiffTreesInput, f as DiffTreesOptions, M as MAX_COMMIT_MESSAGE_BYTES, g as MAX_GITIGNORE_BYTES, h as MAX_GITMODULES_BYTES, i as MAX_HAVES, j as MAX_INDEX_BYTES, k as MAX_PEEL_DEPTH, l as MAX_PUSH_OBJECTS, m as MAX_REFLOG_BYTES, n as MAX_SUBMODULE_DEPTH, o as MAX_SYMBOLIC_REF_DEPTH, p as MAX_WALK_QUEUE_SIZE, q as MAX_WALK_SEEDS, r as MAX_WORKING_TREE_BLOB_BYTES, s as ReadObjectOptions, t as ResolveRefOptions, S as SubmoduleEntry, T as TreeDiff, U as UpdateRefOptions, W as WalkCommitsOptions, u as WalkIgnorePredicate, v as WalkSubmodulesOptions, w as WalkTreeEntry, x as WalkTreeOptions, y as WalkWorkingTreeEntry, z as WalkWorkingTreeOptions } from '../chunks/reflog-entry-BbNnXCTC.cjs';
|
|
5
|
+
export { H as HashBlobOptions, z as HookInput, I as IsIgnoredMatch, A as IsIgnoredMatchSource, B as IsIgnoredQuery, S as SetEntryFlagsOptions, C as StageEntryOptions, D as StageEntrySource, U as UnstageEntryOptions, c as catFileBatch, a as createCommit, d as diffTrees, g as getRepoRoot, h as hashBlob, i as isIgnored, m as mergeBase, r as readBlob, b as readIndex, e as readObject, f as readTree, j as recordRefUpdate, k as resolveRef, l as runHook, s as setEntryFlags, E as sparseCheckoutPath, n as stageEntry, u as unstageEntry, o as updateRef, w as walkCommits, p as walkSubmodules, q as walkTree, t as walkWorkingTree, v as writeObject, x as writeSymbolicRef, y as writeTree } from '../chunks/write-tree-C3oNxOlX.cjs';
|
|
6
|
+
import { H as HttpTransport } from '../chunks/http-transport--_NdQOiw.cjs';
|
|
7
|
+
|
|
8
|
+
interface FlatTreeEntry {
|
|
9
|
+
readonly id: ObjectId;
|
|
10
|
+
readonly mode: FileMode;
|
|
11
|
+
}
|
|
12
|
+
interface FlatTree {
|
|
13
|
+
readonly entries: ReadonlyMap<FilePath, FlatTreeEntry>;
|
|
14
|
+
}
|
|
7
15
|
|
|
8
16
|
/** `true` ⇒ the path is in the sparse set (materialise it). */
|
|
9
17
|
type SparseMatcher = (path: FilePath) => boolean;
|
|
@@ -107,6 +115,22 @@ interface BuildPackResult {
|
|
|
107
115
|
}
|
|
108
116
|
declare const buildPack: (ctx: Context, input: BuildPackInput) => Promise<BuildPackResult>;
|
|
109
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Single source of truth for "is this index entry dirty in the working tree?".
|
|
120
|
+
*
|
|
121
|
+
* Compares the working file at `entry.path` against the entry's `(id, mode)`:
|
|
122
|
+
* `absent` when no working file exists, `modified` when the derived working
|
|
123
|
+
* mode or the content hash differs, else `unchanged`. Content is hashed via the
|
|
124
|
+
* uncapped `serializeAndHash` core (never the size-capped `hashBlob` write path),
|
|
125
|
+
* so a read-only comparison never throws on a large working file. Symlink
|
|
126
|
+
* content is its target (`readlink`), not the followed file.
|
|
127
|
+
*
|
|
128
|
+
* Consumed by `status` (reporting) and `rm` (the local-modification valve).
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
type WorkingTreeComparison = 'absent' | 'unchanged' | 'modified';
|
|
132
|
+
declare const compareWorkingTreeEntry: (ctx: Context, entry: IndexEntry) => Promise<WorkingTreeComparison>;
|
|
133
|
+
|
|
110
134
|
/**
|
|
111
135
|
* Subset of `.git/config` that v1 commands consume. Only fields actually used by
|
|
112
136
|
* commands are typed — the parser ignores everything else (lenient, like git itself).
|
|
@@ -126,6 +150,8 @@ interface ParsedConfig {
|
|
|
126
150
|
};
|
|
127
151
|
readonly remote?: ReadonlyMap<string, {
|
|
128
152
|
readonly url?: string;
|
|
153
|
+
/** `remote.<name>.pushurl` — push-only URL; `push` reads `pushUrl ?? url`. */
|
|
154
|
+
readonly pushUrl?: string;
|
|
129
155
|
readonly fetch?: ReadonlyArray<string>;
|
|
130
156
|
/** `remote.<name>.promisor` — true when this is a partial-clone promisor remote. */
|
|
131
157
|
readonly promisor?: boolean;
|
|
@@ -156,6 +182,98 @@ declare const readConfig: (ctx: Context) => Promise<ParsedConfig>;
|
|
|
156
182
|
* stale parse.
|
|
157
183
|
*/
|
|
158
184
|
declare const invalidateConfigCache: (ctx: Context) => void;
|
|
185
|
+
/**
|
|
186
|
+
* One `[section "subsection"]` block of a git-config-format INI file: the
|
|
187
|
+
* section name, an optional quoted subsection, and its key/value entries.
|
|
188
|
+
* Exported so `.gitmodules` parsing — byte-identical grammar — reuses one
|
|
189
|
+
* tokenizer (ADR-086).
|
|
190
|
+
*/
|
|
191
|
+
interface IniSection {
|
|
192
|
+
readonly section: string;
|
|
193
|
+
readonly subsection: string | undefined;
|
|
194
|
+
readonly entries: ReadonlyArray<{
|
|
195
|
+
readonly key: string;
|
|
196
|
+
readonly value: string;
|
|
197
|
+
}>;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Tokenize git-config-format INI text into its sections. Lenient, like git:
|
|
201
|
+
* orphan and malformed lines are skipped; comments and backslash
|
|
202
|
+
* continuations are honored.
|
|
203
|
+
*/
|
|
204
|
+
declare const parseIniSections: (text: string) => ReadonlyArray<IniSection>;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Drop the per-scope sections cache for a single `Context`. Called by
|
|
208
|
+
* `invalidateConfigCache` in `config-read.ts` so writers can invalidate both
|
|
209
|
+
* caches atomically.
|
|
210
|
+
*/
|
|
211
|
+
declare const invalidateScopedConfigCache: (ctx: Context) => void;
|
|
212
|
+
/**
|
|
213
|
+
* Read the raw IniSection array for a single config scope, or a scope-tagged
|
|
214
|
+
* flat array merged in precedence order (`system → global → local → worktree`)
|
|
215
|
+
* when `scope` is omitted.
|
|
216
|
+
*
|
|
217
|
+
* Per-Context, per-scope cached: a second call with the same `(ctx, scope)`
|
|
218
|
+
* shares the in-flight promise of the first. `invalidateConfigCache(ctx)` (from
|
|
219
|
+
* `config-read.ts`) drops the cached entries here too.
|
|
220
|
+
*
|
|
221
|
+
* In the merged-read path (`scope` omitted), scopes that are unavailable on
|
|
222
|
+
* the current adapter (`CONFIG_SCOPE_NOT_AVAILABLE`, `CONFIG_SYSTEM_PATH_UNRESOLVED`)
|
|
223
|
+
* are silently skipped — the caller gets whatever scopes the adapter can
|
|
224
|
+
* actually surface. Single-scope calls raise instead, so the caller can react
|
|
225
|
+
* to a missing scope explicitly.
|
|
226
|
+
*/
|
|
227
|
+
declare const readConfigSections: ({ ctx, scope, }: {
|
|
228
|
+
readonly ctx: Context;
|
|
229
|
+
readonly scope?: ConfigScope;
|
|
230
|
+
}) => Promise<ReadonlyArray<{
|
|
231
|
+
readonly scope: ConfigScope;
|
|
232
|
+
readonly section: IniSection;
|
|
233
|
+
}>>;
|
|
234
|
+
/**
|
|
235
|
+
* Look up a single value for a fully-qualified key (`section.name` or
|
|
236
|
+
* `section.subsection.name`). Behaviour:
|
|
237
|
+
*
|
|
238
|
+
* - When `scope` is provided, reads only that scope. If the key has more than
|
|
239
|
+
* one match in that scope, throws `CONFIG_MULTIPLE_VALUES` (carries `scope`).
|
|
240
|
+
* - When `scope` is omitted, merges across the four scopes. Same multi-value
|
|
241
|
+
* throw if more than one entry matches anywhere across the merged view
|
|
242
|
+
* (without the `scope` discriminator).
|
|
243
|
+
* - Absent key: returns `{ key, value: undefined }`; never throws.
|
|
244
|
+
*
|
|
245
|
+
* Branding: the returned `key` is the caller's input cast to `ConfigKey`;
|
|
246
|
+
* `parseConfigKey` validates the string before this cast, so the brand is
|
|
247
|
+
* load-bearing only at the type level.
|
|
248
|
+
*/
|
|
249
|
+
declare const getConfigValue: ({ ctx, key, scope, }: {
|
|
250
|
+
readonly ctx: Context;
|
|
251
|
+
readonly key: string;
|
|
252
|
+
readonly scope?: ConfigScope;
|
|
253
|
+
}) => Promise<{
|
|
254
|
+
readonly key: ConfigKey;
|
|
255
|
+
readonly value: string;
|
|
256
|
+
readonly scope: ConfigScope;
|
|
257
|
+
} | {
|
|
258
|
+
readonly key: ConfigKey;
|
|
259
|
+
readonly value: undefined;
|
|
260
|
+
}>;
|
|
261
|
+
/**
|
|
262
|
+
* Look up every value for a key. Returns matches in scope-precedence order
|
|
263
|
+
* (and physical-file order within each scope). Empty array when the key is
|
|
264
|
+
* absent. Never throws on multi-value.
|
|
265
|
+
*/
|
|
266
|
+
declare const getAllConfigValues: ({ ctx, key, scope, }: {
|
|
267
|
+
readonly ctx: Context;
|
|
268
|
+
readonly key: string;
|
|
269
|
+
readonly scope?: ConfigScope;
|
|
270
|
+
}) => Promise<{
|
|
271
|
+
readonly key: ConfigKey;
|
|
272
|
+
readonly values: ReadonlyArray<{
|
|
273
|
+
readonly value: string;
|
|
274
|
+
readonly scope: ConfigScope;
|
|
275
|
+
}>;
|
|
276
|
+
}>;
|
|
159
277
|
|
|
160
278
|
interface EnumeratePushObjectsInput {
|
|
161
279
|
/**
|
|
@@ -221,6 +339,21 @@ interface FetchPackResult {
|
|
|
221
339
|
}
|
|
222
340
|
declare const fetchPack: (ctx: Context, transport: HttpTransport, input: FetchPackInput) => Promise<FetchPackResult>;
|
|
223
341
|
|
|
342
|
+
/**
|
|
343
|
+
* Flatten a nested `Tree` object into the `FlatTree` shape that the
|
|
344
|
+
* `mergeTrees` domain primitive consumes.
|
|
345
|
+
*
|
|
346
|
+
* Bridges `walkTree`'s iterator into the `FlatTree` Map of
|
|
347
|
+
* `path → { id, mode }`. Consumed by `merge.ts`'s clean-merge tree walk
|
|
348
|
+
* and by `rm`'s HEAD-vs-index staged-change check (the safety valve), so
|
|
349
|
+
* it is exported from the primitives barrel.
|
|
350
|
+
*
|
|
351
|
+
* Pure with respect to the working tree — only reads git objects via
|
|
352
|
+
* `walkTree`.
|
|
353
|
+
*/
|
|
354
|
+
|
|
355
|
+
declare const flattenTree: (ctx: Context, treeId: ObjectId) => Promise<FlatTree>;
|
|
356
|
+
|
|
224
357
|
/**
|
|
225
358
|
* Compose `walkTree → computeChangeset → applyChangeset` to update the
|
|
226
359
|
* working tree to a target tree's contents.
|
|
@@ -393,6 +526,18 @@ declare const updateShallow: (ctx: Context, updates: ShallowUpdate) => Promise<v
|
|
|
393
526
|
*/
|
|
394
527
|
declare const synthesizeTreeFromIndex: (ctx: Context, entries: ReadonlyArray<IndexEntry>) => Promise<ObjectId>;
|
|
395
528
|
|
|
529
|
+
/**
|
|
530
|
+
* Targeted `.git/config` writer (ADR-082). tsgit has no general INI writer;
|
|
531
|
+
* this performs line surgery that preserves comments, blank lines, key order,
|
|
532
|
+
* casing of unrelated keys, and every other section byte-for-byte. It writes
|
|
533
|
+
* one `key = value` per call under any `[section]` / `[section "subsection"]`.
|
|
534
|
+
*
|
|
535
|
+
* @writes
|
|
536
|
+
* surface: config
|
|
537
|
+
* kind: readback-only
|
|
538
|
+
* format: git-config-text
|
|
539
|
+
*/
|
|
540
|
+
|
|
396
541
|
/**
|
|
397
542
|
* Set `key` under `[section]` / `[section "subsection"]`, preserving every
|
|
398
543
|
* other byte verbatim.
|
|
@@ -402,9 +547,9 @@ declare const synthesizeTreeFromIndex: (ctx: Context, entries: ReadonlyArray<Ind
|
|
|
402
547
|
* inserted right after the header;
|
|
403
548
|
* - no such section ⇒ `[section]\n\t<key> = <value>\n` is appended.
|
|
404
549
|
*/
|
|
405
|
-
declare const
|
|
406
|
-
/** `
|
|
407
|
-
declare const
|
|
550
|
+
declare const setConfigEntryInText: (text: string, section: string, subsection: string | undefined, key: string, value: string) => string;
|
|
551
|
+
/** `setConfigEntryInText` bound to the `[core]` section — kept for legacy callers. */
|
|
552
|
+
declare const setCoreConfigEntryInText: (text: string, key: string, value: string) => string;
|
|
408
553
|
/** One `key = value` write under `[section]` / `[section "subsection"]`. */
|
|
409
554
|
interface ConfigEntry {
|
|
410
555
|
readonly section: string;
|
|
@@ -414,12 +559,115 @@ interface ConfigEntry {
|
|
|
414
559
|
}
|
|
415
560
|
/**
|
|
416
561
|
* Read `${gitDir}/config` (a missing file is treated as `''`), fold
|
|
417
|
-
* `
|
|
562
|
+
* `setConfigEntryInText` over `entries`, write the result, and invalidate the
|
|
418
563
|
* per-`Context` `readConfig` cache so a later read sees the new values.
|
|
419
564
|
*/
|
|
420
565
|
declare const updateConfigEntries: (ctx: Context, entries: ReadonlyArray<ConfigEntry>) => Promise<void>;
|
|
421
566
|
/** Fold a batch of `[core]` `key = value` writes via `updateConfigEntries`. */
|
|
422
567
|
declare const updateCoreConfig: (ctx: Context, entries: Record<string, string>) => Promise<void>;
|
|
568
|
+
/**
|
|
569
|
+
* Mixed-operation batch entry. Folded over the on-disk text in order in
|
|
570
|
+
* a single `writeUtf8`. Use this when `remote` CRUD needs a section-
|
|
571
|
+
* remove paired with branch-referrer key removals in one atomic write.
|
|
572
|
+
*/
|
|
573
|
+
type ConfigOperation = {
|
|
574
|
+
readonly kind: 'set';
|
|
575
|
+
readonly section: string;
|
|
576
|
+
readonly subsection?: string;
|
|
577
|
+
readonly key: string;
|
|
578
|
+
readonly value: string;
|
|
579
|
+
} | {
|
|
580
|
+
/**
|
|
581
|
+
* Insert a fresh `key = value` line after the section header WITHOUT
|
|
582
|
+
* replacing any existing entry with the same key. Use for multi-value
|
|
583
|
+
* keys (`fetch`) where every call must yield an additional line.
|
|
584
|
+
*/
|
|
585
|
+
readonly kind: 'appendEntry';
|
|
586
|
+
readonly section: string;
|
|
587
|
+
readonly subsection?: string;
|
|
588
|
+
readonly key: string;
|
|
589
|
+
readonly value: string;
|
|
590
|
+
} | {
|
|
591
|
+
readonly kind: 'removeEntry';
|
|
592
|
+
readonly section: string;
|
|
593
|
+
readonly subsection?: string;
|
|
594
|
+
readonly key: string;
|
|
595
|
+
} | {
|
|
596
|
+
readonly kind: 'removeSection';
|
|
597
|
+
readonly section: string;
|
|
598
|
+
readonly subsection?: string;
|
|
599
|
+
} | {
|
|
600
|
+
readonly kind: 'renameSection';
|
|
601
|
+
readonly section: string;
|
|
602
|
+
readonly from: string;
|
|
603
|
+
readonly to: string;
|
|
604
|
+
};
|
|
605
|
+
declare const applyConfigOpInText: (text: string, op: ConfigOperation) => string;
|
|
606
|
+
/**
|
|
607
|
+
* Write a single `key = value` entry into the config file for the given scope
|
|
608
|
+
* (default `'local'`). Re-runs of the same call with a different value
|
|
609
|
+
* overwrite the existing entry in place (preserving comments and surrounding
|
|
610
|
+
* content). The key is validated via `parseConfigKey` (throws
|
|
611
|
+
* `CONFIG_KEY_INVALID` on a malformed input) and the value is validated by
|
|
612
|
+
* `assertValueSafe` (throws `CONFIG_VALUE_INVALID` on a banned control char)
|
|
613
|
+
* BEFORE any I/O — a rejected input never touches the file system.
|
|
614
|
+
*
|
|
615
|
+
* The branding on `ConfigKey` is enforced at the type level; this primitive
|
|
616
|
+
* accepts a raw string and parses it internally so it can be used directly
|
|
617
|
+
* from porcelain wrappers that hold un-branded callers' input.
|
|
618
|
+
*/
|
|
619
|
+
declare const setConfigEntry: ({ ctx, key, value, scope, }: {
|
|
620
|
+
readonly ctx: Context;
|
|
621
|
+
readonly key: string;
|
|
622
|
+
readonly value: string;
|
|
623
|
+
readonly scope?: ConfigScope;
|
|
624
|
+
}) => Promise<void>;
|
|
625
|
+
/**
|
|
626
|
+
* Remove a single `key = value` entry from the given scope. Idempotent — if
|
|
627
|
+
* the key is absent the call is a no-op (no I/O). If the key appears more
|
|
628
|
+
* than once in the targeted scope, throws `CONFIG_MULTIPLE_VALUES` with
|
|
629
|
+
* `requested: 'remove'` (the caller should use `unsetAllConfigEntries` to
|
|
630
|
+
* clear every occurrence).
|
|
631
|
+
*/
|
|
632
|
+
declare const unsetConfigEntry: ({ ctx, key, scope, }: {
|
|
633
|
+
readonly ctx: Context;
|
|
634
|
+
readonly key: string;
|
|
635
|
+
readonly scope?: ConfigScope;
|
|
636
|
+
}) => Promise<void>;
|
|
637
|
+
/**
|
|
638
|
+
* Remove every occurrence of `key` from the targeted scope. Idempotent — a
|
|
639
|
+
* missing key produces no I/O. Unlike `unsetConfigEntry`, multi-valued keys
|
|
640
|
+
* are explicitly supported: all matching lines are removed in a single
|
|
641
|
+
* read-modify-write pass.
|
|
642
|
+
*/
|
|
643
|
+
declare const unsetAllConfigEntries: ({ ctx, key, scope, }: {
|
|
644
|
+
readonly ctx: Context;
|
|
645
|
+
readonly key: string;
|
|
646
|
+
readonly scope?: ConfigScope;
|
|
647
|
+
}) => Promise<void>;
|
|
648
|
+
/**
|
|
649
|
+
* Rename `[<section> "<oldSubsection>"]` to `[<section> "<newSubsection>"]`.
|
|
650
|
+
* Both inputs are dotted (`'remote.origin'`). The two section families MUST
|
|
651
|
+
* match — renaming across families (e.g. `remote.origin` → `branch.main`) is
|
|
652
|
+
* rejected with `INVALID_OPTION`. Throws `CONFIG_SECTION_NOT_FOUND` if the
|
|
653
|
+
* source section does not exist in the targeted scope.
|
|
654
|
+
*/
|
|
655
|
+
declare const renameConfigSection: ({ ctx, oldName, newName, scope, }: {
|
|
656
|
+
readonly ctx: Context;
|
|
657
|
+
readonly oldName: string;
|
|
658
|
+
readonly newName: string;
|
|
659
|
+
readonly scope?: ConfigScope;
|
|
660
|
+
}) => Promise<void>;
|
|
661
|
+
/**
|
|
662
|
+
* Delete `[<section> "<subsection>"]` and its body. `sectionName` is dotted
|
|
663
|
+
* (`'remote.origin'`). Throws `CONFIG_SECTION_NOT_FOUND` when the section is
|
|
664
|
+
* absent in the targeted scope.
|
|
665
|
+
*/
|
|
666
|
+
declare const removeConfigSection: ({ ctx, sectionName, scope, }: {
|
|
667
|
+
readonly ctx: Context;
|
|
668
|
+
readonly sectionName: string;
|
|
669
|
+
readonly scope?: ConfigScope;
|
|
670
|
+
}) => Promise<void>;
|
|
423
671
|
|
|
424
672
|
/**
|
|
425
673
|
* Write the `.git/info/sparse-checkout` pattern file. The command tier
|
|
@@ -440,5 +688,5 @@ declare const updateCoreConfig: (ctx: Context, entries: Record<string, string>)
|
|
|
440
688
|
*/
|
|
441
689
|
declare const writeSparsePatternText: (ctx: Context, text: string) => Promise<void>;
|
|
442
690
|
|
|
443
|
-
export { MAX_SPARSE_PATTERN_FILE_BYTES, appendReflog, applyChangeset, buildIndexFromTree, buildPack, computeChangeset, deleteReflog, enumeratePushObjects, enumerateRefs, fetchPack, invalidateConfigCache, isWorkingTreeDirty, listReflogs, loadSparseMatcher, materializeTree, readConfig, readReflog, readShallow, readSparsePatternText, reflogExists, resolveReflogIdentity, setConfigEntry,
|
|
444
|
-
export type { ApplyChangesetOpts, ApplyChangesetResult, BuildIndexFromTreeOpts, BuildPackInput, BuildPackResult, Changeset, ChangesetEntry, ChangesetStats, ConfigEntry, EnumeratePushObjectsInput, FetchPackInput, FetchPackResult, MaterializeTreeOpts, MaterializeTreeResult, ParsedConfig };
|
|
691
|
+
export { MAX_SPARSE_PATTERN_FILE_BYTES, appendReflog, applyChangeset, applyConfigOpInText, buildIndexFromTree, buildPack, compareWorkingTreeEntry, computeChangeset, deleteReflog, enumeratePushObjects, enumerateRefs, fetchPack, flattenTree, getAllConfigValues, getConfigValue, invalidateConfigCache, invalidateScopedConfigCache, isWorkingTreeDirty, listReflogs, loadSparseMatcher, materializeTree, parseIniSections, readConfig, readConfigSections, readReflog, readShallow, readSparsePatternText, reflogExists, removeConfigSection, renameConfigSection, resolveReflogIdentity, setConfigEntry, setConfigEntryInText, setCoreConfigEntryInText, synthesizeTreeFromIndex, unsetAllConfigEntries, unsetConfigEntry, updateConfigEntries, updateCoreConfig, updateShallow, writeReflog, writeSparsePatternText };
|
|
692
|
+
export type { ApplyChangesetOpts, ApplyChangesetResult, BuildIndexFromTreeOpts, BuildPackInput, BuildPackResult, Changeset, ChangesetEntry, ChangesetStats, ConfigEntry, EnumeratePushObjectsInput, FetchPackInput, FetchPackResult, IniSection, MaterializeTreeOpts, MaterializeTreeResult, ParsedConfig, WorkingTreeComparison };
|