@statewalker/vcs-commands 0.9.0 → 0.11.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 (468) 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 +144 -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 +28 -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 +54 -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 +60 -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-ipc.d.ts +30 -0
  109. package/dist/commands/fsmonitor-ipc.d.ts.map +1 -0
  110. package/dist/commands/fsmonitor-refresh.d.ts +69 -0
  111. package/dist/commands/fsmonitor-refresh.d.ts.map +1 -0
  112. package/dist/commands/gc-command.d.ts +5 -0
  113. package/dist/commands/gc-command.d.ts.map +1 -1
  114. package/dist/commands/git-hooks.d.ts +32 -0
  115. package/dist/commands/git-hooks.d.ts.map +1 -1
  116. package/dist/commands/git-paths.d.ts +26 -0
  117. package/dist/commands/git-paths.d.ts.map +1 -0
  118. package/dist/commands/grep/grep-command.d.ts +2 -1
  119. package/dist/commands/grep/grep-command.d.ts.map +1 -1
  120. package/dist/commands/history-command.d.ts +156 -0
  121. package/dist/commands/history-command.d.ts.map +1 -0
  122. package/dist/commands/http-config.d.ts +38 -0
  123. package/dist/commands/http-config.d.ts.map +1 -0
  124. package/dist/commands/index-adder.d.ts +12 -1
  125. package/dist/commands/index-adder.d.ts.map +1 -1
  126. package/dist/commands/index-host.d.ts.map +1 -1
  127. package/dist/commands/index.d.ts +45 -1
  128. package/dist/commands/index.d.ts.map +1 -1
  129. package/dist/commands/index.js +6 -5
  130. package/dist/commands/init-command.d.ts.map +1 -1
  131. package/dist/commands/last-modified-command.d.ts +102 -0
  132. package/dist/commands/last-modified-command.d.ts.map +1 -0
  133. package/dist/commands/lfs/go-url.d.ts +43 -0
  134. package/dist/commands/lfs/go-url.d.ts.map +1 -0
  135. package/dist/commands/lfs/index.d.ts +3 -0
  136. package/dist/commands/lfs/index.d.ts.map +1 -0
  137. package/dist/commands/lfs/lfs-config.d.ts +174 -0
  138. package/dist/commands/lfs/lfs-config.d.ts.map +1 -0
  139. package/dist/commands/lfs/lfs-endpoint-command.d.ts +83 -0
  140. package/dist/commands/lfs/lfs-endpoint-command.d.ts.map +1 -0
  141. package/dist/commands/local-transport.d.ts.map +1 -1
  142. package/dist/commands/log-command.d.ts +26 -0
  143. package/dist/commands/log-command.d.ts.map +1 -1
  144. package/dist/commands/log-output.d.ts +28 -1
  145. package/dist/commands/log-output.d.ts.map +1 -1
  146. package/dist/commands/ls-files-command.d.ts +153 -0
  147. package/dist/commands/ls-files-command.d.ts.map +1 -0
  148. package/dist/commands/ls-remote-command.d.ts +5 -0
  149. package/dist/commands/ls-remote-command.d.ts.map +1 -1
  150. package/dist/commands/ls-tree-command.d.ts +105 -0
  151. package/dist/commands/ls-tree-command.d.ts.map +1 -0
  152. package/dist/commands/maintenance-run-command.d.ts +122 -0
  153. package/dist/commands/maintenance-run-command.d.ts.map +1 -0
  154. package/dist/commands/merge-command.d.ts +7 -0
  155. package/dist/commands/merge-command.d.ts.map +1 -1
  156. package/dist/commands/merge-config.d.ts +7 -0
  157. package/dist/commands/merge-config.d.ts.map +1 -1
  158. package/dist/commands/merge-drivers.d.ts +67 -5
  159. package/dist/commands/merge-drivers.d.ts.map +1 -1
  160. package/dist/commands/merge-support.d.ts +6 -0
  161. package/dist/commands/merge-support.d.ts.map +1 -1
  162. package/dist/commands/merge-tree-command.d.ts +122 -0
  163. package/dist/commands/merge-tree-command.d.ts.map +1 -0
  164. package/dist/commands/mktag-command.d.ts +51 -0
  165. package/dist/commands/mktag-command.d.ts.map +1 -0
  166. package/dist/commands/object-store/count-objects-command.d.ts +58 -0
  167. package/dist/commands/object-store/count-objects-command.d.ts.map +1 -0
  168. package/dist/commands/object-store/index.d.ts +5 -0
  169. package/dist/commands/object-store/index.d.ts.map +1 -0
  170. package/dist/commands/object-store/objects-directory.d.ts +12 -0
  171. package/dist/commands/object-store/objects-directory.d.ts.map +1 -0
  172. package/dist/commands/object-store/prune-command.d.ts +38 -0
  173. package/dist/commands/object-store/prune-command.d.ts.map +1 -0
  174. package/dist/commands/object-store/show-index-command.d.ts +23 -0
  175. package/dist/commands/object-store/show-index-command.d.ts.map +1 -0
  176. package/dist/commands/ort-merge.d.ts +24 -0
  177. package/dist/commands/ort-merge.d.ts.map +1 -1
  178. package/dist/commands/patch-id-command.d.ts +30 -0
  179. package/dist/commands/patch-id-command.d.ts.map +1 -0
  180. package/dist/commands/patch-id.d.ts +24 -0
  181. package/dist/commands/patch-id.d.ts.map +1 -1
  182. package/dist/commands/plumbing-command.d.ts +66 -0
  183. package/dist/commands/plumbing-command.d.ts.map +1 -0
  184. package/dist/commands/plumbing-input.d.ts +38 -0
  185. package/dist/commands/plumbing-input.d.ts.map +1 -0
  186. package/dist/commands/promisor-remote-reply.d.ts +35 -0
  187. package/dist/commands/promisor-remote-reply.d.ts.map +1 -0
  188. package/dist/commands/promisor-remote.d.ts.map +1 -1
  189. package/dist/commands/pull-command.d.ts.map +1 -1
  190. package/dist/commands/push-command.d.ts +17 -2
  191. package/dist/commands/push-command.d.ts.map +1 -1
  192. package/dist/commands/rebase-command.d.ts +108 -2
  193. package/dist/commands/rebase-command.d.ts.map +1 -1
  194. package/dist/commands/refs-command.d.ts +81 -0
  195. package/dist/commands/refs-command.d.ts.map +1 -0
  196. package/dist/commands/remote-object-info-command.d.ts +55 -0
  197. package/dist/commands/remote-object-info-command.d.ts.map +1 -0
  198. package/dist/commands/remote-transport.d.ts +40 -3
  199. package/dist/commands/remote-transport.d.ts.map +1 -1
  200. package/dist/commands/repack-command.d.ts +115 -0
  201. package/dist/commands/repack-command.d.ts.map +1 -0
  202. package/dist/commands/replace-command.d.ts +143 -0
  203. package/dist/commands/replace-command.d.ts.map +1 -0
  204. package/dist/commands/replay-command.d.ts +117 -0
  205. package/dist/commands/replay-command.d.ts.map +1 -0
  206. package/dist/commands/repo-command.d.ts +158 -0
  207. package/dist/commands/repo-command.d.ts.map +1 -0
  208. package/dist/commands/request-pull-command.d.ts +82 -0
  209. package/dist/commands/request-pull-command.d.ts.map +1 -0
  210. package/dist/commands/rerere-command.d.ts +36 -0
  211. package/dist/commands/rerere-command.d.ts.map +1 -0
  212. package/dist/commands/rerere.d.ts +102 -0
  213. package/dist/commands/rerere.d.ts.map +1 -0
  214. package/dist/commands/reset-command.d.ts +19 -2
  215. package/dist/commands/reset-command.d.ts.map +1 -1
  216. package/dist/commands/rev-filter/commit-grep.d.ts +3 -1
  217. package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -1
  218. package/dist/commands/rev-list-command.d.ts +3 -0
  219. package/dist/commands/rev-list-command.d.ts.map +1 -1
  220. package/dist/commands/rev-parse-command.d.ts +5 -0
  221. package/dist/commands/rev-parse-command.d.ts.map +1 -1
  222. package/dist/commands/revert-command.d.ts +10 -0
  223. package/dist/commands/revert-command.d.ts.map +1 -1
  224. package/dist/commands/revision-range.d.ts +5 -0
  225. package/dist/commands/revision-range.d.ts.map +1 -1
  226. package/dist/commands/revision-resolver.d.ts +27 -1
  227. package/dist/commands/revision-resolver.d.ts.map +1 -1
  228. package/dist/commands/sequencer-pick.d.ts +18 -0
  229. package/dist/commands/sequencer-pick.d.ts.map +1 -1
  230. package/dist/commands/serve-repository.d.ts +23 -1
  231. package/dist/commands/serve-repository.d.ts.map +1 -1
  232. package/dist/commands/session-id.d.ts +18 -0
  233. package/dist/commands/session-id.d.ts.map +1 -0
  234. package/dist/commands/show-branch-command.d.ts +59 -0
  235. package/dist/commands/show-branch-command.d.ts.map +1 -0
  236. package/dist/commands/show-ref-command.d.ts +112 -0
  237. package/dist/commands/show-ref-command.d.ts.map +1 -0
  238. package/dist/commands/signature-check.d.ts +9 -2
  239. package/dist/commands/signature-check.d.ts.map +1 -1
  240. package/dist/commands/signing.d.ts +30 -2
  241. package/dist/commands/signing.d.ts.map +1 -1
  242. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  243. package/dist/commands/stash-export-command.d.ts +115 -0
  244. package/dist/commands/stash-export-command.d.ts.map +1 -0
  245. package/dist/commands/status-command.d.ts +16 -2
  246. package/dist/commands/status-command.d.ts.map +1 -1
  247. package/dist/commands/stripspace-command.d.ts +44 -0
  248. package/dist/commands/stripspace-command.d.ts.map +1 -0
  249. package/dist/commands/submodule-add-command.d.ts +22 -1
  250. package/dist/commands/submodule-add-command.d.ts.map +1 -1
  251. package/dist/commands/submodule-auth.d.ts +3 -1
  252. package/dist/commands/submodule-auth.d.ts.map +1 -1
  253. package/dist/commands/submodule-commands.d.ts +9 -1
  254. package/dist/commands/submodule-commands.d.ts.map +1 -1
  255. package/dist/commands/submodule-update-command.d.ts +27 -1
  256. package/dist/commands/submodule-update-command.d.ts.map +1 -1
  257. package/dist/commands/tag-command.d.ts.map +1 -1
  258. package/dist/commands/textconv-cache.d.ts +58 -0
  259. package/dist/commands/textconv-cache.d.ts.map +1 -0
  260. package/dist/commands/tree-restore.d.ts +5 -0
  261. package/dist/commands/tree-restore.d.ts.map +1 -1
  262. package/dist/commands/unpack-objects-command.d.ts +47 -0
  263. package/dist/commands/unpack-objects-command.d.ts.map +1 -0
  264. package/dist/commands/update-index-command.d.ts +131 -0
  265. package/dist/commands/update-index-command.d.ts.map +1 -0
  266. package/dist/commands/uri-protocols.d.ts +13 -0
  267. package/dist/commands/uri-protocols.d.ts.map +1 -0
  268. package/dist/commands/url-parse-command.d.ts +30 -0
  269. package/dist/commands/url-parse-command.d.ts.map +1 -0
  270. package/dist/commands/var-command.d.ts +42 -0
  271. package/dist/commands/var-command.d.ts.map +1 -0
  272. package/dist/{commands-CNvli5bl.js → commands-bQQ9OmCh.js} +52514 -44630
  273. package/dist/errors/command-errors.d.ts +33 -0
  274. package/dist/errors/command-errors.d.ts.map +1 -1
  275. package/dist/errors/index.js +39 -1
  276. package/dist/{fsck-CPeDh9fh.js → fsck-BHT9bUS-.js} +184 -143
  277. package/dist/git-command.d.ts +66 -4
  278. package/dist/git-command.d.ts.map +1 -1
  279. package/dist/git.d.ts +532 -1
  280. package/dist/git.d.ts.map +1 -1
  281. package/dist/guarded-transport-command.d.ts +3 -1
  282. package/dist/guarded-transport-command.d.ts.map +1 -1
  283. package/dist/index.js +7 -6
  284. package/dist/maintenance-run-command-Cx2PlGV9.js +13544 -0
  285. package/dist/{remote-transport-CCmBadm-.js → remote-transport-BrQZfyHu.js} +1009 -10
  286. package/dist/results/cherry-pick-result.d.ts +6 -0
  287. package/dist/results/cherry-pick-result.d.ts.map +1 -1
  288. package/dist/results/diff-entry.d.ts +10 -0
  289. package/dist/results/diff-entry.d.ts.map +1 -1
  290. package/dist/results/diff-formatter.d.ts.map +1 -1
  291. package/dist/results/diff-output.d.ts +49 -3
  292. package/dist/results/diff-output.d.ts.map +1 -1
  293. package/dist/results/fetch-result.d.ts +12 -0
  294. package/dist/results/fetch-result.d.ts.map +1 -1
  295. package/dist/results/index.js +2 -2
  296. package/dist/results/merge-result.d.ts +5 -0
  297. package/dist/results/merge-result.d.ts.map +1 -1
  298. package/dist/results/push-result.d.ts +5 -0
  299. package/dist/results/push-result.d.ts.map +1 -1
  300. package/dist/results/rebase-result.d.ts +7 -0
  301. package/dist/results/rebase-result.d.ts.map +1 -1
  302. package/dist/results/revert-result.d.ts +6 -0
  303. package/dist/results/revert-result.d.ts.map +1 -1
  304. package/dist/results/stash-result.d.ts +5 -0
  305. package/dist/results/stash-result.d.ts.map +1 -1
  306. package/dist/{results-BDuEgdLU.js → results-CNHQnU5Y.js} +13707 -10608
  307. package/dist/transport-command.d.ts +79 -1
  308. package/dist/transport-command.d.ts.map +1 -1
  309. package/package.json +13 -13
  310. package/src/commands/add-command.ts +3 -0
  311. package/src/commands/add-patch/patch-backend.ts +4 -1
  312. package/src/commands/add-patch/patch-modes.ts +26 -2
  313. package/src/commands/add-patch/patch-session.ts +6 -0
  314. package/src/commands/am/am-command.ts +193 -22
  315. package/src/commands/apply/index.ts +1 -0
  316. package/src/commands/archive/archive-command.ts +1148 -0
  317. package/src/commands/archive/archive-entry.ts +93 -0
  318. package/src/commands/archive/index.ts +7 -0
  319. package/src/commands/archive/remote-archive-command.ts +140 -0
  320. package/src/commands/archive/tar-archive.ts +207 -0
  321. package/src/commands/archive/tar-commit-id.ts +72 -0
  322. package/src/commands/archive/upload-archive-writer.ts +213 -0
  323. package/src/commands/archive/zip-archive.ts +317 -0
  324. package/src/commands/attributes-source.ts +26 -12
  325. package/src/commands/blame-command.ts +118 -19
  326. package/src/commands/bundle/bundle-create-command.ts +405 -0
  327. package/src/commands/bundle/bundle-format.ts +228 -0
  328. package/src/commands/bundle/bundle-list.ts +276 -0
  329. package/src/commands/bundle/bundle-read-commands.ts +157 -0
  330. package/src/commands/bundle/bundle-support.ts +85 -0
  331. package/src/commands/bundle/bundle-transport.ts +107 -0
  332. package/src/commands/bundle/bundle-uri-host.ts +204 -0
  333. package/src/commands/bundle/bundle-uri.ts +236 -0
  334. package/src/commands/bundle/bundle-verify.ts +152 -0
  335. package/src/commands/bundle/index.ts +14 -0
  336. package/src/commands/cat-file/batch-format.ts +193 -0
  337. package/src/commands/cat-file/cat-file-command.ts +895 -0
  338. package/src/commands/cat-file/index.ts +2 -0
  339. package/src/commands/check-attr-command.ts +333 -0
  340. package/src/commands/check-ignore-command.ts +261 -0
  341. package/src/commands/check-ref-format-command.ts +129 -0
  342. package/src/commands/checkout-command.ts +61 -22
  343. package/src/commands/checkout-index-command.ts +568 -0
  344. package/src/commands/checkout-paths.ts +7 -0
  345. package/src/commands/cherry-pick-command.ts +21 -1
  346. package/src/commands/clone-command.ts +249 -9
  347. package/src/commands/commit-command.ts +22 -4
  348. package/src/commands/config-command.ts +9 -0
  349. package/src/commands/daemon-access-hook.ts +78 -0
  350. package/src/commands/default-branch.ts +118 -1
  351. package/src/commands/diff-command.ts +592 -47
  352. package/src/commands/diff-external.ts +131 -0
  353. package/src/commands/diff-plumbing/diff-pairs-command.ts +193 -0
  354. package/src/commands/diff-plumbing/diff-plumbing-command.ts +424 -0
  355. package/src/commands/diff-plumbing/index.ts +2 -0
  356. package/src/commands/diff-textconv.ts +5 -1
  357. package/src/commands/fast-export/fast-export-command.ts +911 -0
  358. package/src/commands/fast-export/fast-import-command.ts +1553 -0
  359. package/src/commands/fast-export/fast-stream-support.ts +162 -0
  360. package/src/commands/fast-export/index.ts +3 -0
  361. package/src/commands/fetch-command.ts +312 -8
  362. package/src/commands/fetch-multiple-command.ts +4 -1
  363. package/src/commands/format-rev-command.ts +267 -0
  364. package/src/commands/fsck/fsck-command.ts +47 -20
  365. package/src/commands/fsck/fsck-msg-ids.ts +19 -3
  366. package/src/commands/fsck/fsck-pack.ts +2 -2
  367. package/src/commands/fsmonitor-ipc.ts +121 -0
  368. package/src/commands/fsmonitor-refresh.ts +320 -0
  369. package/src/commands/gc-command.ts +10 -0
  370. package/src/commands/git-hooks.ts +123 -6
  371. package/src/commands/git-paths.ts +136 -0
  372. package/src/commands/grep/grep-command.ts +38 -15
  373. package/src/commands/history-command.ts +617 -0
  374. package/src/commands/http-config.ts +139 -0
  375. package/src/commands/index-adder.ts +37 -3
  376. package/src/commands/index-host.ts +6 -1
  377. package/src/commands/index.ts +46 -0
  378. package/src/commands/init-command.ts +14 -0
  379. package/src/commands/last-modified-command.ts +804 -0
  380. package/src/commands/lfs/go-url.ts +370 -0
  381. package/src/commands/lfs/index.ts +2 -0
  382. package/src/commands/lfs/lfs-config.ts +738 -0
  383. package/src/commands/lfs/lfs-endpoint-command.ts +180 -0
  384. package/src/commands/local-transport.ts +252 -4
  385. package/src/commands/log-command.ts +104 -5
  386. package/src/commands/log-output.ts +66 -5
  387. package/src/commands/ls-files-command.ts +1177 -0
  388. package/src/commands/ls-remote-command.ts +6 -0
  389. package/src/commands/ls-tree-command.ts +708 -0
  390. package/src/commands/maintenance-run-command.ts +949 -0
  391. package/src/commands/merge-command.ts +78 -32
  392. package/src/commands/merge-config.ts +23 -1
  393. package/src/commands/merge-drivers.ts +109 -20
  394. package/src/commands/merge-support.ts +29 -5
  395. package/src/commands/merge-tree-command.ts +786 -0
  396. package/src/commands/mktag-command.ts +149 -0
  397. package/src/commands/object-store/count-objects-command.ts +404 -0
  398. package/src/commands/object-store/index.ts +4 -0
  399. package/src/commands/object-store/objects-directory.ts +24 -0
  400. package/src/commands/object-store/prune-command.ts +129 -0
  401. package/src/commands/object-store/show-index-command.ts +151 -0
  402. package/src/commands/ort-merge.ts +92 -25
  403. package/src/commands/patch-id-command.ts +65 -0
  404. package/src/commands/patch-id.ts +218 -0
  405. package/src/commands/plumbing-command.ts +141 -0
  406. package/src/commands/plumbing-input.ts +87 -0
  407. package/src/commands/promisor-remote-reply.ts +276 -0
  408. package/src/commands/promisor-remote.ts +25 -2
  409. package/src/commands/pull-command.ts +2 -0
  410. package/src/commands/push-command.ts +87 -5
  411. package/src/commands/rebase-command.ts +507 -19
  412. package/src/commands/refs-command.ts +274 -0
  413. package/src/commands/remote-object-info-command.ts +109 -0
  414. package/src/commands/remote-transport.ts +116 -1
  415. package/src/commands/repack-command.ts +383 -0
  416. package/src/commands/replace-command.ts +816 -0
  417. package/src/commands/replay-command.ts +674 -0
  418. package/src/commands/repo-command.ts +1066 -0
  419. package/src/commands/request-pull-command.ts +356 -0
  420. package/src/commands/rerere-command.ts +179 -0
  421. package/src/commands/rerere.ts +925 -0
  422. package/src/commands/reset-command.ts +75 -3
  423. package/src/commands/rev-filter/commit-grep.ts +7 -2
  424. package/src/commands/rev-list-command.ts +9 -0
  425. package/src/commands/rev-parse-command.ts +49 -5
  426. package/src/commands/revert-command.ts +21 -1
  427. package/src/commands/revision-range.ts +7 -2
  428. package/src/commands/revision-resolver.ts +97 -14
  429. package/src/commands/sequencer-pick.ts +47 -0
  430. package/src/commands/serve-repository.ts +65 -0
  431. package/src/commands/session-id.ts +31 -0
  432. package/src/commands/show-branch-command.ts +981 -0
  433. package/src/commands/show-command.ts +1 -1
  434. package/src/commands/show-ref-command.ts +439 -0
  435. package/src/commands/signature-check.ts +37 -5
  436. package/src/commands/signing.ts +176 -23
  437. package/src/commands/stash-apply-command.ts +3 -0
  438. package/src/commands/stash-export-command.ts +397 -0
  439. package/src/commands/status-command.ts +74 -8
  440. package/src/commands/stripspace-command.ts +118 -0
  441. package/src/commands/submodule-add-command.ts +40 -2
  442. package/src/commands/submodule-auth.ts +61 -6
  443. package/src/commands/submodule-commands.ts +12 -2
  444. package/src/commands/submodule-update-command.ts +47 -1
  445. package/src/commands/tag-command.ts +33 -11
  446. package/src/commands/textconv-cache.ts +143 -0
  447. package/src/commands/tree-restore.ts +14 -0
  448. package/src/commands/unpack-objects-command.ts +235 -0
  449. package/src/commands/update-index-command.ts +1148 -0
  450. package/src/commands/uri-protocols.ts +13 -0
  451. package/src/commands/url-parse-command.ts +67 -0
  452. package/src/commands/var-command.ts +219 -0
  453. package/src/errors/command-errors.ts +45 -0
  454. package/src/git-command.ts +177 -3
  455. package/src/git.ts +808 -1
  456. package/src/guarded-transport-command.ts +6 -1
  457. package/src/results/cherry-pick-result.ts +6 -0
  458. package/src/results/diff-entry.ts +12 -0
  459. package/src/results/diff-formatter.ts +7 -4
  460. package/src/results/diff-output.ts +117 -11
  461. package/src/results/diff-pickaxe.ts +1 -1
  462. package/src/results/fetch-result.ts +12 -0
  463. package/src/results/merge-result.ts +5 -0
  464. package/src/results/push-result.ts +5 -0
  465. package/src/results/rebase-result.ts +7 -0
  466. package/src/results/revert-result.ts +6 -0
  467. package/src/results/stash-result.ts +6 -0
  468. package/src/transport-command.ts +182 -1
@@ -1,12 +1,780 @@
1
- import { I as __exportAll, m as receiveFsckOf } from "./fsck-CPeDh9fh.js";
1
+ import { I as __exportAll, m as receiveFsckOf } from "./fsck-BHT9bUS-.js";
2
2
  import { GitApiError, InvalidConfigError, InvalidPathError, ReadTreeFailedError, TransportError as TransportError$1 } from "./errors/index.js";
3
- import { Do as quoteCStyleBody, Ic as hookSettingsFromEntries, Kc as worktreeModeTrust, Kt as SubmoduleUnpack, L as StatusCommand, Mt as resetMerge, Nc as hookHostOf, Po as GitCommand, Sc as worktreePathRules, Tc as LOCAL_REPO_ENV, Wc as coreBool, Ws as SparseUnpack, Xi as firstPlainError, Zi as flatTree, _c as restoreCaseOptions, ca as switchTrees, dc as untrackedUnder, ea as plainUnpackError, fl as hostEnvironmentOf, fn as repositoryPlaceOf, gn as usesBranch, ia as rewriteIndex, nc as entryNotUptodate, oc as pruneEmptyParents, qs as pushSparseWarnings, qt as recursesIntoSubmodules, sc as removeCaseVariants, ta as planPathsRestore, tc as IndexCaseFolding, vc as writeTreeRestorePlan, vn as worktreeUsingBranch, wc as HookSession, wl as RemoteConfigStore, xc as withTreePathRefusal, yc as firstInvalidPath, zc as refTransactionHookOf } from "./results-BDuEgdLU.js";
3
+ import { $t as SubmoduleUnpack, Bl as worktreeModeTrust, Cl as hookHostOf, Ds as quoteCStyleBody, El as hookSettingsFromEntries, Gc as IndexCaseFolding, In as checkSignatureWith, Kc as entryNotUptodate, Lc as pushSparseWarnings, Lt as resetMerge, Pc as SparseUnpack, R as StatusCommand, Ra as GitCommand, Rl as coreBool, Xc as pruneEmptyParents, Ya as signingConfigFromEntries, Zc as removeCaseVariants, bn as worktreeAdminWorkingCopy, ca as planPathsRestore, cl as writeTreeRestorePlan, da as rewriteIndex, dl as withTreePathRefusal, en as recursesIntoSubmodules, fl as worktreePathRules, gn as requireWorktrees, ha as switchTrees, hl as LOCAL_REPO_ENV, hn as repositoryPlaceOf, ia as flatTree, kl as refTransactionHookOf, ll as firstInvalidPath, lu as hostEnvironmentOf, ml as HookSession, pn as parseExpiry, ra as firstPlainError, sa as plainUnpackError, sl as restoreCaseOptions, tl as untrackedUnder, xn as worktreeUsingBranch, xu as RemoteConfigStore, yn as usesBranch } from "./results-CNHQnU5Y.js";
4
4
  import { FileMode, historyWithoutLazyFetch } from "@statewalker/vcs-core";
5
- import { compareGitPaths, parseGitBool, parseGitInt } from "@statewalker/vcs-utils/encoding";
5
+ import { compareGitPaths, decodeGitPath, encodeGitPath, parseGitBool, parseGitInt } from "@statewalker/vcs-utils/encoding";
6
6
  import { attributesIndexOf, cacheTreeOfTree, entryStatOf, isIndexUnborn, repairCacheTree, sparseFilterMatcher } from "@statewalker/vcs-working-tree";
7
+ import { parseGitInt as parseGitInt$1 } from "@statewalker/vcs-utils";
7
8
  import { readFile as readFile$1 } from "@statewalker/vcs-utils/files";
8
- import { configFilesApiOf, readConfinedFile } from "@statewalker/vcs-store-files";
9
- import { ReceivePackDiedError, createRepositoryFacade, createTransportRefStore, isGitUrl, openDuplexConnection, openDuplexReceivePackConnection, openReceivePack, openUploadPack, parseGitUrl, protocolVersionFor, serveOverDuplex, serverSettingsFromConfig } from "@statewalker/vcs-transport";
9
+ import { SHA1_OBJECT_FORMAT as SHA1_OBJECT_FORMAT$1, objectFormatByName as objectFormatByName$1 } from "@statewalker/vcs-utils/hash";
10
+ import { configFilesApiOf, gc, parseExpiryDate, readConfinedFile, updateServerInfo } from "@statewalker/vcs-store-files";
11
+ import { ReceivePackDiedError, connectivityErrors, createRepositoryFacade, createTransportRefStore, isGitUrl, openDuplexConnection, openDuplexReceivePackConnection, openReceivePack, openUploadPack, parseGitUrl, protocolVersionFor, pushCertificateEnv, serveOverDuplex, serverSettingsFromConfig } from "@statewalker/vcs-transport";
12
+ //#region src/commands/bundle/bundle-format.ts
13
+ /**
14
+ * git's bundle files (bundle.c, `Documentation/gitformat-bundle.adoc`): a header naming the
15
+ * refs the bundle carries and the commits it needs, then a pack.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // # v3 git bundle
20
+ * // @object-format=sha256
21
+ * // -<id> <subject> (a prerequisite)
22
+ * // <id> refs/heads/main (a ref)
23
+ * // (an empty line, then the pack)
24
+ * const header = parseBundleHeader(bytes);
25
+ * if (header.ok) for (const ref of header.header.references) console.log(ref.id, ref.name);
26
+ * ```
27
+ */
28
+ /** The first line of a v2 bundle. */
29
+ const V2_BUNDLE_SIGNATURE = "# v2 git bundle\n";
30
+ /** The first line of a v3 bundle (capabilities may follow). */
31
+ const V3_BUNDLE_SIGNATURE = "# v3 git bundle\n";
32
+ /** git's sane_ctype isspace: SP, HT, LF, CR */
33
+ const SPACE = (c) => c === 32 || c === 9 || c === 10 || c === 13;
34
+ const HEX = /^[0-9a-fA-F]$/;
35
+ /**
36
+ * bundle.c's `read_bundle_header_fd`: the signature, then lines up to an empty one (or the
37
+ * end): v3 capabilities (`@object-format=`, `@filter=`), prerequisites (`-<id>` optionally
38
+ * followed by a space and a comment) and refs (`<id> <name>`), each line right-trimmed.
39
+ * `name` is how a bad signature is reported (git's `report_path`).
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const parsed = parseBundleHeader(bytes, "repo.bundle");
44
+ * if (!parsed.ok) console.error(`error: ${parsed.error}`);
45
+ * ```
46
+ */
47
+ function parseBundleHeader(bytes, name = "<bundle>") {
48
+ let at = 0;
49
+ /** strbuf_getwholeline_fd: the next line with its LF; undefined at the end */
50
+ const nextLine = () => {
51
+ if (at >= bytes.length) return void 0;
52
+ const lf = bytes.indexOf(10, at);
53
+ const end = lf < 0 ? bytes.length : lf + 1;
54
+ const line = bytes.subarray(at, end);
55
+ at = end;
56
+ return line;
57
+ };
58
+ const first = nextLine();
59
+ const signature = first ? latin1(first) : "";
60
+ const version = signature === "# v2 git bundle\n" ? 2 : signature === "# v3 git bundle\n" ? 3 : 0;
61
+ if (version === 0) return {
62
+ ok: false,
63
+ error: `'${name}' does not look like a v2 or v3 bundle file`,
64
+ notABundle: true
65
+ };
66
+ let objectFormat = SHA1_OBJECT_FORMAT$1;
67
+ let filter;
68
+ const prerequisites = [];
69
+ const references = [];
70
+ const fail = (error) => ({
71
+ ok: false,
72
+ error,
73
+ notABundle: false
74
+ });
75
+ for (let line = nextLine(); line !== void 0; line = nextLine()) {
76
+ if (line.length === 0 || line[0] === 10) break;
77
+ let end = line.length;
78
+ while (end > 0 && SPACE(line[end - 1])) end--;
79
+ let text = line.subarray(0, end);
80
+ if (version === 3 && text[0] === 64) {
81
+ const capability = decodeGitPath(text.subarray(1));
82
+ if (capability.startsWith("object-format=")) {
83
+ const format = objectFormatByName$1(capability.slice(14));
84
+ if (!format) return fail(`unrecognized bundle hash algorithm: ${capability.slice(14)}`);
85
+ objectFormat = format;
86
+ continue;
87
+ }
88
+ if (capability.startsWith("filter=")) {
89
+ filter = capability.slice(7);
90
+ continue;
91
+ }
92
+ return fail(`unknown capability '${capability}'`);
93
+ }
94
+ const prereq = text[0] === 45;
95
+ if (prereq) text = text.subarray(1);
96
+ const hex = objectFormat.hexLength;
97
+ let valid = text.length >= hex;
98
+ for (let i = 0; valid && i < hex; i++) valid = HEX.test(String.fromCharCode(text[i]));
99
+ const rest = text.subarray(hex);
100
+ if (valid && rest.length > 0 && !SPACE(rest[0])) valid = false;
101
+ if (valid && !prereq && rest.length === 0) valid = false;
102
+ if (!valid) return fail(`unrecognized header: ${prereq ? "-" : ""}${decodeGitPath(text)} (${text.length})`);
103
+ const id = latin1(text.subarray(0, hex)).toLowerCase();
104
+ if (prereq) prerequisites.push({
105
+ id,
106
+ comment: decodeGitPath(rest.subarray(1)).trim()
107
+ });
108
+ else references.push({
109
+ id,
110
+ name: decodeGitPath(rest.subarray(1))
111
+ });
112
+ }
113
+ return {
114
+ ok: true,
115
+ header: {
116
+ version,
117
+ objectFormat,
118
+ ...filter !== void 0 ? { filter } : {},
119
+ prerequisites,
120
+ references
121
+ },
122
+ packOffset: at
123
+ };
124
+ }
125
+ /**
126
+ * The header `create_bundle` writes: the signature (v3 with `@object-format=` and, for a
127
+ * filtered bundle, `@filter=`), `-<id> <comment>` per prerequisite, `<id> <name>` per ref,
128
+ * then the empty line the pack follows.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const bytes = encodeBundleHeader({ version: 2, objectFormat: SHA1_OBJECT_FORMAT,
133
+ * prerequisites: [], references: [{ id, name: "refs/heads/main" }] });
134
+ * ```
135
+ */
136
+ function encodeBundleHeader(header) {
137
+ const parts = [];
138
+ const text = (s) => parts.push(encodeGitPath(s));
139
+ if (header.version === 2) text(V2_BUNDLE_SIGNATURE);
140
+ else {
141
+ text(V3_BUNDLE_SIGNATURE);
142
+ text(`@object-format=${header.objectFormat.name}\n`);
143
+ if (header.filter !== void 0) text(`@filter=${header.filter}\n`);
144
+ }
145
+ for (const p of header.prerequisites) text(`-${p.id} ${p.comment}\n`);
146
+ for (const r of header.references) text(`${r.id} ${r.name}\n`);
147
+ text("\n");
148
+ let length = 0;
149
+ for (const p of parts) length += p.length;
150
+ const out = new Uint8Array(length);
151
+ let at = 0;
152
+ for (const p of parts) {
153
+ out.set(p, at);
154
+ at += p.length;
155
+ }
156
+ return out;
157
+ }
158
+ /**
159
+ * bundle.c's `list_refs`: `<id> <name>` per ref, only those named in `names` when any are
160
+ * (exact names, as `git bundle list-heads <file> <refname>...` and `unbundle` take them).
161
+ * A prerequisite is listed with an empty name (`<id> `), as `git bundle verify` prints it.
162
+ */
163
+ function listBundleRefs(refs, names = []) {
164
+ let out = "";
165
+ for (const ref of refs) {
166
+ const name = "name" in ref ? ref.name : "";
167
+ if (names.length > 0 && !names.includes(name)) continue;
168
+ out += `${ref.id} ${name}\n`;
169
+ }
170
+ return out;
171
+ }
172
+ function latin1(bytes) {
173
+ let s = "";
174
+ for (let i = 0; i < bytes.length; i++) s += String.fromCharCode(bytes[i]);
175
+ return s;
176
+ }
177
+ //#endregion
178
+ //#region src/commands/bundle/bundle-verify.ts
179
+ /**
180
+ * bundle.c's reading side without a command: a bundle's bytes read (`read_bundle_header`)
181
+ * and checked against a repository (`verify_bundle`), as the bundle commands and the bundle
182
+ * transport do.
183
+ */
184
+ /** The bytes of a {@link BundleInput}, collected. */
185
+ async function bundleBytes(input) {
186
+ if (input instanceof Uint8Array) return input;
187
+ const chunks = [];
188
+ let length = 0;
189
+ for await (const chunk of input) {
190
+ chunks.push(chunk);
191
+ length += chunk.length;
192
+ }
193
+ const out = new Uint8Array(length);
194
+ let at = 0;
195
+ for (const chunk of chunks) {
196
+ out.set(chunk, at);
197
+ at += chunk.length;
198
+ }
199
+ return out;
200
+ }
201
+ /**
202
+ * builtin/bundle.c's `open_bundle` (`read_bundle_header`): the header and the pack, or git's
203
+ * `error:` line (the bundle reported as `name`: its path, `<stdin>` for `-`).
204
+ */
205
+ function openBundle(bytes, name) {
206
+ const parsed = parseBundleHeader(bytes, name);
207
+ if (!parsed.ok) return {
208
+ ok: false,
209
+ error: `error: ${parsed.error}\n`
210
+ };
211
+ return {
212
+ ok: true,
213
+ bundle: {
214
+ header: parsed.header,
215
+ pack: bytes.subarray(parsed.packOffset)
216
+ }
217
+ };
218
+ }
219
+ /**
220
+ * bundle.c's `verify_bundle`: every prerequisite must be an object here (each missing one
221
+ * on an `error:` line after `Repository lacks these prerequisite commits:`, unless quiet),
222
+ * then connected to the refs (`check_connected` of the prerequisites, `--not --all`); with
223
+ * `verbose`, what the bundle holds on stdout.
224
+ */
225
+ async function verifyBundleIn(repository, header, options = {}) {
226
+ const objects = historyWithoutLazyFetch(repository.history);
227
+ let stderr = "";
228
+ let missing = 0;
229
+ for (const prerequisite of header.prerequisites) {
230
+ if (await objectExists(objects, prerequisite.id)) continue;
231
+ missing++;
232
+ if (options.quiet) continue;
233
+ if (missing === 1) stderr += "error: Repository lacks these prerequisite commits:\n";
234
+ stderr += `error: ${prerequisite.id} \n`;
235
+ }
236
+ if (missing > 0) return {
237
+ ok: false,
238
+ stdout: "",
239
+ stderr
240
+ };
241
+ let ok = true;
242
+ const tips = header.prerequisites.map((p) => p.id);
243
+ if (tips.length > 0) {
244
+ const facade = createRepositoryFacade({ history: objects });
245
+ if (await connectivityErrors(facade, tips, {
246
+ known: await repository.refValues(),
247
+ shallow: new Set(await repository.shallow())
248
+ })) {
249
+ ok = false;
250
+ stderr += "error: some prerequisite commits exist in the object store, but are not connected to the repository's history\n";
251
+ }
252
+ }
253
+ let stdout = "";
254
+ if (options.verbose) {
255
+ const refs = header.references;
256
+ stdout += refs.length === 1 ? "The bundle contains this ref:\n" : `The bundle contains these ${refs.length} refs:\n`;
257
+ stdout += listBundleRefs(refs);
258
+ const prereqs = header.prerequisites;
259
+ if (prereqs.length === 0) stdout += "The bundle records a complete history.\n";
260
+ else {
261
+ stdout += prereqs.length === 1 ? "The bundle requires this ref:\n" : `The bundle requires these ${prereqs.length} refs:\n`;
262
+ stdout += listBundleRefs(prereqs);
263
+ }
264
+ stdout += `The bundle uses this hash algorithm: ${header.objectFormat.name}\n`;
265
+ if (header.filter !== void 0) stdout += `The bundle uses this filter: ${header.filter}\n`;
266
+ }
267
+ return {
268
+ ok,
269
+ stdout,
270
+ stderr
271
+ };
272
+ }
273
+ /** git's `parse_object` succeeds: the object is here, whatever its type. */
274
+ async function objectExists(history, id) {
275
+ const objects = history.objects;
276
+ if (objects) return objects.has(id).catch(() => false);
277
+ for (const store of [
278
+ history.commits,
279
+ history.trees,
280
+ history.blobs,
281
+ history.tags
282
+ ]) if (await store.has(id).catch(() => false)) return true;
283
+ return false;
284
+ }
285
+ //#endregion
286
+ //#region src/commands/bundle/bundle-transport.ts
287
+ /**
288
+ * git's bundle transport (transport.c's `bundle_vtable`): a remote URL that is a path to a
289
+ * bundle file is read as a repository whose refs are the bundle's and whose only pack is the
290
+ * bundle's. Fetch, clone, pull and ls-remote reach it through an upload-pack served in
291
+ * process from the bundle: its refs advertised (in git's order: the bundle's refs reversed,
292
+ * as `get_refs_from_bundle` prepends each), and any fetch answered with the bundle's pack,
293
+ * once the fetching repository has the bundle's prerequisites (`unbundle`'s `verify_bundle`).
294
+ */
295
+ /**
296
+ * A fetch from a bundle the repository lacks the prerequisites of: `verify_bundle`'s lines
297
+ * (`git fetch` exits 1; `git clone` adds `fatal: remote transport reported error`, 128).
298
+ */
299
+ var BundlePrerequisitesError = class extends TransportError$1 {
300
+ lines;
301
+ constructor(lines) {
302
+ super(lines.replace(/\n$/, ""), void 0, { exitCode: 1 });
303
+ this.lines = lines;
304
+ this.name = "BundlePrerequisitesError";
305
+ }
306
+ };
307
+ /** Bytes per chunk the served pack is cut into. */
308
+ const CHUNK = 65536;
309
+ /**
310
+ * Runs `run` over a connection to an upload-pack serving the bundle (protocol v0). A fetch
311
+ * that needs the pack verifies the bundle first: when the repository lacks its prerequisites
312
+ * the fetch fails with git's lines (exit 1, as `git fetch` returns).
313
+ */
314
+ async function withBundleUploadPack(remote, createPair, run) {
315
+ const { header, pack } = remote.bundle;
316
+ let refused;
317
+ const facade = {
318
+ objectFormat: header.objectFormat,
319
+ importPack: () => Promise.reject(/* @__PURE__ */ new Error("a bundle cannot be written to")),
320
+ async *exportPack() {
321
+ const verified = await remote.verify();
322
+ if (!verified.ok) {
323
+ refused = verified.stderr;
324
+ throw new Error("bundle prerequisites missing");
325
+ }
326
+ for (let at = 0; at < pack.length; at += CHUNK) yield pack.subarray(at, at + CHUNK);
327
+ },
328
+ has: async (oid) => header.references.some((r) => r.id === oid),
329
+ async *walkAncestors() {}
330
+ };
331
+ const [client, server] = createPair();
332
+ const serving = serveOverDuplex({
333
+ duplex: server,
334
+ repository: facade,
335
+ refStore: bundleRefStore(header),
336
+ service: "git-upload-pack"
337
+ }).finally(() => server.close?.());
338
+ try {
339
+ const connection = await openDuplexConnection(client, { closeDuplex: true });
340
+ try {
341
+ return await run(connection);
342
+ } catch (error) {
343
+ if (refused !== void 0) throw new BundlePrerequisitesError(refused);
344
+ throw error;
345
+ } finally {
346
+ await connection.close();
347
+ }
348
+ } finally {
349
+ await client.close?.();
350
+ await serving.catch(() => void 0);
351
+ }
352
+ }
353
+ /** The refs a bundle advertises: read-only, in `get_refs_from_bundle`'s (reversed) order. */
354
+ function bundleRefStore(header) {
355
+ const refs = [...header.references].reverse();
356
+ return {
357
+ get: async (name) => refs.find((r) => r.name === name)?.id,
358
+ update: () => Promise.reject(/* @__PURE__ */ new Error("a bundle cannot be written to")),
359
+ listAll: async () => refs.map((r) => [r.name, r.id]),
360
+ isRefTip: async (oid) => refs.some((r) => r.id === oid)
361
+ };
362
+ }
363
+ //#endregion
364
+ //#region src/commands/worktree-prune-command.ts
365
+ /**
366
+ * Prune the administrative files of worktrees that are gone.
367
+ *
368
+ * Equivalent to `git worktree prune [-n] [-v] [--expire <expire>]`.
369
+ *
370
+ * @example
371
+ * ```typescript
372
+ * const { pruned } = await git.worktreePrune().setDryRun(true).call();
373
+ * await git.worktreePrune().setExpire("3.months.ago").call();
374
+ * ```
375
+ *
376
+ * As git's `should_prune_worktree`, `.git/worktrees/<id>` goes when it is not a directory,
377
+ * has no `gitdir` file, an empty one, or one naming a place that no longer exists and whose
378
+ * `index` is not newer than `--expire` (default: every such worktree). A locked worktree is
379
+ * kept whatever its state. Of the kept worktrees, those whose `gitdir` names the same
380
+ * place as another (or as the repository) are pruned as `duplicate entry`, the first by
381
+ * name kept. The empty `.git/worktrees` goes too. `git gc` runs this with
382
+ * `gc.worktreePruneExpire` (default `3.months.ago`).
383
+ */
384
+ var WorktreePruneCommand = class extends GitCommand {
385
+ dryRun = false;
386
+ verbose = false;
387
+ expire = Number.POSITIVE_INFINITY;
388
+ /** `-n`: report, remove nothing. */
389
+ setDryRun(dryRun) {
390
+ this.checkCallable();
391
+ this.dryRun = dryRun;
392
+ return this;
393
+ }
394
+ /** `-v`: report what is removed. */
395
+ setVerbose(verbose) {
396
+ this.checkCallable();
397
+ this.verbose = verbose;
398
+ return this;
399
+ }
400
+ /** `--expire <time>`: missing worktrees whose index is newer are kept. */
401
+ setExpire(expire) {
402
+ this.checkCallable();
403
+ this.expire = expire;
404
+ return this;
405
+ }
406
+ async call() {
407
+ this.checkCallable();
408
+ this.setCallable(false);
409
+ const worktrees = requireWorktrees(this.workingCopy, "prune");
410
+ const expire = parseExpiry(this.expire);
411
+ const pruned = [];
412
+ const messages = [];
413
+ const prune = async (id, reason) => {
414
+ if (this.dryRun || this.verbose) messages.push(`Removing worktrees/${id}: ${reason}`);
415
+ if (!this.dryRun) await worktrees.deleteAdminDir(id).catch(() => void 0);
416
+ pruned.push({
417
+ id,
418
+ reason
419
+ });
420
+ };
421
+ const kept = [];
422
+ for (const id of await worktrees.adminIds()) {
423
+ const check = await worktrees.pruneCheck(id, expire);
424
+ if (check.reason !== void 0) await prune(id, check.reason);
425
+ else if (check.gitdirPath !== void 0) kept.push({
426
+ path: check.gitdirPath,
427
+ id
428
+ });
429
+ }
430
+ kept.push({ path: worktrees.commonDirPath().replace(/\/\.$/, "") });
431
+ kept.sort((a, b) => {
432
+ if (a.path !== b.path) return a.path < b.path ? -1 : 1;
433
+ if (a.id === void 0) return -1;
434
+ if (b.id === void 0) return 1;
435
+ return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
436
+ });
437
+ for (let i = 1; i < kept.length; i++) {
438
+ const id = kept[i].id;
439
+ if (kept[i].path === kept[i - 1].path && id !== void 0) await prune(id, "duplicate entry");
440
+ }
441
+ if (!this.dryRun) await worktrees.deleteAdminRootIfEmpty();
442
+ return {
443
+ pruned,
444
+ messages
445
+ };
446
+ }
447
+ };
448
+ //#endregion
449
+ //#region src/commands/gc-command.ts
450
+ /** git's defaults: `gc.auto` loose objects, `gc.autoPackLimit` packs. */
451
+ const GC_AUTO_DEFAULT = 6700;
452
+ const GC_AUTO_PACK_LIMIT_DEFAULT = 50;
453
+ /**
454
+ * Run garbage collection on the repository: `git gc`.
455
+ *
456
+ * Over a files repository it runs what `git gc` runs, in git's order (builtin/gc.c): `pack-refs
457
+ * --all --prune` (`gc.packRefs`), `reflog expire --all` (`gc.reflogExpire*`), `worktree prune
458
+ * --expire <gc.worktreePruneExpire>` and `rerere gc` (`gc.rerereResolved`/`Unresolved`), the
459
+ * repack (`repack -d -l` with `--cruft --cruft-expiration=<gc.pruneExpire>` (`gc.cruftPacks`,
460
+ * default), `-A --unpack-unreachable=<expire>` without cruft packs, or `-a` for `--prune=now`;
461
+ * `--keep-pack` for `--keep-largest-pack`/`gc.bigPackThreshold`; `-f --depth --window` for
462
+ * `--aggressive`; a bitmap in a bare repository), `update-server-info`, `prune --expire
463
+ * <expire>` (with `prune_shallow`), and the commit-graph (`gc.writeCommitGraph`). git 2.43 runs
464
+ * the worktree prune and rerere gc after the prune, 2.5x before the repack: the hook runner's
465
+ * compatibility decides. Without a files repository only refs are packed and worktrees pruned.
466
+ *
467
+ * @example
468
+ * ```typescript
469
+ * const result = await git.gc().call();
470
+ * console.log(`Removed ${result.objectsRemoved} objects`);
471
+ *
472
+ * // git gc --aggressive --prune=now
473
+ * await git.gc().setAggressive(true).setPrune("now").call();
474
+ *
475
+ * // git gc --no-prune
476
+ * await git.gc().setPrune(false).call();
477
+ * ```
478
+ */
479
+ var GarbageCollectCommand = class extends GitCommand {
480
+ _packRefs;
481
+ /** git's fsck and gc read the objects as stored, never through replace refs. */
482
+ readsReplacedObjects() {
483
+ return false;
484
+ }
485
+ _aggressive = false;
486
+ _expire;
487
+ _prune;
488
+ _auto = false;
489
+ _quiet = false;
490
+ _cruft;
491
+ _maxCruftSize;
492
+ _keepLargestPack;
493
+ _force = false;
494
+ /**
495
+ * `git gc --auto`: housekeeping only when needed (git's `need_to_gc`: more loose objects
496
+ * than `gc.auto`, estimated from `objects/17` as git does, default 6700, or more packs
497
+ * without a `.keep` than `gc.autoPackLimit`, default 50; 0 or less turns either check
498
+ * off, `gc.auto=0` all of auto gc), and only when the pre-auto-gc hook, run first, agrees.
499
+ * With too many packs the repack is a full one, else an incremental one (the reachable loose
500
+ * objects into a new pack). No command runs it by itself: callers decide when (git's
501
+ * `maintenance.auto` after a commit, merge or fetch is not reproduced).
502
+ *
503
+ * @example
504
+ * ```typescript
505
+ * const result = await git.gc().setAuto(true).call();
506
+ * if (result.autoSkipped) console.log(`nothing done: ${result.autoSkipped}`);
507
+ * ```
508
+ */
509
+ setAuto(auto) {
510
+ this.checkCallable();
511
+ this._auto = auto;
512
+ return this;
513
+ }
514
+ /** `--quiet`: no "Auto packing the repository ..." messages. */
515
+ setQuiet(quiet) {
516
+ this.checkCallable();
517
+ this._quiet = quiet;
518
+ return this;
519
+ }
520
+ /**
521
+ * `--prune=<date>` (a git expiry date: `now`, `never`, `2.weeks.ago`, a `Date`), `--prune`
522
+ * (true: `gc.pruneExpire`, default two weeks) or `--no-prune` (false: nothing unreachable
523
+ * expires, `git prune` does not run).
524
+ */
525
+ setPrune(prune) {
526
+ this.checkCallable();
527
+ if (prune instanceof Date) this._expire = prune;
528
+ else this._prune = prune;
529
+ return this;
530
+ }
531
+ /** `--cruft` / `--no-cruft` (default `gc.cruftPacks`, true). */
532
+ setCruft(cruft) {
533
+ this.checkCallable();
534
+ this._cruft = cruft;
535
+ return this;
536
+ }
537
+ /** `--max-cruft-size=<bytes>` (default `gc.maxCruftSize`). */
538
+ setMaxCruftSize(bytes) {
539
+ this.checkCallable();
540
+ this._maxCruftSize = bytes;
541
+ return this;
542
+ }
543
+ /**
544
+ * `--keep-largest-pack` (true) / `--no-keep-largest-pack` (false): the largest non-cruft
545
+ * pack is kept as it is; false also ignores `gc.bigPackThreshold`.
546
+ */
547
+ setKeepLargestPack(keep) {
548
+ this.checkCallable();
549
+ this._keepLargestPack = keep;
550
+ return this;
551
+ }
552
+ /**
553
+ * git's `need_to_gc`: whether `gc --auto` has work to do (the maintenance gc task's `--auto`
554
+ * condition). Reads only the configuration and the objects directory.
555
+ */
556
+ async isAutoGcNeeded() {
557
+ return this.needsAutoGc();
558
+ }
559
+ /** git's `need_to_gc`: whether `gc --auto` has work to do. */
560
+ async needsAutoGc() {
561
+ const config = RemoteConfigStore.from(this.workingCopy);
562
+ const int = (key, fallback) => {
563
+ const value = config.value(key);
564
+ if (value === void 0) return fallback;
565
+ const n = parseGitInt$1(value);
566
+ if (n === void 0) throw new GitApiError(`fatal: bad numeric config value '${value}' for '${key.toLowerCase()}': invalid unit`);
567
+ return n;
568
+ };
569
+ const gcAuto = int("gc.auto", GC_AUTO_DEFAULT);
570
+ if (gcAuto <= 0) return false;
571
+ const packLimit = int("gc.autoPackLimit", GC_AUTO_PACK_LIMIT_DEFAULT);
572
+ const objects = await this.hooks.commonGitFile("objects");
573
+ if (!objects) return false;
574
+ const names = async (dir) => {
575
+ const out = [];
576
+ try {
577
+ for await (const info of objects.files.list(`${objects.path}/${dir}`)) out.push(info.name);
578
+ } catch {}
579
+ return out;
580
+ };
581
+ if (packLimit > 0) {
582
+ const files = new Set(await names("pack"));
583
+ let packs = 0;
584
+ for (const name of files) {
585
+ if (!name.endsWith(".pack")) continue;
586
+ const base = name.slice(0, -5);
587
+ if (files.has(`${base}.idx`) && !files.has(`${base}.keep`)) packs++;
588
+ }
589
+ if (packs > packLimit) return true;
590
+ }
591
+ const loose = new RegExp(`^[0-9a-f]{${this.objectFormat.hexLength - 2}}$`);
592
+ return (await names("17")).filter((n) => loose.test(n)).length * 256 > Math.ceil(gcAuto / 256) * 256;
593
+ }
594
+ /**
595
+ * `--force`: run even when `gc.pid` says another gc is running (git's `lock_repo_for_gc`
596
+ * with `force`); `gc.pid.lock` must still be free.
597
+ */
598
+ setForce(force) {
599
+ this.checkCallable();
600
+ this._force = force;
601
+ return this;
602
+ }
603
+ /**
604
+ * `--aggressive`: deltas searched again (`repack -f`) with `gc.aggressiveWindow` (250) and
605
+ * `gc.aggressiveDepth` (50).
606
+ */
607
+ setAggressive(aggressive) {
608
+ this.checkCallable();
609
+ this._aggressive = aggressive;
610
+ return this;
611
+ }
612
+ /**
613
+ * Whether to pack refs (`git pack-refs --all --prune`). Default: `gc.packRefs` (true;
614
+ * `notbare` packs them only in a repository with a worktree).
615
+ */
616
+ setPackRefs(packRefs) {
617
+ this.checkCallable();
618
+ this._packRefs = packRefs;
619
+ return this;
620
+ }
621
+ /**
622
+ * `--prune=<date>`: unreachable objects older than this date expire; younger ones stay
623
+ * (loose, or in a cruft pack) in case a write in progress needs them.
624
+ */
625
+ setExpire(expire) {
626
+ this.checkCallable();
627
+ this._expire = expire;
628
+ return this;
629
+ }
630
+ /** The repository's files backend: its FilesApi, common git directory and history. */
631
+ async filesRepository() {
632
+ const history = this.workingCopy.history;
633
+ if (!history?.objects || !history.packs) return void 0;
634
+ const objects = await this.hooks.commonGitFile("objects");
635
+ if (!objects) return void 0;
636
+ return {
637
+ files: objects.files,
638
+ gitDir: objects.path.replace(/\/?objects$/, ""),
639
+ history
640
+ };
641
+ }
642
+ /** The prune expiry in milliseconds before now, undefined for the config's. */
643
+ pruneExpireMs() {
644
+ if (this._expire) return Math.max(0, Date.now() - this._expire.getTime());
645
+ if (typeof this._prune !== "string") return void 0;
646
+ const nowMs = Date.now();
647
+ const cutoff = parseExpiryDate(this._prune, Math.floor(nowMs / 1e3), "--prune");
648
+ if (cutoff === 0) return Number.POSITIVE_INFINITY;
649
+ if (cutoff === Number.POSITIVE_INFINITY) return 0;
650
+ return Math.max(0, nowMs - cutoff * 1e3);
651
+ }
652
+ /** `gc.packRefs`: a boolean, or `notbare` (packed unless the repository is bare). */
653
+ packRefsConfigured() {
654
+ if (this._packRefs !== void 0) return this._packRefs;
655
+ const config = RemoteConfigStore.from(this.workingCopy);
656
+ const value = config.value("gc.packRefs");
657
+ if (value === void 0) return true;
658
+ if (value === "notbare") {
659
+ const bare = config.value("core.bare");
660
+ return !(bare !== void 0 && (parseGitBool(bare) ?? false));
661
+ }
662
+ return parseGitBool(value) ?? true;
663
+ }
664
+ /**
665
+ * Execute the garbage collection.
666
+ *
667
+ * @returns GC result with statistics
668
+ */
669
+ async call() {
670
+ this.checkCallable();
671
+ this.setCallable(false);
672
+ const startTime = Date.now();
673
+ let refsPacked = false;
674
+ const messages = [];
675
+ const skipped = (autoSkipped) => ({
676
+ objectsRemoved: 0,
677
+ bytesFreed: 0,
678
+ refsPacked,
679
+ durationMs: Date.now() - startTime,
680
+ worktreesPruned: [],
681
+ autoSkipped
682
+ });
683
+ if (this._auto) {
684
+ if (!await this.needsAutoGc()) return skipped("not-needed");
685
+ const hook = await this.hooks.run("pre-auto-gc");
686
+ if (hook && hook.exitCode !== 0) return skipped("hook");
687
+ if (!this._quiet) messages.push("Auto packing the repository for optimum performance.", "See \"git help gc\" for manual housekeeping.");
688
+ }
689
+ const errors = [];
690
+ const packRefs = async () => {
691
+ if (!this.refsStore.packRefs) return;
692
+ await this.refsStore.packRefs([], {
693
+ all: true,
694
+ deleteLoose: true,
695
+ ...this._auto && this.hooks.compatibility !== "2.43" ? { auto: true } : {},
696
+ onError: (line) => {
697
+ errors.push(line);
698
+ this.hooks.append(`${line}\n`);
699
+ }
700
+ });
701
+ refsPacked = true;
702
+ };
703
+ const worktreesPruned = [];
704
+ const pruneWorktrees = async () => {
705
+ if (!this.workingCopy.worktrees) return;
706
+ const expire = RemoteConfigStore.from(this.workingCopy).value("gc.worktreePruneExpire") ?? "3.months.ago";
707
+ const { pruned } = await new WorktreePruneCommand(this.workingCopy).setExpire(expire).call();
708
+ for (const p of pruned) worktreesPruned.push(p.id);
709
+ };
710
+ const repository = await this.filesRepository();
711
+ if (!repository) {
712
+ if (this.packRefsConfigured()) await packRefs();
713
+ await pruneWorktrees();
714
+ return {
715
+ objectsRemoved: 0,
716
+ bytesFreed: 0,
717
+ refsPacked,
718
+ durationMs: Date.now() - startTime,
719
+ worktreesPruned,
720
+ ...this._auto ? { messages } : {},
721
+ ...errors.length > 0 || this.alternatesErrors().length > 0 ? { errors: [...this.alternatesErrors(), ...errors] } : {}
722
+ };
723
+ }
724
+ const environment = hostEnvironmentOf(this.workingCopy);
725
+ const pruneExpireMs = this.pruneExpireMs();
726
+ const details = await gc({
727
+ history: repository.history,
728
+ files: repository.files,
729
+ gitDir: repository.gitDir,
730
+ compatibility: this.hooks.compatibility,
731
+ ...environment ? { environment } : {},
732
+ ...this.progress && !this._quiet ? { progress: this.progress } : {},
733
+ packRefs: this.packRefsConfigured(),
734
+ packRefsStep: packRefs,
735
+ beforeObjects: pruneWorktrees,
736
+ afterObjects: pruneWorktrees,
737
+ ...this._prune === false ? { prune: false } : {},
738
+ ...pruneExpireMs !== void 0 ? { pruneExpireMs } : {},
739
+ ...this._cruft !== void 0 ? { cruftPacks: this._cruft } : {},
740
+ ...this._maxCruftSize !== void 0 ? { maxCruftSize: this._maxCruftSize } : {},
741
+ ...this._keepLargestPack !== void 0 ? { keepLargestPack: this._keepLargestPack } : {},
742
+ ...this._aggressive ? { aggressive: true } : {},
743
+ ...this._auto ? { auto: true } : {},
744
+ ...this._force ? { force: true } : {}
745
+ });
746
+ if (details.skipped) {
747
+ if (details.lockFileExists) throw new GitApiError(this.gcLockFileMessage());
748
+ if (this._auto) return skipped("running");
749
+ const holder = details.lockHolder;
750
+ throw new GitApiError(`fatal: gc is already running on machine '${holder?.machine}' pid ${holder?.pid} (use --force if not)`);
751
+ }
752
+ const storage = details.storage;
753
+ const allErrors = [
754
+ ...this.alternatesErrors(),
755
+ ...errors,
756
+ ...details.errors ?? []
757
+ ];
758
+ const uniqueErrors = allErrors.filter((line, i) => !this.alternatesErrors().includes(line) || allErrors.indexOf(line) === i);
759
+ return {
760
+ objectsRemoved: storage ? storage.before.objects - storage.after.objects : 0,
761
+ bytesFreed: storage ? storage.before.bytes - storage.after.bytes : 0,
762
+ refsPacked,
763
+ durationMs: Date.now() - startTime,
764
+ worktreesPruned,
765
+ ...this._auto ? { messages } : {},
766
+ ...uniqueErrors.length > 0 ? { errors: uniqueErrors } : {},
767
+ ...details.warnings ? { warnings: details.warnings } : {},
768
+ details
769
+ };
770
+ }
771
+ /** git's `unable_to_lock_die` for `gc.pid.lock` (2.43's longer advice under its compatibility). */
772
+ gcLockFileMessage() {
773
+ const gitDir = this.workingCopy.config?.hostGitDir;
774
+ return `fatal: Unable to create '${gitDir ? `${gitDir.replace(/\/+$/, "")}/gc.pid.lock` : ".git/gc.pid.lock"}': File exists.\n\n${this.hooks.compatibility === "2.43" ? "Another git process seems to be running in this repository, e.g.\nan editor opened by 'git commit'. Please make sure all processes\nare terminated then try again. If it still fails, a git process\nmay have crashed in this repository earlier:\nremove the file manually to continue." : "Another git process seems to be running in this repository, or the lock file may be stale"}`;
775
+ }
776
+ };
777
+ //#endregion
10
778
  //#region src/commands/read-tree-command.ts
11
779
  /**
12
780
  * `git read-tree` (builtin/read-tree.c over unpack-trees.c): read trees into the index,
@@ -838,6 +1606,14 @@ async function withLocalUploadPack(remote, run, options = {}) {
838
1606
  ...options.protocolVersion === 1 ? { announceVersion1: true } : {},
839
1607
  uploadPackHideRefs: settings.uploadPackHideRefs,
840
1608
  ...settings.uploadPackFilter ? { uploadPackFilter: settings.uploadPackFilter } : {},
1609
+ ...settings.uploadPackRequestPolicy ? { uploadPackRequestPolicy: settings.uploadPackRequestPolicy } : {},
1610
+ ...settings.allowRefInWant ? { allowRefInWant: true } : {},
1611
+ ...settings.allowSidebandAll ? { allowSidebandAll: true } : {},
1612
+ ...settings.blobPackfileUris?.length ? { blobPackfileUris: settings.blobPackfileUris } : {},
1613
+ ...settings.bundleUris !== void 0 ? { bundleUris: settings.bundleUris } : {},
1614
+ ...settings.advertiseSID ? { advertiseSID: true } : {},
1615
+ ...settings.advertiseObjectInfo ? { advertiseObjectInfo: true } : {},
1616
+ ...settings.promisorRemoteInfo !== void 0 ? { promisorRemoteInfo: settings.promisorRemoteInfo } : {},
841
1617
  ...head && "target" in head ? { currentBranch: head.target } : {}
842
1618
  }))().finally(() => server.close?.());
843
1619
  try {
@@ -901,6 +1677,32 @@ function servedMaxTreeDepth(remote) {
901
1677
  if (value === void 0 || value === null) return void 0;
902
1678
  return parseGitInt(value);
903
1679
  }
1680
+ /**
1681
+ * receive-pack's check of a push certificate's signature (`prepare_push_cert_sha1`'s
1682
+ * `check_signature`): the served repository's `gpg.*`, the host's verifier (none: git's result
1683
+ * when its program cannot run). A signature of no known format dies as git dies.
1684
+ */
1685
+ function pushCertVerifierOf(remote, hooks) {
1686
+ return async (payload, signature) => {
1687
+ const environment = hooks?.hostEnvironment;
1688
+ const entries = () => (remote.config?.listWithOrigin?.() ?? remote.config?.list() ?? []).map((e) => ({
1689
+ key: e.key.toLowerCase(),
1690
+ text: e.value ?? void 0,
1691
+ ...e.file !== void 0 ? { file: e.file } : {},
1692
+ ...e.line !== void 0 ? { line: e.line } : {}
1693
+ }));
1694
+ const cwd = await hooks?.hostGitDir().catch(() => void 0);
1695
+ const check = await checkSignatureWith(() => signingConfigFromEntries(entries(), environment), environment?.verifier, payload, signature, {
1696
+ payloadType: "push-cert",
1697
+ ...cwd !== void 0 ? { cwd } : {}
1698
+ });
1699
+ return {
1700
+ result: check.result,
1701
+ ...check.signer !== void 0 ? { signer: check.signer } : {},
1702
+ ...check.key !== void 0 ? { key: check.key } : {}
1703
+ };
1704
+ };
1705
+ }
904
1706
  /** What git's upload-pack and receive-pack read from the served repository's config. */
905
1707
  function serverSettingsOf(remote) {
906
1708
  const config = remote.config;
@@ -1094,6 +1896,14 @@ async function receivePackSettingsOf(remote, hooks, receiveHooks = hooks?.enable
1094
1896
  denyDeleteCurrent: settings.denyDeleteCurrent,
1095
1897
  shallowUpdate: settings.shallowUpdate,
1096
1898
  advertisePushOptions: settings.advertisePushOptions,
1899
+ ...settings.advertiseSID ? { advertiseSID: true } : {},
1900
+ ...settings.advertiseAtomic !== void 0 ? { advertiseAtomic: settings.advertiseAtomic } : {},
1901
+ ...settings.maxInputSize !== void 0 ? { maxInputSize: settings.maxInputSize } : {},
1902
+ ...settings.certNonceSeed !== void 0 ? { certNonceSeed: settings.certNonceSeed } : {},
1903
+ ...settings.certNonceSlop !== void 0 ? { certNonceSlop: settings.certNonceSlop } : {},
1904
+ pushCertificates: { verify: pushCertVerifierOf(remote, hooks) },
1905
+ ...settings.unpackLimit !== void 0 ? { unpackLimit: settings.unpackLimit } : {},
1906
+ ...settings.receiveKeepAliveMs !== void 0 ? { receiveKeepAliveMs: settings.receiveKeepAliveMs } : {},
1097
1907
  uploadPackHideRefs: settings.uploadPackHideRefs,
1098
1908
  receivePackHideRefs: settings.receivePackHideRefs,
1099
1909
  ...receiveHooks ? {
@@ -1108,12 +1918,88 @@ async function receivePackSettingsOf(remote, hooks, receiveHooks = hooks?.enable
1108
1918
  ...hooks?.enabled && hooks.compatibility !== "2.43" ? { batchNonAtomic: true } : {},
1109
1919
  ...hooks?.enabled && hooks.compatibility === "2.43" ? { interleaveUpdateHook: true } : {},
1110
1920
  ...checkedOut ? { checkedOutBranches: checkedOut } : {},
1921
+ ...afterPushOf(remote, hooks),
1111
1922
  ...worktrees ? { updateWorktree: async (ref, newOid, ctx) => {
1112
1923
  const verdict = await pushToCheckout(hooks, worktrees, ref, newOid, ctx);
1113
1924
  return verdict === null ? pushToDeploy(worktrees, ref, newOid) : verdict;
1114
1925
  } } : {}
1115
1926
  };
1116
1927
  }
1928
+ /** git's `git_config_bool` of the last value of `key` in `remote`'s config, else `fallback`. */
1929
+ function remoteBool(remote, key, fallback) {
1930
+ const value = remote.config?.getAll(key).at(-1);
1931
+ if (value === void 0) return fallback;
1932
+ if (value === null) return true;
1933
+ return parseGitBool(value) ?? fallback;
1934
+ }
1935
+ /**
1936
+ * run-command.c's `prepare_auto_maintenance`: whether git runs `maintenance run --auto` after a
1937
+ * command (`maintenance.auto`, else `gc.auto` greater than 0, else yes).
1938
+ */
1939
+ function autoMaintenanceEnabled(remote) {
1940
+ const auto = remote.config?.getAll("maintenance.auto").at(-1);
1941
+ if (auto !== void 0) return auto === null ? true : parseGitBool(auto) ?? true;
1942
+ const gcAuto = remote.config?.getAll("gc.auto").at(-1);
1943
+ if (gcAuto !== void 0 && gcAuto !== null) {
1944
+ const n = parseGitInt(gcAuto);
1945
+ if (n !== void 0) return n > 0;
1946
+ }
1947
+ return true;
1948
+ }
1949
+ /**
1950
+ * What git's receive-pack does once a push is done (`ReceivePackConfig.afterPush`), after
1951
+ * post-receive and post-update: `receive.autogc` (default true) runs the auto maintenance:
1952
+ * git 2.5x's `maintenance run --auto --quiet` when `prepare_auto_maintenance` allows it
1953
+ * (`maintenance.auto`, else `gc.auto` above 0), with the maintenance strategy and each task's
1954
+ * condition (`MaintenanceRunCommand`), git 2.43's `gc --auto --quiet` (the receive side's
1955
+ * hook runner tells the version); `receive.updateServerInfo` (default false)
1956
+ * `update-server-info`. Nothing when neither applies.
1957
+ */
1958
+ function afterPushOf(remote, hooks) {
1959
+ const v243 = hooks?.compatibility === "2.43";
1960
+ const autoGc = remoteBool(remote, "receive.autogc", true) && (v243 || autoMaintenanceEnabled(remote)) && remote.worktrees !== void 0 && remote.history.packs !== void 0;
1961
+ const serverInfo = remoteBool(remote, "receive.updateServerInfo", false) && remote.files !== void 0 && remote.history.objects !== void 0 && remote.history.packs !== void 0;
1962
+ if (!autoGc && !serverInfo) return {};
1963
+ return { afterPush: async (ctx) => {
1964
+ if (autoGc && remote.worktrees) {
1965
+ const admin = await remote.worktrees.openAdmin();
1966
+ const workingCopy = withEnvironment(worktreeAdminWorkingCopy(admin), hooks?.hostEnvironment);
1967
+ let lines;
1968
+ if (v243) {
1969
+ const result = await new GarbageCollectCommand(workingCopy).setAuto(true).setQuiet(true).call();
1970
+ lines = [...result.errors ?? [], ...result.warnings ?? []];
1971
+ } else {
1972
+ const { MaintenanceRunCommand } = await import("./maintenance-run-command-Cx2PlGV9.js").then((n) => n.r);
1973
+ lines = (await new MaintenanceRunCommand(workingCopy).setAuto(true).setQuiet(true).call()).stderr.split("\n").filter((l) => l.length > 0);
1974
+ }
1975
+ if (lines.length > 0) await ctx.message(`${lines.join("\n")}\n`);
1976
+ }
1977
+ const { files } = remote;
1978
+ const { objects, packs } = remote.history;
1979
+ if (serverInfo && files && objects && packs) {
1980
+ const gitDir = (remote.commonDir ?? remote.gitDir).replace(/^\/+/, "").replace(/\/+$/, "");
1981
+ await updateServerInfo({
1982
+ files,
1983
+ gitDir,
1984
+ objects,
1985
+ packs
1986
+ });
1987
+ }
1988
+ } };
1989
+ }
1990
+ /**
1991
+ * `workingCopy` whose configuration answers `environment` (see `hostEnvironmentOf`) with
1992
+ * `environment`; itself without one.
1993
+ */
1994
+ function withEnvironment(workingCopy, environment) {
1995
+ if (!environment) return workingCopy;
1996
+ const own = (target, key) => {
1997
+ const value = Reflect.get(target, key, target);
1998
+ return typeof value === "function" ? value.bind(target) : value;
1999
+ };
2000
+ const config = new Proxy(workingCopy.config, { get: (target, key) => key === "environment" ? environment : own(target, key) });
2001
+ return new Proxy(workingCopy, { get: (target, key) => key === "config" ? config : own(target, key) });
2002
+ }
1117
2003
  async function receiveOver(remote, run, hooks, receiveHooks, version1, options = {}) {
1118
2004
  const [client, server] = createDuplexPair();
1119
2005
  const host = options.host ?? {};
@@ -1310,6 +2196,16 @@ function scriptReceiveHooks(hooks) {
1310
2196
  });
1311
2197
  return env;
1312
2198
  };
2199
+ const certEnv = async (name, ctx) => {
2200
+ if (!ctx.pushCertificate) return {};
2201
+ try {
2202
+ if (!await hooks.exists(name)) return {};
2203
+ return pushCertificateEnv(await ctx.pushCertificate());
2204
+ } catch (error) {
2205
+ if (error instanceof GitApiError && error.message.startsWith("fatal: ")) throw new ReceivePackDiedError(error.message.slice(7));
2206
+ throw error;
2207
+ }
2208
+ };
1313
2209
  const run = async (name, ctx, options) => {
1314
2210
  const result = await hooks.run(name, {
1315
2211
  ...options,
@@ -1317,6 +2213,7 @@ function scriptReceiveHooks(hooks) {
1317
2213
  ...hookClientEnv(hooks, ctx),
1318
2214
  GIT_DIR: ".",
1319
2215
  ...await quarantineEnv(hooks, ctx),
2216
+ ...name === "update" ? {} : await certEnv(name, ctx),
1320
2217
  ...options.env ?? {}
1321
2218
  },
1322
2219
  prefix: false
@@ -1351,10 +2248,37 @@ function scriptReceiveHooks(hooks) {
1351
2248
  const refs = commands.filter((c) => !c.report).map((c) => c.pushedRef ?? c.refName);
1352
2249
  if (refs.length > 0) await run("post-update", ctx, { args: refs });
1353
2250
  },
1354
- procReceive: (ctx) => hooks.start("proc-receive", {
2251
+ ...hooks.compatibility === "2.43" ? {} : { receiveReport: async (report, ctx) => {
2252
+ const started = await hooks.start("receive-report", {
2253
+ env: {
2254
+ ...hookClientEnv(hooks, ctx),
2255
+ GIT_DIR: "."
2256
+ },
2257
+ prefix: false,
2258
+ onStderr: (text) => ctx.message(text)
2259
+ });
2260
+ if (!started) return void 0;
2261
+ const chunks = [];
2262
+ const reading = (async () => {
2263
+ for await (const chunk of started.stdout) chunks.push(chunk);
2264
+ })().catch(() => {});
2265
+ await started.write(report).catch(() => {});
2266
+ await started.closeStdin().catch(() => {});
2267
+ await reading;
2268
+ if (await started.wait() !== 0) return false;
2269
+ const out = new Uint8Array(chunks.reduce((n, c) => n + c.length, 0));
2270
+ let at = 0;
2271
+ for (const c of chunks) {
2272
+ out.set(c, at);
2273
+ at += c.length;
2274
+ }
2275
+ return out;
2276
+ } },
2277
+ procReceive: async (ctx) => hooks.start("proc-receive", {
1355
2278
  env: {
1356
2279
  ...hookClientEnv(hooks, ctx),
1357
- GIT_DIR: "."
2280
+ GIT_DIR: ".",
2281
+ ...await certEnv("proc-receive", ctx)
1358
2282
  },
1359
2283
  prefix: false,
1360
2284
  onStderr: (text) => ctx.message(text)
@@ -1371,8 +2295,11 @@ function scriptReceiveHooks(hooks) {
1371
2295
  * registry names for it (smart HTTP by default).
1372
2296
  */
1373
2297
  var remote_transport_exports = /* @__PURE__ */ __exportAll({
2298
+ bundleRemoteOf: () => bundleRemoteOf,
1374
2299
  checkTransportAllowed: () => checkTransportAllowed,
2300
+ httpSessionSettings: () => httpSessionSettings,
1375
2301
  isTransportAllowed: () => isTransportAllowed,
2302
+ openBundleRemote: () => openBundleRemote,
1376
2303
  openResolvedRemote: () => openResolvedRemote,
1377
2304
  prepareRemote: () => prepareRemote,
1378
2305
  protocolVersionOf: () => protocolVersionOf,
@@ -1504,11 +2431,57 @@ async function prepareRemote(workingCopy, url, transports) {
1504
2431
  /** A resolved remote with its local repository opened ({@link prepareRemote}'s second half). */
1505
2432
  async function openResolvedRemote(workingCopy, resolved) {
1506
2433
  if (resolved.kind !== "local") return resolved;
2434
+ const bundle = await openBundleRemote(workingCopy, resolved.url, resolved.path);
2435
+ if (bundle) return {
2436
+ kind: "bundle",
2437
+ url: resolved.url,
2438
+ path: resolved.path,
2439
+ remote: bundle
2440
+ };
1507
2441
  return {
1508
2442
  ...resolved,
1509
2443
  repository: await openLocalRemote(workingCopy, resolved.path)
1510
2444
  };
1511
2445
  }
2446
+ /**
2447
+ * transport_get's `url_is_local_not_ssh(url) && is_file(url) && is_bundle(url, 1)`: a path
2448
+ * (not a `file://` URL) to a regular file whose header reads as a bundle's, with what checks
2449
+ * it against `workingCopy` (the repository fetching); undefined for anything else.
2450
+ */
2451
+ async function openBundleRemote(workingCopy, url, path) {
2452
+ if (/^file:/i.test(url)) return void 0;
2453
+ const bytes = await repositoryPlaceOf(workingCopy)?.readLocalFile?.(path).catch(() => void 0);
2454
+ if (!bytes) return void 0;
2455
+ return bundleRemoteOf(workingCopy, bytes, path);
2456
+ }
2457
+ /**
2458
+ * A bundle's bytes as a remote of `workingCopy` (the repository fetching): undefined when
2459
+ * they do not read as a bundle. `name` is how git reports it (its path as given).
2460
+ */
2461
+ function bundleRemoteOf(workingCopy, bytes, name) {
2462
+ const opened = openBundle(bytes, name);
2463
+ if (!opened.ok) return void 0;
2464
+ const history = workingCopy.history;
2465
+ return {
2466
+ bundle: opened.bundle,
2467
+ verify: () => verifyBundleIn({
2468
+ history,
2469
+ refValues: () => refValuesOf(history.refs),
2470
+ shallow: async () => await history.refs.getShallow?.().catch(() => void 0) ?? []
2471
+ }, opened.bundle.header)
2472
+ };
2473
+ }
2474
+ /** Every ref's value and HEAD's (what `rev-list --all` starts from). */
2475
+ async function refValuesOf(refs) {
2476
+ const out = /* @__PURE__ */ new Set();
2477
+ for await (const ref of refs.list()) {
2478
+ const id = "objectId" in ref && ref.objectId ? ref.objectId : (await refs.resolve(ref.name).catch(() => void 0))?.objectId;
2479
+ if (id) out.add(id);
2480
+ }
2481
+ const head = (await refs.resolve("HEAD").catch(() => void 0))?.objectId;
2482
+ if (head) out.add(head);
2483
+ return [...out];
2484
+ }
1512
2485
  /** The resolution context of a working copy: its configuration and host environment. */
1513
2486
  function remoteContextOf(workingCopy, transports) {
1514
2487
  const environment = hostEnvironmentOf(workingCopy);
@@ -1518,6 +2491,24 @@ function remoteContextOf(workingCopy, transports) {
1518
2491
  transports
1519
2492
  };
1520
2493
  }
2494
+ /**
2495
+ * The dumb-HTTP settings a session takes from the configuration and the environment
2496
+ * (`http.followRedirects` and the other `http.*` keys come with `httpSettings`): which
2497
+ * alternates a dumb fetch may use (http-walker's `is_transport_allowed(<scheme>, 0)`: as a
2498
+ * transport not from the user) and `$GIT_SMART_HTTP`.
2499
+ */
2500
+ function httpSessionSettings(workingCopy) {
2501
+ const config = RemoteConfigStore.from(workingCopy);
2502
+ const environment = hostEnvironmentOf(workingCopy);
2503
+ const notFromUser = {
2504
+ ...environment,
2505
+ protocolFromUser: false
2506
+ };
2507
+ return {
2508
+ alternateAllowed: (scheme) => isTransportAllowed(scheme, config, notFromUser),
2509
+ ...environment?.smartHttp === false ? { smartHttp: false } : {}
2510
+ };
2511
+ }
1521
2512
  function connectRequest(remote, service, options) {
1522
2513
  return {
1523
2514
  url: remote.parsed,
@@ -1527,7 +2518,9 @@ function connectRequest(remote, service, options) {
1527
2518
  ...options.credentials ? { credentials: options.credentials } : {},
1528
2519
  ...options.headers ? { headers: options.headers } : {},
1529
2520
  ...options.timeout !== void 0 ? { timeout: options.timeout } : {},
1530
- ...options.signal ? { signal: options.signal } : {}
2521
+ ...options.signal ? { signal: options.signal } : {},
2522
+ ...options.httpSettings ? { http: options.httpSettings(remote.url) } : {},
2523
+ ...options.credentialHelper ? { credentialHelper: options.credentialHelper } : {}
1531
2524
  };
1532
2525
  }
1533
2526
  /**
@@ -1574,8 +2567,13 @@ async function withRemoteSession(remote, service, options, run) {
1574
2567
  */
1575
2568
  async function withRemoteUploadPack(remote, options, run) {
1576
2569
  if (remote.kind === "local") return withLocalUploadPack(remote.repository, run, { protocolVersion: options.protocolVersion });
2570
+ if (remote.kind === "bundle") return withBundleUploadPack(remote.remote, createDuplexPair, run);
1577
2571
  return withRemoteSession(remote, "git-upload-pack", options, async (session, request) => {
1578
- const connection = await openUploadPack(session, request, { ...options.gzipRequests !== void 0 ? { gzipRequests: options.gzipRequests } : {} });
2572
+ const connection = await openUploadPack(session, request, {
2573
+ ...options.gzipRequests !== void 0 ? { gzipRequests: options.gzipRequests } : {},
2574
+ ...options.alternateAllowed ? { alternateAllowed: options.alternateAllowed } : {},
2575
+ ...options.smartHttp === false ? { smartHttp: false } : {}
2576
+ });
1579
2577
  try {
1580
2578
  return await run(connection);
1581
2579
  } finally {
@@ -1589,6 +2587,7 @@ async function withRemoteUploadPack(remote, options, run) {
1589
2587
  * connector opens (`openReceivePack`).
1590
2588
  */
1591
2589
  async function withRemoteReceivePack(remote, options, run, hooks, transactionHooks, local = {}) {
2590
+ if (remote.kind === "bundle") throw new TransportError$1(`error: failed to push some refs to '${remote.url}'`, void 0, { exitCode: 1 });
1592
2591
  if (remote.kind === "local") return withLocalReceivePack(remote.repository, run, hooks, transactionHooks, {
1593
2592
  protocolVersion: options.protocolVersion,
1594
2593
  ...local
@@ -1603,4 +2602,4 @@ async function withRemoteReceivePack(remote, options, run, hooks, transactionHoo
1603
2602
  });
1604
2603
  }
1605
2604
  //#endregion
1606
- export { ReadTreeCommand as _, remote_transport_exports as a, withRemoteUploadPack as c, receiveFsckSettingsOf as d, receivePackSettingsOf as f, withReceiveTransactionHook as g, servedUseBitmaps as h, remoteContextOf as i, httpBackendEnv as l, servedMaxTreeDepth as m, prepareRemote as n, resolveRemote as o, remoteHookSession as p, protocolVersionOf as r, withRemoteReceivePack as s, openResolvedRemote as t, quarantineEnv as u };
2605
+ export { V3_BUNDLE_SIGNATURE as A, WorktreePruneCommand as C, openBundle as D, bundleBytes as E, listBundleRefs as M, parseBundleHeader as N, verifyBundleIn as O, GarbageCollectCommand as S, withBundleUploadPack as T, remoteHookSession as _, protocolVersionOf as a, withReceiveTransactionHook as b, resolveRemote as c, withRemoteUploadPack as d, createDuplexPair as f, receivePackSettingsOf as g, receiveFsckSettingsOf as h, prepareRemote as i, encodeBundleHeader as j, V2_BUNDLE_SIGNATURE as k, withRemoteReceivePack as l, quarantineEnv as m, httpSessionSettings as n, remoteContextOf as o, httpBackendEnv as p, openResolvedRemote as r, remote_transport_exports as s, bundleRemoteOf as t, withRemoteSession as u, servedMaxTreeDepth as v, BundlePrerequisitesError as w, ReadTreeCommand as x, servedUseBitmaps as y };