@statewalker/vcs-commands 0.6.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 (481) 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/bisect/bisect-engine.d.ts.map +1 -1
  15. package/dist/commands/branch-command.d.ts +148 -18
  16. package/dist/commands/branch-command.d.ts.map +1 -1
  17. package/dist/commands/branch-info-command.d.ts +55 -0
  18. package/dist/commands/branch-info-command.d.ts.map +1 -0
  19. package/dist/commands/branch-tracking.d.ts +106 -17
  20. package/dist/commands/branch-tracking.d.ts.map +1 -1
  21. package/dist/commands/branch-upstream-command.d.ts +83 -0
  22. package/dist/commands/branch-upstream-command.d.ts.map +1 -0
  23. package/dist/commands/checkout-command.d.ts +19 -3
  24. package/dist/commands/checkout-command.d.ts.map +1 -1
  25. package/dist/commands/cherry-pick-command.d.ts +59 -0
  26. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  27. package/dist/commands/clean-command.d.ts +12 -0
  28. package/dist/commands/clean-command.d.ts.map +1 -1
  29. package/dist/commands/clone-command.d.ts +17 -0
  30. package/dist/commands/clone-command.d.ts.map +1 -1
  31. package/dist/commands/comment-char-config.d.ts +35 -0
  32. package/dist/commands/comment-char-config.d.ts.map +1 -0
  33. package/dist/commands/commit-command.d.ts +191 -5
  34. package/dist/commands/commit-command.d.ts.map +1 -1
  35. package/dist/commands/commit-reuse.d.ts +33 -0
  36. package/dist/commands/commit-reuse.d.ts.map +1 -0
  37. package/dist/commands/config-command.d.ts +236 -0
  38. package/dist/commands/config-command.d.ts.map +1 -0
  39. package/dist/commands/config-value-types.d.ts +91 -0
  40. package/dist/commands/config-value-types.d.ts.map +1 -0
  41. package/dist/commands/core-config.d.ts +20 -0
  42. package/dist/commands/core-config.d.ts.map +1 -1
  43. package/dist/commands/default-branch.d.ts +70 -0
  44. package/dist/commands/default-branch.d.ts.map +1 -0
  45. package/dist/commands/diff-color-config.d.ts +73 -0
  46. package/dist/commands/diff-color-config.d.ts.map +1 -0
  47. package/dist/commands/diff-command.d.ts +252 -5
  48. package/dist/commands/diff-command.d.ts.map +1 -1
  49. package/dist/commands/fetch-command.d.ts +20 -0
  50. package/dist/commands/fetch-command.d.ts.map +1 -1
  51. package/dist/commands/fmt-merge-msg-command.d.ts +124 -0
  52. package/dist/commands/fmt-merge-msg-command.d.ts.map +1 -0
  53. package/dist/commands/fork-point.d.ts +38 -0
  54. package/dist/commands/fork-point.d.ts.map +1 -0
  55. package/dist/commands/format-patch-command.d.ts +41 -1
  56. package/dist/commands/format-patch-command.d.ts.map +1 -1
  57. package/dist/commands/fsck/fetch-fsck.d.ts +51 -0
  58. package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -1
  59. package/dist/commands/fsck/fsck-command.d.ts +2 -0
  60. package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
  61. package/dist/commands/fsck/fsck-loose.d.ts +3 -0
  62. package/dist/commands/fsck/fsck-loose.d.ts.map +1 -1
  63. package/dist/commands/fsck/fsck-object-checks.d.ts +25 -14
  64. package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -1
  65. package/dist/commands/fsck/fsck-object-table.d.ts +15 -7
  66. package/dist/commands/fsck/fsck-object-table.d.ts.map +1 -1
  67. package/dist/commands/fsck/fsck-pack.d.ts +11 -4
  68. package/dist/commands/fsck/fsck-pack.d.ts.map +1 -1
  69. package/dist/commands/fsck/verify-pack-command.d.ts.map +1 -1
  70. package/dist/commands/gc-command.d.ts +80 -48
  71. package/dist/commands/gc-command.d.ts.map +1 -1
  72. package/dist/commands/git-date.d.ts +1 -65
  73. package/dist/commands/git-date.d.ts.map +1 -1
  74. package/dist/commands/git-describe.d.ts +4 -0
  75. package/dist/commands/git-describe.d.ts.map +1 -1
  76. package/dist/commands/git-hooks.d.ts +43 -0
  77. package/dist/commands/git-hooks.d.ts.map +1 -1
  78. package/dist/commands/grep/grep-command.d.ts +210 -0
  79. package/dist/commands/grep/grep-command.d.ts.map +1 -0
  80. package/dist/commands/grep/grep-engine.d.ts +218 -0
  81. package/dist/commands/grep/grep-engine.d.ts.map +1 -0
  82. package/dist/commands/grep/index.d.ts +3 -0
  83. package/dist/commands/grep/index.d.ts.map +1 -0
  84. package/dist/commands/index-adder.d.ts +15 -2
  85. package/dist/commands/index-adder.d.ts.map +1 -1
  86. package/dist/commands/index.d.ts +28 -0
  87. package/dist/commands/index.d.ts.map +1 -1
  88. package/dist/commands/index.js +3 -3
  89. package/dist/commands/init-command.d.ts +50 -3
  90. package/dist/commands/init-command.d.ts.map +1 -1
  91. package/dist/commands/interpret-trailers-command.d.ts +90 -0
  92. package/dist/commands/interpret-trailers-command.d.ts.map +1 -0
  93. package/dist/commands/legacy-remotes.d.ts +55 -0
  94. package/dist/commands/legacy-remotes.d.ts.map +1 -0
  95. package/dist/commands/local-transport.d.ts +36 -5
  96. package/dist/commands/local-transport.d.ts.map +1 -1
  97. package/dist/commands/log-command.d.ts +296 -11
  98. package/dist/commands/log-command.d.ts.map +1 -1
  99. package/dist/commands/log-graph.d.ts +26 -1
  100. package/dist/commands/log-graph.d.ts.map +1 -1
  101. package/dist/commands/log-output.d.ts +133 -5
  102. package/dist/commands/log-output.d.ts.map +1 -1
  103. package/dist/commands/ls-remote-command.d.ts +2 -0
  104. package/dist/commands/ls-remote-command.d.ts.map +1 -1
  105. package/dist/commands/mailmap.d.ts +30 -0
  106. package/dist/commands/mailmap.d.ts.map +1 -1
  107. package/dist/commands/merge-base-command.d.ts +60 -0
  108. package/dist/commands/merge-base-command.d.ts.map +1 -0
  109. package/dist/commands/merge-bases.d.ts +23 -0
  110. package/dist/commands/merge-bases.d.ts.map +1 -1
  111. package/dist/commands/merge-command.d.ts +108 -9
  112. package/dist/commands/merge-command.d.ts.map +1 -1
  113. package/dist/commands/merge-support.d.ts +11 -3
  114. package/dist/commands/merge-support.d.ts.map +1 -1
  115. package/dist/commands/mv-command.d.ts +4 -0
  116. package/dist/commands/mv-command.d.ts.map +1 -1
  117. package/dist/commands/name-rev.d.ts +48 -0
  118. package/dist/commands/name-rev.d.ts.map +1 -0
  119. package/dist/commands/notes-command.d.ts.map +1 -1
  120. package/dist/commands/notes-merge-command.d.ts.map +1 -1
  121. package/dist/commands/notes-tree.d.ts +11 -1
  122. package/dist/commands/notes-tree.d.ts.map +1 -1
  123. package/dist/commands/patch-id.d.ts +3 -0
  124. package/dist/commands/patch-id.d.ts.map +1 -1
  125. package/dist/commands/pathspec-file.d.ts +39 -0
  126. package/dist/commands/pathspec-file.d.ts.map +1 -0
  127. package/dist/commands/pathspec.d.ts +3 -0
  128. package/dist/commands/pathspec.d.ts.map +1 -1
  129. package/dist/commands/pretty-format.d.ts +43 -3
  130. package/dist/commands/pretty-format.d.ts.map +1 -1
  131. package/dist/commands/promisor-remote.d.ts.map +1 -1
  132. package/dist/commands/pull-command.d.ts +28 -0
  133. package/dist/commands/pull-command.d.ts.map +1 -1
  134. package/dist/commands/push-command.d.ts +160 -9
  135. package/dist/commands/push-command.d.ts.map +1 -1
  136. package/dist/commands/read-tree-command.d.ts +6 -0
  137. package/dist/commands/read-tree-command.d.ts.map +1 -1
  138. package/dist/commands/rebase-command.d.ts +168 -6
  139. package/dist/commands/rebase-command.d.ts.map +1 -1
  140. package/dist/commands/ref-filter/for-each-ref-command.d.ts +121 -0
  141. package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -0
  142. package/dist/commands/ref-filter/index.d.ts +8 -0
  143. package/dist/commands/ref-filter/index.d.ts.map +1 -0
  144. package/dist/commands/ref-filter/ref-atoms.d.ts +88 -0
  145. package/dist/commands/ref-filter/ref-atoms.d.ts.map +1 -0
  146. package/dist/commands/ref-filter/ref-filter.d.ts +178 -0
  147. package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -0
  148. package/dist/commands/ref-filter/ref-format.d.ts +222 -0
  149. package/dist/commands/ref-filter/ref-format.d.ts.map +1 -0
  150. package/dist/commands/ref-filter/ref-listing-command.d.ts +56 -0
  151. package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -0
  152. package/dist/commands/ref-filter/ref-quote.d.ts +20 -0
  153. package/dist/commands/ref-filter/ref-quote.d.ts.map +1 -0
  154. package/dist/commands/ref-filter/version-compare.d.ts +20 -0
  155. package/dist/commands/ref-filter/version-compare.d.ts.map +1 -0
  156. package/dist/commands/reflog-command.d.ts +120 -0
  157. package/dist/commands/reflog-command.d.ts.map +1 -1
  158. package/dist/commands/reflog-walk.d.ts +72 -0
  159. package/dist/commands/reflog-walk.d.ts.map +1 -0
  160. package/dist/commands/remote-command.d.ts +138 -29
  161. package/dist/commands/remote-command.d.ts.map +1 -1
  162. package/dist/commands/remote-transport.d.ts +7 -1
  163. package/dist/commands/remote-transport.d.ts.map +1 -1
  164. package/dist/commands/reset-command.d.ts +2 -3
  165. package/dist/commands/reset-command.d.ts.map +1 -1
  166. package/dist/commands/restore-command.d.ts +2 -3
  167. package/dist/commands/restore-command.d.ts.map +1 -1
  168. package/dist/commands/rev-filter/commit-filter.d.ts +95 -0
  169. package/dist/commands/rev-filter/commit-filter.d.ts.map +1 -0
  170. package/dist/commands/rev-filter/commit-grep.d.ts +91 -0
  171. package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -0
  172. package/dist/commands/rev-filter/index.d.ts +3 -0
  173. package/dist/commands/rev-filter/index.d.ts.map +1 -0
  174. package/dist/commands/rev-list-command.d.ts +154 -2
  175. package/dist/commands/rev-list-command.d.ts.map +1 -1
  176. package/dist/commands/rev-parse-command.d.ts +9 -0
  177. package/dist/commands/rev-parse-command.d.ts.map +1 -1
  178. package/dist/commands/revert-command.d.ts +32 -0
  179. package/dist/commands/revert-command.d.ts.map +1 -1
  180. package/dist/commands/revision-range.d.ts +32 -1
  181. package/dist/commands/revision-range.d.ts.map +1 -1
  182. package/dist/commands/revision-resolver.d.ts +21 -2
  183. package/dist/commands/revision-resolver.d.ts.map +1 -1
  184. package/dist/commands/rm-command.d.ts +70 -2
  185. package/dist/commands/rm-command.d.ts.map +1 -1
  186. package/dist/commands/sequencer-pick.d.ts +85 -5
  187. package/dist/commands/sequencer-pick.d.ts.map +1 -1
  188. package/dist/commands/sequencer-support.d.ts +2 -0
  189. package/dist/commands/sequencer-support.d.ts.map +1 -1
  190. package/dist/commands/serve-repository.d.ts +7 -0
  191. package/dist/commands/serve-repository.d.ts.map +1 -1
  192. package/dist/commands/show-command.d.ts +130 -0
  193. package/dist/commands/show-command.d.ts.map +1 -0
  194. package/dist/commands/show-commit.d.ts +11 -0
  195. package/dist/commands/show-commit.d.ts.map +1 -0
  196. package/dist/commands/signature-check.d.ts +164 -0
  197. package/dist/commands/signature-check.d.ts.map +1 -0
  198. package/dist/commands/signing.d.ts +160 -0
  199. package/dist/commands/signing.d.ts.map +1 -0
  200. package/dist/commands/sparse-checkout-command.d.ts.map +1 -1
  201. package/dist/commands/sparse-index-view.d.ts +45 -0
  202. package/dist/commands/sparse-index-view.d.ts.map +1 -0
  203. package/dist/commands/ssh-signer.d.ts +29 -0
  204. package/dist/commands/ssh-signer.d.ts.map +1 -0
  205. package/dist/commands/ssh-verifier.d.ts +42 -0
  206. package/dist/commands/ssh-verifier.d.ts.map +1 -0
  207. package/dist/commands/stash-apply-command.d.ts +5 -0
  208. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  209. package/dist/commands/stash-branch-command.d.ts +34 -0
  210. package/dist/commands/stash-branch-command.d.ts.map +1 -0
  211. package/dist/commands/stash-create-command.d.ts +18 -1
  212. package/dist/commands/stash-create-command.d.ts.map +1 -1
  213. package/dist/commands/stash-info.d.ts +93 -0
  214. package/dist/commands/stash-info.d.ts.map +1 -0
  215. package/dist/commands/stash-list-command.d.ts +16 -0
  216. package/dist/commands/stash-list-command.d.ts.map +1 -1
  217. package/dist/commands/stash-pop-command.d.ts +39 -0
  218. package/dist/commands/stash-pop-command.d.ts.map +1 -0
  219. package/dist/commands/stash-show-command.d.ts +48 -0
  220. package/dist/commands/stash-show-command.d.ts.map +1 -0
  221. package/dist/commands/stash-store-command.d.ts +29 -0
  222. package/dist/commands/stash-store-command.d.ts.map +1 -0
  223. package/dist/commands/stash-working-tree.d.ts.map +1 -1
  224. package/dist/commands/status-command.d.ts.map +1 -1
  225. package/dist/commands/status-header.d.ts +5 -0
  226. package/dist/commands/status-header.d.ts.map +1 -1
  227. package/dist/commands/submodule-add-command.d.ts +89 -0
  228. package/dist/commands/submodule-add-command.d.ts.map +1 -0
  229. package/dist/commands/submodule-auth.d.ts +90 -0
  230. package/dist/commands/submodule-auth.d.ts.map +1 -0
  231. package/dist/commands/submodule-commands.d.ts +375 -0
  232. package/dist/commands/submodule-commands.d.ts.map +1 -0
  233. package/dist/commands/submodule-model.d.ts +288 -0
  234. package/dist/commands/submodule-model.d.ts.map +1 -0
  235. package/dist/commands/submodule-summary-command.d.ts.map +1 -1
  236. package/dist/commands/submodule-update-command.d.ts +198 -0
  237. package/dist/commands/submodule-update-command.d.ts.map +1 -0
  238. package/dist/commands/switch-command.d.ts.map +1 -1
  239. package/dist/commands/tag-command.d.ts +259 -10
  240. package/dist/commands/tag-command.d.ts.map +1 -1
  241. package/dist/commands/trailers.d.ts +218 -17
  242. package/dist/commands/trailers.d.ts.map +1 -1
  243. package/dist/commands/tree-restore.d.ts +7 -0
  244. package/dist/commands/tree-restore.d.ts.map +1 -1
  245. package/dist/commands/untracked-cache-support.d.ts +2 -1
  246. package/dist/commands/untracked-cache-support.d.ts.map +1 -1
  247. package/dist/commands/verify-command.d.ts +92 -0
  248. package/dist/commands/verify-command.d.ts.map +1 -0
  249. package/dist/commands/worktree-add-command.d.ts +79 -7
  250. package/dist/commands/worktree-add-command.d.ts.map +1 -1
  251. package/dist/commands/worktree-list-command.d.ts.map +1 -1
  252. package/dist/commands/worktree-path-rules.d.ts +66 -0
  253. package/dist/commands/worktree-path-rules.d.ts.map +1 -0
  254. package/dist/commands/worktree-remove-command.d.ts +10 -3
  255. package/dist/commands/worktree-remove-command.d.ts.map +1 -1
  256. package/dist/commands/worktree-repair-command.d.ts +15 -2
  257. package/dist/commands/worktree-repair-command.d.ts.map +1 -1
  258. package/dist/commands/worktree-support.d.ts +5 -0
  259. package/dist/commands/worktree-support.d.ts.map +1 -1
  260. package/dist/{commands-DnmlfwGV.js → commands-ISM52N0n.js} +66120 -49271
  261. package/dist/errors/checkout-errors.d.ts +19 -0
  262. package/dist/errors/checkout-errors.d.ts.map +1 -1
  263. package/dist/errors/command-errors.d.ts.map +1 -1
  264. package/dist/errors/index.js +57 -3
  265. package/dist/errors/ref-errors.d.ts +19 -0
  266. package/dist/errors/ref-errors.d.ts.map +1 -1
  267. package/dist/errors/worktree-errors.d.ts +6 -1
  268. package/dist/errors/worktree-errors.d.ts.map +1 -1
  269. package/dist/{git-command-DxvwPrPB.js → fsck-DLRpbwTj.js} +6863 -1070
  270. package/dist/git-command.d.ts +43 -2
  271. package/dist/git-command.d.ts.map +1 -1
  272. package/dist/git.d.ts +276 -3
  273. package/dist/git.d.ts.map +1 -1
  274. package/dist/index.js +5 -5
  275. package/dist/remote-config/index.d.ts +1 -1
  276. package/dist/remote-config/index.d.ts.map +1 -1
  277. package/dist/remote-config/remote-config-store.d.ts +117 -3
  278. package/dist/remote-config/remote-config-store.d.ts.map +1 -1
  279. package/dist/rename/detect-renames.d.ts.map +1 -1
  280. package/dist/results/clone-result.d.ts +8 -0
  281. package/dist/results/clone-result.d.ts.map +1 -1
  282. package/dist/results/combined-diff.d.ts +3 -0
  283. package/dist/results/combined-diff.d.ts.map +1 -1
  284. package/dist/results/diff-check.d.ts +38 -0
  285. package/dist/results/diff-check.d.ts.map +1 -0
  286. package/dist/results/diff-color.d.ts +135 -0
  287. package/dist/results/diff-color.d.ts.map +1 -0
  288. package/dist/results/diff-output.d.ts +85 -1
  289. package/dist/results/diff-output.d.ts.map +1 -1
  290. package/dist/results/diff-pickaxe.d.ts +67 -0
  291. package/dist/results/diff-pickaxe.d.ts.map +1 -0
  292. package/dist/results/diff-words.d.ts +55 -0
  293. package/dist/results/diff-words.d.ts.map +1 -0
  294. package/dist/results/index.d.ts +4 -0
  295. package/dist/results/index.d.ts.map +1 -1
  296. package/dist/results/index.js +2 -2
  297. package/dist/results/init-result.d.ts +7 -0
  298. package/dist/results/init-result.d.ts.map +1 -1
  299. package/dist/results/pull-result.d.ts +5 -0
  300. package/dist/results/pull-result.d.ts.map +1 -1
  301. package/dist/results/push-result.d.ts +12 -0
  302. package/dist/results/push-result.d.ts.map +1 -1
  303. package/dist/results/rebase-result.d.ts +2 -0
  304. package/dist/results/rebase-result.d.ts.map +1 -1
  305. package/dist/results/stash-result.d.ts +6 -0
  306. package/dist/results/stash-result.d.ts.map +1 -1
  307. package/dist/results/status-result.d.ts.map +1 -1
  308. package/dist/{results-BZGa2Z3I.js → results-TB2IJ64h.js} +2178 -412
  309. package/dist/whitespace/index.d.ts +2 -0
  310. package/dist/whitespace/index.d.ts.map +1 -0
  311. package/dist/whitespace/whitespace-rule.d.ts +94 -0
  312. package/dist/whitespace/whitespace-rule.d.ts.map +1 -0
  313. package/package.json +12 -12
  314. package/src/commands/add-command.ts +178 -17
  315. package/src/commands/add-patch/add-interactive.ts +3 -3
  316. package/src/commands/am/am-command.ts +263 -43
  317. package/src/commands/am/index.ts +1 -0
  318. package/src/commands/am/mailsplit.ts +326 -0
  319. package/src/commands/apply/apply-command.ts +18 -8
  320. package/src/commands/apply/apply-engine.ts +6 -7
  321. package/src/commands/apply/apply-parse.ts +10 -10
  322. package/src/commands/attributes-source.ts +1 -1
  323. package/src/commands/bisect/bisect-command.ts +18 -5
  324. package/src/commands/bisect/bisect-engine.ts +2 -1
  325. package/src/commands/branch-command.ts +528 -53
  326. package/src/commands/branch-info-command.ts +150 -0
  327. package/src/commands/branch-tracking.ts +335 -60
  328. package/src/commands/branch-upstream-command.ts +218 -0
  329. package/src/commands/checkout-command.ts +70 -44
  330. package/src/commands/cherry-pick-command.ts +143 -0
  331. package/src/commands/clean-command.ts +34 -3
  332. package/src/commands/clone-command.ts +118 -5
  333. package/src/commands/comment-char-config.ts +160 -0
  334. package/src/commands/commit-command.ts +790 -71
  335. package/src/commands/commit-reuse.ts +94 -0
  336. package/src/commands/config-command.ts +1256 -0
  337. package/src/commands/config-value-types.ts +358 -0
  338. package/src/commands/core-config.ts +47 -2
  339. package/src/commands/default-branch.ts +196 -0
  340. package/src/commands/diff-color-config.ts +274 -0
  341. package/src/commands/diff-command.ts +1053 -75
  342. package/src/commands/fetch-command.ts +161 -13
  343. package/src/commands/fmt-merge-msg-command.ts +715 -0
  344. package/src/commands/fork-point.ts +63 -0
  345. package/src/commands/format-patch-command.ts +316 -43
  346. package/src/commands/fsck/fetch-fsck.ts +172 -18
  347. package/src/commands/fsck/fsck-command.ts +183 -66
  348. package/src/commands/fsck/fsck-loose.ts +14 -4
  349. package/src/commands/fsck/fsck-object-checks.ts +87 -46
  350. package/src/commands/fsck/fsck-object-table.ts +52 -42
  351. package/src/commands/fsck/fsck-pack.ts +64 -34
  352. package/src/commands/fsck/verify-pack-command.ts +5 -2
  353. package/src/commands/gc-command.ts +238 -107
  354. package/src/commands/git-date.ts +9 -895
  355. package/src/commands/git-describe.ts +31 -11
  356. package/src/commands/git-hooks.ts +92 -0
  357. package/src/commands/grep/grep-command.ts +1077 -0
  358. package/src/commands/grep/grep-engine.ts +1024 -0
  359. package/src/commands/grep/index.ts +2 -0
  360. package/src/commands/index-adder.ts +54 -10
  361. package/src/commands/index.ts +28 -0
  362. package/src/commands/init-command.ts +167 -11
  363. package/src/commands/interpret-trailers-command.ts +256 -0
  364. package/src/commands/legacy-remotes.ts +224 -0
  365. package/src/commands/local-transport.ts +109 -10
  366. package/src/commands/log-command.ts +1283 -232
  367. package/src/commands/log-graph.ts +123 -26
  368. package/src/commands/log-output.ts +280 -21
  369. package/src/commands/ls-remote-command.ts +9 -0
  370. package/src/commands/mailmap.ts +119 -0
  371. package/src/commands/merge-base-command.ts +170 -0
  372. package/src/commands/merge-bases.ts +63 -8
  373. package/src/commands/merge-command.ts +360 -82
  374. package/src/commands/merge-support.ts +43 -9
  375. package/src/commands/mv-command.ts +6 -3
  376. package/src/commands/name-rev.ts +171 -0
  377. package/src/commands/notes-command.ts +11 -1
  378. package/src/commands/notes-merge-command.ts +23 -14
  379. package/src/commands/notes-tree.ts +28 -13
  380. package/src/commands/octopus-merge.ts +3 -2
  381. package/src/commands/patch-id.ts +16 -8
  382. package/src/commands/pathspec-file.ts +72 -0
  383. package/src/commands/pathspec.ts +14 -2
  384. package/src/commands/pretty-format.ts +105 -20
  385. package/src/commands/promisor-remote.ts +10 -1
  386. package/src/commands/pull-command.ts +149 -22
  387. package/src/commands/push-command.ts +704 -72
  388. package/src/commands/read-tree-command.ts +34 -3
  389. package/src/commands/rebase-command.ts +957 -142
  390. package/src/commands/ref-filter/for-each-ref-command.ts +298 -0
  391. package/src/commands/ref-filter/index.ts +7 -0
  392. package/src/commands/ref-filter/ref-atoms.ts +581 -0
  393. package/src/commands/ref-filter/ref-filter.ts +651 -0
  394. package/src/commands/ref-filter/ref-format.ts +1070 -0
  395. package/src/commands/ref-filter/ref-listing-command.ts +421 -0
  396. package/src/commands/ref-filter/ref-quote.ts +69 -0
  397. package/src/commands/ref-filter/version-compare.ts +177 -0
  398. package/src/commands/reflog-command.ts +492 -2
  399. package/src/commands/reflog-walk.ts +234 -0
  400. package/src/commands/remote-command.ts +484 -74
  401. package/src/commands/remote-transport.ts +9 -1
  402. package/src/commands/reset-command.ts +40 -42
  403. package/src/commands/restore-command.ts +12 -41
  404. package/src/commands/rev-filter/commit-filter.ts +159 -0
  405. package/src/commands/rev-filter/commit-grep.ts +444 -0
  406. package/src/commands/rev-filter/index.ts +2 -0
  407. package/src/commands/rev-list-command.ts +402 -15
  408. package/src/commands/rev-parse-command.ts +22 -0
  409. package/src/commands/revert-command.ts +82 -0
  410. package/src/commands/revision-range.ts +204 -4
  411. package/src/commands/revision-resolver.ts +55 -22
  412. package/src/commands/rm-command.ts +282 -21
  413. package/src/commands/sequencer-pick.ts +504 -86
  414. package/src/commands/sequencer-support.ts +30 -5
  415. package/src/commands/serve-repository.ts +18 -3
  416. package/src/commands/show-command.ts +490 -0
  417. package/src/commands/show-commit.ts +24 -0
  418. package/src/commands/signature-check.ts +657 -0
  419. package/src/commands/signing.ts +385 -0
  420. package/src/commands/sparse-checkout-command.ts +2 -9
  421. package/src/commands/sparse-checkout-support.ts +2 -2
  422. package/src/commands/sparse-index-view.ts +135 -0
  423. package/src/commands/ssh-signer.ts +199 -0
  424. package/src/commands/ssh-verifier.ts +523 -0
  425. package/src/commands/stash-apply-command.ts +17 -5
  426. package/src/commands/stash-branch-command.ts +88 -0
  427. package/src/commands/stash-create-command.ts +30 -2
  428. package/src/commands/stash-info.ts +243 -0
  429. package/src/commands/stash-list-command.ts +33 -0
  430. package/src/commands/stash-pop-command.ts +83 -0
  431. package/src/commands/stash-show-command.ts +141 -0
  432. package/src/commands/stash-store-command.ts +82 -0
  433. package/src/commands/stash-working-tree.ts +2 -2
  434. package/src/commands/status-command.ts +7 -6
  435. package/src/commands/status-header.ts +44 -8
  436. package/src/commands/submodule-add-command.ts +509 -0
  437. package/src/commands/submodule-auth.ts +276 -0
  438. package/src/commands/submodule-commands.ts +1517 -0
  439. package/src/commands/submodule-model.ts +930 -0
  440. package/src/commands/submodule-summary-command.ts +6 -7
  441. package/src/commands/submodule-update-command.ts +1092 -0
  442. package/src/commands/switch-command.ts +3 -1
  443. package/src/commands/tag-command.ts +876 -64
  444. package/src/commands/trailers.ts +837 -100
  445. package/src/commands/tree-restore.ts +38 -10
  446. package/src/commands/untracked-cache-support.ts +16 -12
  447. package/src/commands/verify-command.ts +235 -0
  448. package/src/commands/worktree-add-command.ts +268 -24
  449. package/src/commands/worktree-list-command.ts +3 -5
  450. package/src/commands/worktree-path-rules.ts +183 -0
  451. package/src/commands/worktree-remove-command.ts +39 -5
  452. package/src/commands/worktree-repair-command.ts +52 -5
  453. package/src/commands/worktree-support.ts +22 -1
  454. package/src/core-commands/add.command.impl.ts +1 -1
  455. package/src/errors/checkout-errors.ts +29 -0
  456. package/src/errors/command-errors.ts +2 -1
  457. package/src/errors/ref-errors.ts +23 -0
  458. package/src/errors/worktree-errors.ts +8 -1
  459. package/src/git-command.ts +98 -3
  460. package/src/git.ts +420 -4
  461. package/src/remote-config/index.ts +4 -0
  462. package/src/remote-config/remote-config-store.ts +238 -11
  463. package/src/rename/detect-renames.ts +5 -1
  464. package/src/results/clone-result.ts +9 -0
  465. package/src/results/combined-diff.ts +38 -18
  466. package/src/results/diff-check.ts +185 -0
  467. package/src/results/diff-color.ts +868 -0
  468. package/src/results/diff-output.ts +204 -37
  469. package/src/results/diff-pickaxe.ts +304 -0
  470. package/src/results/diff-words.ts +395 -0
  471. package/src/results/index.ts +4 -0
  472. package/src/results/init-result.ts +9 -0
  473. package/src/results/pull-result.ts +5 -0
  474. package/src/results/push-result.ts +12 -0
  475. package/src/results/rebase-result.ts +3 -0
  476. package/src/results/stash-result.ts +7 -0
  477. package/src/results/status-result.ts +5 -2
  478. package/src/whitespace/index.ts +1 -0
  479. package/src/{commands/apply/whitespace.ts → whitespace/whitespace-rule.ts} +173 -23
  480. package/dist/commands/apply/whitespace.d.ts +0 -58
  481. package/dist/commands/apply/whitespace.d.ts.map +0 -1
@@ -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
+ }
@@ -0,0 +1,224 @@
1
+ /**
2
+ * git 2.x's legacy remotes: a remote defined by a file `$GIT_COMMON_DIR/remotes/<name>` or
3
+ * `$GIT_COMMON_DIR/branches/<name>` instead of the configuration (remote.c
4
+ * `read_remotes_file`, `read_branches_file`). git reads them when it looks a remote up by
5
+ * name and the configuration gives that name no URL; git 3.0 (`WITH_BREAKING_CHANGES`,
6
+ * `GitHostEnvironment.breakingChanges`) never reads them.
7
+ *
8
+ * @example
9
+ * ```text
10
+ * $ cat .git/remotes/upstream $ cat .git/branches/vendor
11
+ * URL: https://example.com/r.git https://example.com/v.git#stable
12
+ * Pull: refs/heads/main:refs/heads/upstream
13
+ * Push: refs/heads/main:refs/heads/main
14
+ * ```
15
+ *
16
+ * The branches file fetches `refs/heads/stable:refs/heads/vendor` and pushes
17
+ * `HEAD:refs/heads/stable`; without `#<branch>` the branch is `init.defaultBranch`, else
18
+ * `master`.
19
+ */
20
+
21
+ import { parseGitBool } from "@statewalker/vcs-utils";
22
+ import type { FilesApi } from "@statewalker/vcs-utils/files";
23
+ import type { WorkingCopy } from "@statewalker/vcs-working-tree";
24
+
25
+ import { type LegacyRemote, RemoteConfigStore, setLegacyRemote } from "../remote-config/index.js";
26
+ import { defaultBranchHint } from "./default-branch.js";
27
+ import { commonGitFileOf } from "./git-hooks.js";
28
+ import { hostEnvironmentOf } from "./git-ident.js";
29
+
30
+ /** What {@link loadLegacyRemote} found, and the lines git prints on stderr reading it. */
31
+ export interface LegacyRemoteLoad {
32
+ remote?: LegacyRemote;
33
+ /**
34
+ * git's stderr while it reads the files, each entry one message (lines joined by `\n`):
35
+ * 2.5x's deprecation warning per file read, and the `advice.defaultBranchName` hint of a
36
+ * branches file without `#<branch>` (2.43 prints only the hint, in its own words)
37
+ */
38
+ messages: string[];
39
+ }
40
+
41
+ /**
42
+ * Reads the legacy remote `name` of a working copy, as remote.c's `remotes_remote_get_1`
43
+ * does, and records it for the working copy's {@link RemoteConfigStore}s (they see it while
44
+ * the configuration gives the name no URL): nothing under git 3.0, for a name that is no
45
+ * valid remote nickname (empty, `.`, `..`, a `/`), or for a remote the configuration gives a
46
+ * URL; else `remotes/<name>`, then, while there is still no URL, `branches/<name>`.
47
+ *
48
+ * @param compatibility The git whose stderr to give: 2.43 has no deprecation warning
49
+ */
50
+ export async function loadLegacyRemote(
51
+ workingCopy: WorkingCopy,
52
+ name: string,
53
+ compatibility: "2.43" | "2.56" = "2.56",
54
+ ): Promise<LegacyRemoteLoad> {
55
+ const messages: string[] = [];
56
+ const store = RemoteConfigStore.from(workingCopy);
57
+ setLegacyRemote(workingCopy, name, undefined);
58
+ if (hostEnvironmentOf(workingCopy)?.breakingChanges) return { messages };
59
+ if (!isValidRemoteNick(name) || store.remoteUrls(name).length > 0) return { messages };
60
+
61
+ let remote: LegacyRemote | undefined;
62
+ const remotesFile = await readGitFile(workingCopy, `remotes/${name}`);
63
+ if (remotesFile !== undefined) {
64
+ if (compatibility !== "2.43") messages.push(deprecationWarning("remotes", name));
65
+ remote = { ...parseRemotesFile(remotesFile), origin: "remotes", followTags: false };
66
+ }
67
+ if (!remote || remote.urls.length === 0) {
68
+ const branchesFile = await readGitFile(workingCopy, `branches/${name}`);
69
+ if (branchesFile !== undefined) {
70
+ if (compatibility !== "2.43") messages.push(deprecationWarning("branches", name));
71
+ const line = trimGitSpace(branchesFile.split("\n")[0] ?? "");
72
+ if (line) {
73
+ const at = line.indexOf("#");
74
+ let branch: string;
75
+ if (at >= 0) branch = line.slice(at + 1);
76
+ else {
77
+ const found = defaultBranchName(store, compatibility);
78
+ branch = found.name;
79
+ if (found.hint) messages.push(found.hint);
80
+ }
81
+ const url = at >= 0 ? line.slice(0, at) : line;
82
+ remote = {
83
+ origin: "branches",
84
+ urls: [...(remote?.urls ?? []), url],
85
+ fetchRefspecs: [
86
+ ...(remote?.fetchRefspecs ?? []),
87
+ `refs/heads/${branch}:refs/heads/${name}`,
88
+ ],
89
+ pushRefspecs: [...(remote?.pushRefspecs ?? []), `HEAD:refs/heads/${branch}`],
90
+ followTags: true,
91
+ };
92
+ }
93
+ }
94
+ }
95
+ setLegacyRemote(workingCopy, name, remote);
96
+ return { remote, messages };
97
+ }
98
+
99
+ /**
100
+ * Removes the file a legacy remote was read from (builtin/remote.c `migrate_file`'s
101
+ * `unlink_or_warn`) and forgets the remote; a file already gone is no error.
102
+ */
103
+ export async function removeLegacyRemoteFile(
104
+ workingCopy: WorkingCopy,
105
+ origin: "remotes" | "branches",
106
+ name: string,
107
+ ): Promise<void> {
108
+ const file = await commonGitFileOf(workingCopy, `${origin}/${name}`);
109
+ if (file) await file.files.remove(file.path).catch(() => false);
110
+ setLegacyRemote(workingCopy, name, undefined);
111
+ }
112
+
113
+ /** remote.c's `valid_remote_nick`: not empty, `.` or `..`, and no `/`. */
114
+ export function isValidRemoteNick(name: string): boolean {
115
+ return name !== "" && name !== "." && name !== ".." && !name.includes("/");
116
+ }
117
+
118
+ /**
119
+ * Parses a `remotes/<name>` file as `read_remotes_file`: each line, its trailing
120
+ * whitespace (git's `isspace`: space, `\t`, `\n`, `\r`) dropped, is a `URL:`, `Push:` or `Pull:` line (the value's leading whitespace
121
+ * dropped) or ignored.
122
+ */
123
+ export function parseRemotesFile(
124
+ text: string,
125
+ ): Pick<LegacyRemote, "urls" | "fetchRefspecs" | "pushRefspecs"> {
126
+ const urls: string[] = [];
127
+ const fetchRefspecs: string[] = [];
128
+ const pushRefspecs: string[] = [];
129
+ const lines = text.split("\n");
130
+ if (lines.at(-1) === "") lines.pop();
131
+ for (const raw of lines) {
132
+ const line = raw.replace(/[\t\n\r ]+$/, "");
133
+ const value = (prefix: string) => line.slice(prefix.length).replace(/^[\t\n\r ]+/, "");
134
+ if (line.startsWith("URL:")) urls.push(value("URL:"));
135
+ else if (line.startsWith("Push:")) pushRefspecs.push(value("Push:"));
136
+ else if (line.startsWith("Pull:")) fetchRefspecs.push(value("Pull:"));
137
+ }
138
+ return { urls, fetchRefspecs, pushRefspecs };
139
+ }
140
+
141
+ /**
142
+ * `strbuf_trim`: leading and trailing whitespace dropped as git's `isspace` (sane_ctype.h:
143
+ * space, `\t`, `\n`, `\r` only; a vertical tab or form feed is kept, as JavaScript's
144
+ * `trim()` would not).
145
+ */
146
+ function trimGitSpace(text: string): string {
147
+ return text.replace(/^[\t\n\r ]+/, "").replace(/[\t\n\r ]+$/, "");
148
+ }
149
+
150
+ /** 2.5x's `warn_about_deprecated_remote_type`, as `warning()` prints it. */
151
+ function deprecationWarning(type: "remotes" | "branches", name: string): string {
152
+ return [
153
+ `warning: reading remote from "${type}/${name}", which is nominated for removal.`,
154
+ "",
155
+ 'If you still use the "remotes/" directory it is recommended to',
156
+ "migrate to config-based remotes:",
157
+ "",
158
+ `\tgit remote rename ${name} ${name}`,
159
+ "",
160
+ "If you cannot, please let us know why you still need to use it by",
161
+ "sending an e-mail to <git@vger.kernel.org>.",
162
+ ].join("\n");
163
+ }
164
+
165
+ /**
166
+ * refs.c's `repo_default_branch_name(repo, 0)`: `init.defaultBranch` (every scope of the
167
+ * working copy's configuration), else `master` with the `advice.defaultBranchName` hint.
168
+ */
169
+ function defaultBranchName(
170
+ store: RemoteConfigStore,
171
+ compatibility: "2.43" | "2.56",
172
+ ): { name: string; hint?: string } {
173
+ const configured = store.value("init.defaultBranch");
174
+ if (configured !== undefined && configured !== "") return { name: configured };
175
+ const name = "master";
176
+ const advice = store.value("advice.defaultBranchName");
177
+ if (advice !== undefined && parseGitBool(advice) === false) return { name };
178
+ const hint =
179
+ compatibility === "2.43" ? defaultBranchHint243(name) : defaultBranchHint(name, false);
180
+ return { name, hint: hint.join("\n") };
181
+ }
182
+
183
+ /** git 2.43's `default_branch_name_advice` (an empty line is `hint: `, with its space). */
184
+ function defaultBranchHint243(name: string): string[] {
185
+ return [
186
+ `Using '${name}' as the name for the initial branch. This default branch name`,
187
+ "is subject to change. To configure the initial branch name to use in all",
188
+ "of your new repositories, which will suppress this warning, call:",
189
+ "",
190
+ "\tgit config --global init.defaultBranch <name>",
191
+ "",
192
+ "Names commonly chosen instead of 'master' are 'main', 'trunk' and",
193
+ "'development'. The just-created branch can be renamed via this command:",
194
+ "",
195
+ "\tgit branch -m <name>",
196
+ ].map((line) => `hint: ${line}`);
197
+ }
198
+
199
+ /**
200
+ * A file of the common git directory as text, or undefined when it is not a regular file
201
+ * (absent, a directory: `fopen_or_warn` reads nothing from either).
202
+ */
203
+ async function readGitFile(workingCopy: WorkingCopy, name: string): Promise<string | undefined> {
204
+ const file = await commonGitFileOf(workingCopy, name);
205
+ if (!file) return undefined;
206
+ return readText(file.files, file.path);
207
+ }
208
+
209
+ async function readText(files: FilesApi, path: string): Promise<string | undefined> {
210
+ try {
211
+ if ((await files.stats(path))?.kind !== "file") return undefined;
212
+ const chunks: Uint8Array[] = [];
213
+ for await (const chunk of files.read(path)) chunks.push(chunk);
214
+ const bytes = new Uint8Array(chunks.reduce((n, c) => n + c.length, 0));
215
+ let at = 0;
216
+ for (const chunk of chunks) {
217
+ bytes.set(chunk, at);
218
+ at += chunk.length;
219
+ }
220
+ return new TextDecoder().decode(bytes);
221
+ } catch {
222
+ return undefined;
223
+ }
224
+ }
@@ -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,