@statewalker/vcs-commands 0.7.0 → 0.8.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 (410) hide show
  1. package/dist/commands/add-command.d.ts +38 -0
  2. package/dist/commands/add-command.d.ts.map +1 -1
  3. package/dist/commands/am/am-command.d.ts +55 -1
  4. package/dist/commands/am/am-command.d.ts.map +1 -1
  5. package/dist/commands/am/index.d.ts +1 -0
  6. package/dist/commands/am/index.d.ts.map +1 -1
  7. package/dist/commands/am/mailsplit.d.ts +88 -0
  8. package/dist/commands/am/mailsplit.d.ts.map +1 -0
  9. package/dist/commands/apply/apply-command.d.ts.map +1 -1
  10. package/dist/commands/apply/apply-engine.d.ts.map +1 -1
  11. package/dist/commands/apply/apply-parse.d.ts.map +1 -1
  12. package/dist/commands/bisect/bisect-command.d.ts +2 -0
  13. package/dist/commands/bisect/bisect-command.d.ts.map +1 -1
  14. package/dist/commands/branch-command.d.ts +148 -18
  15. package/dist/commands/branch-command.d.ts.map +1 -1
  16. package/dist/commands/branch-info-command.d.ts +55 -0
  17. package/dist/commands/branch-info-command.d.ts.map +1 -0
  18. package/dist/commands/branch-tracking.d.ts +106 -17
  19. package/dist/commands/branch-tracking.d.ts.map +1 -1
  20. package/dist/commands/branch-upstream-command.d.ts +83 -0
  21. package/dist/commands/branch-upstream-command.d.ts.map +1 -0
  22. package/dist/commands/checkout-command.d.ts +19 -3
  23. package/dist/commands/checkout-command.d.ts.map +1 -1
  24. package/dist/commands/cherry-pick-command.d.ts +59 -0
  25. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  26. package/dist/commands/clean-command.d.ts +12 -0
  27. package/dist/commands/clean-command.d.ts.map +1 -1
  28. package/dist/commands/clone-command.d.ts.map +1 -1
  29. package/dist/commands/commit-command.d.ts +191 -5
  30. package/dist/commands/commit-command.d.ts.map +1 -1
  31. package/dist/commands/commit-reuse.d.ts +33 -0
  32. package/dist/commands/commit-reuse.d.ts.map +1 -0
  33. package/dist/commands/config-command.d.ts +236 -0
  34. package/dist/commands/config-command.d.ts.map +1 -0
  35. package/dist/commands/config-value-types.d.ts +91 -0
  36. package/dist/commands/config-value-types.d.ts.map +1 -0
  37. package/dist/commands/core-config.d.ts +20 -0
  38. package/dist/commands/core-config.d.ts.map +1 -1
  39. package/dist/commands/diff-color-config.d.ts +73 -0
  40. package/dist/commands/diff-color-config.d.ts.map +1 -0
  41. package/dist/commands/diff-command.d.ts +252 -5
  42. package/dist/commands/diff-command.d.ts.map +1 -1
  43. package/dist/commands/fetch-command.d.ts +20 -0
  44. package/dist/commands/fetch-command.d.ts.map +1 -1
  45. package/dist/commands/fmt-merge-msg-command.d.ts +124 -0
  46. package/dist/commands/fmt-merge-msg-command.d.ts.map +1 -0
  47. package/dist/commands/fork-point.d.ts +38 -0
  48. package/dist/commands/fork-point.d.ts.map +1 -0
  49. package/dist/commands/format-patch-command.d.ts +41 -1
  50. package/dist/commands/format-patch-command.d.ts.map +1 -1
  51. package/dist/commands/fsck/fetch-fsck.d.ts +51 -0
  52. package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -1
  53. package/dist/commands/gc-command.d.ts +8 -0
  54. package/dist/commands/gc-command.d.ts.map +1 -1
  55. package/dist/commands/git-describe.d.ts +4 -0
  56. package/dist/commands/git-describe.d.ts.map +1 -1
  57. package/dist/commands/git-hooks.d.ts +35 -0
  58. package/dist/commands/git-hooks.d.ts.map +1 -1
  59. package/dist/commands/grep/grep-command.d.ts +210 -0
  60. package/dist/commands/grep/grep-command.d.ts.map +1 -0
  61. package/dist/commands/grep/grep-engine.d.ts +218 -0
  62. package/dist/commands/grep/grep-engine.d.ts.map +1 -0
  63. package/dist/commands/grep/index.d.ts +3 -0
  64. package/dist/commands/grep/index.d.ts.map +1 -0
  65. package/dist/commands/index-adder.d.ts +13 -2
  66. package/dist/commands/index-adder.d.ts.map +1 -1
  67. package/dist/commands/index.d.ts +26 -0
  68. package/dist/commands/index.d.ts.map +1 -1
  69. package/dist/commands/index.js +3 -3
  70. package/dist/commands/interpret-trailers-command.d.ts +90 -0
  71. package/dist/commands/interpret-trailers-command.d.ts.map +1 -0
  72. package/dist/commands/local-transport.d.ts +36 -5
  73. package/dist/commands/local-transport.d.ts.map +1 -1
  74. package/dist/commands/log-command.d.ts +296 -11
  75. package/dist/commands/log-command.d.ts.map +1 -1
  76. package/dist/commands/log-graph.d.ts +26 -1
  77. package/dist/commands/log-graph.d.ts.map +1 -1
  78. package/dist/commands/log-output.d.ts +133 -5
  79. package/dist/commands/log-output.d.ts.map +1 -1
  80. package/dist/commands/ls-remote-command.d.ts +2 -0
  81. package/dist/commands/ls-remote-command.d.ts.map +1 -1
  82. package/dist/commands/mailmap.d.ts +30 -0
  83. package/dist/commands/mailmap.d.ts.map +1 -1
  84. package/dist/commands/merge-base-command.d.ts +60 -0
  85. package/dist/commands/merge-base-command.d.ts.map +1 -0
  86. package/dist/commands/merge-bases.d.ts +23 -0
  87. package/dist/commands/merge-bases.d.ts.map +1 -1
  88. package/dist/commands/merge-command.d.ts +96 -9
  89. package/dist/commands/merge-command.d.ts.map +1 -1
  90. package/dist/commands/merge-support.d.ts.map +1 -1
  91. package/dist/commands/mv-command.d.ts +4 -0
  92. package/dist/commands/mv-command.d.ts.map +1 -1
  93. package/dist/commands/name-rev.d.ts +48 -0
  94. package/dist/commands/name-rev.d.ts.map +1 -0
  95. package/dist/commands/notes-command.d.ts.map +1 -1
  96. package/dist/commands/pathspec-file.d.ts +39 -0
  97. package/dist/commands/pathspec-file.d.ts.map +1 -0
  98. package/dist/commands/pathspec.d.ts +3 -0
  99. package/dist/commands/pathspec.d.ts.map +1 -1
  100. package/dist/commands/pretty-format.d.ts +43 -3
  101. package/dist/commands/pretty-format.d.ts.map +1 -1
  102. package/dist/commands/promisor-remote.d.ts.map +1 -1
  103. package/dist/commands/pull-command.d.ts +10 -0
  104. package/dist/commands/pull-command.d.ts.map +1 -1
  105. package/dist/commands/push-command.d.ts +160 -9
  106. package/dist/commands/push-command.d.ts.map +1 -1
  107. package/dist/commands/read-tree-command.d.ts +6 -0
  108. package/dist/commands/read-tree-command.d.ts.map +1 -1
  109. package/dist/commands/rebase-command.d.ts +168 -6
  110. package/dist/commands/rebase-command.d.ts.map +1 -1
  111. package/dist/commands/ref-filter/for-each-ref-command.d.ts +121 -0
  112. package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -0
  113. package/dist/commands/ref-filter/index.d.ts +8 -0
  114. package/dist/commands/ref-filter/index.d.ts.map +1 -0
  115. package/dist/commands/ref-filter/ref-atoms.d.ts +88 -0
  116. package/dist/commands/ref-filter/ref-atoms.d.ts.map +1 -0
  117. package/dist/commands/ref-filter/ref-filter.d.ts +178 -0
  118. package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -0
  119. package/dist/commands/ref-filter/ref-format.d.ts +222 -0
  120. package/dist/commands/ref-filter/ref-format.d.ts.map +1 -0
  121. package/dist/commands/ref-filter/ref-listing-command.d.ts +56 -0
  122. package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -0
  123. package/dist/commands/ref-filter/ref-quote.d.ts +20 -0
  124. package/dist/commands/ref-filter/ref-quote.d.ts.map +1 -0
  125. package/dist/commands/ref-filter/version-compare.d.ts +20 -0
  126. package/dist/commands/ref-filter/version-compare.d.ts.map +1 -0
  127. package/dist/commands/reflog-command.d.ts +120 -0
  128. package/dist/commands/reflog-command.d.ts.map +1 -1
  129. package/dist/commands/reflog-walk.d.ts +72 -0
  130. package/dist/commands/reflog-walk.d.ts.map +1 -0
  131. package/dist/commands/remote-command.d.ts +138 -29
  132. package/dist/commands/remote-command.d.ts.map +1 -1
  133. package/dist/commands/remote-transport.d.ts +7 -1
  134. package/dist/commands/remote-transport.d.ts.map +1 -1
  135. package/dist/commands/reset-command.d.ts +2 -3
  136. package/dist/commands/reset-command.d.ts.map +1 -1
  137. package/dist/commands/restore-command.d.ts +2 -3
  138. package/dist/commands/restore-command.d.ts.map +1 -1
  139. package/dist/commands/rev-filter/commit-filter.d.ts +95 -0
  140. package/dist/commands/rev-filter/commit-filter.d.ts.map +1 -0
  141. package/dist/commands/rev-filter/commit-grep.d.ts +91 -0
  142. package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -0
  143. package/dist/commands/rev-filter/index.d.ts +3 -0
  144. package/dist/commands/rev-filter/index.d.ts.map +1 -0
  145. package/dist/commands/rev-list-command.d.ts +154 -2
  146. package/dist/commands/rev-list-command.d.ts.map +1 -1
  147. package/dist/commands/revert-command.d.ts +32 -0
  148. package/dist/commands/revert-command.d.ts.map +1 -1
  149. package/dist/commands/revision-range.d.ts +32 -1
  150. package/dist/commands/revision-range.d.ts.map +1 -1
  151. package/dist/commands/revision-resolver.d.ts +15 -0
  152. package/dist/commands/revision-resolver.d.ts.map +1 -1
  153. package/dist/commands/rm-command.d.ts +70 -2
  154. package/dist/commands/rm-command.d.ts.map +1 -1
  155. package/dist/commands/sequencer-pick.d.ts +84 -4
  156. package/dist/commands/sequencer-pick.d.ts.map +1 -1
  157. package/dist/commands/sequencer-support.d.ts +2 -0
  158. package/dist/commands/sequencer-support.d.ts.map +1 -1
  159. package/dist/commands/serve-repository.d.ts +7 -0
  160. package/dist/commands/serve-repository.d.ts.map +1 -1
  161. package/dist/commands/show-command.d.ts +130 -0
  162. package/dist/commands/show-command.d.ts.map +1 -0
  163. package/dist/commands/show-commit.d.ts +11 -0
  164. package/dist/commands/show-commit.d.ts.map +1 -0
  165. package/dist/commands/signature-check.d.ts +164 -0
  166. package/dist/commands/signature-check.d.ts.map +1 -0
  167. package/dist/commands/signing.d.ts +160 -0
  168. package/dist/commands/signing.d.ts.map +1 -0
  169. package/dist/commands/sparse-checkout-command.d.ts.map +1 -1
  170. package/dist/commands/sparse-index-view.d.ts +45 -0
  171. package/dist/commands/sparse-index-view.d.ts.map +1 -0
  172. package/dist/commands/ssh-signer.d.ts +29 -0
  173. package/dist/commands/ssh-signer.d.ts.map +1 -0
  174. package/dist/commands/ssh-verifier.d.ts +42 -0
  175. package/dist/commands/ssh-verifier.d.ts.map +1 -0
  176. package/dist/commands/stash-apply-command.d.ts +5 -0
  177. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  178. package/dist/commands/stash-branch-command.d.ts +34 -0
  179. package/dist/commands/stash-branch-command.d.ts.map +1 -0
  180. package/dist/commands/stash-create-command.d.ts +17 -0
  181. package/dist/commands/stash-create-command.d.ts.map +1 -1
  182. package/dist/commands/stash-info.d.ts +93 -0
  183. package/dist/commands/stash-info.d.ts.map +1 -0
  184. package/dist/commands/stash-list-command.d.ts +16 -0
  185. package/dist/commands/stash-list-command.d.ts.map +1 -1
  186. package/dist/commands/stash-pop-command.d.ts +39 -0
  187. package/dist/commands/stash-pop-command.d.ts.map +1 -0
  188. package/dist/commands/stash-show-command.d.ts +48 -0
  189. package/dist/commands/stash-show-command.d.ts.map +1 -0
  190. package/dist/commands/stash-store-command.d.ts +29 -0
  191. package/dist/commands/stash-store-command.d.ts.map +1 -0
  192. package/dist/commands/stash-working-tree.d.ts.map +1 -1
  193. package/dist/commands/status-command.d.ts.map +1 -1
  194. package/dist/commands/status-header.d.ts +5 -0
  195. package/dist/commands/status-header.d.ts.map +1 -1
  196. package/dist/commands/submodule-add-command.d.ts +89 -0
  197. package/dist/commands/submodule-add-command.d.ts.map +1 -0
  198. package/dist/commands/submodule-auth.d.ts +90 -0
  199. package/dist/commands/submodule-auth.d.ts.map +1 -0
  200. package/dist/commands/submodule-commands.d.ts +375 -0
  201. package/dist/commands/submodule-commands.d.ts.map +1 -0
  202. package/dist/commands/submodule-model.d.ts +288 -0
  203. package/dist/commands/submodule-model.d.ts.map +1 -0
  204. package/dist/commands/submodule-update-command.d.ts +198 -0
  205. package/dist/commands/submodule-update-command.d.ts.map +1 -0
  206. package/dist/commands/switch-command.d.ts.map +1 -1
  207. package/dist/commands/tag-command.d.ts +259 -10
  208. package/dist/commands/tag-command.d.ts.map +1 -1
  209. package/dist/commands/trailers.d.ts +218 -17
  210. package/dist/commands/trailers.d.ts.map +1 -1
  211. package/dist/commands/tree-restore.d.ts +7 -0
  212. package/dist/commands/tree-restore.d.ts.map +1 -1
  213. package/dist/commands/verify-command.d.ts +92 -0
  214. package/dist/commands/verify-command.d.ts.map +1 -0
  215. package/dist/commands/worktree-add-command.d.ts +79 -7
  216. package/dist/commands/worktree-add-command.d.ts.map +1 -1
  217. package/dist/commands/worktree-path-rules.d.ts +66 -0
  218. package/dist/commands/worktree-path-rules.d.ts.map +1 -0
  219. package/dist/commands/worktree-remove-command.d.ts +10 -3
  220. package/dist/commands/worktree-remove-command.d.ts.map +1 -1
  221. package/dist/commands/worktree-repair-command.d.ts +15 -2
  222. package/dist/commands/worktree-repair-command.d.ts.map +1 -1
  223. package/dist/commands/worktree-support.d.ts +5 -0
  224. package/dist/commands/worktree-support.d.ts.map +1 -1
  225. package/dist/{commands-DIJ91NnD.js → commands-ISM52N0n.js} +70736 -54492
  226. package/dist/errors/checkout-errors.d.ts +19 -0
  227. package/dist/errors/checkout-errors.d.ts.map +1 -1
  228. package/dist/errors/command-errors.d.ts.map +1 -1
  229. package/dist/errors/index.js +57 -3
  230. package/dist/errors/ref-errors.d.ts +19 -0
  231. package/dist/errors/ref-errors.d.ts.map +1 -1
  232. package/dist/errors/worktree-errors.d.ts +6 -1
  233. package/dist/errors/worktree-errors.d.ts.map +1 -1
  234. package/dist/{git-command-BGiOJ8Zk.js → fsck-DLRpbwTj.js} +6230 -71
  235. package/dist/git-command.d.ts +27 -1
  236. package/dist/git-command.d.ts.map +1 -1
  237. package/dist/git.d.ts +267 -1
  238. package/dist/git.d.ts.map +1 -1
  239. package/dist/index.js +5 -5
  240. package/dist/remote-config/index.d.ts +1 -1
  241. package/dist/remote-config/index.d.ts.map +1 -1
  242. package/dist/remote-config/remote-config-store.d.ts +55 -0
  243. package/dist/remote-config/remote-config-store.d.ts.map +1 -1
  244. package/dist/results/combined-diff.d.ts +3 -0
  245. package/dist/results/combined-diff.d.ts.map +1 -1
  246. package/dist/results/diff-check.d.ts +38 -0
  247. package/dist/results/diff-check.d.ts.map +1 -0
  248. package/dist/results/diff-color.d.ts +135 -0
  249. package/dist/results/diff-color.d.ts.map +1 -0
  250. package/dist/results/diff-output.d.ts +85 -1
  251. package/dist/results/diff-output.d.ts.map +1 -1
  252. package/dist/results/diff-pickaxe.d.ts +67 -0
  253. package/dist/results/diff-pickaxe.d.ts.map +1 -0
  254. package/dist/results/diff-words.d.ts +55 -0
  255. package/dist/results/diff-words.d.ts.map +1 -0
  256. package/dist/results/index.d.ts +4 -0
  257. package/dist/results/index.d.ts.map +1 -1
  258. package/dist/results/index.js +2 -2
  259. package/dist/results/push-result.d.ts +7 -0
  260. package/dist/results/push-result.d.ts.map +1 -1
  261. package/dist/results/rebase-result.d.ts +2 -0
  262. package/dist/results/rebase-result.d.ts.map +1 -1
  263. package/dist/results/stash-result.d.ts +6 -0
  264. package/dist/results/stash-result.d.ts.map +1 -1
  265. package/dist/{results-WVlBhVb1.js → results-TB2IJ64h.js} +2168 -403
  266. package/dist/whitespace/index.d.ts +2 -0
  267. package/dist/whitespace/index.d.ts.map +1 -0
  268. package/dist/whitespace/whitespace-rule.d.ts +94 -0
  269. package/dist/whitespace/whitespace-rule.d.ts.map +1 -0
  270. package/package.json +12 -12
  271. package/src/commands/add-command.ts +178 -17
  272. package/src/commands/am/am-command.ts +262 -42
  273. package/src/commands/am/index.ts +1 -0
  274. package/src/commands/am/mailsplit.ts +326 -0
  275. package/src/commands/apply/apply-command.ts +6 -6
  276. package/src/commands/apply/apply-engine.ts +1 -1
  277. package/src/commands/apply/apply-parse.ts +7 -8
  278. package/src/commands/bisect/bisect-command.ts +18 -5
  279. package/src/commands/branch-command.ts +528 -53
  280. package/src/commands/branch-info-command.ts +150 -0
  281. package/src/commands/branch-tracking.ts +335 -60
  282. package/src/commands/branch-upstream-command.ts +218 -0
  283. package/src/commands/checkout-command.ts +69 -43
  284. package/src/commands/cherry-pick-command.ts +143 -0
  285. package/src/commands/clean-command.ts +34 -3
  286. package/src/commands/clone-command.ts +2 -1
  287. package/src/commands/commit-command.ts +782 -64
  288. package/src/commands/commit-reuse.ts +94 -0
  289. package/src/commands/config-command.ts +1256 -0
  290. package/src/commands/config-value-types.ts +358 -0
  291. package/src/commands/core-config.ts +40 -0
  292. package/src/commands/diff-color-config.ts +274 -0
  293. package/src/commands/diff-command.ts +1009 -49
  294. package/src/commands/fetch-command.ts +142 -8
  295. package/src/commands/fmt-merge-msg-command.ts +715 -0
  296. package/src/commands/fork-point.ts +63 -0
  297. package/src/commands/format-patch-command.ts +314 -46
  298. package/src/commands/fsck/fetch-fsck.ts +172 -18
  299. package/src/commands/gc-command.ts +31 -1
  300. package/src/commands/git-describe.ts +31 -11
  301. package/src/commands/git-hooks.ts +81 -0
  302. package/src/commands/grep/grep-command.ts +1077 -0
  303. package/src/commands/grep/grep-engine.ts +1024 -0
  304. package/src/commands/grep/index.ts +2 -0
  305. package/src/commands/index-adder.ts +46 -7
  306. package/src/commands/index.ts +26 -0
  307. package/src/commands/interpret-trailers-command.ts +256 -0
  308. package/src/commands/local-transport.ts +109 -10
  309. package/src/commands/log-command.ts +1246 -210
  310. package/src/commands/log-graph.ts +123 -26
  311. package/src/commands/log-output.ts +280 -21
  312. package/src/commands/ls-remote-command.ts +5 -0
  313. package/src/commands/mailmap.ts +119 -0
  314. package/src/commands/merge-base-command.ts +170 -0
  315. package/src/commands/merge-bases.ts +63 -8
  316. package/src/commands/merge-command.ts +330 -82
  317. package/src/commands/merge-support.ts +14 -1
  318. package/src/commands/mv-command.ts +6 -3
  319. package/src/commands/name-rev.ts +171 -0
  320. package/src/commands/notes-command.ts +11 -1
  321. package/src/commands/pathspec-file.ts +72 -0
  322. package/src/commands/pathspec.ts +14 -2
  323. package/src/commands/pretty-format.ts +103 -19
  324. package/src/commands/promisor-remote.ts +10 -1
  325. package/src/commands/pull-command.ts +26 -7
  326. package/src/commands/push-command.ts +682 -65
  327. package/src/commands/read-tree-command.ts +28 -1
  328. package/src/commands/rebase-command.ts +933 -129
  329. package/src/commands/ref-filter/for-each-ref-command.ts +298 -0
  330. package/src/commands/ref-filter/index.ts +7 -0
  331. package/src/commands/ref-filter/ref-atoms.ts +581 -0
  332. package/src/commands/ref-filter/ref-filter.ts +651 -0
  333. package/src/commands/ref-filter/ref-format.ts +1070 -0
  334. package/src/commands/ref-filter/ref-listing-command.ts +421 -0
  335. package/src/commands/ref-filter/ref-quote.ts +69 -0
  336. package/src/commands/ref-filter/version-compare.ts +177 -0
  337. package/src/commands/reflog-command.ts +492 -2
  338. package/src/commands/reflog-walk.ts +234 -0
  339. package/src/commands/remote-command.ts +449 -69
  340. package/src/commands/remote-transport.ts +9 -1
  341. package/src/commands/reset-command.ts +36 -31
  342. package/src/commands/restore-command.ts +12 -41
  343. package/src/commands/rev-filter/commit-filter.ts +159 -0
  344. package/src/commands/rev-filter/commit-grep.ts +444 -0
  345. package/src/commands/rev-filter/index.ts +2 -0
  346. package/src/commands/rev-list-command.ts +402 -15
  347. package/src/commands/revert-command.ts +82 -0
  348. package/src/commands/revision-range.ts +204 -4
  349. package/src/commands/revision-resolver.ts +23 -8
  350. package/src/commands/rm-command.ts +282 -21
  351. package/src/commands/sequencer-pick.ts +498 -85
  352. package/src/commands/sequencer-support.ts +20 -2
  353. package/src/commands/serve-repository.ts +18 -3
  354. package/src/commands/show-command.ts +490 -0
  355. package/src/commands/show-commit.ts +24 -0
  356. package/src/commands/signature-check.ts +657 -0
  357. package/src/commands/signing.ts +385 -0
  358. package/src/commands/sparse-checkout-command.ts +2 -9
  359. package/src/commands/sparse-checkout-support.ts +2 -2
  360. package/src/commands/sparse-index-view.ts +135 -0
  361. package/src/commands/ssh-signer.ts +199 -0
  362. package/src/commands/ssh-verifier.ts +523 -0
  363. package/src/commands/stash-apply-command.ts +16 -4
  364. package/src/commands/stash-branch-command.ts +88 -0
  365. package/src/commands/stash-create-command.ts +28 -0
  366. package/src/commands/stash-info.ts +243 -0
  367. package/src/commands/stash-list-command.ts +33 -0
  368. package/src/commands/stash-pop-command.ts +83 -0
  369. package/src/commands/stash-show-command.ts +141 -0
  370. package/src/commands/stash-store-command.ts +82 -0
  371. package/src/commands/stash-working-tree.ts +2 -2
  372. package/src/commands/status-command.ts +5 -2
  373. package/src/commands/status-header.ts +41 -7
  374. package/src/commands/submodule-add-command.ts +509 -0
  375. package/src/commands/submodule-auth.ts +276 -0
  376. package/src/commands/submodule-commands.ts +1517 -0
  377. package/src/commands/submodule-model.ts +930 -0
  378. package/src/commands/submodule-update-command.ts +1092 -0
  379. package/src/commands/switch-command.ts +3 -1
  380. package/src/commands/tag-command.ts +876 -64
  381. package/src/commands/trailers.ts +837 -100
  382. package/src/commands/tree-restore.ts +38 -10
  383. package/src/commands/verify-command.ts +235 -0
  384. package/src/commands/worktree-add-command.ts +268 -24
  385. package/src/commands/worktree-path-rules.ts +183 -0
  386. package/src/commands/worktree-remove-command.ts +39 -5
  387. package/src/commands/worktree-repair-command.ts +52 -5
  388. package/src/commands/worktree-support.ts +22 -1
  389. package/src/errors/checkout-errors.ts +29 -0
  390. package/src/errors/command-errors.ts +2 -1
  391. package/src/errors/ref-errors.ts +23 -0
  392. package/src/errors/worktree-errors.ts +8 -1
  393. package/src/git-command.ts +66 -1
  394. package/src/git.ts +404 -1
  395. package/src/remote-config/index.ts +2 -0
  396. package/src/remote-config/remote-config-store.ts +101 -0
  397. package/src/results/combined-diff.ts +38 -18
  398. package/src/results/diff-check.ts +185 -0
  399. package/src/results/diff-color.ts +868 -0
  400. package/src/results/diff-output.ts +195 -30
  401. package/src/results/diff-pickaxe.ts +304 -0
  402. package/src/results/diff-words.ts +395 -0
  403. package/src/results/index.ts +4 -0
  404. package/src/results/push-result.ts +7 -0
  405. package/src/results/rebase-result.ts +3 -0
  406. package/src/results/stash-result.ts +7 -0
  407. package/src/whitespace/index.ts +1 -0
  408. package/src/{commands/apply/whitespace.ts → whitespace/whitespace-rule.ts} +173 -23
  409. package/dist/commands/apply/whitespace.d.ts +0 -58
  410. package/dist/commands/apply/whitespace.d.ts.map +0 -1
@@ -11,11 +11,17 @@
11
11
  * copies none (only `rebase --apply` does, through `rewritten`).
12
12
  */
13
13
 
14
- import { formatPersonIdent, type ObjectId, type PersonIdent } from "@statewalker/vcs-core";
15
-
14
+ import {
15
+ type Commit,
16
+ formatPersonIdent,
17
+ type ObjectId,
18
+ type PersonIdent,
19
+ } from "@statewalker/vcs-core";
20
+ import { parseGitBool } from "@statewalker/vcs-utils";
16
21
  import { compareGitPaths, encodeGitPath } from "@statewalker/vcs-utils/encoding";
17
-
22
+ import { wildmatch } from "@statewalker/vcs-working-tree";
18
23
  import { GitCommand } from "../../git-command.js";
24
+ import { RemoteConfigStore } from "../../remote-config/index.js";
19
25
  import { quotePath } from "../../results/quote-path.js";
20
26
  import { ApplyCommand } from "../apply/apply-command.js";
21
27
  import { ApplyEngine, type ApplyIO } from "../apply/apply-engine.js";
@@ -47,8 +53,11 @@ import { ortResultEntries } from "../ort-merge.js";
47
53
  import { mergeStoredTrees, storedBase } from "../ort-recursive.js";
48
54
  import { updateHead, updateHeadExpecting } from "../reflog-messages.js";
49
55
  import { removeBranchState, resetMerge, resetUnmergedToHead } from "../sequencer-support.js";
56
+ import { showCommitBytes } from "../show-commit.js";
57
+ import { SigningFailedError, signCommit, signPayload, signRequestOf } from "../signing.js";
50
58
  import { appendSignoff } from "../trailers.js";
51
- import { mailinfo, mailsplit } from "./mailinfo.js";
59
+ import { mailinfo } from "./mailinfo.js";
60
+ import { type MailsplitSource, splitMail } from "./mailsplit.js";
52
61
  import {
53
62
  type AmPatchFormat,
54
63
  detectPatchFormat,
@@ -66,7 +75,15 @@ export interface AmResult {
66
75
  errors: string;
67
76
  }
68
77
 
69
- type Resume = "apply" | "continue" | "allow-empty" | "skip" | "abort" | "quit";
78
+ type Resume =
79
+ | "apply"
80
+ | "continue"
81
+ | "allow-empty"
82
+ | "skip"
83
+ | "abort"
84
+ | "quit"
85
+ | "show-raw"
86
+ | "show-diff";
70
87
 
71
88
  /** The options `git am` passes to `git apply` (kept in `apply-opt`). */
72
89
  export interface AmApplyOptions {
@@ -86,6 +103,28 @@ export interface AmApplyOptions {
86
103
  reject?: boolean;
87
104
  /** `--ignore-whitespace` */
88
105
  ignoreWhitespace?: boolean;
106
+ /** `--ignore-space-change` */
107
+ ignoreSpaceChange?: boolean;
108
+ }
109
+
110
+ /**
111
+ * The `git apply` options `git am` keeps in `apply-opt`, set on an apply: both the first
112
+ * attempt and the 3-way fallback's apply to the fake ancestor take all of them
113
+ * (`run_apply`).
114
+ */
115
+ function configureApply(cmd: ApplyCommand, opts: string[]): ApplyCommand {
116
+ for (const a of opts) {
117
+ if (a.startsWith("-C")) cmd.setContext(Number(a.slice(2)));
118
+ else if (a.startsWith("-p")) cmd.setStrip(Number(a.slice(2)));
119
+ else if (a.startsWith("--whitespace=")) cmd.setWhitespace(a.slice(13));
120
+ else if (a.startsWith("--directory=")) cmd.setDirectory(a.slice(12));
121
+ else if (a.startsWith("--exclude=")) cmd.addExclude(a.slice(10));
122
+ else if (a.startsWith("--include=")) cmd.addInclude(a.slice(10));
123
+ else if (a === "--reject") cmd.setReject(true);
124
+ else if (a === "--ignore-whitespace" || a === "--ignore-space-change")
125
+ cmd.setIgnoreWhitespace(true);
126
+ }
127
+ return cmd;
89
128
  }
90
129
 
91
130
  /** `sq_quote_buf`. */
@@ -131,7 +170,11 @@ function sqDequoteAll(s: string): string[] {
131
170
  * ```
132
171
  */
133
172
  export class AmCommand extends GitCommand<AmResult> {
134
- private mboxes: { content: string; name?: string }[] = [];
173
+ private mboxes: {
174
+ content: string;
175
+ name?: string;
176
+ maildir?: { name: string; content: Uint8Array | string }[];
177
+ }[] = [];
135
178
  private patchFormat?: AmPatchFormat;
136
179
  private fixedClock?: number;
137
180
  private resume?: Resume;
@@ -141,8 +184,11 @@ export class AmCommand extends GitCommand<AmResult> {
141
184
  private keep: "t" | "b" | "f" = "f";
142
185
  private messageId?: boolean;
143
186
  private scissors?: boolean;
187
+ private quotedCr?: "nowarn" | "warn" | "strip";
144
188
  private quiet = false;
145
189
  private noVerify = false;
190
+ /** `-S[<keyid>]` / `--no-gpg-sign` (undefined: `commit.gpgSign`) */
191
+ private sign?: boolean | string;
146
192
  private utf8 = true;
147
193
  private ignoreDate = false;
148
194
  private committerDateIsAuthorDate = false;
@@ -164,6 +210,18 @@ export class AmCommand extends GitCommand<AmResult> {
164
210
  return this;
165
211
  }
166
212
 
213
+ /**
214
+ * A Maildir to apply, in order (`git am <dir>`): its messages, each named by its path in
215
+ * the Maildir (`cur/<file>`, `new/<file>`), split as `git mailsplit` splits a Maildir
216
+ * (`cur/` then `new/`, numbers in names compared as numbers). `name` is the directory as
217
+ * git names it in messages. A Maildir given first is read as mailboxes (git's format
218
+ * detection takes a directory for mbox).
219
+ */
220
+ addMaildir(messages: { name: string; content: Uint8Array | string }[], name: string): this {
221
+ this.mboxes.push({ content: "", name, maildir: messages });
222
+ return this;
223
+ }
224
+
167
225
  /**
168
226
  * `--patch-format=<format>`: mbox, mboxrd, stgit or hg (Mercurial); detected from the
169
227
  * first named mailbox when not given. An StGit series (`stgit-series`) names its patch
@@ -194,6 +252,17 @@ export class AmCommand extends GitCommand<AmResult> {
194
252
  return this;
195
253
  }
196
254
 
255
+ /**
256
+ * `--show-current-patch[=raw|diff]`: the mail of the patch that stopped (`raw`, the
257
+ * default) or its diff (`diff`, `rebase-apply/patch`) on stdout, as they stand in
258
+ * `.git/rebase-apply/`; a session of `rebase --apply` shows its original commit
259
+ * (`git show <original-commit>`).
260
+ */
261
+ setShowCurrentPatch(mode: "raw" | "diff" = "raw"): this {
262
+ this.resume = mode === "diff" ? "show-diff" : "show-raw";
263
+ return this;
264
+ }
265
+
197
266
  /** `-3` / `--3way` (default `am.threeWay`). */
198
267
  setThreeWay(value: boolean): this {
199
268
  this.threeWay = value;
@@ -224,12 +293,23 @@ export class AmCommand extends GitCommand<AmResult> {
224
293
  return this;
225
294
  }
226
295
 
227
- /** `-c` / `--scissors`, `--no-scissors`. */
296
+ /** `-c` / `--scissors`, `--no-scissors` (default `mailinfo.scissors`). */
228
297
  setScissors(value: boolean): this {
229
298
  this.scissors = value;
230
299
  return this;
231
300
  }
232
301
 
302
+ /**
303
+ * `--quoted-cr=<action>`: what mailinfo does with a CRLF line ending of a base64 or
304
+ * quoted-printable body (`warn`, the default from `mailinfo.quotedCr`, warns `quoted CRLF
305
+ * detected`; `strip` drops the CR; `nowarn` keeps it silently). Kept in `quoted-cr` for the
306
+ * whole session.
307
+ */
308
+ setQuotedCr(action: "nowarn" | "warn" | "strip"): this {
309
+ this.quotedCr = action;
310
+ return this;
311
+ }
312
+
233
313
  /** `--no-verify`: the applypatch-msg and pre-applypatch hooks do not run. */
234
314
  setNoVerify(value: boolean): this {
235
315
  this.checkCallable();
@@ -237,6 +317,27 @@ export class AmCommand extends GitCommand<AmResult> {
237
317
  return this;
238
318
  }
239
319
 
320
+ /**
321
+ * `-S` (true) / `--no-gpg-sign` (false): whether to sign the commits; undefined (the
322
+ * default) leaves it to `commit.gpgSign`. Each commit is signed through the host's signer
323
+ * (`GitHostEnvironment.signer`) as git's commit_tree signs it; when it cannot be signed the
324
+ * am fails as git's does (`error: gpg failed to sign the data:`, `fatal: failed to write
325
+ * commit object`, exit 128), the patch left applied to the index in `.git/rebase-apply`
326
+ * and nothing committed.
327
+ */
328
+ setSign(sign: boolean | undefined): this {
329
+ this.checkCallable();
330
+ this.sign = sign;
331
+ return this;
332
+ }
333
+
334
+ /** `-S<keyid>`: sign with this key (see {@link setSign}). */
335
+ setSigningKey(keyId: string): this {
336
+ this.checkCallable();
337
+ this.sign = keyId;
338
+ return this;
339
+ }
340
+
240
341
  /** `-q`. */
241
342
  setQuiet(value: boolean): this {
242
343
  this.quiet = value;
@@ -351,6 +452,7 @@ export class AmCommand extends GitCommand<AmResult> {
351
452
  }
352
453
  if (mode === "abort") return this.abort();
353
454
  const st = await this.load();
455
+ if (mode === "show-raw" || mode === "show-diff") return this.showPatch(st, mode);
354
456
  if (mode === "skip") {
355
457
  // am_skip: clean_index(HEAD, HEAD), then the next patch
356
458
  const head = await this.headId();
@@ -373,6 +475,23 @@ export class AmCommand extends GitCommand<AmResult> {
373
475
  return this.setup();
374
476
  }
375
477
 
478
+ /** git's show_patch. */
479
+ private async showPatch(st: AmState, mode: "show-raw" | "show-diff"): Promise<AmResult> {
480
+ const original = (await this.read("original-commit"))?.trim();
481
+ if (original) {
482
+ // `git show <original-commit> --`
483
+ this.out += bytesToLatin1(await showCommitBytes(this.workingCopy, original));
484
+ return this.result(0);
485
+ }
486
+ const name = mode === "show-raw" ? String(st.cur).padStart(4, "0") : "patch";
487
+ const content = await this.read(name);
488
+ if (content === undefined) {
489
+ this.fatal(`failed to read '.git/${DIR}/${name}': No such file or directory`);
490
+ }
491
+ this.out += content;
492
+ return this.result(0);
493
+ }
494
+
376
495
  private async setup(): Promise<AmResult> {
377
496
  const state = this.state();
378
497
  const bool = (k: string) => {
@@ -388,7 +507,7 @@ export class AmCommand extends GitCommand<AmResult> {
388
507
  this.patchFormat ??
389
508
  (this.mboxrd
390
509
  ? "mboxrd"
391
- : first?.name !== undefined
510
+ : first?.name !== undefined && !first.maildir
392
511
  ? detectPatchFormat(first.content)
393
512
  : "mbox");
394
513
  if (!format) {
@@ -403,15 +522,18 @@ export class AmCommand extends GitCommand<AmResult> {
403
522
  };
404
523
  const inputs = this.mboxes.length ? this.mboxes : [{ content: "" }];
405
524
  if (format === "mbox" || format === "mboxrd") {
406
- for (const mbox of inputs) {
407
- // mailsplit: an empty file (git's isspace: space, tab, LF, CR) is an error, empty
408
- // standard input is not
409
- if (mbox.name !== undefined && /^[ \t\n\r]*$/.test(mbox.content)) {
410
- this.err += `error: empty mbox: '${mbox.name}'\n`;
411
- failSplit(`cannot split patches from ${mbox.name}`);
412
- }
413
- mails.push(...mailsplit(mbox.content, { keepCr, mboxrd: format === "mboxrd" }));
525
+ // split_mail_mbox: git mailsplit -d4 -b [--keep-cr] [--mboxrd] -- <paths>
526
+ const sources: MailsplitSource[] = inputs.map((m) =>
527
+ m.maildir
528
+ ? { maildir: m.maildir, name: m.name as string }
529
+ : { mbox: latin1ToBytes(m.content), ...(m.name !== undefined ? { name: m.name } : {}) },
530
+ );
531
+ const split = splitMail(sources, { allowBare: true, keepCr, mboxrd: format === "mboxrd" });
532
+ if (split.exitCode) {
533
+ this.err += split.errors;
534
+ this.fatal("Failed to split patches.");
414
535
  }
536
+ for (const f of split.files) mails.push(bytesToLatin1(f.content));
415
537
  } else if (format === "stgit-series") {
416
538
  // split_mail_stgit_series: one named series file, whose patches are files next to it
417
539
  // (this command reads no files: the first one cannot be opened)
@@ -430,6 +552,7 @@ export class AmCommand extends GitCommand<AmResult> {
430
552
  mails.push(stgitPatchToMail(""));
431
553
  } else {
432
554
  for (const mbox of inputs) {
555
+ if (mbox.maildir) failSplit(`could not open '${mbox.name}' for reading: Is a directory`);
433
556
  if (format === "stgit") mails.push(stgitPatchToMail(mbox.content));
434
557
  else {
435
558
  const r = hgPatchToMail(mbox.content);
@@ -450,7 +573,7 @@ export class AmCommand extends GitCommand<AmResult> {
450
573
  await this.writeText("keep", this.keep);
451
574
  await this.writeText("messageid", messageId ? "t" : "f");
452
575
  await this.writeText("scissors", this.scissors === undefined ? "" : this.scissors ? "t" : "f");
453
- await this.writeText("quoted-cr", "");
576
+ await this.writeText("quoted-cr", this.quotedCr ?? "");
454
577
  await this.writeText(
455
578
  "apply-opt",
456
579
  this.applyArgs()
@@ -482,6 +605,7 @@ export class AmCommand extends GitCommand<AmResult> {
482
605
  for (const e of o.include ?? []) args.push(`--include=${e}`);
483
606
  if (o.reject) args.push("--reject");
484
607
  if (o.ignoreWhitespace) args.push("--ignore-whitespace");
608
+ if (o.ignoreSpaceChange) args.push("--ignore-space-change");
485
609
  return args;
486
610
  }
487
611
 
@@ -497,6 +621,7 @@ export class AmCommand extends GitCommand<AmResult> {
497
621
  keep: ((await t("keep")) || "f") as "t" | "b" | "f",
498
622
  messageId: (await t("messageid")) === "t",
499
623
  scissors: await t("scissors"),
624
+ quotedCr: await t("quoted-cr"),
500
625
  applyOpts: sqDequoteAll(await t("apply-opt")),
501
626
  };
502
627
  const script = await this.read("author-script");
@@ -594,11 +719,16 @@ export class AmCommand extends GitCommand<AmResult> {
594
719
  this.fatal(`cannot resume: .git/${DIR}/final-commit does not exist.`);
595
720
  if (!st.author) this.fatal(`cannot resume: .git/${DIR}/author-script does not exist.`);
596
721
  } else {
722
+ // setup_mailinfo: mailinfo.scissors and mailinfo.quotedCr, then the session's options
723
+ const config = this.mailinfoConfig();
724
+ const quotedCr = (st.quotedCr || config.quotedCr) as "nowarn" | "warn" | "strip";
725
+ const useScissors = st.scissors ? st.scissors === "t" : config.scissors;
597
726
  const mi = mailinfo(mail, {
598
727
  keepSubject: st.keep === "t",
599
728
  keepNonPatchBrackets: st.keep === "b",
600
729
  addMessageId: st.messageId,
601
- ...(st.scissors ? { useScissors: st.scissors === "t" } : {}),
730
+ useScissors,
731
+ quotedCr,
602
732
  utf8: st.utf8,
603
733
  // metainfo_charset: get_commit_output_encoding()
604
734
  charset: configValue(this.workingCopy, "i18n.commitEncoding") ?? "UTF-8",
@@ -689,22 +819,54 @@ export class AmCommand extends GitCommand<AmResult> {
689
819
  return this.result(0);
690
820
  }
691
821
 
822
+ /**
823
+ * `setup_mailinfo`'s config (`git_mailinfo_config`, in config order): `mailinfo.scissors`
824
+ * and `mailinfo.quotedCr`; a value git refuses dies as git's config callback does.
825
+ */
826
+ private mailinfoConfig(): { scissors: boolean; quotedCr: "nowarn" | "warn" | "strip" } {
827
+ const out: { scissors: boolean; quotedCr: "nowarn" | "warn" | "strip" } = {
828
+ scissors: false,
829
+ quotedCr: "warn",
830
+ };
831
+ if (!this.workingCopy.config) return out;
832
+ const store = RemoteConfigStore.from(this.workingCopy);
833
+ const where = (key: string, file?: string, line?: number) =>
834
+ file !== undefined && line !== undefined
835
+ ? `bad config variable '${key}' in file '${file}' at line ${line}`
836
+ : `unable to parse '${key}' from command-line config`;
837
+ const entries = store.entriesWithOriginFor(["mailinfo.scissors", "mailinfo.quotedcr"]) ?? [
838
+ ...store
839
+ .valuesWithOrigin("mailinfo.scissors")
840
+ .map((e) => ({ ...e, key: "mailinfo.scissors" })),
841
+ ...store
842
+ .valuesWithOrigin("mailinfo.quotedcr")
843
+ .map((e) => ({ ...e, key: "mailinfo.quotedcr" })),
844
+ ];
845
+ for (const e of entries) {
846
+ if (e.key === "mailinfo.scissors") {
847
+ const v = e.text === undefined ? true : parseGitBool(e.text);
848
+ if (v === undefined) this.fatal(`bad boolean config value '${e.text}' for '${e.key}'`);
849
+ out.scissors = v;
850
+ } else if (e.text === undefined) {
851
+ this.err += `error: missing value for '${e.key}'\n`;
852
+ this.fatal(where(e.key, e.file, e.line));
853
+ } else if (e.text === "nowarn" || e.text === "warn" || e.text === "strip") {
854
+ out.quotedCr = e.text;
855
+ } else {
856
+ this.err += `error: bad action '${e.text}' for '${e.key}'\n`;
857
+ this.fatal(where(e.key, e.file, e.line));
858
+ }
859
+ }
860
+ return out;
861
+ }
862
+
692
863
  private async runApply(st: AmState): Promise<number> {
693
864
  const patch = (await this.read("patch")) ?? "";
694
865
  const cmd = new ApplyCommand(this.workingCopy)
695
866
  .addPatch(latin1ToBytes(patch), `.git/${DIR}/patch`)
696
867
  .setIndex(true)
697
868
  .setLegacyMessages(this.legacyMessages);
698
- for (const a of st.applyOpts) {
699
- if (a.startsWith("-C")) cmd.setContext(Number(a.slice(2)));
700
- else if (a.startsWith("-p")) cmd.setStrip(Number(a.slice(2)));
701
- else if (a.startsWith("--whitespace=")) cmd.setWhitespace(a.slice(13));
702
- else if (a.startsWith("--directory=")) cmd.setDirectory(a.slice(12));
703
- else if (a.startsWith("--exclude=")) cmd.addExclude(a.slice(10));
704
- else if (a.startsWith("--include=")) cmd.addInclude(a.slice(10));
705
- else if (a === "--reject") cmd.setReject(true);
706
- else if (a === "--ignore-whitespace") cmd.setIgnoreWhitespace(true);
707
- }
869
+ configureApply(cmd, st.applyOpts);
708
870
  if (st.threeway) cmd.setVerbose(false);
709
871
  const r = await cmd.call();
710
872
  this.out += pathToLatin1(r.output);
@@ -722,10 +884,15 @@ export class AmCommand extends GitCommand<AmResult> {
722
884
  undefined as unknown as ApplyIO,
723
885
  () => undefined,
724
886
  async () => 0,
725
- () => false,
887
+ (pattern, text) => wildmatch(latin1ToPath(pattern), latin1ToPath(text)),
726
888
  );
727
889
  for (const a of st.applyOpts) {
728
- if (a.startsWith("-p")) {
890
+ // --include/--exclude limit the patches the fake ancestor is built from too
891
+ if (a.startsWith("--exclude=") || a.startsWith("--include=")) {
892
+ const include = a.startsWith("--include=");
893
+ parser.limitByName.push({ pattern: pathToLatin1(a.slice(10)), include });
894
+ if (include) parser.hasInclude = true;
895
+ } else if (a.startsWith("-p")) {
729
896
  parser.pValue = Number(a.slice(2));
730
897
  parser.pValueKnown = true;
731
898
  } else if (a.startsWith("--directory="))
@@ -803,12 +970,7 @@ export class AmCommand extends GitCommand<AmResult> {
803
970
  .addPatch(latin1ToBytes(patch), `.git/${DIR}/patch`)
804
971
  .setTemporaryIndex(fake)
805
972
  .setLegacyMessages(this.legacyMessages);
806
- for (const a of st.applyOpts) {
807
- if (a.startsWith("-C")) apply.setContext(Number(a.slice(2)));
808
- else if (a.startsWith("-p")) apply.setStrip(Number(a.slice(2)));
809
- else if (a.startsWith("--whitespace=")) apply.setWhitespace(a.slice(13));
810
- else if (a.startsWith("--directory=")) apply.setDirectory(a.slice(12));
811
- }
973
+ configureApply(apply, st.applyOpts);
812
974
  const applied = await apply.call();
813
975
  this.out += pathToLatin1(applied.output);
814
976
  this.err += pathToLatin1(applied.errors);
@@ -921,17 +1083,49 @@ export class AmCommand extends GitCommand<AmResult> {
921
1083
  author = { ...author, name: latin1ToPath(author.name), email: latin1ToPath(author.email) };
922
1084
  const message = latin1ToPath(msg);
923
1085
  const parents = head ? [head] : [];
1086
+ // commit_tree_extended signs before writing: when it cannot, git's failure and nothing
1087
+ // written
1088
+ const sign = signRequestOf(this.workingCopy, this.sign);
924
1089
  const objects = this.workingCopy.history?.objects;
925
1090
  let id: ObjectId;
926
1091
  if (!isUtf8Encoding(commitEncoding) && objects) {
927
1092
  // commit_tree_extended: the `encoding` header, the message and idents as their bytes
928
- let text = `tree ${tree}\n`;
929
- for (const p of parents) text += `parent ${p}\n`;
930
- text += `author ${formatPersonIdent(author)}\ncommitter ${formatPersonIdent(committer)}\n`;
931
- text += `encoding ${commitEncoding}\n\n${message}`;
932
- id = await objects.putUnsized("commit", [encodeGitPath(text)]);
1093
+ let head = `tree ${tree}\n`;
1094
+ for (const p of parents) head += `parent ${p}\n`;
1095
+ head += `author ${formatPersonIdent(author)}\ncommitter ${formatPersonIdent(committer)}\n`;
1096
+ head += `encoding ${commitEncoding}\n`;
1097
+ const body = `\n${message}`;
1098
+ let header = "";
1099
+ if (sign !== undefined) {
1100
+ const payload = encodeGitPath(head + body);
1101
+ const signature = latin1ToPath(
1102
+ bytesToLatin1(
1103
+ await this.signOrDie((cwd) =>
1104
+ signPayload(this.workingCopy, sign, payload, {
1105
+ committer,
1106
+ tail: [],
1107
+ ...(cwd !== undefined ? { cwd } : {}),
1108
+ }),
1109
+ ),
1110
+ ),
1111
+ );
1112
+ // add_header_signature: the repository's header (`gpgsig`, `gpgsig-sha256` in a
1113
+ // SHA-256 repository) after the other headers, continuation lines indented
1114
+ const lines = (signature.endsWith("\n") ? signature.slice(0, -1) : signature).split("\n");
1115
+ header = `${this.objectFormat.signatureHeader} ${lines.join("\n ")}\n`;
1116
+ }
1117
+ id = await objects.putUnsized("commit", [encodeGitPath(head + header + body)]);
933
1118
  } else {
934
- id = await this.commits.store({ tree, parents, author, committer, message });
1119
+ let commit: Commit = { tree, parents, author, committer, message };
1120
+ if (sign !== undefined) {
1121
+ commit = await this.signOrDie((cwd) =>
1122
+ signCommit(this.workingCopy, sign, commit, {
1123
+ tail: [],
1124
+ ...(cwd !== undefined ? { cwd } : {}),
1125
+ }),
1126
+ );
1127
+ }
1128
+ id = await this.commits.store(commit);
935
1129
  }
936
1130
  const action = this.reflogAction("am");
937
1131
  // do_commit's update_ref("HEAD", commit, old_oid): HEAD expecting the commit it left
@@ -945,6 +1139,30 @@ export class AmCommand extends GitCommand<AmResult> {
945
1139
  await this.runAmHook("post-applypatch");
946
1140
  }
947
1141
 
1142
+ /**
1143
+ * Runs a signing (`run(cwd)`, the signing program in the worktree top) as do_commit's
1144
+ * commit_tree: a signature that cannot be made adds gpg's lines and dies with `fatal:
1145
+ * failed to write commit object` (exit 128), or as the signing itself died.
1146
+ */
1147
+ private async signOrDie<T>(run: (cwd: string | undefined) => Promise<T>): Promise<T> {
1148
+ let cwd: string | undefined;
1149
+ try {
1150
+ cwd = await this.hooks.hostWorkingDirectory();
1151
+ } catch {
1152
+ cwd = undefined;
1153
+ }
1154
+ try {
1155
+ return await run(cwd);
1156
+ } catch (error) {
1157
+ if (!(error instanceof SigningFailedError)) throw error;
1158
+ const lines = error.message.split("\n");
1159
+ this.err += `${lines.map(pathToLatin1).join("\n")}\n`;
1160
+ // the signing died itself (ssh without a key): nothing follows
1161
+ if (lines[lines.length - 1]?.startsWith("fatal: ")) throw new AmStop(128);
1162
+ this.fatal("failed to write commit object");
1163
+ }
1164
+ }
1165
+
948
1166
  private async resolve(st: AmState, allowEmpty: boolean): Promise<AmResult> {
949
1167
  if (st.msg === undefined) this.fatal(`cannot resume: .git/${DIR}/final-commit does not exist.`);
950
1168
  if (!st.author) this.fatal(`cannot resume: .git/${DIR}/author-script does not exist.`);
@@ -1036,6 +1254,8 @@ interface AmState {
1036
1254
  keep: "t" | "b" | "f";
1037
1255
  messageId: boolean;
1038
1256
  scissors: string;
1257
+ /** `quoted-cr`: nowarn, warn, strip, or empty (`mailinfo.quotedCr`) */
1258
+ quotedCr: string;
1039
1259
  applyOpts: string[];
1040
1260
  author?: { name: string; email: string; date: string };
1041
1261
  msg?: string;
@@ -1,2 +1,3 @@
1
1
  export * from "./am-command.js";
2
2
  export { type MailInfo, type MailInfoOptions, mailinfo, mailsplit } from "./mailinfo.js";
3
+ export * from "./mailsplit.js";