@statewalker/vcs-commands 0.9.0 → 0.10.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 (460) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/add-command.d.ts.map +1 -1
  3. package/dist/commands/add-patch/patch-backend.d.ts +2 -0
  4. package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
  5. package/dist/commands/add-patch/patch-modes.d.ts +6 -2
  6. package/dist/commands/add-patch/patch-modes.d.ts.map +1 -1
  7. package/dist/commands/add-patch/patch-session.d.ts +4 -0
  8. package/dist/commands/add-patch/patch-session.d.ts.map +1 -1
  9. package/dist/commands/am/am-command.d.ts +41 -2
  10. package/dist/commands/am/am-command.d.ts.map +1 -1
  11. package/dist/commands/apply/index.d.ts +1 -1
  12. package/dist/commands/apply/index.d.ts.map +1 -1
  13. package/dist/commands/archive/archive-command.d.ts +169 -0
  14. package/dist/commands/archive/archive-command.d.ts.map +1 -0
  15. package/dist/commands/archive/archive-entry.d.ts +60 -0
  16. package/dist/commands/archive/archive-entry.d.ts.map +1 -0
  17. package/dist/commands/archive/index.d.ts +8 -0
  18. package/dist/commands/archive/index.d.ts.map +1 -0
  19. package/dist/commands/archive/remote-archive-command.d.ts +56 -0
  20. package/dist/commands/archive/remote-archive-command.d.ts.map +1 -0
  21. package/dist/commands/archive/tar-archive.d.ts +31 -0
  22. package/dist/commands/archive/tar-archive.d.ts.map +1 -0
  23. package/dist/commands/archive/tar-commit-id.d.ts +13 -0
  24. package/dist/commands/archive/tar-commit-id.d.ts.map +1 -0
  25. package/dist/commands/archive/upload-archive-writer.d.ts +48 -0
  26. package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -0
  27. package/dist/commands/archive/zip-archive.d.ts +42 -0
  28. package/dist/commands/archive/zip-archive.d.ts.map +1 -0
  29. package/dist/commands/attributes-source.d.ts +10 -0
  30. package/dist/commands/attributes-source.d.ts.map +1 -1
  31. package/dist/commands/blame-command.d.ts +43 -1
  32. package/dist/commands/blame-command.d.ts.map +1 -1
  33. package/dist/commands/bundle/bundle-create-command.d.ts +67 -0
  34. package/dist/commands/bundle/bundle-create-command.d.ts.map +1 -0
  35. package/dist/commands/bundle/bundle-format.d.ts +89 -0
  36. package/dist/commands/bundle/bundle-format.d.ts.map +1 -0
  37. package/dist/commands/bundle/bundle-list.d.ts +92 -0
  38. package/dist/commands/bundle/bundle-list.d.ts.map +1 -0
  39. package/dist/commands/bundle/bundle-read-commands.d.ts +81 -0
  40. package/dist/commands/bundle/bundle-read-commands.d.ts.map +1 -0
  41. package/dist/commands/bundle/bundle-support.d.ts +32 -0
  42. package/dist/commands/bundle/bundle-support.d.ts.map +1 -0
  43. package/dist/commands/bundle/bundle-transport.d.ts +38 -0
  44. package/dist/commands/bundle/bundle-transport.d.ts.map +1 -0
  45. package/dist/commands/bundle/bundle-uri-host.d.ts +43 -0
  46. package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -0
  47. package/dist/commands/bundle/bundle-uri.d.ts +55 -0
  48. package/dist/commands/bundle/bundle-uri.d.ts.map +1 -0
  49. package/dist/commands/bundle/bundle-verify.d.ts +63 -0
  50. package/dist/commands/bundle/bundle-verify.d.ts.map +1 -0
  51. package/dist/commands/bundle/index.d.ts +14 -0
  52. package/dist/commands/bundle/index.d.ts.map +1 -0
  53. package/dist/commands/cat-file/batch-format.d.ts +58 -0
  54. package/dist/commands/cat-file/batch-format.d.ts.map +1 -0
  55. package/dist/commands/cat-file/cat-file-command.d.ts +135 -0
  56. package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -0
  57. package/dist/commands/cat-file/index.d.ts +3 -0
  58. package/dist/commands/cat-file/index.d.ts.map +1 -0
  59. package/dist/commands/check-attr-command.d.ts +66 -0
  60. package/dist/commands/check-attr-command.d.ts.map +1 -0
  61. package/dist/commands/check-ignore-command.d.ts +58 -0
  62. package/dist/commands/check-ignore-command.d.ts.map +1 -0
  63. package/dist/commands/check-ref-format-command.d.ts +60 -0
  64. package/dist/commands/check-ref-format-command.d.ts.map +1 -0
  65. package/dist/commands/checkout-command.d.ts.map +1 -1
  66. package/dist/commands/checkout-index-command.d.ts +96 -0
  67. package/dist/commands/checkout-index-command.d.ts.map +1 -0
  68. package/dist/commands/cherry-pick-command.d.ts +10 -0
  69. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  70. package/dist/commands/clone-command.d.ts +19 -0
  71. package/dist/commands/clone-command.d.ts.map +1 -1
  72. package/dist/commands/commit-command.d.ts +9 -1
  73. package/dist/commands/commit-command.d.ts.map +1 -1
  74. package/dist/commands/config-command.d.ts +2 -0
  75. package/dist/commands/config-command.d.ts.map +1 -1
  76. package/dist/commands/daemon-access-hook.d.ts +36 -0
  77. package/dist/commands/daemon-access-hook.d.ts.map +1 -0
  78. package/dist/commands/default-branch.d.ts +42 -0
  79. package/dist/commands/default-branch.d.ts.map +1 -1
  80. package/dist/commands/diff-command.d.ts +132 -5
  81. package/dist/commands/diff-command.d.ts.map +1 -1
  82. package/dist/commands/diff-external.d.ts +43 -0
  83. package/dist/commands/diff-external.d.ts.map +1 -0
  84. package/dist/commands/diff-plumbing/diff-pairs-command.d.ts +27 -0
  85. package/dist/commands/diff-plumbing/diff-pairs-command.d.ts.map +1 -0
  86. package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts +129 -0
  87. package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts.map +1 -0
  88. package/dist/commands/diff-plumbing/index.d.ts +3 -0
  89. package/dist/commands/diff-plumbing/index.d.ts.map +1 -0
  90. package/dist/commands/diff-textconv.d.ts +5 -1
  91. package/dist/commands/diff-textconv.d.ts.map +1 -1
  92. package/dist/commands/fast-export/fast-export-command.d.ts +135 -0
  93. package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -0
  94. package/dist/commands/fast-export/fast-import-command.d.ts +182 -0
  95. package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -0
  96. package/dist/commands/fast-export/fast-stream-support.d.ts +64 -0
  97. package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -0
  98. package/dist/commands/fast-export/index.d.ts +4 -0
  99. package/dist/commands/fast-export/index.d.ts.map +1 -0
  100. package/dist/commands/fetch-command.d.ts +65 -0
  101. package/dist/commands/fetch-command.d.ts.map +1 -1
  102. package/dist/commands/fetch-multiple-command.d.ts.map +1 -1
  103. package/dist/commands/format-rev-command.d.ts +58 -0
  104. package/dist/commands/format-rev-command.d.ts.map +1 -0
  105. package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
  106. package/dist/commands/fsck/fsck-msg-ids.d.ts +18 -3
  107. package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -1
  108. package/dist/commands/fsmonitor-refresh.d.ts +69 -0
  109. package/dist/commands/fsmonitor-refresh.d.ts.map +1 -0
  110. package/dist/commands/gc-command.d.ts +5 -0
  111. package/dist/commands/gc-command.d.ts.map +1 -1
  112. package/dist/commands/git-hooks.d.ts +32 -0
  113. package/dist/commands/git-hooks.d.ts.map +1 -1
  114. package/dist/commands/git-paths.d.ts +26 -0
  115. package/dist/commands/git-paths.d.ts.map +1 -0
  116. package/dist/commands/grep/grep-command.d.ts +2 -1
  117. package/dist/commands/grep/grep-command.d.ts.map +1 -1
  118. package/dist/commands/history-command.d.ts +156 -0
  119. package/dist/commands/history-command.d.ts.map +1 -0
  120. package/dist/commands/http-config.d.ts +38 -0
  121. package/dist/commands/http-config.d.ts.map +1 -0
  122. package/dist/commands/index-adder.d.ts +12 -1
  123. package/dist/commands/index-adder.d.ts.map +1 -1
  124. package/dist/commands/index-host.d.ts.map +1 -1
  125. package/dist/commands/index.d.ts +44 -1
  126. package/dist/commands/index.d.ts.map +1 -1
  127. package/dist/commands/index.js +6 -5
  128. package/dist/commands/init-command.d.ts.map +1 -1
  129. package/dist/commands/last-modified-command.d.ts +102 -0
  130. package/dist/commands/last-modified-command.d.ts.map +1 -0
  131. package/dist/commands/lfs/go-url.d.ts +43 -0
  132. package/dist/commands/lfs/go-url.d.ts.map +1 -0
  133. package/dist/commands/lfs/index.d.ts +3 -0
  134. package/dist/commands/lfs/index.d.ts.map +1 -0
  135. package/dist/commands/lfs/lfs-config.d.ts +174 -0
  136. package/dist/commands/lfs/lfs-config.d.ts.map +1 -0
  137. package/dist/commands/lfs/lfs-endpoint-command.d.ts +83 -0
  138. package/dist/commands/lfs/lfs-endpoint-command.d.ts.map +1 -0
  139. package/dist/commands/local-transport.d.ts.map +1 -1
  140. package/dist/commands/log-command.d.ts +26 -0
  141. package/dist/commands/log-command.d.ts.map +1 -1
  142. package/dist/commands/log-output.d.ts +22 -1
  143. package/dist/commands/log-output.d.ts.map +1 -1
  144. package/dist/commands/ls-files-command.d.ts +153 -0
  145. package/dist/commands/ls-files-command.d.ts.map +1 -0
  146. package/dist/commands/ls-remote-command.d.ts +5 -0
  147. package/dist/commands/ls-remote-command.d.ts.map +1 -1
  148. package/dist/commands/ls-tree-command.d.ts +105 -0
  149. package/dist/commands/ls-tree-command.d.ts.map +1 -0
  150. package/dist/commands/maintenance-run-command.d.ts +122 -0
  151. package/dist/commands/maintenance-run-command.d.ts.map +1 -0
  152. package/dist/commands/merge-command.d.ts +7 -0
  153. package/dist/commands/merge-command.d.ts.map +1 -1
  154. package/dist/commands/merge-config.d.ts +7 -0
  155. package/dist/commands/merge-config.d.ts.map +1 -1
  156. package/dist/commands/merge-drivers.d.ts +67 -5
  157. package/dist/commands/merge-drivers.d.ts.map +1 -1
  158. package/dist/commands/merge-support.d.ts +6 -0
  159. package/dist/commands/merge-support.d.ts.map +1 -1
  160. package/dist/commands/merge-tree-command.d.ts +122 -0
  161. package/dist/commands/merge-tree-command.d.ts.map +1 -0
  162. package/dist/commands/mktag-command.d.ts +51 -0
  163. package/dist/commands/mktag-command.d.ts.map +1 -0
  164. package/dist/commands/object-store/count-objects-command.d.ts +58 -0
  165. package/dist/commands/object-store/count-objects-command.d.ts.map +1 -0
  166. package/dist/commands/object-store/index.d.ts +5 -0
  167. package/dist/commands/object-store/index.d.ts.map +1 -0
  168. package/dist/commands/object-store/objects-directory.d.ts +12 -0
  169. package/dist/commands/object-store/objects-directory.d.ts.map +1 -0
  170. package/dist/commands/object-store/prune-command.d.ts +38 -0
  171. package/dist/commands/object-store/prune-command.d.ts.map +1 -0
  172. package/dist/commands/object-store/show-index-command.d.ts +23 -0
  173. package/dist/commands/object-store/show-index-command.d.ts.map +1 -0
  174. package/dist/commands/ort-merge.d.ts +24 -0
  175. package/dist/commands/ort-merge.d.ts.map +1 -1
  176. package/dist/commands/patch-id-command.d.ts +30 -0
  177. package/dist/commands/patch-id-command.d.ts.map +1 -0
  178. package/dist/commands/patch-id.d.ts +24 -0
  179. package/dist/commands/patch-id.d.ts.map +1 -1
  180. package/dist/commands/plumbing-command.d.ts +66 -0
  181. package/dist/commands/plumbing-command.d.ts.map +1 -0
  182. package/dist/commands/plumbing-input.d.ts +38 -0
  183. package/dist/commands/plumbing-input.d.ts.map +1 -0
  184. package/dist/commands/promisor-remote-reply.d.ts +35 -0
  185. package/dist/commands/promisor-remote-reply.d.ts.map +1 -0
  186. package/dist/commands/promisor-remote.d.ts.map +1 -1
  187. package/dist/commands/pull-command.d.ts.map +1 -1
  188. package/dist/commands/push-command.d.ts +17 -2
  189. package/dist/commands/push-command.d.ts.map +1 -1
  190. package/dist/commands/rebase-command.d.ts +108 -2
  191. package/dist/commands/rebase-command.d.ts.map +1 -1
  192. package/dist/commands/refs-command.d.ts +81 -0
  193. package/dist/commands/refs-command.d.ts.map +1 -0
  194. package/dist/commands/remote-object-info-command.d.ts +55 -0
  195. package/dist/commands/remote-object-info-command.d.ts.map +1 -0
  196. package/dist/commands/remote-transport.d.ts +40 -3
  197. package/dist/commands/remote-transport.d.ts.map +1 -1
  198. package/dist/commands/repack-command.d.ts +115 -0
  199. package/dist/commands/repack-command.d.ts.map +1 -0
  200. package/dist/commands/replace-command.d.ts +143 -0
  201. package/dist/commands/replace-command.d.ts.map +1 -0
  202. package/dist/commands/replay-command.d.ts +117 -0
  203. package/dist/commands/replay-command.d.ts.map +1 -0
  204. package/dist/commands/repo-command.d.ts +136 -0
  205. package/dist/commands/repo-command.d.ts.map +1 -0
  206. package/dist/commands/request-pull-command.d.ts +82 -0
  207. package/dist/commands/request-pull-command.d.ts.map +1 -0
  208. package/dist/commands/rerere-command.d.ts +36 -0
  209. package/dist/commands/rerere-command.d.ts.map +1 -0
  210. package/dist/commands/rerere.d.ts +102 -0
  211. package/dist/commands/rerere.d.ts.map +1 -0
  212. package/dist/commands/rev-filter/commit-grep.d.ts +3 -1
  213. package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -1
  214. package/dist/commands/rev-list-command.d.ts +3 -0
  215. package/dist/commands/rev-list-command.d.ts.map +1 -1
  216. package/dist/commands/rev-parse-command.d.ts +9 -0
  217. package/dist/commands/rev-parse-command.d.ts.map +1 -1
  218. package/dist/commands/revert-command.d.ts +10 -0
  219. package/dist/commands/revert-command.d.ts.map +1 -1
  220. package/dist/commands/revision-range.d.ts +5 -0
  221. package/dist/commands/revision-range.d.ts.map +1 -1
  222. package/dist/commands/revision-resolver.d.ts +12 -0
  223. package/dist/commands/revision-resolver.d.ts.map +1 -1
  224. package/dist/commands/sequencer-pick.d.ts +18 -0
  225. package/dist/commands/sequencer-pick.d.ts.map +1 -1
  226. package/dist/commands/serve-repository.d.ts +23 -1
  227. package/dist/commands/serve-repository.d.ts.map +1 -1
  228. package/dist/commands/session-id.d.ts +18 -0
  229. package/dist/commands/session-id.d.ts.map +1 -0
  230. package/dist/commands/show-branch-command.d.ts +59 -0
  231. package/dist/commands/show-branch-command.d.ts.map +1 -0
  232. package/dist/commands/show-ref-command.d.ts +112 -0
  233. package/dist/commands/show-ref-command.d.ts.map +1 -0
  234. package/dist/commands/signature-check.d.ts +9 -2
  235. package/dist/commands/signature-check.d.ts.map +1 -1
  236. package/dist/commands/signing.d.ts +22 -1
  237. package/dist/commands/signing.d.ts.map +1 -1
  238. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  239. package/dist/commands/stash-export-command.d.ts +115 -0
  240. package/dist/commands/stash-export-command.d.ts.map +1 -0
  241. package/dist/commands/status-command.d.ts +2 -1
  242. package/dist/commands/status-command.d.ts.map +1 -1
  243. package/dist/commands/stripspace-command.d.ts +44 -0
  244. package/dist/commands/stripspace-command.d.ts.map +1 -0
  245. package/dist/commands/submodule-add-command.d.ts +10 -1
  246. package/dist/commands/submodule-add-command.d.ts.map +1 -1
  247. package/dist/commands/submodule-auth.d.ts +3 -1
  248. package/dist/commands/submodule-auth.d.ts.map +1 -1
  249. package/dist/commands/submodule-commands.d.ts +9 -1
  250. package/dist/commands/submodule-commands.d.ts.map +1 -1
  251. package/dist/commands/submodule-update-command.d.ts +13 -1
  252. package/dist/commands/submodule-update-command.d.ts.map +1 -1
  253. package/dist/commands/textconv-cache.d.ts +58 -0
  254. package/dist/commands/textconv-cache.d.ts.map +1 -0
  255. package/dist/commands/tree-restore.d.ts +5 -0
  256. package/dist/commands/tree-restore.d.ts.map +1 -1
  257. package/dist/commands/unpack-objects-command.d.ts +47 -0
  258. package/dist/commands/unpack-objects-command.d.ts.map +1 -0
  259. package/dist/commands/update-index-command.d.ts +110 -0
  260. package/dist/commands/update-index-command.d.ts.map +1 -0
  261. package/dist/commands/uri-protocols.d.ts +13 -0
  262. package/dist/commands/uri-protocols.d.ts.map +1 -0
  263. package/dist/commands/url-parse-command.d.ts +30 -0
  264. package/dist/commands/url-parse-command.d.ts.map +1 -0
  265. package/dist/commands/var-command.d.ts +42 -0
  266. package/dist/commands/var-command.d.ts.map +1 -0
  267. package/dist/{commands-CNvli5bl.js → commands-Mlo1dxQN.js} +52078 -44471
  268. package/dist/errors/command-errors.d.ts +33 -0
  269. package/dist/errors/command-errors.d.ts.map +1 -1
  270. package/dist/errors/index.js +39 -1
  271. package/dist/{fsck-CPeDh9fh.js → fsck-CrhVMNIH.js} +184 -143
  272. package/dist/git-command.d.ts +58 -2
  273. package/dist/git-command.d.ts.map +1 -1
  274. package/dist/git.d.ts +532 -1
  275. package/dist/git.d.ts.map +1 -1
  276. package/dist/guarded-transport-command.d.ts +3 -1
  277. package/dist/guarded-transport-command.d.ts.map +1 -1
  278. package/dist/index.js +7 -6
  279. package/dist/maintenance-run-command-Bw21HEkH.js +13539 -0
  280. package/dist/{remote-transport-CCmBadm-.js → remote-transport-Bu4PGSMD.js} +1009 -10
  281. package/dist/results/cherry-pick-result.d.ts +6 -0
  282. package/dist/results/cherry-pick-result.d.ts.map +1 -1
  283. package/dist/results/diff-entry.d.ts +10 -0
  284. package/dist/results/diff-entry.d.ts.map +1 -1
  285. package/dist/results/diff-formatter.d.ts.map +1 -1
  286. package/dist/results/diff-output.d.ts +49 -3
  287. package/dist/results/diff-output.d.ts.map +1 -1
  288. package/dist/results/fetch-result.d.ts +12 -0
  289. package/dist/results/fetch-result.d.ts.map +1 -1
  290. package/dist/results/index.js +2 -2
  291. package/dist/results/merge-result.d.ts +5 -0
  292. package/dist/results/merge-result.d.ts.map +1 -1
  293. package/dist/results/push-result.d.ts +5 -0
  294. package/dist/results/push-result.d.ts.map +1 -1
  295. package/dist/results/rebase-result.d.ts +7 -0
  296. package/dist/results/rebase-result.d.ts.map +1 -1
  297. package/dist/results/revert-result.d.ts +6 -0
  298. package/dist/results/revert-result.d.ts.map +1 -1
  299. package/dist/results/stash-result.d.ts +5 -0
  300. package/dist/results/stash-result.d.ts.map +1 -1
  301. package/dist/{results-BDuEgdLU.js → results-ERo9vELd.js} +28511 -25685
  302. package/dist/transport-command.d.ts +79 -1
  303. package/dist/transport-command.d.ts.map +1 -1
  304. package/package.json +12 -12
  305. package/src/commands/add-command.ts +3 -0
  306. package/src/commands/add-patch/patch-backend.ts +4 -1
  307. package/src/commands/add-patch/patch-modes.ts +26 -2
  308. package/src/commands/add-patch/patch-session.ts +6 -0
  309. package/src/commands/am/am-command.ts +163 -8
  310. package/src/commands/apply/index.ts +1 -0
  311. package/src/commands/archive/archive-command.ts +1148 -0
  312. package/src/commands/archive/archive-entry.ts +93 -0
  313. package/src/commands/archive/index.ts +7 -0
  314. package/src/commands/archive/remote-archive-command.ts +140 -0
  315. package/src/commands/archive/tar-archive.ts +207 -0
  316. package/src/commands/archive/tar-commit-id.ts +72 -0
  317. package/src/commands/archive/upload-archive-writer.ts +213 -0
  318. package/src/commands/archive/zip-archive.ts +317 -0
  319. package/src/commands/attributes-source.ts +26 -12
  320. package/src/commands/blame-command.ts +118 -19
  321. package/src/commands/bundle/bundle-create-command.ts +405 -0
  322. package/src/commands/bundle/bundle-format.ts +228 -0
  323. package/src/commands/bundle/bundle-list.ts +276 -0
  324. package/src/commands/bundle/bundle-read-commands.ts +157 -0
  325. package/src/commands/bundle/bundle-support.ts +85 -0
  326. package/src/commands/bundle/bundle-transport.ts +107 -0
  327. package/src/commands/bundle/bundle-uri-host.ts +204 -0
  328. package/src/commands/bundle/bundle-uri.ts +236 -0
  329. package/src/commands/bundle/bundle-verify.ts +152 -0
  330. package/src/commands/bundle/index.ts +14 -0
  331. package/src/commands/cat-file/batch-format.ts +193 -0
  332. package/src/commands/cat-file/cat-file-command.ts +857 -0
  333. package/src/commands/cat-file/index.ts +2 -0
  334. package/src/commands/check-attr-command.ts +333 -0
  335. package/src/commands/check-ignore-command.ts +261 -0
  336. package/src/commands/check-ref-format-command.ts +129 -0
  337. package/src/commands/checkout-command.ts +39 -21
  338. package/src/commands/checkout-index-command.ts +568 -0
  339. package/src/commands/checkout-paths.ts +7 -0
  340. package/src/commands/cherry-pick-command.ts +21 -1
  341. package/src/commands/clone-command.ts +208 -7
  342. package/src/commands/commit-command.ts +22 -4
  343. package/src/commands/config-command.ts +9 -0
  344. package/src/commands/daemon-access-hook.ts +78 -0
  345. package/src/commands/default-branch.ts +99 -1
  346. package/src/commands/diff-command.ts +573 -46
  347. package/src/commands/diff-external.ts +131 -0
  348. package/src/commands/diff-plumbing/diff-pairs-command.ts +193 -0
  349. package/src/commands/diff-plumbing/diff-plumbing-command.ts +424 -0
  350. package/src/commands/diff-plumbing/index.ts +2 -0
  351. package/src/commands/diff-textconv.ts +5 -1
  352. package/src/commands/fast-export/fast-export-command.ts +911 -0
  353. package/src/commands/fast-export/fast-import-command.ts +1553 -0
  354. package/src/commands/fast-export/fast-stream-support.ts +162 -0
  355. package/src/commands/fast-export/index.ts +3 -0
  356. package/src/commands/fetch-command.ts +312 -8
  357. package/src/commands/fetch-multiple-command.ts +4 -1
  358. package/src/commands/format-rev-command.ts +251 -0
  359. package/src/commands/fsck/fsck-command.ts +47 -20
  360. package/src/commands/fsck/fsck-msg-ids.ts +19 -3
  361. package/src/commands/fsck/fsck-pack.ts +2 -2
  362. package/src/commands/fsmonitor-refresh.ts +315 -0
  363. package/src/commands/gc-command.ts +10 -0
  364. package/src/commands/git-hooks.ts +123 -6
  365. package/src/commands/git-paths.ts +136 -0
  366. package/src/commands/grep/grep-command.ts +38 -15
  367. package/src/commands/history-command.ts +617 -0
  368. package/src/commands/http-config.ts +139 -0
  369. package/src/commands/index-adder.ts +37 -3
  370. package/src/commands/index-host.ts +6 -1
  371. package/src/commands/index.ts +45 -0
  372. package/src/commands/init-command.ts +14 -0
  373. package/src/commands/last-modified-command.ts +804 -0
  374. package/src/commands/lfs/go-url.ts +370 -0
  375. package/src/commands/lfs/index.ts +2 -0
  376. package/src/commands/lfs/lfs-config.ts +738 -0
  377. package/src/commands/lfs/lfs-endpoint-command.ts +180 -0
  378. package/src/commands/local-transport.ts +252 -4
  379. package/src/commands/log-command.ts +104 -5
  380. package/src/commands/log-output.ts +55 -5
  381. package/src/commands/ls-files-command.ts +1177 -0
  382. package/src/commands/ls-remote-command.ts +6 -0
  383. package/src/commands/ls-tree-command.ts +684 -0
  384. package/src/commands/maintenance-run-command.ts +949 -0
  385. package/src/commands/merge-command.ts +78 -32
  386. package/src/commands/merge-config.ts +23 -1
  387. package/src/commands/merge-drivers.ts +109 -20
  388. package/src/commands/merge-support.ts +29 -5
  389. package/src/commands/merge-tree-command.ts +786 -0
  390. package/src/commands/mktag-command.ts +149 -0
  391. package/src/commands/object-store/count-objects-command.ts +404 -0
  392. package/src/commands/object-store/index.ts +4 -0
  393. package/src/commands/object-store/objects-directory.ts +24 -0
  394. package/src/commands/object-store/prune-command.ts +129 -0
  395. package/src/commands/object-store/show-index-command.ts +151 -0
  396. package/src/commands/ort-merge.ts +92 -25
  397. package/src/commands/patch-id-command.ts +65 -0
  398. package/src/commands/patch-id.ts +218 -0
  399. package/src/commands/plumbing-command.ts +141 -0
  400. package/src/commands/plumbing-input.ts +87 -0
  401. package/src/commands/promisor-remote-reply.ts +276 -0
  402. package/src/commands/promisor-remote.ts +25 -2
  403. package/src/commands/pull-command.ts +2 -0
  404. package/src/commands/push-command.ts +87 -5
  405. package/src/commands/rebase-command.ts +507 -19
  406. package/src/commands/refs-command.ts +274 -0
  407. package/src/commands/remote-object-info-command.ts +109 -0
  408. package/src/commands/remote-transport.ts +116 -1
  409. package/src/commands/repack-command.ts +383 -0
  410. package/src/commands/replace-command.ts +816 -0
  411. package/src/commands/replay-command.ts +674 -0
  412. package/src/commands/repo-command.ts +967 -0
  413. package/src/commands/request-pull-command.ts +356 -0
  414. package/src/commands/rerere-command.ts +179 -0
  415. package/src/commands/rerere.ts +925 -0
  416. package/src/commands/rev-filter/commit-grep.ts +7 -2
  417. package/src/commands/rev-list-command.ts +9 -0
  418. package/src/commands/rev-parse-command.ts +62 -4
  419. package/src/commands/revert-command.ts +21 -1
  420. package/src/commands/revision-range.ts +7 -2
  421. package/src/commands/revision-resolver.ts +44 -3
  422. package/src/commands/sequencer-pick.ts +47 -0
  423. package/src/commands/serve-repository.ts +65 -0
  424. package/src/commands/session-id.ts +31 -0
  425. package/src/commands/show-branch-command.ts +981 -0
  426. package/src/commands/show-command.ts +1 -1
  427. package/src/commands/show-ref-command.ts +439 -0
  428. package/src/commands/signature-check.ts +37 -5
  429. package/src/commands/signing.ts +122 -16
  430. package/src/commands/stash-apply-command.ts +3 -0
  431. package/src/commands/stash-export-command.ts +397 -0
  432. package/src/commands/status-command.ts +43 -6
  433. package/src/commands/stripspace-command.ts +118 -0
  434. package/src/commands/submodule-add-command.ts +22 -1
  435. package/src/commands/submodule-auth.ts +61 -6
  436. package/src/commands/submodule-commands.ts +12 -2
  437. package/src/commands/submodule-update-command.ts +29 -0
  438. package/src/commands/textconv-cache.ts +143 -0
  439. package/src/commands/tree-restore.ts +14 -0
  440. package/src/commands/unpack-objects-command.ts +235 -0
  441. package/src/commands/update-index-command.ts +1016 -0
  442. package/src/commands/uri-protocols.ts +13 -0
  443. package/src/commands/url-parse-command.ts +67 -0
  444. package/src/commands/var-command.ts +219 -0
  445. package/src/errors/command-errors.ts +45 -0
  446. package/src/git-command.ts +131 -1
  447. package/src/git.ts +808 -1
  448. package/src/guarded-transport-command.ts +6 -1
  449. package/src/results/cherry-pick-result.ts +6 -0
  450. package/src/results/diff-entry.ts +12 -0
  451. package/src/results/diff-formatter.ts +7 -4
  452. package/src/results/diff-output.ts +117 -11
  453. package/src/results/diff-pickaxe.ts +1 -1
  454. package/src/results/fetch-result.ts +12 -0
  455. package/src/results/merge-result.ts +5 -0
  456. package/src/results/push-result.ts +5 -0
  457. package/src/results/rebase-result.ts +7 -0
  458. package/src/results/revert-result.ts +6 -0
  459. package/src/results/stash-result.ts +6 -0
  460. package/src/transport-command.ts +182 -1
@@ -0,0 +1,804 @@
1
+ /**
2
+ * `git last-modified` (builtin/last-modified.c, git 2.52+): for each path of a commit's tree,
3
+ * the commit that last changed it.
4
+ */
5
+
6
+ import {
7
+ type BloomFilterSettings,
8
+ bloomFilterContains,
9
+ bloomKey,
10
+ type CommitGraph,
11
+ type CommitHeader,
12
+ type ObjectId,
13
+ } from "@statewalker/vcs-core";
14
+ import { parseGitBool } from "@statewalker/vcs-utils";
15
+ import { decodeGitPath, encodeGitPath } from "@statewalker/vcs-utils/encoding";
16
+
17
+ import { RefNotFoundError } from "../errors/index.js";
18
+ import { RemoteConfigStore } from "../remote-config/index.js";
19
+ import { quotePath } from "../results/quote-path.js";
20
+ import { prefixedElement } from "./ls-files-command.js";
21
+ import { configBool, configValue } from "./merge-config.js";
22
+ import {
23
+ ENTRY_NOT_INTERESTING,
24
+ type PathspecItem,
25
+ parsePathspec,
26
+ type TreePathspec,
27
+ treeEntryInteresting,
28
+ treePathspec,
29
+ } from "./pathspec.js";
30
+ import { PlumbingCommand, PlumbingError } from "./plumbing-command.js";
31
+
32
+ const USAGE =
33
+ "usage: git last-modified [--recursive] [--show-trees] [--max-depth=<depth>] [-z]\n" +
34
+ " [<revision-range>] [[--] <pathspec>...]";
35
+
36
+ /** One line of `git last-modified`'s output. */
37
+ export interface LastModifiedEntry {
38
+ /** The path, from the top of the worktree */
39
+ path: string;
40
+ /** The commit that last changed it (or the boundary commit the walk stopped at) */
41
+ commit: ObjectId;
42
+ /** The walk stopped at `commit` (a `-<n>` limit or an excluded commit): printed with `^` */
43
+ boundary: boolean;
44
+ }
45
+
46
+ /** What a run did with the commit-graph's changed-path Bloom filters. */
47
+ export interface LastModifiedStatistics {
48
+ /** First-parent comparisons a filter answered "no path changed" (no tree read) */
49
+ bloomDefinitelyNot: number;
50
+ /** First-parent comparisons a filter answered "maybe" */
51
+ bloomMaybe: number;
52
+ /** Tree comparisons made */
53
+ treeDiffs: number;
54
+ }
55
+
56
+ /** A commit as the walk holds it (git's `struct commit` plus the object flags it uses). */
57
+ interface WalkCommit {
58
+ id: ObjectId;
59
+ parsed: boolean;
60
+ tree: ObjectId;
61
+ parents: WalkCommit[];
62
+ /** committer date; 0 until parsed (git's `commit->date`) */
63
+ date: number;
64
+ /** commit-graph generation; Infinity until parsed or outside the graph */
65
+ generation: number;
66
+ flags: number;
67
+ /** the paths (by `all_paths` index) still to be associated, when allocated */
68
+ active?: Uint8Array;
69
+ }
70
+
71
+ // object flags (builtin/last-modified.c, revision.h)
72
+ const PARENT1 = 1;
73
+ const PARENT2 = 2;
74
+ const BOUNDARY = 4;
75
+ const BOTTOM = 8;
76
+
77
+ interface PathEntry {
78
+ path: string;
79
+ /** the path's bytes */
80
+ bytes: Uint8Array;
81
+ id: ObjectId;
82
+ hash: number;
83
+ index: number;
84
+ key?: number[];
85
+ }
86
+
87
+ /**
88
+ * `git last-modified`: which commit last changed each path of the tree (its files and, with
89
+ * `setShowTrees` or without recursion, its directories), walking back from one commit.
90
+ *
91
+ * This is builtin/last-modified.c: the paths come from the tree of the one included revision
92
+ * (default HEAD) limited by the pathspec and `--max-depth`; the walk takes commits newest
93
+ * first (generation, then date) and hands each still-unexplained path on to the first parent
94
+ * whose version of it is the same; a path no parent shares was changed by the commit. Before
95
+ * comparing a commit with its first parent, the commit's changed-path Bloom filter (when the
96
+ * commit-graph has one) is asked whether any of the paths may have changed; a "no" passes them
97
+ * all to that parent without reading a tree. A path still unexplained at a boundary commit
98
+ * (`-<n>`, an excluded commit) is printed with `^` before the boundary's id. Lines come in the
99
+ * order git prints them: by the commit that explains them, then in the order of git's
100
+ * hashmap of the paths.
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const entries = await git.lastModified().setRecursive().addPaths("src").callEntries();
105
+ * ```
106
+ */
107
+ export class LastModifiedCommand extends PlumbingCommand {
108
+ private maxDepth = 0;
109
+ private showTrees = false;
110
+ private nul = false;
111
+ private maxCount = -1;
112
+ private revisions: string[] = [];
113
+ private paths: string[] = [];
114
+ private prefix = "";
115
+ private useBloomFilters = true;
116
+ private statistics: LastModifiedStatistics = {
117
+ bloomDefinitelyNot: 0,
118
+ bloomMaybe: 0,
119
+ treeDiffs: 0,
120
+ };
121
+ private entriesOut?: LastModifiedEntry[];
122
+
123
+ /** `-r`, `--recursive`: every path below the pathspec (`--max-depth=-1`). */
124
+ setRecursive(recursive = true): this {
125
+ this.checkCallable();
126
+ this.maxDepth = recursive ? -1 : 0;
127
+ return this;
128
+ }
129
+
130
+ /** `-t`, `--show-trees`: directories too when recursing into them. */
131
+ setShowTrees(show = true): this {
132
+ this.checkCallable();
133
+ this.showTrees = show;
134
+ return this;
135
+ }
136
+
137
+ /** `--max-depth=<depth>`: levels below each pathspec element (negative: no limit; default 0). */
138
+ setMaxDepth(depth: number): this {
139
+ this.checkCallable();
140
+ this.maxDepth = depth;
141
+ return this;
142
+ }
143
+
144
+ /** `-z`: paths unquoted, each line ended by a NUL. */
145
+ setNullTerminated(nul = true): this {
146
+ this.checkCallable();
147
+ this.nul = nul;
148
+ return this;
149
+ }
150
+
151
+ /** `-<n>`, `-n <n>`, `--max-count=<n>`: stop after `n` commits (the next is a boundary). */
152
+ setMaxCount(count: number): this {
153
+ this.checkCallable();
154
+ this.maxCount = count;
155
+ return this;
156
+ }
157
+
158
+ /**
159
+ * Revisions as git reads them: `<rev>`, `^<rev>` and `<a>..<b>` (one included commit at
160
+ * most). An argument starting with `-` is refused as git refuses an unknown option.
161
+ */
162
+ addRevisions(...revisions: string[]): this {
163
+ this.checkCallable();
164
+ this.revisions.push(...revisions);
165
+ return this;
166
+ }
167
+
168
+ /** Pathspec elements, relative to {@link setPrefix}. */
169
+ addPaths(...paths: string[]): this {
170
+ this.checkCallable();
171
+ this.paths.push(...paths);
172
+ return this;
173
+ }
174
+
175
+ /** The directory below the top the command runs in (pathspecs are relative to it). */
176
+ setPrefix(prefix: string): this {
177
+ this.checkCallable();
178
+ this.prefix = prefix.replace(/\/+$/, "");
179
+ return this;
180
+ }
181
+
182
+ /** Whether the commit-graph's changed-path Bloom filters are asked (default true). */
183
+ setUseBloomFilters(use: boolean): this {
184
+ this.checkCallable();
185
+ this.useBloomFilters = use;
186
+ return this;
187
+ }
188
+
189
+ /** What the last run did with the Bloom filters. */
190
+ getStatistics(): LastModifiedStatistics {
191
+ return { ...this.statistics };
192
+ }
193
+
194
+ /**
195
+ * Runs the command and returns its lines as entries (git's deaths thrown as
196
+ * `PlumbingError`).
197
+ */
198
+ async callEntries(): Promise<LastModifiedEntry[]> {
199
+ const entries: LastModifiedEntry[] = [];
200
+ this.entriesOut = entries;
201
+ const r = await this.call();
202
+ if (r.exitCode !== 0) throw new PlumbingError(r.stderr.trimEnd(), r.exitCode);
203
+ return entries;
204
+ }
205
+
206
+ protected async run(): Promise<number> {
207
+ for (const r of this.revisions) {
208
+ if (r.startsWith("-")) {
209
+ throw new PlumbingError(`error: unknown last-modified argument: ${r}\n${USAGE}`, 129);
210
+ }
211
+ }
212
+ const items = await this.parsePaths();
213
+ const ps = items.length > 0 ? treePathspec(items) : undefined;
214
+ const depthValid = this.maxDepth >= 0;
215
+ if (ps?.hasWildcard && depthValid) {
216
+ throw new PlumbingError("fatal: max-depth cannot be used with wildcard pathspecs");
217
+ }
218
+ const diff = new TreeDiff(this, ps, depthValid ? this.maxDepth : -1, this.showTrees);
219
+
220
+ // setup_revisions: the arguments, then HEAD when none was given (rev.def)
221
+ const commits = new Map<ObjectId, WalkCommit>();
222
+ const lookup = (id: ObjectId): WalkCommit => {
223
+ let c = commits.get(id);
224
+ if (!c) {
225
+ c = { id, parsed: false, tree: "", parents: [], date: 0, generation: Infinity, flags: 0 };
226
+ commits.set(id, c);
227
+ }
228
+ return c;
229
+ };
230
+ const pending: { name: string; id: ObjectId; exclude: boolean }[] = [];
231
+ const resolver = this.revisionResolver();
232
+ const resolve = async (name: string, arg = name): Promise<ObjectId> => {
233
+ let id: ObjectId | undefined;
234
+ try {
235
+ id = await resolver.resolve(name);
236
+ } catch (e) {
237
+ if (!(e instanceof RefNotFoundError)) throw e;
238
+ }
239
+ for (const w of resolver.warnings) this.warn(w);
240
+ resolver.warnings.length = 0;
241
+ if (id === undefined) {
242
+ throw new PlumbingError(
243
+ `fatal: ambiguous argument '${arg}': unknown revision or path not in the working tree.\n` +
244
+ "Use '--' to separate paths from revisions, like this:\n" +
245
+ "'git <command> [<revision>...] -- [<file>...]'",
246
+ );
247
+ }
248
+ return id;
249
+ };
250
+ const revisions = this.revisions.length > 0 ? this.revisions : ["HEAD"];
251
+ for (const arg of revisions) {
252
+ const dots = arg.indexOf("..");
253
+ if (dots >= 0 && arg[dots + 2] !== ".") {
254
+ const left = arg.slice(0, dots) || "HEAD";
255
+ const right = arg.slice(dots + 2) || "HEAD";
256
+ pending.push({ name: left, id: await resolve(left, arg), exclude: true });
257
+ pending.push({ name: right, id: await resolve(right, arg), exclude: false });
258
+ } else if (dots >= 0) {
259
+ // a symmetric difference includes both sides
260
+ const left = arg.slice(0, dots) || "HEAD";
261
+ const right = arg.slice(dots + 3) || "HEAD";
262
+ pending.push({ name: left, id: await resolve(left, arg), exclude: false });
263
+ pending.push({ name: right, id: await resolve(right, arg), exclude: false });
264
+ } else if (arg.startsWith("^")) {
265
+ pending.push({ name: arg.slice(1), id: await resolve(arg.slice(1)), exclude: true });
266
+ } else {
267
+ pending.push({ name: arg, id: await resolve(arg), exclude: false });
268
+ }
269
+ }
270
+
271
+ // populate_paths_from_revs: the paths of the one included commit's tree
272
+ const included = pending.filter((p) => !p.exclude);
273
+ if (included.length > 1) {
274
+ this.warn("error: last-modified can only operate on one commit at a time");
275
+ return 255;
276
+ }
277
+ const paths = new GitHashmapOrder();
278
+ let start: WalkCommit | undefined;
279
+ for (const p of included) {
280
+ const commitId = await resolver.peelToType(p.id, "commit");
281
+ if (commitId === undefined) {
282
+ const type = (await resolver.objectType(p.id)) ?? "bad object";
283
+ this.warn(`error: revision argument '${p.name}' is a ${type}, not a commit-ish`);
284
+ return 255;
285
+ }
286
+ start = lookup(commitId);
287
+ }
288
+
289
+ const shallow = new Set((await this.refsStore.getShallow?.().catch(() => undefined)) ?? []);
290
+ const reader = await this.commits.headerReader?.().catch(() => undefined);
291
+ const graph =
292
+ shallow.size > 0 ? undefined : await this.commits.commitGraph?.get().catch(() => undefined);
293
+ const parse = async (c: WalkCommit): Promise<boolean> => {
294
+ if (c.parsed) return true;
295
+ let header: CommitHeader | undefined;
296
+ if (reader) header = await reader.getHeader(c.id).catch(() => undefined);
297
+ else {
298
+ const commit = await this.commits.load(c.id).catch(() => undefined);
299
+ header = commit && {
300
+ tree: commit.tree,
301
+ parents: commit.parents,
302
+ commitTime: commit.committer.timestamp,
303
+ generation: Infinity,
304
+ };
305
+ }
306
+ if (!header) return false;
307
+ c.parsed = true;
308
+ c.tree = header.tree;
309
+ c.date = header.commitTime;
310
+ c.generation = shallow.size > 0 ? Infinity : header.generation;
311
+ c.parents = shallow.has(c.id) ? [] : header.parents.map(lookup);
312
+ return true;
313
+ };
314
+
315
+ if (start) {
316
+ if (!(await parse(start))) throw new PlumbingError(`fatal: bad object ${start.id}`);
317
+ for (const e of await diff.entries(undefined, start.tree)) paths.add(e);
318
+ }
319
+ const allPaths = paths.ordered();
320
+ const byPath = new Map<string, PathEntry>();
321
+ for (let i = 0; i < allPaths.length; i++) {
322
+ const e = allPaths[i] as PathEntry;
323
+ e.index = i;
324
+ byPath.set(e.path, e);
325
+ }
326
+ const count = allPaths.length;
327
+
328
+ // the Bloom filters git's maybe_changed_path asks (rev.bloom_filter_settings)
329
+ const bloom = this.useBloomFilters ? this.bloomSettings(graph) : undefined;
330
+ if (bloom) for (const e of allPaths) e.key = bloomKey(e.bytes, bloom.settings);
331
+
332
+ const config = this._workingCopy.config ? RemoteConfigStore.from(this._workingCopy) : undefined;
333
+ const quotePathValue = config?.value("core.quotePath");
334
+ const quoteFully = quotePathValue === undefined ? true : (parseGitBool(quotePathValue) ?? true);
335
+
336
+ const emit = async (path: string, c: WalkCommit): Promise<void> => {
337
+ const boundary = (c.flags & BOUNDARY) !== 0;
338
+ this.entriesOut?.push({ path, commit: c.id, boundary });
339
+ const name = this.nul ? `${path}\0` : `${quotePath(path, quoteFully)}\n`;
340
+ await this.write(`${boundary ? "^" : ""}${c.id}\t${name}`);
341
+ };
342
+ /** mark_path: emit a path still waiting (at `id`, when given), and forget it */
343
+ const markPath = async (path: string, id: ObjectId | undefined, c: WalkCommit) => {
344
+ const e = byPath.get(path);
345
+ if (!e) return;
346
+ if (id !== undefined && id !== e.id) return;
347
+ await emit(path, c);
348
+ byPath.delete(path);
349
+ };
350
+ const activeOf = (c: WalkCommit): Uint8Array => {
351
+ c.active ??= new Uint8Array(count);
352
+ return c.active;
353
+ };
354
+ const isEmpty = (bits: Uint8Array) => bits.indexOf(1) < 0;
355
+
356
+ /** maybe_changed_path: whether `c`'s filter may hold one of the paths active in it */
357
+ const maybeChangedPath = (c: WalkCommit, active: Uint8Array): boolean => {
358
+ if (!bloom || !graph) return true;
359
+ if (c.generation === Infinity) return true;
360
+ const pos = graph.position(c.id);
361
+ if (pos < 0) return true;
362
+ const found = graph.bloomFilterAt(pos);
363
+ if (!found || (bloom.version !== -1 && found.settings.hashVersion !== bloom.version)) {
364
+ return true;
365
+ }
366
+ for (const e of byPath.values()) {
367
+ if (!active[e.index]) continue;
368
+ if (bloomFilterContains(found.data, e.key as number[]) !== 0) {
369
+ this.statistics.bloomMaybe++;
370
+ return true;
371
+ }
372
+ }
373
+ this.statistics.bloomDefinitelyNot++;
374
+ return false;
375
+ };
376
+
377
+ const queue = new PrioQueue();
378
+ const notQueue = new PrioQueue();
379
+
380
+ /** process_parent */
381
+ const processParent = async (
382
+ c: WalkCommit,
383
+ activeC: Uint8Array,
384
+ parent: WalkCommit,
385
+ nth: number,
386
+ ): Promise<void> => {
387
+ if (!(await parse(parent))) return;
388
+ const activeP = activeOf(parent);
389
+ let changed: QueuedPath[] = [];
390
+ if (nth > 0 || maybeChangedPath(c, activeC)) {
391
+ this.statistics.treeDiffs++;
392
+ changed = await diff.entries(parent.tree, c.tree);
393
+ }
394
+ const scratch = new Uint8Array(count);
395
+ for (const fp of changed) {
396
+ const e = byPath.get(fp.path);
397
+ if (e && activeC[e.index]) scratch[e.index] = 1;
398
+ }
399
+ for (let i = 0; i < count; i++) {
400
+ if (activeC[i] && !scratch[i]) {
401
+ activeC[i] = 0;
402
+ activeP[i] = 1;
403
+ }
404
+ }
405
+ if (!isEmpty(activeP) && !(parent.flags & PARENT1)) {
406
+ parent.flags |= PARENT1;
407
+ queue.put(parent);
408
+ }
409
+ if (!(parent.flags & PARENT1)) parent.active = undefined;
410
+ };
411
+
412
+ // last_modified_run: rev.commits are the pending commits (prepare_revision_walk)
413
+ const seen = new Set<WalkCommit>();
414
+ const listed: WalkCommit[] = [];
415
+ for (const p of pending) {
416
+ const id = p.exclude ? await resolver.peelToType(p.id, "commit") : (start?.id ?? undefined);
417
+ if (id === undefined) continue;
418
+ const c = lookup(id);
419
+ if (p.exclude) c.flags |= BOTTOM;
420
+ if (!(await parse(c))) continue;
421
+ if (!seen.has(c)) {
422
+ seen.add(c);
423
+ listed.push(c);
424
+ }
425
+ }
426
+ for (const c of listed) {
427
+ if (c.flags & BOTTOM) {
428
+ notQueue.put(c);
429
+ c.flags |= PARENT2;
430
+ } else if (!(c.flags & PARENT1)) {
431
+ queue.put(c);
432
+ c.flags |= PARENT1;
433
+ activeOf(c).fill(1);
434
+ }
435
+ }
436
+
437
+ let popped = 0;
438
+ for (let c = queue.get(); c; c = queue.get()) {
439
+ const activeC = activeOf(c);
440
+ if ((this.maxCount >= 0 && this.maxCount < ++popped) || c.flags & PARENT2) {
441
+ // a boundary commit, or past the limit: what is left is explained by it
442
+ c.flags |= PARENT2 | BOUNDARY;
443
+ for (const e of await diff.entries(undefined, c.tree)) await markPath(e.path, e.id, c);
444
+ c.active = undefined;
445
+ continue;
446
+ }
447
+ if (await parse(c)) {
448
+ // make sure c is not reachable from anything in the --not queue
449
+ for (let n = notQueue.get(); n; n = notQueue.get()) {
450
+ if (!(await parse(n))) continue;
451
+ for (const np of n.parents) {
452
+ if (!(np.flags & PARENT2)) {
453
+ notQueue.put(np);
454
+ np.flags |= PARENT2;
455
+ }
456
+ }
457
+ if (n.generation < c.generation) break;
458
+ }
459
+ for (let nth = 0; nth < c.parents.length; nth++) {
460
+ await processParent(c, activeC, c.parents[nth] as WalkCommit, nth);
461
+ if (isEmpty(activeC)) break;
462
+ }
463
+ // the paths left, or not the same in any parent, were changed by c
464
+ if (!isEmpty(activeC)) {
465
+ for (let i = 0; i < count; i++) {
466
+ if (activeC[i]) await markPath((allPaths[i] as PathEntry).path, undefined, c);
467
+ }
468
+ }
469
+ }
470
+ c.active = undefined;
471
+ }
472
+ return 0;
473
+ }
474
+
475
+ /** The pathspec, its elements relative to the prefix (prefix_path). */
476
+ private async parsePaths(): Promise<PathspecItem[]> {
477
+ // each element, magic ones too, read against the current directory (prefix_path_gently);
478
+ // no element, or only excludes, is the whole tree (parse_pathspec without PREFER_CWD)
479
+ const top = this.paths.length > 0 ? await this.hostWorkingDir() : undefined;
480
+ const paths = this.paths.map((p) =>
481
+ prefixedElement(p, this.prefix ? `${this.prefix}/` : "", top),
482
+ );
483
+ try {
484
+ return parsePathspec(paths);
485
+ } catch (e) {
486
+ if (e instanceof Error && !(e instanceof PlumbingError)) {
487
+ throw new PlumbingError(`fatal: ${e.message}`);
488
+ }
489
+ throw e;
490
+ }
491
+ }
492
+
493
+ /**
494
+ * get_bloom_filter_settings with `commitGraph.changedPathsVersion` (-1: any version; 0 or
495
+ * `commitGraph.readChangedPaths=false`: none).
496
+ */
497
+ private bloomSettings(
498
+ graph: CommitGraph | undefined,
499
+ ): { settings: BloomFilterSettings; version: number } | undefined {
500
+ const settings = graph?.bloomSettings;
501
+ if (!settings) return undefined;
502
+ const raw = configValue(this._workingCopy, "commitGraph.changedPathsVersion");
503
+ const version =
504
+ raw !== undefined && /^\s*[-+]?\d+\s*$/.test(raw)
505
+ ? Number.parseInt(raw, 10)
506
+ : configBool(this._workingCopy, "commitGraph.readChangedPaths", true)
507
+ ? -1
508
+ : 0;
509
+ if (version === 0) return undefined;
510
+ return { settings, version };
511
+ }
512
+
513
+ /** Raw tree entries (the command's tree view: replace refs applied). */
514
+ async readTreeItems(id: ObjectId): Promise<TreeItem[]> {
515
+ if (id === this.objectFormat.emptyTreeId) return [];
516
+ const loaded = await this.trees.load(id);
517
+ if (!loaded) throw new PlumbingError(`fatal: unable to read tree ${id}`);
518
+ const out: TreeItem[] = [];
519
+ for await (const e of loaded) {
520
+ const name = encodeGitPath(e.name);
521
+ out.push({ name, mode: e.mode, id: e.id, isDir: (e.mode & 0o170000) === 0o040000 });
522
+ }
523
+ return out;
524
+ }
525
+ }
526
+
527
+ interface TreeItem {
528
+ name: Uint8Array;
529
+ mode: number;
530
+ id: ObjectId;
531
+ isDir: boolean;
532
+ }
533
+
534
+ /** A path diff_tree_oid queues (its `two` side: the newer tree's id, if any). */
535
+ interface QueuedPath {
536
+ path: string;
537
+ bytes: Uint8Array;
538
+ id: ObjectId | undefined;
539
+ }
540
+
541
+ /**
542
+ * git's recursive diff_tree_oid as last-modified sets it up (tree-diff.c): the pathspec,
543
+ * `max_depth` (`check_recursion_depth`) and `tree_in_recursive` (`--show-trees`).
544
+ */
545
+ class TreeDiff {
546
+ private cache = new Map<ObjectId, TreeItem[]>();
547
+
548
+ constructor(
549
+ private readonly host: LastModifiedCommand,
550
+ private readonly ps: TreePathspec | undefined,
551
+ /** -1: no limit */
552
+ private readonly maxDepth: number,
553
+ private readonly showTrees: boolean,
554
+ ) {}
555
+
556
+ /** The paths that differ between `from` (undefined: empty) and `to`, in git's order. */
557
+ async entries(from: ObjectId | undefined, to: ObjectId): Promise<QueuedPath[]> {
558
+ const out: QueuedPath[] = [];
559
+ await this.walk(from, to, new Uint8Array(0), out);
560
+ return out;
561
+ }
562
+
563
+ private async tree(id: ObjectId | undefined): Promise<TreeItem[]> {
564
+ if (id === undefined) return [];
565
+ let t = this.cache.get(id);
566
+ if (!t) {
567
+ t = await this.host.readTreeItems(id);
568
+ if (this.cache.size > 4096) this.cache.clear();
569
+ this.cache.set(id, t);
570
+ }
571
+ return t;
572
+ }
573
+
574
+ private interesting(e: TreeItem, base: Uint8Array): boolean {
575
+ if (!this.ps) return true;
576
+ return (
577
+ treeEntryInteresting(this.ps, e.name, 0, e.name.length, e.mode, base) > ENTRY_NOT_INTERESTING
578
+ );
579
+ }
580
+
581
+ /** should_recurse / check_recursion_depth for the directory `name` (its full path). */
582
+ private shouldRecurse(name: Uint8Array): boolean {
583
+ if (this.maxDepth < 0) return true;
584
+ const items = this.ps?.elements ?? [];
585
+ if (items.length === 0) return withinDepth(name, 0, name.length, 1, this.maxDepth);
586
+ for (let i = items.length - 1; i >= 0; i--) {
587
+ const match = (items[i] as TreePathspec["elements"][number]).match;
588
+ if (name.length >= match.length) {
589
+ if (!isDirPrefix(name, match)) continue;
590
+ return withinDepth(name, match.length, name.length, 1, this.maxDepth);
591
+ }
592
+ if (isDirPrefix(match, name)) return true;
593
+ }
594
+ return false;
595
+ }
596
+
597
+ private async walk(
598
+ from: ObjectId | undefined,
599
+ to: ObjectId | undefined,
600
+ base: Uint8Array,
601
+ out: QueuedPath[],
602
+ ): Promise<void> {
603
+ const a = (await this.tree(from)).filter((e) => this.interesting(e, base));
604
+ const b = (await this.tree(to)).filter((e) => this.interesting(e, base));
605
+ let i = 0;
606
+ let j = 0;
607
+ while (i < a.length || j < b.length) {
608
+ const ea = a[i];
609
+ const eb = b[j];
610
+ const cmp = ea && eb ? baseNameCompare(ea, eb) : ea ? -1 : 1;
611
+ if (cmp === 0) {
612
+ i++;
613
+ j++;
614
+ if (ea?.mode === eb?.mode && ea?.id === eb?.id) continue;
615
+ await this.emit(ea, eb, base, out);
616
+ } else if (cmp < 0) {
617
+ i++;
618
+ await this.emit(ea, undefined, base, out);
619
+ } else {
620
+ j++;
621
+ await this.emit(undefined, eb, base, out);
622
+ }
623
+ }
624
+ }
625
+
626
+ private async emit(
627
+ a: TreeItem | undefined,
628
+ b: TreeItem | undefined,
629
+ base: Uint8Array,
630
+ out: QueuedPath[],
631
+ ): Promise<void> {
632
+ const e = (b ?? a) as TreeItem;
633
+ const full = new Uint8Array(base.length + e.name.length);
634
+ full.set(base);
635
+ full.set(e.name, base.length);
636
+ let emitThis = true;
637
+ let recurse = false;
638
+ if (e.isDir && this.shouldRecurse(full)) {
639
+ recurse = true;
640
+ emitThis = this.showTrees;
641
+ }
642
+ if (emitThis) out.push({ path: decodeGitPath(full), bytes: full, id: b?.id });
643
+ if (recurse) {
644
+ const below = new Uint8Array(full.length + 1);
645
+ below.set(full);
646
+ below[full.length] = 0x2f;
647
+ await this.walk(a?.id, b?.id, below, out);
648
+ }
649
+ }
650
+ }
651
+
652
+ /** base_name_compare: names compare as bytes, a directory's as if it ended in "/". */
653
+ function baseNameCompare(a: TreeItem, b: TreeItem): number {
654
+ const x = a.name;
655
+ const y = b.name;
656
+ const n = Math.min(x.length, y.length);
657
+ for (let k = 0; k < n; k++) {
658
+ const d = (x[k] as number) - (y[k] as number);
659
+ if (d) return d;
660
+ }
661
+ const cx = x.length > n ? (x[n] as number) : a.isDir ? 0x2f : 0;
662
+ const cy = y.length > n ? (y[n] as number) : b.isDir ? 0x2f : 0;
663
+ return cx - cy;
664
+ }
665
+
666
+ /** is_dir_prefix: `dir` leads `path` (equal, or followed by "/"). */
667
+ function isDirPrefix(path: Uint8Array, dir: Uint8Array): boolean {
668
+ if (path.length < dir.length) return false;
669
+ for (let k = 0; k < dir.length; k++) if (path[k] !== dir[k]) return false;
670
+ return path.length === dir.length || path[dir.length] === 0x2f;
671
+ }
672
+
673
+ /** dir.c's within_depth over `name[start, end)`. */
674
+ function withinDepth(
675
+ name: Uint8Array,
676
+ start: number,
677
+ end: number,
678
+ depth: number,
679
+ maxDepth: number,
680
+ ): boolean {
681
+ for (let k = start; k < end; k++) {
682
+ if (name[k] !== 0x2f) continue;
683
+ depth++;
684
+ if (depth > maxDepth) return false;
685
+ }
686
+ return depth <= maxDepth;
687
+ }
688
+
689
+ /**
690
+ * The iteration order of git's hashmap (hashmap.c) of the paths, keyed by `strhash`: 64
691
+ * buckets, growing fourfold past 80% load; each new entry goes first in its bucket, and a
692
+ * rehash moves the entries bucket by bucket, putting each first in its new bucket.
693
+ */
694
+ class GitHashmapOrder {
695
+ private table: (PathEntry & { next?: PathEntry })[][] = Array.from({ length: 64 }, () => []);
696
+ private size = 0;
697
+
698
+ add(q: QueuedPath): void {
699
+ const hash = strhash(q.bytes);
700
+ const e: PathEntry = { path: q.path, bytes: q.bytes, id: q.id ?? "", hash, index: 0 };
701
+ this.table[hash & (this.table.length - 1)]?.unshift(e);
702
+ this.size++;
703
+ if (this.size > Math.floor((this.table.length * 80) / 100)) this.rehash(this.table.length * 4);
704
+ }
705
+
706
+ private rehash(newSize: number): void {
707
+ const old = this.table;
708
+ this.table = Array.from({ length: newSize }, () => []);
709
+ for (const bucket of old) {
710
+ for (const e of bucket) this.table[e.hash & (newSize - 1)]?.unshift(e);
711
+ }
712
+ }
713
+
714
+ ordered(): PathEntry[] {
715
+ return this.table.flat();
716
+ }
717
+ }
718
+
719
+ /** git's strhash: 32-bit FNV-1 over the path's bytes. */
720
+ function strhash(bytes: Uint8Array): number {
721
+ let hash = 0x811c9dc5;
722
+ for (const c of bytes) hash = (Math.imul(hash, 0x01000193) ^ c) >>> 0;
723
+ return hash;
724
+ }
725
+
726
+ /**
727
+ * git's prio_queue with `compare_commits_by_gen_then_commit_date` (prio-queue.c): a binary
728
+ * heap, ties by insertion order, the root taken lazily (a `put` after a `get` takes its place).
729
+ * Keys are read when compared: a commit parsed after it was queued compares by its new date.
730
+ */
731
+ class PrioQueue {
732
+ private items: { c: WalkCommit; ctr: number }[] = [];
733
+ private ctr = 0;
734
+ private getPending = false;
735
+
736
+ private compare(i: number, j: number): number {
737
+ const a = this.items[i] as { c: WalkCommit; ctr: number };
738
+ const b = this.items[j] as { c: WalkCommit; ctr: number };
739
+ const cmp = compareCommits(a.c, b.c);
740
+ if (cmp) return cmp;
741
+ return a.ctr > b.ctr ? 1 : a.ctr < b.ctr ? -1 : 0;
742
+ }
743
+
744
+ private swap(i: number, j: number): void {
745
+ const t = this.items[i] as { c: WalkCommit; ctr: number };
746
+ this.items[i] = this.items[j] as { c: WalkCommit; ctr: number };
747
+ this.items[j] = t;
748
+ }
749
+
750
+ private siftDownRoot(): void {
751
+ const n = this.items.length;
752
+ for (let ix = 0, child: number; ix * 2 + 1 < n; ix = child) {
753
+ child = ix * 2 + 1;
754
+ if (child + 1 < n && this.compare(child, child + 1) >= 0) child++;
755
+ if (this.compare(ix, child) <= 0) break;
756
+ this.swap(child, ix);
757
+ }
758
+ }
759
+
760
+ private flushGet(): void {
761
+ if (!this.getPending) return;
762
+ this.getPending = false;
763
+ const last = this.items.pop() as { c: WalkCommit; ctr: number };
764
+ if (this.items.length > 0) {
765
+ this.items[0] = last;
766
+ this.siftDownRoot();
767
+ }
768
+ }
769
+
770
+ put(c: WalkCommit): void {
771
+ if (this.getPending) {
772
+ this.getPending = false;
773
+ this.items[0] = { c, ctr: this.ctr++ };
774
+ this.siftDownRoot();
775
+ return;
776
+ }
777
+ this.items.push({ c, ctr: this.ctr++ });
778
+ for (let ix = this.items.length - 1, parent: number; ix; ix = parent) {
779
+ parent = (ix - 1) >> 1;
780
+ if (this.compare(parent, ix) <= 0) break;
781
+ this.swap(parent, ix);
782
+ }
783
+ }
784
+
785
+ get(): WalkCommit | undefined {
786
+ if (this.items.length <= (this.getPending ? 1 : 0)) {
787
+ this.items = [];
788
+ this.getPending = false;
789
+ return undefined;
790
+ }
791
+ this.flushGet();
792
+ this.getPending = true;
793
+ return this.items[0]?.c;
794
+ }
795
+ }
796
+
797
+ /** compare_commits_by_gen_then_commit_date: newer first. */
798
+ function compareCommits(a: WalkCommit, b: WalkCommit): number {
799
+ if (a.generation < b.generation) return 1;
800
+ if (a.generation > b.generation) return -1;
801
+ if (a.date < b.date) return 1;
802
+ if (a.date > b.date) return -1;
803
+ return 0;
804
+ }