@statewalker/vcs-commands 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/dist/commands/add-command.d.ts +38 -0
  2. package/dist/commands/add-command.d.ts.map +1 -1
  3. package/dist/commands/am/am-command.d.ts +55 -1
  4. package/dist/commands/am/am-command.d.ts.map +1 -1
  5. package/dist/commands/am/index.d.ts +1 -0
  6. package/dist/commands/am/index.d.ts.map +1 -1
  7. package/dist/commands/am/mailsplit.d.ts +88 -0
  8. package/dist/commands/am/mailsplit.d.ts.map +1 -0
  9. package/dist/commands/apply/apply-command.d.ts.map +1 -1
  10. package/dist/commands/apply/apply-engine.d.ts.map +1 -1
  11. package/dist/commands/apply/apply-parse.d.ts.map +1 -1
  12. package/dist/commands/bisect/bisect-command.d.ts +2 -0
  13. package/dist/commands/bisect/bisect-command.d.ts.map +1 -1
  14. package/dist/commands/branch-command.d.ts +148 -18
  15. package/dist/commands/branch-command.d.ts.map +1 -1
  16. package/dist/commands/branch-info-command.d.ts +55 -0
  17. package/dist/commands/branch-info-command.d.ts.map +1 -0
  18. package/dist/commands/branch-tracking.d.ts +106 -17
  19. package/dist/commands/branch-tracking.d.ts.map +1 -1
  20. package/dist/commands/branch-upstream-command.d.ts +83 -0
  21. package/dist/commands/branch-upstream-command.d.ts.map +1 -0
  22. package/dist/commands/checkout-command.d.ts +19 -3
  23. package/dist/commands/checkout-command.d.ts.map +1 -1
  24. package/dist/commands/cherry-pick-command.d.ts +59 -0
  25. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  26. package/dist/commands/clean-command.d.ts +12 -0
  27. package/dist/commands/clean-command.d.ts.map +1 -1
  28. package/dist/commands/clone-command.d.ts.map +1 -1
  29. package/dist/commands/commit-command.d.ts +191 -5
  30. package/dist/commands/commit-command.d.ts.map +1 -1
  31. package/dist/commands/commit-reuse.d.ts +33 -0
  32. package/dist/commands/commit-reuse.d.ts.map +1 -0
  33. package/dist/commands/config-command.d.ts +236 -0
  34. package/dist/commands/config-command.d.ts.map +1 -0
  35. package/dist/commands/config-value-types.d.ts +91 -0
  36. package/dist/commands/config-value-types.d.ts.map +1 -0
  37. package/dist/commands/core-config.d.ts +20 -0
  38. package/dist/commands/core-config.d.ts.map +1 -1
  39. package/dist/commands/diff-color-config.d.ts +73 -0
  40. package/dist/commands/diff-color-config.d.ts.map +1 -0
  41. package/dist/commands/diff-command.d.ts +252 -5
  42. package/dist/commands/diff-command.d.ts.map +1 -1
  43. package/dist/commands/fetch-command.d.ts +20 -0
  44. package/dist/commands/fetch-command.d.ts.map +1 -1
  45. package/dist/commands/fmt-merge-msg-command.d.ts +124 -0
  46. package/dist/commands/fmt-merge-msg-command.d.ts.map +1 -0
  47. package/dist/commands/fork-point.d.ts +38 -0
  48. package/dist/commands/fork-point.d.ts.map +1 -0
  49. package/dist/commands/format-patch-command.d.ts +41 -1
  50. package/dist/commands/format-patch-command.d.ts.map +1 -1
  51. package/dist/commands/fsck/fetch-fsck.d.ts +51 -0
  52. package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -1
  53. package/dist/commands/gc-command.d.ts +8 -0
  54. package/dist/commands/gc-command.d.ts.map +1 -1
  55. package/dist/commands/git-describe.d.ts +4 -0
  56. package/dist/commands/git-describe.d.ts.map +1 -1
  57. package/dist/commands/git-hooks.d.ts +35 -0
  58. package/dist/commands/git-hooks.d.ts.map +1 -1
  59. package/dist/commands/grep/grep-command.d.ts +210 -0
  60. package/dist/commands/grep/grep-command.d.ts.map +1 -0
  61. package/dist/commands/grep/grep-engine.d.ts +218 -0
  62. package/dist/commands/grep/grep-engine.d.ts.map +1 -0
  63. package/dist/commands/grep/index.d.ts +3 -0
  64. package/dist/commands/grep/index.d.ts.map +1 -0
  65. package/dist/commands/index-adder.d.ts +13 -2
  66. package/dist/commands/index-adder.d.ts.map +1 -1
  67. package/dist/commands/index.d.ts +26 -0
  68. package/dist/commands/index.d.ts.map +1 -1
  69. package/dist/commands/index.js +3 -3
  70. package/dist/commands/interpret-trailers-command.d.ts +90 -0
  71. package/dist/commands/interpret-trailers-command.d.ts.map +1 -0
  72. package/dist/commands/local-transport.d.ts +36 -5
  73. package/dist/commands/local-transport.d.ts.map +1 -1
  74. package/dist/commands/log-command.d.ts +296 -11
  75. package/dist/commands/log-command.d.ts.map +1 -1
  76. package/dist/commands/log-graph.d.ts +26 -1
  77. package/dist/commands/log-graph.d.ts.map +1 -1
  78. package/dist/commands/log-output.d.ts +133 -5
  79. package/dist/commands/log-output.d.ts.map +1 -1
  80. package/dist/commands/ls-remote-command.d.ts +2 -0
  81. package/dist/commands/ls-remote-command.d.ts.map +1 -1
  82. package/dist/commands/mailmap.d.ts +30 -0
  83. package/dist/commands/mailmap.d.ts.map +1 -1
  84. package/dist/commands/merge-base-command.d.ts +60 -0
  85. package/dist/commands/merge-base-command.d.ts.map +1 -0
  86. package/dist/commands/merge-bases.d.ts +23 -0
  87. package/dist/commands/merge-bases.d.ts.map +1 -1
  88. package/dist/commands/merge-command.d.ts +96 -9
  89. package/dist/commands/merge-command.d.ts.map +1 -1
  90. package/dist/commands/merge-support.d.ts.map +1 -1
  91. package/dist/commands/mv-command.d.ts +4 -0
  92. package/dist/commands/mv-command.d.ts.map +1 -1
  93. package/dist/commands/name-rev.d.ts +48 -0
  94. package/dist/commands/name-rev.d.ts.map +1 -0
  95. package/dist/commands/notes-command.d.ts.map +1 -1
  96. package/dist/commands/pathspec-file.d.ts +39 -0
  97. package/dist/commands/pathspec-file.d.ts.map +1 -0
  98. package/dist/commands/pathspec.d.ts +3 -0
  99. package/dist/commands/pathspec.d.ts.map +1 -1
  100. package/dist/commands/pretty-format.d.ts +43 -3
  101. package/dist/commands/pretty-format.d.ts.map +1 -1
  102. package/dist/commands/promisor-remote.d.ts.map +1 -1
  103. package/dist/commands/pull-command.d.ts +10 -0
  104. package/dist/commands/pull-command.d.ts.map +1 -1
  105. package/dist/commands/push-command.d.ts +160 -9
  106. package/dist/commands/push-command.d.ts.map +1 -1
  107. package/dist/commands/read-tree-command.d.ts +6 -0
  108. package/dist/commands/read-tree-command.d.ts.map +1 -1
  109. package/dist/commands/rebase-command.d.ts +168 -6
  110. package/dist/commands/rebase-command.d.ts.map +1 -1
  111. package/dist/commands/ref-filter/for-each-ref-command.d.ts +121 -0
  112. package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -0
  113. package/dist/commands/ref-filter/index.d.ts +8 -0
  114. package/dist/commands/ref-filter/index.d.ts.map +1 -0
  115. package/dist/commands/ref-filter/ref-atoms.d.ts +88 -0
  116. package/dist/commands/ref-filter/ref-atoms.d.ts.map +1 -0
  117. package/dist/commands/ref-filter/ref-filter.d.ts +178 -0
  118. package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -0
  119. package/dist/commands/ref-filter/ref-format.d.ts +222 -0
  120. package/dist/commands/ref-filter/ref-format.d.ts.map +1 -0
  121. package/dist/commands/ref-filter/ref-listing-command.d.ts +56 -0
  122. package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -0
  123. package/dist/commands/ref-filter/ref-quote.d.ts +20 -0
  124. package/dist/commands/ref-filter/ref-quote.d.ts.map +1 -0
  125. package/dist/commands/ref-filter/version-compare.d.ts +20 -0
  126. package/dist/commands/ref-filter/version-compare.d.ts.map +1 -0
  127. package/dist/commands/reflog-command.d.ts +120 -0
  128. package/dist/commands/reflog-command.d.ts.map +1 -1
  129. package/dist/commands/reflog-walk.d.ts +72 -0
  130. package/dist/commands/reflog-walk.d.ts.map +1 -0
  131. package/dist/commands/remote-command.d.ts +138 -29
  132. package/dist/commands/remote-command.d.ts.map +1 -1
  133. package/dist/commands/remote-transport.d.ts +7 -1
  134. package/dist/commands/remote-transport.d.ts.map +1 -1
  135. package/dist/commands/reset-command.d.ts +2 -3
  136. package/dist/commands/reset-command.d.ts.map +1 -1
  137. package/dist/commands/restore-command.d.ts +2 -3
  138. package/dist/commands/restore-command.d.ts.map +1 -1
  139. package/dist/commands/rev-filter/commit-filter.d.ts +95 -0
  140. package/dist/commands/rev-filter/commit-filter.d.ts.map +1 -0
  141. package/dist/commands/rev-filter/commit-grep.d.ts +91 -0
  142. package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -0
  143. package/dist/commands/rev-filter/index.d.ts +3 -0
  144. package/dist/commands/rev-filter/index.d.ts.map +1 -0
  145. package/dist/commands/rev-list-command.d.ts +154 -2
  146. package/dist/commands/rev-list-command.d.ts.map +1 -1
  147. package/dist/commands/revert-command.d.ts +32 -0
  148. package/dist/commands/revert-command.d.ts.map +1 -1
  149. package/dist/commands/revision-range.d.ts +32 -1
  150. package/dist/commands/revision-range.d.ts.map +1 -1
  151. package/dist/commands/revision-resolver.d.ts +15 -0
  152. package/dist/commands/revision-resolver.d.ts.map +1 -1
  153. package/dist/commands/rm-command.d.ts +70 -2
  154. package/dist/commands/rm-command.d.ts.map +1 -1
  155. package/dist/commands/sequencer-pick.d.ts +84 -4
  156. package/dist/commands/sequencer-pick.d.ts.map +1 -1
  157. package/dist/commands/sequencer-support.d.ts +2 -0
  158. package/dist/commands/sequencer-support.d.ts.map +1 -1
  159. package/dist/commands/serve-repository.d.ts +7 -0
  160. package/dist/commands/serve-repository.d.ts.map +1 -1
  161. package/dist/commands/show-command.d.ts +130 -0
  162. package/dist/commands/show-command.d.ts.map +1 -0
  163. package/dist/commands/show-commit.d.ts +11 -0
  164. package/dist/commands/show-commit.d.ts.map +1 -0
  165. package/dist/commands/signature-check.d.ts +164 -0
  166. package/dist/commands/signature-check.d.ts.map +1 -0
  167. package/dist/commands/signing.d.ts +160 -0
  168. package/dist/commands/signing.d.ts.map +1 -0
  169. package/dist/commands/sparse-checkout-command.d.ts.map +1 -1
  170. package/dist/commands/sparse-index-view.d.ts +45 -0
  171. package/dist/commands/sparse-index-view.d.ts.map +1 -0
  172. package/dist/commands/ssh-signer.d.ts +29 -0
  173. package/dist/commands/ssh-signer.d.ts.map +1 -0
  174. package/dist/commands/ssh-verifier.d.ts +42 -0
  175. package/dist/commands/ssh-verifier.d.ts.map +1 -0
  176. package/dist/commands/stash-apply-command.d.ts +5 -0
  177. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  178. package/dist/commands/stash-branch-command.d.ts +34 -0
  179. package/dist/commands/stash-branch-command.d.ts.map +1 -0
  180. package/dist/commands/stash-create-command.d.ts +17 -0
  181. package/dist/commands/stash-create-command.d.ts.map +1 -1
  182. package/dist/commands/stash-info.d.ts +93 -0
  183. package/dist/commands/stash-info.d.ts.map +1 -0
  184. package/dist/commands/stash-list-command.d.ts +16 -0
  185. package/dist/commands/stash-list-command.d.ts.map +1 -1
  186. package/dist/commands/stash-pop-command.d.ts +39 -0
  187. package/dist/commands/stash-pop-command.d.ts.map +1 -0
  188. package/dist/commands/stash-show-command.d.ts +48 -0
  189. package/dist/commands/stash-show-command.d.ts.map +1 -0
  190. package/dist/commands/stash-store-command.d.ts +29 -0
  191. package/dist/commands/stash-store-command.d.ts.map +1 -0
  192. package/dist/commands/stash-working-tree.d.ts.map +1 -1
  193. package/dist/commands/status-command.d.ts.map +1 -1
  194. package/dist/commands/status-header.d.ts +5 -0
  195. package/dist/commands/status-header.d.ts.map +1 -1
  196. package/dist/commands/submodule-add-command.d.ts +89 -0
  197. package/dist/commands/submodule-add-command.d.ts.map +1 -0
  198. package/dist/commands/submodule-auth.d.ts +90 -0
  199. package/dist/commands/submodule-auth.d.ts.map +1 -0
  200. package/dist/commands/submodule-commands.d.ts +375 -0
  201. package/dist/commands/submodule-commands.d.ts.map +1 -0
  202. package/dist/commands/submodule-model.d.ts +288 -0
  203. package/dist/commands/submodule-model.d.ts.map +1 -0
  204. package/dist/commands/submodule-update-command.d.ts +198 -0
  205. package/dist/commands/submodule-update-command.d.ts.map +1 -0
  206. package/dist/commands/switch-command.d.ts.map +1 -1
  207. package/dist/commands/tag-command.d.ts +259 -10
  208. package/dist/commands/tag-command.d.ts.map +1 -1
  209. package/dist/commands/trailers.d.ts +218 -17
  210. package/dist/commands/trailers.d.ts.map +1 -1
  211. package/dist/commands/tree-restore.d.ts +7 -0
  212. package/dist/commands/tree-restore.d.ts.map +1 -1
  213. package/dist/commands/verify-command.d.ts +92 -0
  214. package/dist/commands/verify-command.d.ts.map +1 -0
  215. package/dist/commands/worktree-add-command.d.ts +79 -7
  216. package/dist/commands/worktree-add-command.d.ts.map +1 -1
  217. package/dist/commands/worktree-path-rules.d.ts +66 -0
  218. package/dist/commands/worktree-path-rules.d.ts.map +1 -0
  219. package/dist/commands/worktree-remove-command.d.ts +10 -3
  220. package/dist/commands/worktree-remove-command.d.ts.map +1 -1
  221. package/dist/commands/worktree-repair-command.d.ts +15 -2
  222. package/dist/commands/worktree-repair-command.d.ts.map +1 -1
  223. package/dist/commands/worktree-support.d.ts +5 -0
  224. package/dist/commands/worktree-support.d.ts.map +1 -1
  225. package/dist/{commands-DIJ91NnD.js → commands-ISM52N0n.js} +70736 -54492
  226. package/dist/errors/checkout-errors.d.ts +19 -0
  227. package/dist/errors/checkout-errors.d.ts.map +1 -1
  228. package/dist/errors/command-errors.d.ts.map +1 -1
  229. package/dist/errors/index.js +57 -3
  230. package/dist/errors/ref-errors.d.ts +19 -0
  231. package/dist/errors/ref-errors.d.ts.map +1 -1
  232. package/dist/errors/worktree-errors.d.ts +6 -1
  233. package/dist/errors/worktree-errors.d.ts.map +1 -1
  234. package/dist/{git-command-BGiOJ8Zk.js → fsck-DLRpbwTj.js} +6230 -71
  235. package/dist/git-command.d.ts +27 -1
  236. package/dist/git-command.d.ts.map +1 -1
  237. package/dist/git.d.ts +267 -1
  238. package/dist/git.d.ts.map +1 -1
  239. package/dist/index.js +5 -5
  240. package/dist/remote-config/index.d.ts +1 -1
  241. package/dist/remote-config/index.d.ts.map +1 -1
  242. package/dist/remote-config/remote-config-store.d.ts +55 -0
  243. package/dist/remote-config/remote-config-store.d.ts.map +1 -1
  244. package/dist/results/combined-diff.d.ts +3 -0
  245. package/dist/results/combined-diff.d.ts.map +1 -1
  246. package/dist/results/diff-check.d.ts +38 -0
  247. package/dist/results/diff-check.d.ts.map +1 -0
  248. package/dist/results/diff-color.d.ts +135 -0
  249. package/dist/results/diff-color.d.ts.map +1 -0
  250. package/dist/results/diff-output.d.ts +85 -1
  251. package/dist/results/diff-output.d.ts.map +1 -1
  252. package/dist/results/diff-pickaxe.d.ts +67 -0
  253. package/dist/results/diff-pickaxe.d.ts.map +1 -0
  254. package/dist/results/diff-words.d.ts +55 -0
  255. package/dist/results/diff-words.d.ts.map +1 -0
  256. package/dist/results/index.d.ts +4 -0
  257. package/dist/results/index.d.ts.map +1 -1
  258. package/dist/results/index.js +2 -2
  259. package/dist/results/push-result.d.ts +7 -0
  260. package/dist/results/push-result.d.ts.map +1 -1
  261. package/dist/results/rebase-result.d.ts +2 -0
  262. package/dist/results/rebase-result.d.ts.map +1 -1
  263. package/dist/results/stash-result.d.ts +6 -0
  264. package/dist/results/stash-result.d.ts.map +1 -1
  265. package/dist/{results-WVlBhVb1.js → results-TB2IJ64h.js} +2168 -403
  266. package/dist/whitespace/index.d.ts +2 -0
  267. package/dist/whitespace/index.d.ts.map +1 -0
  268. package/dist/whitespace/whitespace-rule.d.ts +94 -0
  269. package/dist/whitespace/whitespace-rule.d.ts.map +1 -0
  270. package/package.json +12 -12
  271. package/src/commands/add-command.ts +178 -17
  272. package/src/commands/am/am-command.ts +262 -42
  273. package/src/commands/am/index.ts +1 -0
  274. package/src/commands/am/mailsplit.ts +326 -0
  275. package/src/commands/apply/apply-command.ts +6 -6
  276. package/src/commands/apply/apply-engine.ts +1 -1
  277. package/src/commands/apply/apply-parse.ts +7 -8
  278. package/src/commands/bisect/bisect-command.ts +18 -5
  279. package/src/commands/branch-command.ts +528 -53
  280. package/src/commands/branch-info-command.ts +150 -0
  281. package/src/commands/branch-tracking.ts +335 -60
  282. package/src/commands/branch-upstream-command.ts +218 -0
  283. package/src/commands/checkout-command.ts +69 -43
  284. package/src/commands/cherry-pick-command.ts +143 -0
  285. package/src/commands/clean-command.ts +34 -3
  286. package/src/commands/clone-command.ts +2 -1
  287. package/src/commands/commit-command.ts +782 -64
  288. package/src/commands/commit-reuse.ts +94 -0
  289. package/src/commands/config-command.ts +1256 -0
  290. package/src/commands/config-value-types.ts +358 -0
  291. package/src/commands/core-config.ts +40 -0
  292. package/src/commands/diff-color-config.ts +274 -0
  293. package/src/commands/diff-command.ts +1009 -49
  294. package/src/commands/fetch-command.ts +142 -8
  295. package/src/commands/fmt-merge-msg-command.ts +715 -0
  296. package/src/commands/fork-point.ts +63 -0
  297. package/src/commands/format-patch-command.ts +314 -46
  298. package/src/commands/fsck/fetch-fsck.ts +172 -18
  299. package/src/commands/gc-command.ts +31 -1
  300. package/src/commands/git-describe.ts +31 -11
  301. package/src/commands/git-hooks.ts +81 -0
  302. package/src/commands/grep/grep-command.ts +1077 -0
  303. package/src/commands/grep/grep-engine.ts +1024 -0
  304. package/src/commands/grep/index.ts +2 -0
  305. package/src/commands/index-adder.ts +46 -7
  306. package/src/commands/index.ts +26 -0
  307. package/src/commands/interpret-trailers-command.ts +256 -0
  308. package/src/commands/local-transport.ts +109 -10
  309. package/src/commands/log-command.ts +1246 -210
  310. package/src/commands/log-graph.ts +123 -26
  311. package/src/commands/log-output.ts +280 -21
  312. package/src/commands/ls-remote-command.ts +5 -0
  313. package/src/commands/mailmap.ts +119 -0
  314. package/src/commands/merge-base-command.ts +170 -0
  315. package/src/commands/merge-bases.ts +63 -8
  316. package/src/commands/merge-command.ts +330 -82
  317. package/src/commands/merge-support.ts +14 -1
  318. package/src/commands/mv-command.ts +6 -3
  319. package/src/commands/name-rev.ts +171 -0
  320. package/src/commands/notes-command.ts +11 -1
  321. package/src/commands/pathspec-file.ts +72 -0
  322. package/src/commands/pathspec.ts +14 -2
  323. package/src/commands/pretty-format.ts +103 -19
  324. package/src/commands/promisor-remote.ts +10 -1
  325. package/src/commands/pull-command.ts +26 -7
  326. package/src/commands/push-command.ts +682 -65
  327. package/src/commands/read-tree-command.ts +28 -1
  328. package/src/commands/rebase-command.ts +933 -129
  329. package/src/commands/ref-filter/for-each-ref-command.ts +298 -0
  330. package/src/commands/ref-filter/index.ts +7 -0
  331. package/src/commands/ref-filter/ref-atoms.ts +581 -0
  332. package/src/commands/ref-filter/ref-filter.ts +651 -0
  333. package/src/commands/ref-filter/ref-format.ts +1070 -0
  334. package/src/commands/ref-filter/ref-listing-command.ts +421 -0
  335. package/src/commands/ref-filter/ref-quote.ts +69 -0
  336. package/src/commands/ref-filter/version-compare.ts +177 -0
  337. package/src/commands/reflog-command.ts +492 -2
  338. package/src/commands/reflog-walk.ts +234 -0
  339. package/src/commands/remote-command.ts +449 -69
  340. package/src/commands/remote-transport.ts +9 -1
  341. package/src/commands/reset-command.ts +36 -31
  342. package/src/commands/restore-command.ts +12 -41
  343. package/src/commands/rev-filter/commit-filter.ts +159 -0
  344. package/src/commands/rev-filter/commit-grep.ts +444 -0
  345. package/src/commands/rev-filter/index.ts +2 -0
  346. package/src/commands/rev-list-command.ts +402 -15
  347. package/src/commands/revert-command.ts +82 -0
  348. package/src/commands/revision-range.ts +204 -4
  349. package/src/commands/revision-resolver.ts +23 -8
  350. package/src/commands/rm-command.ts +282 -21
  351. package/src/commands/sequencer-pick.ts +498 -85
  352. package/src/commands/sequencer-support.ts +20 -2
  353. package/src/commands/serve-repository.ts +18 -3
  354. package/src/commands/show-command.ts +490 -0
  355. package/src/commands/show-commit.ts +24 -0
  356. package/src/commands/signature-check.ts +657 -0
  357. package/src/commands/signing.ts +385 -0
  358. package/src/commands/sparse-checkout-command.ts +2 -9
  359. package/src/commands/sparse-checkout-support.ts +2 -2
  360. package/src/commands/sparse-index-view.ts +135 -0
  361. package/src/commands/ssh-signer.ts +199 -0
  362. package/src/commands/ssh-verifier.ts +523 -0
  363. package/src/commands/stash-apply-command.ts +16 -4
  364. package/src/commands/stash-branch-command.ts +88 -0
  365. package/src/commands/stash-create-command.ts +28 -0
  366. package/src/commands/stash-info.ts +243 -0
  367. package/src/commands/stash-list-command.ts +33 -0
  368. package/src/commands/stash-pop-command.ts +83 -0
  369. package/src/commands/stash-show-command.ts +141 -0
  370. package/src/commands/stash-store-command.ts +82 -0
  371. package/src/commands/stash-working-tree.ts +2 -2
  372. package/src/commands/status-command.ts +5 -2
  373. package/src/commands/status-header.ts +41 -7
  374. package/src/commands/submodule-add-command.ts +509 -0
  375. package/src/commands/submodule-auth.ts +276 -0
  376. package/src/commands/submodule-commands.ts +1517 -0
  377. package/src/commands/submodule-model.ts +930 -0
  378. package/src/commands/submodule-update-command.ts +1092 -0
  379. package/src/commands/switch-command.ts +3 -1
  380. package/src/commands/tag-command.ts +876 -64
  381. package/src/commands/trailers.ts +837 -100
  382. package/src/commands/tree-restore.ts +38 -10
  383. package/src/commands/verify-command.ts +235 -0
  384. package/src/commands/worktree-add-command.ts +268 -24
  385. package/src/commands/worktree-path-rules.ts +183 -0
  386. package/src/commands/worktree-remove-command.ts +39 -5
  387. package/src/commands/worktree-repair-command.ts +52 -5
  388. package/src/commands/worktree-support.ts +22 -1
  389. package/src/errors/checkout-errors.ts +29 -0
  390. package/src/errors/command-errors.ts +2 -1
  391. package/src/errors/ref-errors.ts +23 -0
  392. package/src/errors/worktree-errors.ts +8 -1
  393. package/src/git-command.ts +66 -1
  394. package/src/git.ts +404 -1
  395. package/src/remote-config/index.ts +2 -0
  396. package/src/remote-config/remote-config-store.ts +101 -0
  397. package/src/results/combined-diff.ts +38 -18
  398. package/src/results/diff-check.ts +185 -0
  399. package/src/results/diff-color.ts +868 -0
  400. package/src/results/diff-output.ts +195 -30
  401. package/src/results/diff-pickaxe.ts +304 -0
  402. package/src/results/diff-words.ts +395 -0
  403. package/src/results/index.ts +4 -0
  404. package/src/results/push-result.ts +7 -0
  405. package/src/results/rebase-result.ts +3 -0
  406. package/src/results/stash-result.ts +7 -0
  407. package/src/whitespace/index.ts +1 -0
  408. package/src/{commands/apply/whitespace.ts → whitespace/whitespace-rule.ts} +173 -23
  409. package/dist/commands/apply/whitespace.d.ts +0 -58
  410. package/dist/commands/apply/whitespace.d.ts.map +0 -1
@@ -0,0 +1,2 @@
1
+ export * from "./grep-command.js";
2
+ export * from "./grep-engine.js";
@@ -8,6 +8,7 @@ import {
8
8
  FileMode,
9
9
  isValidWorktreePath,
10
10
  type ObjectId,
11
+ type WorktreePathOptions,
11
12
  } from "@statewalker/vcs-core";
12
13
  import { compareGitPaths, foldAsciiCase } from "@statewalker/vcs-utils/encoding";
13
14
  import {
@@ -30,6 +31,7 @@ import {
30
31
  wholeSeconds,
31
32
  } from "@statewalker/vcs-working-tree";
32
33
  import { storeWorktreeFile } from "../core-commands/index.js";
34
+ import { strerror } from "./strerror.js";
33
35
 
34
36
  const SURROGATE = /[\ud800-\udfff]/;
35
37
 
@@ -58,6 +60,19 @@ export interface AddToIndexOptions {
58
60
  indexed?: StagingEntry;
59
61
  }
60
62
 
63
+ /**
64
+ * A file `index_path` cannot open (an errno such as EACCES): git's `error_errno` of its
65
+ * `open`, then add_to_index's "unable to index file" line. Anything else is rethrown.
66
+ */
67
+ function unreadable(path: string, error: unknown): never {
68
+ const code = (error as { code?: unknown })?.code;
69
+ if (typeof code !== "string" || !/^E[A-Z]+$/.test(code) || code === "ENOENT") throw error;
70
+ throw new AddToIndexError(path, [
71
+ `error: open("${path}"): ${strerror(error)}`,
72
+ `error: unable to index file '${path}'`,
73
+ ]);
74
+ }
75
+
61
76
  /** A path `add_to_index` cannot add: git's error lines (`fatal: adding files failed` follows). */
62
77
  export class AddToIndexError extends Error {
63
78
  constructor(
@@ -184,13 +199,29 @@ export async function chmodIndexEntries(
184
199
  staging: Staging,
185
200
  flip: "+" | "-",
186
201
  matches: (entry: StagingEntry) => boolean,
187
- options: { pretend?: boolean } = {},
202
+ /**
203
+ * `includeSkipWorktree`: skip-worktree entries too (`git add --sparse --chmod`);
204
+ * `collapsed`: sparse directories git holds as one entry each (`out/`), refused as any
205
+ * entry that is no regular file when matched
206
+ */
207
+ options: { pretend?: boolean; includeSkipWorktree?: boolean; collapsed?: readonly string[] } = {},
188
208
  ): Promise<string[]> {
189
209
  const errors: string[] = [];
190
210
  const editor = staging.createEditor();
191
211
  const touched: string[] = [];
212
+ const collapsed = options.collapsed ?? [];
213
+ let lastDir: string | undefined;
192
214
  for await (const entry of staging.entries()) {
193
- if (entry.skipWorktree || !matches(entry)) continue;
215
+ const dir = collapsed.find((d) => entry.path.startsWith(d));
216
+ if (dir) {
217
+ if (dir !== lastDir) {
218
+ lastDir = dir;
219
+ const dirEntry: StagingEntry = { ...entry, path: dir, mode: FileMode.TREE };
220
+ if (matches(dirEntry)) errors.push(`error: cannot chmod ${flip}x '${dir}'`);
221
+ }
222
+ continue;
223
+ }
224
+ if ((entry.skipWorktree && !options.includeSkipWorktree) || !matches(entry)) continue;
194
225
  if ((entry.mode & 0o170000) !== 0o100000) {
195
226
  errors.push(`error: cannot chmod ${flip}x '${entry.path}'`);
196
227
  continue;
@@ -261,6 +292,8 @@ export class IndexAdder {
261
292
  private readonly trust: WorktreeModeTrust,
262
293
  /** git's `ADD_CACHE_PRETEND` (`add --dry-run`): nothing is written or edited */
263
294
  private readonly pretend: boolean,
295
+ /** `verify_path`'s rules (`core.protectNTFS`, `core.protectHFS`; default both on) */
296
+ private readonly pathRules: WorktreePathOptions = {},
264
297
  ) {
265
298
  this.editor = staging.createEditor();
266
299
  this.indexTime = staging.getUpdateTime();
@@ -274,9 +307,15 @@ export class IndexAdder {
274
307
  staging: Staging,
275
308
  blobs: Blobs,
276
309
  trust: WorktreeModeTrust,
277
- options: { pretend?: boolean } = {},
310
+ options: { pretend?: boolean; pathRules?: WorktreePathOptions } = {},
278
311
  ): Promise<IndexAdder> {
279
- const adder = new IndexAdder(staging, blobs, trust, options.pretend === true);
312
+ const adder = new IndexAdder(
313
+ staging,
314
+ blobs,
315
+ trust,
316
+ options.pretend === true,
317
+ options.pathRules,
318
+ );
280
319
  const take = (entry: StagingEntry) => {
281
320
  if (entry.stage === 0) {
282
321
  adder.basePaths.push(entry.path);
@@ -396,7 +435,7 @@ export class IndexAdder {
396
435
  // add_index_entry's verify_path (after the file is hashed; never with ADD_CACHE_PRETEND)
397
436
  if (!this.pretend) {
398
437
  const mode = modeFromWorktree(entry.mode, indexed?.mode, this.trust);
399
- if (!isValidWorktreePath(name, mode)) {
438
+ if (!isValidWorktreePath(name, mode, this.pathRules)) {
400
439
  const shown = options.displayPath ?? path;
401
440
  throw new AddToIndexError(path, [
402
441
  `error: invalid path '${shown}'`,
@@ -437,7 +476,7 @@ export class IndexAdder {
437
476
  const known = indexed ?? this.unmerged.get(name)?.[0];
438
477
  if (this.pretend) {
439
478
  // git's ADD_CACHE_PRETEND: hashed, never written
440
- const id = await worktree.computeHash(path);
479
+ const id = await worktree.computeHash(path).catch((error) => unreadable(path, error));
441
480
  const mode = modeFromWorktree(entry.mode, known?.mode, this.trust);
442
481
  return indexed && indexed.objectId === id && indexed.mode === mode ? "same" : "added";
443
482
  }
@@ -445,7 +484,7 @@ export class IndexAdder {
445
484
  const stored = await storeWorktreeFile(this.blobs, worktree, path, entry, {
446
485
  onWarning: options.onWarning,
447
486
  ...(options.renormalize ? { renormalize: true } : {}),
448
- });
487
+ }).catch((error) => unreadable(path, error));
449
488
  const mode = modeFromWorktree(stored.entry.mode, known?.mode, this.trust);
450
489
  this.stage(name, stored.id, mode, entryStatOf(stored.entry));
451
490
  return indexed && indexed.objectId === stored.id && indexed.mode === mode ? "same" : "added";
@@ -6,7 +6,9 @@ export * from "./backfill-command.js";
6
6
  export * from "./bisect/index.js";
7
7
  export * from "./blame-command.js";
8
8
  export * from "./branch-command.js";
9
+ export * from "./branch-info-command.js";
9
10
  export { TrackMode } from "./branch-tracking.js";
11
+ export * from "./branch-upstream-command.js";
10
12
  export * from "./checkout-command.js";
11
13
  export * from "./checkout-paths.js";
12
14
  export * from "./cherry-pick-command.js";
@@ -14,18 +16,22 @@ export * from "./clean-command.js";
14
16
  export * from "./clone-command.js";
15
17
  export * from "./comment-char-config.js";
16
18
  export * from "./commit-command.js";
19
+ export * from "./config-command.js";
17
20
  export * from "./date-format.js";
18
21
  export * from "./default-branch.js";
19
22
  export * from "./describe-command.js";
23
+ export * from "./diff-color-config.js";
20
24
  export * from "./diff-command.js";
21
25
  export * from "./diff-textconv.js";
22
26
  export * from "./fetch-command.js";
27
+ export * from "./fmt-merge-msg-command.js";
23
28
  export * from "./format-patch-command.js";
24
29
  export * from "./fsck/index.js";
25
30
  export * from "./gc-command.js";
26
31
  export * from "./git-describe.js";
27
32
  export * from "./git-hooks.js";
28
33
  export * from "./git-ident.js";
34
+ export * from "./grep/index.js";
29
35
  export * from "./hook-command.js";
30
36
  export {
31
37
  IndexVersionConfigError,
@@ -34,12 +40,14 @@ export {
34
40
  takeIndexWarnings,
35
41
  } from "./index-host.js";
36
42
  export * from "./init-command.js";
43
+ export * from "./interpret-trailers-command.js";
37
44
  export { httpBackendEnv, quarantineEnv, remoteHookSession } from "./local-transport.js";
38
45
  export * from "./log-command.js";
39
46
  export * from "./log-graph.js";
40
47
  export * from "./log-output.js";
41
48
  export * from "./ls-remote-command.js";
42
49
  export * from "./mailmap.js";
50
+ export * from "./merge-base-command.js";
43
51
  export * from "./merge-command.js";
44
52
  export {
45
53
  createMergeDriver,
@@ -73,6 +81,7 @@ export * from "./push-command.js";
73
81
  export * from "./read-tree-command.js";
74
82
  export * from "./rebase-command.js";
75
83
  export * from "./ref-decoration-filter.js";
84
+ export * from "./ref-filter/index.js";
76
85
  export * from "./reflog-command.js";
77
86
  export {
78
87
  committerIdent,
@@ -82,6 +91,7 @@ export {
82
91
  export * from "./remote-command.js";
83
92
  export * from "./reset-command.js";
84
93
  export * from "./restore-command.js";
94
+ export * from "./rev-filter/index.js";
85
95
  export * from "./rev-list-command.js";
86
96
  export * from "./rev-parse-command.js";
87
97
  export * from "./revert-command.js";
@@ -91,19 +101,35 @@ export * from "./revision-resolver.js";
91
101
  export * from "./rm-command.js";
92
102
  export { SequencerOperation } from "./sequencer-pick.js";
93
103
  export * from "./serve-repository.js";
104
+ export * from "./show-command.js";
105
+ export * from "./signature-check.js";
106
+ export * from "./signing.js";
94
107
  export * from "./sparse-checkout-command.js";
108
+ export * from "./ssh-signer.js";
109
+ export * from "./ssh-verifier.js";
95
110
  export * from "./stash-apply-command.js";
111
+ export * from "./stash-branch-command.js";
96
112
  export * from "./stash-create-command.js";
97
113
  export * from "./stash-drop-command.js";
114
+ export * from "./stash-info.js";
98
115
  export * from "./stash-list-command.js";
116
+ export * from "./stash-pop-command.js";
117
+ export * from "./stash-show-command.js";
118
+ export * from "./stash-store-command.js";
99
119
  export * from "./stash-working-tree.js";
100
120
  export * from "./status-command.js";
101
121
  export * from "./status-format.js";
122
+ export * from "./submodule-add-command.js";
123
+ export * from "./submodule-auth.js";
124
+ export * from "./submodule-commands.js";
125
+ export * from "./submodule-model.js";
102
126
  export * from "./submodule-summary.js";
103
127
  export * from "./submodule-summary-command.js";
128
+ export * from "./submodule-update-command.js";
104
129
  export * from "./switch-command.js";
105
130
  export * from "./tag-command.js";
106
131
  export * from "./trailers.js";
132
+ export * from "./verify-command.js";
107
133
  export * from "./worktree-add-command.js";
108
134
  export * from "./worktree-list-command.js";
109
135
  export * from "./worktree-lock-command.js";
@@ -0,0 +1,256 @@
1
+ /**
2
+ * `git interpret-trailers` (builtin/interpret-trailers.c) as a library command.
3
+ *
4
+ * ```typescript
5
+ * const { stdout } = await git
6
+ * .interpretTrailers()
7
+ * .setInput("Fix the parser\n")
8
+ * .addTrailer("Reviewed-by: R <r@example.com>")
9
+ * .setWhere("start")
10
+ * .addTrailer("Bug: 42")
11
+ * .call();
12
+ * // "Fix the parser\n\nBug: 42\nReviewed-by: R <r@example.com>\n"
13
+ *
14
+ * const parsed = await git.interpretTrailers().setInput(message).setParse(true).call();
15
+ * parsed.stdout; // the trailers alone, unfolded
16
+ * ```
17
+ */
18
+
19
+ import { GitApiError } from "../errors/index.js";
20
+ import { GitCommand } from "../git-command.js";
21
+ import {
22
+ type NewTrailer,
23
+ processTrailers,
24
+ type TrailerCommandRunner,
25
+ type TrailerIfExists,
26
+ type TrailerIfMissing,
27
+ type TrailerWhere,
28
+ trailerConfigOf,
29
+ } from "./trailers.js";
30
+
31
+ /** What {@link InterpretTrailersCommand} gave. */
32
+ export interface InterpretTrailersCommandResult {
33
+ /** git's stdout: each input with its trailers (nothing for files edited in place) */
34
+ stdout: string;
35
+ /**
36
+ * git's stderr: the configuration's warnings, `error:` lines (an empty trailer token, a
37
+ * failed trailer command) and what the trailer commands wrote there
38
+ */
39
+ stderr: string;
40
+ }
41
+
42
+ const encoder = new TextEncoder();
43
+ const decoder = new TextDecoder();
44
+
45
+ /**
46
+ * Add or parse the trailers of messages, as `git interpret-trailers [--in-place]
47
+ * [--trim-empty] [(--trailer <key>[(=|:)<value>])...] [--parse] [<file>...]`.
48
+ *
49
+ * The input is {@link setInput} (git's stdin) or the files added with {@link addFile} (paths
50
+ * from the worktree top, through the repository's FilesApi), each completed with a line end.
51
+ * The `trailer.*` configuration applies (`trailer.<key>.key`, `.where`, `.ifexists`,
52
+ * `.ifmissing`, `.cmd`, `.command`, `trailer.separators`, the defaults); `--where`,
53
+ * `--if-exists` and `--if-missing` apply to the trailers added after them, as on git's
54
+ * command line ({@link setWhere} with undefined is `--no-where`). Trailer commands run through
55
+ * the host environment's hook runner (`sh -c`, in the worktree top, without the variables
56
+ * naming the repository); without a runner none runs: a trailer keeps the value given and
57
+ * `trailer.<key>.command` adds no trailer of its own.
58
+ */
59
+ export class InterpretTrailersCommand extends GitCommand<InterpretTrailersCommandResult> {
60
+ private input = "";
61
+ private files: string[] = [];
62
+ private inPlace = false;
63
+ private trimEmpty = false;
64
+ private onlyTrailers = false;
65
+ private onlyInput = false;
66
+ private unfold = false;
67
+ private noDivider = false;
68
+ private where?: TrailerWhere;
69
+ private ifExists?: TrailerIfExists;
70
+ private ifMissing?: TrailerIfMissing;
71
+ private trailers: NewTrailer[] = [];
72
+ private compatibility?: "2.43" | "2.56";
73
+
74
+ /** The message to read when no file is given (git's stdin). */
75
+ setInput(input: string | Uint8Array): this {
76
+ this.checkCallable();
77
+ this.input = typeof input === "string" ? input : decoder.decode(input);
78
+ return this;
79
+ }
80
+
81
+ /** A file to read (`<file>`), from the worktree top; several are output one after another. */
82
+ addFile(path: string): this {
83
+ this.checkCallable();
84
+ this.files.push(path);
85
+ return this;
86
+ }
87
+
88
+ /** `--in-place`: write each file back instead of the output. */
89
+ setInPlace(inPlace: boolean): this {
90
+ this.checkCallable();
91
+ this.inPlace = inPlace;
92
+ return this;
93
+ }
94
+
95
+ /** `--trim-empty`: leave out trailers whose value is empty. */
96
+ setTrimEmpty(trim: boolean): this {
97
+ this.checkCallable();
98
+ this.trimEmpty = trim;
99
+ return this;
100
+ }
101
+
102
+ /** `--only-trailers`: output only the trailers. */
103
+ setOnlyTrailers(only: boolean): this {
104
+ this.checkCallable();
105
+ this.onlyTrailers = only;
106
+ return this;
107
+ }
108
+
109
+ /** `--only-input`: apply no `trailer.<key>.command` trailers. */
110
+ setOnlyInput(only: boolean): this {
111
+ this.checkCallable();
112
+ this.onlyInput = only;
113
+ return this;
114
+ }
115
+
116
+ /** `--unfold`: join continuation lines into one. */
117
+ setUnfold(unfold: boolean): this {
118
+ this.checkCallable();
119
+ this.unfold = unfold;
120
+ return this;
121
+ }
122
+
123
+ /** `--parse`: `--only-trailers --only-input --unfold` (true sets the three). */
124
+ setParse(parse: boolean): this {
125
+ this.checkCallable();
126
+ if (parse) {
127
+ this.onlyTrailers = true;
128
+ this.onlyInput = true;
129
+ this.unfold = true;
130
+ }
131
+ return this;
132
+ }
133
+
134
+ /** `--no-divider`: a `---` line does not end the message. */
135
+ setNoDivider(noDivider: boolean): this {
136
+ this.checkCallable();
137
+ this.noDivider = noDivider;
138
+ return this;
139
+ }
140
+
141
+ /** `--where <placement>` for the trailers added next; undefined is `--no-where`. */
142
+ setWhere(where: TrailerWhere | undefined): this {
143
+ this.checkCallable();
144
+ this.where = where;
145
+ return this;
146
+ }
147
+
148
+ /** `--if-exists <action>` for the trailers added next; undefined is `--no-if-exists`. */
149
+ setIfExists(action: TrailerIfExists | undefined): this {
150
+ this.checkCallable();
151
+ this.ifExists = action;
152
+ return this;
153
+ }
154
+
155
+ /** `--if-missing <action>` for the trailers added next; undefined is `--no-if-missing`. */
156
+ setIfMissing(action: TrailerIfMissing | undefined): this {
157
+ this.checkCallable();
158
+ this.ifMissing = action;
159
+ return this;
160
+ }
161
+
162
+ /** `--trailer <key>[(=|:)<value>]`, with the placement and actions set so far. */
163
+ addTrailer(text: string): this {
164
+ this.checkCallable();
165
+ this.trailers.push({
166
+ text,
167
+ ...(this.where ? { where: this.where } : {}),
168
+ ...(this.ifExists ? { ifExists: this.ifExists } : {}),
169
+ ...(this.ifMissing ? { ifMissing: this.ifMissing } : {}),
170
+ });
171
+ return this;
172
+ }
173
+
174
+ /** `--no-trailer`: forget the trailers added so far. */
175
+ clearTrailers(): this {
176
+ this.checkCallable();
177
+ this.trailers = [];
178
+ return this;
179
+ }
180
+
181
+ /** The git version to follow where versions differ (default: the hook runner's, else 2.56). */
182
+ setCompatibility(version: "2.43" | "2.56"): this {
183
+ this.checkCallable();
184
+ this.compatibility = version;
185
+ return this;
186
+ }
187
+
188
+ async call(): Promise<InterpretTrailersCommandResult> {
189
+ this.checkCallable();
190
+ this.setCallable(false);
191
+ const hooks = this.hooks;
192
+ const compatibility = this.compatibility ?? hooks.compatibility;
193
+ const config = { ...trailerConfigOf(this.workingCopy), compatibility };
194
+ let stderr = (config.warnings ?? []).map((w) => `${w}\n`).join("");
195
+ if (this.onlyInput && this.trailers.length > 0) {
196
+ throw new GitApiError("fatal: --trailer with --only-input does not make sense", {
197
+ exitCode: 129,
198
+ });
199
+ }
200
+ if (this.files.length === 0 && this.inPlace) {
201
+ throw new GitApiError("fatal: no input file given for in-place editing", { exitCode: 128 });
202
+ }
203
+ const runCommand: TrailerCommandRunner | undefined = hooks.enabled
204
+ ? (command) => hooks.runShellCommand("trailer", command.command, command.args)
205
+ : undefined;
206
+ const process = async (text: string) => {
207
+ // read_input_file: strbuf_complete_line (2.44+; 2.43 reads the input as it is)
208
+ const complete = compatibility !== "2.43" && text.length > 0 && !text.endsWith("\n");
209
+ const input = complete ? `${text}\n` : text;
210
+ const result = await processTrailers(
211
+ input,
212
+ {
213
+ trailers: this.trailers,
214
+ trimEmpty: this.trimEmpty,
215
+ onlyTrailers: this.onlyTrailers,
216
+ onlyInput: this.onlyInput,
217
+ unfold: this.unfold,
218
+ noDivider: this.noDivider,
219
+ ...(runCommand ? { runCommand } : {}),
220
+ },
221
+ config,
222
+ );
223
+ stderr += result.errors;
224
+ return result.output;
225
+ };
226
+ if (this.files.length === 0) return { stdout: await process(this.input), stderr };
227
+ let stdout = "";
228
+ for (const name of this.files) {
229
+ const file = await hooks.fileAt(name);
230
+ const stats = file ? await file.files.stats(file.path) : undefined;
231
+ if (!file || stats?.kind !== "file") {
232
+ const reason = stats ? "Is a directory" : "No such file or directory";
233
+ throw new GitApiError(`fatal: could not read input file '${name}': ${reason}`, {
234
+ exitCode: 128,
235
+ });
236
+ }
237
+ const chunks: Uint8Array[] = [];
238
+ for await (const chunk of file.files.read(file.path)) chunks.push(chunk);
239
+ const output = await process(decoder.decode(concat(chunks)));
240
+ if (this.inPlace) await file.files.write(file.path, [encoder.encode(output)]);
241
+ else stdout += output;
242
+ }
243
+ return { stdout, stderr };
244
+ }
245
+ }
246
+
247
+ function concat(chunks: Uint8Array[]): Uint8Array {
248
+ if (chunks.length === 1) return chunks[0] as Uint8Array;
249
+ const out = new Uint8Array(chunks.reduce((n, c) => n + c.length, 0));
250
+ let at = 0;
251
+ for (const c of chunks) {
252
+ out.set(c, at);
253
+ at += c.length;
254
+ }
255
+ return out;
256
+ }
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import { historyWithoutLazyFetch, type RefTransactionHook } from "@statewalker/vcs-core";
9
+ import { configFilesApiOf, readConfinedFile } from "@statewalker/vcs-store-files";
9
10
  import {
10
11
  createRepositoryFacade,
11
12
  createTransportRefStore,
@@ -25,8 +26,9 @@ import {
25
26
  type UploadPackConnection,
26
27
  } from "@statewalker/vcs-transport";
27
28
  import { parseGitBool, parseGitInt } from "@statewalker/vcs-utils/encoding";
28
- import type { FilesApi } from "@statewalker/vcs-utils/files";
29
+ import { type FilesApi, readFile } from "@statewalker/vcs-utils/files";
29
30
  import {
31
+ type GitHostEnvironment,
30
32
  type LinkedWorktrees,
31
33
  type OpenedRepository,
32
34
  sparseFilterMatcher,
@@ -34,6 +36,7 @@ import {
34
36
  } from "@statewalker/vcs-working-tree";
35
37
  import { GitApiError, TransportError } from "../errors/index.js";
36
38
  import { quoteCStyleBody } from "../results/index.js";
39
+ import { type ReceiveFsckSettings, receiveFsckOf } from "./fsck/index.js";
37
40
  import {
38
41
  HookSession,
39
42
  hookHostOf,
@@ -217,6 +220,7 @@ const DEFAULT_SETTINGS: ServerConfigSettings = {
217
220
  denyCurrentBranch: "unconfigured",
218
221
  denyDeleteCurrent: "unconfigured",
219
222
  shallowUpdate: false,
223
+ advertisePushOptions: false,
220
224
  uploadPackHideRefs: [],
221
225
  receivePackHideRefs: [],
222
226
  };
@@ -340,8 +344,17 @@ export async function withLocalReceivePack<T>(
340
344
  * output reaches the pushing user's stderr directly, not as "remote: " lines
341
345
  */
342
346
  transactionHooks: HookSession | undefined = hooks,
343
- /** `protocol.version`: 1 has receive-pack answer `version 1` first (2 is v0 for a push) */
344
- options: { protocolVersion?: 0 | 1 | 2 } = {},
347
+ /**
348
+ * `protocol.version`: 1 has receive-pack answer `version 1` first (2 is v0 for a push);
349
+ * `host`: where receive-pack runs ({@link ReceivePackHost}); `onWarning`: receive-pack's own
350
+ * warnings as it reads its config (`warning: skipping unknown msg id '<id>'`), which git's
351
+ * local transport shows on the pushing user's stderr
352
+ */
353
+ options: {
354
+ protocolVersion?: 0 | 1 | 2;
355
+ host?: ReceivePackHost;
356
+ onWarning?: (line: string) => void;
357
+ } = {},
345
358
  ): Promise<T> {
346
359
  // receive-pack's enter_repo(path, 0): a repository another user owns is refused (git's
347
360
  // die_upon_dubious_ownership in the child), and the client sees the connection fail
@@ -357,7 +370,7 @@ export async function withLocalReceivePack<T>(
357
370
  // the remote's reference-transaction hook on its ref store while receive-pack runs (its
358
371
  // output goes to the pushing user's stderr directly, not through the side-band)
359
372
  return withReceiveTransactionHook(remote, transactionHooks, () =>
360
- receiveOver(remote, run, hooks, receiveHooks, options.protocolVersion === 1),
373
+ receiveOver(remote, run, hooks, receiveHooks, options.protocolVersion === 1, options),
361
374
  );
362
375
  }
363
376
 
@@ -414,11 +427,83 @@ export async function withReceiveTransactionHook<T>(
414
427
  }
415
428
  }
416
429
 
430
+ /** Where receive-pack runs: what it reads besides the served repository. */
431
+ export interface ReceivePackHost {
432
+ /** The host environment (absolute and `~/` skip lists, `$HOME`) */
433
+ environment?: GitHostEnvironment;
434
+ /** Whose messages to give where git 2.43 and 2.5x differ (default 2.5x) */
435
+ compatibility?: "2.43" | "2.56";
436
+ /**
437
+ * The repository is someone else's (served): files its configuration names (a
438
+ * `receive.fsck.skipList`) are read only inside its own git directories, as confined
439
+ * includes (`configIncludes: "files"`), never from the host; a local push into one's own
440
+ * repository reads them as git does
441
+ */
442
+ confineFiles?: boolean;
443
+ }
444
+
445
+ /**
446
+ * receive-pack's `receive.fsckObjects` / `transfer.fsckObjects` settings of the repository it
447
+ * serves (`receiveFsckOf`): skip lists named by a relative path are read from its git
448
+ * directory (receive-pack's working directory), absolute ones from the host; with
449
+ * `confineFiles` (a served repository) only files inside its own git directories, where their
450
+ * links lead and capped as confined includes (`readConfinedFile`), anything else unreadable.
451
+ */
452
+ export function receiveFsckSettingsOf(
453
+ remote: OpenedRepository,
454
+ host: ReceivePackHost = {},
455
+ ): ReceiveFsckSettings {
456
+ const config = remote.config;
457
+ if (!config) return { warnings: [] };
458
+ const gitDir = remote.gitDir.replace(/^\/+/, "").replace(/\/+$/, "");
459
+ const files = remote.files;
460
+ const environment = host.environment;
461
+ const listWithOrigin = config.listWithOrigin?.bind(config);
462
+ // receive-pack runs in the git directory: git names its files from there (`config`)
463
+ const entries = () =>
464
+ listWithOrigin
465
+ ? listWithOrigin().map((e) =>
466
+ e.file?.replace(/^\/+/, "").startsWith(`${gitDir}/`)
467
+ ? { ...e, file: e.file.replace(/^\/+/, "").slice(gitDir.length + 1) }
468
+ : e,
469
+ )
470
+ : config.list();
471
+ if (host.confineFiles) {
472
+ // a served repository's skip list: only its own files, where their links lead, capped
473
+ const roots = [gitDir];
474
+ const common = remote.commonDir?.replace(/^\/+/, "").replace(/\/+$/, "");
475
+ if (common !== undefined && common !== gitDir) roots.push(common);
476
+ const confined = files ? configFilesApiOf(files) : undefined;
477
+ return receiveFsckOf({
478
+ entries,
479
+ compatibility: host.compatibility ?? "2.56",
480
+ readFile: async (path) =>
481
+ confined
482
+ ? readConfinedFile(confined, path, { baseDir: gitDir, roots }).catch(() => undefined)
483
+ : undefined,
484
+ });
485
+ }
486
+ return receiveFsckOf({
487
+ entries,
488
+ compatibility: host.compatibility ?? "2.56",
489
+ ...(environment?.home ? { home: environment.home } : {}),
490
+ readFile: async (path) => {
491
+ if (path.startsWith("/") && environment) return environment.readFile(path);
492
+ if (!files) return undefined;
493
+ const full = path.startsWith("/") ? path : `${gitDir}/${path}`;
494
+ // a missing file reads as no bytes in some FilesApis: ask first
495
+ if ((await files.stats(full).catch(() => undefined))?.kind !== "file") return undefined;
496
+ return readFile(files, full);
497
+ },
498
+ });
499
+ }
500
+
417
501
  /**
418
502
  * The settings git's receive-pack takes from the repository it serves: the policies and hidden
419
503
  * refs of its config (`serverSettingsFromConfig`), its current branch and the branches its
420
- * worktrees have checked out, `updateInstead` (push-to-checkout, push-to-deploy), and, with
421
- * hooks, pre-receive / update / post-receive run as git's receive-pack runs them.
504
+ * worktrees have checked out, `updateInstead` (push-to-checkout, push-to-deploy), the fsck of
505
+ * pushed objects (`receive.fsckObjects`, {@link receiveFsckSettingsOf}) and, with hooks,
506
+ * pre-receive / update / post-receive run as git's receive-pack runs them.
422
507
  */
423
508
  export async function receivePackSettingsOf(
424
509
  remote: OpenedRepository,
@@ -426,9 +511,15 @@ export async function receivePackSettingsOf(
426
511
  receiveHooks: ReceivePackHooks | undefined = hooks?.enabled
427
512
  ? scriptReceiveHooks(hooks)
428
513
  : undefined,
514
+ host: ReceivePackHost = {},
429
515
  ): Promise<GitServeSettings> {
430
516
  const head = await remote.history.refs.get("HEAD").catch(() => undefined);
431
517
  const settings = serverSettingsOf(remote);
518
+ const fsck = receiveFsckSettingsOf(remote, {
519
+ compatibility: hooks?.compatibility,
520
+ ...host,
521
+ });
522
+ const configError = settings.receivePackConfigError ?? fsck.configError;
432
523
  const checkedOut = await checkedOutBranches(remote.worktrees);
433
524
  const worktrees = remote.worktrees;
434
525
  return {
@@ -439,6 +530,8 @@ export async function receivePackSettingsOf(
439
530
  denyCurrentBranch: settings.denyCurrentBranch,
440
531
  denyDeleteCurrent: settings.denyDeleteCurrent,
441
532
  shallowUpdate: settings.shallowUpdate,
533
+ // receive.advertisePushOptions (git's default false)
534
+ advertisePushOptions: settings.advertisePushOptions,
442
535
  uploadPackHideRefs: settings.uploadPackHideRefs,
443
536
  receivePackHideRefs: settings.receivePackHideRefs,
444
537
  ...(receiveHooks ? { hooks: receiveHooks, relayPostReceive: true } : {}),
@@ -448,9 +541,9 @@ export async function receivePackSettingsOf(
448
541
  preReceiveSeesRefused: true,
449
542
  // receive.procReceiveRefs: the commands the proc-receive hook takes
450
543
  ...(settings.procReceiveRefs?.length ? { procReceiveRefs: settings.procReceiveRefs } : {}),
451
- ...(settings.receivePackConfigError !== undefined
452
- ? { receivePackConfigError: settings.receivePackConfigError }
453
- : {}),
544
+ ...(configError !== undefined ? { receivePackConfigError: configError } : {}),
545
+ // receive.fsckObjects: unpack-objects / index-pack --strict
546
+ ...(fsck.fsckObjects ? { fsckObjects: fsck.fsckObjects } : {}),
454
547
  // git 2.5x updates the refs of a push that is not atomic in two batches
455
548
  ...(hooks?.enabled && hooks.compatibility !== "2.43" ? { batchNonAtomic: true } : {}),
456
549
  // ... git 2.43 updates each ref after its update hook
@@ -473,9 +566,15 @@ async function receiveOver<T>(
473
566
  hooks: HookSession | undefined,
474
567
  receiveHooks: ReceivePackHooks | undefined,
475
568
  version1: boolean,
569
+ options: { host?: ReceivePackHost; onWarning?: (line: string) => void } = {},
476
570
  ): Promise<T> {
477
571
  const [client, server] = createDuplexPair();
478
- const settings = await receivePackSettingsOf(remote, hooks, receiveHooks);
572
+ const host = options.host ?? {};
573
+ const settings = await receivePackSettingsOf(remote, hooks, receiveHooks, host);
574
+ // receive-pack's warnings as it reads its config, on the shared stderr
575
+ if (options.onWarning) {
576
+ for (const line of receiveFsckSettingsOf(remote, host).warnings) options.onWarning(line);
577
+ }
479
578
  const serving = serveOverDuplex({
480
579
  ...settings,
481
580
  duplex: server,