@statewalker/vcs-commands 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (460) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/add-command.d.ts.map +1 -1
  3. package/dist/commands/add-patch/patch-backend.d.ts +2 -0
  4. package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
  5. package/dist/commands/add-patch/patch-modes.d.ts +6 -2
  6. package/dist/commands/add-patch/patch-modes.d.ts.map +1 -1
  7. package/dist/commands/add-patch/patch-session.d.ts +4 -0
  8. package/dist/commands/add-patch/patch-session.d.ts.map +1 -1
  9. package/dist/commands/am/am-command.d.ts +41 -2
  10. package/dist/commands/am/am-command.d.ts.map +1 -1
  11. package/dist/commands/apply/index.d.ts +1 -1
  12. package/dist/commands/apply/index.d.ts.map +1 -1
  13. package/dist/commands/archive/archive-command.d.ts +169 -0
  14. package/dist/commands/archive/archive-command.d.ts.map +1 -0
  15. package/dist/commands/archive/archive-entry.d.ts +60 -0
  16. package/dist/commands/archive/archive-entry.d.ts.map +1 -0
  17. package/dist/commands/archive/index.d.ts +8 -0
  18. package/dist/commands/archive/index.d.ts.map +1 -0
  19. package/dist/commands/archive/remote-archive-command.d.ts +56 -0
  20. package/dist/commands/archive/remote-archive-command.d.ts.map +1 -0
  21. package/dist/commands/archive/tar-archive.d.ts +31 -0
  22. package/dist/commands/archive/tar-archive.d.ts.map +1 -0
  23. package/dist/commands/archive/tar-commit-id.d.ts +13 -0
  24. package/dist/commands/archive/tar-commit-id.d.ts.map +1 -0
  25. package/dist/commands/archive/upload-archive-writer.d.ts +48 -0
  26. package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -0
  27. package/dist/commands/archive/zip-archive.d.ts +42 -0
  28. package/dist/commands/archive/zip-archive.d.ts.map +1 -0
  29. package/dist/commands/attributes-source.d.ts +10 -0
  30. package/dist/commands/attributes-source.d.ts.map +1 -1
  31. package/dist/commands/blame-command.d.ts +43 -1
  32. package/dist/commands/blame-command.d.ts.map +1 -1
  33. package/dist/commands/bundle/bundle-create-command.d.ts +67 -0
  34. package/dist/commands/bundle/bundle-create-command.d.ts.map +1 -0
  35. package/dist/commands/bundle/bundle-format.d.ts +89 -0
  36. package/dist/commands/bundle/bundle-format.d.ts.map +1 -0
  37. package/dist/commands/bundle/bundle-list.d.ts +92 -0
  38. package/dist/commands/bundle/bundle-list.d.ts.map +1 -0
  39. package/dist/commands/bundle/bundle-read-commands.d.ts +81 -0
  40. package/dist/commands/bundle/bundle-read-commands.d.ts.map +1 -0
  41. package/dist/commands/bundle/bundle-support.d.ts +32 -0
  42. package/dist/commands/bundle/bundle-support.d.ts.map +1 -0
  43. package/dist/commands/bundle/bundle-transport.d.ts +38 -0
  44. package/dist/commands/bundle/bundle-transport.d.ts.map +1 -0
  45. package/dist/commands/bundle/bundle-uri-host.d.ts +43 -0
  46. package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -0
  47. package/dist/commands/bundle/bundle-uri.d.ts +55 -0
  48. package/dist/commands/bundle/bundle-uri.d.ts.map +1 -0
  49. package/dist/commands/bundle/bundle-verify.d.ts +63 -0
  50. package/dist/commands/bundle/bundle-verify.d.ts.map +1 -0
  51. package/dist/commands/bundle/index.d.ts +14 -0
  52. package/dist/commands/bundle/index.d.ts.map +1 -0
  53. package/dist/commands/cat-file/batch-format.d.ts +58 -0
  54. package/dist/commands/cat-file/batch-format.d.ts.map +1 -0
  55. package/dist/commands/cat-file/cat-file-command.d.ts +135 -0
  56. package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -0
  57. package/dist/commands/cat-file/index.d.ts +3 -0
  58. package/dist/commands/cat-file/index.d.ts.map +1 -0
  59. package/dist/commands/check-attr-command.d.ts +66 -0
  60. package/dist/commands/check-attr-command.d.ts.map +1 -0
  61. package/dist/commands/check-ignore-command.d.ts +58 -0
  62. package/dist/commands/check-ignore-command.d.ts.map +1 -0
  63. package/dist/commands/check-ref-format-command.d.ts +60 -0
  64. package/dist/commands/check-ref-format-command.d.ts.map +1 -0
  65. package/dist/commands/checkout-command.d.ts.map +1 -1
  66. package/dist/commands/checkout-index-command.d.ts +96 -0
  67. package/dist/commands/checkout-index-command.d.ts.map +1 -0
  68. package/dist/commands/cherry-pick-command.d.ts +10 -0
  69. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  70. package/dist/commands/clone-command.d.ts +19 -0
  71. package/dist/commands/clone-command.d.ts.map +1 -1
  72. package/dist/commands/commit-command.d.ts +9 -1
  73. package/dist/commands/commit-command.d.ts.map +1 -1
  74. package/dist/commands/config-command.d.ts +2 -0
  75. package/dist/commands/config-command.d.ts.map +1 -1
  76. package/dist/commands/daemon-access-hook.d.ts +36 -0
  77. package/dist/commands/daemon-access-hook.d.ts.map +1 -0
  78. package/dist/commands/default-branch.d.ts +42 -0
  79. package/dist/commands/default-branch.d.ts.map +1 -1
  80. package/dist/commands/diff-command.d.ts +132 -5
  81. package/dist/commands/diff-command.d.ts.map +1 -1
  82. package/dist/commands/diff-external.d.ts +43 -0
  83. package/dist/commands/diff-external.d.ts.map +1 -0
  84. package/dist/commands/diff-plumbing/diff-pairs-command.d.ts +27 -0
  85. package/dist/commands/diff-plumbing/diff-pairs-command.d.ts.map +1 -0
  86. package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts +129 -0
  87. package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts.map +1 -0
  88. package/dist/commands/diff-plumbing/index.d.ts +3 -0
  89. package/dist/commands/diff-plumbing/index.d.ts.map +1 -0
  90. package/dist/commands/diff-textconv.d.ts +5 -1
  91. package/dist/commands/diff-textconv.d.ts.map +1 -1
  92. package/dist/commands/fast-export/fast-export-command.d.ts +135 -0
  93. package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -0
  94. package/dist/commands/fast-export/fast-import-command.d.ts +182 -0
  95. package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -0
  96. package/dist/commands/fast-export/fast-stream-support.d.ts +64 -0
  97. package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -0
  98. package/dist/commands/fast-export/index.d.ts +4 -0
  99. package/dist/commands/fast-export/index.d.ts.map +1 -0
  100. package/dist/commands/fetch-command.d.ts +65 -0
  101. package/dist/commands/fetch-command.d.ts.map +1 -1
  102. package/dist/commands/fetch-multiple-command.d.ts.map +1 -1
  103. package/dist/commands/format-rev-command.d.ts +58 -0
  104. package/dist/commands/format-rev-command.d.ts.map +1 -0
  105. package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
  106. package/dist/commands/fsck/fsck-msg-ids.d.ts +18 -3
  107. package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -1
  108. package/dist/commands/fsmonitor-refresh.d.ts +69 -0
  109. package/dist/commands/fsmonitor-refresh.d.ts.map +1 -0
  110. package/dist/commands/gc-command.d.ts +5 -0
  111. package/dist/commands/gc-command.d.ts.map +1 -1
  112. package/dist/commands/git-hooks.d.ts +32 -0
  113. package/dist/commands/git-hooks.d.ts.map +1 -1
  114. package/dist/commands/git-paths.d.ts +26 -0
  115. package/dist/commands/git-paths.d.ts.map +1 -0
  116. package/dist/commands/grep/grep-command.d.ts +2 -1
  117. package/dist/commands/grep/grep-command.d.ts.map +1 -1
  118. package/dist/commands/history-command.d.ts +156 -0
  119. package/dist/commands/history-command.d.ts.map +1 -0
  120. package/dist/commands/http-config.d.ts +38 -0
  121. package/dist/commands/http-config.d.ts.map +1 -0
  122. package/dist/commands/index-adder.d.ts +12 -1
  123. package/dist/commands/index-adder.d.ts.map +1 -1
  124. package/dist/commands/index-host.d.ts.map +1 -1
  125. package/dist/commands/index.d.ts +44 -1
  126. package/dist/commands/index.d.ts.map +1 -1
  127. package/dist/commands/index.js +6 -5
  128. package/dist/commands/init-command.d.ts.map +1 -1
  129. package/dist/commands/last-modified-command.d.ts +102 -0
  130. package/dist/commands/last-modified-command.d.ts.map +1 -0
  131. package/dist/commands/lfs/go-url.d.ts +43 -0
  132. package/dist/commands/lfs/go-url.d.ts.map +1 -0
  133. package/dist/commands/lfs/index.d.ts +3 -0
  134. package/dist/commands/lfs/index.d.ts.map +1 -0
  135. package/dist/commands/lfs/lfs-config.d.ts +174 -0
  136. package/dist/commands/lfs/lfs-config.d.ts.map +1 -0
  137. package/dist/commands/lfs/lfs-endpoint-command.d.ts +83 -0
  138. package/dist/commands/lfs/lfs-endpoint-command.d.ts.map +1 -0
  139. package/dist/commands/local-transport.d.ts.map +1 -1
  140. package/dist/commands/log-command.d.ts +26 -0
  141. package/dist/commands/log-command.d.ts.map +1 -1
  142. package/dist/commands/log-output.d.ts +22 -1
  143. package/dist/commands/log-output.d.ts.map +1 -1
  144. package/dist/commands/ls-files-command.d.ts +153 -0
  145. package/dist/commands/ls-files-command.d.ts.map +1 -0
  146. package/dist/commands/ls-remote-command.d.ts +5 -0
  147. package/dist/commands/ls-remote-command.d.ts.map +1 -1
  148. package/dist/commands/ls-tree-command.d.ts +105 -0
  149. package/dist/commands/ls-tree-command.d.ts.map +1 -0
  150. package/dist/commands/maintenance-run-command.d.ts +122 -0
  151. package/dist/commands/maintenance-run-command.d.ts.map +1 -0
  152. package/dist/commands/merge-command.d.ts +7 -0
  153. package/dist/commands/merge-command.d.ts.map +1 -1
  154. package/dist/commands/merge-config.d.ts +7 -0
  155. package/dist/commands/merge-config.d.ts.map +1 -1
  156. package/dist/commands/merge-drivers.d.ts +67 -5
  157. package/dist/commands/merge-drivers.d.ts.map +1 -1
  158. package/dist/commands/merge-support.d.ts +6 -0
  159. package/dist/commands/merge-support.d.ts.map +1 -1
  160. package/dist/commands/merge-tree-command.d.ts +122 -0
  161. package/dist/commands/merge-tree-command.d.ts.map +1 -0
  162. package/dist/commands/mktag-command.d.ts +51 -0
  163. package/dist/commands/mktag-command.d.ts.map +1 -0
  164. package/dist/commands/object-store/count-objects-command.d.ts +58 -0
  165. package/dist/commands/object-store/count-objects-command.d.ts.map +1 -0
  166. package/dist/commands/object-store/index.d.ts +5 -0
  167. package/dist/commands/object-store/index.d.ts.map +1 -0
  168. package/dist/commands/object-store/objects-directory.d.ts +12 -0
  169. package/dist/commands/object-store/objects-directory.d.ts.map +1 -0
  170. package/dist/commands/object-store/prune-command.d.ts +38 -0
  171. package/dist/commands/object-store/prune-command.d.ts.map +1 -0
  172. package/dist/commands/object-store/show-index-command.d.ts +23 -0
  173. package/dist/commands/object-store/show-index-command.d.ts.map +1 -0
  174. package/dist/commands/ort-merge.d.ts +24 -0
  175. package/dist/commands/ort-merge.d.ts.map +1 -1
  176. package/dist/commands/patch-id-command.d.ts +30 -0
  177. package/dist/commands/patch-id-command.d.ts.map +1 -0
  178. package/dist/commands/patch-id.d.ts +24 -0
  179. package/dist/commands/patch-id.d.ts.map +1 -1
  180. package/dist/commands/plumbing-command.d.ts +66 -0
  181. package/dist/commands/plumbing-command.d.ts.map +1 -0
  182. package/dist/commands/plumbing-input.d.ts +38 -0
  183. package/dist/commands/plumbing-input.d.ts.map +1 -0
  184. package/dist/commands/promisor-remote-reply.d.ts +35 -0
  185. package/dist/commands/promisor-remote-reply.d.ts.map +1 -0
  186. package/dist/commands/promisor-remote.d.ts.map +1 -1
  187. package/dist/commands/pull-command.d.ts.map +1 -1
  188. package/dist/commands/push-command.d.ts +17 -2
  189. package/dist/commands/push-command.d.ts.map +1 -1
  190. package/dist/commands/rebase-command.d.ts +108 -2
  191. package/dist/commands/rebase-command.d.ts.map +1 -1
  192. package/dist/commands/refs-command.d.ts +81 -0
  193. package/dist/commands/refs-command.d.ts.map +1 -0
  194. package/dist/commands/remote-object-info-command.d.ts +55 -0
  195. package/dist/commands/remote-object-info-command.d.ts.map +1 -0
  196. package/dist/commands/remote-transport.d.ts +40 -3
  197. package/dist/commands/remote-transport.d.ts.map +1 -1
  198. package/dist/commands/repack-command.d.ts +115 -0
  199. package/dist/commands/repack-command.d.ts.map +1 -0
  200. package/dist/commands/replace-command.d.ts +143 -0
  201. package/dist/commands/replace-command.d.ts.map +1 -0
  202. package/dist/commands/replay-command.d.ts +117 -0
  203. package/dist/commands/replay-command.d.ts.map +1 -0
  204. package/dist/commands/repo-command.d.ts +136 -0
  205. package/dist/commands/repo-command.d.ts.map +1 -0
  206. package/dist/commands/request-pull-command.d.ts +82 -0
  207. package/dist/commands/request-pull-command.d.ts.map +1 -0
  208. package/dist/commands/rerere-command.d.ts +36 -0
  209. package/dist/commands/rerere-command.d.ts.map +1 -0
  210. package/dist/commands/rerere.d.ts +102 -0
  211. package/dist/commands/rerere.d.ts.map +1 -0
  212. package/dist/commands/rev-filter/commit-grep.d.ts +3 -1
  213. package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -1
  214. package/dist/commands/rev-list-command.d.ts +3 -0
  215. package/dist/commands/rev-list-command.d.ts.map +1 -1
  216. package/dist/commands/rev-parse-command.d.ts +9 -0
  217. package/dist/commands/rev-parse-command.d.ts.map +1 -1
  218. package/dist/commands/revert-command.d.ts +10 -0
  219. package/dist/commands/revert-command.d.ts.map +1 -1
  220. package/dist/commands/revision-range.d.ts +5 -0
  221. package/dist/commands/revision-range.d.ts.map +1 -1
  222. package/dist/commands/revision-resolver.d.ts +12 -0
  223. package/dist/commands/revision-resolver.d.ts.map +1 -1
  224. package/dist/commands/sequencer-pick.d.ts +18 -0
  225. package/dist/commands/sequencer-pick.d.ts.map +1 -1
  226. package/dist/commands/serve-repository.d.ts +23 -1
  227. package/dist/commands/serve-repository.d.ts.map +1 -1
  228. package/dist/commands/session-id.d.ts +18 -0
  229. package/dist/commands/session-id.d.ts.map +1 -0
  230. package/dist/commands/show-branch-command.d.ts +59 -0
  231. package/dist/commands/show-branch-command.d.ts.map +1 -0
  232. package/dist/commands/show-ref-command.d.ts +112 -0
  233. package/dist/commands/show-ref-command.d.ts.map +1 -0
  234. package/dist/commands/signature-check.d.ts +9 -2
  235. package/dist/commands/signature-check.d.ts.map +1 -1
  236. package/dist/commands/signing.d.ts +22 -1
  237. package/dist/commands/signing.d.ts.map +1 -1
  238. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  239. package/dist/commands/stash-export-command.d.ts +115 -0
  240. package/dist/commands/stash-export-command.d.ts.map +1 -0
  241. package/dist/commands/status-command.d.ts +2 -1
  242. package/dist/commands/status-command.d.ts.map +1 -1
  243. package/dist/commands/stripspace-command.d.ts +44 -0
  244. package/dist/commands/stripspace-command.d.ts.map +1 -0
  245. package/dist/commands/submodule-add-command.d.ts +10 -1
  246. package/dist/commands/submodule-add-command.d.ts.map +1 -1
  247. package/dist/commands/submodule-auth.d.ts +3 -1
  248. package/dist/commands/submodule-auth.d.ts.map +1 -1
  249. package/dist/commands/submodule-commands.d.ts +9 -1
  250. package/dist/commands/submodule-commands.d.ts.map +1 -1
  251. package/dist/commands/submodule-update-command.d.ts +13 -1
  252. package/dist/commands/submodule-update-command.d.ts.map +1 -1
  253. package/dist/commands/textconv-cache.d.ts +58 -0
  254. package/dist/commands/textconv-cache.d.ts.map +1 -0
  255. package/dist/commands/tree-restore.d.ts +5 -0
  256. package/dist/commands/tree-restore.d.ts.map +1 -1
  257. package/dist/commands/unpack-objects-command.d.ts +47 -0
  258. package/dist/commands/unpack-objects-command.d.ts.map +1 -0
  259. package/dist/commands/update-index-command.d.ts +110 -0
  260. package/dist/commands/update-index-command.d.ts.map +1 -0
  261. package/dist/commands/uri-protocols.d.ts +13 -0
  262. package/dist/commands/uri-protocols.d.ts.map +1 -0
  263. package/dist/commands/url-parse-command.d.ts +30 -0
  264. package/dist/commands/url-parse-command.d.ts.map +1 -0
  265. package/dist/commands/var-command.d.ts +42 -0
  266. package/dist/commands/var-command.d.ts.map +1 -0
  267. package/dist/{commands-CNvli5bl.js → commands-Mlo1dxQN.js} +52078 -44471
  268. package/dist/errors/command-errors.d.ts +33 -0
  269. package/dist/errors/command-errors.d.ts.map +1 -1
  270. package/dist/errors/index.js +39 -1
  271. package/dist/{fsck-CPeDh9fh.js → fsck-CrhVMNIH.js} +184 -143
  272. package/dist/git-command.d.ts +58 -2
  273. package/dist/git-command.d.ts.map +1 -1
  274. package/dist/git.d.ts +532 -1
  275. package/dist/git.d.ts.map +1 -1
  276. package/dist/guarded-transport-command.d.ts +3 -1
  277. package/dist/guarded-transport-command.d.ts.map +1 -1
  278. package/dist/index.js +7 -6
  279. package/dist/maintenance-run-command-Bw21HEkH.js +13539 -0
  280. package/dist/{remote-transport-CCmBadm-.js → remote-transport-Bu4PGSMD.js} +1009 -10
  281. package/dist/results/cherry-pick-result.d.ts +6 -0
  282. package/dist/results/cherry-pick-result.d.ts.map +1 -1
  283. package/dist/results/diff-entry.d.ts +10 -0
  284. package/dist/results/diff-entry.d.ts.map +1 -1
  285. package/dist/results/diff-formatter.d.ts.map +1 -1
  286. package/dist/results/diff-output.d.ts +49 -3
  287. package/dist/results/diff-output.d.ts.map +1 -1
  288. package/dist/results/fetch-result.d.ts +12 -0
  289. package/dist/results/fetch-result.d.ts.map +1 -1
  290. package/dist/results/index.js +2 -2
  291. package/dist/results/merge-result.d.ts +5 -0
  292. package/dist/results/merge-result.d.ts.map +1 -1
  293. package/dist/results/push-result.d.ts +5 -0
  294. package/dist/results/push-result.d.ts.map +1 -1
  295. package/dist/results/rebase-result.d.ts +7 -0
  296. package/dist/results/rebase-result.d.ts.map +1 -1
  297. package/dist/results/revert-result.d.ts +6 -0
  298. package/dist/results/revert-result.d.ts.map +1 -1
  299. package/dist/results/stash-result.d.ts +5 -0
  300. package/dist/results/stash-result.d.ts.map +1 -1
  301. package/dist/{results-BDuEgdLU.js → results-ERo9vELd.js} +28511 -25685
  302. package/dist/transport-command.d.ts +79 -1
  303. package/dist/transport-command.d.ts.map +1 -1
  304. package/package.json +12 -12
  305. package/src/commands/add-command.ts +3 -0
  306. package/src/commands/add-patch/patch-backend.ts +4 -1
  307. package/src/commands/add-patch/patch-modes.ts +26 -2
  308. package/src/commands/add-patch/patch-session.ts +6 -0
  309. package/src/commands/am/am-command.ts +163 -8
  310. package/src/commands/apply/index.ts +1 -0
  311. package/src/commands/archive/archive-command.ts +1148 -0
  312. package/src/commands/archive/archive-entry.ts +93 -0
  313. package/src/commands/archive/index.ts +7 -0
  314. package/src/commands/archive/remote-archive-command.ts +140 -0
  315. package/src/commands/archive/tar-archive.ts +207 -0
  316. package/src/commands/archive/tar-commit-id.ts +72 -0
  317. package/src/commands/archive/upload-archive-writer.ts +213 -0
  318. package/src/commands/archive/zip-archive.ts +317 -0
  319. package/src/commands/attributes-source.ts +26 -12
  320. package/src/commands/blame-command.ts +118 -19
  321. package/src/commands/bundle/bundle-create-command.ts +405 -0
  322. package/src/commands/bundle/bundle-format.ts +228 -0
  323. package/src/commands/bundle/bundle-list.ts +276 -0
  324. package/src/commands/bundle/bundle-read-commands.ts +157 -0
  325. package/src/commands/bundle/bundle-support.ts +85 -0
  326. package/src/commands/bundle/bundle-transport.ts +107 -0
  327. package/src/commands/bundle/bundle-uri-host.ts +204 -0
  328. package/src/commands/bundle/bundle-uri.ts +236 -0
  329. package/src/commands/bundle/bundle-verify.ts +152 -0
  330. package/src/commands/bundle/index.ts +14 -0
  331. package/src/commands/cat-file/batch-format.ts +193 -0
  332. package/src/commands/cat-file/cat-file-command.ts +857 -0
  333. package/src/commands/cat-file/index.ts +2 -0
  334. package/src/commands/check-attr-command.ts +333 -0
  335. package/src/commands/check-ignore-command.ts +261 -0
  336. package/src/commands/check-ref-format-command.ts +129 -0
  337. package/src/commands/checkout-command.ts +39 -21
  338. package/src/commands/checkout-index-command.ts +568 -0
  339. package/src/commands/checkout-paths.ts +7 -0
  340. package/src/commands/cherry-pick-command.ts +21 -1
  341. package/src/commands/clone-command.ts +208 -7
  342. package/src/commands/commit-command.ts +22 -4
  343. package/src/commands/config-command.ts +9 -0
  344. package/src/commands/daemon-access-hook.ts +78 -0
  345. package/src/commands/default-branch.ts +99 -1
  346. package/src/commands/diff-command.ts +573 -46
  347. package/src/commands/diff-external.ts +131 -0
  348. package/src/commands/diff-plumbing/diff-pairs-command.ts +193 -0
  349. package/src/commands/diff-plumbing/diff-plumbing-command.ts +424 -0
  350. package/src/commands/diff-plumbing/index.ts +2 -0
  351. package/src/commands/diff-textconv.ts +5 -1
  352. package/src/commands/fast-export/fast-export-command.ts +911 -0
  353. package/src/commands/fast-export/fast-import-command.ts +1553 -0
  354. package/src/commands/fast-export/fast-stream-support.ts +162 -0
  355. package/src/commands/fast-export/index.ts +3 -0
  356. package/src/commands/fetch-command.ts +312 -8
  357. package/src/commands/fetch-multiple-command.ts +4 -1
  358. package/src/commands/format-rev-command.ts +251 -0
  359. package/src/commands/fsck/fsck-command.ts +47 -20
  360. package/src/commands/fsck/fsck-msg-ids.ts +19 -3
  361. package/src/commands/fsck/fsck-pack.ts +2 -2
  362. package/src/commands/fsmonitor-refresh.ts +315 -0
  363. package/src/commands/gc-command.ts +10 -0
  364. package/src/commands/git-hooks.ts +123 -6
  365. package/src/commands/git-paths.ts +136 -0
  366. package/src/commands/grep/grep-command.ts +38 -15
  367. package/src/commands/history-command.ts +617 -0
  368. package/src/commands/http-config.ts +139 -0
  369. package/src/commands/index-adder.ts +37 -3
  370. package/src/commands/index-host.ts +6 -1
  371. package/src/commands/index.ts +45 -0
  372. package/src/commands/init-command.ts +14 -0
  373. package/src/commands/last-modified-command.ts +804 -0
  374. package/src/commands/lfs/go-url.ts +370 -0
  375. package/src/commands/lfs/index.ts +2 -0
  376. package/src/commands/lfs/lfs-config.ts +738 -0
  377. package/src/commands/lfs/lfs-endpoint-command.ts +180 -0
  378. package/src/commands/local-transport.ts +252 -4
  379. package/src/commands/log-command.ts +104 -5
  380. package/src/commands/log-output.ts +55 -5
  381. package/src/commands/ls-files-command.ts +1177 -0
  382. package/src/commands/ls-remote-command.ts +6 -0
  383. package/src/commands/ls-tree-command.ts +684 -0
  384. package/src/commands/maintenance-run-command.ts +949 -0
  385. package/src/commands/merge-command.ts +78 -32
  386. package/src/commands/merge-config.ts +23 -1
  387. package/src/commands/merge-drivers.ts +109 -20
  388. package/src/commands/merge-support.ts +29 -5
  389. package/src/commands/merge-tree-command.ts +786 -0
  390. package/src/commands/mktag-command.ts +149 -0
  391. package/src/commands/object-store/count-objects-command.ts +404 -0
  392. package/src/commands/object-store/index.ts +4 -0
  393. package/src/commands/object-store/objects-directory.ts +24 -0
  394. package/src/commands/object-store/prune-command.ts +129 -0
  395. package/src/commands/object-store/show-index-command.ts +151 -0
  396. package/src/commands/ort-merge.ts +92 -25
  397. package/src/commands/patch-id-command.ts +65 -0
  398. package/src/commands/patch-id.ts +218 -0
  399. package/src/commands/plumbing-command.ts +141 -0
  400. package/src/commands/plumbing-input.ts +87 -0
  401. package/src/commands/promisor-remote-reply.ts +276 -0
  402. package/src/commands/promisor-remote.ts +25 -2
  403. package/src/commands/pull-command.ts +2 -0
  404. package/src/commands/push-command.ts +87 -5
  405. package/src/commands/rebase-command.ts +507 -19
  406. package/src/commands/refs-command.ts +274 -0
  407. package/src/commands/remote-object-info-command.ts +109 -0
  408. package/src/commands/remote-transport.ts +116 -1
  409. package/src/commands/repack-command.ts +383 -0
  410. package/src/commands/replace-command.ts +816 -0
  411. package/src/commands/replay-command.ts +674 -0
  412. package/src/commands/repo-command.ts +967 -0
  413. package/src/commands/request-pull-command.ts +356 -0
  414. package/src/commands/rerere-command.ts +179 -0
  415. package/src/commands/rerere.ts +925 -0
  416. package/src/commands/rev-filter/commit-grep.ts +7 -2
  417. package/src/commands/rev-list-command.ts +9 -0
  418. package/src/commands/rev-parse-command.ts +62 -4
  419. package/src/commands/revert-command.ts +21 -1
  420. package/src/commands/revision-range.ts +7 -2
  421. package/src/commands/revision-resolver.ts +44 -3
  422. package/src/commands/sequencer-pick.ts +47 -0
  423. package/src/commands/serve-repository.ts +65 -0
  424. package/src/commands/session-id.ts +31 -0
  425. package/src/commands/show-branch-command.ts +981 -0
  426. package/src/commands/show-command.ts +1 -1
  427. package/src/commands/show-ref-command.ts +439 -0
  428. package/src/commands/signature-check.ts +37 -5
  429. package/src/commands/signing.ts +122 -16
  430. package/src/commands/stash-apply-command.ts +3 -0
  431. package/src/commands/stash-export-command.ts +397 -0
  432. package/src/commands/status-command.ts +43 -6
  433. package/src/commands/stripspace-command.ts +118 -0
  434. package/src/commands/submodule-add-command.ts +22 -1
  435. package/src/commands/submodule-auth.ts +61 -6
  436. package/src/commands/submodule-commands.ts +12 -2
  437. package/src/commands/submodule-update-command.ts +29 -0
  438. package/src/commands/textconv-cache.ts +143 -0
  439. package/src/commands/tree-restore.ts +14 -0
  440. package/src/commands/unpack-objects-command.ts +235 -0
  441. package/src/commands/update-index-command.ts +1016 -0
  442. package/src/commands/uri-protocols.ts +13 -0
  443. package/src/commands/url-parse-command.ts +67 -0
  444. package/src/commands/var-command.ts +219 -0
  445. package/src/errors/command-errors.ts +45 -0
  446. package/src/git-command.ts +131 -1
  447. package/src/git.ts +808 -1
  448. package/src/guarded-transport-command.ts +6 -1
  449. package/src/results/cherry-pick-result.ts +6 -0
  450. package/src/results/diff-entry.ts +12 -0
  451. package/src/results/diff-formatter.ts +7 -4
  452. package/src/results/diff-output.ts +117 -11
  453. package/src/results/diff-pickaxe.ts +1 -1
  454. package/src/results/fetch-result.ts +12 -0
  455. package/src/results/merge-result.ts +5 -0
  456. package/src/results/push-result.ts +5 -0
  457. package/src/results/rebase-result.ts +7 -0
  458. package/src/results/revert-result.ts +6 -0
  459. package/src/results/stash-result.ts +6 -0
  460. package/src/transport-command.ts +182 -1
@@ -0,0 +1,276 @@
1
+ /**
2
+ * The client side of the v2 `promisor-remote` capability (git 2.49+, promisor-remote.c's
3
+ * `filter_promisor_remote` and `promisor_remote_reply`): which promisor remotes a server
4
+ * advertises the client accepts (`promisor.acceptFromServer`: `None`, `KnownUrl`, `KnownName`,
5
+ * `All`; `promisor.checkFields`), what it stores of them (`promisor.storeFields`: the
6
+ * `partialCloneFilter` and `token` of a remote it already has), and which remotes its lazy
7
+ * fetches then try first ({@link acceptedPromisorRemotes}).
8
+ *
9
+ * Not yet: `promisor.acceptFromServerUrl` (2.56: remotes created from an advertised URL) and
10
+ * `--filter=auto`.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * // [promisor] acceptFromServer = knownUrl; [remote "lop"] url = file:///lop; promisor = true
15
+ * const reply = promisorRemoteReplyOf(workingCopy, (line) => stderr.push(line));
16
+ * await reply("name=lop,url=file:///lop"); // "lop": sent as `promisor-remote=lop`
17
+ * acceptedPromisorRemotes(workingCopy); // Set { "lop" }
18
+ * ```
19
+ */
20
+
21
+ import { ObjectFilterError, parseObjectFilter } from "@statewalker/vcs-core";
22
+ import {
23
+ encodePromisorRemoteNames,
24
+ type PromisorRemoteInfo,
25
+ type PromisorRemoteReply,
26
+ parsePromisorRemoteInfo,
27
+ } from "@statewalker/vcs-transport";
28
+ import type { WorkingCopy } from "@statewalker/vcs-working-tree";
29
+ import { RemoteConfigStore } from "../remote-config/index.js";
30
+ import { promisorRemotes } from "./promisor-remote.js";
31
+
32
+ type AcceptPolicy = "none" | "knownUrl" | "knownName" | "all";
33
+
34
+ /** The optional fields git knows (`known_fields`), lower-cased. */
35
+ const KNOWN_FIELDS = new Map([
36
+ ["partialclonefilter", "partialCloneFilter"],
37
+ ["token", "token"],
38
+ ]);
39
+
40
+ const accepted = new WeakMap<object, Set<string>>();
41
+
42
+ /**
43
+ * The promisor remotes a server's `promisor-remote` advertisement made this repository
44
+ * accept (git's `promisor_remote.accepted`, kept for the process): its lazy fetches try them
45
+ * before the other promisor remotes.
46
+ */
47
+ export function acceptedPromisorRemotes(workingCopy: WorkingCopy): ReadonlySet<string> {
48
+ return accepted.get(keyOf(workingCopy)) ?? new Set();
49
+ }
50
+
51
+ function keyOf(workingCopy: WorkingCopy): object {
52
+ try {
53
+ return workingCopy.history?.objects ?? workingCopy;
54
+ } catch {
55
+ return workingCopy;
56
+ }
57
+ }
58
+
59
+ /**
60
+ * The answer of `workingCopy` to a server's `promisor-remote` capability, given to
61
+ * `fetchFromConnection` (`FetchClientOptions.promisorRemote`). `stderr` gets git's lines
62
+ * (warnings, `Storing new filter from server ...`), each without its newline. Each call reads
63
+ * the configuration afresh: a stored field is not stored (nor told) again.
64
+ */
65
+ export function promisorRemoteReplyOf(
66
+ workingCopy: WorkingCopy,
67
+ stderr: (line: string) => void,
68
+ ): PromisorRemoteReply {
69
+ // fields_checked / fields_stored warn about unknown names once per process
70
+ const warnedFields = new Set<string>();
71
+ const fieldsOf = (store: RemoteConfigStore, key: string): string[] => {
72
+ const value = store.value(key);
73
+ if (!value) return [];
74
+ const out: string[] = [];
75
+ for (const raw of value.split(",")) {
76
+ const field = raw.trim();
77
+ if (field === "") continue;
78
+ const known = KNOWN_FIELDS.get(field.toLowerCase());
79
+ if (!known) {
80
+ if (!warnedFields.has(`${key}\0${field}`)) {
81
+ warnedFields.add(`${key}\0${field}`);
82
+ stderr(`warning: unsupported field '${field}' in '${key}' config`);
83
+ }
84
+ continue;
85
+ }
86
+ if (!out.includes(known)) out.push(known);
87
+ }
88
+ return out;
89
+ };
90
+ return async (info) => {
91
+ const store = RemoteConfigStore.from(workingCopy);
92
+ const policy = acceptPolicyOf(store, stderr);
93
+ if (policy === "none") return undefined;
94
+ const { remotes, warnings } = parsePromisorRemoteInfo(info);
95
+ for (const w of warnings) stderr(`warning: ${w}`);
96
+ const checked = fieldsOf(store, "promisor.checkFields");
97
+ const local = configuredPromisors(store, checked);
98
+ const accepting: PromisorRemoteInfo[] = [];
99
+ for (const advertised of remotes) {
100
+ if (shouldAccept(policy, advertised, local, checked, stderr)) accepting.push(advertised);
101
+ }
102
+ if (accepting.length === 0) return undefined;
103
+ // promisor_store_advertised_fields: only for a remote configured here
104
+ const storedFields = fieldsOf(store, "promisor.storeFields");
105
+ let changed = false;
106
+ if (storedFields.length > 0) {
107
+ const current = configuredPromisors(store, storedFields);
108
+ for (const advertised of accepting) {
109
+ const mine = current.find((p) => p.name === advertised.name);
110
+ if (!mine) continue;
111
+ if (
112
+ storedFields.includes("partialCloneFilter") &&
113
+ advertised.filter !== undefined &&
114
+ validFilter(advertised.filter, advertised.name, stderr)
115
+ ) {
116
+ changed =
117
+ storeField(
118
+ store,
119
+ advertised.name,
120
+ "filter",
121
+ "partialCloneFilter",
122
+ advertised.filter,
123
+ mine.filter,
124
+ stderr,
125
+ ) || changed;
126
+ }
127
+ if (
128
+ storedFields.includes("token") &&
129
+ advertised.token !== undefined &&
130
+ validToken(advertised.token, advertised.name, stderr)
131
+ ) {
132
+ changed =
133
+ storeField(
134
+ store,
135
+ advertised.name,
136
+ "token",
137
+ "token",
138
+ advertised.token,
139
+ mine.token,
140
+ stderr,
141
+ ) || changed;
142
+ }
143
+ }
144
+ }
145
+ if (changed) await store.save();
146
+ // the accepted remotes that are promisor remotes here are tried first by lazy fetches
147
+ const promisors = new Set(
148
+ promisorRemotes(RemoteConfigStore.from(workingCopy)).map((r) => r.name),
149
+ );
150
+ const key = keyOf(workingCopy);
151
+ const set = accepted.get(key) ?? new Set<string>();
152
+ for (const r of accepting) if (promisors.has(r.name)) set.add(r.name);
153
+ accepted.set(key, set);
154
+ return encodePromisorRemoteNames(accepting.map((r) => r.name));
155
+ };
156
+ }
157
+
158
+ /** accept_from_server: the last `promisor.acceptFromServer`, case-insensitive. */
159
+ function acceptPolicyOf(store: RemoteConfigStore, stderr: (line: string) => void): AcceptPolicy {
160
+ const value = store.value("promisor.acceptfromserver");
161
+ if (value === undefined) return "none";
162
+ const v = value.toLowerCase();
163
+ if (v === "" || v === "none") return "none";
164
+ if (v === "knownurl") return "knownUrl";
165
+ if (v === "knownname") return "knownName";
166
+ if (v === "all") return "all";
167
+ stderr(`warning: unknown '${value}' value for 'promisor.acceptfromserver' config option`);
168
+ return "none";
169
+ }
170
+
171
+ /** promisor_config_info_list: the promisor remotes with a non-empty URL, with `fields`. */
172
+ function configuredPromisors(
173
+ store: RemoteConfigStore,
174
+ fields: readonly string[],
175
+ ): PromisorRemoteInfo[] {
176
+ const out: PromisorRemoteInfo[] = [];
177
+ const nonEmpty = (key: string) => {
178
+ const v = store.value(key);
179
+ return v ? v : undefined;
180
+ };
181
+ for (const { name } of promisorRemotes(store)) {
182
+ const url = nonEmpty(`remote.${name}.url`);
183
+ if (url === undefined) continue;
184
+ const filter = fields.includes("partialCloneFilter")
185
+ ? nonEmpty(`remote.${name}.partialCloneFilter`)
186
+ : undefined;
187
+ const token = fields.includes("token") ? nonEmpty(`remote.${name}.token`) : undefined;
188
+ out.push({
189
+ name,
190
+ url,
191
+ ...(filter !== undefined ? { filter } : {}),
192
+ ...(token !== undefined ? { token } : {}),
193
+ });
194
+ }
195
+ return out;
196
+ }
197
+
198
+ /** should_accept_remote (without `promisor.acceptFromServerUrl`). */
199
+ function shouldAccept(
200
+ policy: AcceptPolicy,
201
+ advertised: PromisorRemoteInfo,
202
+ local: readonly PromisorRemoteInfo[],
203
+ checked: readonly string[],
204
+ stderr: (line: string) => void,
205
+ ): boolean {
206
+ const mine = local.find((p) => p.name === advertised.name);
207
+ if (!mine) return policy === "all" && allFieldsMatch(advertised, local, undefined, checked);
208
+ if (policy === "all") return allFieldsMatch(advertised, local, undefined, checked);
209
+ if (policy === "knownName") return allFieldsMatch(advertised, local, mine, checked);
210
+ if (mine.url !== advertised.url) {
211
+ stderr(
212
+ `warning: known remote named '${advertised.name}' but with URL '${mine.url}' instead of '${advertised.url}', ignoring this remote`,
213
+ );
214
+ return false;
215
+ }
216
+ return policy === "knownUrl" && allFieldsMatch(advertised, local, mine, checked);
217
+ }
218
+
219
+ /** all_fields_match: every checked field advertised and equal to one remote's (or `mine`'s). */
220
+ function allFieldsMatch(
221
+ advertised: PromisorRemoteInfo,
222
+ local: readonly PromisorRemoteInfo[],
223
+ mine: PromisorRemoteInfo | undefined,
224
+ checked: readonly string[],
225
+ ): boolean {
226
+ const fieldOf = (r: PromisorRemoteInfo, field: string) =>
227
+ field === "partialCloneFilter" ? r.filter : r.token;
228
+ for (const field of checked) {
229
+ const value = fieldOf(advertised, field);
230
+ if (value === undefined) return false;
231
+ const candidates = mine ? [mine] : local;
232
+ if (!candidates.some((r) => fieldOf(r, field) === value)) return false;
233
+ }
234
+ return true;
235
+ }
236
+
237
+ /** store_one_field: a new value written (`repo_config_set_gently`) and told on stderr. */
238
+ function storeField(
239
+ store: RemoteConfigStore,
240
+ remote: string,
241
+ label: string,
242
+ field: string,
243
+ advertised: string,
244
+ current: string | undefined,
245
+ stderr: (line: string) => void,
246
+ ): boolean {
247
+ if (current !== undefined && current === advertised) return false;
248
+ stderr(`Storing new ${label} from server for remote '${remote}'.`);
249
+ stderr(` '${current ?? ""}' -> '${advertised}'`);
250
+ store.setValue(`remote.${remote}.${field}`, advertised);
251
+ return true;
252
+ }
253
+
254
+ /** valid_filter: the advertised filter must parse (git warns with the parser's reason). */
255
+ function validFilter(filter: string, remote: string, stderr: (line: string) => void): boolean {
256
+ try {
257
+ parseObjectFilter(filter);
258
+ return true;
259
+ } catch (error) {
260
+ const reason = error instanceof ObjectFilterError ? error.message : String(error);
261
+ stderr(
262
+ `warning: invalid filter '${filter}' for remote '${remote}' will not be stored: ${reason}`,
263
+ );
264
+ return false;
265
+ }
266
+ }
267
+
268
+ /** valid_token: no control character. */
269
+ function validToken(token: string, remote: string, stderr: (line: string) => void): boolean {
270
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: git's iscntrl check
271
+ if (/[\x00-\x1f\x7f]/.test(token)) {
272
+ stderr(`warning: invalid token '${token}' for remote '${remote}' will not be stored`);
273
+ return false;
274
+ }
275
+ return true;
276
+ }
@@ -34,11 +34,14 @@ import {
34
34
  FetchCheckError,
35
35
  fetchPromisedObjects,
36
36
  type GitTransportRegistry,
37
+ unpackLimitOf,
37
38
  } from "@statewalker/vcs-transport";
38
39
  import { parseGitBool } from "@statewalker/vcs-utils";
39
40
  import type { WorkingCopy } from "@statewalker/vcs-working-tree";
40
41
  import { RemoteConfigStore } from "../remote-config/index.js";
41
42
  import { hostEnvironmentOf } from "./git-ident.js";
43
+ import { httpClientSettingsOf } from "./http-config.js";
44
+ import { acceptedPromisorRemotes } from "./promisor-remote-reply.js";
42
45
 
43
46
  /** A promisor remote (git's `struct promisor_remote`). */
44
47
  export interface PromisorRemote {
@@ -166,6 +169,14 @@ export function createPromisorFetcher(
166
169
  return false;
167
170
  }
168
171
  const config = store();
172
+ // the child `git fetch <remote> --filter=blob:none` registers the filter first
173
+ // (fetch_one_setup_partial's partial_clone_register): a promisor remote without one,
174
+ // such as a large object promisor a server's promisor-remote capability named, gets it
175
+ if (remote.partialCloneFilter === undefined) {
176
+ registerPartialClone(config, remote.name, "blob:none");
177
+ await config.save();
178
+ remote.partialCloneFilter = "blob:none";
179
+ }
169
180
  const url = config.remoteUrlOf(remote.name);
170
181
  // the child fetch runs with fetch_if_missing = 0: it reads through the history's view
171
182
  // without lazy fetch (a read elsewhere meanwhile still fetches)
@@ -177,6 +188,7 @@ export function createPromisorFetcher(
177
188
  const { fetchFsckOf } = await import("./fsck/index.js");
178
189
  const environment = hostEnvironmentOf(workingCopy);
179
190
  const fsckWarnings: string[] = [];
191
+ const unpackLimit = unpackLimitOf({ getAll: (key) => config.values(key) }, "fetch");
180
192
  const fsck = await fetchFsckOf({
181
193
  value: (key) => config.value(key),
182
194
  entries: (prefix) => config.entriesWithPrefix(prefix),
@@ -203,6 +215,8 @@ export function createPromisorFetcher(
203
215
  ...(options.headers ? { headers: options.headers } : {}),
204
216
  ...(options.timeout !== undefined ? { timeout: options.timeout } : {}),
205
217
  protocolVersion: protocolVersionOf(config),
218
+ httpSettings: (remoteUrl) =>
219
+ httpClientSettingsOf(config, remoteUrl, environment, { compatibility }),
206
220
  },
207
221
  async (connection) => {
208
222
  try {
@@ -213,6 +227,8 @@ export function createPromisorFetcher(
213
227
  url: anonymizeUrl(url),
214
228
  compatibility,
215
229
  ...(fsck ? { fsckObjects: fsck } : {}),
230
+ // the child fetch's fetch.unpackLimit: whether fetch-pack keeps the pack itself
231
+ ...(unpackLimit !== undefined ? { unpackLimit } : {}),
216
232
  });
217
233
  } catch (error) {
218
234
  // fetch-pack ran: its start-up warnings came first
@@ -268,8 +284,15 @@ export function createPromisorFetcher(
268
284
  fetchIfMissing: () => !noLazyFetch(),
269
285
  async fetch(ids) {
270
286
  let remaining = [...ids];
271
- // try_promisor_remotes: the first remote whose fetch succeeds ends it
272
- for (const remote of promisorRemotes(store())) {
287
+ // try_promisor_remotes: the first remote whose fetch succeeds ends it, the remotes a
288
+ // server's promisor-remote capability made us accept first
289
+ const all = promisorRemotes(store());
290
+ const acceptedNames = acceptedPromisorRemotes(workingCopy);
291
+ const ordered = [
292
+ ...all.filter((r) => acceptedNames.has(r.name)),
293
+ ...all.filter((r) => !acceptedNames.has(r.name)),
294
+ ];
295
+ for (const remote of ordered) {
273
296
  if (await fetchFrom(remote, remaining)) return [];
274
297
  if (remaining.length === 1) continue;
275
298
  // remove_fetched_oids: what a failed fetch brought all the same
@@ -805,6 +805,8 @@ export class PullCommand extends GuardedTransportCommand<PullResult> {
805
805
  // the guarded transports: credentials and headers only where this pull's rule allows
806
806
  update.setTransports(this.getTransports());
807
807
  if (this.timeout !== undefined) update.setTimeout(this.timeout);
808
+ if (this.credentialHelper) update.setCredentialHelper(this.credentialHelper);
809
+ if (this.warningCallback) update.setWarningCallback(this.warningCallback);
808
810
  try {
809
811
  return await update.call();
810
812
  } catch (error) {
@@ -1,5 +1,6 @@
1
1
  import { isValidRefName, parseCoreAbbrev } from "@statewalker/vcs-core";
2
2
  import {
3
+ anonymizeUrl,
3
4
  countRefspecMatch,
4
5
  createRepositoryFacade,
5
6
  createTransportRefStore,
@@ -11,6 +12,7 @@ import {
11
12
  ObjectFormatMismatchError,
12
13
  objectSource,
13
14
  PushCertificateError,
15
+ type PushCertSigner,
14
16
  type PushClientResult,
15
17
  type PushCommandResult,
16
18
  PushRefspecError,
@@ -38,10 +40,17 @@ import { RemoteConfigStore } from "../remote-config/index.js";
38
40
  import { type PushResult, PushStatus, type RemoteRefUpdate } from "../results/push-result.js";
39
41
  import { TransportCommand } from "../transport-command.js";
40
42
  import { endOfSymbolicChain, installTracking, pushTrackingPlan } from "./branch-tracking.js";
41
- import { hostEnvironmentOf } from "./git-ident.js";
43
+ import { FetchCommand } from "./fetch-command.js";
44
+ import { committerIdentOf, hostEnvironmentOf, localTimezoneOffset } from "./git-ident.js";
42
45
  import { remoteHookSession } from "./local-transport.js";
43
46
  import { withRemoteReceivePack } from "./remote-transport.js";
44
- import { SIGNING_FAILED_LINES, SigningFailedError } from "./signing.js";
47
+ import { clientSessionIdOf } from "./session-id.js";
48
+ import {
49
+ SIGNING_FAILED_LINES,
50
+ SigningFailedError,
51
+ signingKeyIdOf,
52
+ signPayload,
53
+ } from "./signing.js";
45
54
  import {
46
55
  createSubmoduleAuthPolicy,
47
56
  guardSubmoduleTransports,
@@ -424,8 +433,9 @@ export class PushCommand extends TransportCommand<PushResult> {
424
433
  * certificate; undefined (the default) leaves it to `push.gpgSign` (a boolean or
425
434
  * `if-asked`). A server that takes no certificate refuses a signed push (`fatal: the
426
435
  * receiving end does not support --signed push`) and gets an `if-asked` one unsigned,
427
- * with git's warning ({@link PushResult.warnings}). Not signed yet: a certificate
428
- * the server takes fails as git fails when gpg cannot sign (`error: gpg failed to sign
436
+ * with git's warning ({@link PushResult.warnings}). The certificate is signed through the
437
+ * host's signer as `commit -S` signs (`gpg.format`, `user.signingKey`); without a signer, or
438
+ * when it fails, the push dies as git does when gpg cannot sign (`error: gpg failed to sign
429
439
  * the data:`, `fatal: failed to sign the push certificate`, exit 128:
430
440
  * {@link SigningFailedError}), before anything is sent.
431
441
  */
@@ -450,6 +460,43 @@ export class PushCommand extends TransportCommand<PushResult> {
450
460
  return value === true ? "always" : value === "if-asked" ? "if-asked" : undefined;
451
461
  }
452
462
 
463
+ /**
464
+ * send-pack's `generate_push_cert` through the host's signer (`sign_buffer` with the default
465
+ * key, as `push --signed` signs): the pusher is `get_signing_key_id()`, the date now in the
466
+ * local zone (git's `datestamp`: never `GIT_COMMITTER_DATE`), the pushee the URL without its
467
+ * credentials. A failed signing dies as git: gpg's lines, `fatal: failed to sign the push
468
+ * certificate`, exit 128.
469
+ */
470
+ private pushCertSigner(remoteUrl: string): PushCertSigner {
471
+ const committer = () => committerIdentOf(this.workingCopy);
472
+ return {
473
+ pusher: () => signingKeyIdOf(this.workingCopy, "", committer()),
474
+ pushee: anonymizeUrl(remoteUrl),
475
+ date: () => {
476
+ const timestamp = Math.floor(Date.now() / 1000);
477
+ return { timestamp, tzOffset: localTimezoneOffset(timestamp) };
478
+ },
479
+ sign: async (payload) => {
480
+ const cwd = await this.hooks.hostWorkingDirectory().catch(() => undefined);
481
+ try {
482
+ return await signPayload(this.workingCopy, "", payload, {
483
+ committer: committer(),
484
+ ...(cwd !== undefined ? { cwd } : {}),
485
+ tail: ["fatal: failed to sign the push certificate"],
486
+ });
487
+ } catch (error) {
488
+ if (!(error instanceof SigningFailedError) || error.exitCode !== undefined) throw error;
489
+ throw new SigningFailedError(error.message, error.signingKey, 128, {
490
+ ...(error.signerMessages ? { signerMessages: error.signerMessages } : {}),
491
+ ...(error.programExitCode !== undefined
492
+ ? { programExitCode: error.programExitCode }
493
+ : {}),
494
+ });
495
+ }
496
+ },
497
+ };
498
+ }
499
+
453
500
  /**
454
501
  * Whether atomic push is enabled.
455
502
  */
@@ -728,7 +775,9 @@ export class PushCommand extends TransportCommand<PushResult> {
728
775
  const recurseOnPush =
729
776
  recurse !== undefined && new SubmoduleFetchRepository(this.workingCopy).hasWorktree();
730
777
  const submoduleOutput = { text: submoduleWarnings.map((w) => `${w}\n`).join("") };
778
+ const sessionId = clientSessionIdOf(this.workingCopy);
731
779
  const pushOptions: TransportPushOptions = {
780
+ ...(sessionId !== undefined ? { sessionId } : {}),
732
781
  url: remoteUrl,
733
782
  auth: this.credentials,
734
783
  headers: this.headers,
@@ -738,7 +787,9 @@ export class PushCommand extends TransportCommand<PushResult> {
738
787
  refspecs,
739
788
  force: this.force || mirror,
740
789
  atomic: this.atomic,
741
- ...(this.pushCertMode() ? { signed: this.pushCertMode() } : {}),
790
+ ...(this.pushCertMode()
791
+ ? { signed: this.pushCertMode(), pushCertSigner: this.pushCertSigner(remoteUrl) }
792
+ : {}),
742
793
  thin: this.thin,
743
794
  dryRun: this.dryRun,
744
795
  prune: this.prune,
@@ -757,6 +808,10 @@ export class PushCommand extends TransportCommand<PushResult> {
757
808
  }
758
809
  : {}),
759
810
  followTags: this.followTags ?? this.configBool("push.followTags") ?? false,
811
+ // push.negotiate: send-pack's child `git fetch --negotiate-only` to the same URL
812
+ ...(this.configBool("push.negotiate")
813
+ ? { negotiate: (tips: readonly string[]) => this.negotiateCommons(remoteUrl, tips) }
814
+ : {}),
760
815
  onProgress: (message) => {
761
816
  messages.push(message);
762
817
  this.progressMessageCallback?.(message);
@@ -992,6 +1047,7 @@ export class PushCommand extends TransportCommand<PushResult> {
992
1047
  return {
993
1048
  uri: remoteUrl,
994
1049
  remoteUpdates,
1050
+ ...(result.serverSessionId !== undefined ? { serverSessionId: result.serverSessionId } : {}),
995
1051
  bytesSent: result.bytesSent,
996
1052
  objectCount: result.packObjects,
997
1053
  messages,
@@ -1150,6 +1206,8 @@ export class PushCommand extends TransportCommand<PushResult> {
1150
1206
  // directory, its directory as cwd), their output relayed where the child prints it
1151
1207
  child.setTransports(this.submoduleTransports());
1152
1208
  if (this.timeout !== undefined) child.setTimeout(this.timeout);
1209
+ if (this.credentialHelper) child.setCredentialHelper(this.credentialHelper);
1210
+ if (this.warningCallback) child.setWarningCallback(this.warningCallback);
1153
1211
  if (this.dryRun) child.setDryRun(true);
1154
1212
  if (pushOptions.length > 0) child.setPushOptions([...pushOptions]);
1155
1213
  if (configured) {
@@ -1300,6 +1358,30 @@ export class PushCommand extends TransportCommand<PushResult> {
1300
1358
  return lines;
1301
1359
  }
1302
1360
 
1361
+ /**
1362
+ * get_commons_through_negotiation: `git fetch --negotiate-only --negotiation-tip=<id>...
1363
+ * <url>` run as git's child, its acknowledged commits the commons; its warnings (stderr)
1364
+ * passed on, and no commons when it fails (git's "push negotiation failed").
1365
+ */
1366
+ private async negotiateCommons(
1367
+ url: string,
1368
+ tips: readonly string[],
1369
+ ): Promise<{ commons?: readonly string[]; warnings?: readonly string[] }> {
1370
+ const fetch = this.configureChild(new FetchCommand(this._workingCopy))
1371
+ .setRemote(url)
1372
+ .setNegotiationTips(...tips)
1373
+ .setNegotiateOnly(true);
1374
+ try {
1375
+ const result = await fetch.call();
1376
+ return {
1377
+ warnings: result.messages,
1378
+ ...(result.exitCode ? {} : { commons: result.negotiatedCommits ?? [] }),
1379
+ };
1380
+ } catch (error) {
1381
+ return { warnings: [error instanceof Error ? error.message : String(error)] };
1382
+ }
1383
+ }
1384
+
1303
1385
  /**
1304
1386
  * remote.c's `is_reachable_in_reflog` for `--force-if-includes`: whether the remote's value
1305
1387
  * (peeled to a commit) is the new value of an entry of the local ref's reflog (the local ref