@statewalker/vcs-commands 0.4.0 → 0.6.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 (561) hide show
  1. package/README.md +123 -8
  2. package/dist/commands/add-command.d.ts +265 -34
  3. package/dist/commands/add-command.d.ts.map +1 -1
  4. package/dist/commands/add-patch/add-interactive.d.ts +46 -0
  5. package/dist/commands/add-patch/add-interactive.d.ts.map +1 -0
  6. package/dist/commands/add-patch/add-patch.d.ts +139 -0
  7. package/dist/commands/add-patch/add-patch.d.ts.map +1 -0
  8. package/dist/commands/add-patch/index.d.ts +6 -0
  9. package/dist/commands/add-patch/index.d.ts.map +1 -0
  10. package/dist/commands/add-patch/patch-backend.d.ts +80 -0
  11. package/dist/commands/add-patch/patch-backend.d.ts.map +1 -0
  12. package/dist/commands/add-patch/patch-modes.d.ts +71 -0
  13. package/dist/commands/add-patch/patch-modes.d.ts.map +1 -0
  14. package/dist/commands/add-patch/patch-session.d.ts +49 -0
  15. package/dist/commands/add-patch/patch-session.d.ts.map +1 -0
  16. package/dist/commands/am/am-command.d.ts +175 -0
  17. package/dist/commands/am/am-command.d.ts.map +1 -0
  18. package/dist/commands/am/index.d.ts +3 -0
  19. package/dist/commands/am/index.d.ts.map +1 -0
  20. package/dist/commands/am/mailinfo.d.ts +58 -0
  21. package/dist/commands/am/mailinfo.d.ts.map +1 -0
  22. package/dist/commands/am/patch-format.d.ts +24 -0
  23. package/dist/commands/am/patch-format.d.ts.map +1 -0
  24. package/dist/commands/apply/apply-command.d.ts +153 -0
  25. package/dist/commands/apply/apply-command.d.ts.map +1 -0
  26. package/dist/commands/apply/apply-engine.d.ts +195 -0
  27. package/dist/commands/apply/apply-engine.d.ts.map +1 -0
  28. package/dist/commands/apply/apply-parse.d.ts +86 -0
  29. package/dist/commands/apply/apply-parse.d.ts.map +1 -0
  30. package/dist/commands/apply/apply-types.d.ts +70 -0
  31. package/dist/commands/apply/apply-types.d.ts.map +1 -0
  32. package/dist/commands/apply/index.d.ts +6 -0
  33. package/dist/commands/apply/index.d.ts.map +1 -0
  34. package/dist/commands/apply/latin1.d.ts +32 -0
  35. package/dist/commands/apply/latin1.d.ts.map +1 -0
  36. package/dist/commands/apply/whitespace.d.ts +58 -0
  37. package/dist/commands/apply/whitespace.d.ts.map +1 -0
  38. package/dist/commands/attributes-source.d.ts +26 -0
  39. package/dist/commands/attributes-source.d.ts.map +1 -0
  40. package/dist/commands/backfill-command.d.ts +110 -0
  41. package/dist/commands/backfill-command.d.ts.map +1 -0
  42. package/dist/commands/bisect/bisect-checkout.d.ts +64 -0
  43. package/dist/commands/bisect/bisect-checkout.d.ts.map +1 -0
  44. package/dist/commands/bisect/bisect-command.d.ts +201 -0
  45. package/dist/commands/bisect/bisect-command.d.ts.map +1 -0
  46. package/dist/commands/bisect/bisect-engine.d.ts +219 -0
  47. package/dist/commands/bisect/bisect-engine.d.ts.map +1 -0
  48. package/dist/commands/bisect/bisect-graph.d.ts +127 -0
  49. package/dist/commands/bisect/bisect-graph.d.ts.map +1 -0
  50. package/dist/commands/bisect/bisect-quote.d.ts +27 -0
  51. package/dist/commands/bisect/bisect-quote.d.ts.map +1 -0
  52. package/dist/commands/bisect/index.d.ts +5 -0
  53. package/dist/commands/bisect/index.d.ts.map +1 -0
  54. package/dist/commands/blame-command.d.ts +122 -131
  55. package/dist/commands/blame-command.d.ts.map +1 -1
  56. package/dist/commands/branch-command.d.ts +52 -2
  57. package/dist/commands/branch-command.d.ts.map +1 -1
  58. package/dist/commands/branch-tracking.d.ts +98 -0
  59. package/dist/commands/branch-tracking.d.ts.map +1 -0
  60. package/dist/commands/checkout-command.d.ts +299 -34
  61. package/dist/commands/checkout-command.d.ts.map +1 -1
  62. package/dist/commands/checkout-paths.d.ts +124 -0
  63. package/dist/commands/checkout-paths.d.ts.map +1 -0
  64. package/dist/commands/cherry-pick-command.d.ts +50 -42
  65. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  66. package/dist/commands/clean-command.d.ts +67 -4
  67. package/dist/commands/clean-command.d.ts.map +1 -1
  68. package/dist/commands/clone-command.d.ts +179 -7
  69. package/dist/commands/clone-command.d.ts.map +1 -1
  70. package/dist/commands/commit-command.d.ts +311 -17
  71. package/dist/commands/commit-command.d.ts.map +1 -1
  72. package/dist/commands/core-config.d.ts +93 -0
  73. package/dist/commands/core-config.d.ts.map +1 -0
  74. package/dist/commands/date-format.d.ts +58 -0
  75. package/dist/commands/date-format.d.ts.map +1 -0
  76. package/dist/commands/describe-command.d.ts.map +1 -1
  77. package/dist/commands/diff-command.d.ts +377 -30
  78. package/dist/commands/diff-command.d.ts.map +1 -1
  79. package/dist/commands/diff-textconv.d.ts +40 -0
  80. package/dist/commands/diff-textconv.d.ts.map +1 -0
  81. package/dist/commands/fetch-command.d.ts +244 -23
  82. package/dist/commands/fetch-command.d.ts.map +1 -1
  83. package/dist/commands/format-patch-command.d.ts +164 -0
  84. package/dist/commands/format-patch-command.d.ts.map +1 -0
  85. package/dist/commands/fsck/fetch-fsck.d.ts +60 -0
  86. package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -0
  87. package/dist/commands/fsck/fsck-command.d.ts +225 -0
  88. package/dist/commands/fsck/fsck-command.d.ts.map +1 -0
  89. package/dist/commands/fsck/fsck-loose.d.ts +68 -0
  90. package/dist/commands/fsck/fsck-loose.d.ts.map +1 -0
  91. package/dist/commands/fsck/fsck-msg-ids.d.ts +122 -0
  92. package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -0
  93. package/dist/commands/fsck/fsck-object-checks.d.ts +148 -0
  94. package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -0
  95. package/dist/commands/fsck/fsck-object-table.d.ts +132 -0
  96. package/dist/commands/fsck/fsck-object-table.d.ts.map +1 -0
  97. package/dist/commands/fsck/fsck-pack.d.ts +115 -0
  98. package/dist/commands/fsck/fsck-pack.d.ts.map +1 -0
  99. package/dist/commands/fsck/index.d.ts +6 -0
  100. package/dist/commands/fsck/index.d.ts.map +1 -0
  101. package/dist/commands/fsck/verify-pack-command.d.ts +81 -0
  102. package/dist/commands/fsck/verify-pack-command.d.ts.map +1 -0
  103. package/dist/commands/gc-command.d.ts +43 -0
  104. package/dist/commands/gc-command.d.ts.map +1 -1
  105. package/dist/commands/git-date.d.ts +66 -0
  106. package/dist/commands/git-date.d.ts.map +1 -0
  107. package/dist/commands/git-describe.d.ts +67 -0
  108. package/dist/commands/git-describe.d.ts.map +1 -0
  109. package/dist/commands/git-hooks.d.ts +416 -0
  110. package/dist/commands/git-hooks.d.ts.map +1 -0
  111. package/dist/commands/git-ident.d.ts +128 -0
  112. package/dist/commands/git-ident.d.ts.map +1 -0
  113. package/dist/commands/hook-command.d.ts +96 -0
  114. package/dist/commands/hook-command.d.ts.map +1 -0
  115. package/dist/commands/index-adder.d.ts +231 -0
  116. package/dist/commands/index-adder.d.ts.map +1 -0
  117. package/dist/commands/index-host.d.ts +86 -0
  118. package/dist/commands/index-host.d.ts.map +1 -0
  119. package/dist/commands/index.d.ts +55 -0
  120. package/dist/commands/index.d.ts.map +1 -1
  121. package/dist/commands/index.js +3 -2
  122. package/dist/commands/init-command.d.ts +12 -1
  123. package/dist/commands/init-command.d.ts.map +1 -1
  124. package/dist/commands/local-clone.d.ts +60 -0
  125. package/dist/commands/local-clone.d.ts.map +1 -0
  126. package/dist/commands/local-transport.d.ts +117 -0
  127. package/dist/commands/local-transport.d.ts.map +1 -0
  128. package/dist/commands/log-command.d.ts +216 -24
  129. package/dist/commands/log-command.d.ts.map +1 -1
  130. package/dist/commands/log-graph.d.ts +120 -0
  131. package/dist/commands/log-graph.d.ts.map +1 -0
  132. package/dist/commands/log-output.d.ts +323 -0
  133. package/dist/commands/log-output.d.ts.map +1 -0
  134. package/dist/commands/ls-remote-command.d.ts +23 -7
  135. package/dist/commands/ls-remote-command.d.ts.map +1 -1
  136. package/dist/commands/mailmap.d.ts +31 -0
  137. package/dist/commands/mailmap.d.ts.map +1 -0
  138. package/dist/commands/merge-bases.d.ts +85 -0
  139. package/dist/commands/merge-bases.d.ts.map +1 -0
  140. package/dist/commands/merge-command.d.ts +209 -74
  141. package/dist/commands/merge-command.d.ts.map +1 -1
  142. package/dist/commands/merge-config.d.ts +13 -0
  143. package/dist/commands/merge-config.d.ts.map +1 -0
  144. package/dist/commands/merge-drivers.d.ts +130 -0
  145. package/dist/commands/merge-drivers.d.ts.map +1 -0
  146. package/dist/commands/merge-support.d.ts +252 -0
  147. package/dist/commands/merge-support.d.ts.map +1 -0
  148. package/dist/commands/message-cleanup.d.ts +86 -0
  149. package/dist/commands/message-cleanup.d.ts.map +1 -0
  150. package/dist/commands/mv-command.d.ts +94 -0
  151. package/dist/commands/mv-command.d.ts.map +1 -0
  152. package/dist/commands/notes-command.d.ts +256 -0
  153. package/dist/commands/notes-command.d.ts.map +1 -0
  154. package/dist/commands/notes-commands.d.ts +41 -0
  155. package/dist/commands/notes-commands.d.ts.map +1 -0
  156. package/dist/commands/notes-merge-command.d.ts +105 -0
  157. package/dist/commands/notes-merge-command.d.ts.map +1 -0
  158. package/dist/commands/notes-support.d.ts +125 -0
  159. package/dist/commands/notes-support.d.ts.map +1 -0
  160. package/dist/commands/notes-tree.d.ts +106 -0
  161. package/dist/commands/notes-tree.d.ts.map +1 -0
  162. package/dist/commands/object-id-input.d.ts +20 -0
  163. package/dist/commands/object-id-input.d.ts.map +1 -0
  164. package/dist/commands/octopus-merge.d.ts +59 -0
  165. package/dist/commands/octopus-merge.d.ts.map +1 -0
  166. package/dist/commands/ort-merge.d.ts +126 -0
  167. package/dist/commands/ort-merge.d.ts.map +1 -0
  168. package/dist/commands/ort-recursive.d.ts +53 -0
  169. package/dist/commands/ort-recursive.d.ts.map +1 -0
  170. package/dist/commands/pack-refs-command.d.ts +20 -0
  171. package/dist/commands/pack-refs-command.d.ts.map +1 -1
  172. package/dist/commands/patch-id.d.ts +41 -0
  173. package/dist/commands/patch-id.d.ts.map +1 -0
  174. package/dist/commands/pathspec-attributes.d.ts +64 -0
  175. package/dist/commands/pathspec-attributes.d.ts.map +1 -0
  176. package/dist/commands/pathspec.d.ts +324 -0
  177. package/dist/commands/pathspec.d.ts.map +1 -0
  178. package/dist/commands/post-index-change.d.ts +33 -0
  179. package/dist/commands/post-index-change.d.ts.map +1 -0
  180. package/dist/commands/pretty-format.d.ts +222 -0
  181. package/dist/commands/pretty-format.d.ts.map +1 -0
  182. package/dist/commands/promisor-remote.d.ts +80 -0
  183. package/dist/commands/promisor-remote.d.ts.map +1 -0
  184. package/dist/commands/pull-command.d.ts +41 -8
  185. package/dist/commands/pull-command.d.ts.map +1 -1
  186. package/dist/commands/push-command.d.ts +24 -8
  187. package/dist/commands/push-command.d.ts.map +1 -1
  188. package/dist/commands/read-tree-command.d.ts +112 -0
  189. package/dist/commands/read-tree-command.d.ts.map +1 -0
  190. package/dist/commands/rebase-command.d.ts +507 -75
  191. package/dist/commands/rebase-command.d.ts.map +1 -1
  192. package/dist/commands/rebase-todo.d.ts +130 -0
  193. package/dist/commands/rebase-todo.d.ts.map +1 -0
  194. package/dist/commands/ref-decoration-filter.d.ts +53 -0
  195. package/dist/commands/ref-decoration-filter.d.ts.map +1 -0
  196. package/dist/commands/reflog-messages.d.ts +98 -0
  197. package/dist/commands/reflog-messages.d.ts.map +1 -0
  198. package/dist/commands/remote-command.d.ts +146 -6
  199. package/dist/commands/remote-command.d.ts.map +1 -1
  200. package/dist/commands/remote-transport.d.ts +120 -0
  201. package/dist/commands/remote-transport.d.ts.map +1 -0
  202. package/dist/commands/reset-command.d.ts +161 -7
  203. package/dist/commands/reset-command.d.ts.map +1 -1
  204. package/dist/commands/restore-command.d.ts +103 -0
  205. package/dist/commands/restore-command.d.ts.map +1 -0
  206. package/dist/commands/rev-list-command.d.ts +78 -0
  207. package/dist/commands/rev-list-command.d.ts.map +1 -0
  208. package/dist/commands/rev-parse-command.d.ts +80 -0
  209. package/dist/commands/rev-parse-command.d.ts.map +1 -0
  210. package/dist/commands/revert-command.d.ts +46 -38
  211. package/dist/commands/revert-command.d.ts.map +1 -1
  212. package/dist/commands/revision-filenames.d.ts +95 -0
  213. package/dist/commands/revision-filenames.d.ts.map +1 -0
  214. package/dist/commands/revision-range.d.ts +67 -0
  215. package/dist/commands/revision-range.d.ts.map +1 -0
  216. package/dist/commands/revision-resolver.d.ts +321 -0
  217. package/dist/commands/revision-resolver.d.ts.map +1 -0
  218. package/dist/commands/rm-command.d.ts +69 -7
  219. package/dist/commands/rm-command.d.ts.map +1 -1
  220. package/dist/commands/sequencer-pick.d.ts +191 -0
  221. package/dist/commands/sequencer-pick.d.ts.map +1 -0
  222. package/dist/commands/sequencer-support.d.ts +125 -0
  223. package/dist/commands/sequencer-support.d.ts.map +1 -0
  224. package/dist/commands/serve-repository.d.ts +52 -0
  225. package/dist/commands/serve-repository.d.ts.map +1 -0
  226. package/dist/commands/sparse-checkout-command.d.ts +190 -0
  227. package/dist/commands/sparse-checkout-command.d.ts.map +1 -0
  228. package/dist/commands/sparse-checkout-support.d.ts +268 -0
  229. package/dist/commands/sparse-checkout-support.d.ts.map +1 -0
  230. package/dist/commands/stash-apply-command.d.ts +69 -13
  231. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  232. package/dist/commands/stash-create-command.d.ts +214 -26
  233. package/dist/commands/stash-create-command.d.ts.map +1 -1
  234. package/dist/commands/stash-drop-command.d.ts +10 -2
  235. package/dist/commands/stash-drop-command.d.ts.map +1 -1
  236. package/dist/commands/stash-list-command.d.ts +2 -4
  237. package/dist/commands/stash-list-command.d.ts.map +1 -1
  238. package/dist/commands/stash-working-tree.d.ts +95 -0
  239. package/dist/commands/stash-working-tree.d.ts.map +1 -0
  240. package/dist/commands/status-command.d.ts +320 -28
  241. package/dist/commands/status-command.d.ts.map +1 -1
  242. package/dist/commands/status-format.d.ts +155 -0
  243. package/dist/commands/status-format.d.ts.map +1 -0
  244. package/dist/commands/status-header.d.ts +64 -0
  245. package/dist/commands/status-header.d.ts.map +1 -0
  246. package/dist/commands/strerror.d.ts +7 -0
  247. package/dist/commands/strerror.d.ts.map +1 -0
  248. package/dist/commands/submodule-config.d.ts +38 -0
  249. package/dist/commands/submodule-config.d.ts.map +1 -0
  250. package/dist/commands/submodule-summary-command.d.ts +80 -0
  251. package/dist/commands/submodule-summary-command.d.ts.map +1 -0
  252. package/dist/commands/submodule-summary.d.ts +150 -0
  253. package/dist/commands/submodule-summary.d.ts.map +1 -0
  254. package/dist/commands/switch-command.d.ts +132 -0
  255. package/dist/commands/switch-command.d.ts.map +1 -0
  256. package/dist/commands/tag-command.d.ts +23 -2
  257. package/dist/commands/tag-command.d.ts.map +1 -1
  258. package/dist/commands/tracking-info.d.ts +64 -0
  259. package/dist/commands/tracking-info.d.ts.map +1 -0
  260. package/dist/commands/trailers.d.ts +73 -0
  261. package/dist/commands/trailers.d.ts.map +1 -0
  262. package/dist/commands/tree-restore.d.ts +137 -6
  263. package/dist/commands/tree-restore.d.ts.map +1 -1
  264. package/dist/commands/untracked-cache-support.d.ts +53 -0
  265. package/dist/commands/untracked-cache-support.d.ts.map +1 -0
  266. package/dist/commands/worktree-add-command.d.ts +108 -0
  267. package/dist/commands/worktree-add-command.d.ts.map +1 -0
  268. package/dist/commands/worktree-list-command.d.ts +69 -0
  269. package/dist/commands/worktree-list-command.d.ts.map +1 -0
  270. package/dist/commands/worktree-lock-command.d.ts +44 -0
  271. package/dist/commands/worktree-lock-command.d.ts.map +1 -0
  272. package/dist/commands/worktree-overwrite-checks.d.ts +204 -0
  273. package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -0
  274. package/dist/commands/worktree-prune-command.d.ts +48 -0
  275. package/dist/commands/worktree-prune-command.d.ts.map +1 -0
  276. package/dist/commands/worktree-remove-command.d.ts +59 -0
  277. package/dist/commands/worktree-remove-command.d.ts.map +1 -0
  278. package/dist/commands/worktree-repair-command.d.ts +35 -0
  279. package/dist/commands/worktree-repair-command.d.ts.map +1 -0
  280. package/dist/commands/worktree-support.d.ts +64 -0
  281. package/dist/commands/worktree-support.d.ts.map +1 -0
  282. package/dist/commands-DnmlfwGV.js +61620 -0
  283. package/dist/core-commands/add.command.impl.d.ts.map +1 -1
  284. package/dist/core-commands/index.d.ts +0 -3
  285. package/dist/core-commands/index.d.ts.map +1 -1
  286. package/dist/errors/add-errors.d.ts +55 -0
  287. package/dist/errors/add-errors.d.ts.map +1 -1
  288. package/dist/errors/checkout-errors.d.ts +29 -0
  289. package/dist/errors/checkout-errors.d.ts.map +1 -1
  290. package/dist/errors/command-errors.d.ts +77 -0
  291. package/dist/errors/command-errors.d.ts.map +1 -1
  292. package/dist/errors/commit-errors.d.ts +9 -0
  293. package/dist/errors/commit-errors.d.ts.map +1 -1
  294. package/dist/errors/git-api-error.d.ts +59 -2
  295. package/dist/errors/git-api-error.d.ts.map +1 -1
  296. package/dist/errors/index.d.ts +1 -0
  297. package/dist/errors/index.d.ts.map +1 -1
  298. package/dist/errors/index.js +371 -19
  299. package/dist/errors/rebase-errors.d.ts +9 -0
  300. package/dist/errors/rebase-errors.d.ts.map +1 -1
  301. package/dist/errors/ref-errors.d.ts +32 -0
  302. package/dist/errors/ref-errors.d.ts.map +1 -1
  303. package/dist/errors/transport-errors.d.ts +12 -2
  304. package/dist/errors/transport-errors.d.ts.map +1 -1
  305. package/dist/errors/worktree-errors.d.ts +35 -0
  306. package/dist/errors/worktree-errors.d.ts.map +1 -0
  307. package/dist/git-command-DxvwPrPB.js +7612 -0
  308. package/dist/git-command.d.ts +422 -32
  309. package/dist/git-command.d.ts.map +1 -1
  310. package/dist/git.d.ts +326 -5
  311. package/dist/git.d.ts.map +1 -1
  312. package/dist/index.d.ts +1 -1
  313. package/dist/index.d.ts.map +1 -1
  314. package/dist/index.js +5 -5
  315. package/dist/remote-config/index.d.ts +1 -0
  316. package/dist/remote-config/index.d.ts.map +1 -1
  317. package/dist/remote-config/remote-config-store.d.ts +123 -3
  318. package/dist/remote-config/remote-config-store.d.ts.map +1 -1
  319. package/dist/remote-config/remote-refs.d.ts +41 -0
  320. package/dist/remote-config/remote-refs.d.ts.map +1 -0
  321. package/dist/rename/detect-renames.d.ts +148 -0
  322. package/dist/rename/detect-renames.d.ts.map +1 -0
  323. package/dist/rename/git-similarity.d.ts +44 -0
  324. package/dist/rename/git-similarity.d.ts.map +1 -0
  325. package/dist/rename/index.d.ts +2 -0
  326. package/dist/rename/index.d.ts.map +1 -1
  327. package/dist/results/binary-patch.d.ts +11 -0
  328. package/dist/results/binary-patch.d.ts.map +1 -0
  329. package/dist/results/blame-format.d.ts +55 -0
  330. package/dist/results/blame-format.d.ts.map +1 -0
  331. package/dist/results/cherry-pick-result.d.ts +10 -0
  332. package/dist/results/cherry-pick-result.d.ts.map +1 -1
  333. package/dist/results/clone-result.d.ts +16 -0
  334. package/dist/results/clone-result.d.ts.map +1 -1
  335. package/dist/results/combined-diff.d.ts +77 -0
  336. package/dist/results/combined-diff.d.ts.map +1 -0
  337. package/dist/results/diff-entry.d.ts +32 -0
  338. package/dist/results/diff-entry.d.ts.map +1 -1
  339. package/dist/results/diff-formatter.d.ts +34 -60
  340. package/dist/results/diff-formatter.d.ts.map +1 -1
  341. package/dist/results/diff-order.d.ts +25 -0
  342. package/dist/results/diff-order.d.ts.map +1 -0
  343. package/dist/results/diff-output.d.ts +249 -0
  344. package/dist/results/diff-output.d.ts.map +1 -0
  345. package/dist/results/fetch-result.d.ts +24 -1
  346. package/dist/results/fetch-result.d.ts.map +1 -1
  347. package/dist/results/index.d.ts +5 -0
  348. package/dist/results/index.d.ts.map +1 -1
  349. package/dist/results/index.js +2 -252
  350. package/dist/results/merge-result.d.ts +15 -1
  351. package/dist/results/merge-result.d.ts.map +1 -1
  352. package/dist/results/pull-result.d.ts +12 -3
  353. package/dist/results/pull-result.d.ts.map +1 -1
  354. package/dist/results/push-result.d.ts +42 -0
  355. package/dist/results/push-result.d.ts.map +1 -1
  356. package/dist/results/quote-path.d.ts +27 -0
  357. package/dist/results/quote-path.d.ts.map +1 -0
  358. package/dist/results/rebase-result.d.ts +28 -1
  359. package/dist/results/rebase-result.d.ts.map +1 -1
  360. package/dist/results/revert-result.d.ts +10 -0
  361. package/dist/results/revert-result.d.ts.map +1 -1
  362. package/dist/results/stash-result.d.ts +5 -0
  363. package/dist/results/stash-result.d.ts.map +1 -1
  364. package/dist/results/status-result.d.ts +143 -18
  365. package/dist/results/status-result.d.ts.map +1 -1
  366. package/dist/results-BZGa2Z3I.js +2934 -0
  367. package/dist/transport-command.d.ts +56 -1
  368. package/dist/transport-command.d.ts.map +1 -1
  369. package/package.json +15 -10
  370. package/src/commands/add-command.ts +1291 -224
  371. package/src/commands/add-patch/add-interactive.ts +941 -0
  372. package/src/commands/add-patch/add-patch.ts +1169 -0
  373. package/src/commands/add-patch/index.ts +5 -0
  374. package/src/commands/add-patch/patch-backend.ts +239 -0
  375. package/src/commands/add-patch/patch-modes.ts +249 -0
  376. package/src/commands/add-patch/patch-session.ts +159 -0
  377. package/src/commands/am/am-command.ts +1111 -0
  378. package/src/commands/am/index.ts +2 -0
  379. package/src/commands/am/mailinfo.ts +1015 -0
  380. package/src/commands/am/patch-format.ts +121 -0
  381. package/src/commands/apply/apply-command.ts +832 -0
  382. package/src/commands/apply/apply-engine.ts +1603 -0
  383. package/src/commands/apply/apply-parse.ts +1209 -0
  384. package/src/commands/apply/apply-types.ts +112 -0
  385. package/src/commands/apply/index.ts +5 -0
  386. package/src/commands/apply/latin1.ts +171 -0
  387. package/src/commands/apply/whitespace.ts +260 -0
  388. package/src/commands/attributes-source.ts +96 -0
  389. package/src/commands/backfill-command.ts +694 -0
  390. package/src/commands/bisect/bisect-checkout.ts +217 -0
  391. package/src/commands/bisect/bisect-command.ts +788 -0
  392. package/src/commands/bisect/bisect-engine.ts +1079 -0
  393. package/src/commands/bisect/bisect-graph.ts +595 -0
  394. package/src/commands/bisect/bisect-quote.ts +92 -0
  395. package/src/commands/bisect/index.ts +4 -0
  396. package/src/commands/blame-command.ts +711 -986
  397. package/src/commands/branch-command.ts +354 -32
  398. package/src/commands/branch-tracking.ts +331 -0
  399. package/src/commands/checkout-command.ts +1426 -297
  400. package/src/commands/checkout-paths.ts +784 -0
  401. package/src/commands/cherry-pick-command.ts +156 -396
  402. package/src/commands/clean-command.ts +532 -85
  403. package/src/commands/clone-command.ts +826 -55
  404. package/src/commands/commit-command.ts +1781 -166
  405. package/src/commands/core-config.ts +196 -0
  406. package/src/commands/date-format.ts +668 -0
  407. package/src/commands/describe-command.ts +2 -0
  408. package/src/commands/diff-command.ts +1898 -110
  409. package/src/commands/diff-textconv.ts +50 -0
  410. package/src/commands/fetch-command.ts +1038 -79
  411. package/src/commands/format-patch-command.ts +969 -0
  412. package/src/commands/fsck/fetch-fsck.ts +229 -0
  413. package/src/commands/fsck/fsck-command.ts +3347 -0
  414. package/src/commands/fsck/fsck-loose.ts +287 -0
  415. package/src/commands/fsck/fsck-msg-ids.ts +176 -0
  416. package/src/commands/fsck/fsck-object-checks.ts +1044 -0
  417. package/src/commands/fsck/fsck-object-table.ts +363 -0
  418. package/src/commands/fsck/fsck-pack.ts +604 -0
  419. package/src/commands/fsck/index.ts +5 -0
  420. package/src/commands/fsck/verify-pack-command.ts +249 -0
  421. package/src/commands/gc-command.ts +147 -1
  422. package/src/commands/git-date.ts +895 -0
  423. package/src/commands/git-describe.ts +316 -0
  424. package/src/commands/git-hooks.ts +1472 -0
  425. package/src/commands/git-ident.ts +344 -0
  426. package/src/commands/hook-command.ts +247 -0
  427. package/src/commands/index-adder.ts +706 -0
  428. package/src/commands/index-host.ts +291 -0
  429. package/src/commands/index.ts +83 -0
  430. package/src/commands/init-command.ts +60 -11
  431. package/src/commands/local-clone.ts +183 -0
  432. package/src/commands/local-transport.ts +762 -0
  433. package/src/commands/log-command.ts +1915 -170
  434. package/src/commands/log-graph.ts +671 -0
  435. package/src/commands/log-output.ts +1359 -0
  436. package/src/commands/ls-remote-command.ts +101 -58
  437. package/src/commands/mailmap.ts +129 -0
  438. package/src/commands/merge-bases.ts +296 -0
  439. package/src/commands/merge-command.ts +1386 -491
  440. package/src/commands/merge-config.ts +25 -0
  441. package/src/commands/merge-drivers.ts +306 -0
  442. package/src/commands/merge-support.ts +1198 -0
  443. package/src/commands/message-cleanup.ts +275 -0
  444. package/src/commands/mv-command.ts +976 -0
  445. package/src/commands/notes-command.ts +890 -0
  446. package/src/commands/notes-commands.ts +87 -0
  447. package/src/commands/notes-merge-command.ts +768 -0
  448. package/src/commands/notes-support.ts +402 -0
  449. package/src/commands/notes-tree.ts +602 -0
  450. package/src/commands/object-id-input.ts +27 -0
  451. package/src/commands/octopus-merge.ts +377 -0
  452. package/src/commands/ort-merge.ts +1660 -0
  453. package/src/commands/ort-recursive.ts +160 -0
  454. package/src/commands/pack-refs-command.ts +39 -22
  455. package/src/commands/patch-id.ts +196 -0
  456. package/src/commands/pathspec-attributes.ts +162 -0
  457. package/src/commands/pathspec.ts +1199 -0
  458. package/src/commands/post-index-change.ts +62 -0
  459. package/src/commands/pretty-format.ts +1431 -0
  460. package/src/commands/promisor-remote.ts +298 -0
  461. package/src/commands/pull-command.ts +207 -22
  462. package/src/commands/push-command.ts +236 -23
  463. package/src/commands/read-tree-command.ts +857 -0
  464. package/src/commands/rebase-command.ts +3808 -371
  465. package/src/commands/rebase-todo.ts +584 -0
  466. package/src/commands/ref-decoration-filter.ts +118 -0
  467. package/src/commands/reflog-messages.ts +177 -0
  468. package/src/commands/remote-command.ts +500 -19
  469. package/src/commands/remote-transport.ts +383 -0
  470. package/src/commands/reset-command.ts +828 -91
  471. package/src/commands/restore-command.ts +350 -0
  472. package/src/commands/rev-list-command.ts +167 -0
  473. package/src/commands/rev-parse-command.ts +277 -0
  474. package/src/commands/revert-command.ts +152 -399
  475. package/src/commands/revision-filenames.ts +254 -0
  476. package/src/commands/revision-range.ts +222 -0
  477. package/src/commands/revision-resolver.ts +1379 -0
  478. package/src/commands/rm-command.ts +613 -67
  479. package/src/commands/sequencer-pick.ts +869 -0
  480. package/src/commands/sequencer-support.ts +869 -0
  481. package/src/commands/serve-repository.ts +125 -0
  482. package/src/commands/sparse-checkout-command.ts +1389 -0
  483. package/src/commands/sparse-checkout-support.ts +793 -0
  484. package/src/commands/stash-apply-command.ts +692 -124
  485. package/src/commands/stash-create-command.ts +752 -89
  486. package/src/commands/stash-drop-command.ts +67 -6
  487. package/src/commands/stash-list-command.ts +10 -4
  488. package/src/commands/stash-working-tree.ts +387 -0
  489. package/src/commands/status-command.ts +1426 -97
  490. package/src/commands/status-format.ts +775 -0
  491. package/src/commands/status-header.ts +330 -0
  492. package/src/commands/strerror.ts +29 -0
  493. package/src/commands/submodule-config.ts +94 -0
  494. package/src/commands/submodule-summary-command.ts +334 -0
  495. package/src/commands/submodule-summary.ts +446 -0
  496. package/src/commands/switch-command.ts +402 -0
  497. package/src/commands/tag-command.ts +129 -41
  498. package/src/commands/tracking-info.ts +201 -0
  499. package/src/commands/trailers.ts +417 -0
  500. package/src/commands/tree-restore.ts +344 -15
  501. package/src/commands/untracked-cache-support.ts +194 -0
  502. package/src/commands/worktree-add-command.ts +458 -0
  503. package/src/commands/worktree-list-command.ts +208 -0
  504. package/src/commands/worktree-lock-command.ts +96 -0
  505. package/src/commands/worktree-overwrite-checks.ts +641 -0
  506. package/src/commands/worktree-prune-command.ts +99 -0
  507. package/src/commands/worktree-remove-command.ts +186 -0
  508. package/src/commands/worktree-repair-command.ts +59 -0
  509. package/src/commands/worktree-support.ts +214 -0
  510. package/src/core-commands/add.command.impl.ts +9 -5
  511. package/src/core-commands/index.ts +0 -8
  512. package/src/errors/add-errors.ts +45 -0
  513. package/src/errors/checkout-errors.ts +46 -2
  514. package/src/errors/command-errors.ts +101 -1
  515. package/src/errors/commit-errors.ts +18 -2
  516. package/src/errors/git-api-error.ts +82 -2
  517. package/src/errors/index.ts +1 -0
  518. package/src/errors/merge-errors.ts +2 -2
  519. package/src/errors/rebase-errors.ts +12 -0
  520. package/src/errors/ref-errors.ts +56 -2
  521. package/src/errors/remote-errors.ts +2 -2
  522. package/src/errors/stash-errors.ts +1 -1
  523. package/src/errors/transport-errors.ts +20 -4
  524. package/src/errors/worktree-errors.ts +49 -0
  525. package/src/git-command.ts +1218 -118
  526. package/src/git.ts +552 -11
  527. package/src/index.ts +1 -1
  528. package/src/remote-config/index.ts +1 -0
  529. package/src/remote-config/remote-config-store.ts +326 -16
  530. package/src/remote-config/remote-refs.ts +119 -0
  531. package/src/rename/detect-renames.ts +711 -0
  532. package/src/rename/git-similarity.ts +116 -0
  533. package/src/rename/index.ts +2 -0
  534. package/src/results/binary-patch.ts +401 -0
  535. package/src/results/blame-format.ts +239 -0
  536. package/src/results/cherry-pick-result.ts +10 -0
  537. package/src/results/clone-result.ts +18 -0
  538. package/src/results/combined-diff.ts +585 -0
  539. package/src/results/diff-entry.ts +35 -0
  540. package/src/results/diff-formatter.ts +152 -288
  541. package/src/results/diff-order.ts +64 -0
  542. package/src/results/diff-output.ts +1051 -0
  543. package/src/results/fetch-result.ts +24 -1
  544. package/src/results/index.ts +5 -0
  545. package/src/results/merge-result.ts +15 -1
  546. package/src/results/pull-result.ts +12 -3
  547. package/src/results/push-result.ts +43 -0
  548. package/src/results/quote-path.ts +103 -0
  549. package/src/results/rebase-result.ts +37 -0
  550. package/src/results/revert-result.ts +10 -0
  551. package/src/results/stash-result.ts +6 -0
  552. package/src/results/status-result.ts +288 -27
  553. package/src/transport-command.ts +139 -2
  554. package/dist/commands-BpeXZTC3.js +0 -10278
  555. package/dist/core-commands/checkout.command.d.ts +0 -103
  556. package/dist/core-commands/checkout.command.d.ts.map +0 -1
  557. package/dist/core-commands/checkout.command.impl.d.ts +0 -110
  558. package/dist/core-commands/checkout.command.impl.d.ts.map +0 -1
  559. package/dist/status-result-BapZoQaR.js +0 -411
  560. package/src/core-commands/checkout.command.impl.ts +0 -564
  561. package/src/core-commands/checkout.command.ts +0 -125
@@ -0,0 +1,446 @@
1
+ /**
2
+ * What git's submodule.c shows of a submodule's own history: the header of a submodule's
3
+ * change (`Submodule <path> <a>..<b>:`, `show_submodule_header`), the commits between its
4
+ * two sides as `git diff --submodule=log` lists them (`show_submodule_diff_summary`), and
5
+ * the first-parent, left/right revision walk inside the submodule's repository that both
6
+ * that and `git submodule summary` (builtin/submodule--helper.c) print from.
7
+ */
8
+ import type { ObjectId } from "@statewalker/vcs-core";
9
+ import { collectChunks, type WorkingCopy } from "@statewalker/vcs-working-tree";
10
+
11
+ import { InvalidConfigError } from "../errors/index.js";
12
+ import { GitCommand } from "../git-command.js";
13
+ import { RemoteConfigStore } from "../remote-config/index.js";
14
+ import { createIdAbbreviator, type IdAbbreviator } from "./core-config.js";
15
+ import { commitsBaseSource, MergeBaseGraph } from "./merge-bases.js";
16
+ import { formatCommitPretty } from "./pretty-format.js";
17
+ import type { SubmoduleDirt } from "./status-command.js";
18
+ import { type GitmodulesEntry, parseGitmodules } from "./submodule-config.js";
19
+
20
+ /** `--submodule=<format>` / `diff.submodule`: how a submodule's change is shown. */
21
+ export type SubmoduleDiffFormat = "short" | "log" | "diff";
22
+
23
+ /** A value of `--submodule` or `diff.submodule` (diff.c `parse_submodule_params`). */
24
+ export function parseSubmoduleDiffFormat(
25
+ value: string | undefined,
26
+ ): SubmoduleDiffFormat | undefined {
27
+ return value === "short" || value === "log" || value === "diff" ? value : undefined;
28
+ }
29
+
30
+ /** `diff.submodule` as git's `git_diff_ui_config` reads it. */
31
+ export interface DiffSubmoduleConfig {
32
+ /** The last value git knows, undefined when none */
33
+ format?: SubmoduleDiffFormat;
34
+ /** `warning: Unknown value for 'diff.submodule' config variable: '<value>'`, per value */
35
+ warnings: string[];
36
+ }
37
+
38
+ /**
39
+ * `diff.submodule` as git reads it before any diff (`git_diff_ui_config`, whatever
40
+ * `--submodule` says): every value in the configuration's order, the last one it knows
41
+ * winning; each other value warns (`parse_submodule_params` fails, the warning of
42
+ * `git_diff_ui_config`). A variable without `=` fails as git 2.5x fails (`error: missing
43
+ * value for 'diff.submodule'`, then where it was read; git 2.43 crashes there).
44
+ *
45
+ * @throws InvalidConfigError for a variable without a value
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const { format, warnings } = readDiffSubmoduleConfig(workingCopy);
50
+ * ```
51
+ */
52
+ export function readDiffSubmoduleConfig(workingCopy: WorkingCopy): DiffSubmoduleConfig {
53
+ const key = "diff.submodule";
54
+ const out: DiffSubmoduleConfig = { warnings: [] };
55
+ if (!workingCopy.config) return out;
56
+ for (const { text, file, line } of RemoteConfigStore.from(workingCopy).valuesWithOrigin(key)) {
57
+ if (text === undefined) {
58
+ const where =
59
+ file !== undefined && line !== undefined
60
+ ? `fatal: bad config variable '${key}' in file '${file}' at line ${line}`
61
+ : `fatal: unable to parse '${key}' from command-line config`;
62
+ throw new InvalidConfigError(key, `error: missing value for '${key}'\n${where}`);
63
+ }
64
+ const format = parseSubmoduleDiffFormat(text);
65
+ if (format) out.format = format;
66
+ else out.warnings.push(`warning: Unknown value for '${key}' config variable: '${text}'`);
67
+ }
68
+ return out;
69
+ }
70
+
71
+ /** git's null object id: the side of a submodule that is not there. */
72
+ export const NULL_OBJECT_ID = "0".repeat(40);
73
+
74
+ const isNull = (id: ObjectId) => /^0+$/.test(id);
75
+
76
+ /** One commit of the walk, and whether it was reached from the left side (`%m` is `<`). */
77
+ export interface SubmoduleWalkCommit {
78
+ id: ObjectId;
79
+ left: boolean;
80
+ }
81
+
82
+ /** Where a walk starts: a commit, marked left (`SYMMETRIC_LEFT`) or uninteresting. */
83
+ export interface SubmoduleWalkStart {
84
+ id: ObjectId;
85
+ left?: boolean;
86
+ uninteresting?: boolean;
87
+ }
88
+
89
+ const SEEN = 1;
90
+ const UNINTERESTING = 2;
91
+ const LEFT = 4;
92
+ /** revision.c's SLOP: uninteresting commits looked at before the walk gives up */
93
+ const SLOP = 5;
94
+
95
+ /** The walk failed: a commit it had to read is missing ("revision walker failed"). */
96
+ export class SubmoduleWalkError extends Error {}
97
+
98
+ /**
99
+ * The repository of a submodule as the summaries read it: its commits, refs and
100
+ * abbreviations. Opened by {@link openSubmoduleRepository}.
101
+ */
102
+ export class SubmoduleRepository extends GitCommand<never> {
103
+ private abbreviations?: IdAbbreviator;
104
+ /** Whether the repository is the one checked out at the path (not `modules/<name>`) */
105
+ populated = false;
106
+
107
+ /** Not a command: it reads for the submodule summaries. */
108
+ async call(): Promise<never> {
109
+ throw new Error("SubmoduleRepository is not callable");
110
+ }
111
+
112
+ /** The working copy of the submodule's repository. */
113
+ get repository(): WorkingCopy {
114
+ return this.workingCopy;
115
+ }
116
+
117
+ /** git's `lookup_commit_reference`: the commit `id` names (tags peeled), else undefined. */
118
+ async commitReference(id: ObjectId): Promise<ObjectId | undefined> {
119
+ if (isNull(id)) return undefined;
120
+ return this.revisionResolver()
121
+ .commitReference(id)
122
+ .catch(() => undefined);
123
+ }
124
+
125
+ /** The commit HEAD points at, undefined when there is none. */
126
+ async head(): Promise<ObjectId | undefined> {
127
+ return (await this.refsStore.resolve("HEAD").catch(() => undefined))?.objectId;
128
+ }
129
+
130
+ /**
131
+ * git's `repo_get_merge_bases` of two commits, in git's order.
132
+ *
133
+ * @throws SubmoduleWalkError when a commit the walk reaches is missing (git 2.45 and later:
134
+ * `paint_down_to_common` fails, and the header says "(corrupt repository)")
135
+ */
136
+ async mergeBases(one: ObjectId, two: ObjectId): Promise<ObjectId[]> {
137
+ const source = commitsBaseSource(this.walkCommits, async () => new Map());
138
+ const load = source.load;
139
+ source.load = async (id) => {
140
+ const found = await load(id);
141
+ if (!found) throw new SubmoduleWalkError(`could not parse commit ${id}`);
142
+ return found;
143
+ };
144
+ const graph = new MergeBaseGraph(source);
145
+ const bases = await graph.mergeBases(graph.commit(one), graph.commit(two));
146
+ return bases.map((n) => n.id).filter((id): id is ObjectId => id !== undefined);
147
+ }
148
+
149
+ /** `id` abbreviated as this repository abbreviates it (`rev-parse --short`). */
150
+ abbreviate(id: ObjectId): Promise<string> {
151
+ this.abbreviations ??= createIdAbbreviator(this.workingCopy);
152
+ return this.abbreviations.abbreviate(id);
153
+ }
154
+
155
+ /**
156
+ * The commits of `git log --first-parent` from `starts` (git's `limit_list` with
157
+ * `first_parent_only`): newest commit date first, ties in the order queued, the commits
158
+ * reachable from an uninteresting start left out. Left marks run down the first parents.
159
+ *
160
+ * @throws SubmoduleWalkError when an interesting commit or its first parent is missing
161
+ */
162
+ async walkFirstParent(starts: SubmoduleWalkStart[]): Promise<SubmoduleWalkCommit[]> {
163
+ const commits = this.walkCommits;
164
+ const flags = new Map<ObjectId, number>();
165
+ const parentsOf = new Map<ObjectId, ObjectId[]>();
166
+ const dates = new Map<ObjectId, number>();
167
+ const flag = (id: ObjectId) => flags.get(id) ?? 0;
168
+ const set = (id: ObjectId, f: number) => flags.set(id, flag(id) | f);
169
+ const parse = async (id: ObjectId): Promise<boolean> => {
170
+ if (parentsOf.has(id)) return true;
171
+ const commit = await commits.load(id).catch(() => undefined);
172
+ if (!commit) return false;
173
+ parentsOf.set(id, commit.parents);
174
+ dates.set(id, commit.committer.timestamp);
175
+ return true;
176
+ };
177
+ // mark_parents_uninteresting: through the commits already parsed
178
+ const markParentsUninteresting = (id: ObjectId) => {
179
+ const pending = [...(parentsOf.get(id) ?? [])];
180
+ while (pending.length > 0) {
181
+ const p = pending.pop() as ObjectId;
182
+ if (flag(p) & UNINTERESTING) continue;
183
+ set(p, UNINTERESTING);
184
+ pending.push(...(parentsOf.get(p) ?? []));
185
+ }
186
+ };
187
+ // the queue: newest first, ties in insertion order (prio_queue's counter)
188
+ let counter = 0;
189
+ const queue: { id: ObjectId; date: number; ctr: number }[] = [];
190
+ const put = (id: ObjectId) => {
191
+ const entry = { id, date: dates.get(id) ?? 0, ctr: counter++ };
192
+ let at = queue.length;
193
+ while (
194
+ at > 0 &&
195
+ (queue[at - 1].date < entry.date ||
196
+ (queue[at - 1].date === entry.date && queue[at - 1].ctr > entry.ctr))
197
+ ) {
198
+ at--;
199
+ }
200
+ queue.splice(at, 0, entry);
201
+ };
202
+ for (const s of starts) set(s.id, (s.left ? LEFT : 0) | (s.uninteresting ? UNINTERESTING : 0));
203
+ // prepare_revision_walk: each start once, sorted by date (stable)
204
+ const initial: ObjectId[] = [];
205
+ for (const s of starts) {
206
+ if (!(await parse(s.id))) throw new SubmoduleWalkError(`bad object ${s.id}`);
207
+ if (flag(s.id) & UNINTERESTING) markParentsUninteresting(s.id);
208
+ if (flag(s.id) & SEEN) continue;
209
+ set(s.id, SEEN);
210
+ initial.push(s.id);
211
+ }
212
+ const sorted = initial
213
+ .map((id, i) => ({ id, i, date: dates.get(id) ?? 0 }))
214
+ .sort((a, b) => b.date - a.date || a.i - b.i);
215
+ for (const e of sorted) put(e.id);
216
+ const everybodyUninteresting = () => queue.every((e) => flag(e.id) & UNINTERESTING);
217
+ const out: ObjectId[] = [];
218
+ let slop = SLOP;
219
+ let date = Number.POSITIVE_INFINITY;
220
+ while (queue.length > 0) {
221
+ const { id } = queue.shift() as { id: ObjectId };
222
+ // process_parents
223
+ const parents = parentsOf.get(id) ?? [];
224
+ if (flag(id) & UNINTERESTING) {
225
+ for (const p of parents) {
226
+ set(p, UNINTERESTING);
227
+ if (!(await parse(p))) continue;
228
+ markParentsUninteresting(p);
229
+ if (flag(p) & SEEN) continue;
230
+ set(p, SEEN);
231
+ put(p);
232
+ }
233
+ markParentsUninteresting(id);
234
+ // still_interesting
235
+ const next = queue[0];
236
+ if (!next) break;
237
+ if (date <= next.date || !everybodyUninteresting()) slop = SLOP;
238
+ else slop--;
239
+ if (slop) continue;
240
+ break;
241
+ }
242
+ const first = parents[0];
243
+ if (first !== undefined) {
244
+ if (!(await parse(first))) throw new SubmoduleWalkError(`bad object ${first}`);
245
+ set(first, flag(id) & LEFT);
246
+ if (!(flag(first) & SEEN)) {
247
+ set(first, SEEN);
248
+ put(first);
249
+ }
250
+ }
251
+ date = dates.get(id) ?? 0;
252
+ out.push(id);
253
+ }
254
+ return out
255
+ .filter((id) => !(flag(id) & UNINTERESTING))
256
+ .map((id) => ({ id, left: (flag(id) & LEFT) !== 0 }));
257
+ }
258
+
259
+ /**
260
+ * The commits of `git log --first-parent <a>...<b>` (and `rev-list --count` of it): the
261
+ * merge bases excluded, `a`'s side marked left.
262
+ */
263
+ async symmetricWalk(a: ObjectId, b: ObjectId): Promise<SubmoduleWalkCommit[]> {
264
+ const bases = await this.mergeBases(a, b);
265
+ return this.walkFirstParent([
266
+ ...bases.map((id) => ({ id, uninteresting: true })),
267
+ { id: a, left: true },
268
+ { id: b },
269
+ ]);
270
+ }
271
+
272
+ /** One line of `--pretty=<format>` for a commit (`%m` its mark). */
273
+ async formatLine(format: string, c: SubmoduleWalkCommit): Promise<string> {
274
+ const commit = await this.walkCommits.load(c.id);
275
+ if (!commit) return "";
276
+ return `${await formatCommitPretty(format, commit, c.id, { mark: c.left ? "<" : ">" })}\n`;
277
+ }
278
+ }
279
+
280
+ /**
281
+ * The text of the superproject's `.gitmodules` as git's `config_from_gitmodules` reads it:
282
+ * the worktree's file, else the index's blob, else HEAD's; undefined without one.
283
+ */
284
+ export async function readGitmodulesEntries(
285
+ workingCopy: WorkingCopy,
286
+ ): Promise<GitmodulesEntry[] | undefined> {
287
+ const reader = new GitmodulesReader(workingCopy);
288
+ const text = await reader.call();
289
+ return text === undefined ? undefined : parseGitmodules(text);
290
+ }
291
+
292
+ class GitmodulesReader extends GitCommand<string | undefined> {
293
+ async call(): Promise<string | undefined> {
294
+ const decode = (bytes: Uint8Array) => new TextDecoder().decode(bytes);
295
+ const worktree = this.worktreeAccess;
296
+ try {
297
+ if (worktree && (await worktree.getEntry(".gitmodules"))) {
298
+ return decode(await collectChunks(worktree.readContent(".gitmodules")));
299
+ }
300
+ } catch {
301
+ // not readable: the index's
302
+ }
303
+ const blob = async (id: ObjectId) =>
304
+ decode(await collectChunks((await this.blobs.load(id)) ?? []));
305
+ const staged = await this.staging.getEntry(".gitmodules").catch(() => undefined);
306
+ if (staged) return blob(staged.objectId);
307
+ try {
308
+ return await blob(await this.resolveRevision("HEAD:.gitmodules"));
309
+ } catch {
310
+ return undefined;
311
+ }
312
+ }
313
+ }
314
+
315
+ /**
316
+ * git's `open_submodule`: the repository of the submodule at `path` (its `.git`, else the
317
+ * one kept under `<gitdir>/modules/<name>` for the name `.gitmodules` gives the path);
318
+ * undefined when there is none.
319
+ *
320
+ * Known gaps:
321
+ * - A gitfile naming a repository beyond the FilesApi's root cannot be followed here, so
322
+ * the submodule reads as holding none and the `modules/<name>` fallback is taken, where
323
+ * git reads the repository the gitfile names.
324
+ * - When `.gitmodules` gives one path to several names, the first name is taken; git's
325
+ * submodule-config cache keeps the last one read (`cache_put_path` replaces the entry).
326
+ */
327
+ export async function openSubmoduleRepository(
328
+ workingCopy: WorkingCopy,
329
+ path: string,
330
+ ): Promise<SubmoduleRepository | undefined> {
331
+ const worktree = workingCopy.worktree;
332
+ if (!worktree?.openGitlink) return undefined;
333
+ let inner = await worktree.openGitlink(path).catch(() => undefined);
334
+ const populated = inner !== undefined;
335
+ if (!inner) {
336
+ const name = (await readGitmodulesEntries(workingCopy).catch(() => undefined))?.find(
337
+ (e) => e.path === path,
338
+ )?.name;
339
+ if (name !== undefined)
340
+ inner = await worktree.openGitlink(path, { name }).catch(() => undefined);
341
+ }
342
+ if (!inner) return undefined;
343
+ const sub = new SubmoduleRepository(inner);
344
+ sub.populated = populated;
345
+ return sub;
346
+ }
347
+
348
+ /** What {@link submoduleHeader} found: the commits of both sides and their merge bases. */
349
+ export interface SubmoduleHeader {
350
+ text: string;
351
+ left?: ObjectId;
352
+ right?: ObjectId;
353
+ bases: ObjectId[];
354
+ }
355
+
356
+ /**
357
+ * submodule.c's `show_submodule_header`: the "contains untracked / modified content" lines
358
+ * of a dirty submodule, then `Submodule <path> <a>..<b>:` (`...` unless one side is an
359
+ * ancestor of the other, ` (rewind)` when the new side is the older), or the header with
360
+ * "(new submodule)", "(submodule deleted)", "(commits not present)" or "(corrupt
361
+ * repository)"; no header when both sides are the same commit. The ids are abbreviated as
362
+ * the superproject abbreviates them (`abbreviate`).
363
+ */
364
+ export async function submoduleHeader(o: {
365
+ path: string;
366
+ one: ObjectId;
367
+ two: ObjectId;
368
+ dirt?: SubmoduleDirt;
369
+ sub: SubmoduleRepository | undefined;
370
+ abbreviate: (id: ObjectId) => Promise<string>;
371
+ }): Promise<SubmoduleHeader> {
372
+ const { path, one, two, sub } = o;
373
+ let text = "";
374
+ if (o.dirt?.untracked) text += `Submodule ${path} contains untracked content\n`;
375
+ if (o.dirt?.modified) text += `Submodule ${path} contains modified content\n`;
376
+ let message: string | undefined;
377
+ if (isNull(one)) message = "(new submodule)";
378
+ else if (isNull(two)) message = "(submodule deleted)";
379
+ let left: ObjectId | undefined;
380
+ let right: ObjectId | undefined;
381
+ let bases: ObjectId[] = [];
382
+ let fastForward = false;
383
+ let fastBackward = false;
384
+ const header = async () => {
385
+ let line = `Submodule ${path} ${await o.abbreviate(one)}`;
386
+ line += fastBackward || fastForward ? ".." : "...";
387
+ line += await o.abbreviate(two);
388
+ line += message ? ` ${message}\n` : `${fastBackward ? " (rewind)" : ""}:\n`;
389
+ return line;
390
+ };
391
+ if (!sub) {
392
+ message ??= "(commits not present)";
393
+ return { text: text + (await header()), bases };
394
+ }
395
+ left = await sub.commitReference(one);
396
+ right = await sub.commitReference(two);
397
+ if ((!isNull(one) && !left) || (!isNull(two) && !right)) message = "(commits not present)";
398
+ // repo_get_merge_bases: one side missing has none; the same commit (or none on both
399
+ // sides) is its own
400
+ try {
401
+ if (left === right) bases = left !== undefined ? [left] : [];
402
+ else if (left !== undefined && right !== undefined) bases = await sub.mergeBases(left, right);
403
+ } catch {
404
+ message = "(corrupt repository)";
405
+ return { text: text + (await header()), left, right, bases: [] };
406
+ }
407
+ if (left === right) fastForward = true;
408
+ else if (bases.length > 0) {
409
+ if (bases[0] === left) fastForward = true;
410
+ else if (bases[0] === right) fastBackward = true;
411
+ }
412
+ if (one === two) return { text, left, right, bases };
413
+ return { text: text + (await header()), left, right, bases };
414
+ }
415
+
416
+ /**
417
+ * submodule.c's `show_submodule_diff_summary` (`git diff --submodule=log`): the header,
418
+ * then the commits between the two sides, ` < subject` for those only the old side has
419
+ * and ` > subject` for the new side's, as a `--left-right --first-parent` walk lists them.
420
+ */
421
+ export async function showSubmoduleDiffSummary(o: {
422
+ workingCopy: WorkingCopy;
423
+ path: string;
424
+ one: ObjectId;
425
+ two: ObjectId;
426
+ dirt?: SubmoduleDirt;
427
+ abbreviate: (id: ObjectId) => Promise<string>;
428
+ }): Promise<string> {
429
+ const sub = await openSubmoduleRepository(o.workingCopy, o.path);
430
+ const header = await submoduleHeader({ ...o, sub });
431
+ let out = header.text;
432
+ const { left, right } = header;
433
+ if (!left || !right || !sub) return out;
434
+ let walked: SubmoduleWalkCommit[];
435
+ try {
436
+ walked = await sub.walkFirstParent([
437
+ { id: left, left: true },
438
+ { id: right },
439
+ ...header.bases.map((id) => ({ id, uninteresting: true })),
440
+ ]);
441
+ } catch {
442
+ return `${out}(revision walker failed)\n`;
443
+ }
444
+ for (const c of walked) out += await sub.formatLine(" %m %s", c);
445
+ return out;
446
+ }