@statewalker/vcs-commands 0.7.0 → 0.9.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 (568) hide show
  1. package/dist/commands/add-command.d.ts +70 -0
  2. package/dist/commands/add-command.d.ts.map +1 -1
  3. package/dist/commands/add-patch/add-patch.d.ts +7 -0
  4. package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
  5. package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
  6. package/dist/commands/am/am-command.d.ts +102 -1
  7. package/dist/commands/am/am-command.d.ts.map +1 -1
  8. package/dist/commands/am/index.d.ts +1 -0
  9. package/dist/commands/am/index.d.ts.map +1 -1
  10. package/dist/commands/am/mailsplit.d.ts +88 -0
  11. package/dist/commands/am/mailsplit.d.ts.map +1 -0
  12. package/dist/commands/apply/apply-command.d.ts +2 -0
  13. package/dist/commands/apply/apply-command.d.ts.map +1 -1
  14. package/dist/commands/apply/apply-engine.d.ts.map +1 -1
  15. package/dist/commands/apply/apply-parse.d.ts +7 -0
  16. package/dist/commands/apply/apply-parse.d.ts.map +1 -1
  17. package/dist/commands/apply/index.d.ts +1 -1
  18. package/dist/commands/apply/index.d.ts.map +1 -1
  19. package/dist/commands/bisect/bisect-command.d.ts +2 -0
  20. package/dist/commands/bisect/bisect-command.d.ts.map +1 -1
  21. package/dist/commands/blame-command.d.ts +303 -8
  22. package/dist/commands/blame-command.d.ts.map +1 -1
  23. package/dist/commands/blame-ignore.d.ts +48 -0
  24. package/dist/commands/blame-ignore.d.ts.map +1 -0
  25. package/dist/commands/branch-command.d.ts +148 -18
  26. package/dist/commands/branch-command.d.ts.map +1 -1
  27. package/dist/commands/branch-info-command.d.ts +55 -0
  28. package/dist/commands/branch-info-command.d.ts.map +1 -0
  29. package/dist/commands/branch-tracking.d.ts +106 -17
  30. package/dist/commands/branch-tracking.d.ts.map +1 -1
  31. package/dist/commands/branch-upstream-command.d.ts +83 -0
  32. package/dist/commands/branch-upstream-command.d.ts.map +1 -0
  33. package/dist/commands/check-mailmap-command.d.ts +49 -0
  34. package/dist/commands/check-mailmap-command.d.ts.map +1 -0
  35. package/dist/commands/checkout-command.d.ts +26 -3
  36. package/dist/commands/checkout-command.d.ts.map +1 -1
  37. package/dist/commands/checkout-paths.d.ts +4 -0
  38. package/dist/commands/checkout-paths.d.ts.map +1 -1
  39. package/dist/commands/cherry-command.d.ts +61 -0
  40. package/dist/commands/cherry-command.d.ts.map +1 -0
  41. package/dist/commands/cherry-pick-command.d.ts +82 -1
  42. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  43. package/dist/commands/clean-command.d.ts +44 -0
  44. package/dist/commands/clean-command.d.ts.map +1 -1
  45. package/dist/commands/clean-interactive.d.ts +56 -0
  46. package/dist/commands/clean-interactive.d.ts.map +1 -0
  47. package/dist/commands/clone-command.d.ts +116 -2
  48. package/dist/commands/clone-command.d.ts.map +1 -1
  49. package/dist/commands/commit-command.d.ts +239 -5
  50. package/dist/commands/commit-command.d.ts.map +1 -1
  51. package/dist/commands/commit-reuse.d.ts +33 -0
  52. package/dist/commands/commit-reuse.d.ts.map +1 -0
  53. package/dist/commands/config-command.d.ts +236 -0
  54. package/dist/commands/config-command.d.ts.map +1 -0
  55. package/dist/commands/config-value-types.d.ts +91 -0
  56. package/dist/commands/config-value-types.d.ts.map +1 -0
  57. package/dist/commands/core-config.d.ts +20 -0
  58. package/dist/commands/core-config.d.ts.map +1 -1
  59. package/dist/commands/describe-command.d.ts +71 -64
  60. package/dist/commands/describe-command.d.ts.map +1 -1
  61. package/dist/commands/diff-color-config.d.ts +73 -0
  62. package/dist/commands/diff-color-config.d.ts.map +1 -0
  63. package/dist/commands/diff-command.d.ts +369 -10
  64. package/dist/commands/diff-command.d.ts.map +1 -1
  65. package/dist/commands/fetch-command.d.ts +80 -0
  66. package/dist/commands/fetch-command.d.ts.map +1 -1
  67. package/dist/commands/fetch-multiple-command.d.ts +193 -0
  68. package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
  69. package/dist/commands/fmt-merge-msg-command.d.ts +124 -0
  70. package/dist/commands/fmt-merge-msg-command.d.ts.map +1 -0
  71. package/dist/commands/fork-point.d.ts +38 -0
  72. package/dist/commands/fork-point.d.ts.map +1 -0
  73. package/dist/commands/format-patch-command.d.ts +69 -3
  74. package/dist/commands/format-patch-command.d.ts.map +1 -1
  75. package/dist/commands/fsck/fetch-fsck.d.ts +51 -0
  76. package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -1
  77. package/dist/commands/gc-command.d.ts +8 -0
  78. package/dist/commands/gc-command.d.ts.map +1 -1
  79. package/dist/commands/git-describe.d.ts +81 -4
  80. package/dist/commands/git-describe.d.ts.map +1 -1
  81. package/dist/commands/git-hooks.d.ts +50 -1
  82. package/dist/commands/git-hooks.d.ts.map +1 -1
  83. package/dist/commands/grep/grep-command.d.ts +210 -0
  84. package/dist/commands/grep/grep-command.d.ts.map +1 -0
  85. package/dist/commands/grep/grep-engine.d.ts +218 -0
  86. package/dist/commands/grep/grep-engine.d.ts.map +1 -0
  87. package/dist/commands/grep/index.d.ts +3 -0
  88. package/dist/commands/grep/index.d.ts.map +1 -0
  89. package/dist/commands/index-adder.d.ts +13 -2
  90. package/dist/commands/index-adder.d.ts.map +1 -1
  91. package/dist/commands/index.d.ts +38 -0
  92. package/dist/commands/index.d.ts.map +1 -1
  93. package/dist/commands/index.js +5 -3
  94. package/dist/commands/init-command.d.ts +89 -0
  95. package/dist/commands/init-command.d.ts.map +1 -1
  96. package/dist/commands/interpret-trailers-command.d.ts +90 -0
  97. package/dist/commands/interpret-trailers-command.d.ts.map +1 -0
  98. package/dist/commands/line-log.d.ts +161 -0
  99. package/dist/commands/line-log.d.ts.map +1 -0
  100. package/dist/commands/local-transport.d.ts +36 -5
  101. package/dist/commands/local-transport.d.ts.map +1 -1
  102. package/dist/commands/log-command.d.ts +527 -13
  103. package/dist/commands/log-command.d.ts.map +1 -1
  104. package/dist/commands/log-graph.d.ts +30 -3
  105. package/dist/commands/log-graph.d.ts.map +1 -1
  106. package/dist/commands/log-output.d.ts +199 -6
  107. package/dist/commands/log-output.d.ts.map +1 -1
  108. package/dist/commands/ls-remote-command.d.ts +2 -0
  109. package/dist/commands/ls-remote-command.d.ts.map +1 -1
  110. package/dist/commands/mailmap.d.ts +53 -0
  111. package/dist/commands/mailmap.d.ts.map +1 -1
  112. package/dist/commands/merge-base-command.d.ts +60 -0
  113. package/dist/commands/merge-base-command.d.ts.map +1 -0
  114. package/dist/commands/merge-bases.d.ts +23 -0
  115. package/dist/commands/merge-bases.d.ts.map +1 -1
  116. package/dist/commands/merge-command.d.ts +147 -10
  117. package/dist/commands/merge-command.d.ts.map +1 -1
  118. package/dist/commands/merge-drivers.d.ts +2 -0
  119. package/dist/commands/merge-drivers.d.ts.map +1 -1
  120. package/dist/commands/merge-strategy-options.d.ts +69 -0
  121. package/dist/commands/merge-strategy-options.d.ts.map +1 -0
  122. package/dist/commands/merge-support.d.ts +10 -0
  123. package/dist/commands/merge-support.d.ts.map +1 -1
  124. package/dist/commands/message-cleanup.d.ts +2 -0
  125. package/dist/commands/message-cleanup.d.ts.map +1 -1
  126. package/dist/commands/mv-command.d.ts +4 -0
  127. package/dist/commands/mv-command.d.ts.map +1 -1
  128. package/dist/commands/name-rev-command.d.ts +65 -0
  129. package/dist/commands/name-rev-command.d.ts.map +1 -0
  130. package/dist/commands/name-rev.d.ts +136 -0
  131. package/dist/commands/name-rev.d.ts.map +1 -0
  132. package/dist/commands/notes-command.d.ts.map +1 -1
  133. package/dist/commands/octopus-merge.d.ts +26 -1
  134. package/dist/commands/octopus-merge.d.ts.map +1 -1
  135. package/dist/commands/ort-merge.d.ts +16 -0
  136. package/dist/commands/ort-merge.d.ts.map +1 -1
  137. package/dist/commands/ort-recursive.d.ts.map +1 -1
  138. package/dist/commands/patch-id.d.ts +58 -0
  139. package/dist/commands/patch-id.d.ts.map +1 -1
  140. package/dist/commands/pathspec-file.d.ts +39 -0
  141. package/dist/commands/pathspec-file.d.ts.map +1 -0
  142. package/dist/commands/pathspec.d.ts +3 -0
  143. package/dist/commands/pathspec.d.ts.map +1 -1
  144. package/dist/commands/pretty-format.d.ts +43 -3
  145. package/dist/commands/pretty-format.d.ts.map +1 -1
  146. package/dist/commands/promisor-remote.d.ts.map +1 -1
  147. package/dist/commands/pull-command.d.ts +186 -32
  148. package/dist/commands/pull-command.d.ts.map +1 -1
  149. package/dist/commands/push-command.d.ts +225 -9
  150. package/dist/commands/push-command.d.ts.map +1 -1
  151. package/dist/commands/range-diff/index.d.ts +4 -0
  152. package/dist/commands/range-diff/index.d.ts.map +1 -0
  153. package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
  154. package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
  155. package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
  156. package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
  157. package/dist/commands/range-diff/range-diff.d.ts +106 -0
  158. package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
  159. package/dist/commands/read-tree-command.d.ts +20 -0
  160. package/dist/commands/read-tree-command.d.ts.map +1 -1
  161. package/dist/commands/rebase-command.d.ts +189 -8
  162. package/dist/commands/rebase-command.d.ts.map +1 -1
  163. package/dist/commands/ref-filter/for-each-ref-command.d.ts +121 -0
  164. package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -0
  165. package/dist/commands/ref-filter/index.d.ts +8 -0
  166. package/dist/commands/ref-filter/index.d.ts.map +1 -0
  167. package/dist/commands/ref-filter/ref-atoms.d.ts +88 -0
  168. package/dist/commands/ref-filter/ref-atoms.d.ts.map +1 -0
  169. package/dist/commands/ref-filter/ref-filter.d.ts +178 -0
  170. package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -0
  171. package/dist/commands/ref-filter/ref-format.d.ts +222 -0
  172. package/dist/commands/ref-filter/ref-format.d.ts.map +1 -0
  173. package/dist/commands/ref-filter/ref-listing-command.d.ts +56 -0
  174. package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -0
  175. package/dist/commands/ref-filter/ref-quote.d.ts +20 -0
  176. package/dist/commands/ref-filter/ref-quote.d.ts.map +1 -0
  177. package/dist/commands/ref-filter/version-compare.d.ts +20 -0
  178. package/dist/commands/ref-filter/version-compare.d.ts.map +1 -0
  179. package/dist/commands/reflog-command.d.ts +120 -0
  180. package/dist/commands/reflog-command.d.ts.map +1 -1
  181. package/dist/commands/reflog-walk.d.ts +72 -0
  182. package/dist/commands/reflog-walk.d.ts.map +1 -0
  183. package/dist/commands/remerge-diff.d.ts +59 -0
  184. package/dist/commands/remerge-diff.d.ts.map +1 -0
  185. package/dist/commands/remote-command.d.ts +179 -29
  186. package/dist/commands/remote-command.d.ts.map +1 -1
  187. package/dist/commands/remote-show-command.d.ts +204 -0
  188. package/dist/commands/remote-show-command.d.ts.map +1 -0
  189. package/dist/commands/remote-transport.d.ts +7 -1
  190. package/dist/commands/remote-transport.d.ts.map +1 -1
  191. package/dist/commands/reset-command.d.ts +21 -4
  192. package/dist/commands/reset-command.d.ts.map +1 -1
  193. package/dist/commands/restore-command.d.ts +9 -3
  194. package/dist/commands/restore-command.d.ts.map +1 -1
  195. package/dist/commands/rev-filter/commit-filter.d.ts +95 -0
  196. package/dist/commands/rev-filter/commit-filter.d.ts.map +1 -0
  197. package/dist/commands/rev-filter/commit-grep.d.ts +91 -0
  198. package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -0
  199. package/dist/commands/rev-filter/index.d.ts +3 -0
  200. package/dist/commands/rev-filter/index.d.ts.map +1 -0
  201. package/dist/commands/rev-list-command.d.ts +226 -2
  202. package/dist/commands/rev-list-command.d.ts.map +1 -1
  203. package/dist/commands/revert-command.d.ts +54 -1
  204. package/dist/commands/revert-command.d.ts.map +1 -1
  205. package/dist/commands/revision-range.d.ts +34 -1
  206. package/dist/commands/revision-range.d.ts.map +1 -1
  207. package/dist/commands/revision-resolver.d.ts +15 -0
  208. package/dist/commands/revision-resolver.d.ts.map +1 -1
  209. package/dist/commands/rm-command.d.ts +70 -2
  210. package/dist/commands/rm-command.d.ts.map +1 -1
  211. package/dist/commands/sequencer-pick.d.ts +186 -5
  212. package/dist/commands/sequencer-pick.d.ts.map +1 -1
  213. package/dist/commands/sequencer-support.d.ts +12 -1
  214. package/dist/commands/sequencer-support.d.ts.map +1 -1
  215. package/dist/commands/serve-repository.d.ts +7 -0
  216. package/dist/commands/serve-repository.d.ts.map +1 -1
  217. package/dist/commands/shortlog-command.d.ts +109 -0
  218. package/dist/commands/shortlog-command.d.ts.map +1 -0
  219. package/dist/commands/shortlog.d.ts +151 -0
  220. package/dist/commands/shortlog.d.ts.map +1 -0
  221. package/dist/commands/show-command.d.ts +130 -0
  222. package/dist/commands/show-command.d.ts.map +1 -0
  223. package/dist/commands/show-commit.d.ts +11 -0
  224. package/dist/commands/show-commit.d.ts.map +1 -0
  225. package/dist/commands/signature-check.d.ts +164 -0
  226. package/dist/commands/signature-check.d.ts.map +1 -0
  227. package/dist/commands/signing.d.ts +160 -0
  228. package/dist/commands/signing.d.ts.map +1 -0
  229. package/dist/commands/sparse-checkout-command.d.ts.map +1 -1
  230. package/dist/commands/sparse-index-view.d.ts +45 -0
  231. package/dist/commands/sparse-index-view.d.ts.map +1 -0
  232. package/dist/commands/ssh-signer.d.ts +29 -0
  233. package/dist/commands/ssh-signer.d.ts.map +1 -0
  234. package/dist/commands/ssh-verifier.d.ts +42 -0
  235. package/dist/commands/ssh-verifier.d.ts.map +1 -0
  236. package/dist/commands/stash-apply-command.d.ts +5 -0
  237. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  238. package/dist/commands/stash-branch-command.d.ts +34 -0
  239. package/dist/commands/stash-branch-command.d.ts.map +1 -0
  240. package/dist/commands/stash-create-command.d.ts +17 -0
  241. package/dist/commands/stash-create-command.d.ts.map +1 -1
  242. package/dist/commands/stash-info.d.ts +93 -0
  243. package/dist/commands/stash-info.d.ts.map +1 -0
  244. package/dist/commands/stash-list-command.d.ts +16 -0
  245. package/dist/commands/stash-list-command.d.ts.map +1 -1
  246. package/dist/commands/stash-pop-command.d.ts +39 -0
  247. package/dist/commands/stash-pop-command.d.ts.map +1 -0
  248. package/dist/commands/stash-show-command.d.ts +48 -0
  249. package/dist/commands/stash-show-command.d.ts.map +1 -0
  250. package/dist/commands/stash-store-command.d.ts +29 -0
  251. package/dist/commands/stash-store-command.d.ts.map +1 -0
  252. package/dist/commands/stash-working-tree.d.ts.map +1 -1
  253. package/dist/commands/status-command.d.ts +31 -2
  254. package/dist/commands/status-command.d.ts.map +1 -1
  255. package/dist/commands/status-header.d.ts +5 -0
  256. package/dist/commands/status-header.d.ts.map +1 -1
  257. package/dist/commands/submodule-add-command.d.ts +89 -0
  258. package/dist/commands/submodule-add-command.d.ts.map +1 -0
  259. package/dist/commands/submodule-auth.d.ts +90 -0
  260. package/dist/commands/submodule-auth.d.ts.map +1 -0
  261. package/dist/commands/submodule-commands.d.ts +463 -0
  262. package/dist/commands/submodule-commands.d.ts.map +1 -0
  263. package/dist/commands/submodule-fetch.d.ts +149 -0
  264. package/dist/commands/submodule-fetch.d.ts.map +1 -0
  265. package/dist/commands/submodule-model.d.ts +296 -0
  266. package/dist/commands/submodule-model.d.ts.map +1 -0
  267. package/dist/commands/submodule-unpack.d.ts +120 -0
  268. package/dist/commands/submodule-unpack.d.ts.map +1 -0
  269. package/dist/commands/submodule-update-command.d.ts +206 -0
  270. package/dist/commands/submodule-update-command.d.ts.map +1 -0
  271. package/dist/commands/subtree-shift.d.ts +27 -0
  272. package/dist/commands/subtree-shift.d.ts.map +1 -0
  273. package/dist/commands/switch-command.d.ts +3 -0
  274. package/dist/commands/switch-command.d.ts.map +1 -1
  275. package/dist/commands/tag-command.d.ts +259 -10
  276. package/dist/commands/tag-command.d.ts.map +1 -1
  277. package/dist/commands/trailers.d.ts +218 -17
  278. package/dist/commands/trailers.d.ts.map +1 -1
  279. package/dist/commands/tree-restore.d.ts +7 -0
  280. package/dist/commands/tree-restore.d.ts.map +1 -1
  281. package/dist/commands/verify-command.d.ts +92 -0
  282. package/dist/commands/verify-command.d.ts.map +1 -0
  283. package/dist/commands/worktree-add-command.d.ts +79 -7
  284. package/dist/commands/worktree-add-command.d.ts.map +1 -1
  285. package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
  286. package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
  287. package/dist/commands/worktree-path-rules.d.ts +66 -0
  288. package/dist/commands/worktree-path-rules.d.ts.map +1 -0
  289. package/dist/commands/worktree-remove-command.d.ts +10 -3
  290. package/dist/commands/worktree-remove-command.d.ts.map +1 -1
  291. package/dist/commands/worktree-repair-command.d.ts +15 -2
  292. package/dist/commands/worktree-repair-command.d.ts.map +1 -1
  293. package/dist/commands/worktree-support.d.ts +5 -0
  294. package/dist/commands/worktree-support.d.ts.map +1 -1
  295. package/dist/{commands-DIJ91NnD.js → commands-CNvli5bl.js} +49442 -54941
  296. package/dist/errors/checkout-errors.d.ts +19 -0
  297. package/dist/errors/checkout-errors.d.ts.map +1 -1
  298. package/dist/errors/command-errors.d.ts +25 -0
  299. package/dist/errors/command-errors.d.ts.map +1 -1
  300. package/dist/errors/index.js +85 -3
  301. package/dist/errors/ref-errors.d.ts +19 -0
  302. package/dist/errors/ref-errors.d.ts.map +1 -1
  303. package/dist/errors/worktree-errors.d.ts +6 -1
  304. package/dist/errors/worktree-errors.d.ts.map +1 -1
  305. package/dist/fsck-CPeDh9fh.js +5138 -0
  306. package/dist/git-command.d.ts +58 -2
  307. package/dist/git-command.d.ts.map +1 -1
  308. package/dist/git.d.ts +363 -1
  309. package/dist/git.d.ts.map +1 -1
  310. package/dist/guarded-transport-command.d.ts +82 -0
  311. package/dist/guarded-transport-command.d.ts.map +1 -0
  312. package/dist/index.d.ts +1 -0
  313. package/dist/index.d.ts.map +1 -1
  314. package/dist/index.js +6 -5
  315. package/dist/remote-config/index.d.ts +1 -1
  316. package/dist/remote-config/index.d.ts.map +1 -1
  317. package/dist/remote-config/remote-config-store.d.ts +55 -0
  318. package/dist/remote-config/remote-config-store.d.ts.map +1 -1
  319. package/dist/remote-transport-CCmBadm-.js +1606 -0
  320. package/dist/rename/detect-renames.d.ts +20 -0
  321. package/dist/rename/detect-renames.d.ts.map +1 -1
  322. package/dist/rename/diffcore-break.d.ts +51 -0
  323. package/dist/rename/diffcore-break.d.ts.map +1 -0
  324. package/dist/rename/index.d.ts +1 -0
  325. package/dist/rename/index.d.ts.map +1 -1
  326. package/dist/results/blame-format.d.ts +62 -1
  327. package/dist/results/blame-format.d.ts.map +1 -1
  328. package/dist/results/clone-result.d.ts +9 -0
  329. package/dist/results/clone-result.d.ts.map +1 -1
  330. package/dist/results/combined-diff.d.ts +3 -0
  331. package/dist/results/combined-diff.d.ts.map +1 -1
  332. package/dist/results/diff-check.d.ts +38 -0
  333. package/dist/results/diff-check.d.ts.map +1 -0
  334. package/dist/results/diff-color.d.ts +135 -0
  335. package/dist/results/diff-color.d.ts.map +1 -0
  336. package/dist/results/diff-dirstat.d.ts +36 -0
  337. package/dist/results/diff-dirstat.d.ts.map +1 -0
  338. package/dist/results/diff-entry.d.ts +10 -0
  339. package/dist/results/diff-entry.d.ts.map +1 -1
  340. package/dist/results/diff-formatter.d.ts.map +1 -1
  341. package/dist/results/diff-output.d.ts +103 -1
  342. package/dist/results/diff-output.d.ts.map +1 -1
  343. package/dist/results/diff-pickaxe.d.ts +67 -0
  344. package/dist/results/diff-pickaxe.d.ts.map +1 -0
  345. package/dist/results/diff-words.d.ts +55 -0
  346. package/dist/results/diff-words.d.ts.map +1 -0
  347. package/dist/results/fetch-result.d.ts +12 -1
  348. package/dist/results/fetch-result.d.ts.map +1 -1
  349. package/dist/results/index.d.ts +6 -0
  350. package/dist/results/index.d.ts.map +1 -1
  351. package/dist/results/index.js +2 -2
  352. package/dist/results/init-result.d.ts +8 -1
  353. package/dist/results/init-result.d.ts.map +1 -1
  354. package/dist/results/line-range-hunks.d.ts +27 -0
  355. package/dist/results/line-range-hunks.d.ts.map +1 -0
  356. package/dist/results/merge-result.d.ts +8 -1
  357. package/dist/results/merge-result.d.ts.map +1 -1
  358. package/dist/results/pull-result.d.ts +11 -0
  359. package/dist/results/pull-result.d.ts.map +1 -1
  360. package/dist/results/push-result.d.ts +12 -0
  361. package/dist/results/push-result.d.ts.map +1 -1
  362. package/dist/results/rebase-result.d.ts +2 -0
  363. package/dist/results/rebase-result.d.ts.map +1 -1
  364. package/dist/results/stash-result.d.ts +6 -0
  365. package/dist/results/stash-result.d.ts.map +1 -1
  366. package/dist/results/status-result.d.ts +1 -1
  367. package/dist/results/status-result.d.ts.map +1 -1
  368. package/dist/results-BDuEgdLU.js +46847 -0
  369. package/dist/transport-command.d.ts +14 -0
  370. package/dist/transport-command.d.ts.map +1 -1
  371. package/dist/whitespace/index.d.ts +2 -0
  372. package/dist/whitespace/index.d.ts.map +1 -0
  373. package/dist/whitespace/whitespace-rule.d.ts +94 -0
  374. package/dist/whitespace/whitespace-rule.d.ts.map +1 -0
  375. package/package.json +12 -12
  376. package/src/commands/add-command.ts +293 -17
  377. package/src/commands/add-patch/add-patch.ts +8 -0
  378. package/src/commands/add-patch/patch-backend.ts +20 -2
  379. package/src/commands/am/am-command.ts +400 -46
  380. package/src/commands/am/index.ts +1 -0
  381. package/src/commands/am/mailsplit.ts +326 -0
  382. package/src/commands/apply/apply-command.ts +58 -15
  383. package/src/commands/apply/apply-engine.ts +1 -1
  384. package/src/commands/apply/apply-parse.ts +17 -8
  385. package/src/commands/apply/index.ts +8 -1
  386. package/src/commands/bisect/bisect-command.ts +18 -5
  387. package/src/commands/blame-command.ts +1450 -51
  388. package/src/commands/blame-ignore.ts +307 -0
  389. package/src/commands/branch-command.ts +528 -53
  390. package/src/commands/branch-info-command.ts +150 -0
  391. package/src/commands/branch-tracking.ts +335 -60
  392. package/src/commands/branch-upstream-command.ts +218 -0
  393. package/src/commands/check-mailmap-command.ts +129 -0
  394. package/src/commands/checkout-command.ts +166 -55
  395. package/src/commands/checkout-paths.ts +28 -0
  396. package/src/commands/cherry-command.ts +187 -0
  397. package/src/commands/cherry-pick-command.ts +185 -1
  398. package/src/commands/clean-command.ts +126 -15
  399. package/src/commands/clean-interactive.ts +522 -0
  400. package/src/commands/clone-command.ts +598 -45
  401. package/src/commands/commit-command.ts +925 -74
  402. package/src/commands/commit-reuse.ts +94 -0
  403. package/src/commands/config-command.ts +1256 -0
  404. package/src/commands/config-value-types.ts +358 -0
  405. package/src/commands/core-config.ts +40 -0
  406. package/src/commands/describe-command.ts +341 -254
  407. package/src/commands/diff-color-config.ts +274 -0
  408. package/src/commands/diff-command.ts +1619 -99
  409. package/src/commands/fetch-command.ts +495 -14
  410. package/src/commands/fetch-multiple-command.ts +665 -0
  411. package/src/commands/fmt-merge-msg-command.ts +715 -0
  412. package/src/commands/fork-point.ts +63 -0
  413. package/src/commands/format-patch-command.ts +496 -116
  414. package/src/commands/fsck/fetch-fsck.ts +172 -18
  415. package/src/commands/gc-command.ts +31 -1
  416. package/src/commands/git-describe.ts +460 -201
  417. package/src/commands/git-hooks.ts +123 -3
  418. package/src/commands/grep/grep-command.ts +1077 -0
  419. package/src/commands/grep/grep-engine.ts +1024 -0
  420. package/src/commands/grep/index.ts +2 -0
  421. package/src/commands/index-adder.ts +46 -7
  422. package/src/commands/index.ts +43 -0
  423. package/src/commands/init-command.ts +603 -49
  424. package/src/commands/interpret-trailers-command.ts +256 -0
  425. package/src/commands/line-log.ts +931 -0
  426. package/src/commands/local-transport.ts +109 -10
  427. package/src/commands/log-command.ts +2599 -326
  428. package/src/commands/log-graph.ts +129 -29
  429. package/src/commands/log-output.ts +449 -27
  430. package/src/commands/ls-remote-command.ts +5 -0
  431. package/src/commands/mailmap.ts +155 -0
  432. package/src/commands/merge-base-command.ts +170 -0
  433. package/src/commands/merge-bases.ts +63 -8
  434. package/src/commands/merge-command.ts +601 -95
  435. package/src/commands/merge-drivers.ts +3 -0
  436. package/src/commands/merge-strategy-options.ts +224 -0
  437. package/src/commands/merge-support.ts +115 -22
  438. package/src/commands/message-cleanup.ts +1 -1
  439. package/src/commands/mv-command.ts +6 -3
  440. package/src/commands/name-rev-command.ts +184 -0
  441. package/src/commands/name-rev.ts +762 -0
  442. package/src/commands/notes-command.ts +11 -1
  443. package/src/commands/octopus-merge.ts +35 -11
  444. package/src/commands/ort-merge.ts +41 -7
  445. package/src/commands/ort-recursive.ts +40 -2
  446. package/src/commands/patch-id.ts +109 -0
  447. package/src/commands/pathspec-file.ts +72 -0
  448. package/src/commands/pathspec.ts +14 -2
  449. package/src/commands/pretty-format.ts +103 -19
  450. package/src/commands/promisor-remote.ts +10 -1
  451. package/src/commands/pull-command.ts +734 -221
  452. package/src/commands/push-command.ts +1035 -68
  453. package/src/commands/range-diff/index.ts +3 -0
  454. package/src/commands/range-diff/linear-assignment.ts +203 -0
  455. package/src/commands/range-diff/range-diff-command.ts +433 -0
  456. package/src/commands/range-diff/range-diff.ts +617 -0
  457. package/src/commands/read-tree-command.ts +102 -4
  458. package/src/commands/rebase-command.ts +1074 -194
  459. package/src/commands/ref-filter/for-each-ref-command.ts +298 -0
  460. package/src/commands/ref-filter/index.ts +7 -0
  461. package/src/commands/ref-filter/ref-atoms.ts +581 -0
  462. package/src/commands/ref-filter/ref-filter.ts +651 -0
  463. package/src/commands/ref-filter/ref-format.ts +1070 -0
  464. package/src/commands/ref-filter/ref-listing-command.ts +421 -0
  465. package/src/commands/ref-filter/ref-quote.ts +69 -0
  466. package/src/commands/ref-filter/version-compare.ts +177 -0
  467. package/src/commands/reflog-command.ts +492 -2
  468. package/src/commands/reflog-walk.ts +234 -0
  469. package/src/commands/remerge-diff.ts +241 -0
  470. package/src/commands/remote-command.ts +537 -69
  471. package/src/commands/remote-show-command.ts +836 -0
  472. package/src/commands/remote-transport.ts +9 -1
  473. package/src/commands/reset-command.ts +114 -34
  474. package/src/commands/restore-command.ts +27 -41
  475. package/src/commands/rev-filter/commit-filter.ts +159 -0
  476. package/src/commands/rev-filter/commit-grep.ts +444 -0
  477. package/src/commands/rev-filter/index.ts +2 -0
  478. package/src/commands/rev-list-command.ts +578 -15
  479. package/src/commands/revert-command.ts +123 -1
  480. package/src/commands/revision-range.ts +207 -5
  481. package/src/commands/revision-resolver.ts +23 -8
  482. package/src/commands/rm-command.ts +282 -21
  483. package/src/commands/sequencer-pick.ts +818 -111
  484. package/src/commands/sequencer-support.ts +184 -4
  485. package/src/commands/serve-repository.ts +18 -3
  486. package/src/commands/shortlog-command.ts +354 -0
  487. package/src/commands/shortlog.ts +361 -0
  488. package/src/commands/show-command.ts +491 -0
  489. package/src/commands/show-commit.ts +24 -0
  490. package/src/commands/signature-check.ts +657 -0
  491. package/src/commands/signing.ts +385 -0
  492. package/src/commands/sparse-checkout-command.ts +2 -9
  493. package/src/commands/sparse-checkout-support.ts +2 -2
  494. package/src/commands/sparse-index-view.ts +135 -0
  495. package/src/commands/ssh-signer.ts +199 -0
  496. package/src/commands/ssh-verifier.ts +523 -0
  497. package/src/commands/stash-apply-command.ts +16 -4
  498. package/src/commands/stash-branch-command.ts +88 -0
  499. package/src/commands/stash-create-command.ts +28 -0
  500. package/src/commands/stash-info.ts +243 -0
  501. package/src/commands/stash-list-command.ts +33 -0
  502. package/src/commands/stash-pop-command.ts +83 -0
  503. package/src/commands/stash-show-command.ts +141 -0
  504. package/src/commands/stash-store-command.ts +82 -0
  505. package/src/commands/stash-working-tree.ts +2 -2
  506. package/src/commands/status-command.ts +120 -27
  507. package/src/commands/status-format.ts +1 -1
  508. package/src/commands/status-header.ts +41 -7
  509. package/src/commands/submodule-add-command.ts +509 -0
  510. package/src/commands/submodule-auth.ts +276 -0
  511. package/src/commands/submodule-commands.ts +1835 -0
  512. package/src/commands/submodule-fetch.ts +789 -0
  513. package/src/commands/submodule-model.ts +938 -0
  514. package/src/commands/submodule-unpack.ts +265 -0
  515. package/src/commands/submodule-update-command.ts +1126 -0
  516. package/src/commands/subtree-shift.ts +215 -0
  517. package/src/commands/switch-command.ts +12 -1
  518. package/src/commands/tag-command.ts +876 -64
  519. package/src/commands/trailers.ts +837 -100
  520. package/src/commands/tree-restore.ts +44 -11
  521. package/src/commands/verify-command.ts +235 -0
  522. package/src/commands/worktree-add-command.ts +268 -24
  523. package/src/commands/worktree-overwrite-checks.ts +5 -0
  524. package/src/commands/worktree-path-rules.ts +183 -0
  525. package/src/commands/worktree-remove-command.ts +39 -5
  526. package/src/commands/worktree-repair-command.ts +52 -5
  527. package/src/commands/worktree-support.ts +22 -1
  528. package/src/errors/checkout-errors.ts +29 -0
  529. package/src/errors/command-errors.ts +37 -1
  530. package/src/errors/ref-errors.ts +23 -0
  531. package/src/errors/worktree-errors.ts +8 -1
  532. package/src/git-command.ts +153 -2
  533. package/src/git.ts +550 -1
  534. package/src/guarded-transport-command.ts +171 -0
  535. package/src/index.ts +1 -0
  536. package/src/remote-config/index.ts +2 -0
  537. package/src/remote-config/remote-config-store.ts +101 -0
  538. package/src/rename/detect-renames.ts +42 -8
  539. package/src/rename/diffcore-break.ts +166 -0
  540. package/src/rename/index.ts +1 -0
  541. package/src/results/blame-format.ts +268 -43
  542. package/src/results/clone-result.ts +6 -0
  543. package/src/results/combined-diff.ts +38 -18
  544. package/src/results/diff-check.ts +185 -0
  545. package/src/results/diff-color.ts +868 -0
  546. package/src/results/diff-dirstat.ts +117 -0
  547. package/src/results/diff-entry.ts +12 -0
  548. package/src/results/diff-formatter.ts +1 -0
  549. package/src/results/diff-output.ts +322 -32
  550. package/src/results/diff-pickaxe.ts +304 -0
  551. package/src/results/diff-words.ts +395 -0
  552. package/src/results/fetch-result.ts +12 -1
  553. package/src/results/index.ts +6 -0
  554. package/src/results/init-result.ts +10 -1
  555. package/src/results/line-range-hunks.ts +126 -0
  556. package/src/results/merge-result.ts +9 -0
  557. package/src/results/pull-result.ts +7 -0
  558. package/src/results/push-result.ts +12 -0
  559. package/src/results/rebase-result.ts +3 -0
  560. package/src/results/stash-result.ts +7 -0
  561. package/src/results/status-result.ts +2 -2
  562. package/src/transport-command.ts +34 -3
  563. package/src/whitespace/index.ts +1 -0
  564. package/src/{commands/apply/whitespace.ts → whitespace/whitespace-rule.ts} +173 -23
  565. package/dist/commands/apply/whitespace.d.ts +0 -58
  566. package/dist/commands/apply/whitespace.d.ts.map +0 -1
  567. package/dist/git-command-BGiOJ8Zk.js +0 -7246
  568. package/dist/results-WVlBhVb1.js +0 -2935
@@ -1,5 +1,9 @@
1
1
  import type { Commit, ObjectId, PersonIdent } from "@statewalker/vcs-core";
2
- import { DEFAULT_BIG_FILE_THRESHOLD, FileMode } from "@statewalker/vcs-core";
2
+ import {
3
+ DEFAULT_BIG_FILE_THRESHOLD,
4
+ FileMode,
5
+ InvalidTreeEntryNameError,
6
+ } from "@statewalker/vcs-core";
3
7
  import { parseGitBool } from "@statewalker/vcs-utils";
4
8
  import { compareGitPaths } from "@statewalker/vcs-utils/encoding";
5
9
  import {
@@ -12,6 +16,7 @@ import {
12
16
  invalidateCacheTreePath,
13
17
  type Worktree,
14
18
  } from "@statewalker/vcs-working-tree";
19
+ import { InvalidPathError } from "../errors/checkout-errors.js";
15
20
  import { InvalidArgumentError } from "../errors/command-errors.js";
16
21
  import { GitApiError } from "../errors/git-api-error.js";
17
22
  import {
@@ -30,10 +35,16 @@ import {
30
35
  MergeStatus,
31
36
  MergeStrategy,
32
37
  } from "../results/merge-result.js";
33
- import { CommitCommand, type CommitResult } from "./commit-command.js";
38
+ import { CommitCommand, type CommitEditor, type CommitResult } from "./commit-command.js";
34
39
  import { coreBool, worktreeModeTrust } from "./core-config.js";
40
+ import {
41
+ DEFAULT_MERGE_LOG_LENGTH,
42
+ FmtMergeMsgCommand,
43
+ fmtMergeMsgConfigOf,
44
+ } from "./fmt-merge-msg-command.js";
35
45
  import { configBool, conflictStyleOf } from "./merge-config.js";
36
46
  import { ortConfigOptions } from "./merge-drivers.js";
47
+ import { parseStrategyOptions, strategyOrtOptions } from "./merge-strategy-options.js";
37
48
  import {
38
49
  conflictsComment,
39
50
  flatTree,
@@ -53,8 +64,9 @@ import {
53
64
  cleanupWith,
54
65
  commitCleanupMode,
55
66
  commitMessageFromOption,
67
+ preparedMessageCleanup,
56
68
  } from "./message-cleanup.js";
57
- import { octopusMerge } from "./octopus-merge.js";
69
+ import { octopusMerge, threeway } from "./octopus-merge.js";
58
70
  import { ortResultEntries } from "./ort-merge.js";
59
71
  import { mergeBaseTree, mergeStoredTrees } from "./ort-recursive.js";
60
72
  import { reflogMessages, updateHead, updateHeadExpecting } from "./reflog-messages.js";
@@ -67,14 +79,18 @@ import {
67
79
  saveAutostash,
68
80
  squashMessage,
69
81
  } from "./sequencer-support.js";
82
+ import { readStoredObjectBytes, verifyMergeSignature } from "./signature-check.js";
83
+ import { SigningFailedError, signRequestOf } from "./signing.js";
70
84
  import { readSparseCheckoutPatterns, sparseCheckoutConfig } from "./sparse-checkout-support.js";
71
85
  import { WorkingCopyStashProvider } from "./stash-working-tree.js";
72
86
  import { readDiffSubmoduleConfig } from "./submodule-summary.js";
87
+ import { appendSignoff, ignoredLogMessageBytes, signoffLine, trailerConfigOf } from "./trailers.js";
73
88
  import {
74
89
  type CheckedEntry,
75
90
  pruneEmptyParents,
76
91
  worktreeModified,
77
92
  } from "./worktree-overwrite-checks.js";
93
+ import { treePathRefusal, worktreePathRules } from "./worktree-path-rules.js";
78
94
 
79
95
  /** What `git merge` is asked to do. */
80
96
  export enum MergeOperation {
@@ -134,13 +150,67 @@ export class MergeCommand extends GitCommand<MergeResult> {
134
150
  private includes: string[] = [];
135
151
  private fastForwardMode = FastForwardMode.FF;
136
152
  private strategy = MergeStrategy.RECURSIVE;
153
+ /** Whether `-s` was given (`-s recursive` names itself in git's messages) */
154
+ private strategyGiven = false;
137
155
  private contentStrategy?: ContentMergeStrategy;
156
+ /** `-X <option>`s, in order */
157
+ private strategyOptions: string[] = [];
138
158
  private squash = false;
139
159
  private commit = true;
140
160
  private message?: string;
141
161
  private cleanupMode?: CleanupMode;
142
162
  private inProcess = false;
143
163
  private noVerify = false;
164
+ /** `-S[<keyid>]` / `--no-gpg-sign` (undefined: `commit.gpgSign`) */
165
+ private sign?: boolean | string;
166
+ /** `--[no-]verify-signatures` (undefined: `merge.verifySignatures`) */
167
+ private verifySignatures?: boolean;
168
+ /** git's stdout lines of the signatures checked (`Commit <id> has a good GPG signature`) */
169
+ private readonly signatureLines: string[] = [];
170
+
171
+ /**
172
+ * `--verify-signatures` (true) / `--no-verify-signatures` (false): every commit merged
173
+ * must carry a good signature of at least marginal trust (with `gpg.minTrustLevel` set,
174
+ * that level instead), checked through the host's verifier before anything is written
175
+ * (commit.c's `verify_merge_signature`); undefined (the default) leaves it to
176
+ * `merge.verifySignatures`. A refusal throws {@link SignatureVerificationError} with git's
177
+ * death; a good signature adds `Commit <id> has a good GPG signature by <signer>` to the
178
+ * output.
179
+ */
180
+ setVerifySignatures(verify: boolean | undefined): this {
181
+ this.checkCallable();
182
+ this.verifySignatures = verify;
183
+ return this;
184
+ }
185
+
186
+ /** Whether the commits merged are checked (the option, else `merge.verifySignatures`). */
187
+ private verifiesSignatures(): boolean {
188
+ if (this.verifySignatures !== undefined) return this.verifySignatures;
189
+ if (this.inProcess) return false;
190
+ return configBool(this.workingCopy, "merge.verifySignatures", false);
191
+ }
192
+
193
+ /** verify_merge_signature of one commit merged, its good line kept for the output */
194
+ private async verifyMergedCommit(id: ObjectId): Promise<void> {
195
+ // git_merge_config: any gpg.minTrustLevel turns the marginal-trust check off
196
+ const checkTrust =
197
+ !this.workingCopy.config ||
198
+ RemoteConfigStore.from(this.workingCopy).value("gpg.minTrustLevel") === undefined;
199
+ const cwd = await this.hostWorkingDir();
200
+ this.signatureLines.push(
201
+ await verifyMergeSignature(
202
+ this.workingCopy,
203
+ await readStoredObjectBytes(this.workingCopy, id),
204
+ {
205
+ commitId: id,
206
+ abbreviated: await this.abbreviateObjectId(id),
207
+ objectFormat: this.objectFormat,
208
+ checkTrust,
209
+ ...(cwd !== undefined ? { cwd } : {}),
210
+ },
211
+ ),
212
+ );
213
+ }
144
214
 
145
215
  /**
146
216
  * `--no-verify`: the `pre-merge-commit` and `commit-msg` hooks do not run
@@ -152,6 +222,30 @@ export class MergeCommand extends GitCommand<MergeResult> {
152
222
  return this;
153
223
  }
154
224
 
225
+ /**
226
+ * `-S` (true) / `--no-gpg-sign` (false): whether to sign the merge commit; undefined (the
227
+ * default) leaves it to `commit.gpgSign`. The merge commit is signed through the host's
228
+ * signer (`GitHostEnvironment.signer`) as git's commit_tree signs it; when it cannot be
229
+ * signed (no signer, a failing one) the merge fails as git's does (`error: gpg failed to
230
+ * sign the data:`, `fatal: failed to write commit object`, exit 128:
231
+ * {@link SigningFailedError}), left in progress as git leaves it (MERGE_HEAD, the merged
232
+ * index and files) and no commit made. A fast-forward or a merge stopped before its commit
233
+ * signs nothing. `merge --continue` commits as git runs a plain `git commit`: signed only
234
+ * under `commit.gpgSign`.
235
+ */
236
+ setSign(sign: boolean | undefined): this {
237
+ this.checkCallable();
238
+ this.sign = sign;
239
+ return this;
240
+ }
241
+
242
+ /** `-S<keyid>`: sign with this key (see {@link setSign}). */
243
+ setSigningKey(keyId: string): this {
244
+ this.checkCallable();
245
+ this.sign = keyId;
246
+ return this;
247
+ }
248
+
155
249
  /**
156
250
  * A merge another command makes in process (a rebase's `merge`), which reads no `git
157
251
  * merge` configuration of its own (`git_merge_config`).
@@ -169,6 +263,15 @@ export class MergeCommand extends GitCommand<MergeResult> {
169
263
  private autoStash?: boolean;
170
264
  private renormalize?: boolean;
171
265
  private allowUnrelated = false;
266
+ /** `--log[=<n>]` / `--no-log` (undefined: `merge.log`) */
267
+ private log?: number;
268
+ private signoff = false;
269
+ /** `--edit` / `--no-edit` (undefined: no editor, as git without a terminal) */
270
+ private edit?: boolean;
271
+ private editor?: CommitEditor;
272
+ private intoName?: string;
273
+ /** FETCH_HEAD-style lines naming the heads (a pull's), instead of merge_name's */
274
+ private mergeNames?: string;
172
275
 
173
276
  /**
174
277
  * Add a commit/branch to merge.
@@ -202,13 +305,37 @@ export class MergeCommand extends GitCommand<MergeResult> {
202
305
  * - RECURSIVE (default): git's merge-ort
203
306
  * - OURS: Keep our tree, ignore their changes (creates merge commit)
204
307
  * - THEIRS: Replace our tree with theirs (creates merge commit)
205
- * - RESOLVE: as RECURSIVE
308
+ * - RESOLVE: git-merge-resolve (a trivial in-index merge, else `read-tree -m --aggressive`
309
+ * and git-merge-one-file)
310
+ * - SUBTREE: merge-ort with the other side shifted to ours' shape (never a fast-forward)
206
311
  *
207
312
  * @param strategy Merge strategy
208
313
  */
209
314
  setStrategy(strategy: MergeStrategy): this {
210
315
  this.checkCallable();
211
316
  this.strategy = strategy;
317
+ this.strategyGiven = true;
318
+ return this;
319
+ }
320
+
321
+ /**
322
+ * git's `-X <option>`s, in order (merge-ort's parse_merge_opt): `ours`, `theirs`,
323
+ * `subtree[=<path>]`, `patience`, `histogram`, `diff-algorithm=<name>`,
324
+ * `ignore-space-change`, `ignore-all-space`, `ignore-space-at-eol`, `ignore-cr-at-eol`,
325
+ * `renormalize`, `no-renormalize`, `no-renames`, `find-renames[=<n>]`,
326
+ * `rename-threshold=<n>`. An unknown one fails the merge when merge-ort runs
327
+ * ({@link UnknownStrategyOptionError}, git's `unknown strategy option`).
328
+ */
329
+ setStrategyOptions(options: readonly string[]): this {
330
+ this.checkCallable();
331
+ this.strategyOptions = [...options];
332
+ return this;
333
+ }
334
+
335
+ /** Adds one `-X <option>` (see {@link setStrategyOptions}). */
336
+ addStrategyOption(option: string): this {
337
+ this.checkCallable();
338
+ this.strategyOptions.push(option);
212
339
  return this;
213
340
  }
214
341
 
@@ -347,6 +474,78 @@ export class MergeCommand extends GitCommand<MergeResult> {
347
474
  return this;
348
475
  }
349
476
 
477
+ /**
478
+ * `--log[=<n>]`: the merge message lists the commits each head brings, at most `n` of them
479
+ * (true: 20), as git's fmt-merge-msg shortlog (`* <name>:` and their subjects; see
480
+ * {@link FmtMergeMsgCommand}); `--no-log` (false or 0) lists none. Undefined (the default)
481
+ * takes `merge.log` (or its old name `merge.summary`). With {@link setMessage} the list
482
+ * follows the message given.
483
+ */
484
+ setLog(log: boolean | number | undefined): this {
485
+ this.checkCallable();
486
+ this.log = log === true ? DEFAULT_MERGE_LOG_LENGTH : log === false ? 0 : log;
487
+ return this;
488
+ }
489
+
490
+ /**
491
+ * `--signoff`: the merge commit's message gets the committer's `Signed-off-by:` trailer
492
+ * (git's append_signoff, before the hooks see MERGE_MSG); `--no-signoff` (false, the
493
+ * default) none. A merge stopped before its commit (conflicts, `--no-commit`) adds none.
494
+ */
495
+ setSignoff(signoff: boolean): this {
496
+ this.checkCallable();
497
+ this.signoff = signoff;
498
+ return this;
499
+ }
500
+
501
+ /**
502
+ * `--edit` (true) / `--no-edit` (false): with `--edit` the merge commit's message goes
503
+ * through the editor ({@link setEditor}) as git's prepare_to_commit runs it: MERGE_MSG
504
+ * written with git's help comment below the message (and the sign-off), the
505
+ * `prepare-commit-msg` hook, the editor, `commit-msg`, then the text cleaned up as an
506
+ * edited message (`commit.cleanup`, else comments stripped). Without an editor set the
507
+ * message is taken as the editor would leave it. Default: no edit (git's without a
508
+ * terminal); a merge that stops before its commit runs no editor.
509
+ */
510
+ setEdit(edit: boolean): this {
511
+ this.checkCallable();
512
+ this.edit = edit;
513
+ return this;
514
+ }
515
+
516
+ /**
517
+ * The editor `--edit` runs over MERGE_MSG: called with `"MERGE_MSG"` and the text, it
518
+ * returns the edited text (anything else keeps the text as it is), as
519
+ * `CommitCommand.setEditor`.
520
+ */
521
+ setEditor(editor: CommitEditor): this {
522
+ this.checkCallable();
523
+ this.editor = editor;
524
+ return this;
525
+ }
526
+
527
+ /**
528
+ * `--into-name <branch>`: the default message names this branch as the one merged into
529
+ * (`into <branch>` left out as for HEAD's under `merge.suppressDest`).
530
+ */
531
+ setIntoName(name: string | undefined): this {
532
+ this.checkCallable();
533
+ this.intoName = name;
534
+ return this;
535
+ }
536
+
537
+ /**
538
+ * The heads described as FETCH_HEAD describes them (`<id>\t\tbranch 'x' of <url>`), as
539
+ * `git pull` hands them to the merge, instead of describing the names included.
540
+ *
541
+ * @internal
542
+ */
543
+ setMergeNames(lines: string): this {
544
+ this.checkCallable();
545
+ this.mergeNames = lines;
546
+ return this;
547
+ }
548
+
350
549
  /**
351
550
  * The author of the merge commit (default: resolved as git resolves it, from
352
551
  * `GIT_AUTHOR_*`, `author.*`, `user.*`).
@@ -378,6 +577,9 @@ export class MergeCommand extends GitCommand<MergeResult> {
378
577
  // git_merge_config ends in git_diff_ui_config: a diff.submodule without a value dies
379
578
  // (not for the merges a rebase makes in process)
380
579
  if (!this.inProcess) readDiffSubmoduleConfig(this.workingCopy);
580
+ // ... and its fmt_merge_msg_config: a merge.* value git refuses dies before anything is
581
+ // read or written (the message is built only after the tree merge)
582
+ if (!this.inProcess) fmtMergeMsgConfigOf(RemoteConfigStore.from(this.workingCopy));
381
583
  // the index as it is now, before the worktree or a ref is touched: one another writer
382
584
  // replaced is read again (git reads the index at its start), unless this instance holds
383
585
  // unwritten edits (refused)
@@ -403,7 +605,9 @@ export class MergeCommand extends GitCommand<MergeResult> {
403
605
  env: { GIT_REFLOG_ACTION: this.reflogActionValue() },
404
606
  });
405
607
  }
406
- return this.sparseWarnings.length > 0 ? { ...result, warnings: this.sparseWarnings } : result;
608
+ return this.withSignatureLines(
609
+ this.sparseWarnings.length > 0 ? { ...result, warnings: this.sparseWarnings } : result,
610
+ );
407
611
  }
408
612
 
409
613
  /**
@@ -418,7 +622,27 @@ export class MergeCommand extends GitCommand<MergeResult> {
418
622
  this.setCallable(false);
419
623
  await this.readCurrentIndex();
420
624
  const worktree = this.worktreeAccess;
421
- const run = async (): Promise<MergeResult> => {
625
+ // pull_into_void: any --[no-]verify-signatures given to pull checks the commit
626
+ if (this.verifySignatures !== undefined) await this.verifyMergedCommit(mergeHead);
627
+ const run = () => this.intoVoid(mergeHead, worktree);
628
+ const result = await (worktree?.batch ? worktree.batch(run) : run());
629
+ return this.withSignatureLines(
630
+ this.sparseWarnings.length > 0 ? { ...result, warnings: this.sparseWarnings } : result,
631
+ );
632
+ }
633
+
634
+ /** The good-signature lines first in the output, as git prints them before the merge's */
635
+ private withSignatureLines(result: MergeResult): MergeResult {
636
+ if (this.signatureLines.length === 0) return result;
637
+ return { ...result, output: [...this.signatureLines, ...(result.output ?? [])] };
638
+ }
639
+
640
+ /** A two-way switch from the empty tree to `mergeHead`, HEAD's branch created there. */
641
+ private async intoVoid(
642
+ mergeHead: ObjectId,
643
+ worktree: Worktree | undefined,
644
+ ): Promise<MergeResult> {
645
+ {
422
646
  const targetTree = await this.commits.getTree(mergeHead);
423
647
  const target = await flatTree(this.trees, targetTree);
424
648
  const refused = await switchTrees(this.context(worktree), new Map(), target, {
@@ -446,9 +670,7 @@ export class MergeCommand extends GitCommand<MergeResult> {
446
670
  mergedCommits: [mergeHead],
447
671
  output: [],
448
672
  };
449
- };
450
- const result = await (worktree?.batch ? worktree.batch(run) : run());
451
- return this.sparseWarnings.length > 0 ? { ...result, warnings: this.sparseWarnings } : result;
673
+ }
452
674
  }
453
675
 
454
676
  /**
@@ -523,7 +745,22 @@ export class MergeCommand extends GitCommand<MergeResult> {
523
745
  }
524
746
  const headResolved = await this.refsStore.resolve("HEAD");
525
747
  if (!headResolved?.objectId) {
526
- throw new NoHeadError("HEAD does not point to a commit");
748
+ if (!this.verifiesSignatures()) throw new NoHeadError("HEAD does not point to a commit");
749
+ // cmd_merge on an unborn branch: one head only, then verify_merge_signature, then
750
+ // read_empty and HEAD's branch created (the merge into the void)
751
+ if (this.squash)
752
+ throw new GitApiError("fatal: Squash commit into empty head not supported yet");
753
+ if (this.fastForwardMode === FastForwardMode.NO_FF) {
754
+ throw new GitApiError(
755
+ "fatal: Non-fast-forward commit does not make sense into an empty head",
756
+ );
757
+ }
758
+ if (this.includes.length > 1) {
759
+ throw new GitApiError("fatal: Can merge only exactly one commit into empty head");
760
+ }
761
+ const target = await this.mergeHeadOf(this.includes[0] as string);
762
+ await this.verifyMergedCommit(target);
763
+ return this.intoVoid(target, worktree);
527
764
  }
528
765
  const headId = headResolved.objectId;
529
766
 
@@ -557,6 +794,9 @@ export class MergeCommand extends GitCommand<MergeResult> {
557
794
  }
558
795
  const headSubsumed = !independent.some((c) => c.id === headId);
559
796
  const remotes = independent.filter((c) => c.id !== headId);
797
+ if (this.verifiesSignatures()) {
798
+ for (const remote of remotes) await this.verifyMergedCommit(remote.id);
799
+ }
560
800
  if (remotes.length === 0) {
561
801
  await state.setRef("ORIG_HEAD", headId);
562
802
  return {
@@ -577,7 +817,7 @@ export class MergeCommand extends GitCommand<MergeResult> {
577
817
  );
578
818
  }
579
819
  // the message names the heads left (fmt-merge-msg of the reduced heads)
580
- const message = this.message ?? (await this.octopusMessage(remotes));
820
+ const message = await this.mergeMessage(headId, remotes);
581
821
  await state.setRef("ORIG_HEAD", headId);
582
822
  const ids = remotes.map((r) => r.id);
583
823
  if (!this.allowUnrelated && (await this.octopusBases(headId, ids)).length === 0) {
@@ -594,6 +834,16 @@ export class MergeCommand extends GitCommand<MergeResult> {
594
834
  srcId = remotes[0].id;
595
835
  }
596
836
 
837
+ // reduce_parents: a head HEAD already contains is no merged commit, so nothing to check
838
+ if (
839
+ this.includes.length === 1 &&
840
+ this.verifiesSignatures() &&
841
+ srcId !== headId &&
842
+ !(await this.isAncestor(srcId, headId))
843
+ ) {
844
+ await this.verifyMergedCommit(srcId);
845
+ }
846
+
597
847
  // git records where HEAD was before every merge
598
848
  await state.setRef("ORIG_HEAD", headId);
599
849
 
@@ -632,18 +882,58 @@ export class MergeCommand extends GitCommand<MergeResult> {
632
882
  }
633
883
 
634
884
  return this.withAutostash(state, worktree, headId, () =>
635
- fastForward
636
- ? this.doFastForward(headId, srcId, head, state, worktree)
637
- : this.doMerge(headId, srcId, srcRef, head, state, worktree, mergeBases),
885
+ this.refusingTreePaths(headId, srcId, fastForward, worktree, () =>
886
+ fastForward
887
+ ? this.doFastForward(headId, srcId, head, state, worktree)
888
+ : this.doMerge(headId, srcId, srcRef, head, state, worktree, mergeBases),
889
+ ),
638
890
  );
639
891
  }
640
892
 
893
+ /**
894
+ * Runs a merge's write; when a tree holds a name the decoder refuses (`..`, `/` in a name,
895
+ * an empty name), answers as git: `error: invalid path '<path>'` (with merge-ort's
896
+ * `Merge with strategy ort failed.` when not a fast-forward), or the empty name's death.
897
+ */
898
+ private async refusingTreePaths(
899
+ headId: ObjectId,
900
+ srcId: ObjectId,
901
+ fastForward: boolean,
902
+ worktree: Worktree | undefined,
903
+ body: () => Promise<MergeResult>,
904
+ ): Promise<MergeResult> {
905
+ try {
906
+ return await body();
907
+ } catch (error) {
908
+ if (!(error instanceof InvalidTreeEntryNameError)) throw error;
909
+ const rules = worktreePathRules(this.workingCopy, worktree);
910
+ for (const id of [srcId, headId]) {
911
+ const tree = await this.commits.getTree(id);
912
+ const refusal = tree ? await treePathRefusal(this.trees, tree, rules) : undefined;
913
+ if (!refusal) continue;
914
+ if (!(refusal instanceof InvalidPathError)) throw refusal;
915
+ return {
916
+ status: MergeStatus.FAILED,
917
+ newHead: headId,
918
+ mergedCommits: [headId, srcId],
919
+ message: fastForward
920
+ ? refusal.message
921
+ : `${refusal.message}\nMerge with strategy ort failed.`,
922
+ failingPaths: failing([refusal.path]),
923
+ };
924
+ }
925
+ throw error;
926
+ }
927
+ }
928
+
641
929
  /**
642
930
  * git's fast-forward setting as the strategy leaves it: `ours` (NO_FAST_FORWARD) always
643
931
  * makes a merge commit, whatever was asked.
644
932
  */
645
933
  private ffMode(): FastForwardMode {
646
- return this.strategy === MergeStrategy.OURS ? FastForwardMode.NO_FF : this.fastForwardMode;
934
+ return this.strategy === MergeStrategy.OURS || this.strategy === MergeStrategy.SUBTREE
935
+ ? FastForwardMode.NO_FF
936
+ : this.fastForwardMode;
647
937
  }
648
938
 
649
939
  /** git's get_octopus_merge_bases: the merge bases of HEAD and every head, folded. */
@@ -795,6 +1085,9 @@ export class MergeCommand extends GitCommand<MergeResult> {
795
1085
  worktree: Worktree | undefined,
796
1086
  mergeBases: ObjectId[],
797
1087
  ): Promise<MergeResult> {
1088
+ if (this.strategy === MergeStrategy.RESOLVE) {
1089
+ return this.doResolve(headId, srcId, srcName, head, state, worktree, mergeBases);
1090
+ }
798
1091
  // no merge base (unrelated histories allowed): merge-ort merges against the empty tree
799
1092
  const baseId = mergeBases[0] as ObjectId | undefined;
800
1093
  const headCommit = await this.commits.load(headId);
@@ -804,7 +1097,6 @@ export class MergeCommand extends GitCommand<MergeResult> {
804
1097
  }
805
1098
  const { index } = await readIndex(this.staging);
806
1099
 
807
- const mergeName = await this.describeMergeSource(srcName, srcId);
808
1100
  const output: string[] = [];
809
1101
  let target: Map<string, { objectId: ObjectId; mode: number }>;
810
1102
  let merge: Awaited<ReturnType<typeof mergeStoredTrees>> | undefined;
@@ -813,12 +1105,22 @@ export class MergeCommand extends GitCommand<MergeResult> {
813
1105
  } else if (this.strategy === MergeStrategy.THEIRS) {
814
1106
  target = await flatTree(this.trees, srcCommit.tree);
815
1107
  } else {
1108
+ // try_merge_strategy: `-X` read (and refused) before anything is merged
1109
+ const xopts = parseStrategyOptions(this.strategyOptions);
1110
+ const subtreeShift =
1111
+ xopts.subtreeShift ?? (this.strategy === MergeStrategy.SUBTREE ? "" : undefined);
816
1112
  const common = {
817
1113
  style: conflictStyleOf(this.workingCopy),
818
1114
  ignoreCase: coreBool(this.workingCopy, "ignorecase", false),
819
1115
  bigFileThreshold: this.bigFileThreshold,
820
- ...ortConfigOptions(this.workingCopy, worktree, { renormalize: this.renormalize }),
1116
+ ...ortConfigOptions(this.workingCopy, worktree, {
1117
+ renormalize: xopts.renormalize ?? this.renormalize,
1118
+ }),
1119
+ ...strategyOrtOptions(this.inProcess ? undefined : this.workingCopy, xopts),
1120
+ // the inner merges of a virtual merge base are shifted too
1121
+ ...(subtreeShift !== undefined ? { subtreeShift } : {}),
821
1122
  };
1123
+
822
1124
  // several merge bases: merge-ort's virtual merge base, built in memory
823
1125
  const base = await mergeBaseTree(
824
1126
  {
@@ -842,7 +1144,7 @@ export class MergeCommand extends GitCommand<MergeResult> {
842
1144
  oursLabel: "HEAD",
843
1145
  theirsLabel: srcName,
844
1146
  baseLabel: base.label,
845
- favor: favorOf(this.contentStrategy),
1147
+ favor: favorOf(this.contentStrategy) ?? xopts.favor,
846
1148
  },
847
1149
  );
848
1150
  target = await ortResultEntries(this.blobs, merge);
@@ -889,8 +1191,8 @@ export class MergeCommand extends GitCommand<MergeResult> {
889
1191
  };
890
1192
  }
891
1193
  output.push(...(merge?.messages ?? []));
892
- // a message given is the commit's as it is; git's default ends with a newline
893
- const message = this.message ?? (await this.defaultMessage(mergeName));
1194
+ // git's merge_msg: the message given, or fmt-merge-msg's, without its last newline
1195
+ const message = await this.mergeMessage(headId, [{ id: srcId, name: srcName }]);
894
1196
 
895
1197
  if (conflicts.length > 0 || merge?.clean === false) {
896
1198
  const paths = [...new Set(conflicts.map((c) => c.stagePath))].sort(compareGitPaths);
@@ -972,7 +1274,9 @@ export class MergeCommand extends GitCommand<MergeResult> {
972
1274
  output,
973
1275
  };
974
1276
  }
975
- const newCommitId = await this.storeCommit(treeId, [headId, srcId], cleaned);
1277
+ const newCommitId = await this.storeCommit(treeId, [headId, srcId], cleaned, () =>
1278
+ this.writeMergeState(state, srcId, hooked.stateText ?? message),
1279
+ );
976
1280
  await this.updateHead(head, newCommitId, reflogMessages.mergeMade(this.strategyName()));
977
1281
  // the commit ends the merge: git's remove_merge_branch_state
978
1282
  await state.removeRef("AUTO_MERGE");
@@ -986,6 +1290,96 @@ export class MergeCommand extends GitCommand<MergeResult> {
986
1290
  };
987
1291
  }
988
1292
 
1293
+ /**
1294
+ * `-s resolve` of one head (builtin/merge.c with git-merge-resolve): with one merge base and
1295
+ * a commit to make, first git's "really trivial in-index merge" (`read-tree` with
1296
+ * trivial_merges_only: every path taken whole from a side, committed as `In-index merge`);
1297
+ * otherwise, or when that is not trivial ("Nope."), git-merge-resolve's
1298
+ * `read-tree -m --aggressive` and git-merge-one-file for the paths left.
1299
+ */
1300
+ private async doResolve(
1301
+ headId: ObjectId,
1302
+ srcId: ObjectId,
1303
+ srcName: string,
1304
+ head: Awaited<ReturnType<typeof this.refsStore.get>>,
1305
+ state: OperationState,
1306
+ worktree: Worktree | undefined,
1307
+ mergeBases: ObjectId[],
1308
+ ): Promise<MergeResult> {
1309
+ const output: string[] = [];
1310
+ const message = await this.mergeMessage(headId, [{ id: srcId, name: srcName }]);
1311
+ const mergedCommits = [headId, srcId];
1312
+ let refusedTrivial = "";
1313
+ if (mergeBases.length === 1 && this.commit && !this.squash) {
1314
+ const headTreeId = await this.commits.getTree(headId);
1315
+ const headTree = await flatTree(this.trees, headTreeId);
1316
+ const { index } = await readIndex(this.staging);
1317
+ const staged = indexChanges(index, headTree);
1318
+ if (staged.length > 0) {
1319
+ return {
1320
+ status: MergeStatus.FAILED,
1321
+ newHead: headId,
1322
+ mergedCommits,
1323
+ message: `error: Your local changes to the following files would be overwritten by merge:\n ${staged.join(" ")}`,
1324
+ failingPaths: new Map(staged.map((p) => [p, MergeFailureReason.DIRTY_INDEX])),
1325
+ };
1326
+ }
1327
+ output.push("Trying really trivial in-index merge...");
1328
+ const base = await flatTree(this.trees, await this.commits.getTree(mergeBases[0]));
1329
+ const remote = await flatTree(this.trees, await this.commits.getTree(srcId));
1330
+ const target = trivialMerge(base, headTree, remote);
1331
+ if (target) {
1332
+ const refused = await switchTrees(this.context(worktree), headTree, target, {
1333
+ action: "merge",
1334
+ operation: "merge",
1335
+ });
1336
+ if (!refused) {
1337
+ output.push("Wonderful.");
1338
+ const treeId = await storeFlatTree(this.trees, target);
1339
+ const writeState = async (text: string) => this.writeMergeState(state, srcId, text);
1340
+ const hooked = await this.mergeCommitHooks(state, message, writeState);
1341
+ if (hooked.refused !== undefined) {
1342
+ return {
1343
+ status: MergeStatus.FAILED,
1344
+ newHead: headId,
1345
+ mergedCommits,
1346
+ message: hooked.refused,
1347
+ output,
1348
+ };
1349
+ }
1350
+ const newCommitId = await this.storeCommit(treeId, mergedCommits, hooked.message, () =>
1351
+ writeState(hooked.stateText ?? message),
1352
+ );
1353
+ await this.updateHead(head, newCommitId, "In-index merge");
1354
+ await state.removeRef("AUTO_MERGE");
1355
+ output.push("In-index merge");
1356
+ return { status: MergeStatus.MERGED, newHead: newCommitId, mergedCommits, output };
1357
+ }
1358
+ refusedTrivial = `${refused.message}\n`;
1359
+ } else {
1360
+ // unpack-trees' trivial_merges_only refusal
1361
+ refusedTrivial = "error: Merge requires file-level merging\n";
1362
+ }
1363
+ output.push("Nope.");
1364
+ }
1365
+ const result = await this.doOctopus(
1366
+ headId,
1367
+ head,
1368
+ [{ id: srcId, name: srcName }],
1369
+ false,
1370
+ message,
1371
+ state,
1372
+ worktree,
1373
+ );
1374
+ return {
1375
+ ...result,
1376
+ output: [...output, ...(result.output ?? [])],
1377
+ ...(refusedTrivial && result.message !== undefined
1378
+ ? { message: `${refusedTrivial}${result.message}` }
1379
+ : {}),
1380
+ };
1381
+ }
1382
+
989
1383
  /**
990
1384
  * A merge of several heads: git-merge-octopus (the heads merged one after the other) or,
991
1385
  * with strategy `ours`, git-merge-ours (HEAD's tree); written when it merged or left
@@ -1007,7 +1401,12 @@ export class MergeCommand extends GitCommand<MergeResult> {
1007
1401
  const headTree = await flatTree(this.trees, await this.commits.getTree(headId));
1008
1402
  const { index } = await readIndex(this.staging);
1009
1403
  const staged = indexChanges(index, headTree);
1010
- const strategy = this.strategy === MergeStrategy.OURS ? "ours" : "octopus";
1404
+ const strategy =
1405
+ this.strategy === MergeStrategy.OURS
1406
+ ? "ours"
1407
+ : this.strategy === MergeStrategy.RESOLVE
1408
+ ? "resolve"
1409
+ : "octopus";
1011
1410
  // git restores the state it saved (reset --hard, stash apply): AUTO_MERGE as for ort
1012
1411
  const giveUp = async (lines: string[], output: string[] = []): Promise<MergeResult> => {
1013
1412
  const tree = (await this.commits.getTree(headId)) as ObjectId;
@@ -1021,11 +1420,18 @@ export class MergeCommand extends GitCommand<MergeResult> {
1021
1420
  };
1022
1421
  };
1023
1422
  // git-merge-resolve and merge-ort handle two heads only
1024
- if (this.strategy === MergeStrategy.RESOLVE) {
1423
+ if (this.strategy === MergeStrategy.RESOLVE && remotes.length > 1) {
1025
1424
  const tree = (await this.commits.getTree(headId)) as ObjectId;
1026
1425
  const restored = await this.restoreStateQuirk(state, tree, worktree);
1027
1426
  return failed(`${restored}Merge with strategy resolve failed.`);
1028
1427
  }
1428
+ if (this.strategy === MergeStrategy.SUBTREE) {
1429
+ const tree = (await this.commits.getTree(headId)) as ObjectId;
1430
+ const restored = await this.restoreStateQuirk(state, tree, worktree);
1431
+ return failed(
1432
+ `error: Not handling anything other than two heads merge.\n${restored}Merge with strategy subtree failed.`,
1433
+ );
1434
+ }
1029
1435
  let outcome: Awaited<ReturnType<typeof octopusMerge>>;
1030
1436
  if (this.strategy === MergeStrategy.OURS) {
1031
1437
  // git-merge-ours: refuses an index that differs from HEAD, else HEAD's tree
@@ -1050,6 +1456,7 @@ export class MergeCommand extends GitCommand<MergeResult> {
1050
1456
  headId,
1051
1457
  remotes,
1052
1458
  staged,
1459
+ { resolve: this.strategy === MergeStrategy.RESOLVE },
1053
1460
  );
1054
1461
  }
1055
1462
  const output = [...outcome.output];
@@ -1135,45 +1542,14 @@ export class MergeCommand extends GitCommand<MergeResult> {
1135
1542
  output,
1136
1543
  };
1137
1544
  }
1138
- const newCommitId = await this.storeCommit(treeId, parents, cleaned);
1545
+ const newCommitId = await this.storeCommit(treeId, parents, cleaned, () =>
1546
+ writeState(hooked.stateText ?? message),
1547
+ );
1139
1548
  await this.updateHead(head, newCommitId, reflogMessages.mergeMade(strategy));
1140
1549
  output.push(`Merge made by the '${strategy}' strategy.`);
1141
1550
  return { status: MergeStatus.MERGED, newHead: newCommitId, mergedCommits, output };
1142
1551
  }
1143
1552
 
1144
- /** git's fmt-merge-msg title for several heads: `Merge branches 'a', 'b' and tag 'v1'`. */
1145
- private async octopusMessage(heads: { id: ObjectId; name: string }[]): Promise<string> {
1146
- const groups = new Map<string, string[]>();
1147
- for (const { id, name } of heads) {
1148
- const described = await this.describeMergeSource(name, id);
1149
- const k = described.indexOf(" '");
1150
- const kind = described.slice(0, k);
1151
- const list = groups.get(kind) ?? [];
1152
- list.push(described.slice(k + 1));
1153
- groups.set(kind, list);
1154
- }
1155
- const plural: Record<string, string> = {
1156
- branch: "branches",
1157
- "remote-tracking branch": "remote-tracking branches",
1158
- tag: "tags",
1159
- commit: "commits",
1160
- };
1161
- const parts: string[] = [];
1162
- for (const kind of ["branch", "remote-tracking branch", "tag", "commit"]) {
1163
- const list = groups.get(kind);
1164
- if (!list) continue;
1165
- const joined =
1166
- list.length === 1
1167
- ? list[0]
1168
- : `${list.slice(0, -1).join(", ")} and ${list[list.length - 1]}`;
1169
- parts.push(`${list.length === 1 ? kind : plural[kind]} ${joined}`);
1170
- }
1171
- const branch = await this.getCurrentBranch();
1172
- const short = branch?.startsWith("refs/heads/") ? branch.slice("refs/heads/".length) : "HEAD";
1173
- const into = short === "main" || short === "master" ? "" : ` into ${short}`;
1174
- return `Merge ${parts.join(", ")}${into}\n`;
1175
- }
1176
-
1177
1553
  /** The heads MERGE_HEAD names (one per line: several for an octopus). */
1178
1554
  private async mergeHeads(state: OperationState): Promise<ObjectId[]> {
1179
1555
  const text = await state.read("MERGE_HEAD");
@@ -1232,7 +1608,10 @@ export class MergeCommand extends GitCommand<MergeResult> {
1232
1608
  this.message !== undefined
1233
1609
  ? commitMessageFromOption(this.message, this.cleanupMode, this.workingCopy)
1234
1610
  : cleanupMessage((await state.read("MERGE_MSG")) ?? `Merge commit '${mergeHead}'\n`);
1235
- const newCommitId = await this.storeCommit(treeId, [headId, ...heads], message);
1611
+ // `git merge --continue` runs a plain `git commit`: commit.gpgSign alone decides
1612
+ const newCommitId = await this.storeCommit(treeId, [headId, ...heads], message, undefined, {
1613
+ continuing: true,
1614
+ });
1236
1615
  // `git merge --continue` is `git commit`: "commit (merge): <subject>"
1237
1616
  await this.updateHead(head, newCommitId, undefined, reflogMessages.commit("merge", message));
1238
1617
  await state.removeRef("MERGE_HEAD", "AUTO_MERGE");
@@ -1494,12 +1873,56 @@ export class MergeCommand extends GitCommand<MergeResult> {
1494
1873
  }
1495
1874
 
1496
1875
  /**
1497
- * MERGE_MSG's text before any conflicts hint (git's `write_merge_state`): the message as
1498
- * given with a newline added, always (`-m "x\n"` gives `x` and a blank line), or git's
1499
- * default message (already one line ended).
1876
+ * MERGE_MSG's text before any conflicts hint (git's `write_merge_state`): merge_msg with
1877
+ * a newline added, always (`-m "x\n"` gives `x` and a blank line).
1500
1878
  */
1501
1879
  private stateMessage(message: string): string {
1502
- return this.message !== undefined ? `${this.message}\n` : message;
1880
+ return `${message}\n`;
1881
+ }
1882
+
1883
+ /**
1884
+ * git's merge_msg (collect_parents): the message given (`-m`), followed by fmt-merge-msg's
1885
+ * shortlog and tag messages under `--log`, or fmt-merge-msg's whole message without one;
1886
+ * its last newline dropped (prepare_merge_message).
1887
+ */
1888
+ private async mergeMessage(
1889
+ headId: ObjectId,
1890
+ heads: { id: ObjectId; name: string }[],
1891
+ ): Promise<string> {
1892
+ const log =
1893
+ this.log ??
1894
+ (this.inProcess
1895
+ ? 0
1896
+ : Math.max(0, fmtMergeMsgConfigOf(RemoteConfigStore.from(this.workingCopy)).log));
1897
+ if (this.message !== undefined && log === 0) return this.message;
1898
+ const fmt = new FmtMergeMsgCommand(this.workingCopy)
1899
+ .setHead(headId)
1900
+ .setLog(log)
1901
+ .setCreditPeople(false)
1902
+ .setMessage(this.message)
1903
+ .setIntoName(this.intoName);
1904
+ if (this.mergeNames !== undefined) fmt.setInput(this.mergeNames);
1905
+ else for (const { name } of heads) fmt.addHead(name);
1906
+ const text = await fmt.call();
1907
+ return text.endsWith("\n") ? text.slice(0, -1) : text;
1908
+ }
1909
+
1910
+ /**
1911
+ * prepare_to_commit's `--signoff`: the committer's sign-off added to merge_msg
1912
+ * (append_signoff with ignored_log_message_bytes).
1913
+ */
1914
+ private signedOff(message: string): string {
1915
+ if (!this.signoff) return message;
1916
+ const author = this.author ?? this.resolveAuthor(this.committer);
1917
+ const committer = this.committer ?? this.resolveCommitter(author);
1918
+ const config = trailerConfigOf(this.workingCopy);
1919
+ return appendSignoff(
1920
+ message,
1921
+ signoffLine(committer),
1922
+ config,
1923
+ false,
1924
+ ignoredLogMessageBytes(message, config.commentString),
1925
+ );
1503
1926
  }
1504
1927
 
1505
1928
  /** git's merge exports GIT_REFLOG_ACTION before it writes a ref (see reflogActionValue). */
@@ -1524,9 +1947,14 @@ export class MergeCommand extends GitCommand<MergeResult> {
1524
1947
  state: OperationState,
1525
1948
  message: string,
1526
1949
  writeState: (text: string) => Promise<void>,
1527
- ): Promise<{ message: string; refused?: string }> {
1950
+ ): Promise<{ message: string; refused?: string; stateText?: string }> {
1528
1951
  // (a merge a rebase makes in process runs no hooks of its own)
1529
- if (!this.hooks.enabled || this.inProcess) return { message: this.cleanup(message) };
1952
+ const edit = this.edit === true && !this.inProcess;
1953
+ const signed = this.signedOff(edit ? `${message}\n${this.editorComment()}` : message);
1954
+ const hooksRun = this.hooks.enabled && !this.inProcess;
1955
+ if (!hooksRun && !edit) {
1956
+ return { message: this.cleanup(signed), stateText: signed };
1957
+ }
1530
1958
  const env = {
1531
1959
  GIT_INDEX_FILE: await this.hooks.gitPath("index"),
1532
1960
  GIT_EDITOR: ":",
@@ -1539,17 +1967,26 @@ export class MergeCommand extends GitCommand<MergeResult> {
1539
1967
  refused: "Not committing merge; use 'git commit' to complete the merge.",
1540
1968
  };
1541
1969
  };
1542
- if (!this.noVerify) {
1970
+ if (hooksRun && !this.noVerify) {
1543
1971
  const pre = await this.hooks.run("pre-merge-commit", { env });
1544
1972
  if (pre && pre.exitCode !== 0) return abort();
1545
1973
  if (pre) await this.staging.read();
1546
1974
  }
1547
- // prepare_to_commit writes merge_msg as it is (`-m`'s text without a newline added)
1548
- await writeState(this.message ?? message);
1549
- const file = await this.hooks.gitPath("MERGE_MSG");
1550
- const prepare = await this.hooks.run("prepare-commit-msg", { args: [file, "merge"], env });
1551
- if (prepare && prepare.exitCode !== 0) return abort();
1552
- if (!this.noVerify) {
1975
+ // prepare_to_commit writes merge_msg as it is (no newline added), signed off
1976
+ await writeState(signed);
1977
+ if (hooksRun) {
1978
+ const file = await this.hooks.gitPath("MERGE_MSG");
1979
+ const prepare = await this.hooks.run("prepare-commit-msg", { args: [file, "merge"], env });
1980
+ if (prepare && prepare.exitCode !== 0) return abort();
1981
+ }
1982
+ if (edit && this.editor) {
1983
+ // launch_editor over MERGE_MSG
1984
+ const current = (await state.read("MERGE_MSG")) ?? "";
1985
+ const edited = await this.editor("MERGE_MSG", current);
1986
+ if (typeof edited === "string") await state.write("MERGE_MSG", edited);
1987
+ }
1988
+ if (hooksRun && !this.noVerify) {
1989
+ const file = await this.hooks.gitPath("MERGE_MSG");
1553
1990
  const check = await this.hooks.run("commit-msg", { args: [file], env });
1554
1991
  if (check && check.exitCode !== 0) return abort();
1555
1992
  }
@@ -1557,7 +1994,10 @@ export class MergeCommand extends GitCommand<MergeResult> {
1557
1994
  // the commit ends the merge (remove_merge_branch_state)
1558
1995
  await state.removeRef("MERGE_HEAD");
1559
1996
  await state.remove("MERGE_HEAD", "MERGE_MSG", "MERGE_MODE");
1560
- return { message: this.cleanup(text) };
1997
+ const cleaned = edit
1998
+ ? preparedMessageCleanup(this.workingCopy, text, this.cleanupMode)
1999
+ : this.cleanup(text);
2000
+ return { message: cleaned, stateText: text };
1561
2001
  }
1562
2002
 
1563
2003
  /** MERGE_HEAD, MERGE_MSG and MERGE_MODE of a merge stopped before its commit. */
@@ -1577,23 +2017,84 @@ export class MergeCommand extends GitCommand<MergeResult> {
1577
2017
  return "ours";
1578
2018
  case MergeStrategy.THEIRS:
1579
2019
  return "theirs";
2020
+ case MergeStrategy.RESOLVE:
2021
+ return "resolve";
2022
+ case MergeStrategy.SUBTREE:
2023
+ return "subtree";
2024
+ case MergeStrategy.RECURSIVE:
2025
+ return this.strategyGiven ? "recursive" : "ort";
1580
2026
  default:
1581
2027
  return "ort";
1582
2028
  }
1583
2029
  }
1584
2030
 
2031
+ /**
2032
+ * prepare_to_commit's help below the message for the editor (merge_editor_comment and
2033
+ * its scissors or no-scissors line), each line commented.
2034
+ */
2035
+ private editorComment(): string {
2036
+ const comment = trailerConfigOf(this.workingCopy).commentString;
2037
+ const commented = (text: string) =>
2038
+ text
2039
+ .split("\n")
2040
+ .slice(0, -1)
2041
+ .map((line) => (line === "" ? `${comment}\n` : `${comment} ${line}\n`))
2042
+ .join("");
2043
+ const scissors =
2044
+ (this.cleanupMode ?? RemoteConfigStore.from(this.workingCopy).value("commit.cleanup")) ===
2045
+ "scissors";
2046
+ let out = "";
2047
+ if (scissors) {
2048
+ out += `${comment} ------------------------ >8 ------------------------\n`;
2049
+ out += commented(
2050
+ "Do not modify or remove the line above.\nEverything below it will be ignored.\n",
2051
+ );
2052
+ out += commented("\n");
2053
+ }
2054
+ out += commented(
2055
+ "Please enter a commit message to explain why this merge is necessary,\n" +
2056
+ "especially if it merges an updated upstream into a topic branch.\n\n",
2057
+ );
2058
+ out += scissors
2059
+ ? commented("An empty message aborts the commit.\n")
2060
+ : commented(
2061
+ `Lines starting with '${comment}' will be ignored, and an empty message aborts\nthe commit.\n`,
2062
+ );
2063
+ return out;
2064
+ }
2065
+
1585
2066
  /** git's `cleanup_message` of a merge commit's message (prepare_to_commit, no editor). */
1586
2067
  private cleanup(message: string): string {
1587
2068
  const mode = commitCleanupMode(this.workingCopy, this.cleanupMode);
1588
2069
  return cleanupWith(this.workingCopy, message, mode);
1589
2070
  }
1590
2071
 
1591
- private async storeCommit(tree: ObjectId, parents: ObjectId[], message: string) {
2072
+ /**
2073
+ * The merge commit written, signed as `-S[<keyid>]` / `--no-gpg-sign` / `commit.gpgSign`
2074
+ * ask (builtin/merge.c's `commit_tree` with `sign_commit`). When it cannot be signed git
2075
+ * dies after prepare_to_commit has written the merge state (MERGE_MSG as the hooks left
2076
+ * it): `writeState` writes it (not for an in-process merge), so the merge stays in progress
2077
+ * for `git commit`, and the error is thrown.
2078
+ */
2079
+ private async storeCommit(
2080
+ tree: ObjectId,
2081
+ parents: ObjectId[],
2082
+ message: string,
2083
+ writeState?: () => Promise<void>,
2084
+ options: { continuing?: boolean } = {},
2085
+ ) {
1592
2086
  // git's merge commit: the author and the committer as git resolves them (GIT_AUTHOR_* /
1593
2087
  // GIT_COMMITTER_*, author.* / committer.*, user.*), unless given
1594
2088
  const author = this.author ?? this.resolveAuthor(this.committer);
1595
2089
  const committer = this.committer ?? this.resolveCommitter(author);
1596
- const commit: Commit = { tree, parents, author, committer, message };
2090
+ const sign = signRequestOf(this.workingCopy, options.continuing ? undefined : this.sign);
2091
+ let commit: Commit = { tree, parents, author, committer, message };
2092
+ try {
2093
+ commit = await this.signedCommit(sign, commit);
2094
+ } catch (error) {
2095
+ if (error instanceof SigningFailedError && writeState && !this.inProcess) await writeState();
2096
+ throw error;
2097
+ }
1597
2098
  return this.commits.store(commit);
1598
2099
  }
1599
2100
 
@@ -1623,27 +2124,6 @@ export class MergeCommand extends GitCommand<MergeResult> {
1623
2124
  await updateHeadExpecting(this.refsStore, id, old, log);
1624
2125
  }
1625
2126
 
1626
- /** How git's merge message names what is merged: `branch 'x'`, `tag 'v1'`, ... */
1627
- private async describeMergeSource(name: string, id: ObjectId): Promise<string> {
1628
- const strip = (prefix: string) => (name.startsWith(prefix) ? name.slice(prefix.length) : name);
1629
- if (name.startsWith("refs/heads/")) return `branch '${strip("refs/heads/")}'`;
1630
- if (name.startsWith("refs/remotes/"))
1631
- return `remote-tracking branch '${strip("refs/remotes/")}'`;
1632
- if (name.startsWith("refs/tags/")) return `tag '${strip("refs/tags/")}'`;
1633
- if (await this.refsStore.has(`refs/heads/${name}`)) return `branch '${name}'`;
1634
- if (await this.refsStore.has(`refs/tags/${name}`)) return `tag '${name}'`;
1635
- if (await this.refsStore.has(`refs/remotes/${name}`)) return `remote-tracking branch '${name}'`;
1636
- return `commit '${name || id}'`;
1637
- }
1638
-
1639
- /** git's default merge message: `Merge branch 'x'` (`into <branch>` off main/master). */
1640
- private async defaultMessage(description: string): Promise<string> {
1641
- const branch = await this.getCurrentBranch();
1642
- const short = branch?.startsWith("refs/heads/") ? branch.slice("refs/heads/".length) : "HEAD";
1643
- const into = short === "main" || short === "master" ? "" : ` into ${short}`;
1644
- return `Merge ${description}${into}\n`;
1645
- }
1646
-
1647
2127
  /**
1648
2128
  * Check if commitA is an ancestor of commitB.
1649
2129
  */
@@ -1706,3 +2186,29 @@ export function favorOf(
1706
2186
  return undefined;
1707
2187
  }
1708
2188
  }
2189
+
2190
+ /**
2191
+ * builtin/merge.c's read_tree_trivial: the merge of `head` and `remote` against `base` when
2192
+ * every path is trivial (taken whole from a side: unpack-trees' threeway_merge without
2193
+ * `--aggressive`), else undefined. A path that is a file on one side and a directory on
2194
+ * another is never trivial.
2195
+ */
2196
+ function trivialMerge(
2197
+ base: Map<string, CheckedEntry>,
2198
+ head: Map<string, CheckedEntry>,
2199
+ remote: Map<string, CheckedEntry>,
2200
+ ): Map<string, CheckedEntry> | undefined {
2201
+ const paths = new Set([...base.keys(), ...head.keys(), ...remote.keys()]);
2202
+ const dirs = new Set<string>();
2203
+ for (const p of paths) {
2204
+ for (let i = p.indexOf("/"); i >= 0; i = p.indexOf("/", i + 1)) dirs.add(p.slice(0, i));
2205
+ }
2206
+ const out = new Map<string, CheckedEntry>();
2207
+ for (const path of [...paths].sort(compareGitPaths)) {
2208
+ if (dirs.has(path)) return undefined;
2209
+ const r = threeway([base.get(path)], head.get(path), remote.get(path), false);
2210
+ if (r.kind === "merged") out.set(path, r.entry);
2211
+ else if (r.kind !== "removed") return undefined;
2212
+ }
2213
+ return out;
2214
+ }