@osdlc/typed-git 0.7.0 → 0.7.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @osdlc/typed-git
2
2
 
3
+ ## 0.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [0cf31de]
8
+ - @osdlc/command-seam@0.11.0
9
+
10
+ ## 0.7.1
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [910deca]
15
+ - @osdlc/command-seam@0.10.0
16
+
3
17
  ## 0.7.0
4
18
 
5
19
  ### Minor Changes
package/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # @osdlc/typed-git
2
2
 
3
3
  A typed wrapper around the `git` command line for TypeScript, in a synchronous
4
- and an awaitable form. Each verb declares what *absence* means for it; every
5
- other failure throws. `git.try.*` inspects, `raw()` bypasses. What actually
6
- performs the git is a parameter.
4
+ and an awaitable form. Each verb declares which exit codes mean "not there"
5
+ for it, and every other failure throws. `git.try.*` returns the failure
6
+ instead of throwing, and `raw()` skips the checks. You can replace what runs
7
+ git.
7
8
 
8
9
  Use it when a Node or Bun program needs to ask git questions and act on typed
9
10
  answers, without parsing porcelain output by hand. It runs the `git` binary, so
@@ -79,7 +80,7 @@ const git = new Git(process.cwd());
79
80
  git.currentBranch(); // "main", or null when detached
80
81
  git.configGet("no.such.key"); // null — an unset key is an answer
81
82
  git.worktrees(); // Worktree[] — throws outside a repository
82
- git.commit({ message: "feat" }); // throws CommandFailed on a non-zero exit
83
+ git.commit({ message: "feat" }); // throws FailureError on a non-zero exit
83
84
 
84
85
  const r = git.try.worktrees(); // Result<Worktree[], GitFailure>
85
86
 
@@ -93,30 +94,30 @@ of the repository. They are not part of the published package.
93
94
 
94
95
  ## Two clients, one surface
95
96
 
96
- `Git` is synchronous and always shells out. That is a deliberate choice, not a
97
- missing feature: sequential git one-shots gain nothing from being awaited, and
98
- staying synchronous keeps a caller's call graph uncolored.
97
+ `Git` is synchronous and always runs the `git` CLI. That is on purpose. Git
98
+ calls run one after another gain nothing from being awaited, and a
99
+ synchronous client does not force its callers to be async.
99
100
 
100
- `AsyncGit` is the awaitable twin. Reach for it when the caller is a server
101
- that must not block, when calls fan out concurrently, or when git should come
102
- from something other than a subprocess.
101
+ `AsyncGit` has the same methods and returns promises. Use it when the caller
102
+ is a server that must not block, when calls run concurrently, or when git
103
+ should come from something other than a subprocess.
103
104
 
104
- Both drive the same verb table — one definition of every argv and every
105
- parser — so they cannot drift apart. The test suite asserts it: the two
106
- clients are run side by side against a recording runner and their argv
107
- compared.
105
+ Both use the same verb table, which holds the one definition of every argv
106
+ and every parser, so they cannot drift apart. The tests check this: they run
107
+ the two clients side by side against a recording runner and compare their
108
+ argv.
108
109
 
109
110
  ## Absence is an answer; failure is not
110
111
 
111
- **Declared absence returns a value; everything else throws; `try` inspects;
112
- `raw` bypasses.**
112
+ A declared absence returns a value. Everything else throws. `try` returns
113
+ the failure instead of throwing. `raw` skips the checks.
113
114
 
114
115
  Every verb names the exit codes that mean "asked and answered: not there" for
115
- *that* verb. `config --get` exits 1 for an unset key; `check-ignore` exits 1
116
- for "none of these are ignored"; `merge-base` exits 1 for unrelated histories.
117
- Those return the absence value — `null`, `[]`, `false` — exactly as before.
118
- Any other non-zero exit throws the classified failure, carrying the argv and the full
119
- result.
116
+ that verb. `config --get` exits 1 for an unset key. `check-ignore` exits 1
117
+ for "none of these are ignored". `merge-base` exits 1 for unrelated
118
+ histories. Those return the absence value: `null`, `[]` or `false`. Any other
119
+ non-zero exit throws the classified failure, which carries the argv and the
120
+ full result.
120
121
 
121
122
  | | on a declared absence | on anything else |
122
123
  | --- | --- | --- |
@@ -124,12 +125,12 @@ result.
124
125
  | **`git.try.verb()`** | `{ ok: true, value }` | `{ ok: false, error: GitFailure }` |
125
126
  | **`git.raw(argv)`** | the raw `CommandResult`; you decide | the same |
126
127
 
127
- Why it matters: a guard that runs `status --porcelain` outside a repository
128
- used to receive `[]` and report a clean tree. It now throws. The failing check
129
- can no longer ship as a passing one.
128
+ Why it matters: a check that runs `status --porcelain` outside a repository
129
+ gets a throw, not `[]`. So it cannot report a clean tree when git could not
130
+ look.
130
131
 
131
- `git.try.*` is for callers that genuinely tolerate failure — a hook that must
132
- not break a commit, an endpoint that must always answer:
132
+ `git.try.*` is for callers that must tolerate failure, such as a hook that
133
+ must not break a commit, or an endpoint that must always answer:
133
134
 
134
135
  ```ts
135
136
  const r = git.try.topLevel();
@@ -140,7 +141,16 @@ use(r.value);
140
141
  The error is a `GitFailure`: a `Failure` from `@osdlc/result` with a `kind` to
141
142
  branch on, a one-line `message` and a `hint` for a person (`describe(error)`
142
143
  joins them), git's own output in `detail`, the `argv` and `exitCode`, and the
143
- `CommandFailed` it was read from in `cause`. The plain door throws the same failure, wrapped in a `FailureError` (`error.failure`), so a CLI that reports a thrown failure, such as `runMain` from `@osdlc/cli-tool`, shows "The remote refused the credentials" and exits 23 for a signed-out `git push`, as it does for a read. The thrown `message` names the command (`git push: The remote refused the credentials. …`); `failure.message` is the bare sentence, and `describeGitFailure(failure)` renders the same `git <verb>: <message> <hint>` line for a failure from `git.try.*`.
144
+ `CommandFailed` it was read from in `cause`.
145
+
146
+ The methods that throw (`git.push()` and the rest) throw the same failure,
147
+ wrapped in a `FailureError` (`error.failure`). So a CLI that reports a thrown
148
+ failure, such as `runMain` from `@osdlc/cli-tool`, shows "The remote refused
149
+ the credentials" and exits 23 for a signed-out `git push`, as it does for a
150
+ read. The thrown `message` names the command (`git push: The remote refused
151
+ the credentials. …`). `failure.message` is the bare sentence.
152
+ `describeGitFailure(failure)` builds the same `git <verb>: <message> <hint>`
153
+ line for a failure from `git.try.*`.
144
154
 
145
155
  | `kind` | When | `message` / `hint` |
146
156
  | --- | --- | --- |
@@ -159,10 +169,9 @@ differ and the failure is a plain `exit` with git's own line, never a wrong
159
169
  kind. `classifyGitFailure(commandFailed)` makes the same classification for a
160
170
  `CommandFailed` you caught yourself.
161
171
 
162
- It mirrors the whole surface, sync and async, and costs nothing per verb. Two
163
- rules keep it honest: it catches a thrown git failure and nothing else, so a
164
- `TypeError` still propagates; and a declared absence is `{ ok: true }`,
165
- because absence is an answer.
172
+ `git.try.*` covers every method, on both clients. Two rules apply. It catches
173
+ a thrown git failure and nothing else, so a `TypeError` still propagates. And
174
+ a declared absence is `{ ok: true }`, because absence is an answer.
166
175
 
167
176
  `git.soft.*` is for the narrower case where "could not ask" and "nothing
168
177
  there" are the same answer to the caller. Each verb that returns `null`, `[]`
@@ -174,29 +183,27 @@ const sha = git.soft.resolveRef(name); // string | null — null on a broke
174
183
  const dirty = git.soft.statusPorcelain(); // string[] — [] on a broken repo too
175
184
  ```
176
185
 
177
- It is the one-liner for `const r = git.try.resolveRef(x); return r.ok ? r.value : null`.
186
+ It is short for `const r = git.try.resolveRef(x); return r.ok ? r.value : null`.
178
187
  Verbs whose absence is not `null`, `[]` or `false` have no soft form: the
179
188
  outcome verbs such as `merge`, and `checkIgnore`, `aheadBehind` and `diffText`,
180
- plus every mutation. Reach for `try`. Boolean verbs fall back to
181
- `false`, which also means "could not ask": `soft.isDirty` reads a broken repo
182
- as clean, so do not gate a destructive action on it. `soft`
183
- catches a thrown git failure only, exactly like `try`, and one table
184
- (`./soft.ts`, checked against both clients) defines it for `Git` and
185
- `AsyncGit`.
189
+ plus every mutation. Use `try` for those. Boolean verbs fall back to
190
+ `false`, which also means "could not ask". `soft.isDirty` reads a broken repo
191
+ as clean, so do not base a destructive action on it. `soft` catches a thrown
192
+ git failure only, like `try`. One table (`./soft.ts`, checked against both
193
+ clients) defines it for `Git` and `AsyncGit`.
186
194
 
187
- ### The honest limit: git overloads exit 128
195
+ ### Exit 128 means two things in git
188
196
 
189
- For `show` and `log`, git spells *both* "that path/ref is not in the tree"
190
- *and* "this is not a repository" as exit 128. `showAtRev` and `logSubject`
191
- must therefore declare `absent: [128]`, and for those verbs absence and
192
- breakage remain indistinguishable — they keep exactly the weakness this
193
- contract removes elsewhere.
197
+ For `show` and `log`, git uses exit 128 both for "that path/ref is not in the
198
+ tree" and for "this is not a repository". So `showAtRev` and `logSubject`
199
+ must declare `absent: [128]`, and for those verbs absence and breakage look
200
+ the same. This contract cannot separate them there.
194
201
 
195
202
  Eight verbs declare 128 as absence: `showAtRev`, `topLevel`, `gitCommonDir`,
196
- `gitDir`, `symbolicRef`, `logSubject`, `objectExists` and `configRemoveSection`. `try` and `soft` inherit it, because 128 is a declared absence
203
+ `gitDir`, `symbolicRef`, `logSubject`, `objectExists` and `configRemoveSection`. `try` and `soft` behave the same, because 128 is a declared absence
197
204
  there: `git.try.logSubject("HEAD")` outside a repository is `{ ok: true,
198
- value: null }`, not a failure. The contract narrows the failure surface; it
199
- does not eliminate it.
205
+ value: null }`, not a failure. The contract reduces these cases. It does not
206
+ remove them.
200
207
 
201
208
  Where the difference matters, probe with `hasHistory()` first:
202
209
 
@@ -206,27 +213,26 @@ if (!git.hasHistory()) return [];
206
213
  const subject = git.logSubject("HEAD"); // a 128 here is now real breakage
207
214
  ```
208
215
 
209
- **Not `objectExists("HEAD")`.** It is a predicate over both of git's "no"
210
- codes, which is right for "does this name resolve?" and wrong for "does this
211
- repo have history?". Measured against real stores, `cat-file -e HEAD` exits
212
- **128** on an empty repository, **1** on a dangling HEAD ref, and **128** with
213
- the object directory removed — so `objectExists` answers `false` for all three
214
- and folds a *corrupt* store into "nothing here yet", which is the exact
215
- confusion this contract exists to remove. `hasHistory()` — `resolveRef("HEAD")`
216
- under the hood — separates them: **1** (→ `null`) for unborn, **0** for a dangling ref, **128**
217
- (→ throw) for a missing object store.
216
+ Do not use `objectExists("HEAD")` for this. It treats both of git's "no"
217
+ codes as `false`, which is right for "does this name resolve?" and wrong for
218
+ "does this repo have history?". Measured against real stores, `cat-file -e
219
+ HEAD` exits 128 on an empty repository, 1 on a dangling HEAD ref, and 128
220
+ with the object directory removed. So `objectExists` answers `false` for all
221
+ three, and a corrupt store reads as "nothing here yet". `hasHistory()` calls
222
+ `resolveRef("HEAD")`, which separates them: 1 (→ `null`) for unborn, 0 for a
223
+ dangling ref, 128 (→ throw) for a missing object store.
218
224
 
219
225
  ## Paths come back NUL-split
220
226
 
221
227
  `lsFiles`, `lsTree`, `diffNameOnly`, `diffNameStatus` and `diffTree` always
222
- pass `-z`. git's default output *quotes* a path containing a space, a quote or
228
+ pass `-z`. git's default output quotes a path containing a space, a quote or
223
229
  a non-ASCII byte (`"docs/a b.md"`), and a caller splitting on newlines reads the
224
230
  quotes as part of the name. There is no option to turn this off.
225
231
 
226
232
  `diffNameStatus` and `diffTree` return `{ status, path, from? }` rows. The
227
- status token is verbatim — `R100`, not `R` — a rename or copy reports its
228
- **destination** in `path` and its **source** in `from`, and `from` is absent on
229
- every other status:
233
+ status token is verbatim: `R100`, not `R`. A rename or copy reports its
234
+ destination in `path` and its source in `from`. `from` is absent on every
235
+ other status:
230
236
 
231
237
  ```ts
232
238
  git.diffNameStatus({ cached: true });
@@ -235,7 +241,7 @@ git.diffNameStatus({ cached: true });
235
241
  ```
236
242
 
237
243
  That record is three NUL fields (`R100`, old path, new path) where every other
238
- record is two, which is what a hand-rolled caller-side split gets wrong.
244
+ record is two. A split written by hand often gets this wrong.
239
245
 
240
246
  `lsTree` is `-z` for the same reason, and returns
241
247
  `{ mode, type, sha, sizeBytes, path }` rows. `sizeBytes` is set only for a blob
@@ -244,8 +250,8 @@ prints `-` there and a fabricated `0` would be worse than nothing.
244
250
 
245
251
  ## Exit codes that are answers
246
252
 
247
- Two verbs carry their answer in the exit code rather than in stdout, and both
248
- are here because a caller reading `exitCode` by hand gets them wrong:
253
+ Two verbs carry their answer in the exit code rather than in stdout. Both are
254
+ here because a caller reading `exitCode` by hand often gets them wrong:
249
255
 
250
256
  ```ts
251
257
  git.grep("TODO|FIXME", { extendedRegexp: true, lineNumber: true });
@@ -261,23 +267,23 @@ git.isAncestor(sha, "origin/main");
261
267
 
262
268
  An exit code only answers when git produced it. A `git` missing from PATH, a
263
269
  timeout kill or an abort leaves the runner with no exit code of its own to
264
- report, and every verb throws the classified failure there — none of them reads that
265
- as "no matches" or "no such key".
270
+ report. Every verb throws the classified failure there. None of them reads
271
+ that as "no matches" or "no such key".
266
272
 
267
273
  `aheadBehind` is here for a different reason: it owns a field order that is
268
274
  easy to invert. `rev-list --left-right --count base...tip` prints the left
269
- count first, and left is `base` — so that number is *behind*, not ahead.
275
+ count first, and left is `base`. So that number is behind, not ahead.
270
276
 
271
277
  ```ts
272
278
  git.aheadBehind("origin/main", "HEAD"); // { ahead: 2, behind: 1 }
273
279
  ```
274
280
 
275
- Two more edges worth knowing, both exit 0 with empty output rather than an
276
- error: `diffTree` on a **root commit** reports nothing unless you pass
281
+ Two more cases exit 0 with empty output rather than an error: `diffTree` on
282
+ a root commit reports nothing unless you pass
277
283
  `{ root: true }`, and a `grep` pathspec that matches no file is
278
284
  indistinguishable from "no matches".
279
285
 
280
- `diffTreeNumstat(rev, opts)` is the counting twin of `diffTree`, with the same
286
+ `diffTreeNumstat(rev, opts)` is the line-count version of `diffTree`, with the same
281
287
  options and rows of `{ path, linesAdded, linesDeleted }` (`null` counts for a
282
288
  binary file). Two verbs rather than one option, because git rejects
283
289
  `--numstat` together with `--name-status`.
@@ -323,16 +329,16 @@ The exit code alone cannot carry this. Measured against git 2.50.1:
323
329
  | `merge-tree`, unmergeable name | `1` — **stdout empty** |
324
330
  | `merge-tree`, unrelated histories | `128` |
325
331
 
326
- A ref git cannot resolve exits **1, exactly like a conflict**. What separates
332
+ A ref git cannot resolve exits 1, exactly like a conflict. What separates
327
333
  them is that a conflict always writes its report to stdout and a refusal
328
- writes nothing there — a structural signal rather than a string match, because
329
- git's messages are translatable and a locale must not change what an outcome
330
- means.
334
+ writes nothing there. The check looks at where the output goes, not at git's
335
+ words, because git's messages are translated and a locale must not change
336
+ what an outcome means.
331
337
 
332
338
  `conflicts` on the outcome is that report, so treat it as a summary:
333
339
  rename/rename and rename/delete have no parseable form in it, and under a
334
- localized git it can be empty on a real conflict. **`lsFilesUnmerged()` is the
335
- authoritative list.** Its stage detail is also what tells the shapes apart —
340
+ localized git it can be empty on a real conflict. `lsFilesUnmerged()` is the
341
+ authoritative list. Its stage detail is also what tells the shapes apart:
336
342
  all of 1/2/3 is both-modified, 1+3 is we-deleted, 1+2 is they-deleted, 2+3
337
343
  with no base is add/add. A resolver that assumes both-modified deletes files.
338
344
  For the paths alone, `diffNameOnly({ diffFilter: "U" })` is cheaper.
@@ -341,17 +347,17 @@ For the paths alone, `diffNameOnly({ diffFilter: "U" })` is cheaper.
341
347
  backend and call `env`, so `fastForward`, `alreadyUpToDate` and `conflicts` do
342
348
  not change with the caller's locale. Other verbs keep the caller's locale.
343
349
 
344
- One sharp edge git leaves in `checkoutSide`: on a path that is *not*
345
- conflicted it exits 0 and does nothing. There is no error to catch, so take
346
- the path list from `lsFilesUnmerged()` in the same breath, not from an
347
- earlier one. An empty path list returns without running git.
350
+ One trap in `checkoutSide`: on a path that is not conflicted, git exits 0 and
351
+ does nothing. There is no error to catch, so take the path list from
352
+ `lsFilesUnmerged()` just before the call, not from an earlier one. An empty
353
+ path list returns without running git.
348
354
 
349
355
  ## Asking without checking out
350
356
 
351
- `mergeTree` answers the same question as `merge` — would this merge, and where
352
- would it conflict — against the object database alone. No index, no checkout,
353
- no worktree, so it needs no clean tree to run in and leaves nothing to clean
354
- up:
357
+ `mergeTree` answers the same question as `merge` (would this merge, and where
358
+ would it conflict) against the object database alone. It uses no index, no
359
+ checkout and no worktree, so it needs no clean tree to run in and leaves
360
+ nothing to clean up:
355
361
 
356
362
  ```ts
357
363
  const out = git.mergeTree("main", "origin/topic");
@@ -361,14 +367,13 @@ if (out.status === "clean") {
361
367
  }
362
368
  ```
363
369
 
364
- Surveying many branches is where this pays: predicting every open PR's merge
365
- across a large repository costs seconds, while checking each one out to learn
366
- the same thing costs minutes — and most of them merge cleanly, so the checkout
367
- was wasted.
370
+ This helps most when checking many branches. Predicting every open PR's merge
371
+ across a large repository takes seconds. Checking each one out to learn the
372
+ same thing takes minutes, and most of them merge cleanly anyway.
368
373
 
369
- Two differences from `merge` are worth knowing. Its conflict list **is**
370
- authoritative — git names the paths in a machine-readable section rather than
371
- in prose, so there is no `lsFilesUnmerged()` to follow up with. And it takes
374
+ Two differences from `merge`. Its conflict list is authoritative: git names
375
+ the paths in a machine-readable section rather than in prose, so there is no
376
+ need to call `lsFilesUnmerged()` after it. And it takes
372
377
  both sides as arguments rather than merging into the current branch, so
373
378
  nothing depends on where `HEAD` happens to be.
374
379
 
@@ -380,12 +385,12 @@ const raw = git.log({ format: "format:%x1e%H%x1f%s", numstat: true });
380
385
 
381
386
  `log` returns stdout unsplit and untrimmed. The format is yours, and callers
382
387
  frame their own records with `%x1e` / `%x1f` or interleave `--name-status`
383
- blocks — splitting on newlines would cut those records in half. For a
388
+ blocks. Splitting on newlines would cut those records in half. For a
384
389
  one-record-per-line format, `logLines(opts)` is `log` plus that split.
385
390
 
386
- It declares no absence code, deliberately. An empty repository exits 128 —
387
- the same code a corrupt one gives — so `log` on a store with no commits
388
- throws. Probe first, or tolerate:
391
+ It declares no absence code, on purpose. An empty repository exits 128, the
392
+ same code a corrupt one gives, so `log` on a store with no commits throws.
393
+ Check first, or use `try`:
389
394
 
390
395
  ```ts
391
396
  if (git.hasHistory()) git.log({ format: "%H" });
@@ -410,7 +415,7 @@ git.remoteAdd("origin", url);
410
415
 
411
416
  `remoteOwnerRepo(remote = "origin")` is `remoteGetUrl` plus a parse: `null`
412
417
  when there is no such remote or its URL names no project. The parse is
413
- host-agnostic (`parseRemoteUrl`: scp-style and `scheme://[user@]host[:port]/…`),
418
+ not tied to known hosts (`parseRemoteUrl`: scp-style and `scheme://[user@]host[:port]/…`),
414
419
  so a self-hosted Forgejo or Gitea answers, which `parseGitUrl` would not. Two
415
420
  limits: a path with groups, `group/sub/repo`, gives owner `sub` and repo
416
421
  `repo`; and a port is read only from an `http(s)://` URL. The port of an
@@ -419,8 +424,8 @@ throws outside a repository like `remoteGetUrl`; use `git.try.remoteOwnerRepo()`
419
424
  to fold that into a failed outcome.
420
425
 
421
426
  `resolveRef` passes `--verify --quiet`, so a ref that does not resolve is
422
- `null` and an unreadable store still throws. That is what makes `hasHistory()`
423
- the repository-health probe and `objectExists("HEAD")` the wrong one.
427
+ `null` and an unreadable store still throws. That is why `hasHistory()` is the
428
+ way to check a repository, and `objectExists("HEAD")` is not.
424
429
 
425
430
  `headRef` and `currentBranch` differ only on a detached HEAD: `headRef` prints
426
431
  the literal `"HEAD"`, `currentBranch` answers `null`. Pick by what the caller
@@ -572,16 +577,16 @@ throws.
572
577
  | `try.*` | The whole surface again, returning `Result<T, GitFailure>` (from `@osdlc/result`) instead of throwing. |
573
578
  | `soft.*` | Every verb with an absence value, returning it instead of throwing. |
574
579
 
575
- `raw` is the honest answer for a one-off — `update-ref`, `tag -a`, a patch
576
- from `diff --unified`. A verb earns its place by having a
577
- parser worth sharing or an absence worth declaring, not by existing.
580
+ Use `raw` for a one-off command, such as `update-ref`, `tag -a` or a patch
581
+ from `diff --unified`. A git command gets its own verb only when it has a
582
+ parser worth sharing or an absence worth declaring.
578
583
 
579
584
  ## Driving the CLI, or something else
580
585
 
581
- `AsyncGit` talks to a **`GitBackend`**, which takes a `GitRequest` — a plain,
582
- serializable description of one operation — and returns its typed result.
583
- Deliberately not argv: argv is a CLI detail, and a backend built on a
584
- pure-JavaScript git has no argv to receive.
586
+ `AsyncGit` calls a `GitBackend`, which takes a `GitRequest` (a plain,
587
+ serializable description of one operation) and returns its typed result. The
588
+ request is not argv on purpose. argv is a CLI detail, and a backend built on
589
+ a pure-JavaScript git has no argv to receive.
585
590
 
586
591
  ```ts
587
592
  import { AsyncGit, cliBackend, partialBackend } from "@osdlc/typed-git";
@@ -598,15 +603,15 @@ await new AsyncGit(cwd, { backend }).branchExists("topic"); // true
598
603
  await new AsyncGit(cwd, { backend }).worktrees(); // UnsupportedRequest
599
604
  ```
600
605
 
601
- Because a request is data, it can also be logged, queued, or replayed. The one
602
- request that cannot cross that line is `raw`, which is argv by definition.
606
+ Because a request is data, it can also be logged, queued, or replayed. The
607
+ exception is `raw`, which is argv by definition.
603
608
 
604
609
  ## Injecting the subprocess seam
605
610
 
606
611
  `Git` takes a `CommandRunner` and `cliBackend` takes an `AsyncCommandRunner`,
607
612
  both from [`@osdlc/command-seam`](https://www.npmjs.com/package/@osdlc/command-seam).
608
- That is the layer to replace when you want a real `git` but your own spawning —
609
- a fake in tests, a supervised child, a timeout policy of your own.
613
+ Replace the runner when you want a real `git` but your own way of spawning
614
+ it, such as a fake in tests, a supervised child, or your own timeout policy.
610
615
 
611
616
  ```ts
612
617
  import { Git, type CommandRunner } from "@osdlc/typed-git";
@@ -627,23 +632,23 @@ calls; // [["branch", "--show-current"]]
627
632
  const failing: CommandRunner = {
628
633
  run: () => ({ exitCode: 128, stdout: "", stderr: "fatal: not a git repository\n" }),
629
634
  };
630
- new Git("/nowhere", { runner: failing }).currentBranch(); // throws CommandFailed
635
+ new Git("/nowhere", { runner: failing }).currentBranch(); // throws FailureError (kind "not-a-repo")
631
636
  ```
632
637
 
633
638
  `runner: undefined` is the same as omitting it, so a caller holding an optional
634
639
  runner passes it straight through, without a conditional spread. `cliBackend`
635
640
  accepts it too.
636
641
 
637
- The seam's exports are re-exported here, so wiring a runner or catching a
642
+ command-seam's exports are re-exported here, so wiring a runner or catching a
638
643
  `CommandFailed` needs one import rather than two.
639
644
 
640
645
  ## Also: git references
641
646
 
642
- `parseGitUrl` turns any git reference — https, ssh, scp-style, `owner/repo`
643
- shorthand, `github:owner/repo` — into its host, user, and project, over
644
- `hosted-git-info`. `gitSshUrl` builds the scp-style clone URL back out of it.
645
- Returns `null` on anything that is not a known git host — a parse, not a git
646
- invocation, so nothing here throws.
647
+ `parseGitUrl` turns any git reference (https, ssh, scp-style, `owner/repo`
648
+ shorthand, `github:owner/repo`) into its host, user, and project, using
649
+ `hosted-git-info`. `gitSshUrl` builds the scp-style clone URL from it. Both
650
+ return `null` for anything that is not a known git host. They only parse and
651
+ never run git, so nothing here throws.
647
652
 
648
653
  ```ts
649
654
  parseGitUrl("github:acme/widgets#v1");
@@ -659,9 +664,9 @@ is what `remoteOwnerRepo` uses, and it stays on `@osdlc/typed-git/client`.
659
664
  Use it for a remote read from a checkout (any host); use `parseGitUrl` /
660
665
  `parseRepoRef` for a URL a person pasted.
661
666
 
662
- `parseRepoRef` is the question a clone command asks: given anything a person
663
- might paste — a clone URL, the page of a pull request or a file, a bare
664
- `owner/repo` — which repository, and what does `git clone` take? It returns
667
+ `parseRepoRef` answers the question a clone command asks. Given anything a
668
+ person might paste (a clone URL, the page of a pull request or a file, a bare
669
+ `owner/repo`), which repository is it, and what does `git clone` take? It returns
665
670
  the host, owner and repo, a clone URL, and any branch the input named. An
666
671
  explicit `https://…` or `git@…:` input keeps its protocol; shorthand takes
667
672
  the `protocol` argument (default `https`).
@@ -681,20 +686,20 @@ parseRepoRef("./a/local/path"); // null — the input names no repository
681
686
  (`parseGitUrl`, `gitSshUrl`, `parseRepoRef` and their types) and the checkout
682
687
  walks (`checkoutRoot`, `discoverCheckouts`, `scanForCheckouts`, their types,
683
688
  `DEFAULT_MAX_DEPTH` and `DEFAULT_WARN_AFTER`). It has no `hosted-git-info` on
684
- your module graph. That package stays in `dependencies` either way — a bundle
685
- saving, not an install one.
689
+ your module graph. That package stays in `dependencies` either way, so this
690
+ makes the bundle smaller, not the install.
686
691
 
687
692
  `@osdlc/typed-git/testing` builds throwaway repositories:
688
693
 
689
694
  - `makeGitFixture({ dir?, parent?, prefix?, identity?, initialBranch?, bare? })`
690
695
  — one initialized repo.
691
696
  - `makeOriginAndCheckout({ parent?, identity?, initialBranch?, files? })` — an
692
- origin plus a **clone** of it. Returns `{ origin, checkout, cleanup }`.
697
+ origin plus a clone of it. Returns `{ origin, checkout, cleanup }`.
693
698
  - `makeBareAndWorker({ remoteName?, parent?, identity?, initialBranch? })` — a
694
- bare store plus an **independently-inited** worker that names it as a remote.
695
- Returns `{ bare, worker, remoteName, parent, cleanup }`. Not a clone: the
696
- worker starts with no history and no tracking, so its first push is a
697
- genuine publish into an empty store.
699
+ bare store plus a separately initialized worker that names it as a remote.
700
+ Returns `{ bare, worker, remoteName, parent, cleanup }`. It is not a clone:
701
+ the worker starts with no history and no tracking, so its first push is a
702
+ real first push into an empty store.
698
703
 
699
704
  `cleanup()` is manual. Nothing removes a fixture when the process exits, so
700
705
  call it in a `finally` block or an `afterEach`. The helpers have named option
@@ -706,15 +711,15 @@ suite that asserts on a sha gets the same sha every run. Only the identity
706
711
  (and `commit.gpgsign=false` in the fixture repository) is isolated.
707
712
  `core.hooksPath`, `commit.template`, `init.templateDir`, `core.autocrlf` and
708
713
  other global or system git config still apply. To isolate them, set
709
- `GIT_CONFIG_GLOBAL` and `GIT_CONFIG_NOSYSTEM` through `identity`. The identity is bound
710
- as the fixture client's **client-level `env`**, so every call through
711
- `fixture.git` carries it — the suite's own calls included, not just the ones
714
+ `GIT_CONFIG_GLOBAL` and `GIT_CONFIG_NOSYSTEM` through `identity`. The identity is set
715
+ as the fixture client's client-level `env`, so every call through
716
+ `fixture.git` carries it, the suite's own calls included, not just the ones
712
717
  the fixture makes. `IDENTITY` is exported and frozen, so a suite asserting on
713
718
  dates reads the pinned values instead of re-declaring them. `fixture.commit(msg,
714
719
  files, { date, env })` overrides them for one commit.
715
720
 
716
721
  Pass `parent` to put two related repos under one directory (and `dir` to name
717
- one exactly) — the way to have a suite delete a single tree at the end, or
722
+ one exactly). Use it to have a suite delete a single tree at the end, or to
718
723
  assert on relative paths between two repositories. `cleanup()` removes the
719
724
  `dir` you named. The one from `makeBareAndWorker` removes its whole `parent`,
720
725
  including a `parent` you passed in. `makeOriginAndCheckout` removes only its
@@ -735,11 +740,11 @@ try {
735
740
  ## Also: finding a checkout without git
736
741
 
737
742
  `checkoutRoot(path)` finds the git checkout containing `path` by walking up
738
- for a `.git` entry — a pure filesystem check, no git process. `path` may be a
739
- file or a directory. Returns `null` rather than throwing when there is no
740
- checkout, and does not distinguish a linked worktree (`.git` as a file) from a
741
- main checkout (`.git` as a directory) — callers that need `git`'s own answer
742
- (bare repos, `GIT_DIR` overrides) use `Git#topLevel()` instead.
743
+ for a `.git` entry. It reads the filesystem only and runs no git process.
744
+ `path` may be a file or a directory. It returns `null` rather than throwing
745
+ when there is no checkout. It does not tell a linked worktree (`.git` as a
746
+ file) from a main checkout (`.git` as a directory). Callers that need git's
747
+ own answer (bare repos, `GIT_DIR` overrides) use `Git#topLevel()` instead.
743
748
 
744
749
  ```ts
745
750
  import { checkoutRoot } from "@osdlc/typed-git";
@@ -771,7 +776,7 @@ de-duplicate.
771
776
  - No call has a default timeout. Pass `timeoutMs` where a hung `git` would
772
777
  hurt.
773
778
  - `Git` kills a child that writes more than 256 MB to one stream and throws
774
- `CommandFailed`. `AsyncGit` has no such cap. The `maxOutputBytes` call
779
+ the classified failure. `AsyncGit` has no such cap. The `maxOutputBytes` call
775
780
  option sets the cap for one call on either client. Output cut short at a
776
781
  cap or a timeout is a failure, never an answer.
777
782
  - stdout is text. There is no verb or call option that returns raw bytes,
@@ -781,9 +786,11 @@ de-duplicate.
781
786
  - Output is captured, never streamed. For live progress from `clone` or
782
787
  `fetch`, run git through command-seam's `streamRunner`.
783
788
  - `Git` cannot cancel a call. `AsyncGit` takes a `signal`.
784
- - A `CommandFailed` carries `argv`, `result` and `detail`. Read `detail` for
785
- the message, because git writes some failure text to stdout.
786
- - `UnsupportedRequest` is not a `CommandFailed`, so `try` and `soft` let it
789
+ - A thrown `FailureError` carries the `GitFailure` in `error.failure`, with
790
+ `argv`, `exitCode` and `detail`. Read `detail` for git's message, because
791
+ git writes some failure text to stdout. `error.cause` is the
792
+ `CommandFailed`, with the raw `result`.
793
+ - `UnsupportedRequest` is not a git failure, so `try` and `soft` let it
787
794
  through.
788
795
  - `merge`, `rebase` and `rebaseContinue` run with `LC_ALL=C`. Any other verb
789
796
  that reads git's messages assumes English output, so a localized git can