@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,356 @@
1
+ /**
2
+ * `git request-pull` (git-request-pull.sh) as a library command: the text asking someone to
3
+ * pull a branch or tag of a published repository, with the range's shortlog and diffstat.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * // git request-pull v1.0 https://example.com/repo.git main:for-linus
8
+ * const { stdout, stderr, exitCode } = await git
9
+ * .requestPull()
10
+ * .setStart("v1.0")
11
+ * .setUrl("https://example.com/repo.git")
12
+ * .setEnd("main:for-linus")
13
+ * .call();
14
+ * ```
15
+ */
16
+
17
+ import { isSymbolicRef, type ObjectId } from "@statewalker/vcs-core";
18
+ import { decodeGitPath } from "@statewalker/vcs-utils/encoding";
19
+ import { GitApiError } from "../errors/index.js";
20
+ import { RemoteConfigStore } from "../remote-config/index.js";
21
+ import { TransportCommand } from "../transport-command.js";
22
+ import type { PlumbingTextOutput } from "./check-ref-format-command.js";
23
+ import { DiffCommand } from "./diff-command.js";
24
+ import { LsRemoteCommand } from "./ls-remote-command.js";
25
+ import { MergeBaseCommand } from "./merge-base-command.js";
26
+ import { formatCommitPretty } from "./pretty-format.js";
27
+ import { ShortlogCommand } from "./shortlog-command.js";
28
+ import { ShowRefCommand } from "./show-ref-command.js";
29
+
30
+ const RULE = "----------------------------------------------------------------";
31
+
32
+ /** What `"$0" -h` prints (stdout) when the start or the URL is missing; git then exits 1. */
33
+ const USAGE =
34
+ "usage: git request-pull [options] start url [end]\n\n" +
35
+ " -p show patch text as well\n\n";
36
+
37
+ /** git-sh-setup's `die`: the message on stderr, exit 1. */
38
+ class RequestPullDeath extends Error {}
39
+
40
+ /** A line of `git ls-remote` output: an object id and the ref (`^{}` for a peeled tag). */
41
+ type ListedRef = readonly [sha1: string, ref: string];
42
+
43
+ /**
44
+ * `git request-pull [-p] <start> <url> [<end>]`. The result is git's stdout, stderr and exit
45
+ * status: 1 with git's `warn:` lines when `<url>` has no ref of the remote name (default
46
+ * `HEAD`) at the commit asked for, or one at another object (the text is still printed), 1
47
+ * with git's `fatal:` line when a revision names nothing or the two have no common history.
48
+ *
49
+ * The remote's refs are listed through the command's transports (credentials and headers as
50
+ * {@link TransportCommand} gives them); everything else is read from the repository: the
51
+ * merge base, the shortlog (`git shortlog ^<start> <end>`, mailmap applied) and `git diff -M
52
+ * --stat --summary [-p]` of the merge base and the end.
53
+ */
54
+ export class RequestPullCommand extends TransportCommand<PlumbingTextOutput> {
55
+ private start = "";
56
+ private url = "";
57
+ private end = "";
58
+ private patch = false;
59
+ private compatibility: "2.43" | "2.56" = "2.56";
60
+
61
+ /** `<start>`: the commit the changes are based on (the upstream's), any committish. */
62
+ setStart(start: string): this {
63
+ this.checkCallable();
64
+ this.start = start;
65
+ return this;
66
+ }
67
+
68
+ /** `<url>`: the repository to pull from, a URL or a remote's name. */
69
+ setUrl(url: string): this {
70
+ this.checkCallable();
71
+ this.url = url;
72
+ return this;
73
+ }
74
+
75
+ /**
76
+ * `<end>`: what to pull, `<local>[:<remote>]` (default `HEAD`, asked as the remote's
77
+ * `HEAD`); the remote side is the name looked for among the remote's refs.
78
+ */
79
+ setEnd(end: string): this {
80
+ this.checkCallable();
81
+ this.end = end;
82
+ return this;
83
+ }
84
+
85
+ /** `-p`: the patch after the diffstat. */
86
+ setPatch(patch: boolean): this {
87
+ this.checkCallable();
88
+ this.patch = patch;
89
+ return this;
90
+ }
91
+
92
+ /**
93
+ * The git version to follow (default 2.56). Before 2.50 a Perl script matched the remote's
94
+ * refs and kept the last ref matching, from 2.50 a shell loop keeps the first.
95
+ */
96
+ setCompatibility(version: "2.43" | "2.56"): this {
97
+ this.checkCallable();
98
+ this.compatibility = version;
99
+ return this;
100
+ }
101
+
102
+ async call(): Promise<PlumbingTextOutput> {
103
+ this.checkCallable();
104
+ this.setCallable(false);
105
+ if (!this.start || !this.url) return { exitCode: 1, stdout: USAGE, stderr: "" };
106
+ const out: string[] = [];
107
+ const err: string[] = [];
108
+ try {
109
+ const status = await this.run(out, err);
110
+ return { exitCode: status, stdout: out.join(""), stderr: err.join("") };
111
+ } catch (error) {
112
+ if (!(error instanceof RequestPullDeath)) throw error;
113
+ return { exitCode: 1, stdout: out.join(""), stderr: `${err.join("")}${error.message}\n` };
114
+ }
115
+ }
116
+
117
+ private async run(out: string[], err: string[]): Promise<number> {
118
+ let status = 0;
119
+ const base = this.start;
120
+ const url = this.url;
121
+ const baserev = await this.verify(`${base}^0`);
122
+ if (baserev === undefined) throw new RequestPullDeath(`fatal: Not a valid revision: ${base}`);
123
+
124
+ // $3 is `<local>[:<remote>]`: ${3%:*} and ${3#*:}
125
+ const end = this.end;
126
+ const lastColon = end.lastIndexOf(":");
127
+ const firstColon = end.indexOf(":");
128
+ const local = (lastColon >= 0 ? end.slice(0, lastColon) : end) || "HEAD";
129
+ const remote = firstColon >= 0 ? end.slice(firstColon + 1) : end;
130
+ let prettyRemote = remote.startsWith("refs/") ? remote.slice(5) : remote;
131
+ if (prettyRemote.startsWith("heads/")) prettyRemote = prettyRemote.slice(6);
132
+ const head =
133
+ (await this.symbolicRef(local)) ||
134
+ (await this.showRef(local)) ||
135
+ (await this.verify(local)) ||
136
+ "";
137
+ if (!head) throw new RequestPullDeath(`fatal: Not a valid revision: ${local}`);
138
+ // this also verifies that the head is unique: show-ref could have listed several refs
139
+ const headrev = await this.verify(`${head}^0`);
140
+ if (headrev === undefined) throw new RequestPullDeath(`fatal: Ambiguous revision: ${local}`);
141
+ const localSha1 = (await this.verify(head)) ?? "";
142
+
143
+ // was it a branch with a description?
144
+ const config = RemoteConfigStore.from(this._workingCopy);
145
+ const branchName = head.startsWith("refs/heads/") ? head.slice("refs/heads/".length) : head;
146
+ const description = config.value(`branch.${branchName}.description`);
147
+
148
+ const mergeBase = (
149
+ await new MergeBaseCommand(this._workingCopy).addCommit(baserev).addCommit(headrev).call()
150
+ ).bases[0];
151
+ if (mergeBase === undefined) {
152
+ throw new RequestPullDeath(`fatal: No commits in common between ${base} and ${head}`);
153
+ }
154
+
155
+ // a ref of the remote's name at the remote, at the commit asked for
156
+ const asked = remote || "HEAD";
157
+ const found = this.matchRef(await this.listRemote(url, err), asked, headrev);
158
+ if (!found) {
159
+ err.push(`warn: No match for commit ${headrev} found at ${url}\n`);
160
+ err.push(`warn: Are you sure you pushed '${asked}' there?\n`);
161
+ status = 1;
162
+ } else if (localSha1 !== found.remoteSha1) {
163
+ err.push(`warn: ${head} found at ${url} but points to a different object\n`);
164
+ err.push(`warn: Are you sure you pushed '${asked}' there?\n`);
165
+ status = 1;
166
+ }
167
+ // special case: turn "for_linus" to "tags/for_linus" when it is correct
168
+ if (found?.ref === `refs/tags/${prettyRemote}`) prettyRemote = `tags/${prettyRemote}`;
169
+
170
+ const fetchUrl = await this.configureChild(new LsRemoteCommand(this._workingCopy))
171
+ .setRemote(url)
172
+ .callGetUrl();
173
+
174
+ out.push(
175
+ await this.show(
176
+ mergeBase,
177
+ "The following changes since commit %H:\n\n %s (%ci)\n\nare available in the Git repository at:\n",
178
+ ),
179
+ );
180
+ out.push(` ${fetchUrl} ${prettyRemote}\n`);
181
+ out.push(
182
+ await this.show(headrev, `\nfor you to fetch changes up to %H:\n\n %s (%ci)\n\n${RULE}`),
183
+ );
184
+ const tag = await this.tagMessage(localSha1);
185
+ if (tag !== undefined) out.push(`${tag}\n${RULE}\n`);
186
+ if (branchName && description !== undefined) {
187
+ out.push(`(from the branch description for ${branchName} local branch)\n\n`);
188
+ out.push(`${description}\n${RULE}\n`);
189
+ }
190
+
191
+ const shortlog = new ShortlogCommand(this._workingCopy)
192
+ .addArgument(`^${baserev}`)
193
+ .addArgument(headrev);
194
+ out.push(await shortlog.callText());
195
+ for (const line of shortlog.getErrors()) err.push(`${line}\n`);
196
+
197
+ const diff = new DiffCommand(this._workingCopy)
198
+ .setOldTree(mergeBase)
199
+ .setNewTree(headrev)
200
+ .setOptions({ findRenames: true });
201
+ const { bytes } = await diff.callFormats(
202
+ this.patch ? ["stat", "summary", "patch"] : ["stat", "summary"],
203
+ );
204
+ if (bytes) out.push(decodeGitPath(bytes));
205
+ return status;
206
+ }
207
+
208
+ /** `git rev-parse --verify --quiet <name>`: undefined when it names no single object. */
209
+ private async verify(name: string): Promise<ObjectId | undefined> {
210
+ if (name.includes("\n")) return undefined;
211
+ try {
212
+ return await this.revisionResolver().resolve(name);
213
+ } catch {
214
+ return undefined;
215
+ }
216
+ }
217
+
218
+ /** `git symbolic-ref -q <name>`: the ref a symbolic ref names, else undefined. */
219
+ private async symbolicRef(name: string): Promise<string | undefined> {
220
+ try {
221
+ const ref = await this.refsStore.get(name);
222
+ return ref && isSymbolicRef(ref) ? ref.target : undefined;
223
+ } catch {
224
+ return undefined;
225
+ }
226
+ }
227
+
228
+ /**
229
+ * `git show-ref --heads --tags <name> | cut -d' ' -f2`: the branches and tags the name ends
230
+ * (several lines when it names several, which `rev-parse` then refuses).
231
+ */
232
+ private async showRef(name: string): Promise<string | undefined> {
233
+ const r = await new ShowRefCommand(this._workingCopy)
234
+ .setHeads(true)
235
+ .setTags(true)
236
+ .addPattern(name)
237
+ .callOutput();
238
+ const text = decodeGitPath(r.stdout).replace(/\n+$/, "");
239
+ if (!text) return undefined;
240
+ return text
241
+ .split("\n")
242
+ .map((line) => line.split(" ")[1] ?? "")
243
+ .join("\n");
244
+ }
245
+
246
+ /**
247
+ * `git ls-remote <url>`: HEAD first, then each ref and its peeled object (`<ref>^{}`). A
248
+ * listing that fails leaves its lines on stderr and lists nothing, as the pipe does.
249
+ */
250
+ private async listRemote(url: string, err: string[]): Promise<ListedRef[]> {
251
+ try {
252
+ const r = await this.configureChild(new LsRemoteCommand(this._workingCopy))
253
+ .setRemote(url)
254
+ .call();
255
+ const lines: ListedRef[] = [];
256
+ if (r.head) lines.push([r.head, "HEAD"]);
257
+ for (const ref of r.refs) {
258
+ lines.push([ref.objectId, ref.name]);
259
+ if (ref.peeledObjectId) lines.push([ref.peeledObjectId, `${ref.name}^{}`]);
260
+ }
261
+ return lines;
262
+ } catch (error) {
263
+ if (!(error instanceof GitApiError)) throw error;
264
+ err.push(`${error.message}\n`);
265
+ return [];
266
+ }
267
+ }
268
+
269
+ /**
270
+ * find_matching_ref: the remote ref named `asked` (or ending in `/<asked>`) at `headrev`,
271
+ * with the object the remote's matching unpeeled ref names. 2.50+ (a shell loop) stops at
272
+ * the first match; 2.43's Perl script meant to (`break` is no Perl statement) and keeps the
273
+ * last one, the object of the last unpeeled matching ref.
274
+ */
275
+ private matchRef(
276
+ lines: ListedRef[],
277
+ asked: string,
278
+ headrev: ObjectId,
279
+ ): { remoteSha1: string; ref: string } | undefined {
280
+ const matches = (ref: string) => ref === asked || ref.endsWith(`/${asked}`);
281
+ if (this.compatibility === "2.43") {
282
+ let remoteSha1: string | undefined;
283
+ let found: string | undefined;
284
+ for (const [sha1, line] of lines) {
285
+ // /^(\S+)\s+([^^]+)(\S*)$/
286
+ const caret = line.indexOf("^");
287
+ const ref = caret >= 0 ? line.slice(0, caret) : line;
288
+ const deref = caret >= 0 ? line.slice(caret) : "";
289
+ if (!ref) continue;
290
+ if (sha1 === asked) found = remoteSha1 = sha1;
291
+ if (matches(ref)) {
292
+ if (deref === "") remoteSha1 = sha1;
293
+ if (sha1 === headrev) found = ref;
294
+ }
295
+ }
296
+ return found ? { remoteSha1: remoteSha1 ?? headrev, ref: found } : undefined;
297
+ }
298
+ let remoteSha1 = "";
299
+ for (const [sha1, line] of lines) {
300
+ // *"^"?*: ${ref%"^"*}
301
+ const caret = line.lastIndexOf("^");
302
+ const deref = caret >= 0 && caret < line.length - 1;
303
+ const ref = deref ? line.slice(0, caret) : line;
304
+ if (sha1 === asked) return { remoteSha1: sha1, ref: sha1 };
305
+ if (matches(ref)) {
306
+ if (!deref) remoteSha1 = sha1;
307
+ if (sha1 === headrev) return { remoteSha1: remoteSha1 || headrev, ref };
308
+ }
309
+ }
310
+ return undefined;
311
+ }
312
+
313
+ /** `git show -s --format=<format> <id>` */
314
+ private async show(id: ObjectId, format: string): Promise<string> {
315
+ const commit = await this.commits.load(id);
316
+ if (!commit) return "";
317
+ return `${await formatCommitPretty(format, commit, id)}\n`;
318
+ }
319
+
320
+ /**
321
+ * `git cat-file tag <head> | sed -n -e '1,/^$/d' -e '/^-----BEGIN \(PGP\|SSH\|SIGNED\) /q'
322
+ * -e p` when the end names a tag: its message up to the signature (undefined otherwise).
323
+ */
324
+ private async tagMessage(id: string): Promise<string | undefined> {
325
+ const objects = this._workingCopy.history?.objects;
326
+ const object = await objects?.get(id).catch(() => undefined);
327
+ if (!object) return undefined;
328
+ if (object.type !== "tag") {
329
+ await object.content[Symbol.asyncIterator]().return?.();
330
+ return undefined;
331
+ }
332
+ const chunks: Uint8Array[] = [];
333
+ for await (const c of object.content) chunks.push(c.slice());
334
+ const bytes = new Uint8Array(chunks.reduce((n, c) => n + c.length, 0));
335
+ let at = 0;
336
+ for (const c of chunks) {
337
+ bytes.set(c, at);
338
+ at += c.length;
339
+ }
340
+ const lines = decodeGitPath(bytes).split("\n");
341
+ // a final newline leaves an empty last element, which is no line
342
+ const complete = lines[lines.length - 1] === "";
343
+ if (complete) lines.pop();
344
+ let printed = "";
345
+ // 1,/^$/d: the range's end is looked for from line 2 on
346
+ let i = 1;
347
+ while (i < lines.length && lines[i] !== "") i++;
348
+ for (i++; i < lines.length; i++) {
349
+ const line = lines[i] as string;
350
+ if (/^-----BEGIN (PGP|SSH|SIGNED) /.test(line)) break;
351
+ printed += line;
352
+ if (i < lines.length - 1 || complete) printed += "\n";
353
+ }
354
+ return printed;
355
+ }
356
+ }
@@ -0,0 +1,179 @@
1
+ /**
2
+ * `git rerere` (builtin/rerere.c): with no subcommand, rerere's record and replay (what the
3
+ * merge family runs on conflicts and `git commit` after a commit); `clear`, `forget
4
+ * <pathspec>`, `status`, `remaining`, `diff` and `gc`.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * const { stdout } = await git.rerere().setSubcommand("status").call(); // "f\n"
9
+ * await git.rerere().setSubcommand("forget").addPath("f").call();
10
+ * ```
11
+ */
12
+
13
+ import { rerereGc } from "@statewalker/vcs-store-files";
14
+ import { unifiedDiff } from "@statewalker/vcs-utils";
15
+ import { decodeGitPath, encodeGitPath } from "@statewalker/vcs-utils/encoding";
16
+
17
+ import { GitCommand } from "../git-command.js";
18
+ import type { PlumbingTextOutput } from "./check-ref-format-command.js";
19
+ import { hostEnvironmentOf } from "./git-ident.js";
20
+ import { matchPathspec, parsePathspec } from "./pathspec.js";
21
+ import {
22
+ RerereError,
23
+ type RerereHost,
24
+ rerereClear,
25
+ rerereDiff,
26
+ rerereForget,
27
+ rerereGcLocation,
28
+ rerereRemaining,
29
+ rerereStatus,
30
+ runRerere,
31
+ } from "./rerere.js";
32
+
33
+ /** The subcommands of `git rerere` (`record` is the bare `git rerere`). */
34
+ export type RerereSubcommand =
35
+ | "record"
36
+ | "clear"
37
+ | "forget"
38
+ | "status"
39
+ | "remaining"
40
+ | "diff"
41
+ | "gc";
42
+
43
+ const USAGE =
44
+ "usage: git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]\n\n" +
45
+ " --[no-]rerere-autoupdate\n" +
46
+ " register clean resolutions in index\n\n";
47
+
48
+ /**
49
+ * `git rerere [--[no-]rerere-autoupdate] [<subcommand>]`: git's stdout, stderr and exit
50
+ * status.
51
+ */
52
+ export class RerereCommand extends GitCommand<PlumbingTextOutput> {
53
+ private subcommand = "record";
54
+ private readonly paths: string[] = [];
55
+ private autoUpdate?: boolean;
56
+
57
+ /** The subcommand (default `record`, the bare `git rerere`); an unknown one is git's usage */
58
+ setSubcommand(subcommand: RerereSubcommand | string): this {
59
+ this.checkCallable();
60
+ this.subcommand = subcommand;
61
+ return this;
62
+ }
63
+
64
+ /** A pathspec element of `forget` */
65
+ addPath(path: string): this {
66
+ this.checkCallable();
67
+ this.paths.push(path);
68
+ return this;
69
+ }
70
+
71
+ /** `--rerere-autoupdate` (true) / `--no-rerere-autoupdate` (false) */
72
+ setAutoUpdate(value: boolean): this {
73
+ this.checkCallable();
74
+ this.autoUpdate = value;
75
+ return this;
76
+ }
77
+
78
+ async call(): Promise<PlumbingTextOutput> {
79
+ this.checkCallable();
80
+ this.setCallable(false);
81
+ const stderr = (lines: string[]) => lines.map((l) => `${l}\n`).join("");
82
+ try {
83
+ return await this.run(stderr);
84
+ } catch (error) {
85
+ if (error instanceof RerereError) {
86
+ return { exitCode: error.exitCode, stdout: "", stderr: stderr(error.lines) };
87
+ }
88
+ throw error;
89
+ }
90
+ }
91
+
92
+ private async run(stderr: (lines: string[]) => string): Promise<PlumbingTextOutput> {
93
+ const host = this.rerereHost();
94
+ const empty = { exitCode: 0, stdout: "", stderr: "" };
95
+ switch (this.subcommand) {
96
+ case "record": {
97
+ if (!host) return empty;
98
+ await this.staging.read();
99
+ const out = await runRerere(
100
+ host,
101
+ this.autoUpdate === undefined ? {} : { autoUpdate: this.autoUpdate },
102
+ );
103
+ return { exitCode: 0, stdout: "", stderr: stderr(out.messages) };
104
+ }
105
+ case "forget": {
106
+ if (!host) return empty;
107
+ await this.staging.read();
108
+ const items = parsePathspec(this.paths.length > 0 ? this.paths : ["."]);
109
+ const out = await rerereForget(host, (path) => matchPathspec(items, path, 0) > 0);
110
+ return { exitCode: 0, stdout: "", stderr: stderr(out.messages) };
111
+ }
112
+ case "clear": {
113
+ if (!host) return empty;
114
+ const out = await rerereClear(host);
115
+ return { exitCode: 0, stdout: "", stderr: stderr(out.messages) };
116
+ }
117
+ case "status": {
118
+ if (!host) return empty;
119
+ const paths = await rerereStatus(host);
120
+ return { exitCode: 0, stdout: paths.map((p) => `${p}\n`).join(""), stderr: "" };
121
+ }
122
+ case "remaining": {
123
+ if (!host) return empty;
124
+ await this.staging.read();
125
+ const paths = await rerereRemaining(host);
126
+ return { exitCode: 0, stdout: paths.map((p) => `${p}\n`).join(""), stderr: "" };
127
+ }
128
+ case "diff": {
129
+ if (!host) return empty;
130
+ const out = await rerereDiff(host, (minus, plus) =>
131
+ unifiedDiff(minus, plus, {
132
+ context: 3,
133
+ algorithm: "myers",
134
+ findFunction: () => undefined,
135
+ }),
136
+ );
137
+ const bytes = out.stdout.reduce((n, b) => n + b.length, 0);
138
+ const all = new Uint8Array(bytes);
139
+ let at = 0;
140
+ for (const b of out.stdout) {
141
+ all.set(b, at);
142
+ at += b.length;
143
+ }
144
+ return {
145
+ exitCode: out.fatal ? 128 : 0,
146
+ stdout: decodeGitPath(all),
147
+ stderr: out.fatal ? `fatal: ${out.fatal}\n` : "",
148
+ };
149
+ }
150
+ case "gc": {
151
+ const location = await rerereGcLocation(this.workingCopy);
152
+ if (location) {
153
+ const environment = hostEnvironmentOf(this.workingCopy);
154
+ await rerereGc({ ...location, ...(environment ? { environment } : {}) });
155
+ }
156
+ return empty;
157
+ }
158
+ default:
159
+ return { exitCode: 129, stdout: "", stderr: USAGE };
160
+ }
161
+ }
162
+
163
+ /** The bytes git writes on stdout for `diff` are its paths' bytes. */
164
+ static stdoutBytes(output: PlumbingTextOutput): Uint8Array {
165
+ return encodeGitPath(output.stdout);
166
+ }
167
+
168
+ private rerereHost(): RerereHost | undefined {
169
+ const worktree = this.worktreeAccess;
170
+ if (!worktree) return undefined;
171
+ return {
172
+ workingCopy: this.workingCopy,
173
+ staging: this.staging,
174
+ worktree,
175
+ blobs: this.blobs,
176
+ objectFormat: this.objectFormat,
177
+ };
178
+ }
179
+ }