@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,967 @@
1
+ /**
2
+ * `git repo info` and `git repo structure` (builtin/repo.c, git 2.52+).
3
+ *
4
+ * ```typescript
5
+ * const { stdout } = await git.repoInfo().addKeys("layout.bare", "object.format").callOutput();
6
+ * // "layout.bare=false\nobject.format=sha1\n"
7
+ * const table = await git.repoStructure().callOutput(); // the "Repository structure" table
8
+ * ```
9
+ *
10
+ * Both write stdout as git does and return git's exit status ({@link PlumbingCommand}). The
11
+ * keys of `repo info` depend on the git version ({@link RepoInfoCommand.setCompatibility}).
12
+ */
13
+
14
+ import {
15
+ decodeTreeBytes,
16
+ type FilesApi,
17
+ joinPath,
18
+ type ObjectId,
19
+ type ObjectTypeString,
20
+ type Pack,
21
+ packNameOf,
22
+ } from "@statewalker/vcs-core";
23
+ import { readRepositoryFormat } from "@statewalker/vcs-store-files";
24
+ import { compareGitPaths } from "@statewalker/vcs-utils/encoding";
25
+ import { quotePath } from "../results/quote-path.js";
26
+ import { hookHostOf } from "./git-hooks.js";
27
+ import { hostEnvironmentOf } from "./git-ident.js";
28
+ import { PlumbingCommand, PlumbingError } from "./plumbing-command.js";
29
+ import { RevListCommand } from "./rev-list-command.js";
30
+
31
+ /**
32
+ * The `repo info` key sets: "2.54" (2.54 and 2.55: `layout.*`, `object.format`,
33
+ * `references.format`), "2.56" (2.56.x: also `path.commondir.*` and `path.gitdir.*`), "2.57"
34
+ * (git master after 2.56: `objects.storageFormat`, the other `path.*` keys, and
35
+ * `references.format` renamed `references.storageFormat`). `repo structure` is the same in all.
36
+ */
37
+ export type RepoCompatibility = "2.54" | "2.56" | "2.57";
38
+
39
+ type OutputFormat = "table" | "lines" | "nul";
40
+
41
+ /** git's `parse_format_cb`: `nul`, `lines`, `table`, else `invalid format`. */
42
+ function parseFormat(format: string): OutputFormat {
43
+ if (format === "nul" || format === "lines" || format === "table") return format;
44
+ throw new PlumbingError(`fatal: invalid format '${format}'`);
45
+ }
46
+
47
+ /** path.c's relative_path (POSIX: `/` the only separator). */
48
+ export function gitRelativePath(input: string, prefix: string): string {
49
+ const inLen = input.length;
50
+ const prefixLen = prefix.length;
51
+ if (!inLen) return "./";
52
+ if (!prefixLen) return input;
53
+ if (input.startsWith("/") !== prefix.startsWith("/")) return input;
54
+ let i = 0;
55
+ let j = 0;
56
+ let inOff = 0;
57
+ let prefixOff = 0;
58
+ while (i < prefixLen && j < inLen && prefix[i] === input[j]) {
59
+ if (prefix[i] === "/") {
60
+ while (prefix[i] === "/") i++;
61
+ while (input[j] === "/") j++;
62
+ prefixOff = i;
63
+ inOff = j;
64
+ } else {
65
+ i++;
66
+ j++;
67
+ }
68
+ }
69
+ if (i >= prefixLen && prefixOff < prefixLen) {
70
+ if (j >= inLen) inOff = inLen;
71
+ else if (input[j] === "/") {
72
+ while (input[j] === "/") j++;
73
+ inOff = j;
74
+ } else i = prefixOff;
75
+ } else if (j >= inLen && inOff < inLen) {
76
+ if (prefix[i] === "/") {
77
+ while (prefix[i] === "/") i++;
78
+ inOff = inLen;
79
+ }
80
+ }
81
+ const rest = input.slice(inOff);
82
+ if (i >= prefixLen) return rest.length ? rest : "./";
83
+ let out = "";
84
+ while (i < prefixLen) {
85
+ if (prefix[i] === "/") {
86
+ out += "../";
87
+ while (prefix[i] === "/") i++;
88
+ continue;
89
+ }
90
+ i++;
91
+ }
92
+ if (prefix[prefixLen - 1] !== "/") out += "../";
93
+ return out + rest;
94
+ }
95
+
96
+ /** The repository as `repo info` reads it. */
97
+ interface RepoFacts {
98
+ bare: boolean;
99
+ shallow: boolean;
100
+ objectFormat: string;
101
+ refStorage: string;
102
+ /** host paths (realpath'ed where the host can), undefined where there is none */
103
+ gitDir?: string;
104
+ commonDir?: string;
105
+ index?: string;
106
+ workTree?: string;
107
+ superproject?: string;
108
+ /** git's `repo->prefix`: the current directory below the worktree top, with a `/` */
109
+ prefix: string;
110
+ }
111
+
112
+ type InfoField = (facts: RepoFacts) => string;
113
+
114
+ const relativeTo = (facts: RepoFacts, path: string | undefined): string => {
115
+ if (path === undefined) return "";
116
+ // git runs from the worktree top (the git directory when bare); the prefix is below it
117
+ const base = facts.workTree ?? facts.gitDir ?? "";
118
+ const cwd = facts.prefix ? `${base}/${facts.prefix}` : base;
119
+ return gitRelativePath(path, cwd);
120
+ };
121
+
122
+ const COMMON_FIELDS: [string, InfoField][] = [
123
+ ["layout.bare", (f) => (f.bare ? "true" : "false")],
124
+ ["layout.shallow", (f) => (f.shallow ? "true" : "false")],
125
+ ["object.format", (f) => f.objectFormat],
126
+ ];
127
+ const PATH_DIR_FIELDS: [string, InfoField][] = [
128
+ ["path.commondir.absolute", (f) => f.commonDir ?? ""],
129
+ ["path.commondir.relative", (f) => relativeTo(f, f.commonDir)],
130
+ ["path.gitdir.absolute", (f) => f.gitDir ?? ""],
131
+ ["path.gitdir.relative", (f) => relativeTo(f, f.gitDir)],
132
+ ];
133
+
134
+ /** builtin/repo.c's `repo_info_field` table of a version, in its (sorted) order. */
135
+ function infoFields(compatibility: RepoCompatibility): [string, InfoField][] {
136
+ const refFormat: InfoField = (f) => f.refStorage;
137
+ if (compatibility === "2.54") return [...COMMON_FIELDS, ["references.format", refFormat]];
138
+ if (compatibility === "2.56")
139
+ return [...COMMON_FIELDS, ...PATH_DIR_FIELDS, ["references.format", refFormat]];
140
+ return [
141
+ ...COMMON_FIELDS,
142
+ ["objects.storageFormat", () => "files"],
143
+ ...PATH_DIR_FIELDS,
144
+ ["path.index.absolute", (f) => f.index ?? ""],
145
+ ["path.index.relative", (f) => relativeTo(f, f.index)],
146
+ ["path.prefix", (f) => f.prefix],
147
+ ["path.superprojectworkingtree.absolute", (f) => f.superproject ?? ""],
148
+ ["path.superprojectworkingtree.relative", (f) => relativeTo(f, f.superproject)],
149
+ ["path.workingtree.absolute", (f) => f.workTree ?? ""],
150
+ ["path.workingtree.relative", (f) => relativeTo(f, f.workTree)],
151
+ ["references.storageFormat", refFormat],
152
+ ];
153
+ }
154
+
155
+ /** The host path of a FilesApi path (its root directory joined), undefined without one. */
156
+ function hostPathOf(files: FilesApi, path: string): string | undefined {
157
+ const root = (files as { rootDirectory?: string }).rootDirectory;
158
+ if (!root) return undefined;
159
+ const base = root.replace(/\/+$/, "");
160
+ const rest = path.replace(/^\/+|\/+$/g, "");
161
+ return rest ? `${base}/${rest}` : base || "/";
162
+ }
163
+
164
+ /**
165
+ * `git repo info [--format=(lines|nul) | -z] [--all | <key>...]` and `git repo info --keys`.
166
+ *
167
+ * Paths are host paths: the FilesApi's root directory joined with its paths, resolved through
168
+ * the host's `realPath`; without a root directory the path keys are empty. Not followed:
169
+ * `$GIT_DIR`/`$GIT_COMMON_DIR` given apart from the working copy (the working copy's own
170
+ * directories are reported). `path.superprojectworkingtree.*` is found where the repository's
171
+ * git directory is `<super>/.git/modules/<name>` and the superproject's worktree holds the
172
+ * repository at its place (git asks the superproject's index).
173
+ */
174
+ export class RepoInfoCommand extends PlumbingCommand {
175
+ private format = "lines";
176
+ private all = false;
177
+ private showKeys = false;
178
+ private keys: string[] = [];
179
+ private compatibility: RepoCompatibility = "2.57";
180
+ private currentDirectory = "";
181
+
182
+ /** `--format=<format>` (`lines`, `nul`; `table` is refused when printing values) */
183
+ setFormat(format: string): this {
184
+ this.checkCallable();
185
+ // git dies as it parses the option: a later valid one does not save it
186
+ this.format = this.format.startsWith("!") ? this.format : format;
187
+ if (!["nul", "lines", "table"].includes(format)) this.format = `!${format}`;
188
+ return this;
189
+ }
190
+
191
+ /** `-z`: `--format=nul` */
192
+ setNul(): this {
193
+ return this.setFormat("nul");
194
+ }
195
+
196
+ /** `--all`: every key */
197
+ setAll(all: boolean): this {
198
+ this.checkCallable();
199
+ this.all = all;
200
+ return this;
201
+ }
202
+
203
+ /** `--keys`: the key names instead of values */
204
+ setShowKeys(keys: boolean): this {
205
+ this.checkCallable();
206
+ this.showKeys = keys;
207
+ return this;
208
+ }
209
+
210
+ /** The keys asked for, in order (repeats allowed). */
211
+ addKeys(...keys: string[]): this {
212
+ this.checkCallable();
213
+ this.keys.push(...keys);
214
+ return this;
215
+ }
216
+
217
+ /** The git version whose keys are known (default 2.57: git master). */
218
+ setCompatibility(compatibility: RepoCompatibility): this {
219
+ this.checkCallable();
220
+ this.compatibility = compatibility;
221
+ return this;
222
+ }
223
+
224
+ /** The directory git runs from, below the worktree top (`path.prefix`, relative paths). */
225
+ setCurrentDirectory(path: string): this {
226
+ this.checkCallable();
227
+ this.currentDirectory = path.replace(/^\/+|\/+$/g, "");
228
+ return this;
229
+ }
230
+
231
+ protected async run(): Promise<number> {
232
+ const format = parseFormat(this.format.replace(/^!/, ""));
233
+ const fields = infoFields(this.compatibility);
234
+ const keysAsked = this.keys.length > 0;
235
+ if (this.showKeys && (this.all || keysAsked))
236
+ throw new PlumbingError("fatal: --keys cannot be used with a <key> or --all");
237
+ if (this.showKeys) {
238
+ if (format === "table")
239
+ throw new PlumbingError(
240
+ "fatal: --keys can only be used with --format=lines or --format=nul",
241
+ );
242
+ const sep = format === "nul" ? "\0" : "\n";
243
+ await this.write(fields.map(([key]) => `${key}${sep}`).join(""));
244
+ return 0;
245
+ }
246
+ if (format === "table") throw new PlumbingError("fatal: unsupported output format");
247
+ if (this.all && keysAsked)
248
+ throw new PlumbingError("fatal: --all and <key> cannot be used together");
249
+ const facts = await this.facts();
250
+ const table = new Map(fields);
251
+ const print = async (key: string, value: string) => {
252
+ if (format === "lines") await this.write(`${key}=${quotePath(value)}\n`);
253
+ else await this.write(`${key}\n${value}\0`);
254
+ };
255
+ if (this.all) {
256
+ for (const [key, field] of fields) await print(key, field(facts));
257
+ return 0;
258
+ }
259
+ let status = 0;
260
+ for (const key of this.keys) {
261
+ const field = table.get(key);
262
+ if (!field) {
263
+ this.warn(`error: key '${key}' not found`);
264
+ status = 255;
265
+ continue;
266
+ }
267
+ await print(key, field(facts));
268
+ }
269
+ return status;
270
+ }
271
+
272
+ private async facts(): Promise<RepoFacts> {
273
+ const history = this.workingCopy.history;
274
+ const layout = await hookHostOf(this.workingCopy).layout();
275
+ const environment = hostEnvironmentOf(this.workingCopy);
276
+ const real = async (path: string | undefined) =>
277
+ path === undefined
278
+ ? undefined
279
+ : ((await environment?.realPath?.(path).catch(() => undefined)) ?? path);
280
+ const shallow = (await history.refs.getShallow?.()) ?? [];
281
+ const format = layout
282
+ ? await readRepositoryFormat(layout.files, layout.gitDir).catch(() => undefined)
283
+ : undefined;
284
+ const refStorage = format?.refStorage ?? "files";
285
+ const facts: RepoFacts = {
286
+ bare: layout?.bare ?? false,
287
+ shallow: shallow.length > 0,
288
+ objectFormat: this.objectFormat.name,
289
+ refStorage,
290
+ prefix: this.currentDirectory ? `${this.currentDirectory}/` : "",
291
+ };
292
+ if (!layout) return facts;
293
+ const files = layout.files;
294
+ // a gitfile's target (a submodule, a linked worktree) may lie outside the FilesApi
295
+ facts.gitDir = await real(
296
+ layout.gitDirEnv?.startsWith("/") ? layout.gitDirEnv : hostPathOf(files, layout.gitDir),
297
+ );
298
+ // repo_get_common_dir: $GIT_COMMON_DIR, else the git directory's `commondir` file
299
+ // (a linked worktree's), else the git directory itself
300
+ const commondirFile = facts.gitDir
301
+ ? await environment?.readFile(`${facts.gitDir}/commondir`).catch(() => undefined)
302
+ : undefined;
303
+ const named = commondirFile ? new TextDecoder().decode(commondirFile).trim() : undefined;
304
+ facts.commonDir = environment?.commonDir
305
+ ? await real(environment.commonDir)
306
+ : named
307
+ ? await real(named.startsWith("/") ? named : `${facts.gitDir}/${named}`)
308
+ : facts.gitDir;
309
+ const indexFile = environment?.indexFile;
310
+ facts.index =
311
+ indexFile === undefined
312
+ ? facts.gitDir
313
+ ? `${facts.gitDir}/index`
314
+ : undefined
315
+ : indexFile.startsWith("/")
316
+ ? indexFile
317
+ : // relative to the directory git was started in
318
+ await real(
319
+ `${hostPathOf(files, layout.bare ? layout.gitDir : layout.top) ?? ""}/${facts.prefix}${indexFile}`,
320
+ );
321
+ if (!layout.bare) {
322
+ facts.workTree = await real(hostPathOf(files, layout.top));
323
+ facts.superproject = await this.superprojectOf(facts.gitDir, facts.workTree);
324
+ }
325
+ return facts;
326
+ }
327
+
328
+ /** get_superproject_working_tree, for a git directory under `<super>/.git/modules/`. */
329
+ private async superprojectOf(
330
+ gitDir: string | undefined,
331
+ workTree: string | undefined,
332
+ ): Promise<string | undefined> {
333
+ if (!gitDir || !workTree) return undefined;
334
+ const at = gitDir.lastIndexOf("/.git/modules/");
335
+ if (at < 0) return undefined;
336
+ const superTop = gitDir.slice(0, at);
337
+ if (!workTree.startsWith(`${superTop}/`)) return undefined;
338
+ // the superproject's worktree must hold this one (git asks its index for the gitlink)
339
+ const environment = hostEnvironmentOf(this.workingCopy);
340
+ if (environment?.statFile) {
341
+ const s = await environment.statFile(`${superTop}/.git`).catch(() => undefined);
342
+ if (!s) return undefined;
343
+ }
344
+ return superTop;
345
+ }
346
+ }
347
+
348
+ /** Counts and sizes `repo structure` prints of each object type. */
349
+ interface ObjectValues {
350
+ commits: number;
351
+ trees: number;
352
+ blobs: number;
353
+ tags: number;
354
+ }
355
+
356
+ interface Largest {
357
+ id: ObjectId | undefined;
358
+ value: number;
359
+ }
360
+
361
+ /** What `git repo structure` counted. */
362
+ export interface RepoStructure {
363
+ references: { branches: number; tags: number; remotes: number; others: number };
364
+ counts: ObjectValues;
365
+ inflatedSizes: ObjectValues;
366
+ diskSizes: ObjectValues;
367
+ largest: {
368
+ commitSize: Largest;
369
+ treeSize: Largest;
370
+ blobSize: Largest;
371
+ tagSize: Largest;
372
+ parentCount: Largest;
373
+ treeEntries: Largest;
374
+ };
375
+ }
376
+
377
+ const emptyValues = (): ObjectValues => ({ commits: 0, trees: 0, blobs: 0, tags: 0 });
378
+ const total = (v: ObjectValues) => v.commits + v.trees + v.blobs + v.tags;
379
+
380
+ /** strbuf.c's humanise_count. */
381
+ export function humaniseCount(count: number): { value: string; unit?: string } {
382
+ const frac = (x: number, d: number) => String(Math.floor(x / d) % 100).padStart(2, "0");
383
+ if (count >= 1e9) {
384
+ const x = count + 5000000;
385
+ return { value: `${Math.floor(x / 1e9)}.${frac(x % 1e9, 1e7)}`, unit: "G" };
386
+ }
387
+ if (count >= 1e6) {
388
+ const x = count + 5000;
389
+ return { value: `${Math.floor(x / 1e6)}.${frac(x % 1e6, 1e4)}`, unit: "M" };
390
+ }
391
+ if (count >= 1000) {
392
+ const x = count + 5;
393
+ return { value: `${Math.floor(x / 1000)}.${frac(x % 1000, 10)}`, unit: "k" };
394
+ }
395
+ return { value: String(count) };
396
+ }
397
+
398
+ /** strbuf.c's humanise_bytes with HUMANISE_COMPACT. */
399
+ export function humaniseBytesCompact(bytes: number): { value: string; unit: string } {
400
+ const pad = (n: number) => String(n).padStart(2, "0");
401
+ if (bytes > 2 ** 30) {
402
+ const low = bytes % 2 ** 30;
403
+ return {
404
+ value: `${Math.floor(bytes / 2 ** 30)}.${pad(Math.floor(low / 10737419) >>> 0)}`,
405
+ unit: "GiB",
406
+ };
407
+ }
408
+ if (bytes > 2 ** 20) {
409
+ const x = (bytes + 5243) >>> 0;
410
+ return {
411
+ value: `${x >>> 20}.${pad(Math.floor(((x & 0xfffff) * 100) / 2 ** 20))}`,
412
+ unit: "MiB",
413
+ };
414
+ }
415
+ if (bytes > 2 ** 10) {
416
+ const x = (bytes + 5) >>> 0;
417
+ return { value: `${x >>> 10}.${pad(Math.floor(((x & 0x3ff) * 100) / 1024))}`, unit: "KiB" };
418
+ }
419
+ return { value: String(bytes), unit: "B" };
420
+ }
421
+
422
+ /** git's utf8_strwidth for the table's (ASCII) cells. */
423
+ const width = (text: string) => text.length;
424
+
425
+ /** path-walk.c's compare_by_type: tags first, then blobs, then trees; else by path. */
426
+ const TYPE_RANK: Record<string, number> = { tag: 0, blob: 1, tree: 2, commit: 3 };
427
+
428
+ /** A binary heap ordered by `compare` (git's prio_queue without ties). */
429
+ class Heap<T> {
430
+ private items: T[] = [];
431
+ constructor(private readonly compare: (a: T, b: T) => number) {}
432
+ get size(): number {
433
+ return this.items.length;
434
+ }
435
+ push(item: T): void {
436
+ const a = this.items;
437
+ a.push(item);
438
+ let i = a.length - 1;
439
+ while (i > 0) {
440
+ const p = (i - 1) >> 1;
441
+ if (this.compare(a[p] as T, a[i] as T) <= 0) break;
442
+ [a[p], a[i]] = [a[i] as T, a[p] as T];
443
+ i = p;
444
+ }
445
+ }
446
+ pop(): T | undefined {
447
+ const a = this.items;
448
+ if (a.length === 0) return undefined;
449
+ const top = a[0];
450
+ const last = a.pop() as T;
451
+ if (a.length > 0) {
452
+ a[0] = last;
453
+ let i = 0;
454
+ for (;;) {
455
+ const l = 2 * i + 1;
456
+ const r = l + 1;
457
+ let m = i;
458
+ if (l < a.length && this.compare(a[l] as T, a[m] as T) < 0) m = l;
459
+ if (r < a.length && this.compare(a[r] as T, a[m] as T) < 0) m = r;
460
+ if (m === i) break;
461
+ [a[m], a[i]] = [a[i] as T, a[m] as T];
462
+ i = m;
463
+ }
464
+ }
465
+ return top;
466
+ }
467
+ }
468
+
469
+ /** Reads an object whole: its type and bytes, undefined when missing. */
470
+ async function readWhole(
471
+ objects: {
472
+ get(
473
+ id: ObjectId,
474
+ ): Promise<{ type: ObjectTypeString; content: AsyncIterable<Uint8Array> } | undefined>;
475
+ },
476
+ id: ObjectId,
477
+ ): Promise<{ type: ObjectTypeString; bytes: Uint8Array } | undefined> {
478
+ let object: Awaited<ReturnType<typeof objects.get>>;
479
+ try {
480
+ object = await objects.get(id);
481
+ } catch {
482
+ return undefined;
483
+ }
484
+ if (!object) return undefined;
485
+ const chunks: Uint8Array[] = [];
486
+ let length = 0;
487
+ for await (const c of object.content) {
488
+ chunks.push(c);
489
+ length += c.length;
490
+ }
491
+ if (chunks.length === 1) return { type: object.type, bytes: chunks[0] as Uint8Array };
492
+ const bytes = new Uint8Array(length);
493
+ let at = 0;
494
+ for (const c of chunks) {
495
+ bytes.set(c, at);
496
+ at += c.length;
497
+ }
498
+ return { type: object.type, bytes };
499
+ }
500
+
501
+ /** The pack-relevant part of a `PackFile`. */
502
+ interface OffsetPack extends Pack {
503
+ indexOf?(id: ObjectId): number;
504
+ offsetAt?(i: number): number;
505
+ packOrder?(): Uint32Array;
506
+ }
507
+
508
+ /**
509
+ * `git repo structure [--format=(table|lines|nul) | -z] [--[no-]progress]`: the references
510
+ * by kind and the objects reachable from them (path-walk.c's walk over every ref, as git
511
+ * walks it, so ties of the largest objects go to the object git meets first), with their
512
+ * inflated and on-disk sizes (a packed object's entry, a loose object's file; an object only
513
+ * an alternate holds counts 0 bytes on disk).
514
+ */
515
+ export class RepoStructureCommand extends PlumbingCommand {
516
+ private format = "table";
517
+ private showProgress = false;
518
+ private counted?: RepoStructure;
519
+
520
+ /** `--format=<format>` (`table`, `lines`, `nul`) */
521
+ setFormat(format: string): this {
522
+ this.checkCallable();
523
+ // git dies as it parses the option: a later valid one does not save it
524
+ this.format = this.format.startsWith("!") ? this.format : format;
525
+ if (!["nul", "lines", "table"].includes(format)) this.format = `!${format}`;
526
+ return this;
527
+ }
528
+
529
+ /** `-z`: `--format=nul` */
530
+ setNul(): this {
531
+ return this.setFormat("nul");
532
+ }
533
+
534
+ /** `--progress`: the final progress lines on stderr (git's default: on a terminal only) */
535
+ setShowProgress(progress: boolean): this {
536
+ this.checkCallable();
537
+ this.showProgress = progress;
538
+ return this;
539
+ }
540
+
541
+ /** What the last run counted. */
542
+ getStructure(): RepoStructure | undefined {
543
+ return this.counted;
544
+ }
545
+
546
+ protected async run(): Promise<number> {
547
+ const format = parseFormat(this.format.replace(/^!/, ""));
548
+ const s: RepoStructure = {
549
+ references: { branches: 0, tags: 0, remotes: 0, others: 0 },
550
+ counts: emptyValues(),
551
+ inflatedSizes: emptyValues(),
552
+ diskSizes: emptyValues(),
553
+ largest: {
554
+ commitSize: { id: undefined, value: 0 },
555
+ treeSize: { id: undefined, value: 0 },
556
+ blobSize: { id: undefined, value: 0 },
557
+ tagSize: { id: undefined, value: 0 },
558
+ parentCount: { id: undefined, value: 0 },
559
+ treeEntries: { id: undefined, value: 0 },
560
+ },
561
+ };
562
+ const pending = await this.countReferences(s);
563
+ if (this.showProgress) {
564
+ const r = s.references;
565
+ this.warn(`Counting references: ${r.branches + r.tags + r.remotes + r.others}, done.`);
566
+ }
567
+ await this.countObjects(s, pending);
568
+ if (this.showProgress) this.warn(`Counting objects: ${total(s.counts)}, done.`);
569
+ this.counted = s;
570
+ if (format === "table") await this.write(this.table(s));
571
+ else if (format === "lines") await this.write(this.keyValues(s, "=", "\n"));
572
+ else await this.write(this.keyValues(s, "\n", "\0"));
573
+ return 0;
574
+ }
575
+
576
+ /** count_references: every ref under refs/ (symbolic ones resolved), in name order. */
577
+ private async countReferences(s: RepoStructure): Promise<ObjectId[]> {
578
+ const refs = this.workingCopy.history.refs;
579
+ const names: string[] = [];
580
+ for await (const ref of refs.list("refs/")) names.push(ref.name);
581
+ names.sort(compareGitPaths);
582
+ const pending: ObjectId[] = [];
583
+ for (const name of names) {
584
+ const resolved = await refs.resolve(name).catch(() => undefined);
585
+ const id = resolved?.objectId;
586
+ if (!id) continue;
587
+ if (name.startsWith("refs/heads/")) s.references.branches++;
588
+ else if (name.startsWith("refs/remotes/")) s.references.remotes++;
589
+ else if (name.startsWith("refs/tags/")) s.references.tags++;
590
+ else s.references.others++;
591
+ pending.push(id);
592
+ }
593
+ return pending;
594
+ }
595
+
596
+ /** structure_count_objects: path-walk.c's walk_objects_by_path from the refs. */
597
+ private async countObjects(s: RepoStructure, pending: ObjectId[]): Promise<void> {
598
+ const history = this.workingCopy.history;
599
+ const objects = history.objects;
600
+ if (!objects) throw new PlumbingError("fatal: repo structure needs an object store");
601
+ const types = new Map<ObjectId, ObjectTypeString>();
602
+ const typeOf = async (id: ObjectId): Promise<ObjectTypeString | undefined> => {
603
+ let t = types.get(id);
604
+ if (t) return t;
605
+ try {
606
+ t = (await objects.header?.(id))?.type ?? (await objects.get(id))?.type;
607
+ } catch {
608
+ t = undefined;
609
+ }
610
+ if (t) types.set(id, t);
611
+ return t;
612
+ };
613
+ const seen = new Set<ObjectId>();
614
+ const lists = new Map<string, { type: ObjectTypeString; ids: ObjectId[] }>();
615
+ const pushed = new Set<string>();
616
+ const heap = new Heap<string>((a, b) => {
617
+ const la = lists.get(a);
618
+ const lb = lists.get(b);
619
+ if (!la || !lb || la.type === lb.type) return compareGitPaths(a, b);
620
+ return (TYPE_RANK[la.type] ?? 9) - (TYPE_RANK[lb.type] ?? 9);
621
+ });
622
+ const push = (path: string) => {
623
+ if (pushed.has(path)) return;
624
+ pushed.add(path);
625
+ heap.push(path);
626
+ };
627
+ const addToList = (path: string, type: ObjectTypeString, id: ObjectId) => {
628
+ let list = lists.get(path);
629
+ if (!list) {
630
+ list = { type, ids: [] };
631
+ lists.set(path, list);
632
+ }
633
+ list.ids.push(id);
634
+ };
635
+ lists.set("", { type: "tree", ids: [] });
636
+ push("");
637
+
638
+ // setup_pending_objects (after prepare_revision_walk): tags, tagged trees and blobs
639
+ const starts: ObjectId[] = [];
640
+ const tags: ObjectId[] = [];
641
+ const taggedTrees: ObjectId[] = [];
642
+ const taggedBlobs: ObjectId[] = [];
643
+ for (const tip of pending) {
644
+ let id: ObjectId | undefined = tip;
645
+ let type = await typeOf(id);
646
+ let stopped = false;
647
+ while (type === "tag" && id) {
648
+ if (seen.has(id)) {
649
+ stopped = true;
650
+ break;
651
+ }
652
+ seen.add(id);
653
+ tags.push(id);
654
+ const tag = await readWhole(objects, id);
655
+ id = tag
656
+ ? /^object ([0-9a-f]+)/.exec(new TextDecoder().decode(tag.bytes.subarray(0, 200)))?.[1]
657
+ : undefined;
658
+ type = id ? await typeOf(id) : undefined;
659
+ }
660
+ if (stopped || !id || !type) continue;
661
+ if (type === "commit") {
662
+ starts.push(id);
663
+ continue;
664
+ }
665
+ if (seen.has(id)) continue;
666
+ seen.add(id);
667
+ if (type === "tree") taggedTrees.push(id);
668
+ else if (type === "blob") taggedBlobs.push(id);
669
+ }
670
+ for (const [path, type, ids] of [
671
+ ["/tagged-blobs", "blob", taggedBlobs],
672
+ ["/tagged-trees", "tree", taggedTrees],
673
+ ["/tags", "tag", tags],
674
+ ] as const) {
675
+ if (ids.length === 0) continue;
676
+ lists.set(path, { type, ids: [...ids] });
677
+ push(path);
678
+ }
679
+
680
+ // the commit walk: commits in walk order, each new root tree
681
+ const commits: ObjectId[] = [];
682
+ const roots = lists.get("") as { ids: ObjectId[] };
683
+ if (starts.length > 0) {
684
+ const walk = new RevListCommand(this.workingCopy);
685
+ for (const id of starts) walk.addRevision(id);
686
+ for await (const c of await walk.call()) {
687
+ commits.push(c.id);
688
+ if (seen.has(c.tree)) continue;
689
+ seen.add(c.tree);
690
+ roots.ids.push(c.tree);
691
+ }
692
+ }
693
+
694
+ const disk = await this.diskSizer();
695
+ const check = (largest: Largest, id: ObjectId, value: number) => {
696
+ if (value > largest.value || largest.id === undefined) {
697
+ largest.id = id;
698
+ largest.value = value;
699
+ }
700
+ };
701
+ const idLength = this.objectFormat.rawLength;
702
+ const count = async (type: ObjectTypeString, ids: ObjectId[]) => {
703
+ for (const id of ids) {
704
+ if (type === "blob") {
705
+ let size: number | undefined;
706
+ try {
707
+ size = (await objects.header?.(id))?.size;
708
+ if (size === undefined) size = (await readWhole(objects, id))?.bytes.length;
709
+ } catch {
710
+ size = undefined;
711
+ }
712
+ if (size === undefined) continue;
713
+ s.counts.blobs++;
714
+ s.inflatedSizes.blobs += size;
715
+ s.diskSizes.blobs += await disk(id);
716
+ check(s.largest.blobSize, id, size);
717
+ continue;
718
+ }
719
+ const object = await readWhole(objects, id);
720
+ if (!object) continue;
721
+ const size = object.bytes.length;
722
+ if (type === "tag") {
723
+ s.counts.tags++;
724
+ s.inflatedSizes.tags += size;
725
+ s.diskSizes.tags += await disk(id);
726
+ check(s.largest.tagSize, id, size);
727
+ } else if (type === "commit") {
728
+ s.counts.commits++;
729
+ s.inflatedSizes.commits += size;
730
+ s.diskSizes.commits += await disk(id);
731
+ check(s.largest.commitSize, id, size);
732
+ check(s.largest.parentCount, id, parentCount(object.bytes));
733
+ } else if (type === "tree") {
734
+ s.counts.trees++;
735
+ s.inflatedSizes.trees += size;
736
+ s.diskSizes.trees += await disk(id);
737
+ check(s.largest.treeSize, id, size);
738
+ check(
739
+ s.largest.treeEntries,
740
+ id,
741
+ decodeTreeBytes(object.bytes, { idLength, checkNames: false }).length,
742
+ );
743
+ }
744
+ }
745
+ };
746
+ if (commits.length > 0) await count("commit", commits);
747
+
748
+ for (let path = heap.pop(); path !== undefined; path = heap.pop()) {
749
+ const list = lists.get(path);
750
+ pushed.delete(path);
751
+ if (!list || list.ids.length === 0) continue;
752
+ await count(list.type, list.ids);
753
+ if (list.type === "tree") {
754
+ const base = path === "/tagged-trees" ? "" : path;
755
+ for (const treeId of list.ids) {
756
+ const tree = await readWhole(objects, treeId);
757
+ if (!tree) {
758
+ this.warn(`error: bad tree object ${treeId}`);
759
+ return;
760
+ }
761
+ for (const entry of decodeTreeBytes(tree.bytes, { idLength, checkNames: false })) {
762
+ if (entry.mode === 0o160000) continue;
763
+ const isTree = (entry.mode & 0o170000) === 0o040000;
764
+ const child = `${base}${entry.name}${isTree ? "/" : ""}`;
765
+ if (seen.has(entry.id)) continue;
766
+ seen.add(entry.id);
767
+ addToList(child, isTree ? "tree" : "blob", entry.id);
768
+ push(child);
769
+ }
770
+ }
771
+ }
772
+ lists.delete(path);
773
+ }
774
+ }
775
+
776
+ /**
777
+ * The bytes an object takes on disk, as odb_read_object_info_extended's `disk_sizep`: its
778
+ * pack entry (to the next entry by offset, or the trailer), else its loose file.
779
+ */
780
+ private async diskSizer(): Promise<(id: ObjectId) => Promise<number>> {
781
+ const objectsFile = await this.hooks.commonGitFile("objects");
782
+ const packSet = this.workingCopy.history.packs;
783
+ const packs = ((await packSet?.packs().catch(() => [])) ?? []) as OffsetPack[];
784
+ const hashLength = this.objectFormat.rawLength;
785
+ const sorted = new Map<OffsetPack, Float64Array>();
786
+ const packSizes = new Map<OffsetPack, number>();
787
+ const offsetsOf = (pack: OffsetPack): Float64Array => {
788
+ let offsets = sorted.get(pack);
789
+ if (!offsets) {
790
+ offsets = new Float64Array(pack.count);
791
+ for (let i = 0; i < pack.count; i++) offsets[i] = pack.offsetAt?.(i) ?? 0;
792
+ offsets.sort();
793
+ sorted.set(pack, offsets);
794
+ }
795
+ return offsets;
796
+ };
797
+ const packSizeOf = async (pack: OffsetPack): Promise<number> => {
798
+ let size = packSizes.get(pack);
799
+ if (size === undefined) {
800
+ size = 0;
801
+ if (objectsFile) {
802
+ const path = joinPath(objectsFile.path, "pack", `${packNameOf(pack)}.pack`);
803
+ size = (await objectsFile.files.stats(path))?.size ?? 0;
804
+ }
805
+ packSizes.set(pack, size);
806
+ }
807
+ return size;
808
+ };
809
+ return async (id) => {
810
+ for (const pack of packs) {
811
+ if (!pack.has(id) || !pack.indexOf || !pack.offsetAt) continue;
812
+ const index = pack.indexOf(id);
813
+ if (index < 0) continue;
814
+ const offset = pack.offsetAt(index);
815
+ const offsets = offsetsOf(pack);
816
+ let lo = 0;
817
+ let hi = offsets.length;
818
+ while (lo < hi) {
819
+ const mid = (lo + hi) >> 1;
820
+ if ((offsets[mid] as number) <= offset) lo = mid + 1;
821
+ else hi = mid;
822
+ }
823
+ const next =
824
+ lo < offsets.length ? (offsets[lo] as number) : (await packSizeOf(pack)) - hashLength;
825
+ return next - offset;
826
+ }
827
+ if (!objectsFile) return 0;
828
+ const path = joinPath(objectsFile.path, id.slice(0, 2), id.slice(2));
829
+ return (await objectsFile.files.stats(path).catch(() => undefined))?.size ?? 0;
830
+ };
831
+ }
832
+
833
+ /** stats_table_setup_structure + stats_table_print_structure. */
834
+ private table(s: RepoStructure): string {
835
+ type Entry = { value: string; unit?: string; index?: number };
836
+ const rows: { name: string; entry?: Entry }[] = [];
837
+ const annotations: string[] = [];
838
+ let nameWidth = 0;
839
+ let valueWidth = 0;
840
+ let unitWidth = 0;
841
+ const add = (name: string, entry?: Entry, id?: ObjectId) => {
842
+ rows.push({ name, entry });
843
+ nameWidth = Math.max(nameWidth, width(name));
844
+ if (!entry) return;
845
+ if (id) {
846
+ entry.index = annotations.length + 1;
847
+ annotations.push(`[${entry.index}] ${id}`);
848
+ }
849
+ valueWidth = Math.max(valueWidth, width(entry.value));
850
+ if (entry.unit) unitWidth = Math.max(unitWidth, width(entry.unit));
851
+ };
852
+ const countRow = (name: string, n: number, id?: ObjectId) => add(name, humaniseCount(n), id);
853
+ const sizeRow = (name: string, n: number, id?: ObjectId) =>
854
+ add(name, humaniseBytesCompact(n), id);
855
+ const r = s.references;
856
+ add("* References");
857
+ countRow(" * Count", r.branches + r.tags + r.remotes + r.others);
858
+ countRow(" * Branches", r.branches);
859
+ countRow(" * Tags", r.tags);
860
+ countRow(" * Remotes", r.remotes);
861
+ countRow(" * Others", r.others);
862
+ const byType = (values: ObjectValues, row: (name: string, n: number) => void) => {
863
+ row(" * Commits", values.commits);
864
+ row(" * Trees", values.trees);
865
+ row(" * Blobs", values.blobs);
866
+ row(" * Tags", values.tags);
867
+ };
868
+ add("");
869
+ add("* Reachable objects");
870
+ countRow(" * Count", total(s.counts));
871
+ byType(s.counts, countRow);
872
+ sizeRow(" * Inflated size", total(s.inflatedSizes));
873
+ byType(s.inflatedSizes, sizeRow);
874
+ sizeRow(" * Disk size", total(s.diskSizes));
875
+ byType(s.diskSizes, sizeRow);
876
+ const l = s.largest;
877
+ add("");
878
+ add("* Largest objects");
879
+ add(" * Commits");
880
+ sizeRow(" * Maximum size", l.commitSize.value, l.commitSize.id);
881
+ countRow(" * Maximum parents", l.parentCount.value, l.parentCount.id);
882
+ add(" * Trees");
883
+ sizeRow(" * Maximum size", l.treeSize.value, l.treeSize.id);
884
+ countRow(" * Maximum entries", l.treeEntries.value, l.treeEntries.id);
885
+ add(" * Blobs");
886
+ sizeRow(" * Maximum size", l.blobSize.value, l.blobSize.id);
887
+ add(" * Tags");
888
+ sizeRow(" * Maximum size", l.tagSize.value, l.tagSize.id);
889
+
890
+ const nameTitle = "Repository structure";
891
+ const valueTitle = "Value";
892
+ nameWidth = Math.max(nameWidth, width(nameTitle));
893
+ if (width(valueTitle) > valueWidth + unitWidth + 1) valueWidth = width(valueTitle) - unitWidth;
894
+ const INDEX_WIDTH = 4;
895
+ const left = (text: string, w: number) => text.padEnd(w);
896
+ const right = (text: string, w: number) => text.padStart(w);
897
+ const valueCol = valueWidth + unitWidth + 1;
898
+ let out = `| ${left(nameTitle, nameWidth + INDEX_WIDTH)} | ${left(valueTitle, valueCol)} |\n`;
899
+ out += `| ${"-".repeat(nameWidth + INDEX_WIDTH)} | ${"-".repeat(valueCol)} |\n`;
900
+ for (const { name, entry } of rows) {
901
+ out += `| ${left(name, nameWidth)}`;
902
+ out += entry?.index !== undefined ? ` [${entry.index}]` : " ".repeat(INDEX_WIDTH);
903
+ out += ` | ${right(entry?.value ?? "", valueWidth)} ${left(entry?.unit ?? "", unitWidth)} |\n`;
904
+ }
905
+ if (annotations.length > 0) out += `\n${annotations.map((a) => `${a}\n`).join("")}`;
906
+ return out;
907
+ }
908
+
909
+ /** structure_keyvalue_print. */
910
+ private keyValues(s: RepoStructure, keyDelim: string, valueDelim: string): string {
911
+ const nullId = this.objectFormat.nullId;
912
+ let out = "";
913
+ const kv = (key: string, value: number) => {
914
+ out += `${key}${keyDelim}${value}${valueDelim}`;
915
+ };
916
+ const data = (key: string, largest: Largest) => {
917
+ kv(key, largest.value);
918
+ out += `${key}_oid${keyDelim}${largest.id ?? nullId}${valueDelim}`;
919
+ };
920
+ const r = s.references;
921
+ kv("references.branches.count", r.branches);
922
+ kv("references.tags.count", r.tags);
923
+ kv("references.remotes.count", r.remotes);
924
+ kv("references.others.count", r.others);
925
+ for (const [suffix, values] of [
926
+ ["count", s.counts],
927
+ ["inflated_size", s.inflatedSizes],
928
+ ["disk_size", s.diskSizes],
929
+ ] as const) {
930
+ kv(`objects.commits.${suffix}`, values.commits);
931
+ kv(`objects.trees.${suffix}`, values.trees);
932
+ kv(`objects.blobs.${suffix}`, values.blobs);
933
+ kv(`objects.tags.${suffix}`, values.tags);
934
+ }
935
+ const l = s.largest;
936
+ data("objects.commits.max_size", l.commitSize);
937
+ data("objects.trees.max_size", l.treeSize);
938
+ data("objects.blobs.max_size", l.blobSize);
939
+ data("objects.tags.max_size", l.tagSize);
940
+ data("objects.commits.max_parents", l.parentCount);
941
+ data("objects.trees.max_entries", l.treeEntries);
942
+ return out;
943
+ }
944
+ }
945
+
946
+ /** The `parent` lines of a commit's header. */
947
+ function parentCount(bytes: Uint8Array): number {
948
+ const end = bytes.indexOf(0x0a, 0);
949
+ let n = 0;
950
+ let at = end + 1;
951
+ while (at > 0 && at < bytes.length) {
952
+ const next = bytes.indexOf(0x0a, at);
953
+ if (next === at) break;
954
+ // "parent "
955
+ if (
956
+ bytes[at] === 0x70 &&
957
+ bytes[at + 1] === 0x61 &&
958
+ bytes[at + 2] === 0x72 &&
959
+ bytes[at + 6] === 0x20
960
+ )
961
+ n++;
962
+ else if (n > 0) break;
963
+ if (next < 0) break;
964
+ at = next + 1;
965
+ }
966
+ return n;
967
+ }