@statewalker/vcs-commands 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (622) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/add-command.d.ts +32 -0
  3. package/dist/commands/add-command.d.ts.map +1 -1
  4. package/dist/commands/add-patch/add-patch.d.ts +7 -0
  5. package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
  6. package/dist/commands/add-patch/patch-backend.d.ts +2 -0
  7. package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
  8. package/dist/commands/add-patch/patch-modes.d.ts +6 -2
  9. package/dist/commands/add-patch/patch-modes.d.ts.map +1 -1
  10. package/dist/commands/add-patch/patch-session.d.ts +4 -0
  11. package/dist/commands/add-patch/patch-session.d.ts.map +1 -1
  12. package/dist/commands/am/am-command.d.ts +88 -2
  13. package/dist/commands/am/am-command.d.ts.map +1 -1
  14. package/dist/commands/apply/apply-command.d.ts +2 -0
  15. package/dist/commands/apply/apply-command.d.ts.map +1 -1
  16. package/dist/commands/apply/apply-parse.d.ts +7 -0
  17. package/dist/commands/apply/apply-parse.d.ts.map +1 -1
  18. package/dist/commands/apply/index.d.ts +1 -1
  19. package/dist/commands/apply/index.d.ts.map +1 -1
  20. package/dist/commands/archive/archive-command.d.ts +169 -0
  21. package/dist/commands/archive/archive-command.d.ts.map +1 -0
  22. package/dist/commands/archive/archive-entry.d.ts +60 -0
  23. package/dist/commands/archive/archive-entry.d.ts.map +1 -0
  24. package/dist/commands/archive/index.d.ts +8 -0
  25. package/dist/commands/archive/index.d.ts.map +1 -0
  26. package/dist/commands/archive/remote-archive-command.d.ts +56 -0
  27. package/dist/commands/archive/remote-archive-command.d.ts.map +1 -0
  28. package/dist/commands/archive/tar-archive.d.ts +31 -0
  29. package/dist/commands/archive/tar-archive.d.ts.map +1 -0
  30. package/dist/commands/archive/tar-commit-id.d.ts +13 -0
  31. package/dist/commands/archive/tar-commit-id.d.ts.map +1 -0
  32. package/dist/commands/archive/upload-archive-writer.d.ts +48 -0
  33. package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -0
  34. package/dist/commands/archive/zip-archive.d.ts +42 -0
  35. package/dist/commands/archive/zip-archive.d.ts.map +1 -0
  36. package/dist/commands/attributes-source.d.ts +10 -0
  37. package/dist/commands/attributes-source.d.ts.map +1 -1
  38. package/dist/commands/blame-command.d.ts +345 -8
  39. package/dist/commands/blame-command.d.ts.map +1 -1
  40. package/dist/commands/blame-ignore.d.ts +48 -0
  41. package/dist/commands/blame-ignore.d.ts.map +1 -0
  42. package/dist/commands/bundle/bundle-create-command.d.ts +67 -0
  43. package/dist/commands/bundle/bundle-create-command.d.ts.map +1 -0
  44. package/dist/commands/bundle/bundle-format.d.ts +89 -0
  45. package/dist/commands/bundle/bundle-format.d.ts.map +1 -0
  46. package/dist/commands/bundle/bundle-list.d.ts +92 -0
  47. package/dist/commands/bundle/bundle-list.d.ts.map +1 -0
  48. package/dist/commands/bundle/bundle-read-commands.d.ts +81 -0
  49. package/dist/commands/bundle/bundle-read-commands.d.ts.map +1 -0
  50. package/dist/commands/bundle/bundle-support.d.ts +32 -0
  51. package/dist/commands/bundle/bundle-support.d.ts.map +1 -0
  52. package/dist/commands/bundle/bundle-transport.d.ts +38 -0
  53. package/dist/commands/bundle/bundle-transport.d.ts.map +1 -0
  54. package/dist/commands/bundle/bundle-uri-host.d.ts +43 -0
  55. package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -0
  56. package/dist/commands/bundle/bundle-uri.d.ts +55 -0
  57. package/dist/commands/bundle/bundle-uri.d.ts.map +1 -0
  58. package/dist/commands/bundle/bundle-verify.d.ts +63 -0
  59. package/dist/commands/bundle/bundle-verify.d.ts.map +1 -0
  60. package/dist/commands/bundle/index.d.ts +14 -0
  61. package/dist/commands/bundle/index.d.ts.map +1 -0
  62. package/dist/commands/cat-file/batch-format.d.ts +58 -0
  63. package/dist/commands/cat-file/batch-format.d.ts.map +1 -0
  64. package/dist/commands/cat-file/cat-file-command.d.ts +135 -0
  65. package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -0
  66. package/dist/commands/cat-file/index.d.ts +3 -0
  67. package/dist/commands/cat-file/index.d.ts.map +1 -0
  68. package/dist/commands/check-attr-command.d.ts +66 -0
  69. package/dist/commands/check-attr-command.d.ts.map +1 -0
  70. package/dist/commands/check-ignore-command.d.ts +58 -0
  71. package/dist/commands/check-ignore-command.d.ts.map +1 -0
  72. package/dist/commands/check-mailmap-command.d.ts +49 -0
  73. package/dist/commands/check-mailmap-command.d.ts.map +1 -0
  74. package/dist/commands/check-ref-format-command.d.ts +60 -0
  75. package/dist/commands/check-ref-format-command.d.ts.map +1 -0
  76. package/dist/commands/checkout-command.d.ts +7 -0
  77. package/dist/commands/checkout-command.d.ts.map +1 -1
  78. package/dist/commands/checkout-index-command.d.ts +96 -0
  79. package/dist/commands/checkout-index-command.d.ts.map +1 -0
  80. package/dist/commands/checkout-paths.d.ts +4 -0
  81. package/dist/commands/checkout-paths.d.ts.map +1 -1
  82. package/dist/commands/cherry-command.d.ts +61 -0
  83. package/dist/commands/cherry-command.d.ts.map +1 -0
  84. package/dist/commands/cherry-pick-command.d.ts +33 -1
  85. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  86. package/dist/commands/clean-command.d.ts +32 -0
  87. package/dist/commands/clean-command.d.ts.map +1 -1
  88. package/dist/commands/clean-interactive.d.ts +56 -0
  89. package/dist/commands/clean-interactive.d.ts.map +1 -0
  90. package/dist/commands/clone-command.d.ts +135 -2
  91. package/dist/commands/clone-command.d.ts.map +1 -1
  92. package/dist/commands/commit-command.d.ts +59 -3
  93. package/dist/commands/commit-command.d.ts.map +1 -1
  94. package/dist/commands/config-command.d.ts +2 -0
  95. package/dist/commands/config-command.d.ts.map +1 -1
  96. package/dist/commands/daemon-access-hook.d.ts +36 -0
  97. package/dist/commands/daemon-access-hook.d.ts.map +1 -0
  98. package/dist/commands/default-branch.d.ts +42 -0
  99. package/dist/commands/default-branch.d.ts.map +1 -1
  100. package/dist/commands/describe-command.d.ts +71 -64
  101. package/dist/commands/describe-command.d.ts.map +1 -1
  102. package/dist/commands/diff-command.d.ts +249 -10
  103. package/dist/commands/diff-command.d.ts.map +1 -1
  104. package/dist/commands/diff-external.d.ts +43 -0
  105. package/dist/commands/diff-external.d.ts.map +1 -0
  106. package/dist/commands/diff-plumbing/diff-pairs-command.d.ts +27 -0
  107. package/dist/commands/diff-plumbing/diff-pairs-command.d.ts.map +1 -0
  108. package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts +129 -0
  109. package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts.map +1 -0
  110. package/dist/commands/diff-plumbing/index.d.ts +3 -0
  111. package/dist/commands/diff-plumbing/index.d.ts.map +1 -0
  112. package/dist/commands/diff-textconv.d.ts +5 -1
  113. package/dist/commands/diff-textconv.d.ts.map +1 -1
  114. package/dist/commands/fast-export/fast-export-command.d.ts +135 -0
  115. package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -0
  116. package/dist/commands/fast-export/fast-import-command.d.ts +182 -0
  117. package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -0
  118. package/dist/commands/fast-export/fast-stream-support.d.ts +64 -0
  119. package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -0
  120. package/dist/commands/fast-export/index.d.ts +4 -0
  121. package/dist/commands/fast-export/index.d.ts.map +1 -0
  122. package/dist/commands/fetch-command.d.ts +125 -0
  123. package/dist/commands/fetch-command.d.ts.map +1 -1
  124. package/dist/commands/fetch-multiple-command.d.ts +193 -0
  125. package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
  126. package/dist/commands/format-patch-command.d.ts +28 -2
  127. package/dist/commands/format-patch-command.d.ts.map +1 -1
  128. package/dist/commands/format-rev-command.d.ts +58 -0
  129. package/dist/commands/format-rev-command.d.ts.map +1 -0
  130. package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
  131. package/dist/commands/fsck/fsck-msg-ids.d.ts +18 -3
  132. package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -1
  133. package/dist/commands/fsmonitor-refresh.d.ts +69 -0
  134. package/dist/commands/fsmonitor-refresh.d.ts.map +1 -0
  135. package/dist/commands/gc-command.d.ts +5 -0
  136. package/dist/commands/gc-command.d.ts.map +1 -1
  137. package/dist/commands/git-describe.d.ts +77 -4
  138. package/dist/commands/git-describe.d.ts.map +1 -1
  139. package/dist/commands/git-hooks.d.ts +47 -1
  140. package/dist/commands/git-hooks.d.ts.map +1 -1
  141. package/dist/commands/git-paths.d.ts +26 -0
  142. package/dist/commands/git-paths.d.ts.map +1 -0
  143. package/dist/commands/grep/grep-command.d.ts +2 -1
  144. package/dist/commands/grep/grep-command.d.ts.map +1 -1
  145. package/dist/commands/history-command.d.ts +156 -0
  146. package/dist/commands/history-command.d.ts.map +1 -0
  147. package/dist/commands/http-config.d.ts +38 -0
  148. package/dist/commands/http-config.d.ts.map +1 -0
  149. package/dist/commands/index-adder.d.ts +12 -1
  150. package/dist/commands/index-adder.d.ts.map +1 -1
  151. package/dist/commands/index-host.d.ts.map +1 -1
  152. package/dist/commands/index.d.ts +56 -1
  153. package/dist/commands/index.d.ts.map +1 -1
  154. package/dist/commands/index.js +6 -3
  155. package/dist/commands/init-command.d.ts +89 -0
  156. package/dist/commands/init-command.d.ts.map +1 -1
  157. package/dist/commands/last-modified-command.d.ts +102 -0
  158. package/dist/commands/last-modified-command.d.ts.map +1 -0
  159. package/dist/commands/lfs/go-url.d.ts +43 -0
  160. package/dist/commands/lfs/go-url.d.ts.map +1 -0
  161. package/dist/commands/lfs/index.d.ts +3 -0
  162. package/dist/commands/lfs/index.d.ts.map +1 -0
  163. package/dist/commands/lfs/lfs-config.d.ts +174 -0
  164. package/dist/commands/lfs/lfs-config.d.ts.map +1 -0
  165. package/dist/commands/lfs/lfs-endpoint-command.d.ts +83 -0
  166. package/dist/commands/lfs/lfs-endpoint-command.d.ts.map +1 -0
  167. package/dist/commands/line-log.d.ts +161 -0
  168. package/dist/commands/line-log.d.ts.map +1 -0
  169. package/dist/commands/local-transport.d.ts.map +1 -1
  170. package/dist/commands/log-command.d.ts +261 -6
  171. package/dist/commands/log-command.d.ts.map +1 -1
  172. package/dist/commands/log-graph.d.ts +4 -2
  173. package/dist/commands/log-graph.d.ts.map +1 -1
  174. package/dist/commands/log-output.d.ts +88 -2
  175. package/dist/commands/log-output.d.ts.map +1 -1
  176. package/dist/commands/ls-files-command.d.ts +153 -0
  177. package/dist/commands/ls-files-command.d.ts.map +1 -0
  178. package/dist/commands/ls-remote-command.d.ts +5 -0
  179. package/dist/commands/ls-remote-command.d.ts.map +1 -1
  180. package/dist/commands/ls-tree-command.d.ts +105 -0
  181. package/dist/commands/ls-tree-command.d.ts.map +1 -0
  182. package/dist/commands/mailmap.d.ts +24 -1
  183. package/dist/commands/mailmap.d.ts.map +1 -1
  184. package/dist/commands/maintenance-run-command.d.ts +122 -0
  185. package/dist/commands/maintenance-run-command.d.ts.map +1 -0
  186. package/dist/commands/merge-command.d.ts +58 -1
  187. package/dist/commands/merge-command.d.ts.map +1 -1
  188. package/dist/commands/merge-config.d.ts +7 -0
  189. package/dist/commands/merge-config.d.ts.map +1 -1
  190. package/dist/commands/merge-drivers.d.ts +69 -5
  191. package/dist/commands/merge-drivers.d.ts.map +1 -1
  192. package/dist/commands/merge-strategy-options.d.ts +69 -0
  193. package/dist/commands/merge-strategy-options.d.ts.map +1 -0
  194. package/dist/commands/merge-support.d.ts +16 -0
  195. package/dist/commands/merge-support.d.ts.map +1 -1
  196. package/dist/commands/merge-tree-command.d.ts +122 -0
  197. package/dist/commands/merge-tree-command.d.ts.map +1 -0
  198. package/dist/commands/message-cleanup.d.ts +2 -0
  199. package/dist/commands/message-cleanup.d.ts.map +1 -1
  200. package/dist/commands/mktag-command.d.ts +51 -0
  201. package/dist/commands/mktag-command.d.ts.map +1 -0
  202. package/dist/commands/name-rev-command.d.ts +65 -0
  203. package/dist/commands/name-rev-command.d.ts.map +1 -0
  204. package/dist/commands/name-rev.d.ts +110 -22
  205. package/dist/commands/name-rev.d.ts.map +1 -1
  206. package/dist/commands/object-store/count-objects-command.d.ts +58 -0
  207. package/dist/commands/object-store/count-objects-command.d.ts.map +1 -0
  208. package/dist/commands/object-store/index.d.ts +5 -0
  209. package/dist/commands/object-store/index.d.ts.map +1 -0
  210. package/dist/commands/object-store/objects-directory.d.ts +12 -0
  211. package/dist/commands/object-store/objects-directory.d.ts.map +1 -0
  212. package/dist/commands/object-store/prune-command.d.ts +38 -0
  213. package/dist/commands/object-store/prune-command.d.ts.map +1 -0
  214. package/dist/commands/object-store/show-index-command.d.ts +23 -0
  215. package/dist/commands/object-store/show-index-command.d.ts.map +1 -0
  216. package/dist/commands/octopus-merge.d.ts +26 -1
  217. package/dist/commands/octopus-merge.d.ts.map +1 -1
  218. package/dist/commands/ort-merge.d.ts +40 -0
  219. package/dist/commands/ort-merge.d.ts.map +1 -1
  220. package/dist/commands/ort-recursive.d.ts.map +1 -1
  221. package/dist/commands/patch-id-command.d.ts +30 -0
  222. package/dist/commands/patch-id-command.d.ts.map +1 -0
  223. package/dist/commands/patch-id.d.ts +82 -0
  224. package/dist/commands/patch-id.d.ts.map +1 -1
  225. package/dist/commands/plumbing-command.d.ts +66 -0
  226. package/dist/commands/plumbing-command.d.ts.map +1 -0
  227. package/dist/commands/plumbing-input.d.ts +38 -0
  228. package/dist/commands/plumbing-input.d.ts.map +1 -0
  229. package/dist/commands/promisor-remote-reply.d.ts +35 -0
  230. package/dist/commands/promisor-remote-reply.d.ts.map +1 -0
  231. package/dist/commands/promisor-remote.d.ts.map +1 -1
  232. package/dist/commands/pull-command.d.ts +182 -38
  233. package/dist/commands/pull-command.d.ts.map +1 -1
  234. package/dist/commands/push-command.d.ts +82 -2
  235. package/dist/commands/push-command.d.ts.map +1 -1
  236. package/dist/commands/range-diff/index.d.ts +4 -0
  237. package/dist/commands/range-diff/index.d.ts.map +1 -0
  238. package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
  239. package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
  240. package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
  241. package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
  242. package/dist/commands/range-diff/range-diff.d.ts +106 -0
  243. package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
  244. package/dist/commands/read-tree-command.d.ts +14 -0
  245. package/dist/commands/read-tree-command.d.ts.map +1 -1
  246. package/dist/commands/rebase-command.d.ts +129 -4
  247. package/dist/commands/rebase-command.d.ts.map +1 -1
  248. package/dist/commands/refs-command.d.ts +81 -0
  249. package/dist/commands/refs-command.d.ts.map +1 -0
  250. package/dist/commands/remerge-diff.d.ts +59 -0
  251. package/dist/commands/remerge-diff.d.ts.map +1 -0
  252. package/dist/commands/remote-command.d.ts +41 -0
  253. package/dist/commands/remote-command.d.ts.map +1 -1
  254. package/dist/commands/remote-object-info-command.d.ts +55 -0
  255. package/dist/commands/remote-object-info-command.d.ts.map +1 -0
  256. package/dist/commands/remote-show-command.d.ts +204 -0
  257. package/dist/commands/remote-show-command.d.ts.map +1 -0
  258. package/dist/commands/remote-transport.d.ts +40 -3
  259. package/dist/commands/remote-transport.d.ts.map +1 -1
  260. package/dist/commands/repack-command.d.ts +115 -0
  261. package/dist/commands/repack-command.d.ts.map +1 -0
  262. package/dist/commands/replace-command.d.ts +143 -0
  263. package/dist/commands/replace-command.d.ts.map +1 -0
  264. package/dist/commands/replay-command.d.ts +117 -0
  265. package/dist/commands/replay-command.d.ts.map +1 -0
  266. package/dist/commands/repo-command.d.ts +136 -0
  267. package/dist/commands/repo-command.d.ts.map +1 -0
  268. package/dist/commands/request-pull-command.d.ts +82 -0
  269. package/dist/commands/request-pull-command.d.ts.map +1 -0
  270. package/dist/commands/rerere-command.d.ts +36 -0
  271. package/dist/commands/rerere-command.d.ts.map +1 -0
  272. package/dist/commands/rerere.d.ts +102 -0
  273. package/dist/commands/rerere.d.ts.map +1 -0
  274. package/dist/commands/reset-command.d.ts +19 -1
  275. package/dist/commands/reset-command.d.ts.map +1 -1
  276. package/dist/commands/restore-command.d.ts +7 -0
  277. package/dist/commands/restore-command.d.ts.map +1 -1
  278. package/dist/commands/rev-filter/commit-grep.d.ts +3 -1
  279. package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -1
  280. package/dist/commands/rev-list-command.d.ts +78 -3
  281. package/dist/commands/rev-list-command.d.ts.map +1 -1
  282. package/dist/commands/rev-parse-command.d.ts +9 -0
  283. package/dist/commands/rev-parse-command.d.ts.map +1 -1
  284. package/dist/commands/revert-command.d.ts +32 -1
  285. package/dist/commands/revert-command.d.ts.map +1 -1
  286. package/dist/commands/revision-range.d.ts +7 -0
  287. package/dist/commands/revision-range.d.ts.map +1 -1
  288. package/dist/commands/revision-resolver.d.ts +12 -0
  289. package/dist/commands/revision-resolver.d.ts.map +1 -1
  290. package/dist/commands/sequencer-pick.d.ts +120 -1
  291. package/dist/commands/sequencer-pick.d.ts.map +1 -1
  292. package/dist/commands/sequencer-support.d.ts +10 -1
  293. package/dist/commands/sequencer-support.d.ts.map +1 -1
  294. package/dist/commands/serve-repository.d.ts +23 -1
  295. package/dist/commands/serve-repository.d.ts.map +1 -1
  296. package/dist/commands/session-id.d.ts +18 -0
  297. package/dist/commands/session-id.d.ts.map +1 -0
  298. package/dist/commands/shortlog-command.d.ts +109 -0
  299. package/dist/commands/shortlog-command.d.ts.map +1 -0
  300. package/dist/commands/shortlog.d.ts +151 -0
  301. package/dist/commands/shortlog.d.ts.map +1 -0
  302. package/dist/commands/show-branch-command.d.ts +59 -0
  303. package/dist/commands/show-branch-command.d.ts.map +1 -0
  304. package/dist/commands/show-ref-command.d.ts +112 -0
  305. package/dist/commands/show-ref-command.d.ts.map +1 -0
  306. package/dist/commands/signature-check.d.ts +9 -2
  307. package/dist/commands/signature-check.d.ts.map +1 -1
  308. package/dist/commands/signing.d.ts +22 -1
  309. package/dist/commands/signing.d.ts.map +1 -1
  310. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  311. package/dist/commands/stash-export-command.d.ts +115 -0
  312. package/dist/commands/stash-export-command.d.ts.map +1 -0
  313. package/dist/commands/status-command.d.ts +33 -3
  314. package/dist/commands/status-command.d.ts.map +1 -1
  315. package/dist/commands/stripspace-command.d.ts +44 -0
  316. package/dist/commands/stripspace-command.d.ts.map +1 -0
  317. package/dist/commands/submodule-add-command.d.ts +10 -1
  318. package/dist/commands/submodule-add-command.d.ts.map +1 -1
  319. package/dist/commands/submodule-auth.d.ts +3 -1
  320. package/dist/commands/submodule-auth.d.ts.map +1 -1
  321. package/dist/commands/submodule-commands.d.ts +99 -3
  322. package/dist/commands/submodule-commands.d.ts.map +1 -1
  323. package/dist/commands/submodule-fetch.d.ts +149 -0
  324. package/dist/commands/submodule-fetch.d.ts.map +1 -0
  325. package/dist/commands/submodule-model.d.ts +8 -0
  326. package/dist/commands/submodule-model.d.ts.map +1 -1
  327. package/dist/commands/submodule-unpack.d.ts +120 -0
  328. package/dist/commands/submodule-unpack.d.ts.map +1 -0
  329. package/dist/commands/submodule-update-command.d.ts +21 -1
  330. package/dist/commands/submodule-update-command.d.ts.map +1 -1
  331. package/dist/commands/subtree-shift.d.ts +27 -0
  332. package/dist/commands/subtree-shift.d.ts.map +1 -0
  333. package/dist/commands/switch-command.d.ts +3 -0
  334. package/dist/commands/switch-command.d.ts.map +1 -1
  335. package/dist/commands/textconv-cache.d.ts +58 -0
  336. package/dist/commands/textconv-cache.d.ts.map +1 -0
  337. package/dist/commands/tree-restore.d.ts +5 -0
  338. package/dist/commands/tree-restore.d.ts.map +1 -1
  339. package/dist/commands/unpack-objects-command.d.ts +47 -0
  340. package/dist/commands/unpack-objects-command.d.ts.map +1 -0
  341. package/dist/commands/update-index-command.d.ts +110 -0
  342. package/dist/commands/update-index-command.d.ts.map +1 -0
  343. package/dist/commands/uri-protocols.d.ts +13 -0
  344. package/dist/commands/uri-protocols.d.ts.map +1 -0
  345. package/dist/commands/url-parse-command.d.ts +30 -0
  346. package/dist/commands/url-parse-command.d.ts.map +1 -0
  347. package/dist/commands/var-command.d.ts +42 -0
  348. package/dist/commands/var-command.d.ts.map +1 -0
  349. package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
  350. package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
  351. package/dist/{commands-ISM52N0n.js → commands-Mlo1dxQN.js} +56133 -70269
  352. package/dist/errors/command-errors.d.ts +58 -0
  353. package/dist/errors/command-errors.d.ts.map +1 -1
  354. package/dist/errors/index.js +67 -1
  355. package/dist/fsck-CrhVMNIH.js +5179 -0
  356. package/dist/git-command.d.ts +89 -3
  357. package/dist/git-command.d.ts.map +1 -1
  358. package/dist/git.d.ts +628 -1
  359. package/dist/git.d.ts.map +1 -1
  360. package/dist/guarded-transport-command.d.ts +84 -0
  361. package/dist/guarded-transport-command.d.ts.map +1 -0
  362. package/dist/index.d.ts +1 -0
  363. package/dist/index.d.ts.map +1 -1
  364. package/dist/index.js +7 -5
  365. package/dist/maintenance-run-command-Bw21HEkH.js +13539 -0
  366. package/dist/remote-transport-Bu4PGSMD.js +2605 -0
  367. package/dist/rename/detect-renames.d.ts +20 -0
  368. package/dist/rename/detect-renames.d.ts.map +1 -1
  369. package/dist/rename/diffcore-break.d.ts +51 -0
  370. package/dist/rename/diffcore-break.d.ts.map +1 -0
  371. package/dist/rename/index.d.ts +1 -0
  372. package/dist/rename/index.d.ts.map +1 -1
  373. package/dist/results/blame-format.d.ts +62 -1
  374. package/dist/results/blame-format.d.ts.map +1 -1
  375. package/dist/results/cherry-pick-result.d.ts +6 -0
  376. package/dist/results/cherry-pick-result.d.ts.map +1 -1
  377. package/dist/results/clone-result.d.ts +9 -0
  378. package/dist/results/clone-result.d.ts.map +1 -1
  379. package/dist/results/diff-dirstat.d.ts +36 -0
  380. package/dist/results/diff-dirstat.d.ts.map +1 -0
  381. package/dist/results/diff-entry.d.ts +20 -0
  382. package/dist/results/diff-entry.d.ts.map +1 -1
  383. package/dist/results/diff-formatter.d.ts.map +1 -1
  384. package/dist/results/diff-output.d.ts +67 -3
  385. package/dist/results/diff-output.d.ts.map +1 -1
  386. package/dist/results/fetch-result.d.ts +24 -1
  387. package/dist/results/fetch-result.d.ts.map +1 -1
  388. package/dist/results/index.d.ts +2 -0
  389. package/dist/results/index.d.ts.map +1 -1
  390. package/dist/results/index.js +2 -2
  391. package/dist/results/init-result.d.ts +8 -1
  392. package/dist/results/init-result.d.ts.map +1 -1
  393. package/dist/results/line-range-hunks.d.ts +27 -0
  394. package/dist/results/line-range-hunks.d.ts.map +1 -0
  395. package/dist/results/merge-result.d.ts +13 -1
  396. package/dist/results/merge-result.d.ts.map +1 -1
  397. package/dist/results/pull-result.d.ts +11 -0
  398. package/dist/results/pull-result.d.ts.map +1 -1
  399. package/dist/results/push-result.d.ts +10 -0
  400. package/dist/results/push-result.d.ts.map +1 -1
  401. package/dist/results/rebase-result.d.ts +7 -0
  402. package/dist/results/rebase-result.d.ts.map +1 -1
  403. package/dist/results/revert-result.d.ts +6 -0
  404. package/dist/results/revert-result.d.ts.map +1 -1
  405. package/dist/results/stash-result.d.ts +5 -0
  406. package/dist/results/stash-result.d.ts.map +1 -1
  407. package/dist/results/status-result.d.ts +1 -1
  408. package/dist/results/status-result.d.ts.map +1 -1
  409. package/dist/results-ERo9vELd.js +49673 -0
  410. package/dist/transport-command.d.ts +93 -1
  411. package/dist/transport-command.d.ts.map +1 -1
  412. package/package.json +12 -12
  413. package/src/commands/add-command.ts +118 -0
  414. package/src/commands/add-patch/add-patch.ts +8 -0
  415. package/src/commands/add-patch/patch-backend.ts +24 -3
  416. package/src/commands/add-patch/patch-modes.ts +26 -2
  417. package/src/commands/add-patch/patch-session.ts +6 -0
  418. package/src/commands/am/am-command.ts +301 -12
  419. package/src/commands/apply/apply-command.ts +52 -9
  420. package/src/commands/apply/apply-parse.ts +10 -0
  421. package/src/commands/apply/index.ts +9 -1
  422. package/src/commands/archive/archive-command.ts +1148 -0
  423. package/src/commands/archive/archive-entry.ts +93 -0
  424. package/src/commands/archive/index.ts +7 -0
  425. package/src/commands/archive/remote-archive-command.ts +140 -0
  426. package/src/commands/archive/tar-archive.ts +207 -0
  427. package/src/commands/archive/tar-commit-id.ts +72 -0
  428. package/src/commands/archive/upload-archive-writer.ts +213 -0
  429. package/src/commands/archive/zip-archive.ts +317 -0
  430. package/src/commands/attributes-source.ts +26 -12
  431. package/src/commands/blame-command.ts +1551 -53
  432. package/src/commands/blame-ignore.ts +307 -0
  433. package/src/commands/bundle/bundle-create-command.ts +405 -0
  434. package/src/commands/bundle/bundle-format.ts +228 -0
  435. package/src/commands/bundle/bundle-list.ts +276 -0
  436. package/src/commands/bundle/bundle-read-commands.ts +157 -0
  437. package/src/commands/bundle/bundle-support.ts +85 -0
  438. package/src/commands/bundle/bundle-transport.ts +107 -0
  439. package/src/commands/bundle/bundle-uri-host.ts +204 -0
  440. package/src/commands/bundle/bundle-uri.ts +236 -0
  441. package/src/commands/bundle/bundle-verify.ts +152 -0
  442. package/src/commands/bundle/index.ts +14 -0
  443. package/src/commands/cat-file/batch-format.ts +193 -0
  444. package/src/commands/cat-file/cat-file-command.ts +857 -0
  445. package/src/commands/cat-file/index.ts +2 -0
  446. package/src/commands/check-attr-command.ts +333 -0
  447. package/src/commands/check-ignore-command.ts +261 -0
  448. package/src/commands/check-mailmap-command.ts +129 -0
  449. package/src/commands/check-ref-format-command.ts +129 -0
  450. package/src/commands/checkout-command.ts +131 -28
  451. package/src/commands/checkout-index-command.ts +568 -0
  452. package/src/commands/checkout-paths.ts +35 -0
  453. package/src/commands/cherry-command.ts +187 -0
  454. package/src/commands/cherry-pick-command.ts +63 -2
  455. package/src/commands/clean-command.ts +92 -12
  456. package/src/commands/clean-interactive.ts +522 -0
  457. package/src/commands/clone-command.ts +803 -50
  458. package/src/commands/commit-command.ts +202 -51
  459. package/src/commands/config-command.ts +9 -0
  460. package/src/commands/daemon-access-hook.ts +78 -0
  461. package/src/commands/default-branch.ts +99 -1
  462. package/src/commands/describe-command.ts +341 -254
  463. package/src/commands/diff-command.ts +1186 -99
  464. package/src/commands/diff-external.ts +131 -0
  465. package/src/commands/diff-plumbing/diff-pairs-command.ts +193 -0
  466. package/src/commands/diff-plumbing/diff-plumbing-command.ts +424 -0
  467. package/src/commands/diff-plumbing/index.ts +2 -0
  468. package/src/commands/diff-textconv.ts +5 -1
  469. package/src/commands/fast-export/fast-export-command.ts +911 -0
  470. package/src/commands/fast-export/fast-import-command.ts +1553 -0
  471. package/src/commands/fast-export/fast-stream-support.ts +162 -0
  472. package/src/commands/fast-export/index.ts +3 -0
  473. package/src/commands/fetch-command.ts +665 -14
  474. package/src/commands/fetch-multiple-command.ts +668 -0
  475. package/src/commands/format-patch-command.ts +189 -77
  476. package/src/commands/format-rev-command.ts +251 -0
  477. package/src/commands/fsck/fsck-command.ts +47 -20
  478. package/src/commands/fsck/fsck-msg-ids.ts +19 -3
  479. package/src/commands/fsck/fsck-pack.ts +2 -2
  480. package/src/commands/fsmonitor-refresh.ts +315 -0
  481. package/src/commands/gc-command.ts +10 -0
  482. package/src/commands/git-describe.ts +456 -217
  483. package/src/commands/git-hooks.ts +165 -9
  484. package/src/commands/git-paths.ts +136 -0
  485. package/src/commands/grep/grep-command.ts +38 -15
  486. package/src/commands/history-command.ts +617 -0
  487. package/src/commands/http-config.ts +139 -0
  488. package/src/commands/index-adder.ts +37 -3
  489. package/src/commands/index-host.ts +6 -1
  490. package/src/commands/index.ts +62 -0
  491. package/src/commands/init-command.ts +617 -49
  492. package/src/commands/last-modified-command.ts +804 -0
  493. package/src/commands/lfs/go-url.ts +370 -0
  494. package/src/commands/lfs/index.ts +2 -0
  495. package/src/commands/lfs/lfs-config.ts +738 -0
  496. package/src/commands/lfs/lfs-endpoint-command.ts +180 -0
  497. package/src/commands/line-log.ts +931 -0
  498. package/src/commands/local-transport.ts +252 -4
  499. package/src/commands/log-command.ts +1518 -182
  500. package/src/commands/log-graph.ts +6 -3
  501. package/src/commands/log-output.ts +228 -15
  502. package/src/commands/ls-files-command.ts +1177 -0
  503. package/src/commands/ls-remote-command.ts +6 -0
  504. package/src/commands/ls-tree-command.ts +684 -0
  505. package/src/commands/mailmap.ts +41 -5
  506. package/src/commands/maintenance-run-command.ts +949 -0
  507. package/src/commands/merge-command.ts +351 -47
  508. package/src/commands/merge-config.ts +23 -1
  509. package/src/commands/merge-drivers.ts +112 -20
  510. package/src/commands/merge-strategy-options.ts +224 -0
  511. package/src/commands/merge-support.ts +130 -26
  512. package/src/commands/merge-tree-command.ts +786 -0
  513. package/src/commands/message-cleanup.ts +1 -1
  514. package/src/commands/mktag-command.ts +149 -0
  515. package/src/commands/name-rev-command.ts +184 -0
  516. package/src/commands/name-rev.ts +700 -109
  517. package/src/commands/object-store/count-objects-command.ts +404 -0
  518. package/src/commands/object-store/index.ts +4 -0
  519. package/src/commands/object-store/objects-directory.ts +24 -0
  520. package/src/commands/object-store/prune-command.ts +129 -0
  521. package/src/commands/object-store/show-index-command.ts +151 -0
  522. package/src/commands/octopus-merge.ts +35 -11
  523. package/src/commands/ort-merge.ts +124 -23
  524. package/src/commands/ort-recursive.ts +40 -2
  525. package/src/commands/patch-id-command.ts +65 -0
  526. package/src/commands/patch-id.ts +327 -0
  527. package/src/commands/plumbing-command.ts +141 -0
  528. package/src/commands/plumbing-input.ts +87 -0
  529. package/src/commands/promisor-remote-reply.ts +276 -0
  530. package/src/commands/promisor-remote.ts +25 -2
  531. package/src/commands/pull-command.ts +720 -224
  532. package/src/commands/push-command.ts +440 -8
  533. package/src/commands/range-diff/index.ts +3 -0
  534. package/src/commands/range-diff/linear-assignment.ts +203 -0
  535. package/src/commands/range-diff/range-diff-command.ts +433 -0
  536. package/src/commands/range-diff/range-diff.ts +617 -0
  537. package/src/commands/read-tree-command.ts +74 -3
  538. package/src/commands/rebase-command.ts +647 -83
  539. package/src/commands/refs-command.ts +274 -0
  540. package/src/commands/remerge-diff.ts +241 -0
  541. package/src/commands/remote-command.ts +98 -10
  542. package/src/commands/remote-object-info-command.ts +109 -0
  543. package/src/commands/remote-show-command.ts +836 -0
  544. package/src/commands/remote-transport.ts +116 -1
  545. package/src/commands/repack-command.ts +383 -0
  546. package/src/commands/replace-command.ts +816 -0
  547. package/src/commands/replay-command.ts +674 -0
  548. package/src/commands/repo-command.ts +967 -0
  549. package/src/commands/request-pull-command.ts +356 -0
  550. package/src/commands/rerere-command.ts +179 -0
  551. package/src/commands/rerere.ts +925 -0
  552. package/src/commands/reset-command.ts +78 -3
  553. package/src/commands/restore-command.ts +15 -0
  554. package/src/commands/rev-filter/commit-grep.ts +7 -2
  555. package/src/commands/rev-list-command.ts +196 -11
  556. package/src/commands/rev-parse-command.ts +62 -4
  557. package/src/commands/revert-command.ts +62 -2
  558. package/src/commands/revision-range.ts +10 -3
  559. package/src/commands/revision-resolver.ts +44 -3
  560. package/src/commands/sequencer-pick.ts +370 -29
  561. package/src/commands/sequencer-support.ts +164 -2
  562. package/src/commands/serve-repository.ts +65 -0
  563. package/src/commands/session-id.ts +31 -0
  564. package/src/commands/shortlog-command.ts +354 -0
  565. package/src/commands/shortlog.ts +361 -0
  566. package/src/commands/show-branch-command.ts +981 -0
  567. package/src/commands/show-command.ts +3 -2
  568. package/src/commands/show-ref-command.ts +439 -0
  569. package/src/commands/signature-check.ts +37 -5
  570. package/src/commands/signing.ts +122 -16
  571. package/src/commands/stash-apply-command.ts +3 -0
  572. package/src/commands/stash-export-command.ts +397 -0
  573. package/src/commands/status-command.ts +158 -31
  574. package/src/commands/status-format.ts +1 -1
  575. package/src/commands/stripspace-command.ts +118 -0
  576. package/src/commands/submodule-add-command.ts +22 -1
  577. package/src/commands/submodule-auth.ts +61 -6
  578. package/src/commands/submodule-commands.ts +333 -5
  579. package/src/commands/submodule-fetch.ts +789 -0
  580. package/src/commands/submodule-model.ts +9 -1
  581. package/src/commands/submodule-unpack.ts +265 -0
  582. package/src/commands/submodule-update-command.ts +68 -5
  583. package/src/commands/subtree-shift.ts +215 -0
  584. package/src/commands/switch-command.ts +9 -0
  585. package/src/commands/textconv-cache.ts +143 -0
  586. package/src/commands/tree-restore.ts +20 -1
  587. package/src/commands/unpack-objects-command.ts +235 -0
  588. package/src/commands/update-index-command.ts +1016 -0
  589. package/src/commands/uri-protocols.ts +13 -0
  590. package/src/commands/url-parse-command.ts +67 -0
  591. package/src/commands/var-command.ts +219 -0
  592. package/src/commands/worktree-overwrite-checks.ts +5 -0
  593. package/src/errors/command-errors.ts +80 -0
  594. package/src/git-command.ts +218 -2
  595. package/src/git.ts +1033 -80
  596. package/src/guarded-transport-command.ts +176 -0
  597. package/src/index.ts +1 -0
  598. package/src/rename/detect-renames.ts +42 -8
  599. package/src/rename/diffcore-break.ts +166 -0
  600. package/src/rename/index.ts +1 -0
  601. package/src/results/blame-format.ts +268 -43
  602. package/src/results/cherry-pick-result.ts +6 -0
  603. package/src/results/clone-result.ts +6 -0
  604. package/src/results/diff-dirstat.ts +117 -0
  605. package/src/results/diff-entry.ts +24 -0
  606. package/src/results/diff-formatter.ts +8 -4
  607. package/src/results/diff-output.ts +239 -8
  608. package/src/results/diff-pickaxe.ts +1 -1
  609. package/src/results/fetch-result.ts +24 -1
  610. package/src/results/index.ts +2 -0
  611. package/src/results/init-result.ts +10 -1
  612. package/src/results/line-range-hunks.ts +126 -0
  613. package/src/results/merge-result.ts +14 -0
  614. package/src/results/pull-result.ts +7 -0
  615. package/src/results/push-result.ts +10 -0
  616. package/src/results/rebase-result.ts +7 -0
  617. package/src/results/revert-result.ts +6 -0
  618. package/src/results/stash-result.ts +6 -0
  619. package/src/results/status-result.ts +2 -2
  620. package/src/transport-command.ts +216 -4
  621. package/dist/fsck-DLRpbwTj.js +0 -13405
  622. package/dist/results-TB2IJ64h.js +0 -4700
@@ -29,8 +29,15 @@ import {
29
29
  } from "../errors/index.js";
30
30
  import { GitCommand } from "../git-command.js";
31
31
  import { RemoteConfigStore } from "../remote-config/index.js";
32
+ import {
33
+ DEFAULT_RENAME_LIMIT,
34
+ detectRenames,
35
+ renameScoreOption,
36
+ scorePercent,
37
+ } from "../rename/index.js";
32
38
  import { type CombinedDiffOptions, writeCombinedDiff } from "../results/combined-diff.js";
33
39
  import type { DiffColors } from "../results/diff-color.js";
40
+ import type { DiffEntry } from "../results/diff-entry.js";
34
41
  import { DiffPickaxe } from "../results/diff-pickaxe.js";
35
42
  import { quotePath } from "../results/quote-path.js";
36
43
  import { bareAttributesResolver } from "./attributes-source.js";
@@ -43,10 +50,20 @@ import {
43
50
  import {
44
51
  checkPickaxeOptions,
45
52
  DiffCommand,
53
+ type DiffOutputFormat,
46
54
  type DiffTextOptions,
47
55
  hasPickaxe,
56
+ renamesValue,
48
57
  } from "./diff-command.js";
49
58
  import { hostEnvironmentOf } from "./git-ident.js";
59
+ import {
60
+ gitlinkText,
61
+ type LineLogHost,
62
+ type LineLogPair,
63
+ LineLogWalk,
64
+ lineLogEntry,
65
+ parseLineRanges,
66
+ } from "./line-log.js";
50
67
  import { GRAPH_COLUMN_COLORS_ANSI, graphColumnColors } from "./log-graph.js";
51
68
  import {
52
69
  type LogOutputEntry,
@@ -55,7 +72,7 @@ import {
55
72
  LogPrinter,
56
73
  type LogReflogEntry,
57
74
  } from "./log-output.js";
58
- import { type Mailmap, readRepositoryMailmap } from "./mailmap.js";
75
+ import type { Mailmap } from "./mailmap.js";
59
76
  import { configBool, configValue } from "./merge-config.js";
60
77
  import {
61
78
  addRefsByGlob,
@@ -68,6 +85,7 @@ import {
68
85
  } from "./notes-support.js";
69
86
  import { combineNotesIgnore } from "./notes-tree.js";
70
87
  import { canonicalObjectId } from "./object-id-input.js";
88
+ import { PatchIds } from "./patch-id.js";
71
89
  import {
72
90
  ALL_ENTRIES_NOT_INTERESTING,
73
91
  bloomPathOf,
@@ -83,8 +101,14 @@ import {
83
101
  treePathspec,
84
102
  } from "./pathspec.js";
85
103
  import { PathspecAttributes } from "./pathspec-attributes.js";
86
- import { type DecorationPalette, loadRefDecorations } from "./pretty-format.js";
104
+ import {
105
+ type DecorationPalette,
106
+ type LoadRefDecorationsOptions,
107
+ loadRefDecorations,
108
+ type RefDecorations,
109
+ } from "./pretty-format.js";
87
110
  import { openReflogWalk, walkReflogs } from "./reflog-walk.js";
111
+ import { RemergeTreeCommand, remergeObjectsView } from "./remerge-diff.js";
88
112
  import {
89
113
  type CommitFilter,
90
114
  CommitFilters,
@@ -121,6 +145,23 @@ interface PendingCommit {
121
145
  id: ObjectId;
122
146
  exclude: boolean;
123
147
  name?: string;
148
+ /** The left side of a symmetric difference (`a` of `a...b`, git's SYMMETRIC_LEFT) */
149
+ left?: boolean;
150
+ }
151
+
152
+ /** A commit of the walk as the log printer takes it. */
153
+ function outputEntry(c: LogResult): LogOutputEntry {
154
+ const { id, boundary, source, left, patchSame, reflog: _reflog, savedParents, ...commit } = c;
155
+ return {
156
+ id,
157
+ commit,
158
+ parents: c.parents,
159
+ ...(savedParents ? { savedParents } : {}),
160
+ ...(boundary ? { boundary: true } : {}),
161
+ ...(source !== undefined ? { source } : {}),
162
+ ...(left ? { left: true } : {}),
163
+ ...(patchSame ? { patchSame: true } : {}),
164
+ };
124
165
  }
125
166
 
126
167
  /** git's get_revision under `--reverse`: every commit read first, then given oldest first. */
@@ -130,6 +171,18 @@ async function* reversed<T>(source: AsyncIterable<T>): AsyncIterable<T> {
130
171
  for (let i = all.length - 1; i >= 0; i--) yield all[i] as T;
131
172
  }
132
173
 
174
+ /** A commit's parents as the walk holds them, by id */
175
+ function lineLogParentIds(t: RevTable, n: number): ObjectId[] {
176
+ const ids: ObjectId[] = [];
177
+ for (let k = 0, c = t.parentCount(n); k < c; k++) ids.push(t.idOf(t.parent(n, k)));
178
+ return ids;
179
+ }
180
+
181
+ /** A death of `git log -L` (`die()`: `fatal:`, exit 128) */
182
+ function lineLogDeath(message: string): GitApiError {
183
+ return new GitApiError(`fatal: ${message}`).withExitCode(128);
184
+ }
185
+
133
186
  /** git log reads no index: the in-tree attributes files are the worktree's only. */
134
187
  const NO_INDEX = { attributesBlob: () => undefined };
135
188
 
@@ -146,6 +199,16 @@ export interface LogResult extends Commit {
146
199
  * not listed itself, given after the others (git's `BOUNDARY`, the `-` mark)
147
200
  */
148
201
  boundary?: boolean;
202
+ /**
203
+ * On the left side of a symmetric difference (`a` of `a...b`, reached from it only): git's
204
+ * SYMMETRIC_LEFT, the `<` mark of {@link LogCommand.setLeftRight} (`>` otherwise)
205
+ */
206
+ left?: boolean;
207
+ /**
208
+ * {@link LogCommand.setCherryMark}: the other side of the symmetric difference has a commit
209
+ * with the same patch-id (git's PATCHSAME, the `=` mark)
210
+ */
211
+ patchSame?: boolean;
149
212
  /**
150
213
  * The name the commit was reached from ({@link LogCommand.setSource}, git's `--source`):
151
214
  * the revision as given, or the ref `--all`, `--branches`... named
@@ -153,6 +216,11 @@ export interface LogResult extends Commit {
153
216
  source?: string;
154
217
  /** In a reflog walk ({@link LogCommand.addReflogWalk}), the entry the commit is listed for */
155
218
  reflog?: LogReflogEntry;
219
+ /**
220
+ * The parents before {@link LogCommand.setParents} rewrote `parents` (git's saved parents,
221
+ * which `--full-diff` diffs against)
222
+ */
223
+ savedParents?: ObjectId[];
156
224
  }
157
225
 
158
226
  /**
@@ -330,6 +398,10 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
330
398
  private readonly grepReflogs: string[] = [];
331
399
  /** The git version whose behaviour differs where versions differ */
332
400
  private compatibility: "2.43" | "2.56" = "2.56";
401
+ /** `-L` arguments, as given */
402
+ private readonly lineRangeArgs: string[] = [];
403
+ /** The ranges `-L` follows through the walk under way */
404
+ private lineLog?: LineLogWalk;
333
405
  /** `--topo-order`, `--date-order`, `--author-date-order` */
334
406
  private order?: LogOrder;
335
407
  /** `--reverse` */
@@ -338,6 +410,41 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
338
410
  private boundary = false;
339
411
  /** `--source` */
340
412
  private source = false;
413
+ /** `--left-right` */
414
+ private leftRight = false;
415
+ /** `--left-only` */
416
+ private leftOnly = false;
417
+ /** `--right-only` (and `--cherry`) */
418
+ private rightOnly = false;
419
+ /** `--cherry-pick` */
420
+ private cherryPick = false;
421
+ /** `--cherry-mark` (and `--cherry`) */
422
+ private cherryMark = false;
423
+ /** `--cherry`: no merges (git's max_parents 1) */
424
+ private cherry = false;
425
+ /** `--simplify-merges` (and `--simplify-by-decoration`) */
426
+ private simplifyMerges = false;
427
+ /** `--simplify-by-decoration` */
428
+ private simplifyByDecoration = false;
429
+ /** git's `dense`: `--dense` (the default), off with `--sparse` */
430
+ private dense = true;
431
+ /** `--show-pulls` */
432
+ private showPulls = false;
433
+ /** `--parents` (git's `rewrite_parents` by itself) */
434
+ private rewriteParents = false;
435
+ /** `--ancestry-path` without a commit: the bottom commits are the ones */
436
+ private ancestryPathImplicit = false;
437
+ /** `--ancestry-path=<commit>`: the commits given */
438
+ private readonly ancestryPathCommits: ObjectId[] = [];
439
+ /**
440
+ * Commits a revision reaches through an annotated tag `--ancestry-path=<tag>` names: the
441
+ * tag's ANCESTRY_PATH passes to them (handle_commit's `object->flags |= flags`)
442
+ */
443
+ private readonly ancestryPathPeeled: ObjectId[] = [];
444
+ /** `git log --reverse` collects the walk itself: shown commits keep their parents */
445
+ private keepShownParents = false;
446
+ /** Loads the decorations `--simplify-by-decoration` keeps (the log's filter), when set */
447
+ private decorationLoader?: () => Promise<RefDecorations>;
341
448
 
342
449
  /**
343
450
  * The order of the commits ({@link LogOrder}); undefined is git's default, newest commit
@@ -395,6 +502,118 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
395
502
  return this;
396
503
  }
397
504
 
505
+ /**
506
+ * `--left-right`: each commit is marked by the side of the symmetric difference it is
507
+ * reached from: `<` for the left (`a` of `a...b`, {@link add} with `left`), `>` for the
508
+ * right (`commit < <id>`, `< <id> <subject>` under `--oneline`, the graph's `<`/`>` in place
509
+ * of `*`); `left` on each {@link LogResult} says it whatever this says.
510
+ *
511
+ * @example
512
+ * ```typescript
513
+ * // git log --left-right --oneline main...topic
514
+ * await git.revList().addRevision("main...topic").setLeftRight(true).callLogText({ oneline: true });
515
+ * ```
516
+ */
517
+ setLeftRight(leftRight: boolean): this {
518
+ this.checkCallable();
519
+ this.leftRight = leftRight;
520
+ return this;
521
+ }
522
+
523
+ /**
524
+ * `--left-only`: only the commits of the left side of a symmetric difference (none without
525
+ * one). Refused with {@link setRightOnly} or {@link setCherry}, as git refuses them.
526
+ */
527
+ setLeftOnly(leftOnly: boolean): this {
528
+ this.checkCallable();
529
+ if (leftOnly && this.rightOnly) {
530
+ throw new IncompatibleOptionsError(
531
+ ["--left-only", "--right-only/--cherry"],
532
+ "options '--left-only' and '--right-only/--cherry' cannot be used together",
533
+ );
534
+ }
535
+ this.leftOnly = leftOnly;
536
+ return this;
537
+ }
538
+
539
+ /** `--right-only`: only the commits of the right side (see {@link setLeftOnly}). */
540
+ setRightOnly(rightOnly: boolean): this {
541
+ this.checkCallable();
542
+ if (rightOnly && this.leftOnly) {
543
+ throw new IncompatibleOptionsError(
544
+ ["--right-only", "--left-only"],
545
+ "options '--right-only' and '--left-only' cannot be used together",
546
+ );
547
+ }
548
+ this.rightOnly = rightOnly;
549
+ return this;
550
+ }
551
+
552
+ /**
553
+ * `--cherry-pick`: commits whose change (patch-id, as `git patch-id` computes it, limited to
554
+ * the paths) a commit on the other side of the symmetric difference makes too are left out,
555
+ * on both sides. The cheap id of each diff's headers is computed for the smaller side, and
556
+ * full patch-ids only where those collide (revision.c's cherry_pick_list).
557
+ *
558
+ * @example
559
+ * ```typescript
560
+ * // git rev-list --left-right --cherry-pick main...topic
561
+ * await git.revList().addRevision("main...topic").setLeftRight(true).setCherryPick(true).callText();
562
+ * ```
563
+ */
564
+ setCherryPick(cherryPick: boolean): this {
565
+ this.checkCallable();
566
+ if (cherryPick && this.cherryMark) {
567
+ throw new IncompatibleOptionsError(
568
+ ["--cherry-pick", "--cherry-mark"],
569
+ "options '--cherry-pick' and '--cherry-mark' cannot be used together",
570
+ );
571
+ }
572
+ this.cherryPick = cherryPick;
573
+ return this;
574
+ }
575
+
576
+ /**
577
+ * `--cherry-mark`: as {@link setCherryPick}, but the equivalent commits are kept and marked
578
+ * (`patchSame`, the `=` mark; the others `+` when nothing else marks them).
579
+ */
580
+ setCherryMark(cherryMark: boolean): this {
581
+ this.checkCallable();
582
+ if (cherryMark && this.cherryPick) {
583
+ throw new IncompatibleOptionsError(
584
+ ["--cherry-mark", "--cherry-pick"],
585
+ "options '--cherry-mark' and '--cherry-pick' cannot be used together",
586
+ );
587
+ }
588
+ this.cherryMark = cherryMark;
589
+ return this;
590
+ }
591
+
592
+ /**
593
+ * `--cherry`: `--right-only --cherry-mark --no-merges`, the commits of the right side marked
594
+ * by whether the left side has their change (`git cherry` as a walk).
595
+ */
596
+ setCherry(cherry: boolean): this {
597
+ this.checkCallable();
598
+ if (cherry && this.leftOnly) {
599
+ throw new IncompatibleOptionsError(
600
+ ["--cherry", "--left-only"],
601
+ "options '--cherry' and '--left-only' cannot be used together",
602
+ );
603
+ }
604
+ this.cherry = cherry;
605
+ if (cherry) {
606
+ this.cherryMark = true;
607
+ this.rightOnly = true;
608
+ }
609
+ return this;
610
+ }
611
+
612
+ /** The revision options of the marks the output prints (get_revision_mark). */
613
+ private revisionMarks(): { leftRight: boolean; cherryMark: boolean } {
614
+ return { leftRight: this.leftRight, cherryMark: this.cherryMark };
615
+ }
616
+
398
617
  /**
399
618
  * `git log -g <ref>` (`--walk-reflogs`) for the printed log ({@link callText}): the
400
619
  * commits of `ref`'s reflog, newest entry first, each shown with its entry (`Reflog:`
@@ -440,7 +659,9 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
440
659
 
441
660
  /**
442
661
  * The git version to follow where versions differ (default 2.56): 2.43 refuses a reflog
443
- * walk's `--reverse` before a sorted walk (`--topo-order`, `--graph`), 2.56 after.
662
+ * walk's `--reverse` before a sorted walk (`--topo-order`, `--graph`), 2.56 after; 2.43's
663
+ * `--left-only`/`--right-only` hide nothing in a walk nothing else limits (no excluded
664
+ * commit: `a...b` of unrelated histories, or no range at all).
444
665
  */
445
666
  setCompatibility(version: "2.43" | "2.56"): this {
446
667
  this.checkCallable();
@@ -468,11 +689,41 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
468
689
  *
469
690
  * @param commit ObjectId of commit to start from
470
691
  * @param name The name it was given by, which {@link setSource} reports (the id without)
692
+ * @param options `left`: the commit is the left side of a symmetric difference (`a` of
693
+ * `a...b`): it and what only it reaches are marked so ({@link setLeftRight})
471
694
  */
472
- add(commit: ObjectId, name?: string): this {
695
+ add(commit: ObjectId, name?: string, options: { left?: boolean } = {}): this {
473
696
  this.checkCallable();
474
697
  this.startCommits.push(commit);
475
- this.pending.push({ id: commit, exclude: false, ...(name !== undefined ? { name } : {}) });
698
+ this.pending.push({
699
+ id: commit,
700
+ exclude: false,
701
+ ...(name !== undefined ? { name } : {}),
702
+ ...(options.left ? { left: true } : {}),
703
+ });
704
+ return this;
705
+ }
706
+
707
+ /**
708
+ * `-L <start>,<end>:<file>` / `-L :<funcname>:<file>`: follow lines of a file back through
709
+ * history ({@link callBytes} only). The range is given as git takes it: `<start>` and
710
+ * `<end>` line numbers, `+<n>`/`-<n>` offsets, `/<regex>/` (searched from the previous
711
+ * range of the file, or the top with `^/<regex>/`), or `:<regex>` naming a function as the
712
+ * path's diff driver finds them (`diff.<driver>.xfuncname`, the builtin drivers). Each
713
+ * commit whose change touches the lines is shown with its diff cut to them; renames are
714
+ * followed (`diff.renames`, `-M`). Several ranges, of one file or several, are followed
715
+ * together. The log starts from one commit (HEAD by default), and paths cannot be given.
716
+ * Errors are git's deaths (`fatal: ...`, exit 128).
717
+ *
718
+ * @example
719
+ * ```typescript
720
+ * // git log -L 4,12:a.c -L :main:a.c
721
+ * await git.log().addLineRange("4,12:a.c").addLineRange(":main:a.c").callText();
722
+ * ```
723
+ */
724
+ addLineRange(range: string): this {
725
+ this.checkCallable();
726
+ this.lineRangeArgs.push(range);
476
727
  return this;
477
728
  }
478
729
 
@@ -556,6 +807,86 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
556
807
  return this;
557
808
  }
558
809
 
810
+ /**
811
+ * `--simplify-merges`: a path-limited walk keeps every parent of a merge (as
812
+ * {@link setFullHistory}), then removes the merges whose parents simplify to one commit and
813
+ * the parents another parent reaches (revision.c's simplify_merges). Commits come in
814
+ * topological order (`--topo-order` unless another order is set), with their parents
815
+ * rewritten past the commits not shown.
816
+ */
817
+ setSimplifyMerges(simplify: boolean): this {
818
+ this.checkCallable();
819
+ this.simplifyMerges = simplify;
820
+ return this;
821
+ }
822
+
823
+ /**
824
+ * `--simplify-by-decoration`: only commits a ref names (git's ref decorations: every ref and
825
+ * HEAD, or `git log`'s decoration filter in {@link callText}), commits that change the
826
+ * paths when paths are given, and merges tying them together; merges simplified as
827
+ * {@link setSimplifyMerges}.
828
+ */
829
+ setSimplifyByDecoration(simplify: boolean): this {
830
+ this.checkCallable();
831
+ this.simplifyByDecoration = simplify;
832
+ return this;
833
+ }
834
+
835
+ /**
836
+ * `--dense` (true, the default) / `--sparse` (false): with `--sparse` a path-limited walk
837
+ * shows every commit it walks, also those that change none of the paths (merges are still
838
+ * simplified to the parent they match).
839
+ */
840
+ setDense(dense: boolean): this {
841
+ this.checkCallable();
842
+ this.dense = dense;
843
+ return this;
844
+ }
845
+
846
+ /**
847
+ * `--show-pulls`: a merge that differs from its first parent at the paths but matches
848
+ * another parent is shown too (it "pulled" the change into the first-parent history).
849
+ */
850
+ setShowPulls(showPulls: boolean): this {
851
+ this.checkCallable();
852
+ this.showPulls = showPulls;
853
+ return this;
854
+ }
855
+
856
+ /**
857
+ * `--parents`: each commit's `parents` are the ones the walk shows (rewritten past the
858
+ * commits a path-limited walk leaves out, as git's `rewrite_parents`), and TREESAME merges
859
+ * of two relevant lines are kept to tie them together.
860
+ */
861
+ setParents(parents: boolean): this {
862
+ this.checkCallable();
863
+ this.rewriteParents = parents;
864
+ return this;
865
+ }
866
+
867
+ /**
868
+ * `--ancestry-path`: of `A..B`, only the commits that are descendants of an excluded
869
+ * (bottom) commit and ancestors of B. A walk without bottom commits fails (`--ancestry-path
870
+ * given but there are no bottom commits`). Turns history simplification off, as
871
+ * {@link setFullHistory}.
872
+ */
873
+ setAncestryPath(ancestryPath: boolean): this {
874
+ this.checkCallable();
875
+ this.ancestryPathImplicit = ancestryPath;
876
+ return this;
877
+ }
878
+
879
+ /**
880
+ * `--ancestry-path=<commit>` (repeatable): only the commits that are the commit, its
881
+ * ancestors or its descendants (of any commit given). A tag is peeled: its commit then
882
+ * keeps only its descendants, as git marks the tag object and not the commit.
883
+ */
884
+ addAncestryPath(commit: ObjectId): this {
885
+ this.checkCallable();
886
+ this.ancestryPathCommits.push(canonicalObjectId(commit));
887
+ return this;
888
+ }
889
+
559
890
  /**
560
891
  * Follow only the first parent on merges.
561
892
  *
@@ -576,9 +907,14 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
576
907
  * @param commit ObjectId to exclude along with its ancestors
577
908
  * @param name The name it was given by (see {@link add})
578
909
  */
579
- not(commit: ObjectId, name?: string): this {
910
+ not(commit: ObjectId, name?: string, options: { left?: boolean } = {}): this {
580
911
  this.checkCallable();
581
- this.pending.push({ id: commit, exclude: true, ...(name !== undefined ? { name } : {}) });
912
+ this.pending.push({
913
+ id: commit,
914
+ exclude: true,
915
+ ...(name !== undefined ? { name } : {}),
916
+ ...(options.left ? { left: true } : {}),
917
+ });
582
918
  return this;
583
919
  }
584
920
 
@@ -813,20 +1149,27 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
813
1149
  const pending: PendingCommit[] = [];
814
1150
  for (let i = 0; i <= this.pending.length; i++) {
815
1151
  if (this.includeAll && i === this.allAt) {
816
- for (const { id, name } of await this.getAllRefs())
1152
+ for (const { id, name, raw } of await this.getAllRefs()) {
1153
+ if (raw !== id && this.ancestryPathCommits.includes(raw))
1154
+ this.ancestryPathPeeled.push(id);
817
1155
  pending.push({ id, exclude: false, name });
1156
+ }
818
1157
  }
819
1158
  const e = this.pending[i];
1159
+ if (e && e.id !== (await this.peelToCommit(e.id)) && this.ancestryPathCommits.includes(e.id))
1160
+ this.ancestryPathPeeled.push(await this.peelToCommit(e.id));
820
1161
  if (e)
821
1162
  pending.push({
822
1163
  id: await this.peelToCommit(e.id),
823
1164
  exclude: e.exclude,
824
1165
  name: e.name ?? e.id,
1166
+ ...(e.left ? { left: true } : {}),
825
1167
  });
826
1168
  }
827
1169
  if (this.startCommits.length === 0 && !this.includeAll) {
828
1170
  pending.push({ id: await this.resolveHead(), exclude: false, name: "HEAD" });
829
1171
  }
1172
+ if (this.lineRangeArgs.length > 0) await this.startLineLog(pending);
830
1173
  const walk = this.walk(pending);
831
1174
  return this.reverse ? reversed(walk) : walk;
832
1175
  }
@@ -857,8 +1200,7 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
857
1200
  const mapped =
858
1201
  this.useMailmap ??
859
1202
  (this.logConfig ? configBool(this.workingCopy, "log.mailmap", true) : false);
860
- if (headers && mapped)
861
- mailmap = await this.loadMailmap(RemoteConfigStore.from(this._workingCopy));
1203
+ if (headers && mapped) mailmap = await this.loadedMailmap();
862
1204
  filters.push(
863
1205
  CommitFilters.grep({
864
1206
  messages: this.grepMessages,
@@ -937,7 +1279,7 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
937
1279
  * (refs_for_each_ref, symbolic ones resolved), then HEAD (refs_head_ref); annotated tags
938
1280
  * peeled.
939
1281
  */
940
- private async getAllRefs(): Promise<{ id: ObjectId; name: string }[]> {
1282
+ private async getAllRefs(): Promise<{ id: ObjectId; name: string; raw: ObjectId }[]> {
941
1283
  const named: { name: Uint8Array; id: ObjectId }[] = [];
942
1284
  for await (const ref of this.refsStore.list()) {
943
1285
  if (!ref.name.startsWith("refs/")) continue;
@@ -946,11 +1288,11 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
946
1288
  if (id) named.push({ name: encodeGitPath(ref.name), id });
947
1289
  }
948
1290
  named.sort((a, b) => compareBytes(a.name, b.name));
949
- const ids: { id: ObjectId; name: string }[] = [];
1291
+ const ids: { id: ObjectId; name: string; raw: ObjectId }[] = [];
950
1292
  for (const { id, name } of named)
951
- ids.push({ id: await this.peelToCommit(id), name: decodeGitPath(name) });
1293
+ ids.push({ id: await this.peelToCommit(id), name: decodeGitPath(name), raw: id });
952
1294
  const head = (await this.refsStore.resolve("HEAD").catch(() => undefined))?.objectId;
953
- if (head) ids.push({ id: await this.peelToCommit(head), name: "HEAD" });
1295
+ if (head) ids.push({ id: await this.peelToCommit(head), name: "HEAD", raw: head });
954
1296
  return ids;
955
1297
  }
956
1298
 
@@ -975,7 +1317,20 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
975
1317
  * the commit-graph has are reached by their graph positions, without building their ids.
976
1318
  */
977
1319
  private async *walk(pending: PendingCommit[]): AsyncIterable<LogResult> {
978
- const prune = this.paths.length > 0 || this.excludePaths.length > 0;
1320
+ const hasPaths = this.paths.length > 0 || this.excludePaths.length > 0;
1321
+ const simplifyByDecoration = this.simplifyByDecoration;
1322
+ // --simplify-by-decoration prunes without paths: a commit no ref names is TREESAME
1323
+ const prune = hasPaths || simplifyByDecoration;
1324
+ const simplifyMerges = this.simplifyMerges || simplifyByDecoration;
1325
+ const ancestryPath = this.ancestryPathImplicit || this.ancestryPathCommits.length > 0;
1326
+ const dense = this.dense;
1327
+ const showPulls = this.showPulls;
1328
+ // git's want_ancestry: rewrite_parents (--parents, --graph, --simplify-merges)
1329
+ const wantAncestry = this.rewriteParents || simplifyMerges || !!this.outputWalk?.rewrite;
1330
+ const rewrite = prune && dense && wantAncestry;
1331
+ const decorations = simplifyByDecoration
1332
+ ? await (this.decorationLoader?.() ?? this.refDecorations())
1333
+ : undefined;
979
1334
  // a shallow commit has no parents (git's shallow grafts); the graph is off then
980
1335
  const shallowIds = (await this.refsStore.getShallow?.().catch(() => undefined)) ?? [];
981
1336
  const shallow = new Set(shallowIds);
@@ -988,13 +1343,13 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
988
1343
  shallow.size > 0 || replacements
989
1344
  ? undefined
990
1345
  : await this.commits.commitGraph?.get().catch(() => undefined);
991
- const pathspec = prune ? this.pathspec() : undefined;
1346
+ const pathspec = hasPaths ? this.pathspec() : undefined;
992
1347
  const bloom =
993
1348
  pathspec && this.useBloomFilters ? this.bloomKeys(graph, pathspec.items) : undefined;
994
1349
  const bloomVersion = bloom ? this.changedPathsVersion() : -1;
995
1350
  const fast = pathspec?.literal;
996
1351
  const firstParentOnly = this.firstParentOnly;
997
- const simplifyHistory = this.simplifyHistory;
1352
+ const simplifyHistory = this.simplifyHistory && !simplifyMerges && !ancestryPath;
998
1353
  /**
999
1354
  * Each merge's TREESAME to each parent (git's `treesame` decoration), kept when limiting
1000
1355
  * can make it TREESAME later (limiting_can_increase_treesame: full history, a limited walk)
@@ -1050,8 +1405,20 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1050
1405
  for (let k = 0, c = t.parentCount(n); k < c; k++) markOne(t.parent(n, k));
1051
1406
  for (let p = stack.pop(); p !== undefined; p = stack.pop()) markOne(p);
1052
1407
  };
1053
- const differs = (from: ObjectId | undefined, n: number, nth: number) =>
1054
- this.differsAtPaths(
1408
+ const emptyTree = this.objectFormat.emptyTreeId;
1409
+ /** git's rev_compare_tree (`from` given) and rev_same_tree_as_empty: whether n differs */
1410
+ const differs = async (
1411
+ from: ObjectId | undefined,
1412
+ n: number,
1413
+ nth: number,
1414
+ ): Promise<boolean> => {
1415
+ if (decorations && from !== undefined) {
1416
+ // a commit a ref names is worth showing; without paths, no other is
1417
+ if ((decorations.get(t.idOf(n))?.length ?? 0) > 0) return true;
1418
+ if (!pathspec) return false;
1419
+ }
1420
+ if (!pathspec) return t.treeOf(n) !== emptyTree;
1421
+ return this.differsAtPaths(
1055
1422
  from,
1056
1423
  t.treeOf(n),
1057
1424
  pathspec as TreePathspec,
@@ -1061,14 +1428,18 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1061
1428
  graph,
1062
1429
  t.bloomPos(n),
1063
1430
  );
1064
- /** git's try_to_simplify_commit (prune, dense, no show_pulls) */
1431
+ };
1432
+ /** git's try_to_simplify_commit */
1065
1433
  const simplify = async (n: number): Promise<void> => {
1066
- if (!prune) return;
1434
+ // an unparsed commit has no tree (a parent --first-parent never read, met by rewriting)
1435
+ if (!prune || !t.parsed(n)) return;
1067
1436
  const count = t.parentCount(n);
1068
1437
  if (count === 0) {
1069
1438
  if (!(await differs(undefined, n, 0))) t.mark(n, TREESAME);
1070
1439
  return;
1071
1440
  }
1441
+ // --sparse: a non-merge always counts as a change
1442
+ if (!dense && count === 1) return;
1072
1443
  let relevantParents = 0;
1073
1444
  let relevantChange = false;
1074
1445
  let irrelevantChange = false;
@@ -1095,11 +1466,13 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1095
1466
  continue;
1096
1467
  }
1097
1468
  t.keepOnlyParent(n, p);
1098
- t.mark(n, TREESAME);
1469
+ // a merge diverted to a later parent is shown under --show-pulls
1470
+ if (!showPulls || nth === 0) t.mark(n, TREESAME);
1099
1471
  return;
1100
1472
  }
1101
1473
  if (relevant(p)) relevantChange = true;
1102
1474
  else irrelevantChange = true;
1475
+ if (nth === 0) t.mark(n, PULL_MERGE);
1103
1476
  }
1104
1477
  if (relevantParents ? !relevantChange : !irrelevantChange) t.mark(n, TREESAME);
1105
1478
  };
@@ -1120,11 +1493,13 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1120
1493
  return;
1121
1494
  }
1122
1495
  await simplify(n);
1496
+ const passFlags = t.flag(n) & (SYMMETRIC_LEFT | ANCESTRY_PATH);
1123
1497
  for (let k = 0, c = t.parentCount(n); k < c; k++) {
1124
1498
  const p = t.parent(n, k);
1125
1499
  if (!(await parse(p))) {
1126
1500
  throw new GitApiError(`Failed to traverse parents of commit ${t.idOf(n)}`);
1127
1501
  }
1502
+ if (passFlags) t.mark(p, passFlags);
1128
1503
  if (sources && !sources.has(p)) {
1129
1504
  const source = sources.get(n);
1130
1505
  if (source !== undefined) sources.set(p, source);
@@ -1137,22 +1512,25 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1137
1512
  }
1138
1513
  };
1139
1514
  /** git's get_commit_action (no parent rewriting: TREESAME commits are never shown) */
1140
- const shown = async (n: number, rewrite = false): Promise<LogResult | undefined> => {
1515
+ const shown = async (n: number, ancestry = false): Promise<LogResult | undefined> => {
1141
1516
  const bytes = raw.get(n);
1142
1517
  if (bytes) raw.delete(n);
1143
- if (t.flag(n) & UNINTERESTING) return undefined;
1144
- if (t.flag(n) & TREESAME) {
1518
+ // commit_early_ignore
1519
+ if (t.flag(n) & (UNINTERESTING | SHOWN)) return undefined;
1520
+ if (dense && t.flag(n) & TREESAME) {
1145
1521
  // with parents rewritten, a merge of two relevant lines ties the topology together
1146
- if (!rewrite) return undefined;
1147
- let relevantParents = 0;
1148
- for (let k = 0, c = t.parentCount(n); k < c; k++)
1149
- if (relevant(t.parent(n, k))) relevantParents++;
1150
- if (relevantParents < 2) return undefined;
1522
+ if (!ancestry) return undefined;
1523
+ if (!(showPulls && t.flag(n) & PULL_MERGE)) {
1524
+ let relevantParents = 0;
1525
+ for (let k = 0, c = t.parentCount(n); k < c; k++)
1526
+ if (relevant(t.parent(n, k))) relevantParents++;
1527
+ if (relevantParents < 2) return undefined;
1528
+ }
1151
1529
  }
1152
1530
  if (this.untilTime !== undefined && t.date(n) > this.untilTime) return undefined;
1153
1531
  const parents = t.parentCount(n);
1154
1532
  if (this.revFilter === RevFilter.ONLY_MERGES && parents < 2) return undefined;
1155
- if (this.revFilter === RevFilter.NO_MERGES && parents > 1) return undefined;
1533
+ if ((this.revFilter === RevFilter.NO_MERGES || this.cherry) && parents > 1) return undefined;
1156
1534
  const id = t.idOf(n);
1157
1535
  const commit = bytes ? decodeCommit(bytes) : await this.walkCommits.load(id);
1158
1536
  if (!commit) return undefined;
@@ -1174,17 +1552,51 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1174
1552
  if (!(await filter.include(view))) return undefined;
1175
1553
  }
1176
1554
  const source = sources?.get(n);
1177
- return source !== undefined ? { ...commit, id, source } : { ...commit, id };
1555
+ return {
1556
+ ...commit,
1557
+ id,
1558
+ ...(source !== undefined ? { source } : {}),
1559
+ ...sideOf(n),
1560
+ };
1561
+ };
1562
+ /** The side marks of a commit (SYMMETRIC_LEFT, PATCHSAME) */
1563
+ const sideOf = (n: number): { left?: true; patchSame?: true } => {
1564
+ const f = t.flag(n);
1565
+ return {
1566
+ ...(f & SYMMETRIC_LEFT ? { left: true } : {}),
1567
+ ...(f & PATCHSAME ? { patchSame: true } : {}),
1568
+ };
1178
1569
  };
1179
1570
 
1571
+ // --ancestry-path=<commit>: the commits (git marks the object named: a tag's commit is
1572
+ // not marked, only listed among the bottoms)
1573
+ const ancestryBottoms: number[] = [];
1574
+ for (const id of this.ancestryPathCommits) {
1575
+ const commit = await this.peelToCommit(id);
1576
+ const n = t.lookup(commit);
1577
+ if (commit === id) t.mark(n, ANCESTRY_PATH);
1578
+ ancestryBottoms.unshift(n);
1579
+ }
1580
+ for (const id of this.ancestryPathPeeled) t.mark(t.lookup(id), ANCESTRY_PATH);
1180
1581
  // prepare_revision_walk: the flags of every argument first, then handle_commit in order
1181
1582
  for (const e of pending) {
1583
+ if (e.left) t.mark(t.lookup(e.id), SYMMETRIC_LEFT);
1182
1584
  if (!e.exclude) continue;
1183
1585
  const n = t.lookup(e.id);
1184
1586
  t.mark(n, UNINTERESTING | BOTTOM);
1185
1587
  }
1186
1588
  const list: number[] = [];
1187
- let limited = false;
1589
+ // --cherry-pick and --cherry-mark need limit_list, and so do --left-only and
1590
+ // --right-only from git 2.44 on (2.43 applies them only to a walk limited otherwise)
1591
+ // --ancestry-path and --simplify-merges limit the walk too (--parents does not: a
1592
+ // streaming walk rewrites parents as it goes)
1593
+ let limited =
1594
+ !!this.lineLog ||
1595
+ this.cherryPick ||
1596
+ this.cherryMark ||
1597
+ (this.compatibility !== "2.43" && (this.leftOnly || this.rightOnly)) ||
1598
+ ancestryPath ||
1599
+ simplifyMerges;
1188
1600
  /** git's update_treesame: TREESAME again from the per-parent marks, relevance as it is now */
1189
1601
  const updateTreesame = (n: number): void => {
1190
1602
  const count = t.parentCount(n);
@@ -1202,6 +1614,277 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1202
1614
  if (relevantParents ? relevantChange : irrelevantChange) t.unmark(n, TREESAME);
1203
1615
  else t.mark(n, TREESAME);
1204
1616
  };
1617
+ /**
1618
+ * revision.c's limit_to_ancestry: of `list`, the commits neither descending from a bottom
1619
+ * (TMP_MARK) nor marked ANCESTRY_PATH (ancestors of a commit given) become UNINTERESTING.
1620
+ */
1621
+ const limitToAncestry = (bottoms: number[], list: number[]): void => {
1622
+ const marked = new Set(bottoms);
1623
+ const rlist = [...list].reverse();
1624
+ let progress: boolean;
1625
+ do {
1626
+ progress = false;
1627
+ for (const c of rlist) {
1628
+ if (marked.has(c) || t.flag(c) & UNINTERESTING) continue;
1629
+ for (let k = 0, n = t.parentCount(c); k < n; k++) {
1630
+ if (!marked.has(t.parent(c, k))) continue;
1631
+ marked.add(c);
1632
+ progress = true;
1633
+ break;
1634
+ }
1635
+ }
1636
+ } while (progress);
1637
+ for (const c of list) {
1638
+ if (marked.has(c) || t.flag(c) & ANCESTRY_PATH) continue;
1639
+ t.mark(c, UNINTERESTING);
1640
+ }
1641
+ for (const c of list) t.unmark(c, ANCESTRY_PATH);
1642
+ for (const c of bottoms) t.unmark(c, ANCESTRY_PATH);
1643
+ };
1644
+ /**
1645
+ * revision.c's compact_treesame: parent `nth` was just removed from n's parents (git's
1646
+ * treesame decoration follows; a merge become a non-merge takes its TREESAME at once).
1647
+ */
1648
+ const compactTreesame = async (n: number, nth: number): Promise<void> => {
1649
+ if (t.parentCount(n) === 0) {
1650
+ if (await differs(undefined, n, nth)) t.unmark(n, TREESAME);
1651
+ else t.mark(n, TREESAME);
1652
+ return;
1653
+ }
1654
+ const st = treesame.get(n);
1655
+ if (!st || nth >= st.length) throw new GitApiError(`compact_treesame ${nth}`);
1656
+ const next = new Uint8Array(st.length - 1);
1657
+ next.set(st.subarray(0, nth));
1658
+ next.set(st.subarray(nth + 1), nth);
1659
+ if (next.length === 1) {
1660
+ if (next[0] && dense) t.mark(n, TREESAME);
1661
+ else t.unmark(n, TREESAME);
1662
+ treesame.delete(n);
1663
+ } else treesame.set(n, next);
1664
+ };
1665
+ /** revision.c's remove_duplicate_parents: how many parents are left */
1666
+ const removeDuplicateParents = async (n: number): Promise<number> => {
1667
+ const tracked = treesame.has(n);
1668
+ const parents = t.parentList(n);
1669
+ const current = [...parents];
1670
+ let surviving = 0;
1671
+ for (const p of parents) {
1672
+ if (current.slice(0, surviving).includes(p)) {
1673
+ // the list shrinks before the treesame marks follow
1674
+ current.splice(surviving, 1);
1675
+ t.setParentList(n, current);
1676
+ if (tracked) await compactTreesame(n, surviving);
1677
+ continue;
1678
+ }
1679
+ surviving++;
1680
+ }
1681
+ return surviving;
1682
+ };
1683
+ /**
1684
+ * commit-reach.c's paint_down_to_common for remove_redundant (no generation cut): the
1685
+ * PARENT1 (from `one`) and PARENT2 (from `twos`) marks of the commits, through the
1686
+ * parents as the walk holds them (simplified ones included, as git's in-memory commits).
1687
+ */
1688
+ const paintDown = async (one: number, twos: number[]): Promise<Map<number, number>> => {
1689
+ const P1 = 1;
1690
+ const P2 = 2;
1691
+ const STALE = 4;
1692
+ const RESULT = 8;
1693
+ const marks = new Map<number, number>();
1694
+ const queue = new CommitQueue<number>();
1695
+ const markOf = (c: number) => marks.get(c) ?? 0;
1696
+ marks.set(one, P1);
1697
+ queue.put(one, t.date(one));
1698
+ for (const c of twos) {
1699
+ if (c === one) return marks;
1700
+ marks.set(c, markOf(c) | P2);
1701
+ queue.put(c, t.date(c));
1702
+ }
1703
+ const nonStale = () => queue.items().some((c) => !(markOf(c) & STALE));
1704
+ while (nonStale()) {
1705
+ const c = queue.get() as number;
1706
+ let flags = markOf(c) & (P1 | P2 | STALE);
1707
+ if (flags === (P1 | P2)) {
1708
+ marks.set(c, markOf(c) | RESULT);
1709
+ flags |= STALE;
1710
+ }
1711
+ for (let k = 0, n = t.parentCount(c); k < n; k++) {
1712
+ const p = t.parent(c, k);
1713
+ if ((markOf(p) & flags) === flags) continue;
1714
+ if (!(await parse(p))) {
1715
+ throw new GitApiError(`could not parse commit ${t.idOf(p)}`);
1716
+ }
1717
+ marks.set(p, markOf(p) | flags);
1718
+ queue.put(p, t.date(p));
1719
+ }
1720
+ }
1721
+ return marks;
1722
+ };
1723
+ /** commit-reach.c's reduce_heads: the commits no other one of `heads` reaches, in order */
1724
+ const reduceHeads = async (heads: number[]): Promise<number[]> => {
1725
+ const array = [...new Set(heads)];
1726
+ for (const c of array) await parse(c);
1727
+ const redundant = new Array<boolean>(array.length).fill(false);
1728
+ for (let i = 0; i < array.length; i++) {
1729
+ if (redundant[i]) continue;
1730
+ const others: number[] = [];
1731
+ const index: number[] = [];
1732
+ for (let j = 0; j < array.length; j++) {
1733
+ if (i === j || redundant[j]) continue;
1734
+ others.push(array[j] as number);
1735
+ index.push(j);
1736
+ }
1737
+ const marks = await paintDown(array[i] as number, others);
1738
+ if ((marks.get(array[i] as number) ?? 0) & 2) redundant[i] = true;
1739
+ for (let j = 0; j < others.length; j++) {
1740
+ if ((marks.get(others[j] as number) ?? 0) & 1) redundant[index[j] as number] = true;
1741
+ }
1742
+ }
1743
+ return array.filter((_, i) => !redundant[i]);
1744
+ };
1745
+ /** revision.c's simplify_merges over the sorted list: the commits that stay */
1746
+ const simplifyMergesOf = async (list: number[]): Promise<number[]> => {
1747
+ const simplified = new Map<number, number>();
1748
+ const simplifyOne = async (commit: number, tail: number[]): Promise<void> => {
1749
+ if (simplified.has(commit)) return;
1750
+ // an UNINTERESTING commit and a root simplify to themselves
1751
+ if (t.flag(commit) & UNINTERESTING || t.parentCount(commit) === 0) {
1752
+ simplified.set(commit, commit);
1753
+ return;
1754
+ }
1755
+ let pending = 0;
1756
+ for (let k = 0, c = t.parentCount(commit); k < c; k++) {
1757
+ const p = t.parent(commit, k);
1758
+ if (!simplified.has(p)) {
1759
+ tail.push(p);
1760
+ pending++;
1761
+ }
1762
+ if (firstParentOnly) break;
1763
+ }
1764
+ if (pending) {
1765
+ tail.push(commit);
1766
+ return;
1767
+ }
1768
+ // each parent rewritten to what it simplifies to
1769
+ for (let k = 0, c = t.parentCount(commit); k < c; k++) {
1770
+ t.setParent(commit, k, simplified.get(t.parent(commit, k)) as number);
1771
+ if (firstParentOnly) break;
1772
+ }
1773
+ let cnt = firstParentOnly ? 1 : await removeDuplicateParents(commit);
1774
+ if (cnt > 1) {
1775
+ // mark_redundant_parents and mark_treesame_root_parents (git's TMP_MARK)
1776
+ const parents = t.parentList(commit);
1777
+ const reduced = await reduceHeads(parents);
1778
+ const marked = new Set<number>();
1779
+ let count = 0;
1780
+ for (const p of parents) {
1781
+ if (!reduced.includes(p)) {
1782
+ marked.add(p);
1783
+ count++;
1784
+ }
1785
+ }
1786
+ for (const p of parents) {
1787
+ if (t.parentCount(p) === 0 && t.flag(p) & TREESAME) {
1788
+ marked.add(p);
1789
+ count++;
1790
+ }
1791
+ }
1792
+ if (count) {
1793
+ // leave_one_treesame_to_parent
1794
+ const ts = treesame.get(commit);
1795
+ let unmarked: number | undefined;
1796
+ let markedOne: number | undefined;
1797
+ for (let k = 0; k < parents.length; k++) {
1798
+ if (!ts?.[k]) continue;
1799
+ const p = parents[k] as number;
1800
+ if (marked.has(p)) markedOne ??= p;
1801
+ else {
1802
+ unmarked = p;
1803
+ break;
1804
+ }
1805
+ }
1806
+ if (unmarked === undefined && markedOne !== undefined) {
1807
+ marked.delete(markedOne);
1808
+ count--;
1809
+ }
1810
+ }
1811
+ if (count) {
1812
+ // remove_marked_parents
1813
+ const current = [...parents];
1814
+ let nth = 0;
1815
+ let removed = 0;
1816
+ for (const p of parents) {
1817
+ if (marked.has(p)) {
1818
+ current.splice(nth, 1);
1819
+ t.setParentList(commit, current);
1820
+ removed++;
1821
+ await compactTreesame(commit, nth);
1822
+ continue;
1823
+ }
1824
+ nth++;
1825
+ }
1826
+ // removing parents can only make the commit TREESAME
1827
+ if (removed && !(t.flag(commit) & TREESAME)) updateTreesame(commit);
1828
+ cnt = nth;
1829
+ }
1830
+ }
1831
+ const parent =
1832
+ !cnt || t.flag(commit) & UNINTERESTING || !(t.flag(commit) & TREESAME)
1833
+ ? undefined
1834
+ : oneRelevantParent(t, commit, firstParentOnly, relevant);
1835
+ if (parent === undefined || (showPulls && t.flag(commit) & PULL_MERGE)) {
1836
+ simplified.set(commit, commit);
1837
+ } else simplified.set(commit, simplified.get(parent) as number);
1838
+ };
1839
+ let yetToDo = [...list].reverse();
1840
+ while (yetToDo.length > 0) {
1841
+ const todo = yetToDo;
1842
+ yetToDo = [];
1843
+ for (const commit of todo) await simplifyOne(commit, yetToDo);
1844
+ }
1845
+ return list.filter((c) => simplified.get(c) === c);
1846
+ };
1847
+ /**
1848
+ * revision.c's rewrite_parents with rewrite_one in a streaming walk: each commit passed on
1849
+ * the way down is processed first (process_parents, its parents queued through a queue
1850
+ * of its own merged into the walk's), as git rewrites while it streams.
1851
+ */
1852
+ const rewriteStreaming = async (n: number, walkQueue: CommitQueue<number>) => {
1853
+ const out: number[] = [];
1854
+ for (let k = 0, c = t.parentCount(n); k < c; k++) {
1855
+ let p: number | undefined = t.parent(n, k);
1856
+ const own = new CommitQueue<number>();
1857
+ for (;;) {
1858
+ await processParents(p, own);
1859
+ if (t.flag(p) & UNINTERESTING || !(t.flag(p) & TREESAME)) break;
1860
+ if (t.parentCount(p) === 0) {
1861
+ p = undefined;
1862
+ break;
1863
+ }
1864
+ const next = oneRelevantParent(t, p, firstParentOnly, relevant);
1865
+ if (next === undefined) break;
1866
+ p = next;
1867
+ }
1868
+ for (let q = own.get(); q !== undefined; q = own.get()) walkQueue.put(q, t.date(q));
1869
+ if (p !== undefined && !out.includes(p)) out.push(p);
1870
+ }
1871
+ return out;
1872
+ };
1873
+ // `a...b`: git's get_merge_bases parsed every commit it painted while reading the
1874
+ // arguments, so mark_parents_uninteresting from the merge bases reaches through them
1875
+ for (let i = 0; i + 1 < pending.length; i++) {
1876
+ const a = pending[i] as PendingCommit;
1877
+ const b = pending[i + 1] as PendingCommit;
1878
+ if (!a.left || b.left || a.exclude !== b.exclude) continue;
1879
+ const na = t.lookup(a.id);
1880
+ const nb = t.lookup(b.id);
1881
+ if (!(await parse(na)) || !(await parse(nb))) continue;
1882
+ const marks = await paintDown(na, [nb]);
1883
+ const bases: number[] = [];
1884
+ for (const [c, m] of marks) if (m & 8 && !(m & 4)) bases.push(c);
1885
+ // get_merge_bases_many_0's remove_redundant over several candidates parses more
1886
+ if (bases.length > 1) await reduceHeads(bases);
1887
+ }
1205
1888
  for (const e of pending) {
1206
1889
  const n = t.lookup(e.id);
1207
1890
  if (!(await parse(n))) continue;
@@ -1217,16 +1900,27 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1217
1900
  }
1218
1901
  // commit_list_sort_by_date (stable), then into the date queue in that order
1219
1902
  list.sort((a, b) => t.date(b) - t.date(a));
1903
+ // limit_list's collect_bottom_commits
1904
+ if (this.ancestryPathImplicit) {
1905
+ for (const n of list) if (t.flag(n) & BOTTOM) ancestryBottoms.unshift(n);
1906
+ if (ancestryBottoms.length === 0) {
1907
+ throw new GitApiError("--ancestry-path given but there are no bottom commits");
1908
+ }
1909
+ }
1220
1910
  const queue = new CommitQueue<number>();
1221
1911
  for (const n of list) queue.put(n, t.date(n));
1222
1912
 
1223
1913
  const none = this.maxCount !== undefined && this.maxCount <= 0;
1224
1914
  const output = this.outputWalk;
1225
- const order = this.order;
1915
+ // --simplify-merges sorts topologically (in graph order unless another order is set)
1916
+ const order = this.order ?? (simplifyMerges ? "topo" : undefined);
1226
1917
  // the output's walk and a sorted one are limited (git without generation numbers limits
1227
- // a topo walk)
1918
+ // a topo walk); per-parent TREESAME is kept where limiting or simplify_merges needs it
1228
1919
  trackTreesame =
1229
- (limited || !!output || !!order) && prune && !simplifyHistory && !firstParentOnly;
1920
+ prune &&
1921
+ !simplifyHistory &&
1922
+ !firstParentOnly &&
1923
+ (simplifyMerges || ((limited || !!output || !!order) && dense));
1230
1924
  /** git's sort_in_topological_order of `list` (parents as simplified, unparsed: none) */
1231
1925
  const sortTopo = async (list: number[], sort: LogOrder | undefined): Promise<number[]> => {
1232
1926
  if (list.length === 0) return list;
@@ -1275,7 +1969,10 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1275
1969
 
1276
1970
  /** get_revision_1's commits, in the order they come out */
1277
1971
  let candidates: AsyncIterable<number> | Iterable<number>;
1972
+ /** The streaming walk's queue, which rewriting parents walks on (rewrite_one_1) */
1973
+ let streamQueue: CommitQueue<number> | undefined;
1278
1974
  if (!limited && !output && !order) {
1975
+ streamQueue = queue;
1279
1976
  // get_revision_1, streaming
1280
1977
  const since = this.sinceTime;
1281
1978
  candidates = (async function* () {
@@ -1325,23 +2022,81 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1325
2022
  if (slop) continue;
1326
2023
  break;
1327
2024
  }
1328
- if (this.untilTime !== undefined && t.date(n) > this.untilTime) continue;
2025
+ // -L: every commit is followed, --until hides it when shown (get_commit_action)
2026
+ if (this.untilTime !== undefined && t.date(n) > this.untilTime && !this.lineLog) continue;
1329
2027
  date = t.date(n);
1330
2028
  newlist.push(n);
1331
2029
  }
2030
+ if (this.cherryPick || this.cherryMark) {
2031
+ await this.cherryPickList(newlist, t, parse, pathspec ? this.pathspecItems() : undefined);
2032
+ }
2033
+ // limit_left_right
2034
+ if (this.leftOnly || this.rightOnly) {
2035
+ for (const n of newlist) {
2036
+ const left = !!(t.flag(n) & SYMMETRIC_LEFT);
2037
+ if (this.rightOnly ? left : !left) t.mark(n, SHOWN);
2038
+ }
2039
+ }
2040
+ if (ancestryPath) limitToAncestry(ancestryBottoms, newlist);
1332
2041
  // commits made TREESAME by parents that became UNINTERESTING
1333
- if (trackTreesame) {
2042
+ if (trackTreesame && dense) {
1334
2043
  for (const n of newlist) {
1335
2044
  if (!(t.flag(n) & (UNINTERESTING | TREESAME))) updateTreesame(n);
1336
2045
  }
1337
2046
  }
1338
2047
  raw.clear();
2048
+ if (this.lineLog) {
2049
+ // -L sorts topologically (revs->topo_order), children before parents
2050
+ const sorted = await sortTopo(newlist, order ?? "topo");
2051
+ const lineOutput = output ?? { topo: true, rewrite: false, entries: [] };
2052
+ if (wantAncestry) {
2053
+ // want_ancestry (`--graph`, `--parents`, `--simplify-merges`,
2054
+ // `--simplify-by-decoration`): line_log_filter with its own parent rewriting, then
2055
+ // simplify_merges (which does nothing without prune: `-L` alone has none,
2056
+ // `--simplify-by-decoration` prunes), then get_commit_action and rewrite_parents
2057
+ const filtered = await this.lineLogFilter(t, sorted);
2058
+ const kept =
2059
+ simplifyMerges && prune ? await simplifyMergesOf(filtered.kept) : filtered.kept;
2060
+ await this.finishOutputWalk(lineOutput, t, kept, shown, relevant, parse, {
2061
+ ancestry: wantAncestry,
2062
+ rewrite,
2063
+ });
2064
+ for (const p of filtered.unwalked) {
2065
+ if (t.flag(p) & SEEN || !(await parse(p)) || !(await shown(p))) continue;
2066
+ lineOutput.unwalkedShown ??= new Set();
2067
+ lineOutput.unwalkedShown.add(t.idOf(p));
2068
+ }
2069
+ } else await this.finishLineLogWalk(lineOutput, t, sorted, shown);
2070
+ if (!output) {
2071
+ let count = 0;
2072
+ let toSkip = this.skip;
2073
+ for (const e of lineOutput.entries) {
2074
+ if (toSkip > 0) {
2075
+ toSkip--;
2076
+ continue;
2077
+ }
2078
+ yield { ...e.commit, id: e.id, parents: e.parents };
2079
+ if (this.maxCount !== undefined && ++count >= this.maxCount) break;
2080
+ }
2081
+ }
2082
+ return;
2083
+ }
2084
+ let sorted = output
2085
+ ? output.topo
2086
+ ? await sortTopo(newlist, order ?? "topo")
2087
+ : newlist
2088
+ : order
2089
+ ? await sortTopo(newlist, order)
2090
+ : newlist;
2091
+ if (simplifyMerges && prune) sorted = await simplifyMergesOf(sorted);
1339
2092
  if (output) {
1340
- const sorted = output.topo ? await sortTopo(newlist, order ?? "topo") : newlist;
1341
- await this.finishOutputWalk(output, t, sorted, shown, relevant, parse);
2093
+ await this.finishOutputWalk(output, t, sorted, shown, relevant, parse, {
2094
+ ancestry: wantAncestry,
2095
+ rewrite,
2096
+ });
1342
2097
  return;
1343
2098
  }
1344
- candidates = order ? await sortTopo(newlist, order) : newlist;
2099
+ candidates = sorted;
1345
2100
  }
1346
2101
 
1347
2102
  // get_revision_internal: --skip, -n, then (--boundary) the parents of the commits
@@ -1357,8 +2112,21 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1357
2112
  // git's -n 0 reads nothing more in a streaming walk; a limited walk is done before
1358
2113
  if (!none) {
1359
2114
  for await (const n of candidates) {
1360
- const commit = await shown(n);
2115
+ const commit = await shown(n, wantAncestry);
1361
2116
  if (!commit) continue;
2117
+ if (wantAncestry && t.parsed(n)) {
2118
+ // the parents shown: as the walk holds them (simplified), rewritten past the
2119
+ // commits not shown (simplify_commit's rewrite_parents changes commit->parents)
2120
+ const held = t.parentList(n);
2121
+ if (rewrite) {
2122
+ commit.savedParents = held.map((p) => t.idOf(p));
2123
+ const rewritten = streamQueue
2124
+ ? await rewriteStreaming(n, streamQueue)
2125
+ : rewriteParents(t, n, firstParentOnly, relevant);
2126
+ t.setParentList(n, rewritten);
2127
+ commit.parents = rewritten.map((p) => t.idOf(p));
2128
+ } else commit.parents = held.map((p) => t.idOf(p));
2129
+ }
1362
2130
  if (skipped < this.skip) {
1363
2131
  skipped++;
1364
2132
  continue;
@@ -1367,12 +2135,16 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1367
2135
  if (collectBoundary) {
1368
2136
  for (let k = 0, c = t.parentCount(n); k < c; k++) {
1369
2137
  const p = t.parent(n, k);
1370
- if (shownSet.has(p) || childShown.has(p)) continue;
2138
+ if (shownSet.has(p) || childShown.has(p) || t.flag(p) & SHOWN) continue;
1371
2139
  childShown.add(p);
1372
2140
  boundaryCommits.push(p);
1373
2141
  }
1374
2142
  }
1375
2143
  yield commit;
2144
+ // git log and rev-list free a shown commit's parents (cmd_log_walk, finish_commit):
2145
+ // a later rewrite passing through it finds none (not under --reverse, which reads
2146
+ // the whole walk first)
2147
+ if (rewrite && !this.reverse && !this.keepShownParents) t.setParentList(n, []);
1376
2148
  if (this.maxCount !== undefined && ++count >= this.maxCount) break;
1377
2149
  }
1378
2150
  }
@@ -1381,7 +2153,7 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1381
2153
  const boundaryList: number[] = [];
1382
2154
  const marked = new Set<number>();
1383
2155
  for (const n of boundaryCommits) {
1384
- if (shownSet.has(n) || marked.has(n)) continue;
2156
+ if (shownSet.has(n) || marked.has(n) || t.flag(n) & SHOWN) continue;
1385
2157
  marked.add(n);
1386
2158
  boundaryList.unshift(n);
1387
2159
  }
@@ -1391,7 +2163,13 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1391
2163
  if (!commit) continue;
1392
2164
  if (shallow.has(id)) commit.parents = [];
1393
2165
  const source = sources?.get(n);
1394
- yield { ...commit, id, boundary: true, ...(source !== undefined ? { source } : {}) };
2166
+ yield {
2167
+ ...commit,
2168
+ id,
2169
+ boundary: true,
2170
+ ...(source !== undefined ? { source } : {}),
2171
+ ...sideOf(n),
2172
+ };
1395
2173
  }
1396
2174
  }
1397
2175
 
@@ -1404,68 +2182,39 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1404
2182
  output: OutputWalk,
1405
2183
  t: RevTable,
1406
2184
  newlist: number[],
1407
- shown: (n: number, rewrite?: boolean) => Promise<LogResult | undefined>,
2185
+ shown: (n: number, ancestry?: boolean) => Promise<LogResult | undefined>,
1408
2186
  relevant: (n: number) => boolean,
1409
2187
  parse: (n: number) => Promise<boolean>,
2188
+ mode: { ancestry: boolean; rewrite: boolean },
1410
2189
  ): Promise<void> {
1411
2190
  const order = newlist;
1412
2191
  const firstParentOnly = this.firstParentOnly;
1413
- /** revision.c's one_relevant_parent */
1414
- const oneRelevantParent = (n: number): number | undefined => {
1415
- const c = t.parentCount(n);
1416
- if (c === 0) return undefined;
1417
- if (firstParentOnly || c === 1) return t.parent(n, 0);
1418
- let found: number | undefined;
1419
- for (let k = 0; k < c; k++) {
1420
- const p = t.parent(n, k);
1421
- if (!relevant(p)) continue;
1422
- if (found !== undefined) return undefined;
1423
- found = p;
1424
- }
1425
- return found;
1426
- };
1427
- /** revision.c's rewrite_one: the parent shown in place of `p`; undefined to drop it */
1428
- const rewriteOne = (start: number): number | undefined => {
1429
- let p = start;
1430
- for (;;) {
1431
- if (t.flag(p) & UNINTERESTING) return p;
1432
- if (!(t.flag(p) & TREESAME)) return p;
1433
- if (t.parentCount(p) === 0) return undefined;
1434
- const next = oneRelevantParent(p);
1435
- if (next === undefined) return p;
1436
- p = next;
1437
- }
1438
- };
1439
- const prune = this.paths.length > 0 || this.excludePaths.length > 0;
1440
2192
  /** Rewritten parents the walk never reached (only with `--first-parent`) */
1441
2193
  const unwalked = new Set<number>();
1442
2194
  for (const n of order) {
1443
- const commit = await shown(n, output.rewrite && prune);
2195
+ const commit = await shown(n, mode.ancestry);
1444
2196
  if (!commit) continue;
1445
- let parents = commit.parents;
2197
+ // the parents as the walk holds them (simplified), as git's commit->parents
2198
+ let parents = t.parsed(n) ? t.parentList(n).map((p) => t.idOf(p)) : commit.parents;
1446
2199
  let savedParents: ObjectId[] | undefined;
1447
- if (output.rewrite && prune) {
2200
+ if (mode.rewrite) {
1448
2201
  // the parents before rewriting, which `--full-diff` diffs against (save_parents)
1449
- savedParents = [];
1450
- for (let k = 0, c = t.parentCount(n); k < c; k++) savedParents.push(t.idOf(t.parent(n, k)));
1451
- const ids: ObjectId[] = [];
1452
- for (let k = 0, c = t.parentCount(n); k < c; k++) {
1453
- const p = rewriteOne(t.parent(n, k));
1454
- if (p === undefined) continue;
1455
- if (!(t.flag(p) & SEEN)) unwalked.add(p);
1456
- const id = t.idOf(p);
1457
- // remove_duplicate_parents
1458
- if (!ids.includes(id)) ids.push(id);
1459
- }
1460
- parents = ids;
2202
+ savedParents = parents;
2203
+ const rewritten = rewriteParents(t, n, firstParentOnly, relevant);
2204
+ for (const p of rewritten) if (!(t.flag(p) & SEEN)) unwalked.add(p);
2205
+ parents = rewritten.map((p) => t.idOf(p));
1461
2206
  }
1462
- const { id, source, boundary: _boundary, ...rest } = commit;
2207
+ const { id, source, boundary: _boundary, left, patchSame, ...rest } = commit;
2208
+ // the parents git frees once the commit is shown (cmd_log_walk; --skip's are not)
2209
+ if (mode.rewrite && output.entries.length >= this.skip) t.setParentList(n, []);
1463
2210
  output.entries.push({
1464
2211
  id,
1465
2212
  commit: rest,
1466
2213
  parents,
1467
2214
  ...(savedParents ? { savedParents } : {}),
1468
2215
  ...(source !== undefined ? { source } : {}),
2216
+ ...(left ? { left } : {}),
2217
+ ...(patchSame ? { patchSame } : {}),
1469
2218
  });
1470
2219
  }
1471
2220
  // graph.c's graph_is_interesting asks get_commit_action about a parent: one the walk
@@ -1479,6 +2228,268 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1479
2228
  }
1480
2229
  }
1481
2230
 
2231
+ /**
2232
+ * line-log.c's line_log_init: the one commit the log starts from (check_single_commit),
2233
+ * the `-L` ranges parsed against it, and the walk that follows them
2234
+ */
2235
+ private async startLineLog(pending: PendingCommit[]): Promise<void> {
2236
+ let found: PendingCommit | undefined;
2237
+ for (const e of pending) {
2238
+ if (e.exclude) continue;
2239
+ const name = e.name ?? e.id;
2240
+ if (!(await this.readCommitHeader(e.id).catch(() => undefined))) {
2241
+ throw lineLogDeath(`Non commit ${name}?`);
2242
+ }
2243
+ if (found) {
2244
+ throw lineLogDeath(
2245
+ `More than one commit to dig from: ${name} and ${found.name ?? found.id}?`,
2246
+ );
2247
+ }
2248
+ found = e;
2249
+ }
2250
+ if (!found) throw lineLogDeath("No commit specified?");
2251
+ const host = this.lineLogHost();
2252
+ const tree = await host.treeOf(found.id);
2253
+ const drivers = new DiffCommand(this._workingCopy)
2254
+ .setOldTree(tree)
2255
+ .setNewTree(tree)
2256
+ .shareReadsOf(this)
2257
+ .setOptions(this.lineLogDiffOptions());
2258
+ const ranges = await parseLineRanges(this.lineRangeArgs, {
2259
+ blob: async (path) => {
2260
+ const e = await this.treeEntryAt(tree, path);
2261
+ if (!e) return undefined;
2262
+ // a submodule reads as its commit line (diff_populate_filespec)
2263
+ if ((e.mode & 0o170000) === 0o160000) return { ...e, data: gitlinkText(e.id) };
2264
+ const data = await this.readBlob(e.id);
2265
+ if (!data) throw lineLogDeath(`Cannot read blob ${e.id}`);
2266
+ return { ...e, data };
2267
+ },
2268
+ findFunction: async (path) => (await drivers.driverOf(path))?.findFunction,
2269
+ });
2270
+ this.lineLog = new LineLogWalk(host, this.compatibility, this.firstParentOnly);
2271
+ this.lineLog.start(found.id, ranges);
2272
+ }
2273
+
2274
+ /** The diff options of `-L`'s diffs: the builtin drivers of the version followed */
2275
+ private lineLogDiffOptions(): DiffTextOptions {
2276
+ return {
2277
+ ...this.diffOptions,
2278
+ driverCompatibility: this.diffOptions.driverCompatibility ?? this.compatibility,
2279
+ };
2280
+ }
2281
+
2282
+ /** The entry at a path of a tree (its mode canonical), undefined when none */
2283
+ private async treeEntryAt(
2284
+ tree: ObjectId,
2285
+ path: string,
2286
+ ): Promise<{ id: ObjectId; mode: number } | undefined> {
2287
+ const parts = path.split("/");
2288
+ let cur = tree;
2289
+ for (let i = 0; i < parts.length; i++) {
2290
+ const e = await this.entryOf(cur, encodeGitPath(parts[i] as string));
2291
+ if (!e) return undefined;
2292
+ if (i === parts.length - 1) return { id: e.id, mode: canonTreeMode(e.mode) };
2293
+ if (!isTreeMode(e.mode)) return undefined;
2294
+ cur = e.id;
2295
+ }
2296
+ return undefined;
2297
+ }
2298
+
2299
+ /** What `-L`'s walk reads: trees, entries, blobs, and renames as queue_diffs finds them */
2300
+ private lineLogHost(): LineLogHost {
2301
+ const o = this.diffOptions;
2302
+ let detect =
2303
+ o.findRenames !== undefined
2304
+ ? o.findRenames !== false
2305
+ : (renamesValue(configValue(this.workingCopy, "diff.renames")) ?? true) !== false;
2306
+ if (o.findCopies !== undefined && o.findCopies !== false) detect = true;
2307
+ const score =
2308
+ typeof o.findRenames === "string"
2309
+ ? renameScoreOption(o.findRenames, "find-renames")
2310
+ : undefined;
2311
+ const limit = Number(configValue(this.workingCopy, "diff.renameLimit"));
2312
+ const renameLimit =
2313
+ Number.isFinite(limit) && configValue(this.workingCopy, "diff.renameLimit") !== undefined
2314
+ ? limit
2315
+ : DEFAULT_RENAME_LIMIT;
2316
+ const blob = async (id: ObjectId): Promise<Uint8Array> => {
2317
+ const data = await this.readBlob(id);
2318
+ if (!data) throw lineLogDeath(`Cannot read blob ${id}`);
2319
+ return data;
2320
+ };
2321
+ return {
2322
+ treeOf: async (id) => {
2323
+ const header = await this.readCommitHeader(id, await this.objectReplacements());
2324
+ if (!header) throw new GitApiError(`could not parse commit ${id}`);
2325
+ return header.tree;
2326
+ },
2327
+ entry: (tree, path) => this.treeEntryAt(tree, path),
2328
+ blob,
2329
+ ...(hasPickaxe(o) || o.diffFilter !== undefined
2330
+ ? {
2331
+ diffcore: async (pairs: LineLogPair[]) => {
2332
+ const entries = new Map<DiffEntry, LineLogPair>();
2333
+ for (const pair of pairs) entries.set(lineLogEntry(pair), pair);
2334
+ const kept = await new DiffCommand(this._workingCopy)
2335
+ .shareReadsOf(this)
2336
+ .setOptions(this.lineLogDiffOptions())
2337
+ .filterQueue([...entries.keys()]);
2338
+ const out: LineLogPair[] = [];
2339
+ for (const e of kept) {
2340
+ const pair = entries.get(e) ?? pairs.find((p) => p.two.path === e.newPath);
2341
+ if (pair) out.push(pair);
2342
+ }
2343
+ return out;
2344
+ },
2345
+ }
2346
+ : {}),
2347
+ ...(detect
2348
+ ? {
2349
+ renames: async (
2350
+ parentTree: ObjectId,
2351
+ tree: ObjectId,
2352
+ created: { path: string; id: ObjectId; mode: number }[],
2353
+ ) => {
2354
+ const before = await this.flatTree(parentTree);
2355
+ const after = await this.flatTree(tree);
2356
+ const sources = [...before]
2357
+ .filter(([path]) => !after.has(path))
2358
+ .map(([path, e]) => ({ path, mode: e.mode, id: e.id }));
2359
+ if (sources.length === 0) return [];
2360
+ const pairs = await detectRenames(
2361
+ sources,
2362
+ created.map((c) => ({ path: c.path, mode: c.mode, id: c.id })),
2363
+ {
2364
+ load: async (c) =>
2365
+ (c.mode & 0o170000) === 0o160000 ? gitlinkText(c.id) : blob(c.id),
2366
+ renameLimit,
2367
+ ...(score !== undefined ? { minimumScore: score } : {}),
2368
+ },
2369
+ );
2370
+ const out: {
2371
+ from: { path: string; id: ObjectId; mode: number };
2372
+ to: string;
2373
+ score: number;
2374
+ }[] = [];
2375
+ for (const pair of pairs) {
2376
+ const from = before.get(pair.from);
2377
+ if (!from) continue;
2378
+ out.push({
2379
+ from: { path: pair.from, id: from.id, mode: canonTreeMode(from.mode) },
2380
+ to: pair.to,
2381
+ score: scorePercent(pair.score),
2382
+ });
2383
+ }
2384
+ return out;
2385
+ },
2386
+ }
2387
+ : {}),
2388
+ };
2389
+ }
2390
+
2391
+ /**
2392
+ * The walk's commits under `-L` without parents rewritten, sorted topologically: each
2393
+ * followed in turn (git's simplify_commit), shown when its diff touched the ranges and the
2394
+ * other filters keep it, with the parents a merge kept (one when a parent took it all).
2395
+ */
2396
+ private async finishLineLogWalk(
2397
+ output: OutputWalk,
2398
+ t: RevTable,
2399
+ order: number[],
2400
+ shown: (n: number, ancestry?: boolean) => Promise<LogResult | undefined>,
2401
+ ): Promise<void> {
2402
+ const ll = this.lineLog as LineLogWalk;
2403
+ for (const n of order) {
2404
+ const id = t.idOf(n);
2405
+ if (!(await ll.process(id, lineLogParentIds(t, n)))) continue;
2406
+ const commit = await shown(n);
2407
+ if (!commit) continue;
2408
+ const { id: _id, source, boundary: _boundary, left, patchSame, ...rest } = commit;
2409
+ output.entries.push({
2410
+ id,
2411
+ commit: rest,
2412
+ parents: ll.parentsOf(id) ?? commit.parents,
2413
+ ...(source !== undefined ? { source } : {}),
2414
+ ...(left ? { left } : {}),
2415
+ ...(patchSame ? { patchSame } : {}),
2416
+ });
2417
+ }
2418
+ }
2419
+
2420
+ /**
2421
+ * line-log.c's line_log_filter: every commit of the sorted list followed, those whose diff
2422
+ * touched no range marked TREESAME (a merge one parent took whole left with that parent),
2423
+ * the others kept with their parents rewritten past TREESAME commits
2424
+ * (line_log_rewrite_one); `unwalked` the parents rewritten to that the walk never reached
2425
+ */
2426
+ private async lineLogFilter(
2427
+ t: RevTable,
2428
+ order: number[],
2429
+ ): Promise<{ kept: number[]; unwalked: Set<number> }> {
2430
+ const ll = this.lineLog as LineLogWalk;
2431
+ const kept: number[] = [];
2432
+ for (const n of order) {
2433
+ const id = t.idOf(n);
2434
+ if (await ll.process(id, lineLogParentIds(t, n))) kept.push(n);
2435
+ else t.mark(n, TREESAME);
2436
+ const narrowed = ll.parentsOf(id);
2437
+ if (narrowed)
2438
+ t.setParentList(
2439
+ n,
2440
+ narrowed.map((p) => t.lookup(p)),
2441
+ );
2442
+ }
2443
+ /** line_log_rewrite_one */
2444
+ const rewriteOne = (start: number): number | undefined => {
2445
+ let p = start;
2446
+ for (;;) {
2447
+ const parents = t.parsed(p) ? t.parentList(p) : [];
2448
+ if (parents.length > 1 || t.flag(p) & UNINTERESTING || !(t.flag(p) & TREESAME)) return p;
2449
+ if (parents.length === 0) return undefined;
2450
+ p = parents[0] as number;
2451
+ }
2452
+ };
2453
+ const unwalked = new Set<number>();
2454
+ for (const n of kept) {
2455
+ const rewritten: number[] = [];
2456
+ for (const q of t.parentList(n)) {
2457
+ const p = rewriteOne(q);
2458
+ if (p === undefined) continue;
2459
+ if (!(t.flag(p) & SEEN)) unwalked.add(p);
2460
+ if (!rewritten.includes(p)) rewritten.push(p);
2461
+ }
2462
+ t.setParentList(n, rewritten);
2463
+ }
2464
+ return { kept, unwalked };
2465
+ }
2466
+
2467
+ /**
2468
+ * setup_revisions' and cmd_log_init_finish's refusals of `-L`: the diff formats it cannot
2469
+ * show (2.43: anything but `-p` and `-s`), then a pathspec
2470
+ */
2471
+ private checkLineLogOptions(options: LogOutputOptions): void {
2472
+ const o = options;
2473
+ if (this.compatibility === "2.43") {
2474
+ if (
2475
+ o.stat ||
2476
+ o.shortstat ||
2477
+ o.numstat ||
2478
+ o.nameOnly ||
2479
+ o.nameStatus ||
2480
+ o.summary ||
2481
+ o.check
2482
+ ) {
2483
+ throw lineLogDeath("-L does not yet support diff formats besides -p and -s");
2484
+ }
2485
+ } else if (o.stat || o.shortstat || o.numstat || o.check || o.fullDiff) {
2486
+ throw lineLogDeath("-L does not yet support the requested diff format");
2487
+ }
2488
+ if (this.paths.length > 0 || this.excludePaths.length > 0) {
2489
+ throw lineLogDeath("-L<range>:<file> cannot be used with pathspec");
2490
+ }
2491
+ }
2492
+
1482
2493
  /**
1483
2494
  * The log printed as `git log <options>` prints it to a pipe (no pager; colors only when
1484
2495
  * `setDiffOptions({ color })` or `color.ui`/`color.diff` say `always`): the
@@ -1499,13 +2510,18 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1499
2510
  /** {@link callText} as bytes (messages and file contents that are not UTF-8 kept as they are). */
1500
2511
  async callBytes(options: LogOutputOptions = {}): Promise<Uint8Array> {
1501
2512
  // one operation for the worktree: its attributes files (diff drivers) and configuration
1502
- // are read once for every commit's diff, as git keeps its attribute stack
1503
- const worktree = this.worktreeAccess;
1504
- if (worktree?.batch) return worktree.batch(() => this.printLog(options));
1505
- return this.printLog(options);
2513
+ // are read once for every commit's diff, as git keeps its attribute stack (a bare
2514
+ // repository's working copy has none)
2515
+ return this.inOneOperation(() => this.printLog(options));
1506
2516
  }
1507
2517
 
1508
2518
  private async printLog(options: LogOutputOptions): Promise<Uint8Array> {
2519
+ const result = await this.printLogOutput(options);
2520
+ if (this.logConfig) await this.reportMailmapErrors(options, result.length > 0);
2521
+ return result;
2522
+ }
2523
+
2524
+ private async printLogOutput(options: LogOutputOptions): Promise<Uint8Array> {
1509
2525
  const reverse = !!options.reverse || this.reverse;
1510
2526
  await this.checkReflogWalkOptions(options);
1511
2527
  // revision.c's setup_revisions: the graph cannot be reversed
@@ -1524,6 +2540,8 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1524
2540
  const colors = this.readColors();
1525
2541
  const host = this.outputHost(options);
1526
2542
  const paths = [...this.paths];
2543
+ // -L: the walk is sorted, its commits followed before the first is shown
2544
+ const lineLog = this.lineRangeArgs.length > 0;
1527
2545
  // the pathspec as git holds it: the excluded paths as `:(exclude)` elements, `.` when
1528
2546
  // every element excludes
1529
2547
  const pathspec = [...paths, ...this.excludePaths.map((p) => `:(exclude)${p}`)];
@@ -1535,13 +2553,16 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1535
2553
  interesting: (id) => shownIds.has(id) || unwalkedShown.has(id),
1536
2554
  firstParentOnly: this.firstParentOnly,
1537
2555
  paths: pathspec,
2556
+ ...this.revisionMarks(),
1538
2557
  ...(colors ? { colors } : {}),
2558
+ ...(lineLog ? { lineLog: this.compatibility } : {}),
1539
2559
  },
1540
2560
  );
2561
+ if (lineLog) this.checkLineLogOptions(options);
1541
2562
  const follow = printer.followsPath;
1542
2563
  const countsShown = !printer.alwaysShowHeader;
1543
2564
  const graph = !!options.graph;
1544
- const topo = graph;
2565
+ const topo = graph || lineLog;
1545
2566
  const boundary = !!options.boundary || this.boundary;
1546
2567
  if (graph && boundary) {
1547
2568
  // graph.c draws boundary commits as `o` in columns of their own: not reproduced
@@ -1560,12 +2581,28 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1560
2581
  const skip = this.skip;
1561
2582
  const simplifyHistory = this.simplifyHistory;
1562
2583
  if (printer.fullHistory) this.simplifyHistory = false;
2584
+ // --parents: rewritten parents (the header's ids, %P)
2585
+ if (options.parents) this.rewriteParents = true;
2586
+ // --simplify-by-decoration keeps the commits git log's decoration filter decorates
2587
+ this.decorationLoader = () =>
2588
+ host.decorations({
2589
+ decorate: "short",
2590
+ ...(options.decorateRefs ? { decorateRefs: options.decorateRefs } : {}),
2591
+ ...(options.decorateRefsExclude
2592
+ ? { decorateRefsExclude: options.decorateRefsExclude }
2593
+ : {}),
2594
+ ...(options.clearDecorations ? { clearDecorations: true } : {}),
2595
+ });
2596
+ this.keepShownParents = reverse;
1563
2597
  // --follow walks every commit: its path changes as it goes
1564
2598
  if (follow) this.paths = [];
1565
2599
  const shownIds = new Set<ObjectId>();
1566
2600
  const unwalkedShown = new Set<ObjectId>();
1567
2601
  let entries: LogOutputEntry[];
1568
- if (this.reflogWalkNames !== undefined) {
2602
+ if (this.noWalkCommits !== undefined) {
2603
+ entries = await this.noWalkEntries(this.noWalkCommits);
2604
+ for (const e of entries) shownIds.add(e.id);
2605
+ } else if (this.reflogWalkNames !== undefined) {
1569
2606
  entries = await this.reflogEntries(this.reflogWalkNames);
1570
2607
  for (const e of entries) shownIds.add(e.id);
1571
2608
  } else if (topo) {
@@ -1591,14 +2628,7 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1591
2628
  if (maxCount === undefined || maxCount > 0) {
1592
2629
  let shownCount = 0;
1593
2630
  for await (const c of await this.call()) {
1594
- const { id, boundary: isBoundary, source, ...commit } = c;
1595
- const entry: LogOutputEntry = {
1596
- id,
1597
- commit,
1598
- parents: c.parents,
1599
- ...(isBoundary ? { boundary: true } : {}),
1600
- ...(source !== undefined ? { source } : {}),
1601
- };
2631
+ const entry = outputEntry(c);
1602
2632
  const shown = await printer.showCommit(entry, []);
1603
2633
  if (shown && countsShown && maxCount !== undefined && ++shownCount >= maxCount) break;
1604
2634
  }
@@ -1617,14 +2647,7 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1617
2647
  // --reverse: the newest commits walked, reversed, then shown
1618
2648
  entries = [];
1619
2649
  for await (const c of await this.call()) {
1620
- const { id, boundary: isBoundary, source, ...commit } = c;
1621
- entries.push({
1622
- id,
1623
- commit,
1624
- parents: c.parents,
1625
- ...(isBoundary ? { boundary: true } : {}),
1626
- ...(source !== undefined ? { source } : {}),
1627
- });
2650
+ entries.push(outputEntry(c));
1628
2651
  }
1629
2652
  }
1630
2653
  this.simplifyHistory = simplifyHistory;
@@ -1655,6 +2678,55 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1655
2678
  return printer.result();
1656
2679
  }
1657
2680
 
2681
+ /**
2682
+ * The refs' decorations (log-tree.c's load_ref_decorations): with `logOptions`, git log's
2683
+ * decoration filter; without, every ref and HEAD (get_name_decoration's own load).
2684
+ */
2685
+ private async refDecorations(
2686
+ logOptions?: LoadRefDecorationsOptions["logOptions"],
2687
+ ): Promise<RefDecorations> {
2688
+ const replacements = await this.objectReplacements();
2689
+ const shallow = (await this.refsStore.getShallow?.().catch(() => undefined)) ?? [];
2690
+ const environment = hostEnvironmentOf(this._workingCopy);
2691
+ const objects = this._workingCopy.history?.objects;
2692
+ const tags = this.tagsStore;
2693
+ return loadRefDecorations({
2694
+ refs: this.refsStore,
2695
+ ...(tags ? { tags } : {}),
2696
+ ...(environment?.replaceRefBase !== undefined
2697
+ ? { replaceRefBase: environment.replaceRefBase }
2698
+ : {}),
2699
+ useReplaceRefs: this.useReplaceRefs(),
2700
+ grafted: new Set([...(replacements?.grafts.keys() ?? []), ...shallow]),
2701
+ ...(objects ? { hasObject: (id: ObjectId) => objects.has(id) } : {}),
2702
+ ...(logOptions ? { logOptions } : {}),
2703
+ });
2704
+ }
2705
+
2706
+ /** The mailmap, read once for the walk's filters and the output alike. */
2707
+ private loadedMailmap(): Promise<Mailmap> {
2708
+ this.mailmapLoad ??= this.readMailmap((line) => this.mailmapErrors.push(line));
2709
+ return this.mailmapLoad;
2710
+ }
2711
+
2712
+ /**
2713
+ * git's `error:` lines of reading the mailmap (a `mailmap.blob` that is no blob), as git
2714
+ * log prints them: once when it reads the mailmap for the log (`log.mailmap`,
2715
+ * `--use-mailmap`), once more when a user format maps an identity (`%aN`, pretty.c's own
2716
+ * read) of a commit it shows.
2717
+ */
2718
+ private async reportMailmapErrors(options: LogOutputOptions, shown: boolean): Promise<void> {
2719
+ const forLog =
2720
+ options.mailmap ?? this.useMailmap ?? configBool(this.workingCopy, "log.mailmap", true);
2721
+ const pretty = options.pretty ?? configValue(this.workingCopy, "format.pretty") ?? "";
2722
+ const user = /^t?format:/.test(pretty) || (pretty.includes("%") && !options.oneline);
2723
+ const forFormat = shown && user && /%[ac][NEL]/.test(pretty);
2724
+ const times = (forLog ? 1 : 0) + (forFormat ? 1 : 0);
2725
+ if (times === 0) return;
2726
+ await this.loadedMailmap();
2727
+ for (let k = 0; k < times; k++) this.outputWarnings.push(...this.mailmapErrors);
2728
+ }
2729
+
1658
2730
  /**
1659
2731
  * `git show`'s output of objects one at a time (builtin/log.c's cmd_show without a walk):
1660
2732
  * one printer for every object, so commits, tags and trees share git's `shown_one`
@@ -1701,7 +2773,7 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1701
2773
  if (!loaded) throw new GitApiError(`fatal: bad object ${id}`);
1702
2774
  // try_to_simplify_commit, then get_commit_action: a commit TREESAME to a parent (a
1703
2775
  // root without the paths) is ignored
1704
- if (limited && (await this.treesameForShow(id, loaded))) return false;
2776
+ if (limited && (await this.treesameForShow(id, loaded, printer.fullHistory))) return false;
1705
2777
  const filter = this.activeFilter;
1706
2778
  if (filter) {
1707
2779
  const view: FilteredCommit = {
@@ -1733,9 +2805,15 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1733
2805
  };
1734
2806
  }
1735
2807
 
1736
- /** revision.c's try_to_simplify_commit for a commit git shows without walking */
1737
- private async treesameForShow(id: ObjectId, commit: Commit): Promise<boolean> {
2808
+ /**
2809
+ * revision.c's try_to_simplify_commit for a commit git shows without walking; without
2810
+ * `simplify_history` (`--full-history`, `-m`, `--remerge-diff`) a merge is TREESAME only
2811
+ * to every parent it looks at (update_treesame)
2812
+ */
2813
+ private async treesameForShow(id: ObjectId, commit: Commit, full = false): Promise<boolean> {
1738
2814
  if (commit.parents.length === 0) return !(await this.pathsDiffer(undefined, commit.tree));
2815
+ const merge = commit.parents.length > 1 && !this.firstParentOnly;
2816
+ const all = full || !this.simplifyHistory;
1739
2817
  for (let k = 0; k < commit.parents.length; k++) {
1740
2818
  if (k === 1 && this.firstParentOnly) break;
1741
2819
  const parent = await this.walkCommits.load(commit.parents[k] as ObjectId);
@@ -1744,9 +2822,12 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1744
2822
  `fatal: cannot simplify commit ${id} (because of ${commit.parents[k]})`,
1745
2823
  );
1746
2824
  }
1747
- if (!(await this.pathsDiffer(parent.tree, commit.tree))) return true;
2825
+ const same = !(await this.pathsDiffer(parent.tree, commit.tree));
2826
+ if (merge && all) {
2827
+ if (!same) return false;
2828
+ } else if (same) return true;
1748
2829
  }
1749
- return false;
2830
+ return merge && all;
1750
2831
  }
1751
2832
 
1752
2833
  /**
@@ -1800,6 +2881,36 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1800
2881
  * (`--since`/`--until` against the entry's date, path limiting against the commit's parents,
1801
2882
  * get_commit_action), then skipped and counted.
1802
2883
  */
2884
+ /**
2885
+ * Show these commits as they are, nothing walked (`git diff-tree <commit>`, `--stdin`'s
2886
+ * lines): each with its own parents, or the ones given (a `--stdin` line's grafts)
2887
+ *
2888
+ * @internal
2889
+ */
2890
+ setNoWalk(commits: readonly { id: ObjectId; parents?: readonly ObjectId[] }[]): this {
2891
+ this.checkCallable();
2892
+ this.noWalkCommits = commits;
2893
+ return this;
2894
+ }
2895
+
2896
+ private noWalkCommits?: readonly { id: ObjectId; parents?: readonly ObjectId[] }[];
2897
+
2898
+ /** {@link setNoWalk}'s commits as the output shows them */
2899
+ private async noWalkEntries(
2900
+ commits: readonly { id: ObjectId; parents?: readonly ObjectId[] }[],
2901
+ ): Promise<LogOutputEntry[]> {
2902
+ this.checkCallable();
2903
+ this.setCallable(false);
2904
+ readDiffSubmoduleConfig(this.workingCopy);
2905
+ const out: LogOutputEntry[] = [];
2906
+ for (const { id, parents } of commits) {
2907
+ const commit = await this.walkCommits.load(id);
2908
+ if (!commit) throw new GitApiError(`fatal: bad object ${id}`);
2909
+ out.push({ id, commit, parents: parents ? [...parents] : [...commit.parents] });
2910
+ }
2911
+ return out;
2912
+ }
2913
+
1803
2914
  private async reflogEntries(names: readonly string[], claim = true): Promise<LogOutputEntry[]> {
1804
2915
  if (claim) {
1805
2916
  this.checkCallable();
@@ -1916,6 +3027,39 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1916
3027
  }
1917
3028
  return tree;
1918
3029
  };
3030
+ const runDiff = async (
3031
+ oldTree: ObjectId,
3032
+ newTree: ObjectId,
3033
+ formats: DiffOutputFormat[],
3034
+ options: { statWidth?: number; follow?: string; fullDiff?: boolean; abbrev?: number },
3035
+ prepare?: (diff: DiffCommand) => void,
3036
+ ) => {
3037
+ // the trees themselves: a full id names its object, so no revision is looked up
3038
+ const diff = new DiffCommand(this._workingCopy);
3039
+ prepare?.(diff);
3040
+ diff
3041
+ .setOldTree(oldTree)
3042
+ .setNewTree(newTree)
3043
+ // log's diffcore_rotate starts at the first path after a missing one
3044
+ .setRotateStrict(false)
3045
+ .setTreeWalk(this.treeWalk)
3046
+ .shareReadsOf(this);
3047
+ if (this.colorSettings) diff.setColorSettings(this.colorSettings);
3048
+ diff.setOptions({
3049
+ ...this.diffOptions,
3050
+ ...(options.statWidth !== undefined
3051
+ ? { stat: { ...this.diffOptions.stat, width: options.statWidth } }
3052
+ : {}),
3053
+ ...(options.abbrev !== undefined ? { abbrev: options.abbrev } : {}),
3054
+ });
3055
+ if (!options.fullDiff && options.follow === undefined) {
3056
+ const spec = [...this.paths, ...this.excludePaths.map((p) => `:(exclude)${p}`)];
3057
+ if (spec.length > 0) diff.setPathspec(spec);
3058
+ }
3059
+ const shown = await diff.callFormats(formats, options.follow);
3060
+ if (diff.checkFoundErrors) this.checkFailed = true;
3061
+ return shown;
3062
+ };
1919
3063
  return {
1920
3064
  config: (key) => config.value(key),
1921
3065
  configAll: (key) => config.values(key),
@@ -1948,32 +3092,16 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1948
3092
  const bytes = await this.readObjectBytes(replace?.size ? replacementOf(replace, id) : id);
1949
3093
  return bytes ? decodeGitPath(bytes) : undefined;
1950
3094
  },
1951
- decorations: async (options) => {
1952
- const replacements = await this.objectReplacements();
1953
- const shallow = (await this.refsStore.getShallow?.().catch(() => undefined)) ?? [];
1954
- const environment = hostEnvironmentOf(this._workingCopy);
1955
- const objects = this._workingCopy.history?.objects;
1956
- const tags = this.tagsStore;
1957
- return loadRefDecorations({
1958
- refs: this.refsStore,
1959
- ...(tags ? { tags } : {}),
1960
- ...(environment?.replaceRefBase !== undefined
1961
- ? { replaceRefBase: environment.replaceRefBase }
3095
+ decorations: (options) =>
3096
+ this.refDecorations({
3097
+ decorate: options.decorate,
3098
+ ...(options.decorateRefs ? { decorateRefs: options.decorateRefs } : {}),
3099
+ ...(options.decorateRefsExclude
3100
+ ? { decorateRefsExclude: options.decorateRefsExclude }
1962
3101
  : {}),
1963
- useReplaceRefs: this.useReplaceRefs(),
1964
- grafted: new Set([...(replacements?.grafts.keys() ?? []), ...shallow]),
1965
- ...(objects ? { hasObject: (id: ObjectId) => objects.has(id) } : {}),
1966
- logOptions: {
1967
- decorate: options.decorate,
1968
- ...(options.decorateRefs ? { decorateRefs: options.decorateRefs } : {}),
1969
- ...(options.decorateRefsExclude
1970
- ? { decorateRefsExclude: options.decorateRefsExclude }
1971
- : {}),
1972
- ...(options.clearDecorations ? { clearDecorations: true } : {}),
1973
- config,
1974
- },
1975
- });
1976
- },
3102
+ ...(options.clearDecorations ? { clearDecorations: true } : {}),
3103
+ config,
3104
+ }),
1977
3105
  notes: async (id) => {
1978
3106
  notesTrees ??= this.loadNotes(config, options);
1979
3107
  const out: { ref: string; text: string }[] = [];
@@ -1986,34 +3114,60 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
1986
3114
  return out;
1987
3115
  },
1988
3116
  mailmap: () => {
1989
- mailmap ??= this.loadMailmap(config);
3117
+ mailmap ??= this.loadedMailmap();
1990
3118
  return mailmap;
1991
3119
  },
1992
- diff: async (entry, parent, formats, options) => {
1993
- // the trees themselves: a full id names its object, so no revision is looked up
3120
+ diff: async (entry, parent, formats, options) =>
3121
+ runDiff(
3122
+ parent ? await treeOf(parent) : this.objectFormat.emptyTreeId,
3123
+ entry.commit.tree,
3124
+ formats,
3125
+ options,
3126
+ ),
3127
+ remergeDiff: async (entry, parents, formats, options) => {
3128
+ // log-tree.c's do_remerge_diff: the re-merge's objects live in a view of their own
3129
+ // (git's tmp_objdir), dropped after this merge
3130
+ const history = this._workingCopy.history;
3131
+ if (!history) throw new Error("WorkingCopy.history is required for commands");
3132
+ const view = remergeObjectsView(history);
3133
+ const remerge = new RemergeTreeCommand(this._workingCopy)
3134
+ .setObjectsView(view)
3135
+ .shareReadsOf(this)
3136
+ .setParents(parents[0], parents[1]);
3137
+ // git 2.43's cmd_log_walk freed the parents of every commit it had processed (2.44
3138
+ // keeps them under --remerge-diff), so its merge bases stop there (`--reverse`)
3139
+ if (
3140
+ this.compatibility === "2.43" &&
3141
+ this.reflogWalkNames === undefined &&
3142
+ options.processed?.size
3143
+ ) {
3144
+ remerge.setParentlessCommits(options.processed);
3145
+ }
3146
+ const remerged = await remerge.call();
3147
+ return runDiff(remerged.treeId, entry.commit.tree, formats, options, (diff) =>
3148
+ diff.setObjectsView(view).setAdditionalHeaders(remerged.pathMessages),
3149
+ );
3150
+ },
3151
+ combinedDiff: (entry, options) => this.combinedDiff(entry, options),
3152
+ lineLogDiff: async (entry, formats, options) => {
3153
+ const lineLog = this.lineLog;
3154
+ if (!lineLog) return {};
3155
+ const tree = entry.commit.tree;
1994
3156
  const diff = new DiffCommand(this._workingCopy)
1995
- .setOldTree(parent ? await treeOf(parent) : this.objectFormat.emptyTreeId)
1996
- .setNewTree(entry.commit.tree)
1997
- // log's diffcore_rotate starts at the first path after a missing one
3157
+ .setOldTree(tree)
3158
+ .setNewTree(tree)
1998
3159
  .setRotateStrict(false)
1999
- .shareReadsOf(this);
3160
+ .shareReadsOf(this)
3161
+ .setQueue(lineLog.queuedPairs(entry.id));
2000
3162
  if (this.colorSettings) diff.setColorSettings(this.colorSettings);
2001
3163
  diff.setOptions({
2002
- ...this.diffOptions,
2003
- ...(options.statWidth !== undefined
2004
- ? { stat: { ...this.diffOptions.stat, width: options.statWidth } }
2005
- : {}),
3164
+ ...this.lineLogDiffOptions(),
2006
3165
  ...(options.abbrev !== undefined ? { abbrev: options.abbrev } : {}),
2007
3166
  });
2008
- if (!options.fullDiff && options.follow === undefined) {
2009
- const spec = [...this.paths, ...this.excludePaths.map((p) => `:(exclude)${p}`)];
2010
- if (spec.length > 0) diff.setPathspec(spec);
2011
- }
2012
- const shown = await diff.callFormats(formats, options.follow);
2013
- if (diff.checkFoundErrors) this.checkFailed = true;
2014
- return shown;
3167
+ return diff.callFormats(formats);
2015
3168
  },
2016
- combinedDiff: (entry, options) => this.combinedDiff(entry, options),
3169
+ lineLogHacky: async (entry, prefix, colors) =>
3170
+ this.lineLog ? this.lineLog.hackyDiff(entry.id, prefix, colors) : new Uint8Array(0),
2017
3171
  };
2018
3172
  }
2019
3173
 
@@ -2032,6 +3186,9 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
2032
3186
  /** The colors {@link callBytes} prints with */
2033
3187
  private colorSettings?: DiffColorSettings;
2034
3188
  private readonly outputWarnings: string[] = [];
3189
+ /** The mailmap as read once ({@link loadedMailmap}), and git's errors of reading it */
3190
+ private mailmapLoad?: Promise<Mailmap>;
3191
+ private readonly mailmapErrors: string[] = [];
2035
3192
 
2036
3193
  /**
2037
3194
  * What git prints on stderr while {@link callBytes} prints the log without dying: the
@@ -2125,6 +3282,20 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
2125
3282
  return true;
2126
3283
  }
2127
3284
 
3285
+ /**
3286
+ * How the commits' trees are compared (`DiffCommand.setTreeWalk`): `git diff-tree` without
3287
+ * `-r` lists the top tree's differing entries
3288
+ *
3289
+ * @internal
3290
+ */
3291
+ setTreeWalk(walk: "recursive" | "flat" | "show-trees"): this {
3292
+ this.checkCallable();
3293
+ this.treeWalk = walk;
3294
+ return this;
3295
+ }
3296
+
3297
+ private treeWalk: "recursive" | "flat" | "show-trees" = "recursive";
3298
+
2128
3299
  /** Options of the diffs {@link callBytes} prints (context, algorithm, `--stat` widths...) */
2129
3300
  setDiffOptions(options: DiffTextOptions): this {
2130
3301
  this.checkCallable();
@@ -2289,6 +3460,37 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
2289
3460
  return kept;
2290
3461
  }
2291
3462
 
3463
+ /**
3464
+ * The combined raw output's ids (`diff_aligned_abbrev`): full under `rawFullIds` without
3465
+ * `--abbrev`, else each abbreviated uniquely
3466
+ */
3467
+ private async combinedRawAbbreviator(
3468
+ raw: boolean,
3469
+ paths: string[],
3470
+ result: Map<string, { mode: number; id: ObjectId }>,
3471
+ parents: Map<string, { mode: number; id: ObjectId }>[],
3472
+ ): Promise<(id: ObjectId | undefined) => string> {
3473
+ const nullId = this.objectFormat.nullId;
3474
+ const o = this.diffOptions;
3475
+ if (!raw || (o.rawFullIds && o.abbrev === undefined)) return (id) => id ?? nullId;
3476
+ const ids = new Set<string>([nullId]);
3477
+ for (const path of paths) {
3478
+ const r = result.get(path);
3479
+ if (r) ids.add(r.id);
3480
+ for (const m of parents) {
3481
+ const side = m.get(path);
3482
+ if (side) ids.add(side.id);
3483
+ }
3484
+ }
3485
+ const min =
3486
+ o.abbrev === undefined ? undefined : Math.min(40, Math.max(4, Math.trunc(o.abbrev)));
3487
+ const lengths = await this.idAbbreviator().lengths(ids, min);
3488
+ return (id) => {
3489
+ const full = id ?? nullId;
3490
+ return full.slice(0, lengths.get(full) ?? min ?? 7);
3491
+ };
3492
+ }
3493
+
2292
3494
  /**
2293
3495
  * combine-diff.c's diff_tree_combined for a merge: the paths that differ from every
2294
3496
  * parent (within the pathspec), each as a combined diff of the trees.
@@ -2297,7 +3499,7 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
2297
3499
  entry: LogOutputEntry,
2298
3500
  options: {
2299
3501
  dense: boolean;
2300
- names?: "name-only" | "name-status";
3502
+ names?: "name-only" | "name-status" | "raw";
2301
3503
  patch: boolean;
2302
3504
  follow?: string;
2303
3505
  parentPaths?: string[];
@@ -2357,16 +3559,36 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
2357
3559
  parseGitBool(RemoteConfigStore.from(this._workingCopy).value("core.quotePath")) ?? true;
2358
3560
  const names = new ByteSink();
2359
3561
  if (options.names) {
3562
+ // show_raw_diff: `-z` ends each field with a NUL, its paths unquoted
3563
+ const z = this.diffOptions.nullTerminated === true;
3564
+ const inter = z ? "\0" : "\t";
3565
+ const term = z ? "\0" : "\n";
3566
+ const rawId = await this.combinedRawAbbreviator(
3567
+ options.names === "raw",
3568
+ paths,
3569
+ result,
3570
+ parents,
3571
+ );
3572
+ const mode6 = (mode: number | undefined) => (mode ?? 0).toString(8).padStart(6, "0");
2360
3573
  for (const path of paths) {
2361
- if (options.names === "name-status") {
3574
+ if (options.names === "raw") {
3575
+ const r = result.get(path);
3576
+ const sides = parents.map((m, k) => sideOf(m, k, path));
3577
+ names.text(":".repeat(parents.length));
3578
+ for (const side of sides) names.text(`${mode6(side?.mode)} `);
3579
+ names.text(mode6(r?.mode));
3580
+ for (const side of sides) names.text(` ${rawId(side?.id)}`);
3581
+ names.text(` ${rawId(r?.id)} `);
3582
+ }
3583
+ if (options.names === "name-status" || options.names === "raw") {
2362
3584
  const r = result.get(path);
2363
3585
  parents.forEach((m, k) => {
2364
3586
  const found = options.parentStatus?.[k];
2365
3587
  names.text(found ?? (!sideOf(m, k, path) ? "A" : !r ? "D" : "M"));
2366
3588
  });
2367
- names.text("\t");
3589
+ names.text(inter);
2368
3590
  }
2369
- names.text(`${quotePath(path, quote)}\n`);
3591
+ names.text(`${z ? path : quotePath(path, quote)}${term}`);
2370
3592
  }
2371
3593
  }
2372
3594
  if (paths.length === 0 || !options.patch) {
@@ -2472,21 +3694,6 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
2472
3694
  return out;
2473
3695
  }
2474
3696
 
2475
- /** mailmap.c's read_mailmap: `.mailmap` (not in a bare repository), `mailmap.blob`, `mailmap.file` */
2476
- private async loadMailmap(config: RemoteConfigStore): Promise<Mailmap> {
2477
- return readRepositoryMailmap({
2478
- config: (key) => config.value(key),
2479
- worktree: this.worktreeAccess,
2480
- environment: hostEnvironmentOf(this._workingCopy),
2481
- readBlobNamed: async (name) => {
2482
- const id = await this.revisionResolver()
2483
- .resolve(name)
2484
- .catch(() => undefined);
2485
- return id ? this.readBlob(id) : undefined;
2486
- },
2487
- });
2488
- }
2489
-
2490
3697
  /**
2491
3698
  * The tree, parents and date of a commit (git's parse_commit_buffer), from its raw bytes
2492
3699
  * when the store gives them (kept in `raw` to be decoded whole if the commit is shown),
@@ -2537,11 +3744,66 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
2537
3744
  * element's path components when all are plain paths (no wildcard, no magic, no trailing
2538
3745
  * slash): those are compared by looking their entries up, without a tree diff.
2539
3746
  */
2540
- private pathspec(): TreePathspec & { literal: Uint8Array[][] | undefined } {
3747
+ /** The walk's pathspec elements: the paths, the excluded ones, `.` when every one excludes */
3748
+ private pathspecItems(): PathspecItem[] {
2541
3749
  const parse = (p: string) => parsePathspecItem(p, { attr: true });
2542
3750
  const items: PathspecItem[] = this.paths.map(parse);
2543
3751
  for (const p of this.excludePaths) items.push({ ...parse(p), exclude: true });
2544
3752
  if (items.every((i) => i.exclude)) items.push(parse("."));
3753
+ return items;
3754
+ }
3755
+
3756
+ /**
3757
+ * revision.c's cherry_pick_list over the limited list: the patch-ids of the side with fewer
3758
+ * commits are added (header ids only, see {@link PatchIds}), each commit of the other side
3759
+ * looked up, and every match on either side marked PATCHSAME (`--cherry-mark`) or SHOWN
3760
+ * (`--cherry-pick`, hidden). The diffs are limited to the walk's paths, and compare a
3761
+ * commit with its parent as the walk has it (simplified), as git's do.
3762
+ */
3763
+ private async cherryPickList(
3764
+ list: number[],
3765
+ t: RevTable,
3766
+ parse: (n: number) => Promise<boolean>,
3767
+ items: PathspecItem[] | undefined,
3768
+ ): Promise<void> {
3769
+ let leftCount = 0;
3770
+ let rightCount = 0;
3771
+ for (const n of list) {
3772
+ if (t.flag(n) & SYMMETRIC_LEFT) leftCount++;
3773
+ else rightCount++;
3774
+ }
3775
+ if (!leftCount || !rightCount) return;
3776
+ const leftFirst = leftCount < rightCount;
3777
+ const ids = new PatchIds<number>({
3778
+ trees: this.trees,
3779
+ blobs: this.blobs,
3780
+ objectFormat: this.objectFormat,
3781
+ change: async (n) => {
3782
+ const count = t.parentCount(n);
3783
+ if (count > 1) return undefined;
3784
+ if (count === 0) return { tree: t.treeOf(n) };
3785
+ const p = t.parent(n, 0);
3786
+ if (!(await parse(p))) return undefined;
3787
+ return { parentTree: t.treeOf(p), tree: t.treeOf(n) };
3788
+ },
3789
+ ...(items ? { paths: (path: string) => matchPathspec(items, path, 0) > 0 } : {}),
3790
+ });
3791
+ for (const n of list) {
3792
+ if (leftFirst !== !!(t.flag(n) & SYMMETRIC_LEFT)) continue;
3793
+ await ids.add(n);
3794
+ }
3795
+ const flag = this.cherryMark ? PATCHSAME : SHOWN;
3796
+ for (const n of list) {
3797
+ if (leftFirst === !!(t.flag(n) & SYMMETRIC_LEFT)) continue;
3798
+ const found = await ids.matches(n);
3799
+ if (found.length === 0) continue;
3800
+ t.mark(n, flag);
3801
+ for (const m of found) t.mark(m, flag);
3802
+ }
3803
+ }
3804
+
3805
+ private pathspec(): TreePathspec & { literal: Uint8Array[][] | undefined } {
3806
+ const items = this.pathspecItems();
2545
3807
  const plain = items.every(
2546
3808
  (i) =>
2547
3809
  !i.exclude &&
@@ -2935,6 +4197,16 @@ const BOTTOM = 1 << 2;
2935
4197
  const SEEN = 1 << 3;
2936
4198
  const ADDED = 1 << 4;
2937
4199
  const TREESAME = 1 << 5;
4200
+ /** The left side of `a...b` (passed from child to parent) */
4201
+ const SYMMETRIC_LEFT = 1 << 8;
4202
+ /** `--cherry-mark`: a commit whose change the other side has as well */
4203
+ const PATCHSAME = 1 << 9;
4204
+ /** Shown already, or hidden by `--cherry-pick`/`--left-only`/`--right-only` (git's SHOWN) */
4205
+ const SHOWN = 1 << 10;
4206
+ /** `--ancestry-path=<commit>`: an ancestor of a commit named (passed from child to parent) */
4207
+ const ANCESTRY_PATH = 1 << 11;
4208
+ /** `--show-pulls`: a merge that differs from its first parent at the paths */
4209
+ const PULL_MERGE = 1 << 12;
2938
4210
 
2939
4211
  /** How many extra uninteresting commits limit_list looks at (git's SLOP). */
2940
4212
  const SLOP = 5;
@@ -2950,7 +4222,7 @@ class RevTable {
2950
4222
  /** commits held */
2951
4223
  size = 0;
2952
4224
  /** revision.c flags (UNINTERESTING, SEEN, ...) */
2953
- flags = new Uint8Array(INITIAL_REVS);
4225
+ flags = new Uint16Array(INITIAL_REVS);
2954
4226
  /** committer dates (seconds) */
2955
4227
  private dates = new Float64Array(INITIAL_REVS);
2956
4228
  /** position in the commit-graph, -1 for a commit it does not have */
@@ -3084,6 +4356,21 @@ class RevTable {
3084
4356
  return this.pool[(this.parentAt[n] as number) + k] as number;
3085
4357
  }
3086
4358
 
4359
+ /** The parents of a parsed commit, as numbers. */
4360
+ parentList(n: number): number[] {
4361
+ const out: number[] = [];
4362
+ for (let k = 0, c = this.parentCount(n); k < c; k++) out.push(this.parent(n, k));
4363
+ return out;
4364
+ }
4365
+
4366
+ /** Replaces the parents of a parsed commit by `list`, no longer than they were. */
4367
+ setParentList(n: number, list: readonly number[]): void {
4368
+ if (list.length > this.parentCount(n)) throw new Error("parents cannot grow");
4369
+ const at = this.parentAt[n] as number;
4370
+ for (let k = 0; k < list.length; k++) this.pool[at + k] = list[k] as number;
4371
+ this.parents[n] = list.length;
4372
+ }
4373
+
3087
4374
  /** Simplification keeps only parent `p` (git rewrites `commit->parents`). */
3088
4375
  keepOnlyParent(n: number, p: number): void {
3089
4376
  this.pool[this.parentAt[n] as number] = p;
@@ -3100,7 +4387,7 @@ class RevTable {
3100
4387
 
3101
4388
  private grow(): void {
3102
4389
  const size = this.flags.length * 2;
3103
- const flags = new Uint8Array(size);
4390
+ const flags = new Uint16Array(size);
3104
4391
  flags.set(this.flags);
3105
4392
  this.flags = flags;
3106
4393
  const dates = new Float64Array(size);
@@ -3123,6 +4410,55 @@ const INITIAL_REVS = 1024;
3123
4410
  /** `RevTable` flag: parsed from the commit-graph (its tree and Bloom filter are there). */
3124
4411
  const GRAPH_PARSED = 1 << 6;
3125
4412
 
4413
+ /** revision.c's one_relevant_parent: the one parent a TREESAME commit simplifies to */
4414
+ function oneRelevantParent(
4415
+ t: RevTable,
4416
+ n: number,
4417
+ firstParentOnly: boolean,
4418
+ relevant: (n: number) => boolean,
4419
+ ): number | undefined {
4420
+ const c = t.parentCount(n);
4421
+ if (c === 0) return undefined;
4422
+ if (firstParentOnly || c === 1) return t.parent(n, 0);
4423
+ let found: number | undefined;
4424
+ for (let k = 0; k < c; k++) {
4425
+ const p = t.parent(n, k);
4426
+ if (!relevant(p)) continue;
4427
+ if (found !== undefined) return undefined;
4428
+ found = p;
4429
+ }
4430
+ return found;
4431
+ }
4432
+
4433
+ /**
4434
+ * revision.c's rewrite_parents: n's parents, each replaced by the first commit shown on its
4435
+ * way down (rewrite_one), roots TREESAME dropped, duplicates removed.
4436
+ */
4437
+ function rewriteParents(
4438
+ t: RevTable,
4439
+ n: number,
4440
+ firstParentOnly: boolean,
4441
+ relevant: (n: number) => boolean,
4442
+ ): number[] {
4443
+ const out: number[] = [];
4444
+ for (let k = 0, c = t.parentCount(n); k < c; k++) {
4445
+ let p: number | undefined = t.parent(n, k);
4446
+ for (;;) {
4447
+ if (t.flag(p) & UNINTERESTING) break;
4448
+ if (!(t.flag(p) & TREESAME)) break;
4449
+ if (t.parentCount(p) === 0) {
4450
+ p = undefined;
4451
+ break;
4452
+ }
4453
+ const next = oneRelevantParent(t, p, firstParentOnly, relevant);
4454
+ if (next === undefined) break;
4455
+ p = next;
4456
+ }
4457
+ if (p !== undefined && !out.includes(p)) out.push(p);
4458
+ }
4459
+ return out;
4460
+ }
4461
+
3126
4462
  /** A commit read whole, as the commit store decodes it; undefined if it does not parse. */
3127
4463
  function decodeCommit(bytes: Uint8Array): Commit | undefined {
3128
4464
  try {