@statewalker/vcs-commands 0.8.0 → 0.9.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.
Files changed (297) hide show
  1. package/dist/commands/add-command.d.ts +32 -0
  2. package/dist/commands/add-command.d.ts.map +1 -1
  3. package/dist/commands/add-patch/add-patch.d.ts +7 -0
  4. package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
  5. package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
  6. package/dist/commands/am/am-command.d.ts +47 -0
  7. package/dist/commands/am/am-command.d.ts.map +1 -1
  8. package/dist/commands/apply/apply-command.d.ts +2 -0
  9. package/dist/commands/apply/apply-command.d.ts.map +1 -1
  10. package/dist/commands/apply/apply-parse.d.ts +7 -0
  11. package/dist/commands/apply/apply-parse.d.ts.map +1 -1
  12. package/dist/commands/apply/index.d.ts +1 -1
  13. package/dist/commands/apply/index.d.ts.map +1 -1
  14. package/dist/commands/blame-command.d.ts +303 -8
  15. package/dist/commands/blame-command.d.ts.map +1 -1
  16. package/dist/commands/blame-ignore.d.ts +48 -0
  17. package/dist/commands/blame-ignore.d.ts.map +1 -0
  18. package/dist/commands/check-mailmap-command.d.ts +49 -0
  19. package/dist/commands/check-mailmap-command.d.ts.map +1 -0
  20. package/dist/commands/checkout-command.d.ts +7 -0
  21. package/dist/commands/checkout-command.d.ts.map +1 -1
  22. package/dist/commands/checkout-paths.d.ts +4 -0
  23. package/dist/commands/checkout-paths.d.ts.map +1 -1
  24. package/dist/commands/cherry-command.d.ts +61 -0
  25. package/dist/commands/cherry-command.d.ts.map +1 -0
  26. package/dist/commands/cherry-pick-command.d.ts +23 -1
  27. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  28. package/dist/commands/clean-command.d.ts +32 -0
  29. package/dist/commands/clean-command.d.ts.map +1 -1
  30. package/dist/commands/clean-interactive.d.ts +56 -0
  31. package/dist/commands/clean-interactive.d.ts.map +1 -0
  32. package/dist/commands/clone-command.d.ts +116 -2
  33. package/dist/commands/clone-command.d.ts.map +1 -1
  34. package/dist/commands/commit-command.d.ts +50 -2
  35. package/dist/commands/commit-command.d.ts.map +1 -1
  36. package/dist/commands/describe-command.d.ts +71 -64
  37. package/dist/commands/describe-command.d.ts.map +1 -1
  38. package/dist/commands/diff-command.d.ts +118 -6
  39. package/dist/commands/diff-command.d.ts.map +1 -1
  40. package/dist/commands/fetch-command.d.ts +60 -0
  41. package/dist/commands/fetch-command.d.ts.map +1 -1
  42. package/dist/commands/fetch-multiple-command.d.ts +193 -0
  43. package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
  44. package/dist/commands/format-patch-command.d.ts +28 -2
  45. package/dist/commands/format-patch-command.d.ts.map +1 -1
  46. package/dist/commands/git-describe.d.ts +77 -4
  47. package/dist/commands/git-describe.d.ts.map +1 -1
  48. package/dist/commands/git-hooks.d.ts +15 -1
  49. package/dist/commands/git-hooks.d.ts.map +1 -1
  50. package/dist/commands/index.d.ts +12 -0
  51. package/dist/commands/index.d.ts.map +1 -1
  52. package/dist/commands/index.js +5 -3
  53. package/dist/commands/init-command.d.ts +89 -0
  54. package/dist/commands/init-command.d.ts.map +1 -1
  55. package/dist/commands/line-log.d.ts +161 -0
  56. package/dist/commands/line-log.d.ts.map +1 -0
  57. package/dist/commands/log-command.d.ts +235 -6
  58. package/dist/commands/log-command.d.ts.map +1 -1
  59. package/dist/commands/log-graph.d.ts +4 -2
  60. package/dist/commands/log-graph.d.ts.map +1 -1
  61. package/dist/commands/log-output.d.ts +66 -1
  62. package/dist/commands/log-output.d.ts.map +1 -1
  63. package/dist/commands/mailmap.d.ts +24 -1
  64. package/dist/commands/mailmap.d.ts.map +1 -1
  65. package/dist/commands/merge-command.d.ts +51 -1
  66. package/dist/commands/merge-command.d.ts.map +1 -1
  67. package/dist/commands/merge-drivers.d.ts +2 -0
  68. package/dist/commands/merge-drivers.d.ts.map +1 -1
  69. package/dist/commands/merge-strategy-options.d.ts +69 -0
  70. package/dist/commands/merge-strategy-options.d.ts.map +1 -0
  71. package/dist/commands/merge-support.d.ts +10 -0
  72. package/dist/commands/merge-support.d.ts.map +1 -1
  73. package/dist/commands/message-cleanup.d.ts +2 -0
  74. package/dist/commands/message-cleanup.d.ts.map +1 -1
  75. package/dist/commands/name-rev-command.d.ts +65 -0
  76. package/dist/commands/name-rev-command.d.ts.map +1 -0
  77. package/dist/commands/name-rev.d.ts +110 -22
  78. package/dist/commands/name-rev.d.ts.map +1 -1
  79. package/dist/commands/octopus-merge.d.ts +26 -1
  80. package/dist/commands/octopus-merge.d.ts.map +1 -1
  81. package/dist/commands/ort-merge.d.ts +16 -0
  82. package/dist/commands/ort-merge.d.ts.map +1 -1
  83. package/dist/commands/ort-recursive.d.ts.map +1 -1
  84. package/dist/commands/patch-id.d.ts +58 -0
  85. package/dist/commands/patch-id.d.ts.map +1 -1
  86. package/dist/commands/pull-command.d.ts +182 -38
  87. package/dist/commands/pull-command.d.ts.map +1 -1
  88. package/dist/commands/push-command.d.ts +65 -0
  89. package/dist/commands/push-command.d.ts.map +1 -1
  90. package/dist/commands/range-diff/index.d.ts +4 -0
  91. package/dist/commands/range-diff/index.d.ts.map +1 -0
  92. package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
  93. package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
  94. package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
  95. package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
  96. package/dist/commands/range-diff/range-diff.d.ts +106 -0
  97. package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
  98. package/dist/commands/read-tree-command.d.ts +14 -0
  99. package/dist/commands/read-tree-command.d.ts.map +1 -1
  100. package/dist/commands/rebase-command.d.ts +21 -2
  101. package/dist/commands/rebase-command.d.ts.map +1 -1
  102. package/dist/commands/remerge-diff.d.ts +59 -0
  103. package/dist/commands/remerge-diff.d.ts.map +1 -0
  104. package/dist/commands/remote-command.d.ts +41 -0
  105. package/dist/commands/remote-command.d.ts.map +1 -1
  106. package/dist/commands/remote-show-command.d.ts +204 -0
  107. package/dist/commands/remote-show-command.d.ts.map +1 -0
  108. package/dist/commands/reset-command.d.ts +19 -1
  109. package/dist/commands/reset-command.d.ts.map +1 -1
  110. package/dist/commands/restore-command.d.ts +7 -0
  111. package/dist/commands/restore-command.d.ts.map +1 -1
  112. package/dist/commands/rev-list-command.d.ts +75 -3
  113. package/dist/commands/rev-list-command.d.ts.map +1 -1
  114. package/dist/commands/revert-command.d.ts +22 -1
  115. package/dist/commands/revert-command.d.ts.map +1 -1
  116. package/dist/commands/revision-range.d.ts +2 -0
  117. package/dist/commands/revision-range.d.ts.map +1 -1
  118. package/dist/commands/sequencer-pick.d.ts +102 -1
  119. package/dist/commands/sequencer-pick.d.ts.map +1 -1
  120. package/dist/commands/sequencer-support.d.ts +10 -1
  121. package/dist/commands/sequencer-support.d.ts.map +1 -1
  122. package/dist/commands/shortlog-command.d.ts +109 -0
  123. package/dist/commands/shortlog-command.d.ts.map +1 -0
  124. package/dist/commands/shortlog.d.ts +151 -0
  125. package/dist/commands/shortlog.d.ts.map +1 -0
  126. package/dist/commands/status-command.d.ts +31 -2
  127. package/dist/commands/status-command.d.ts.map +1 -1
  128. package/dist/commands/submodule-commands.d.ts +90 -2
  129. package/dist/commands/submodule-commands.d.ts.map +1 -1
  130. package/dist/commands/submodule-fetch.d.ts +149 -0
  131. package/dist/commands/submodule-fetch.d.ts.map +1 -0
  132. package/dist/commands/submodule-model.d.ts +8 -0
  133. package/dist/commands/submodule-model.d.ts.map +1 -1
  134. package/dist/commands/submodule-unpack.d.ts +120 -0
  135. package/dist/commands/submodule-unpack.d.ts.map +1 -0
  136. package/dist/commands/submodule-update-command.d.ts +8 -0
  137. package/dist/commands/submodule-update-command.d.ts.map +1 -1
  138. package/dist/commands/subtree-shift.d.ts +27 -0
  139. package/dist/commands/subtree-shift.d.ts.map +1 -0
  140. package/dist/commands/switch-command.d.ts +3 -0
  141. package/dist/commands/switch-command.d.ts.map +1 -1
  142. package/dist/commands/tree-restore.d.ts.map +1 -1
  143. package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
  144. package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
  145. package/dist/{commands-ISM52N0n.js → commands-CNvli5bl.js} +39426 -61169
  146. package/dist/errors/command-errors.d.ts +25 -0
  147. package/dist/errors/command-errors.d.ts.map +1 -1
  148. package/dist/errors/index.js +29 -1
  149. package/dist/fsck-CPeDh9fh.js +5138 -0
  150. package/dist/git-command.d.ts +31 -1
  151. package/dist/git-command.d.ts.map +1 -1
  152. package/dist/git.d.ts +97 -1
  153. package/dist/git.d.ts.map +1 -1
  154. package/dist/guarded-transport-command.d.ts +82 -0
  155. package/dist/guarded-transport-command.d.ts.map +1 -0
  156. package/dist/index.d.ts +1 -0
  157. package/dist/index.d.ts.map +1 -1
  158. package/dist/index.js +6 -5
  159. package/dist/remote-transport-CCmBadm-.js +1606 -0
  160. package/dist/rename/detect-renames.d.ts +20 -0
  161. package/dist/rename/detect-renames.d.ts.map +1 -1
  162. package/dist/rename/diffcore-break.d.ts +51 -0
  163. package/dist/rename/diffcore-break.d.ts.map +1 -0
  164. package/dist/rename/index.d.ts +1 -0
  165. package/dist/rename/index.d.ts.map +1 -1
  166. package/dist/results/blame-format.d.ts +62 -1
  167. package/dist/results/blame-format.d.ts.map +1 -1
  168. package/dist/results/clone-result.d.ts +9 -0
  169. package/dist/results/clone-result.d.ts.map +1 -1
  170. package/dist/results/diff-dirstat.d.ts +36 -0
  171. package/dist/results/diff-dirstat.d.ts.map +1 -0
  172. package/dist/results/diff-entry.d.ts +10 -0
  173. package/dist/results/diff-entry.d.ts.map +1 -1
  174. package/dist/results/diff-formatter.d.ts.map +1 -1
  175. package/dist/results/diff-output.d.ts +18 -0
  176. package/dist/results/diff-output.d.ts.map +1 -1
  177. package/dist/results/fetch-result.d.ts +12 -1
  178. package/dist/results/fetch-result.d.ts.map +1 -1
  179. package/dist/results/index.d.ts +2 -0
  180. package/dist/results/index.d.ts.map +1 -1
  181. package/dist/results/index.js +2 -2
  182. package/dist/results/init-result.d.ts +8 -1
  183. package/dist/results/init-result.d.ts.map +1 -1
  184. package/dist/results/line-range-hunks.d.ts +27 -0
  185. package/dist/results/line-range-hunks.d.ts.map +1 -0
  186. package/dist/results/merge-result.d.ts +8 -1
  187. package/dist/results/merge-result.d.ts.map +1 -1
  188. package/dist/results/pull-result.d.ts +11 -0
  189. package/dist/results/pull-result.d.ts.map +1 -1
  190. package/dist/results/push-result.d.ts +5 -0
  191. package/dist/results/push-result.d.ts.map +1 -1
  192. package/dist/results/status-result.d.ts +1 -1
  193. package/dist/results/status-result.d.ts.map +1 -1
  194. package/dist/results-BDuEgdLU.js +46847 -0
  195. package/dist/transport-command.d.ts +14 -0
  196. package/dist/transport-command.d.ts.map +1 -1
  197. package/package.json +12 -12
  198. package/src/commands/add-command.ts +115 -0
  199. package/src/commands/add-patch/add-patch.ts +8 -0
  200. package/src/commands/add-patch/patch-backend.ts +20 -2
  201. package/src/commands/am/am-command.ts +138 -4
  202. package/src/commands/apply/apply-command.ts +52 -9
  203. package/src/commands/apply/apply-parse.ts +10 -0
  204. package/src/commands/apply/index.ts +8 -1
  205. package/src/commands/blame-command.ts +1450 -51
  206. package/src/commands/blame-ignore.ts +307 -0
  207. package/src/commands/check-mailmap-command.ts +129 -0
  208. package/src/commands/checkout-command.ts +97 -12
  209. package/src/commands/checkout-paths.ts +28 -0
  210. package/src/commands/cherry-command.ts +187 -0
  211. package/src/commands/cherry-pick-command.ts +42 -1
  212. package/src/commands/clean-command.ts +92 -12
  213. package/src/commands/clean-interactive.ts +522 -0
  214. package/src/commands/clone-command.ts +596 -44
  215. package/src/commands/commit-command.ts +180 -47
  216. package/src/commands/describe-command.ts +341 -254
  217. package/src/commands/diff-command.ts +616 -56
  218. package/src/commands/fetch-command.ts +353 -6
  219. package/src/commands/fetch-multiple-command.ts +665 -0
  220. package/src/commands/format-patch-command.ts +189 -77
  221. package/src/commands/git-describe.ts +456 -217
  222. package/src/commands/git-hooks.ts +42 -3
  223. package/src/commands/index.ts +17 -0
  224. package/src/commands/init-command.ts +603 -49
  225. package/src/commands/line-log.ts +931 -0
  226. package/src/commands/log-command.ts +1414 -177
  227. package/src/commands/log-graph.ts +6 -3
  228. package/src/commands/log-output.ts +173 -10
  229. package/src/commands/mailmap.ts +41 -5
  230. package/src/commands/merge-command.ts +274 -16
  231. package/src/commands/merge-drivers.ts +3 -0
  232. package/src/commands/merge-strategy-options.ts +224 -0
  233. package/src/commands/merge-support.ts +101 -21
  234. package/src/commands/message-cleanup.ts +1 -1
  235. package/src/commands/name-rev-command.ts +184 -0
  236. package/src/commands/name-rev.ts +700 -109
  237. package/src/commands/octopus-merge.ts +35 -11
  238. package/src/commands/ort-merge.ts +41 -7
  239. package/src/commands/ort-recursive.ts +40 -2
  240. package/src/commands/patch-id.ts +109 -0
  241. package/src/commands/pull-command.ts +718 -224
  242. package/src/commands/push-command.ts +353 -3
  243. package/src/commands/range-diff/index.ts +3 -0
  244. package/src/commands/range-diff/linear-assignment.ts +203 -0
  245. package/src/commands/range-diff/range-diff-command.ts +433 -0
  246. package/src/commands/range-diff/range-diff.ts +617 -0
  247. package/src/commands/read-tree-command.ts +74 -3
  248. package/src/commands/rebase-command.ts +141 -65
  249. package/src/commands/remerge-diff.ts +241 -0
  250. package/src/commands/remote-command.ts +98 -10
  251. package/src/commands/remote-show-command.ts +836 -0
  252. package/src/commands/reset-command.ts +78 -3
  253. package/src/commands/restore-command.ts +15 -0
  254. package/src/commands/rev-list-command.ts +187 -11
  255. package/src/commands/revert-command.ts +41 -1
  256. package/src/commands/revision-range.ts +3 -1
  257. package/src/commands/sequencer-pick.ts +323 -29
  258. package/src/commands/sequencer-support.ts +164 -2
  259. package/src/commands/shortlog-command.ts +354 -0
  260. package/src/commands/shortlog.ts +361 -0
  261. package/src/commands/show-command.ts +2 -1
  262. package/src/commands/status-command.ts +115 -25
  263. package/src/commands/status-format.ts +1 -1
  264. package/src/commands/submodule-commands.ts +321 -3
  265. package/src/commands/submodule-fetch.ts +789 -0
  266. package/src/commands/submodule-model.ts +9 -1
  267. package/src/commands/submodule-unpack.ts +265 -0
  268. package/src/commands/submodule-update-command.ts +39 -5
  269. package/src/commands/subtree-shift.ts +215 -0
  270. package/src/commands/switch-command.ts +9 -0
  271. package/src/commands/tree-restore.ts +6 -1
  272. package/src/commands/worktree-overwrite-checks.ts +5 -0
  273. package/src/errors/command-errors.ts +35 -0
  274. package/src/git-command.ts +87 -1
  275. package/src/git.ts +146 -0
  276. package/src/guarded-transport-command.ts +171 -0
  277. package/src/index.ts +1 -0
  278. package/src/rename/detect-renames.ts +42 -8
  279. package/src/rename/diffcore-break.ts +166 -0
  280. package/src/rename/index.ts +1 -0
  281. package/src/results/blame-format.ts +268 -43
  282. package/src/results/clone-result.ts +6 -0
  283. package/src/results/diff-dirstat.ts +117 -0
  284. package/src/results/diff-entry.ts +12 -0
  285. package/src/results/diff-formatter.ts +1 -0
  286. package/src/results/diff-output.ts +127 -2
  287. package/src/results/fetch-result.ts +12 -1
  288. package/src/results/index.ts +2 -0
  289. package/src/results/init-result.ts +10 -1
  290. package/src/results/line-range-hunks.ts +126 -0
  291. package/src/results/merge-result.ts +9 -0
  292. package/src/results/pull-result.ts +7 -0
  293. package/src/results/push-result.ts +5 -0
  294. package/src/results/status-result.ts +2 -2
  295. package/src/transport-command.ts +34 -3
  296. package/dist/fsck-DLRpbwTj.js +0 -13405
  297. package/dist/results-TB2IJ64h.js +0 -4700
@@ -167,3 +167,38 @@ export class HookFailedError extends GitApiError {
167
167
  this.name = "HookFailedError";
168
168
  }
169
169
  }
170
+
171
+ /**
172
+ * Thrown where `git describe` or `git name-rev` dies: the message is git's stderr (its
173
+ * `fatal:` line last), {@link stdout} what it printed before.
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * try {
178
+ * await git.describe().setExactMatch(true).callText();
179
+ * } catch (e) {
180
+ * if (e instanceof DescribeError) console.error(e.message); // fatal: no tag exactly matches '...'
181
+ * }
182
+ * ```
183
+ */
184
+ export class DescribeError extends GitApiError {
185
+ /** What git printed on stdout before it died */
186
+ readonly stdout: string;
187
+ /**
188
+ * A death saying nothing describes the commit (no names, no tag can describe it, no
189
+ * exact match, name-rev's `cannot describe`), not a failure of the command itself
190
+ */
191
+ readonly undescribable: boolean;
192
+
193
+ constructor(
194
+ message: string,
195
+ stdout = "",
196
+ exitCode?: number,
197
+ options: { undescribable?: boolean } = {},
198
+ ) {
199
+ super(message, exitCode !== undefined ? { exitCode } : undefined);
200
+ this.name = "DescribeError";
201
+ this.stdout = stdout;
202
+ this.undescribable = options.undescribable ?? false;
203
+ }
204
+ }
@@ -55,7 +55,7 @@ import {
55
55
  worktreeModeTrust,
56
56
  } from "./commands/core-config.js";
57
57
  import type { ForkPointSource } from "./commands/fork-point.js";
58
- import { HookSession, refTransactionHookOf } from "./commands/git-hooks.js";
58
+ import { type HookHost, HookSession, refTransactionHookOf } from "./commands/git-hooks.js";
59
59
  import {
60
60
  authorIdentOf,
61
61
  committerIdentOf,
@@ -66,6 +66,7 @@ import {
66
66
  } from "./commands/git-ident.js";
67
67
  import { indexHostOf, indexVersionConfigError } from "./commands/index-host.js";
68
68
  import { loadLegacyRemote } from "./commands/legacy-remotes.js";
69
+ import { type Mailmap, readRepositoryMailmap } from "./commands/mailmap.js";
69
70
  import type { MergeBaseGraph } from "./commands/merge-bases.js";
70
71
  import type { NotesContext } from "./commands/notes-support.js";
71
72
  import { postIndexChangeHookOf } from "./commands/post-index-change.js";
@@ -492,6 +493,18 @@ export abstract class GitCommand<T> {
492
493
  return this;
493
494
  }
494
495
 
496
+ /**
497
+ * @internal Runs this command's hooks in their own session over `host` (where they are
498
+ * found, the directory they run in, `GIT_DIR`): a git child process started elsewhere than
499
+ * the worktree top, as a submodule's fetch runs in its git directory; `env`: variables its
500
+ * hooks get too (the child's own, as `GIT_WORK_TREE` from `--work-tree`).
501
+ */
502
+ useHookHost(host: HookHost, env?: Record<string, string>): this {
503
+ const session = new HookSession(host);
504
+ this.hookSession = env ? session.withEnv(env) : session;
505
+ return this;
506
+ }
507
+
495
508
  /**
496
509
  * What the hooks this command ran wrote, in order, with git's hints about hooks it ignored
497
510
  * (`advice.ignoredHook`): git relays all of it on its stderr (a hook's stdout included,
@@ -637,12 +650,28 @@ export abstract class GitCommand<T> {
637
650
 
638
651
  /** The stored objects, as {@link storedCommits} reads commits. */
639
652
  private historyOf(): NonNullable<WorkingCopy["history"]> {
653
+ if (this.objectsView) return this.objectsView;
640
654
  if (!this._workingCopy.history) {
641
655
  throw new Error("WorkingCopy.history is required for commands");
642
656
  }
643
657
  return this._workingCopy.history;
644
658
  }
645
659
 
660
+ /** The stores this command reads and writes objects through (see {@link setObjectsView}) */
661
+ private objectsView?: NonNullable<WorkingCopy["history"]>;
662
+
663
+ /**
664
+ * Read and write blobs, trees and commits through `history` instead of the working copy's
665
+ * stores: a view over them, such as `--remerge-diff`'s in-memory overlay (git's
666
+ * `tmp_objdir`), so what this command stores never reaches the repository.
667
+ */
668
+ setObjectsView(history: NonNullable<WorkingCopy["history"]>): this {
669
+ this.checkCallable();
670
+ this.objectsView = history;
671
+ this.replacedViews = undefined;
672
+ return this;
673
+ }
674
+
646
675
  /** Whether an object was read through the replacements (git then read them, and printed) */
647
676
  private replacementsRead = false;
648
677
 
@@ -1339,6 +1368,58 @@ export abstract class GitCommand<T> {
1339
1368
  return undefined;
1340
1369
  }
1341
1370
 
1371
+ /**
1372
+ * The repository's mailmap as mailmap.c's read_mailmap reads it: the worktree's
1373
+ * `.mailmap` (not in a bare repository), `mailmap.blob` (default `HEAD:.mailmap` in a bare
1374
+ * repository), `mailmap.file`. git's `error:` lines (a `mailmap.blob` that is no blob) go
1375
+ * to `onError`.
1376
+ */
1377
+ protected readMailmap(onError?: (line: string) => void): Promise<Mailmap> {
1378
+ const config = RemoteConfigStore.from(this._workingCopy);
1379
+ let worktree: Worktree | undefined;
1380
+ try {
1381
+ worktree = this.worktreeAccess;
1382
+ } catch {
1383
+ // a bare repository's working copy refuses its worktree
1384
+ }
1385
+ return readRepositoryMailmap({
1386
+ config: (key) => config.value(key),
1387
+ worktree,
1388
+ environment: hostEnvironmentOf(this._workingCopy),
1389
+ readObjectNamed: (name) => this.readObjectNamed(name),
1390
+ ...(onError ? { onError } : {}),
1391
+ });
1392
+ }
1393
+
1394
+ /** The object a revision names, with its type (`bytes` undefined when it cannot be read). */
1395
+ protected async readObjectNamed(
1396
+ name: string,
1397
+ ): Promise<{ type: string; bytes?: Uint8Array } | undefined> {
1398
+ const resolver = this.revisionResolver();
1399
+ const id = await resolver.resolve(name).catch(() => undefined);
1400
+ if (!id) return undefined;
1401
+ const type = await resolver.objectType(id).catch(() => undefined);
1402
+ if (!type) return { type: "unknown" };
1403
+ if (type !== "blob") return { type, bytes: new Uint8Array(0) };
1404
+ try {
1405
+ const content = await this.blobs.load(id);
1406
+ if (!content) return { type };
1407
+ const chunks: Uint8Array[] = [];
1408
+ for await (const c of content) chunks.push(c);
1409
+ let size = 0;
1410
+ for (const c of chunks) size += c.length;
1411
+ const bytes = new Uint8Array(size);
1412
+ let at = 0;
1413
+ for (const c of chunks) {
1414
+ bytes.set(c, at);
1415
+ at += c.length;
1416
+ }
1417
+ return { type, bytes };
1418
+ } catch {
1419
+ return { type };
1420
+ }
1421
+ }
1422
+
1342
1423
  /**
1343
1424
  * A resolver for git's revision syntax over this command's stores (see
1344
1425
  * {@link RevisionResolver}); its `warnings` hold what git would print.
@@ -1501,6 +1582,11 @@ export abstract class GitCommand<T> {
1501
1582
  return entries;
1502
1583
  }
1503
1584
 
1585
+ /** The commits of `.git/shallow` (none in a complete repository). */
1586
+ protected async shallowCommits(): Promise<ObjectId[]> {
1587
+ return (await this.refsStore.getShallow?.().catch(() => undefined)) ?? [];
1588
+ }
1589
+
1504
1590
  /** `id` abbreviated as git prints it, through {@link idAbbreviator}. */
1505
1591
  protected abbreviateObjectId(id: ObjectId): Promise<string> {
1506
1592
  return this.idAbbreviator().abbreviate(id);
package/src/git.ts CHANGED
@@ -18,7 +18,9 @@ import {
18
18
  BisectStateCommand,
19
19
  BisectTermsCommand,
20
20
  BlameCommand,
21
+ CheckMailmapCommand,
21
22
  CheckoutCommand,
23
+ CherryCommand,
22
24
  CherryPickCommand,
23
25
  CleanCommand,
24
26
  CloneCommand,
@@ -32,6 +34,7 @@ import {
32
34
  DiffCommand,
33
35
  EditBranchDescriptionCommand,
34
36
  FetchCommand,
37
+ FetchMultipleCommand,
35
38
  FmtMergeMsgCommand,
36
39
  ForEachRefCommand,
37
40
  FormatPatchCommand,
@@ -49,20 +52,26 @@ import {
49
52
  MergeBaseCommand,
50
53
  MergeCommand,
51
54
  MvCommand,
55
+ NameRevCommand,
52
56
  NotesCommands,
53
57
  PackRefsCommand,
54
58
  PullCommand,
55
59
  PushCommand,
60
+ RangeDiffCommand,
56
61
  ReadTreeCommand,
57
62
  RebaseCommand,
58
63
  ReflogCommand,
59
64
  RemoteAddCommand,
60
65
  RemoteGetUrlCommand,
61
66
  RemoteListCommand,
67
+ RemotePruneCommand,
62
68
  RemoteRemoveCommand,
63
69
  RemoteRenameCommand,
70
+ RemoteSetBranchesCommand,
64
71
  RemoteSetHeadCommand,
65
72
  RemoteSetUrlCommand,
73
+ RemoteShowCommand,
74
+ RemoteUpdateCommand,
66
75
  RenameBranchCommand,
67
76
  ResetCommand,
68
77
  RestoreCommand,
@@ -71,6 +80,7 @@ import {
71
80
  RevParseCommand,
72
81
  RmCommand,
73
82
  SetUpstreamBranchCommand,
83
+ ShortlogCommand,
74
84
  ShowCommand,
75
85
  ShowCurrentBranchCommand,
76
86
  SparseCheckoutCommand,
@@ -800,6 +810,21 @@ export class Git implements Disposable {
800
810
  return new DescribeCommand(this._workingCopy);
801
811
  }
802
812
 
813
+ /**
814
+ * Create a NameRevCommand: symbolic names of commits by the refs that reach them
815
+ * (`git name-rev`).
816
+ *
817
+ * @example
818
+ * ```typescript
819
+ * const { stdout } = await git.nameRev().setNameOnly(true).addRevisions("HEAD~2").call();
820
+ * // "main~2\n"
821
+ * ```
822
+ */
823
+ nameRev(): NameRevCommand {
824
+ this.checkClosed();
825
+ return new NameRevCommand(this._workingCopy);
826
+ }
827
+
803
828
  // ============ Maintenance Operations ============
804
829
 
805
830
  /**
@@ -853,6 +878,62 @@ export class Git implements Disposable {
853
878
  return new VerifyPackCommand(this._workingCopy);
854
879
  }
855
880
 
881
+ /**
882
+ * Create a ShortlogCommand (`git shortlog`): commits grouped by author, committer,
883
+ * trailer values or formats, from a walk or from `git log` output.
884
+ *
885
+ * @example
886
+ * ```typescript
887
+ * await git.shortlog().addRevision("HEAD").setSummary(true).setNumbered(true).callText();
888
+ * ```
889
+ */
890
+ shortlog(): ShortlogCommand {
891
+ this.checkClosed();
892
+ return new ShortlogCommand(this._workingCopy);
893
+ }
894
+
895
+ /**
896
+ * Create a CherryCommand (`git cherry`): the commits of a branch not in its upstream, each
897
+ * marked `-` when upstream has a commit with the same change, `+` otherwise.
898
+ *
899
+ * @example
900
+ * ```typescript
901
+ * await git.cherry().setUpstream("main").setHead("topic").setVerbose(true).callText();
902
+ * ```
903
+ */
904
+ cherry(): CherryCommand {
905
+ this.checkClosed();
906
+ return new CherryCommand(this._workingCopy);
907
+ }
908
+
909
+ /**
910
+ * Create a RangeDiffCommand (`git range-diff`): two versions of a patch series compared
911
+ * commit by commit.
912
+ *
913
+ * @example
914
+ * ```typescript
915
+ * await git.rangeDiff().addArgument("main..topic").addArgument("main..topic-v2").callText();
916
+ * ```
917
+ */
918
+ rangeDiff(): RangeDiffCommand {
919
+ this.checkClosed();
920
+ return new RangeDiffCommand(this._workingCopy);
921
+ }
922
+
923
+ /**
924
+ * Create a CheckMailmapCommand (`git check-mailmap`): contacts mapped through the
925
+ * repository's mailmap.
926
+ *
927
+ * @example
928
+ * ```typescript
929
+ * await git.checkMailmap().addContact("nick1 <bugs@company.xx>").call();
930
+ * ```
931
+ */
932
+ checkMailmap(): CheckMailmapCommand {
933
+ this.checkClosed();
934
+ return new CheckMailmapCommand(this._workingCopy);
935
+ }
936
+
856
937
  /**
857
938
  * Create a FmtMergeMsgCommand that writes the message of a merge (`git fmt-merge-msg`),
858
939
  * from FETCH_HEAD-style lines or the heads `git merge` would be given, with the `merge.*`
@@ -1202,6 +1283,19 @@ export class Git implements Disposable {
1202
1283
  return this.withTransports(new FetchCommand(this._workingCopy));
1203
1284
  }
1204
1285
 
1286
+ /**
1287
+ * Create a FetchMultipleCommand: `git fetch --all`, `git fetch --multiple <remote|group>...`.
1288
+ *
1289
+ * @example
1290
+ * ```typescript
1291
+ * const { stdout, stderr, exitCode } = await git.fetchMultiple().setAll(true).call();
1292
+ * ```
1293
+ */
1294
+ fetchMultiple(): FetchMultipleCommand {
1295
+ this.checkClosed();
1296
+ return this.withTransports(new FetchMultipleCommand(this._workingCopy));
1297
+ }
1298
+
1205
1299
  /**
1206
1300
  * Create a PushCommand for pushing to remotes.
1207
1301
  *
@@ -1356,6 +1450,58 @@ export class Git implements Disposable {
1356
1450
  return this.withTransports(new RemoteSetHeadCommand(this._workingCopy));
1357
1451
  }
1358
1452
 
1453
+ /**
1454
+ * Create a RemoteShowCommand: `git remote show [-n] <name>...`.
1455
+ *
1456
+ * @example
1457
+ * ```typescript
1458
+ * const text = await git.remoteShow().setRemoteNames("origin").callText();
1459
+ * ```
1460
+ */
1461
+ remoteShow(): RemoteShowCommand {
1462
+ this.checkClosed();
1463
+ return this.withTransports(new RemoteShowCommand(this._workingCopy));
1464
+ }
1465
+
1466
+ /**
1467
+ * Create a RemotePruneCommand: `git remote prune [--dry-run] <name>...`.
1468
+ *
1469
+ * @example
1470
+ * ```typescript
1471
+ * await git.remotePrune().setRemoteNames("origin").call();
1472
+ * ```
1473
+ */
1474
+ remotePrune(): RemotePruneCommand {
1475
+ this.checkClosed();
1476
+ return this.withTransports(new RemotePruneCommand(this._workingCopy));
1477
+ }
1478
+
1479
+ /**
1480
+ * Create a RemoteUpdateCommand: `git remote update [-p] [<group>|<remote>...]`.
1481
+ *
1482
+ * @example
1483
+ * ```typescript
1484
+ * const { exitCode } = await git.remoteUpdate().setPrune(true).call();
1485
+ * ```
1486
+ */
1487
+ remoteUpdate(): RemoteUpdateCommand {
1488
+ this.checkClosed();
1489
+ return this.withTransports(new RemoteUpdateCommand(this._workingCopy));
1490
+ }
1491
+
1492
+ /**
1493
+ * Create a RemoteSetBranchesCommand: `git remote set-branches [--add] <name> <branch>...`.
1494
+ *
1495
+ * @example
1496
+ * ```typescript
1497
+ * await git.remoteSetBranches().setRemoteName("origin").setBranches("main").call();
1498
+ * ```
1499
+ */
1500
+ remoteSetBranches(): RemoteSetBranchesCommand {
1501
+ this.checkClosed();
1502
+ return new RemoteSetBranchesCommand(this._workingCopy);
1503
+ }
1504
+
1359
1505
  /**
1360
1506
  * Create a RemoteRenameCommand for renaming a remote (`git remote rename`).
1361
1507
  *
@@ -0,0 +1,171 @@
1
+ import type { Credentials, GitTransportRegistry } from "@statewalker/vcs-transport";
2
+ import type { RemoteSessionOptions } from "./commands/remote-transport.js";
3
+ import {
4
+ type CredentialsForUrl,
5
+ createSubmoduleAuthPolicy,
6
+ guardSubmoduleTransports,
7
+ type HeadersForUrl,
8
+ type SubmoduleAuthFor,
9
+ strictUrlOrigin,
10
+ } from "./commands/submodule-auth.js";
11
+ import { GitApiError } from "./errors/index.js";
12
+ import { TransportCommand } from "./transport-command.js";
13
+
14
+ /**
15
+ * A command that reaches several remotes in one call (`git fetch --all`, `git remote update`,
16
+ * `git remote show <a> <b>`, `git remote prune`): the remotes' URLs come from the
17
+ * configuration and may name any host, so credentials and headers go only where the caller
18
+ * gave them for, as git's credential helpers match per URL.
19
+ *
20
+ * - {@link setCredentials} and {@link setHeaders} are for the origins (scheme, host, port)
21
+ * named with {@link addCredentialOrigin}; when none is named, for the origin of the default
22
+ * remote (the current branch's, the one configured remote, `origin`), and only while every
23
+ * remote the call reaches has that origin: remotes spanning several origins get none.
24
+ * - {@link setCredentialsForUrl} and {@link setHeadersForUrl} answer per URL (after
25
+ * `insteadOf`), for that URL's origin alone.
26
+ * - A URL without an origin (a path, `file:`) gets none.
27
+ *
28
+ * The connections go through guarded transports (`guardSubmoduleTransports`): the connectors
29
+ * attach the credentials and headers themselves, per URL, and follow HTTP redirects by hand
30
+ * so a redirect to another origin carries none. The commands run inside (each `git fetch`)
31
+ * are given the guarded transports and no credentials of their own.
32
+ */
33
+ export abstract class GuardedTransportCommand<T> extends TransportCommand<T> {
34
+ private credentialOrigins: string[] = [];
35
+ private credentialsFor?: CredentialsForUrl;
36
+ private headersFor?: HeadersForUrl;
37
+ private authPolicy?: SubmoduleAuthFor;
38
+ private inheritedPolicy = false;
39
+ private guarded?: GitTransportRegistry;
40
+
41
+ /**
42
+ * Credentials for the trusted origins only: those named with {@link addCredentialOrigin},
43
+ * else the default remote's origin while every remote reached has it (see the class notes).
44
+ * Use {@link setCredentialsForUrl} to decide per URL.
45
+ */
46
+ override setCredentials(credentials: Credentials): this {
47
+ return super.setCredentials(credentials);
48
+ }
49
+
50
+ /** Username and password for the trusted origins only (as {@link setCredentials}). */
51
+ override setCredentialsProvider(username: string, password: string): this {
52
+ return super.setCredentialsProvider(username, password);
53
+ }
54
+
55
+ /** HTTP headers for the trusted origins only (as {@link setCredentials}). */
56
+ override setHeaders(headers: Record<string, string>): this {
57
+ return super.setHeaders(headers);
58
+ }
59
+
60
+ /**
61
+ * An origin the static credentials and headers are for: a URL whose `<scheme>://<host>[:<port>]`
62
+ * is taken (`https://git.example.com`, or any URL of that host). Once one is named, the
63
+ * default remote is no longer trusted by default.
64
+ *
65
+ * @throws GitApiError for a URL without an origin (a path, `file:`)
66
+ */
67
+ addCredentialOrigin(url: string): this {
68
+ this.checkCallable();
69
+ const origin = strictUrlOrigin(url);
70
+ if (origin === undefined) {
71
+ throw new GitApiError(`fatal: '${url}' names no origin (scheme and host) for credentials`);
72
+ }
73
+ this.credentialOrigins.push(origin);
74
+ return this;
75
+ }
76
+
77
+ /**
78
+ * Asked with the URL of each remote reached (after `insteadOf`): its credentials, or
79
+ * undefined for the static ones' rule ({@link setCredentials}).
80
+ */
81
+ setCredentialsForUrl(provider: CredentialsForUrl): this {
82
+ this.checkCallable();
83
+ this.credentialsFor = provider;
84
+ return this;
85
+ }
86
+
87
+ /** Asked with the URL of each remote reached: its headers (as {@link setCredentialsForUrl}). */
88
+ setHeadersForUrl(provider: HeadersForUrl): this {
89
+ this.checkCallable();
90
+ this.headersFor = provider;
91
+ return this;
92
+ }
93
+
94
+ /** @internal The policy of the command running this one (a nested fetch). */
95
+ setAuthPolicy(policy: SubmoduleAuthFor): this {
96
+ this.checkCallable();
97
+ this.authPolicy = policy;
98
+ this.inheritedPolicy = true;
99
+ return this;
100
+ }
101
+
102
+ /**
103
+ * Decides who gets the static credentials and headers, from the URLs this call reaches
104
+ * (after `insteadOf`) and the default remote's URL; call before the first connection
105
+ * (until then nothing gets any).
106
+ */
107
+ protected resolveAuth(urls: readonly string[], defaultRemoteUrl: string | undefined): void {
108
+ if (this.inheritedPolicy) return;
109
+ let origins = this.credentialOrigins;
110
+ if (origins.length === 0 && (this.credentials || this.headers)) {
111
+ const reached = new Set(urls.map((url) => strictUrlOrigin(url) ?? `none:${url}`));
112
+ const origin = defaultRemoteUrl !== undefined ? strictUrlOrigin(defaultRemoteUrl) : undefined;
113
+ origins =
114
+ origin !== undefined && reached.size <= 1 && (reached.size === 0 || reached.has(origin))
115
+ ? [origin]
116
+ : [];
117
+ }
118
+ this.authPolicy = createSubmoduleAuthPolicy({
119
+ ...(this.credentials ? { credentials: this.credentials } : {}),
120
+ ...(this.headers ? { headers: this.headers } : {}),
121
+ origins,
122
+ ...(this.credentialsFor ? { credentialsFor: this.credentialsFor } : {}),
123
+ ...(this.headersFor ? { headersFor: this.headersFor } : {}),
124
+ });
125
+ }
126
+
127
+ /** The policy in force: what {@link resolveAuth} decided (nothing before it). */
128
+ protected policy(): SubmoduleAuthFor {
129
+ return this.authPolicy ?? (() => ({}));
130
+ }
131
+
132
+ /** The given transports, unguarded (for a nested command given this one's policy). */
133
+ private rawTransports(): GitTransportRegistry {
134
+ return super.getTransports();
135
+ }
136
+
137
+ /** The transports every connection goes through: guarded by this command's policy. */
138
+ override getTransports(): GitTransportRegistry {
139
+ this.guarded ??= guardSubmoduleTransports(this.rawTransports(), (url) => this.policy()(url));
140
+ return this.guarded;
141
+ }
142
+
143
+ /** The session options, without credentials and headers: the guarded transports add them. */
144
+ protected override remoteSessionOptions(): RemoteSessionOptions {
145
+ const { credentials: _c, headers: _h, ...rest } = super.remoteSessionOptions();
146
+ return rest;
147
+ }
148
+
149
+ /** A lazy fetch gets the guarded transports, and no credentials of its own. */
150
+ protected override promisorFetcherAuth() {
151
+ return { transports: this.getTransports() };
152
+ }
153
+
154
+ /**
155
+ * A command this one runs: a guarded one gets the transports and this command's policy, any
156
+ * other the guarded transports; neither gets the credentials or headers.
157
+ */
158
+ protected override configureChild<C extends TransportCommand<unknown>>(child: C): C {
159
+ child.shareHooksOf(this);
160
+ if (child instanceof GuardedTransportCommand) {
161
+ child.setTransports(this.rawTransports());
162
+ child.setAuthPolicy((url) => this.policy()(url));
163
+ } else child.setTransports(this.getTransports());
164
+ if (this.timeout) child.setTimeout(this.timeout);
165
+ if (this.gzipRequests !== undefined) child.setGzipRequests(this.gzipRequests);
166
+ if (this.progressCallback) child.setProgressMonitor(this.progressCallback);
167
+ if (this.progressMessageCallback)
168
+ child.setProgressMessageCallback(this.progressMessageCallback);
169
+ return child;
170
+ }
171
+ }
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ export * from "./errors/index.js";
11
11
  export { Git, type GitOptions } from "./git.js";
12
12
  // Base classes
13
13
  export { GitCommand } from "./git-command.js";
14
+ export { GuardedTransportCommand } from "./guarded-transport-command.js";
14
15
  // Results
15
16
  export * from "./results/index.js";
16
17
  export { TransportCommand } from "./transport-command.js";
@@ -28,6 +28,11 @@ export interface RenameCandidate {
28
28
  * once from the start (git's `rename_used++` at register_rename_src), so it is only copied
29
29
  */
30
30
  kept?: boolean;
31
+ /**
32
+ * An unmodified path (`--find-copies-harder`): over the rename limit, `-C -C` falls back to
33
+ * copies from modified paths only (git's `skip_unmodified`)
34
+ */
35
+ unmodified?: boolean;
31
36
  }
32
37
 
33
38
  /** A source paired with a destination. */
@@ -109,6 +114,21 @@ export interface DetectRenamesOptions {
109
114
  * merge options.
110
115
  */
111
116
  copies?: boolean;
117
+ /**
118
+ * Some sources are halves of broken pairs (`-B`, git's `break_idx`): as with copies, no
119
+ * basename matches and every source stays in the matrix (used ones only skipped)
120
+ */
121
+ breakMode?: boolean;
122
+ /**
123
+ * Called when `--find-copies-harder` went over the rename limit and copies were looked for
124
+ * from modified paths only (git's `degraded_cc_to_c`)
125
+ */
126
+ onDegraded?(): void;
127
+ /**
128
+ * Called once detection is done with how many times each source (by path) is used (git's
129
+ * `rename_used`: kept sources count once, each pair once more)
130
+ */
131
+ onUses?(uses: Map<string, number>): void;
112
132
  }
113
133
 
114
134
  /** A source a merge needs for its content (the other side changed it). */
@@ -331,7 +351,11 @@ export async function detectRenames(
331
351
  };
332
352
  // diff_resolve_rename_copy: in destination order, each pair takes one use of its source;
333
353
  // a source with uses left is copied, its last use renames it
354
+ const reportUses = () => {
355
+ options.onUses?.(new Map(src.map((c, i) => [c.path, useCount[i] ?? 0])));
356
+ };
334
357
  const resolved = () => {
358
+ reportUses();
335
359
  if (!copies) return pairs;
336
360
  const left: number[] = [...useCount];
337
361
  const bySrc = new Map(src.map((c, i) => [c.path, i]));
@@ -363,7 +387,7 @@ export async function detectRenames(
363
387
  continue;
364
388
  }
365
389
  // higher for a source not used yet; a used one only for a copy
366
- if (srcUsed.has(s) && !copies) continue;
390
+ if (useCount[s] && !copies) continue;
367
391
  const score =
368
392
  (useCount[s] ? 0 : 1) + (basename(source.path) === basename(target.path) ? 1 : 0);
369
393
  if (score > bestScore) {
@@ -413,15 +437,24 @@ export async function detectRenames(
413
437
  ? estimateSimilarity(await side(src[s], "source"), await side(dst[d], "destination"), minimum)
414
438
  : 0;
415
439
 
416
- if (copies) {
417
- // no basename matches with copies: every source (used ones too) against the
418
- // destinations left, within the rename limit
440
+ if (copies || options.breakMode) {
441
+ // no basename matches with copies or broken pairs: every source (used ones too) against
442
+ // the destinations left, within the rename limit
419
443
  const destinationsLeft = dst.map((_, i) => i).filter((i) => !dstDone.has(i));
420
- const sourcesLeft = src.map((_, i) => i);
444
+ let sourcesLeft = src.map((_, i) => i);
421
445
  if (destinationsLeft.length === 0) return resolved();
422
446
  if (sourcesLeft.length * destinationsLeft.length > renameLimit * renameLimit) {
423
447
  options.onRenameLimit?.(Math.max(sourcesLeft.length, destinationsLeft.length));
424
- return resolved();
448
+ // too_many_rename_candidates: under -C -C, copies from modified paths only if they fit
449
+ const limited = sourcesLeft.filter((i) => !src[i].unmodified);
450
+ if (
451
+ limited.length === sourcesLeft.length ||
452
+ limited.length * destinationsLeft.length > renameLimit * renameLimit
453
+ ) {
454
+ return resolved();
455
+ }
456
+ options.onDegraded?.();
457
+ sourcesLeft = limited;
425
458
  }
426
459
  await options.prefetch?.([
427
460
  ...destinationsLeft.map((d) => ({ candidate: dst[d], side: "destination" as const })),
@@ -435,7 +468,7 @@ export async function detectRenames(
435
468
  dst,
436
469
  );
437
470
  // find_renames: unused sources first, then (copies) any
438
- for (const any of [false, true]) {
471
+ for (const any of copies ? [false, true] : [false]) {
439
472
  for (const m of matrix) {
440
473
  if (m.dst < 0 || m.score < minimumScore) break;
441
474
  if (dstDone.has(m.dst)) continue;
@@ -485,7 +518,7 @@ export async function detectRenames(
485
518
  }
486
519
  return map;
487
520
  };
488
- const liveSources = () => src.map((s, i) => i).filter((i) => !srcUsed.has(i));
521
+ const liveSources = () => src.map((_s, i) => i).filter((i) => !srcUsed.has(i));
489
522
  const srcNames = unique(liveSources().map((i) => [i, src[i].path]));
490
523
  const dstNames = unique(
491
524
  dst.map((d, i) => [i, d.path] as [number, string]).filter(([i]) => !dstDone.has(i)),
@@ -559,6 +592,7 @@ export async function detectRenames(
559
592
  });
560
593
  }
561
594
  const finish = () => {
595
+ reportUses();
562
596
  // only the removed directories still needed keep their counts (`cleanup_dir_rename_info`)
563
597
  if (!info || !dirsRemoved) return pairs;
564
598
  for (const [dir, counts] of [...info.counts]) {