@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
@@ -12,6 +12,7 @@ import {
12
12
  getWorktreeEntries,
13
13
  IndexPathLookup,
14
14
  type IndexStatUpdate,
15
+ invalidateUntrackedPath,
15
16
  isCleanByStat,
16
17
  modeFromWorktree,
17
18
  readConvertedContent,
@@ -462,7 +463,8 @@ export class StatusCommand extends GitCommand<Status> {
462
463
  /**
463
464
  * Whether the stats refreshed while comparing (and a changed untracked cache) are written
464
465
  * back to the index (default true, as `git status`). A caller holding the index with
465
- * edits of its own (a commit's prepared index) passes false.
466
+ * edits of its own (a commit's prepared index) passes false. The environment's
467
+ * `optionalLocks: false` (`GIT_OPTIONAL_LOCKS=0`) turns the write off too.
466
468
  */
467
469
  setWriteIndex(write: boolean): this {
468
470
  this.checkCallable();
@@ -885,12 +887,20 @@ export class StatusCommand extends GitCommand<Status> {
885
887
  // (git's preload_index), each entry then compared synchronously where its stat settles
886
888
  // it, so only the few undecided ones (racy, changed, submodules) cost a promise
887
889
  const matchAll = this.paths.length === 0;
890
+ // the file system monitor, asked once for this index (git's tweak_fsmonitor at read):
891
+ // entries it reported nothing for since its token are up to date without an lstat
892
+ const fsm = worktree ? await this.fsmonitorRefresh(this.staging) : undefined;
893
+ const fsmValid = (entry: StagingEntry) => !!fsm && fsm.state.isValid(entry);
894
+ // entries refresh_index replaces (stat stored): their directories' untracked lists go
895
+ // too (replace_index_entry's mark_fsmonitor_invalid, with the monitor on)
896
+ const replacedPaths: string[] = [];
888
897
  const stated = (entry: StagingEntry) =>
889
898
  !!worktree &&
890
899
  entry.stage === 0 &&
891
900
  !entry.skipWorktree &&
892
901
  !entry.assumeValid &&
893
902
  !isGitlink(entry.mode) &&
903
+ !fsmValid(entry) &&
894
904
  (matchAll || this.matchesTracked(entry.path, entry.mode));
895
905
  const all = this.staging.entryList?.() ?? (await collectEntries(this.staging.entries()));
896
906
  // `:(attr:...)`: the attributes of the tracked paths the pathspec may match
@@ -957,12 +967,16 @@ export class StatusCommand extends GitCommand<Status> {
957
967
  if (worktree && (entry.skipWorktree || entry.assumeValid)) {
958
968
  // git's refresh takes these as up to date (CE_SKIP_WORKTREE, CE_VALID)
959
969
  if (isIgnoreFilePath(entry.path)) upToDate.add(entry.path);
970
+ } else if (worktree && entry.stage === 0 && fsmValid(entry)) {
971
+ // CE_FSMONITOR_VALID: taken as up to date, never stat'ed (refresh_cache_ent)
972
+ if (isIgnoreFilePath(entry.path)) upToDate.add(entry.path);
960
973
  } else if (
961
974
  current !== undefined &&
962
975
  isCleanByStat(entry, current, trust as WorktreeModeTrust, indexTime)
963
976
  ) {
964
977
  // clean by its stat: nothing to report, nothing to refresh
965
978
  if (isIgnoreFilePath(entry.path)) upToDate.add(entry.path);
979
+ if (!entry.intentToAdd) fsm?.state.markValid(entry);
966
980
  } else if (worktree) {
967
981
  const flags = isGitlink(entry.mode) ? await this.worktreeFlags(entry.path) : undefined;
968
982
  if (!flags?.all) {
@@ -973,9 +987,18 @@ export class StatusCommand extends GitCommand<Status> {
973
987
  worktreeMode = result.worktreeMode;
974
988
  // proved clean only by hashing: its fresh stat goes into the index (git's refresh);
975
989
  // changed behind a matching stat: smudged
990
+ let replaced = false;
976
991
  if (result.hashedId !== undefined || result.smudge) {
977
992
  const update = statUpdateOf(entry, result);
978
- if (update) refresh.push(update);
993
+ if (update) {
994
+ refresh.push(update);
995
+ replaced = true;
996
+ if (fsm) replacedPaths.push(entry.path);
997
+ }
998
+ }
999
+ // up to date and kept as it is: mark_fsmonitor_valid (a replaced entry is not)
1000
+ if (!result.kind && !replaced && !flags && !entry.intentToAdd) {
1001
+ fsm?.state.markValid(entry);
979
1002
  }
980
1003
  if (!result.kind && isIgnoreFilePath(entry.path)) upToDate.add(entry.path);
981
1004
  if (flags && result.kind === "modified") commitChanged = true;
@@ -1041,7 +1064,7 @@ export class StatusCommand extends GitCommand<Status> {
1041
1064
  }
1042
1065
 
1043
1066
  const renamed = new Map<string, string>();
1044
- const warnings: string[] = [];
1067
+ const warnings: string[] = (fsm?.warnings ?? []).map((w) => `warning: ${w}`);
1045
1068
  const renameMode = this.renameMode();
1046
1069
  if (renameMode) await this.pairRenames(files, renamed, worktree, warnings, renameMode);
1047
1070
 
@@ -1054,6 +1077,12 @@ export class StatusCommand extends GitCommand<Status> {
1054
1077
  host,
1055
1078
  this.objectFormat,
1056
1079
  );
1080
+ // the directories of the paths the monitor reported (invalidated in the staging's cache
1081
+ // by the refresh) and of the entries refreshed are read again
1082
+ const fsmInvalidated = !!fsm && (fsm.untrackedPaths.length > 0 || replacedPaths.length > 0);
1083
+ if (fsm && untrackedCache.cache) {
1084
+ for (const path of replacedPaths) invalidateUntrackedPath(untrackedCache.cache, path);
1085
+ }
1057
1086
  if (worktree && this.resolvedUntracked !== "no") {
1058
1087
  // git's wt_status_collect_untracked: the dir flags of the modes
1059
1088
  let flags =
@@ -1086,6 +1115,8 @@ export class StatusCommand extends GitCommand<Status> {
1086
1115
  flags,
1087
1116
  ...(matchAll ? {} : { matcher: untrackedScanPathspec(this.pathspec, attributes) }),
1088
1117
  ...(cache ? { cache } : {}),
1118
+ // with the monitor's answer, the cache's valid directories are trusted unstat'ed
1119
+ ...(cache && fsm?.state.useForUntracked ? { trustValidDirectories: true } : {}),
1089
1120
  indexSeconds: Math.floor(indexTime / 1000),
1090
1121
  ...(trust ? { stat: { ctime: trust.ctime, fullStat: trust.fullStat } } : {}),
1091
1122
  // git's "could not open directory" for each directory its scan cannot list
@@ -1102,12 +1133,18 @@ export class StatusCommand extends GitCommand<Status> {
1102
1133
  }
1103
1134
 
1104
1135
  // as git status: the refreshed stats written back when the index is free and unchanged,
1105
- // with the untracked cache when it changed
1106
- if (this.writeIndex) {
1136
+ // with the untracked cache when it changed; never under `GIT_OPTIONAL_LOCKS=0` (`git
1137
+ // --no-optional-locks`: cmd_status takes the index lock only when use_optional_locks())
1138
+ if (this.writeIndex && hostEnvironmentOf(this.workingCopy)?.optionalLocks !== false) {
1139
+ const changed = untrackedCache.changed();
1107
1140
  await refreshIndexStats(
1108
1141
  this.staging,
1109
1142
  refresh,
1110
- untrackedCache.changed() ? { untrackedCache: untrackedCache.cache ?? null } : undefined,
1143
+ changed
1144
+ ? { untrackedCache: untrackedCache.cache ?? null }
1145
+ : fsmInvalidated && untrackedCache.cache
1146
+ ? { carriedUntrackedCache: untrackedCache.cache }
1147
+ : undefined,
1111
1148
  );
1112
1149
  }
1113
1150
 
@@ -0,0 +1,118 @@
1
+ /**
2
+ * `git stripspace` (builtin/stripspace.c): a message cleaned up as `strbuf_stripspace`
3
+ * cleans it (`-s` also drops comment lines), or every line commented out (`-c`,
4
+ * `strbuf_add_commented_lines`).
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * // printf 'a \n\n\n# c\nb' | git stripspace -s
9
+ * await git.stripspace().setInput("a \n\n\n# c\nb").setMode("strip-comments").call();
10
+ * // { exitCode: 0, stdout: "a\n\nb\n", stderr: "" }
11
+ * ```
12
+ */
13
+
14
+ import { decodeGitPath } from "@statewalker/vcs-utils/encoding";
15
+
16
+ import { GitCommand } from "../git-command.js";
17
+ import { RemoteConfigStore } from "../remote-config/index.js";
18
+ import type { PlumbingTextOutput } from "./check-ref-format-command.js";
19
+ import { stripspace } from "./message-cleanup.js";
20
+
21
+ /** `git stripspace`'s modes: no option, `-s` (`--strip-comments`), `-c` (`--comment-lines`). */
22
+ export type StripspaceMode = "default" | "strip-comments" | "comment-lines";
23
+
24
+ /**
25
+ * git's `add_lines` with a space after the prefix (`strbuf_add_commented_lines`): every
26
+ * line prefixed, a space between unless the line is empty or starts with a tab, the last
27
+ * line completed.
28
+ */
29
+ export function commentLines(text: string, commentPrefix: string): string {
30
+ let out = "";
31
+ let i = 0;
32
+ while (i < text.length) {
33
+ const eol = text.indexOf("\n", i);
34
+ const next = eol < 0 ? text.length : eol + 1;
35
+ const first = text[i];
36
+ out += commentPrefix + (first !== "\n" && first !== "\t" ? " " : "") + text.slice(i, next);
37
+ i = next;
38
+ }
39
+ return out.length === 0 || out.endsWith("\n") ? out : `${out}\n`;
40
+ }
41
+
42
+ /**
43
+ * `git stripspace [-s | -c]` over {@link setInput} (git's stdin). The comment string of
44
+ * `-s` and `-c` is `core.commentChar` / `core.commentString` (the last value of either; `auto`
45
+ * is `#`); git dies reading a value it refuses (2.5x: empty or holding a newline; 2.43, which
46
+ * knows only `core.commentChar`: anything but one ASCII character), exit 128 with git's two
47
+ * lines. The default mode reads no configuration.
48
+ */
49
+ export class StripspaceCommand extends GitCommand<PlumbingTextOutput> {
50
+ private input = "";
51
+ private mode: StripspaceMode = "default";
52
+ private compatibility: "2.43" | "2.56" = "2.56";
53
+
54
+ /** The text to clean up (git's stdin); bytes are read as git paths are (`decodeGitPath`). */
55
+ setInput(input: string | Uint8Array): this {
56
+ this.checkCallable();
57
+ this.input = typeof input === "string" ? input : decodeGitPath(input);
58
+ return this;
59
+ }
60
+
61
+ /** `-s` / `-c`; the default only cleans up whitespace. */
62
+ setMode(mode: StripspaceMode): this {
63
+ this.checkCallable();
64
+ this.mode = mode;
65
+ return this;
66
+ }
67
+
68
+ /** The git version whose behaviour to follow (default 2.56). */
69
+ setCompatibility(version: "2.43" | "2.56"): this {
70
+ this.checkCallable();
71
+ this.compatibility = version;
72
+ return this;
73
+ }
74
+
75
+ async call(): Promise<PlumbingTextOutput> {
76
+ this.checkCallable();
77
+ this.setCallable(false);
78
+ if (this.mode === "default") {
79
+ return { exitCode: 0, stdout: stripspace(this.input), stderr: "" };
80
+ }
81
+ const prefix = this.commentString();
82
+ if (typeof prefix !== "string") return { exitCode: 128, stdout: "", stderr: prefix.error };
83
+ const stdout =
84
+ this.mode === "strip-comments"
85
+ ? stripspace(this.input, prefix)
86
+ : commentLines(this.input, prefix);
87
+ return { exitCode: 0, stdout, stderr: "" };
88
+ }
89
+
90
+ /** git_default_core_config's comment settings, each value checked in config order. */
91
+ private commentString(): string | { error: string } {
92
+ const legacy = this.compatibility === "2.43";
93
+ const keys = legacy ? ["core.commentchar"] : ["core.commentchar", "core.commentstring"];
94
+ const config = RemoteConfigStore.from(this._workingCopy);
95
+ let prefix = "#";
96
+ const entries =
97
+ config.entriesWithOriginFor(keys) ??
98
+ keys.flatMap((key) => config.valuesWithOrigin(key).map((where) => ({ key, ...where })));
99
+ for (const { key, text, file, line } of entries) {
100
+ const fatal =
101
+ file !== undefined && line !== undefined
102
+ ? `fatal: bad config variable '${key}' in file '${file}' at line ${line}`
103
+ : `fatal: unable to parse '${key}' from command-line config`;
104
+ let error: string | undefined;
105
+ if (text === undefined) error = `error: missing value for '${key}'`;
106
+ else if (text.toLowerCase() === "auto") prefix = "#";
107
+ else if (legacy) {
108
+ if (text.length !== 1 || text.charCodeAt(0) >= 0x80)
109
+ error = "error: core.commentChar should only be one ASCII character";
110
+ else prefix = text;
111
+ } else if (text === "") error = `error: ${key} must have at least one character`;
112
+ else if (text.includes("\n")) error = `error: ${key} cannot contain newline`;
113
+ else prefix = text;
114
+ if (error) return { error: `${error}\n${fatal}\n` };
115
+ }
116
+ return prefix;
117
+ }
118
+ }
@@ -4,7 +4,7 @@
4
4
  * `submodule-model.ts` and the clone, checkout and add commands.
5
5
  */
6
6
  import { FileMode } from "@statewalker/vcs-core";
7
- import type { GitTransportRegistry } from "@statewalker/vcs-transport";
7
+ import type { GitTransportRegistry, HttpCredentialHelper } from "@statewalker/vcs-transport";
8
8
  import { wildmatch } from "@statewalker/vcs-working-tree";
9
9
 
10
10
  import { GitApiError } from "../errors/index.js";
@@ -154,6 +154,8 @@ export class SubmoduleAddCommand extends SubmoduleCommandBase {
154
154
  private reference?: string;
155
155
  private depth?: number;
156
156
  private transports?: GitTransportRegistry;
157
+ private credentialHelper?: HttpCredentialHelper;
158
+ private warningCallback?: (line: string) => void;
157
159
 
158
160
  /** `<repository>`: the URL to clone (absolute, or `./`/`../` relative to the remote). */
159
161
  setURI(uri: string): this {
@@ -211,6 +213,23 @@ export class SubmoduleAddCommand extends SubmoduleCommandBase {
211
213
  return this;
212
214
  }
213
215
 
216
+ /**
217
+ * A credential helper, as git's `credential.helper` read by the child clone: asked with the
218
+ * submodule URL's host when its server answers 401.
219
+ */
220
+ setCredentialHelper(helper: HttpCredentialHelper): this {
221
+ this.checkCallable();
222
+ this.credentialHelper = helper;
223
+ return this;
224
+ }
225
+
226
+ /** Receives the `warning:` lines of the clone's HTTP client. */
227
+ setWarningCallback(callback: (line: string) => void): this {
228
+ this.checkCallable();
229
+ this.warningCallback = callback;
230
+ return this;
231
+ }
232
+
214
233
  async call(): Promise<SubmoduleCommandResult> {
215
234
  this.start();
216
235
  if (!(await this.writingGitmodulesOk())) {
@@ -425,6 +444,8 @@ export class SubmoduleAddCommand extends SubmoduleCommandBase {
425
444
  ...(this.depth !== undefined ? { depth: this.depth } : {}),
426
445
  ...(this.reference !== undefined ? { references: [this.reference] } : {}),
427
446
  ...(this.transports ? { transports: this.transports } : {}),
447
+ ...(this.credentialHelper ? { credentialHelper: this.credentialHelper } : {}),
448
+ ...(this.warningCallback ? { warningCallback: this.warningCallback } : {}),
428
449
  });
429
450
 
430
451
  const inner = await worktree.openGitlink?.(path).catch(() => undefined);
@@ -19,7 +19,9 @@
19
19
  * the commands: a native connector gets them for the URL just checked, and every smart-HTTP
20
20
  * request carries them only when `new URL(request.url).origin` is the approved origin;
21
21
  * redirects are followed by hand (`redirect: "manual"`) so a redirect to another origin
22
- * goes out without them, and an opaque redirect (a browser's) is refused.
22
+ * goes out without them; an opaque redirect (a browser's, whose target cannot be read) is
23
+ * asked again following it with none of them, and they go to where it ended only when
24
+ * that is the approved origin.
23
25
  *
24
26
  * @example
25
27
  * ```typescript
@@ -217,6 +219,37 @@ function guardConnector(
217
219
  }
218
220
 
219
221
  const REDIRECTS = new Set([301, 302, 303, 307, 308]);
222
+
223
+ /**
224
+ * A response the guard reached by following redirects itself, telling where it ended
225
+ * (`response.url`, which the client re-roots its later requests at) when the `fetch` that
226
+ * answered left it empty.
227
+ */
228
+ function landedAt(response: Response, url: string): Response {
229
+ if (response.url) return response;
230
+ Object.defineProperty(response, "url", { value: url });
231
+ Object.defineProperty(response, "redirected", { value: true });
232
+ return response;
233
+ }
234
+
235
+ /** Headers that identify the user: never carried to another origin (curl's rule). */
236
+ const CREDENTIAL_HEADERS = ["authorization", "cookie", "proxy-authorization"];
237
+
238
+ /**
239
+ * The caller's headers for the next hop of a redirect: whatever identifies the user (an
240
+ * `Authorization` from a credential helper or `http.extraHeader`, cookies) is dropped when
241
+ * the hop changes origin, as curl drops it when the host changes.
242
+ */
243
+ function hopHeaders(headers: Headers, from: URL, to: URL): Headers {
244
+ const out = new Headers(headers);
245
+ if (from.origin !== to.origin) for (const name of CREDENTIAL_HEADERS) out.delete(name);
246
+ return out;
247
+ }
248
+
249
+ /** A redirect as the response shows it (a browser's `opaqueredirect` included). */
250
+ function isRedirect(response: Response): boolean {
251
+ return response.type === "opaqueredirect" || REDIRECTS.has(response.status);
252
+ }
220
253
  const MAX_REDIRECTS = 20;
221
254
 
222
255
  /**
@@ -239,14 +272,36 @@ function guardedFetch(
239
272
  for (const name of added.keys()) headers.delete(name);
240
273
  if (target.origin === origin) for (const [name, value] of added) headers.set(name, value);
241
274
  const kept = current.clone();
275
+ const probe = current.clone();
242
276
  const response = await fetchImpl(new Request(current, { headers, redirect: "manual" }));
277
+ // a request that follows no redirect (`http.followRedirects`) gets the redirect itself
278
+ if (request.redirect !== "follow" && isRedirect(response)) return response;
243
279
  if (response.type === "opaqueredirect") {
244
- throw new TransportError(
245
- `redirect refused: its target cannot be checked before credentials are sent (${target.origin})`,
246
- );
280
+ // a browser hides where it leads: ask again, following, with none of the guard's
281
+ // headers; the credentials go only to where that ended, on the approved origin
282
+ if (hops >= MAX_REDIRECTS) throw new TransportError("too many redirects");
283
+ const followed = await fetchImpl(new Request(probe, { redirect: "follow" }));
284
+ let landed: URL | undefined;
285
+ try {
286
+ landed = followed.url ? new URL(followed.url) : undefined;
287
+ } catch {
288
+ landed = undefined;
289
+ }
290
+ if (!landed || landed.href === target.href || landed.origin !== origin) return followed;
291
+ await followed.body?.cancel().catch(() => undefined);
292
+ const body = kept.method === "GET" || kept.method === "HEAD" ? null : kept.body;
293
+ current = new Request(landed, {
294
+ method: kept.method,
295
+ headers: hopHeaders(kept.headers, target, landed),
296
+ ...(body ? { body, duplex: "half" } : {}),
297
+ signal: kept.signal,
298
+ } as RequestInit);
299
+ continue;
247
300
  }
248
301
  const location = response.headers.get("location");
249
- if (!REDIRECTS.has(response.status) || location === null) return response;
302
+ if (!REDIRECTS.has(response.status) || location === null) {
303
+ return hops > 0 ? landedAt(response, current.url) : response;
304
+ }
250
305
  if (hops >= MAX_REDIRECTS) throw new TransportError("too many redirects");
251
306
  await response.body?.cancel().catch(() => undefined);
252
307
  const next = new URL(location, target);
@@ -257,7 +312,7 @@ function guardedFetch(
257
312
  const body = toGet || method === "GET" || method === "HEAD" ? null : kept.body;
258
313
  current = new Request(next, {
259
314
  method,
260
- headers: kept.headers,
315
+ headers: hopHeaders(kept.headers, target, next),
261
316
  ...(body ? { body, duplex: "half" } : {}),
262
317
  signal: kept.signal,
263
318
  } as RequestInit);
@@ -8,9 +8,9 @@
8
8
  */
9
9
  import { FileMode, type ObjectId, objectFormatOf } from "@statewalker/vcs-core";
10
10
  import { isGitDirectory } from "@statewalker/vcs-store-files";
11
- import type { GitTransportRegistry } from "@statewalker/vcs-transport";
11
+ import type { GitTransportRegistry, HttpCredentialHelper } from "@statewalker/vcs-transport";
12
12
  import { decodeGitPath } from "@statewalker/vcs-utils/encoding";
13
- import { type FilesApi, type PosixFilesApi, readFile } from "@statewalker/vcs-utils/files";
13
+ import { type FilesApi, readFile } from "@statewalker/vcs-utils/files";
14
14
  import { computeObjectId } from "@statewalker/vcs-utils/pack";
15
15
  import type { GitHostEnvironment, WorkingCopy } from "@statewalker/vcs-working-tree";
16
16
 
@@ -73,6 +73,14 @@ export interface SubmoduleCloneOptions {
73
73
  */
74
74
  transports?: GitTransportRegistry;
75
75
  timeout?: number;
76
+ /**
77
+ * The credential helper (git's `credential.helper`, which the child clone reads): asked
78
+ * with the submodule's own URL after a 401, so it decides per host; the guarded transports
79
+ * drop what it gave on a redirect to another origin.
80
+ */
81
+ credentialHelper?: HttpCredentialHelper;
82
+ /** git's `warning:` lines of the clone's HTTP client */
83
+ warningCallback?: (line: string) => void;
76
84
  }
77
85
 
78
86
  /** What a submodule command printed, and its exit status. */
@@ -546,6 +554,8 @@ export abstract class SubmoduleCommandBase extends GitCommand<SubmoduleCommandRe
546
554
  if (options.singleBranch !== undefined) clone.setSingleBranch(options.singleBranch);
547
555
  if (options.transports) clone.setTransports(options.transports);
548
556
  if (options.timeout !== undefined) clone.setTimeout(options.timeout);
557
+ if (options.credentialHelper) clone.setCredentialHelper(options.credentialHelper);
558
+ if (options.warningCallback) clone.setWarningCallback(options.warningCallback);
549
559
  clone.shareHooksOf(this);
550
560
  const result = await clone.call();
551
561
  if (!this.quiet) {
@@ -10,6 +10,7 @@ import {
10
10
  type Credentials,
11
11
  createDefaultTransports,
12
12
  type GitTransportRegistry,
13
+ type HttpCredentialHelper,
13
14
  } from "@statewalker/vcs-transport";
14
15
  import type { PosixFilesApi } from "@statewalker/vcs-utils/files";
15
16
  import { type WorkingCopy, wildmatch } from "@statewalker/vcs-working-tree";
@@ -254,6 +255,8 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
254
255
  /** Set once at the top superproject, handed to nested updates unchanged */
255
256
  private authPolicy?: SubmoduleAuthFor;
256
257
  private timeout?: number;
258
+ private credentialHelper?: HttpCredentialHelper;
259
+ private warningCallback?: (line: string) => void;
257
260
 
258
261
  /** A path (pathspec element) limiting the submodules; uninitialized ones are then reported. */
259
262
  addPath(path: string): this {
@@ -453,6 +456,26 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
453
456
  return this.authPolicy;
454
457
  }
455
458
 
459
+ /**
460
+ * A credential helper, as git's `credential.helper` read by its child clones and fetches:
461
+ * asked with each submodule's own URL when its server answers 401 (so it decides per host,
462
+ * at any depth), told when the credentials worked or were refused. Unlike
463
+ * {@link setCredentials}, its answer for one host never goes to another: the client asks
464
+ * it per URL, and the guarded transports drop it on a redirect to another origin.
465
+ */
466
+ setCredentialHelper(helper: HttpCredentialHelper): this {
467
+ this.checkCallable();
468
+ this.credentialHelper = helper;
469
+ return this;
470
+ }
471
+
472
+ /** Receives the `warning:` lines of the clones' and fetches' HTTP clients. */
473
+ setWarningCallback(callback: (line: string) => void): this {
474
+ this.checkCallable();
475
+ this.warningCallback = callback;
476
+ return this;
477
+ }
478
+
456
479
  /** The timeout of clones and fetches, in milliseconds. */
457
480
  setTimeout(timeout: number): this {
458
481
  this.checkCallable();
@@ -643,6 +666,8 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
643
666
  ...(this.singleBranch !== undefined ? { singleBranch: this.singleBranch } : {}),
644
667
  transports: await this.guardedTransports(),
645
668
  ...(this.timeout !== undefined ? { timeout: this.timeout } : {}),
669
+ ...(this.credentialHelper ? { credentialHelper: this.credentialHelper } : {}),
670
+ ...(this.warningCallback ? { warningCallback: this.warningCallback } : {}),
646
671
  });
647
672
  return true;
648
673
  } catch (error) {
@@ -776,6 +801,8 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
776
801
  const fetch = new FetchCommand(inner);
777
802
  fetch.setTransports(await this.guardedTransports());
778
803
  if (this.timeout !== undefined) fetch.setTimeout(this.timeout);
804
+ if (this.credentialHelper) fetch.setCredentialHelper(this.credentialHelper);
805
+ if (this.warningCallback) fetch.setWarningCallback(this.warningCallback);
779
806
  if (this.depth) fetch.setDepth(this.depth);
780
807
  // the remote named, so its URL is known: `git fetch` alone fetches the default remote
781
808
  const remote = target?.remote ?? (await defaultRemoteOf(inner));
@@ -1003,6 +1030,8 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
1003
1030
  // the top superproject's policy: a nested superproject's remote is no trusted origin
1004
1031
  child.setAuthPolicy(await this.auth());
1005
1032
  if (this.timeout !== undefined) child.setTimeout(this.timeout);
1033
+ if (this.credentialHelper) child.setCredentialHelper(this.credentialHelper);
1034
+ if (this.warningCallback) child.setWarningCallback(this.warningCallback);
1006
1035
  let code: number;
1007
1036
  try {
1008
1037
  const result = await child.call();
@@ -0,0 +1,143 @@
1
+ /**
2
+ * The textconv cache (`diff.<driver>.cachetextconv`), as git's notes-cache.c keeps it: the
3
+ * output of a driver's textconv command for a blob is a note on the blob in
4
+ * `refs/notes/textconv/<driver>`, valid while the subject of the ref's commit is the
5
+ * command (the cache's validity). Every entry added is committed at once (a parentless
6
+ * commit whose message is the command, the ref's reflog saying `update notes cache`), as
7
+ * `fill_textconv` writes the cache after each conversion.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const cache = await TextconvCache.open(ctx, "magic", "./helper");
12
+ * const text = (await cache?.get(blobId)) ?? (await run());
13
+ * await cache?.put(blobId, text);
14
+ * ```
15
+ */
16
+ import type { ObjectId } from "@statewalker/vcs-core";
17
+
18
+ import type { TextconvRequest, TextconvRunner } from "./diff-textconv.js";
19
+ import { initNotes, type NotesContext, type NotesHandle, updateNotesRef } from "./notes-support.js";
20
+ import { combineNotesOverwrite, readNoteBytes } from "./notes-tree.js";
21
+
22
+ /** pretty.c's `%s` of a message, trimmed: its first paragraph on one line. */
23
+ function subjectOf(message: string): string {
24
+ const lines = message.replace(/^\n+/, "").split("\n");
25
+ const paragraph: string[] = [];
26
+ for (const line of lines) {
27
+ if (line.trim() === "") break;
28
+ paragraph.push(line);
29
+ }
30
+ return paragraph.join(" ").trim();
31
+ }
32
+
33
+ export class TextconvCache {
34
+ /** Puts in progress, one after the other (each commits the tree as it then is) */
35
+ private queue: Promise<void> = Promise.resolve();
36
+
37
+ private constructor(
38
+ private readonly ctx: NotesContext,
39
+ private readonly notes: NotesHandle,
40
+ private readonly validity: string,
41
+ ) {}
42
+
43
+ /**
44
+ * notes_cache_init: the cache of `driver`, empty unless the ref's commit was written for
45
+ * `validity`; undefined when the ref cannot hold a cache (git then caches nothing).
46
+ */
47
+ static async open(
48
+ ctx: NotesContext,
49
+ driver: string,
50
+ validity: string,
51
+ ): Promise<TextconvCache | undefined> {
52
+ const ref = `refs/notes/textconv/${driver}`;
53
+ try {
54
+ const id = (await ctx.refs.resolve(ref).catch(() => undefined))?.objectId ?? undefined;
55
+ const commit = id ? await ctx.commits.load(id).catch(() => undefined) : undefined;
56
+ const valid = commit !== undefined && subjectOf(commit.message) === validity;
57
+ const notes = await initNotes(ctx, ref, {
58
+ combine: combineNotesOverwrite,
59
+ writable: true,
60
+ empty: !valid,
61
+ });
62
+ return new TextconvCache(ctx, notes, validity);
63
+ } catch {
64
+ return undefined;
65
+ }
66
+ }
67
+
68
+ /** notes_cache_get: the output cached for `blob`, if any. */
69
+ async get(blob: ObjectId): Promise<Uint8Array | undefined> {
70
+ await this.queue;
71
+ try {
72
+ const note = await this.notes.tree.get(blob);
73
+ return note ? await readNoteBytes(this.ctx.blobs, note) : undefined;
74
+ } catch {
75
+ return undefined;
76
+ }
77
+ }
78
+
79
+ /**
80
+ * notes_cache_put and notes_cache_write: `output` noted for `blob` and committed; errors
81
+ * are ignored, as git ignores them (a read-only repository).
82
+ */
83
+ put(blob: ObjectId, output: Uint8Array): Promise<void> {
84
+ this.queue = this.queue.then(async () => {
85
+ try {
86
+ const note = await this.ctx.blobs.store([output]);
87
+ await this.notes.tree.add(blob, note, combineNotesOverwrite);
88
+ if (!this.notes.tree.dirty || !this.notes.updateRef) return;
89
+ const tree = await this.notes.tree.write();
90
+ const commit = await this.ctx.commits.store({
91
+ tree,
92
+ parents: [],
93
+ author: this.ctx.author(),
94
+ committer: this.ctx.committer(),
95
+ message: this.validity,
96
+ });
97
+ await updateNotesRef(this.ctx, this.notes.updateRef, commit, "update notes cache");
98
+ } catch {
99
+ // as git: the cache is best effort
100
+ }
101
+ });
102
+ return this.queue;
103
+ }
104
+ }
105
+
106
+ /**
107
+ * diff.c's fill_textconv over the drivers' caches of one command (git's per-process
108
+ * caches, by driver and command): the runner's output, read from and written to the
109
+ * driver's notes cache when it asks for one (`diff.<driver>.cachetextconv`) and the
110
+ * content has an object id git knows (a blob of a tree or the index, never a worktree
111
+ * file's).
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * const caches = new TextconvCaches(() => this.notesContext());
116
+ * const text = await caches.run(runner, request, blobId);
117
+ * ```
118
+ */
119
+ export class TextconvCaches {
120
+ private readonly opened = new Map<string, Promise<TextconvCache | undefined>>();
121
+
122
+ constructor(private readonly context: () => NotesContext) {}
123
+
124
+ async run(
125
+ runner: TextconvRunner,
126
+ request: TextconvRequest,
127
+ id: ObjectId | undefined,
128
+ ): Promise<Uint8Array> {
129
+ if (!request.cache || id === undefined) return runner(request);
130
+ const key = `${request.driver}\0${request.command}`;
131
+ let opened = this.opened.get(key);
132
+ if (!opened) {
133
+ opened = TextconvCache.open(this.context(), request.driver, request.command);
134
+ this.opened.set(key, opened);
135
+ }
136
+ const cache = await opened;
137
+ const cached = await cache?.get(id);
138
+ if (cached) return cached;
139
+ const output = await runner(request);
140
+ await cache?.put(id, output);
141
+ return output;
142
+ }
143
+ }