@statewalker/vcs-commands 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (568) hide show
  1. package/dist/commands/add-command.d.ts +70 -0
  2. package/dist/commands/add-command.d.ts.map +1 -1
  3. package/dist/commands/add-patch/add-patch.d.ts +7 -0
  4. package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
  5. package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
  6. package/dist/commands/am/am-command.d.ts +102 -1
  7. package/dist/commands/am/am-command.d.ts.map +1 -1
  8. package/dist/commands/am/index.d.ts +1 -0
  9. package/dist/commands/am/index.d.ts.map +1 -1
  10. package/dist/commands/am/mailsplit.d.ts +88 -0
  11. package/dist/commands/am/mailsplit.d.ts.map +1 -0
  12. package/dist/commands/apply/apply-command.d.ts +2 -0
  13. package/dist/commands/apply/apply-command.d.ts.map +1 -1
  14. package/dist/commands/apply/apply-engine.d.ts.map +1 -1
  15. package/dist/commands/apply/apply-parse.d.ts +7 -0
  16. package/dist/commands/apply/apply-parse.d.ts.map +1 -1
  17. package/dist/commands/apply/index.d.ts +1 -1
  18. package/dist/commands/apply/index.d.ts.map +1 -1
  19. package/dist/commands/bisect/bisect-command.d.ts +2 -0
  20. package/dist/commands/bisect/bisect-command.d.ts.map +1 -1
  21. package/dist/commands/blame-command.d.ts +303 -8
  22. package/dist/commands/blame-command.d.ts.map +1 -1
  23. package/dist/commands/blame-ignore.d.ts +48 -0
  24. package/dist/commands/blame-ignore.d.ts.map +1 -0
  25. package/dist/commands/branch-command.d.ts +148 -18
  26. package/dist/commands/branch-command.d.ts.map +1 -1
  27. package/dist/commands/branch-info-command.d.ts +55 -0
  28. package/dist/commands/branch-info-command.d.ts.map +1 -0
  29. package/dist/commands/branch-tracking.d.ts +106 -17
  30. package/dist/commands/branch-tracking.d.ts.map +1 -1
  31. package/dist/commands/branch-upstream-command.d.ts +83 -0
  32. package/dist/commands/branch-upstream-command.d.ts.map +1 -0
  33. package/dist/commands/check-mailmap-command.d.ts +49 -0
  34. package/dist/commands/check-mailmap-command.d.ts.map +1 -0
  35. package/dist/commands/checkout-command.d.ts +26 -3
  36. package/dist/commands/checkout-command.d.ts.map +1 -1
  37. package/dist/commands/checkout-paths.d.ts +4 -0
  38. package/dist/commands/checkout-paths.d.ts.map +1 -1
  39. package/dist/commands/cherry-command.d.ts +61 -0
  40. package/dist/commands/cherry-command.d.ts.map +1 -0
  41. package/dist/commands/cherry-pick-command.d.ts +82 -1
  42. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  43. package/dist/commands/clean-command.d.ts +44 -0
  44. package/dist/commands/clean-command.d.ts.map +1 -1
  45. package/dist/commands/clean-interactive.d.ts +56 -0
  46. package/dist/commands/clean-interactive.d.ts.map +1 -0
  47. package/dist/commands/clone-command.d.ts +116 -2
  48. package/dist/commands/clone-command.d.ts.map +1 -1
  49. package/dist/commands/commit-command.d.ts +239 -5
  50. package/dist/commands/commit-command.d.ts.map +1 -1
  51. package/dist/commands/commit-reuse.d.ts +33 -0
  52. package/dist/commands/commit-reuse.d.ts.map +1 -0
  53. package/dist/commands/config-command.d.ts +236 -0
  54. package/dist/commands/config-command.d.ts.map +1 -0
  55. package/dist/commands/config-value-types.d.ts +91 -0
  56. package/dist/commands/config-value-types.d.ts.map +1 -0
  57. package/dist/commands/core-config.d.ts +20 -0
  58. package/dist/commands/core-config.d.ts.map +1 -1
  59. package/dist/commands/describe-command.d.ts +71 -64
  60. package/dist/commands/describe-command.d.ts.map +1 -1
  61. package/dist/commands/diff-color-config.d.ts +73 -0
  62. package/dist/commands/diff-color-config.d.ts.map +1 -0
  63. package/dist/commands/diff-command.d.ts +369 -10
  64. package/dist/commands/diff-command.d.ts.map +1 -1
  65. package/dist/commands/fetch-command.d.ts +80 -0
  66. package/dist/commands/fetch-command.d.ts.map +1 -1
  67. package/dist/commands/fetch-multiple-command.d.ts +193 -0
  68. package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
  69. package/dist/commands/fmt-merge-msg-command.d.ts +124 -0
  70. package/dist/commands/fmt-merge-msg-command.d.ts.map +1 -0
  71. package/dist/commands/fork-point.d.ts +38 -0
  72. package/dist/commands/fork-point.d.ts.map +1 -0
  73. package/dist/commands/format-patch-command.d.ts +69 -3
  74. package/dist/commands/format-patch-command.d.ts.map +1 -1
  75. package/dist/commands/fsck/fetch-fsck.d.ts +51 -0
  76. package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -1
  77. package/dist/commands/gc-command.d.ts +8 -0
  78. package/dist/commands/gc-command.d.ts.map +1 -1
  79. package/dist/commands/git-describe.d.ts +81 -4
  80. package/dist/commands/git-describe.d.ts.map +1 -1
  81. package/dist/commands/git-hooks.d.ts +50 -1
  82. package/dist/commands/git-hooks.d.ts.map +1 -1
  83. package/dist/commands/grep/grep-command.d.ts +210 -0
  84. package/dist/commands/grep/grep-command.d.ts.map +1 -0
  85. package/dist/commands/grep/grep-engine.d.ts +218 -0
  86. package/dist/commands/grep/grep-engine.d.ts.map +1 -0
  87. package/dist/commands/grep/index.d.ts +3 -0
  88. package/dist/commands/grep/index.d.ts.map +1 -0
  89. package/dist/commands/index-adder.d.ts +13 -2
  90. package/dist/commands/index-adder.d.ts.map +1 -1
  91. package/dist/commands/index.d.ts +38 -0
  92. package/dist/commands/index.d.ts.map +1 -1
  93. package/dist/commands/index.js +5 -3
  94. package/dist/commands/init-command.d.ts +89 -0
  95. package/dist/commands/init-command.d.ts.map +1 -1
  96. package/dist/commands/interpret-trailers-command.d.ts +90 -0
  97. package/dist/commands/interpret-trailers-command.d.ts.map +1 -0
  98. package/dist/commands/line-log.d.ts +161 -0
  99. package/dist/commands/line-log.d.ts.map +1 -0
  100. package/dist/commands/local-transport.d.ts +36 -5
  101. package/dist/commands/local-transport.d.ts.map +1 -1
  102. package/dist/commands/log-command.d.ts +527 -13
  103. package/dist/commands/log-command.d.ts.map +1 -1
  104. package/dist/commands/log-graph.d.ts +30 -3
  105. package/dist/commands/log-graph.d.ts.map +1 -1
  106. package/dist/commands/log-output.d.ts +199 -6
  107. package/dist/commands/log-output.d.ts.map +1 -1
  108. package/dist/commands/ls-remote-command.d.ts +2 -0
  109. package/dist/commands/ls-remote-command.d.ts.map +1 -1
  110. package/dist/commands/mailmap.d.ts +53 -0
  111. package/dist/commands/mailmap.d.ts.map +1 -1
  112. package/dist/commands/merge-base-command.d.ts +60 -0
  113. package/dist/commands/merge-base-command.d.ts.map +1 -0
  114. package/dist/commands/merge-bases.d.ts +23 -0
  115. package/dist/commands/merge-bases.d.ts.map +1 -1
  116. package/dist/commands/merge-command.d.ts +147 -10
  117. package/dist/commands/merge-command.d.ts.map +1 -1
  118. package/dist/commands/merge-drivers.d.ts +2 -0
  119. package/dist/commands/merge-drivers.d.ts.map +1 -1
  120. package/dist/commands/merge-strategy-options.d.ts +69 -0
  121. package/dist/commands/merge-strategy-options.d.ts.map +1 -0
  122. package/dist/commands/merge-support.d.ts +10 -0
  123. package/dist/commands/merge-support.d.ts.map +1 -1
  124. package/dist/commands/message-cleanup.d.ts +2 -0
  125. package/dist/commands/message-cleanup.d.ts.map +1 -1
  126. package/dist/commands/mv-command.d.ts +4 -0
  127. package/dist/commands/mv-command.d.ts.map +1 -1
  128. package/dist/commands/name-rev-command.d.ts +65 -0
  129. package/dist/commands/name-rev-command.d.ts.map +1 -0
  130. package/dist/commands/name-rev.d.ts +136 -0
  131. package/dist/commands/name-rev.d.ts.map +1 -0
  132. package/dist/commands/notes-command.d.ts.map +1 -1
  133. package/dist/commands/octopus-merge.d.ts +26 -1
  134. package/dist/commands/octopus-merge.d.ts.map +1 -1
  135. package/dist/commands/ort-merge.d.ts +16 -0
  136. package/dist/commands/ort-merge.d.ts.map +1 -1
  137. package/dist/commands/ort-recursive.d.ts.map +1 -1
  138. package/dist/commands/patch-id.d.ts +58 -0
  139. package/dist/commands/patch-id.d.ts.map +1 -1
  140. package/dist/commands/pathspec-file.d.ts +39 -0
  141. package/dist/commands/pathspec-file.d.ts.map +1 -0
  142. package/dist/commands/pathspec.d.ts +3 -0
  143. package/dist/commands/pathspec.d.ts.map +1 -1
  144. package/dist/commands/pretty-format.d.ts +43 -3
  145. package/dist/commands/pretty-format.d.ts.map +1 -1
  146. package/dist/commands/promisor-remote.d.ts.map +1 -1
  147. package/dist/commands/pull-command.d.ts +186 -32
  148. package/dist/commands/pull-command.d.ts.map +1 -1
  149. package/dist/commands/push-command.d.ts +225 -9
  150. package/dist/commands/push-command.d.ts.map +1 -1
  151. package/dist/commands/range-diff/index.d.ts +4 -0
  152. package/dist/commands/range-diff/index.d.ts.map +1 -0
  153. package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
  154. package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
  155. package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
  156. package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
  157. package/dist/commands/range-diff/range-diff.d.ts +106 -0
  158. package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
  159. package/dist/commands/read-tree-command.d.ts +20 -0
  160. package/dist/commands/read-tree-command.d.ts.map +1 -1
  161. package/dist/commands/rebase-command.d.ts +189 -8
  162. package/dist/commands/rebase-command.d.ts.map +1 -1
  163. package/dist/commands/ref-filter/for-each-ref-command.d.ts +121 -0
  164. package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -0
  165. package/dist/commands/ref-filter/index.d.ts +8 -0
  166. package/dist/commands/ref-filter/index.d.ts.map +1 -0
  167. package/dist/commands/ref-filter/ref-atoms.d.ts +88 -0
  168. package/dist/commands/ref-filter/ref-atoms.d.ts.map +1 -0
  169. package/dist/commands/ref-filter/ref-filter.d.ts +178 -0
  170. package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -0
  171. package/dist/commands/ref-filter/ref-format.d.ts +222 -0
  172. package/dist/commands/ref-filter/ref-format.d.ts.map +1 -0
  173. package/dist/commands/ref-filter/ref-listing-command.d.ts +56 -0
  174. package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -0
  175. package/dist/commands/ref-filter/ref-quote.d.ts +20 -0
  176. package/dist/commands/ref-filter/ref-quote.d.ts.map +1 -0
  177. package/dist/commands/ref-filter/version-compare.d.ts +20 -0
  178. package/dist/commands/ref-filter/version-compare.d.ts.map +1 -0
  179. package/dist/commands/reflog-command.d.ts +120 -0
  180. package/dist/commands/reflog-command.d.ts.map +1 -1
  181. package/dist/commands/reflog-walk.d.ts +72 -0
  182. package/dist/commands/reflog-walk.d.ts.map +1 -0
  183. package/dist/commands/remerge-diff.d.ts +59 -0
  184. package/dist/commands/remerge-diff.d.ts.map +1 -0
  185. package/dist/commands/remote-command.d.ts +179 -29
  186. package/dist/commands/remote-command.d.ts.map +1 -1
  187. package/dist/commands/remote-show-command.d.ts +204 -0
  188. package/dist/commands/remote-show-command.d.ts.map +1 -0
  189. package/dist/commands/remote-transport.d.ts +7 -1
  190. package/dist/commands/remote-transport.d.ts.map +1 -1
  191. package/dist/commands/reset-command.d.ts +21 -4
  192. package/dist/commands/reset-command.d.ts.map +1 -1
  193. package/dist/commands/restore-command.d.ts +9 -3
  194. package/dist/commands/restore-command.d.ts.map +1 -1
  195. package/dist/commands/rev-filter/commit-filter.d.ts +95 -0
  196. package/dist/commands/rev-filter/commit-filter.d.ts.map +1 -0
  197. package/dist/commands/rev-filter/commit-grep.d.ts +91 -0
  198. package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -0
  199. package/dist/commands/rev-filter/index.d.ts +3 -0
  200. package/dist/commands/rev-filter/index.d.ts.map +1 -0
  201. package/dist/commands/rev-list-command.d.ts +226 -2
  202. package/dist/commands/rev-list-command.d.ts.map +1 -1
  203. package/dist/commands/revert-command.d.ts +54 -1
  204. package/dist/commands/revert-command.d.ts.map +1 -1
  205. package/dist/commands/revision-range.d.ts +34 -1
  206. package/dist/commands/revision-range.d.ts.map +1 -1
  207. package/dist/commands/revision-resolver.d.ts +15 -0
  208. package/dist/commands/revision-resolver.d.ts.map +1 -1
  209. package/dist/commands/rm-command.d.ts +70 -2
  210. package/dist/commands/rm-command.d.ts.map +1 -1
  211. package/dist/commands/sequencer-pick.d.ts +186 -5
  212. package/dist/commands/sequencer-pick.d.ts.map +1 -1
  213. package/dist/commands/sequencer-support.d.ts +12 -1
  214. package/dist/commands/sequencer-support.d.ts.map +1 -1
  215. package/dist/commands/serve-repository.d.ts +7 -0
  216. package/dist/commands/serve-repository.d.ts.map +1 -1
  217. package/dist/commands/shortlog-command.d.ts +109 -0
  218. package/dist/commands/shortlog-command.d.ts.map +1 -0
  219. package/dist/commands/shortlog.d.ts +151 -0
  220. package/dist/commands/shortlog.d.ts.map +1 -0
  221. package/dist/commands/show-command.d.ts +130 -0
  222. package/dist/commands/show-command.d.ts.map +1 -0
  223. package/dist/commands/show-commit.d.ts +11 -0
  224. package/dist/commands/show-commit.d.ts.map +1 -0
  225. package/dist/commands/signature-check.d.ts +164 -0
  226. package/dist/commands/signature-check.d.ts.map +1 -0
  227. package/dist/commands/signing.d.ts +160 -0
  228. package/dist/commands/signing.d.ts.map +1 -0
  229. package/dist/commands/sparse-checkout-command.d.ts.map +1 -1
  230. package/dist/commands/sparse-index-view.d.ts +45 -0
  231. package/dist/commands/sparse-index-view.d.ts.map +1 -0
  232. package/dist/commands/ssh-signer.d.ts +29 -0
  233. package/dist/commands/ssh-signer.d.ts.map +1 -0
  234. package/dist/commands/ssh-verifier.d.ts +42 -0
  235. package/dist/commands/ssh-verifier.d.ts.map +1 -0
  236. package/dist/commands/stash-apply-command.d.ts +5 -0
  237. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  238. package/dist/commands/stash-branch-command.d.ts +34 -0
  239. package/dist/commands/stash-branch-command.d.ts.map +1 -0
  240. package/dist/commands/stash-create-command.d.ts +17 -0
  241. package/dist/commands/stash-create-command.d.ts.map +1 -1
  242. package/dist/commands/stash-info.d.ts +93 -0
  243. package/dist/commands/stash-info.d.ts.map +1 -0
  244. package/dist/commands/stash-list-command.d.ts +16 -0
  245. package/dist/commands/stash-list-command.d.ts.map +1 -1
  246. package/dist/commands/stash-pop-command.d.ts +39 -0
  247. package/dist/commands/stash-pop-command.d.ts.map +1 -0
  248. package/dist/commands/stash-show-command.d.ts +48 -0
  249. package/dist/commands/stash-show-command.d.ts.map +1 -0
  250. package/dist/commands/stash-store-command.d.ts +29 -0
  251. package/dist/commands/stash-store-command.d.ts.map +1 -0
  252. package/dist/commands/stash-working-tree.d.ts.map +1 -1
  253. package/dist/commands/status-command.d.ts +31 -2
  254. package/dist/commands/status-command.d.ts.map +1 -1
  255. package/dist/commands/status-header.d.ts +5 -0
  256. package/dist/commands/status-header.d.ts.map +1 -1
  257. package/dist/commands/submodule-add-command.d.ts +89 -0
  258. package/dist/commands/submodule-add-command.d.ts.map +1 -0
  259. package/dist/commands/submodule-auth.d.ts +90 -0
  260. package/dist/commands/submodule-auth.d.ts.map +1 -0
  261. package/dist/commands/submodule-commands.d.ts +463 -0
  262. package/dist/commands/submodule-commands.d.ts.map +1 -0
  263. package/dist/commands/submodule-fetch.d.ts +149 -0
  264. package/dist/commands/submodule-fetch.d.ts.map +1 -0
  265. package/dist/commands/submodule-model.d.ts +296 -0
  266. package/dist/commands/submodule-model.d.ts.map +1 -0
  267. package/dist/commands/submodule-unpack.d.ts +120 -0
  268. package/dist/commands/submodule-unpack.d.ts.map +1 -0
  269. package/dist/commands/submodule-update-command.d.ts +206 -0
  270. package/dist/commands/submodule-update-command.d.ts.map +1 -0
  271. package/dist/commands/subtree-shift.d.ts +27 -0
  272. package/dist/commands/subtree-shift.d.ts.map +1 -0
  273. package/dist/commands/switch-command.d.ts +3 -0
  274. package/dist/commands/switch-command.d.ts.map +1 -1
  275. package/dist/commands/tag-command.d.ts +259 -10
  276. package/dist/commands/tag-command.d.ts.map +1 -1
  277. package/dist/commands/trailers.d.ts +218 -17
  278. package/dist/commands/trailers.d.ts.map +1 -1
  279. package/dist/commands/tree-restore.d.ts +7 -0
  280. package/dist/commands/tree-restore.d.ts.map +1 -1
  281. package/dist/commands/verify-command.d.ts +92 -0
  282. package/dist/commands/verify-command.d.ts.map +1 -0
  283. package/dist/commands/worktree-add-command.d.ts +79 -7
  284. package/dist/commands/worktree-add-command.d.ts.map +1 -1
  285. package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
  286. package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
  287. package/dist/commands/worktree-path-rules.d.ts +66 -0
  288. package/dist/commands/worktree-path-rules.d.ts.map +1 -0
  289. package/dist/commands/worktree-remove-command.d.ts +10 -3
  290. package/dist/commands/worktree-remove-command.d.ts.map +1 -1
  291. package/dist/commands/worktree-repair-command.d.ts +15 -2
  292. package/dist/commands/worktree-repair-command.d.ts.map +1 -1
  293. package/dist/commands/worktree-support.d.ts +5 -0
  294. package/dist/commands/worktree-support.d.ts.map +1 -1
  295. package/dist/{commands-DIJ91NnD.js → commands-CNvli5bl.js} +49442 -54941
  296. package/dist/errors/checkout-errors.d.ts +19 -0
  297. package/dist/errors/checkout-errors.d.ts.map +1 -1
  298. package/dist/errors/command-errors.d.ts +25 -0
  299. package/dist/errors/command-errors.d.ts.map +1 -1
  300. package/dist/errors/index.js +85 -3
  301. package/dist/errors/ref-errors.d.ts +19 -0
  302. package/dist/errors/ref-errors.d.ts.map +1 -1
  303. package/dist/errors/worktree-errors.d.ts +6 -1
  304. package/dist/errors/worktree-errors.d.ts.map +1 -1
  305. package/dist/fsck-CPeDh9fh.js +5138 -0
  306. package/dist/git-command.d.ts +58 -2
  307. package/dist/git-command.d.ts.map +1 -1
  308. package/dist/git.d.ts +363 -1
  309. package/dist/git.d.ts.map +1 -1
  310. package/dist/guarded-transport-command.d.ts +82 -0
  311. package/dist/guarded-transport-command.d.ts.map +1 -0
  312. package/dist/index.d.ts +1 -0
  313. package/dist/index.d.ts.map +1 -1
  314. package/dist/index.js +6 -5
  315. package/dist/remote-config/index.d.ts +1 -1
  316. package/dist/remote-config/index.d.ts.map +1 -1
  317. package/dist/remote-config/remote-config-store.d.ts +55 -0
  318. package/dist/remote-config/remote-config-store.d.ts.map +1 -1
  319. package/dist/remote-transport-CCmBadm-.js +1606 -0
  320. package/dist/rename/detect-renames.d.ts +20 -0
  321. package/dist/rename/detect-renames.d.ts.map +1 -1
  322. package/dist/rename/diffcore-break.d.ts +51 -0
  323. package/dist/rename/diffcore-break.d.ts.map +1 -0
  324. package/dist/rename/index.d.ts +1 -0
  325. package/dist/rename/index.d.ts.map +1 -1
  326. package/dist/results/blame-format.d.ts +62 -1
  327. package/dist/results/blame-format.d.ts.map +1 -1
  328. package/dist/results/clone-result.d.ts +9 -0
  329. package/dist/results/clone-result.d.ts.map +1 -1
  330. package/dist/results/combined-diff.d.ts +3 -0
  331. package/dist/results/combined-diff.d.ts.map +1 -1
  332. package/dist/results/diff-check.d.ts +38 -0
  333. package/dist/results/diff-check.d.ts.map +1 -0
  334. package/dist/results/diff-color.d.ts +135 -0
  335. package/dist/results/diff-color.d.ts.map +1 -0
  336. package/dist/results/diff-dirstat.d.ts +36 -0
  337. package/dist/results/diff-dirstat.d.ts.map +1 -0
  338. package/dist/results/diff-entry.d.ts +10 -0
  339. package/dist/results/diff-entry.d.ts.map +1 -1
  340. package/dist/results/diff-formatter.d.ts.map +1 -1
  341. package/dist/results/diff-output.d.ts +103 -1
  342. package/dist/results/diff-output.d.ts.map +1 -1
  343. package/dist/results/diff-pickaxe.d.ts +67 -0
  344. package/dist/results/diff-pickaxe.d.ts.map +1 -0
  345. package/dist/results/diff-words.d.ts +55 -0
  346. package/dist/results/diff-words.d.ts.map +1 -0
  347. package/dist/results/fetch-result.d.ts +12 -1
  348. package/dist/results/fetch-result.d.ts.map +1 -1
  349. package/dist/results/index.d.ts +6 -0
  350. package/dist/results/index.d.ts.map +1 -1
  351. package/dist/results/index.js +2 -2
  352. package/dist/results/init-result.d.ts +8 -1
  353. package/dist/results/init-result.d.ts.map +1 -1
  354. package/dist/results/line-range-hunks.d.ts +27 -0
  355. package/dist/results/line-range-hunks.d.ts.map +1 -0
  356. package/dist/results/merge-result.d.ts +8 -1
  357. package/dist/results/merge-result.d.ts.map +1 -1
  358. package/dist/results/pull-result.d.ts +11 -0
  359. package/dist/results/pull-result.d.ts.map +1 -1
  360. package/dist/results/push-result.d.ts +12 -0
  361. package/dist/results/push-result.d.ts.map +1 -1
  362. package/dist/results/rebase-result.d.ts +2 -0
  363. package/dist/results/rebase-result.d.ts.map +1 -1
  364. package/dist/results/stash-result.d.ts +6 -0
  365. package/dist/results/stash-result.d.ts.map +1 -1
  366. package/dist/results/status-result.d.ts +1 -1
  367. package/dist/results/status-result.d.ts.map +1 -1
  368. package/dist/results-BDuEgdLU.js +46847 -0
  369. package/dist/transport-command.d.ts +14 -0
  370. package/dist/transport-command.d.ts.map +1 -1
  371. package/dist/whitespace/index.d.ts +2 -0
  372. package/dist/whitespace/index.d.ts.map +1 -0
  373. package/dist/whitespace/whitespace-rule.d.ts +94 -0
  374. package/dist/whitespace/whitespace-rule.d.ts.map +1 -0
  375. package/package.json +12 -12
  376. package/src/commands/add-command.ts +293 -17
  377. package/src/commands/add-patch/add-patch.ts +8 -0
  378. package/src/commands/add-patch/patch-backend.ts +20 -2
  379. package/src/commands/am/am-command.ts +400 -46
  380. package/src/commands/am/index.ts +1 -0
  381. package/src/commands/am/mailsplit.ts +326 -0
  382. package/src/commands/apply/apply-command.ts +58 -15
  383. package/src/commands/apply/apply-engine.ts +1 -1
  384. package/src/commands/apply/apply-parse.ts +17 -8
  385. package/src/commands/apply/index.ts +8 -1
  386. package/src/commands/bisect/bisect-command.ts +18 -5
  387. package/src/commands/blame-command.ts +1450 -51
  388. package/src/commands/blame-ignore.ts +307 -0
  389. package/src/commands/branch-command.ts +528 -53
  390. package/src/commands/branch-info-command.ts +150 -0
  391. package/src/commands/branch-tracking.ts +335 -60
  392. package/src/commands/branch-upstream-command.ts +218 -0
  393. package/src/commands/check-mailmap-command.ts +129 -0
  394. package/src/commands/checkout-command.ts +166 -55
  395. package/src/commands/checkout-paths.ts +28 -0
  396. package/src/commands/cherry-command.ts +187 -0
  397. package/src/commands/cherry-pick-command.ts +185 -1
  398. package/src/commands/clean-command.ts +126 -15
  399. package/src/commands/clean-interactive.ts +522 -0
  400. package/src/commands/clone-command.ts +598 -45
  401. package/src/commands/commit-command.ts +925 -74
  402. package/src/commands/commit-reuse.ts +94 -0
  403. package/src/commands/config-command.ts +1256 -0
  404. package/src/commands/config-value-types.ts +358 -0
  405. package/src/commands/core-config.ts +40 -0
  406. package/src/commands/describe-command.ts +341 -254
  407. package/src/commands/diff-color-config.ts +274 -0
  408. package/src/commands/diff-command.ts +1619 -99
  409. package/src/commands/fetch-command.ts +495 -14
  410. package/src/commands/fetch-multiple-command.ts +665 -0
  411. package/src/commands/fmt-merge-msg-command.ts +715 -0
  412. package/src/commands/fork-point.ts +63 -0
  413. package/src/commands/format-patch-command.ts +496 -116
  414. package/src/commands/fsck/fetch-fsck.ts +172 -18
  415. package/src/commands/gc-command.ts +31 -1
  416. package/src/commands/git-describe.ts +460 -201
  417. package/src/commands/git-hooks.ts +123 -3
  418. package/src/commands/grep/grep-command.ts +1077 -0
  419. package/src/commands/grep/grep-engine.ts +1024 -0
  420. package/src/commands/grep/index.ts +2 -0
  421. package/src/commands/index-adder.ts +46 -7
  422. package/src/commands/index.ts +43 -0
  423. package/src/commands/init-command.ts +603 -49
  424. package/src/commands/interpret-trailers-command.ts +256 -0
  425. package/src/commands/line-log.ts +931 -0
  426. package/src/commands/local-transport.ts +109 -10
  427. package/src/commands/log-command.ts +2599 -326
  428. package/src/commands/log-graph.ts +129 -29
  429. package/src/commands/log-output.ts +449 -27
  430. package/src/commands/ls-remote-command.ts +5 -0
  431. package/src/commands/mailmap.ts +155 -0
  432. package/src/commands/merge-base-command.ts +170 -0
  433. package/src/commands/merge-bases.ts +63 -8
  434. package/src/commands/merge-command.ts +601 -95
  435. package/src/commands/merge-drivers.ts +3 -0
  436. package/src/commands/merge-strategy-options.ts +224 -0
  437. package/src/commands/merge-support.ts +115 -22
  438. package/src/commands/message-cleanup.ts +1 -1
  439. package/src/commands/mv-command.ts +6 -3
  440. package/src/commands/name-rev-command.ts +184 -0
  441. package/src/commands/name-rev.ts +762 -0
  442. package/src/commands/notes-command.ts +11 -1
  443. package/src/commands/octopus-merge.ts +35 -11
  444. package/src/commands/ort-merge.ts +41 -7
  445. package/src/commands/ort-recursive.ts +40 -2
  446. package/src/commands/patch-id.ts +109 -0
  447. package/src/commands/pathspec-file.ts +72 -0
  448. package/src/commands/pathspec.ts +14 -2
  449. package/src/commands/pretty-format.ts +103 -19
  450. package/src/commands/promisor-remote.ts +10 -1
  451. package/src/commands/pull-command.ts +734 -221
  452. package/src/commands/push-command.ts +1035 -68
  453. package/src/commands/range-diff/index.ts +3 -0
  454. package/src/commands/range-diff/linear-assignment.ts +203 -0
  455. package/src/commands/range-diff/range-diff-command.ts +433 -0
  456. package/src/commands/range-diff/range-diff.ts +617 -0
  457. package/src/commands/read-tree-command.ts +102 -4
  458. package/src/commands/rebase-command.ts +1074 -194
  459. package/src/commands/ref-filter/for-each-ref-command.ts +298 -0
  460. package/src/commands/ref-filter/index.ts +7 -0
  461. package/src/commands/ref-filter/ref-atoms.ts +581 -0
  462. package/src/commands/ref-filter/ref-filter.ts +651 -0
  463. package/src/commands/ref-filter/ref-format.ts +1070 -0
  464. package/src/commands/ref-filter/ref-listing-command.ts +421 -0
  465. package/src/commands/ref-filter/ref-quote.ts +69 -0
  466. package/src/commands/ref-filter/version-compare.ts +177 -0
  467. package/src/commands/reflog-command.ts +492 -2
  468. package/src/commands/reflog-walk.ts +234 -0
  469. package/src/commands/remerge-diff.ts +241 -0
  470. package/src/commands/remote-command.ts +537 -69
  471. package/src/commands/remote-show-command.ts +836 -0
  472. package/src/commands/remote-transport.ts +9 -1
  473. package/src/commands/reset-command.ts +114 -34
  474. package/src/commands/restore-command.ts +27 -41
  475. package/src/commands/rev-filter/commit-filter.ts +159 -0
  476. package/src/commands/rev-filter/commit-grep.ts +444 -0
  477. package/src/commands/rev-filter/index.ts +2 -0
  478. package/src/commands/rev-list-command.ts +578 -15
  479. package/src/commands/revert-command.ts +123 -1
  480. package/src/commands/revision-range.ts +207 -5
  481. package/src/commands/revision-resolver.ts +23 -8
  482. package/src/commands/rm-command.ts +282 -21
  483. package/src/commands/sequencer-pick.ts +818 -111
  484. package/src/commands/sequencer-support.ts +184 -4
  485. package/src/commands/serve-repository.ts +18 -3
  486. package/src/commands/shortlog-command.ts +354 -0
  487. package/src/commands/shortlog.ts +361 -0
  488. package/src/commands/show-command.ts +491 -0
  489. package/src/commands/show-commit.ts +24 -0
  490. package/src/commands/signature-check.ts +657 -0
  491. package/src/commands/signing.ts +385 -0
  492. package/src/commands/sparse-checkout-command.ts +2 -9
  493. package/src/commands/sparse-checkout-support.ts +2 -2
  494. package/src/commands/sparse-index-view.ts +135 -0
  495. package/src/commands/ssh-signer.ts +199 -0
  496. package/src/commands/ssh-verifier.ts +523 -0
  497. package/src/commands/stash-apply-command.ts +16 -4
  498. package/src/commands/stash-branch-command.ts +88 -0
  499. package/src/commands/stash-create-command.ts +28 -0
  500. package/src/commands/stash-info.ts +243 -0
  501. package/src/commands/stash-list-command.ts +33 -0
  502. package/src/commands/stash-pop-command.ts +83 -0
  503. package/src/commands/stash-show-command.ts +141 -0
  504. package/src/commands/stash-store-command.ts +82 -0
  505. package/src/commands/stash-working-tree.ts +2 -2
  506. package/src/commands/status-command.ts +120 -27
  507. package/src/commands/status-format.ts +1 -1
  508. package/src/commands/status-header.ts +41 -7
  509. package/src/commands/submodule-add-command.ts +509 -0
  510. package/src/commands/submodule-auth.ts +276 -0
  511. package/src/commands/submodule-commands.ts +1835 -0
  512. package/src/commands/submodule-fetch.ts +789 -0
  513. package/src/commands/submodule-model.ts +938 -0
  514. package/src/commands/submodule-unpack.ts +265 -0
  515. package/src/commands/submodule-update-command.ts +1126 -0
  516. package/src/commands/subtree-shift.ts +215 -0
  517. package/src/commands/switch-command.ts +12 -1
  518. package/src/commands/tag-command.ts +876 -64
  519. package/src/commands/trailers.ts +837 -100
  520. package/src/commands/tree-restore.ts +44 -11
  521. package/src/commands/verify-command.ts +235 -0
  522. package/src/commands/worktree-add-command.ts +268 -24
  523. package/src/commands/worktree-overwrite-checks.ts +5 -0
  524. package/src/commands/worktree-path-rules.ts +183 -0
  525. package/src/commands/worktree-remove-command.ts +39 -5
  526. package/src/commands/worktree-repair-command.ts +52 -5
  527. package/src/commands/worktree-support.ts +22 -1
  528. package/src/errors/checkout-errors.ts +29 -0
  529. package/src/errors/command-errors.ts +37 -1
  530. package/src/errors/ref-errors.ts +23 -0
  531. package/src/errors/worktree-errors.ts +8 -1
  532. package/src/git-command.ts +153 -2
  533. package/src/git.ts +550 -1
  534. package/src/guarded-transport-command.ts +171 -0
  535. package/src/index.ts +1 -0
  536. package/src/remote-config/index.ts +2 -0
  537. package/src/remote-config/remote-config-store.ts +101 -0
  538. package/src/rename/detect-renames.ts +42 -8
  539. package/src/rename/diffcore-break.ts +166 -0
  540. package/src/rename/index.ts +1 -0
  541. package/src/results/blame-format.ts +268 -43
  542. package/src/results/clone-result.ts +6 -0
  543. package/src/results/combined-diff.ts +38 -18
  544. package/src/results/diff-check.ts +185 -0
  545. package/src/results/diff-color.ts +868 -0
  546. package/src/results/diff-dirstat.ts +117 -0
  547. package/src/results/diff-entry.ts +12 -0
  548. package/src/results/diff-formatter.ts +1 -0
  549. package/src/results/diff-output.ts +322 -32
  550. package/src/results/diff-pickaxe.ts +304 -0
  551. package/src/results/diff-words.ts +395 -0
  552. package/src/results/fetch-result.ts +12 -1
  553. package/src/results/index.ts +6 -0
  554. package/src/results/init-result.ts +10 -1
  555. package/src/results/line-range-hunks.ts +126 -0
  556. package/src/results/merge-result.ts +9 -0
  557. package/src/results/pull-result.ts +7 -0
  558. package/src/results/push-result.ts +12 -0
  559. package/src/results/rebase-result.ts +3 -0
  560. package/src/results/stash-result.ts +7 -0
  561. package/src/results/status-result.ts +2 -2
  562. package/src/transport-command.ts +34 -3
  563. package/src/whitespace/index.ts +1 -0
  564. package/src/{commands/apply/whitespace.ts → whitespace/whitespace-rule.ts} +173 -23
  565. package/dist/commands/apply/whitespace.d.ts +0 -58
  566. package/dist/commands/apply/whitespace.d.ts.map +0 -1
  567. package/dist/git-command-BGiOJ8Zk.js +0 -7246
  568. package/dist/results-WVlBhVb1.js +0 -2935
@@ -1,26 +1,42 @@
1
1
  import {
2
+ compareRefNames,
2
3
  type FilesApi,
3
4
  historyWithoutLazyFetch,
4
5
  isSymbolicRef,
6
+ isValidRefName,
5
7
  type ObjectId,
6
8
  parseObjectFilter,
7
9
  } from "@statewalker/vcs-core";
8
- import { computeAlternatePath, HostPaths, hostRootOf } from "@statewalker/vcs-store-files";
10
+ import {
11
+ CONFIG_REGEX_NONE,
12
+ computeAlternatePath,
13
+ GitWorkingCopyConfig,
14
+ HostPaths,
15
+ hostRootOf,
16
+ parseConfigKey,
17
+ setConfigMultivarText,
18
+ } from "@statewalker/vcs-store-files";
9
19
  import {
10
20
  createRepositoryFacade,
11
21
  createTransportRefStore,
12
22
  FetchCheckError,
13
23
  fetchFromConnection,
24
+ mapRefs,
25
+ missingSources,
14
26
  type RefspecResolver,
27
+ type RemoteRef,
28
+ refPrefixes,
29
+ ShallowRemoteRejectedError,
15
30
  type FetchOptions as TransportFetchOptions,
16
31
  } from "@statewalker/vcs-transport";
32
+ import { parseGitBool } from "@statewalker/vcs-utils";
17
33
  import { parseGitInt } from "@statewalker/vcs-utils/encoding";
18
34
  import type { ObjectFormat } from "@statewalker/vcs-utils/hash";
19
35
  import type { OpenedRepository, WorkingCopy, Worktree } from "@statewalker/vcs-working-tree";
20
-
21
36
  import {
22
37
  CloneCheckoutError,
23
38
  CloneDestinationError,
39
+ GitApiError,
24
40
  InvalidArgumentError,
25
41
  InvalidRemoteError,
26
42
  RefNotFoundError,
@@ -43,7 +59,10 @@ import { isValidRemoteName } from "./remote-command.js";
43
59
  import { withRemoteUploadPack } from "./remote-transport.js";
44
60
  import { SparseCheckoutCommand } from "./sparse-checkout-command.js";
45
61
  import { SparseUnpack } from "./sparse-checkout-support.js";
62
+ import { SubmoduleCommandError, type SubmoduleCommandResult } from "./submodule-commands.js";
63
+ import { SubmoduleUpdateCommand } from "./submodule-update-command.js";
46
64
  import { checkoutFreshTree } from "./tree-restore.js";
65
+ import { worktreePathRules } from "./worktree-path-rules.js";
47
66
  import { repositoryPlaceOf, worktreeAdminWorkingCopy } from "./worktree-support.js";
48
67
 
49
68
  /** The settings a clone reopened with another object format runs with again. */
@@ -57,6 +76,11 @@ const CLONE_SETTINGS = [
57
76
  "noCheckout",
58
77
  "sparse",
59
78
  "remoteName",
79
+ "remoteExplicit",
80
+ "revision",
81
+ "rejectShallow",
82
+ "serverOptions",
83
+ "compatibility",
60
84
  "cloneAllBranches",
61
85
  "mirror",
62
86
  "singleBranch",
@@ -69,6 +93,10 @@ const CLONE_SETTINGS = [
69
93
  "local",
70
94
  "dissociate",
71
95
  "references",
96
+ "recurseSubmodules",
97
+ "shallowSubmodules",
98
+ "alsoFilterSubmodules",
99
+ "remoteSubmodules",
72
100
  "credentials",
73
101
  "timeout",
74
102
  "headers",
@@ -159,6 +187,18 @@ export class CloneCommand extends TransportCommand<CloneResult> {
159
187
  private noCheckout = false;
160
188
  private sparse = false;
161
189
  private remoteName = "origin";
190
+ /** `-o`/`--origin` given: `clone.defaultRemoteName` is not read */
191
+ private remoteExplicit = false;
192
+ /** `-c`/`--config` entries (`key=value`, or `key` for true) */
193
+ private configEntries: string[] = [];
194
+ /** `--revision` (git 2.49+) */
195
+ private revision?: string;
196
+ /** `--[no-]reject-shallow`; unset: `clone.rejectShallow` */
197
+ private rejectShallow?: boolean;
198
+ /** `--server-option` values */
199
+ private serverOptions: string[] = [];
200
+ /** The git version reproduced; default the hooks' */
201
+ private compatibility?: "2.43" | "2.56";
162
202
  private cloneAllBranches = true;
163
203
  private mirror = false;
164
204
  private singleBranch?: boolean;
@@ -173,6 +213,12 @@ export class CloneCommand extends TransportCommand<CloneResult> {
173
213
  private dissociate = false;
174
214
  /** `--reference` (required) and `--reference-if-able` paths, in the order given */
175
215
  private references: { path: string; required: boolean }[] = [];
216
+ /** `--recurse-submodules[=<pathspec>]` values, in the order given */
217
+ private recurseSubmodules: string[] = [];
218
+ private shallowSubmodules = false;
219
+ /** `--[no-]also-filter-submodules`; unset: `clone.filterSubmodules` */
220
+ private alsoFilterSubmodules?: boolean;
221
+ private remoteSubmodules = false;
176
222
 
177
223
  /**
178
224
  * The destination directory as `git clone <url> <directory>` names it, for messages only
@@ -325,15 +371,84 @@ export class CloneCommand extends TransportCommand<CloneResult> {
325
371
  }
326
372
 
327
373
  /**
328
- * Set the remote name.
374
+ * Set the remote name (`-o`/`--origin`).
329
375
  *
330
- * Default is "origin".
376
+ * Default `clone.defaultRemoteName` (the `-c` values included), else "origin".
331
377
  *
332
378
  * @param remoteName Remote name
333
379
  */
334
380
  setRemote(remoteName: string): this {
335
381
  this.checkCallable();
336
382
  this.remoteName = remoteName;
383
+ this.remoteExplicit = true;
384
+ return this;
385
+ }
386
+
387
+ /**
388
+ * `git clone -c <key>=<value>` (repeatable; `<key>` alone is `true`): each value is added
389
+ * to the new repository's config before anything is fetched (clone.c's `write_config`), so
390
+ * the fetch and the checkout use it: `url.<base>.insteadOf`, `protocol.*`,
391
+ * `fetch.fsckObjects`, `remote.<name>.fetch` (fetched with the clone's own refspec, which
392
+ * is added after it), `core.autocrlf`, `clone.defaultRemoteName`, `clone.rejectShallow`.
393
+ * A key git cannot parse fails the clone before any is written.
394
+ *
395
+ * @example
396
+ * ```ts
397
+ * await git.clone().setURI(url).setConfig(["core.autocrlf=true", "remote.origin.fetch=+refs/pull/*:refs/pull/*"]).call();
398
+ * ```
399
+ */
400
+ setConfig(entries: string[]): this {
401
+ this.checkCallable();
402
+ this.configEntries = [...entries];
403
+ return this;
404
+ }
405
+
406
+ /** Adds one `-c <key>=<value>` entry (see {@link setConfig}). */
407
+ addConfig(entry: string): this {
408
+ this.checkCallable();
409
+ this.configEntries.push(entry);
410
+ return this;
411
+ }
412
+
413
+ /**
414
+ * `git clone --revision=<rev>` (git 2.49+): fetch the history of one ref or commit id and
415
+ * detach HEAD at its commit (a tag peeled); no ref is written for it, no
416
+ * `remote.<name>.fetch` is configured and no tag is followed. A ref name is looked up as
417
+ * `git fetch` looks up a refspec's source; a commit id must be complete. Refused with
418
+ * `--branch` and `--mirror`, and as an unknown option under 2.43 compatibility.
419
+ */
420
+ setRevision(revision: string): this {
421
+ this.checkCallable();
422
+ this.revision = revision;
423
+ return this;
424
+ }
425
+
426
+ /**
427
+ * `git clone --[no-]reject-shallow`: refuse a shallow source (local or not) with git's
428
+ * "source repository is shallow, reject to clone."; unset, `clone.rejectShallow` decides.
429
+ */
430
+ setRejectShallow(reject: boolean): this {
431
+ this.checkCallable();
432
+ this.rejectShallow = reject;
433
+ return this;
434
+ }
435
+
436
+ /**
437
+ * `git clone --server-option=<option>` (repeatable): sent to the server with each protocol
438
+ * v2 request; they replace `remote.<name>.serverOption` (git 2.5x), which is used without
439
+ * them. A server speaking v0 fails the clone when options were given here (git's "server
440
+ * options require protocol version 2 or later"); configured ones are then dropped.
441
+ */
442
+ setServerOptions(options: string[]): this {
443
+ this.checkCallable();
444
+ this.serverOptions = [...options];
445
+ return this;
446
+ }
447
+
448
+ /** The git version reproduced (default the hook runner's, else 2.56). */
449
+ setCompatibility(compatibility: "2.43" | "2.56"): this {
450
+ this.checkCallable();
451
+ this.compatibility = compatibility;
337
452
  return this;
338
453
  }
339
454
 
@@ -584,6 +699,50 @@ export class CloneCommand extends TransportCommand<CloneResult> {
584
699
  * @returns Clone result
585
700
  * @throws InvalidRemoteError if URI is not specified
586
701
  */
702
+ /**
703
+ * `--recurse-submodules[=<pathspec>]` (`--recursive`): `true` is `.` (every submodule), a
704
+ * list the pathspecs given (each written as a `submodule.active` value, sorted, duplicates
705
+ * dropped), `false` none (`--no-recurse-submodules`). After the checkout the submodules
706
+ * are cloned and checked out as `git submodule update --init --require-init --recursive`
707
+ * does (see `SubmoduleUpdateCommand`), its output in {@link CloneResult.submodules}.
708
+ * As in git, submodules are cloned with `GIT_PROTOCOL_FROM_USER=0`: a local URL needs
709
+ * `protocol.file.allow=always`. Credentials and headers reach a submodule's URL only as
710
+ * `SubmoduleUpdateCommand.setCredentials` allows (the clone's own origin).
711
+ */
712
+ setRecurseSubmodules(recurse: boolean | string[]): this {
713
+ this.checkCallable();
714
+ this.recurseSubmodules = recurse === true ? ["."] : recurse === false ? [] : [...recurse];
715
+ return this;
716
+ }
717
+
718
+ /** `--shallow-submodules`: the submodules are cloned with a depth of 1. */
719
+ setShallowSubmodules(shallow: boolean): this {
720
+ this.checkCallable();
721
+ this.shallowSubmodules = shallow;
722
+ return this;
723
+ }
724
+
725
+ /**
726
+ * `--[no-]also-filter-submodules`: the submodules are cloned with this clone's filter
727
+ * ({@link setFilter}); unset, `clone.filterSubmodules` decides. Given true, it needs a
728
+ * filter and {@link setRecurseSubmodules}.
729
+ */
730
+ setAlsoFilterSubmodules(filter: boolean): this {
731
+ this.checkCallable();
732
+ this.alsoFilterSubmodules = filter;
733
+ return this;
734
+ }
735
+
736
+ /**
737
+ * `--remote-submodules`: each submodule is checked out at its remote-tracking branch
738
+ * (`submodule update --remote --no-fetch`).
739
+ */
740
+ setRemoteSubmodules(remote: boolean): this {
741
+ this.checkCallable();
742
+ this.remoteSubmodules = remote;
743
+ return this;
744
+ }
745
+
587
746
  async call(): Promise<CloneResult> {
588
747
  this.checkCallable();
589
748
  this.setCallable(false);
@@ -649,12 +808,47 @@ export class CloneCommand extends TransportCommand<CloneResult> {
649
808
  if (!this.uri) {
650
809
  throw new InvalidRemoteError("", "URI must be specified for clone");
651
810
  }
652
- if (!isValidRemoteName(this.remoteName)) {
653
- throw new InvalidArgumentError(
654
- "remote",
655
- this.remoteName,
656
- `'${this.remoteName}' is not a valid remote name`,
811
+ // cmd_clone: what --recurse-submodules adds to the -c values (option_config)
812
+ const submoduleConfig: string[] = [];
813
+ if (this.recurseSubmodules.length > 0) {
814
+ const patterns = [...new Set(this.recurseSubmodules)].sort((a, b) =>
815
+ a < b ? -1 : a > b ? 1 : 0,
816
+ );
817
+ for (const pattern of patterns) submoduleConfig.push(`submodule.active=${pattern}`);
818
+ const sticky = RemoteConfigStore.from(this.workingCopy).value(
819
+ "submodule.stickyRecursiveClone",
657
820
  );
821
+ if (sticky !== undefined && parseGitBool(sticky) === true) {
822
+ submoduleConfig.push("submodule.recurse=true");
823
+ }
824
+ const required = this.references.some((r) => r.required);
825
+ const optional = this.references.some((r) => !r.required);
826
+ if (required && optional) {
827
+ throw new GitApiError(
828
+ "fatal: clone --recursive is not compatible with both --reference and --reference-if-able",
829
+ );
830
+ }
831
+ if (required || optional) {
832
+ submoduleConfig.push(
833
+ "submodule.alternateLocation=superproject",
834
+ `submodule.alternateErrorStrategy=${required ? "die" : "info"}`,
835
+ );
836
+ }
837
+ }
838
+ if (this.alsoFilterSubmodules === true && this.filterSpec === undefined) {
839
+ throw new GitApiError("fatal: the option '--also-filter-submodules' requires '--filter'");
840
+ }
841
+ if (this.alsoFilterSubmodules === true && this.recurseSubmodules.length === 0) {
842
+ throw new GitApiError(
843
+ "fatal: the option '--also-filter-submodules' requires '--recurse-submodules'",
844
+ );
845
+ }
846
+ const compatibility = this.compatibility ?? this.hooks.compatibility;
847
+ // parse_options: --revision is unknown to 2.43
848
+ if (this.revision !== undefined && compatibility === "2.43") {
849
+ throw new GitApiError(`error: unknown option \`revision=${this.revision}'`, {
850
+ exitCode: 129,
851
+ });
658
852
  }
659
853
 
660
854
  // clone.c: the source is a path or a URL before anything else (get_repo_path): an
@@ -675,15 +869,54 @@ export class CloneCommand extends TransportCommand<CloneResult> {
675
869
  if (isRepositoryPath) repo = absolutePathOf(worktree, uri);
676
870
  else if (uri.includes(":")) repo = uri;
677
871
  else throw new TransportError(`fatal: repository '${uri}' does not exist`);
872
+ // clone.c: a destination that exists and is not empty is refused before anything is
873
+ // written; here the destination is the working copy, empty once `git init` made it
874
+ await this.refuseNonEmptyDestination();
875
+ // write_config: the -c values, after init_db and before anything reads the config (the
876
+ // remote's name, url.*.insteadOf, protocol.*, the fetch and the checkout)
877
+ await this.writeCommandLineConfig(submoduleConfig);
878
+ const store = RemoteConfigStore.from(this.workingCopy);
879
+ // git_clone_config re-read: clone.defaultRemoteName, then --origin over it
880
+ if (!this.remoteExplicit) this.remoteName = store.value("clone.defaultRemoteName") ?? "origin";
881
+ if (!isValidRemoteName(this.remoteName)) {
882
+ throw new InvalidArgumentError(
883
+ "remote",
884
+ this.remoteName,
885
+ `'${this.remoteName}' is not a valid remote name`,
886
+ );
887
+ }
888
+ const rejectShallowConfig = store.value("clone.rejectShallow");
889
+ const rejectShallow =
890
+ this.rejectShallow ??
891
+ (rejectShallowConfig === undefined ? false : (parseGitBool(rejectShallowConfig) ?? false));
892
+ if (this.revision !== undefined) {
893
+ if (this.branch !== undefined) {
894
+ throw new GitApiError("fatal: options '--revision' and '--branch' cannot be used together");
895
+ }
896
+ if (this.mirror) {
897
+ throw new GitApiError("fatal: options '--revision' and '--mirror' cannot be used together");
898
+ }
899
+ if (!isRevisionRefspec(this.revision)) {
900
+ throw new GitApiError(`fatal: invalid refspec '${this.revision}'`);
901
+ }
902
+ }
903
+ // transport.c's handshake: --server-option, else remote.<name>.serverOption (2.5x), an
904
+ // empty value clearing the list
905
+ let serverOptions = this.serverOptions;
906
+ if (serverOptions.length === 0 && compatibility !== "2.43") {
907
+ serverOptions = [];
908
+ for (const value of store.values(`remote.${this.remoteName}.serverOption`)) {
909
+ if (value === "") serverOptions.length = 0;
910
+ else serverOptions.push(value);
911
+ }
912
+ }
913
+
678
914
  this.repoUrl = repo;
679
- const sourceUrl = RemoteConfigStore.from(this.workingCopy).aliasUrl(repo) ?? repo;
915
+ const sourceUrl = store.aliasUrl(repo) ?? repo;
680
916
  const remote = await this.prepareRemote(sourceUrl);
681
917
  const localRemote: OpenedRepository | undefined =
682
918
  remote.kind === "local" ? remote.repository : undefined;
683
-
684
- // clone.c: a destination that exists and is not empty is refused before anything is
685
- // written; here the destination is the working copy, empty once `git init` made it
686
- await this.refuseNonEmptyDestination(localRemote);
919
+ if (localRemote) await this.refuseSourceAsDestination(localRemote);
687
920
 
688
921
  // clone.c's is_local: a local repository path (remote.<name>.url as rewritten; never a
689
922
  // URL, file:// included), unless --no-local or the source is shallow
@@ -713,6 +946,9 @@ export class CloneCommand extends TransportCommand<CloneResult> {
713
946
  localWarnings.push("warning: --filter is ignored in local clones; use file:// instead.\n");
714
947
  }
715
948
  if (await sourceIsShallow(localRemote, worktree?.getFiles?.())) {
949
+ if (rejectShallow) {
950
+ throw new TransportError("fatal: source repository is shallow, reject to clone.");
951
+ }
716
952
  if (this.local === true) {
717
953
  localWarnings.push("warning: source repository is shallow, ignoring --local\n");
718
954
  }
@@ -747,6 +983,7 @@ export class CloneCommand extends TransportCommand<CloneResult> {
747
983
  this.bare ? `refs/heads/${branch}` : `refs/remotes/${this.remoteName}/${branch}`;
748
984
  // git: a shallow clone is a single-branch clone (of --branch, else the remote HEAD's branch)
749
985
  const singleBranch =
986
+ this.revision === undefined &&
750
987
  !this.mirror &&
751
988
  (this.singleBranch ??
752
989
  (branchesToClone.length > 0 ||
@@ -812,11 +1049,58 @@ export class CloneCommand extends TransportCommand<CloneResult> {
812
1049
  } else {
813
1050
  refspecs = [`+refs/heads/*:${tracking("*")}`];
814
1051
  }
815
- // git clone takes every tag, unless one branch is cloned (then tags follow) or --no-tags
1052
+ // --revision: the revision alone, as a refspec without destination (no ref written)
1053
+ let revisionRef: { name: string; oid: string } | undefined;
1054
+ if (this.revision !== undefined) {
1055
+ const rev = this.revision;
1056
+ refspecs = {
1057
+ prefixes: FULL_HEX_ID.test(rev) ? [] : refPrefixes([rev]),
1058
+ resolve: (remoteRefs) => {
1059
+ const found = mapRefs(remoteRefs, [rev])[0];
1060
+ if (!found) {
1061
+ throw new RefNotFoundError(
1062
+ rev,
1063
+ `fatal: Remote revision ${rev} not found in upstream ${this.remoteName}`,
1064
+ );
1065
+ }
1066
+ revisionRef = { name: found.remoteRef, oid: found.oid };
1067
+ return [rev];
1068
+ },
1069
+ };
1070
+ }
1071
+ // remote_get_early: the configured remote.<name>.fetch refspecs (the -c values and the
1072
+ // command line's included) come first; a single-branch clone maps them over its one ref
1073
+ const configuredFetch = store.values(`remote.${this.remoteName}.fetch`);
1074
+ if (configuredFetch.length > 0) {
1075
+ const selected =
1076
+ singleBranch && !this.mirror
1077
+ ? (remoteRefs: readonly RemoteRef[]) => {
1078
+ if (branchToClone !== undefined) {
1079
+ return (
1080
+ remoteRefs.find((r) => r.name === `refs/heads/${branchToClone}` && r.oid) ??
1081
+ remoteRefs.find((r) => r.name === `refs/tags/${branchToClone}` && r.oid)
1082
+ );
1083
+ }
1084
+ const head = remoteRefs.find((r) => r.name === "HEAD")?.symref;
1085
+ return head ? remoteRefs.find((r) => r.name === head && r.oid) : undefined;
1086
+ }
1087
+ : undefined;
1088
+ // (tags: "all" below maps git's TAG_REFSPEC after them)
1089
+ const allTags =
1090
+ this.revision === undefined &&
1091
+ this.tagOption === TagOption.AUTO_FOLLOW &&
1092
+ !singleBranch &&
1093
+ !this.mirror;
1094
+ refspecs = withConfiguredRefspecs(refspecs, configuredFetch, selected, allTags);
1095
+ }
1096
+ // git clone takes every tag, unless one branch is cloned (then tags follow) or --no-tags;
1097
+ // none with --revision
816
1098
  const tags =
817
- this.tagOption === TagOption.AUTO_FOLLOW && !singleBranch && !this.mirror
818
- ? "all"
819
- : toTagMode(this.tagOption);
1099
+ this.revision !== undefined
1100
+ ? "none"
1101
+ : this.tagOption === TagOption.AUTO_FOLLOW && !singleBranch && !this.mirror
1102
+ ? "all"
1103
+ : toTagMode(this.tagOption);
820
1104
 
821
1105
  // fetch.fsckObjects / transfer.fsckObjects (the clone's own config, `-c` settings included)
822
1106
  const environment = hostEnvironmentOf(this.workingCopy);
@@ -859,6 +1143,8 @@ export class CloneCommand extends TransportCommand<CloneResult> {
859
1143
  ? { filter: this.filterSpec, onWarning: (line: string) => messages.push(`${line}\n`) }
860
1144
  : {}),
861
1145
  ...(fsck ? { fsckObjects: fsck } : {}),
1146
+ ...(serverOptions.length > 0 ? { serverOptions } : {}),
1147
+ ...(rejectShallow ? { rejectShallow: true } : {}),
862
1148
  // git's clone takes the remote's hash: a destination of another one is reopened with it
863
1149
  // before anything is fetched (cloneReopenedAs)
864
1150
  onRemoteObjectFormat: (format) => {
@@ -884,9 +1170,19 @@ export class CloneCommand extends TransportCommand<CloneResult> {
884
1170
  };
885
1171
  // fetch_if_missing = 0 while the fetch runs: its walks read through the history's view
886
1172
  // without lazy fetch (the facade above)
887
- const result = await withRemoteUploadPack(remote, sessionOptions, (connection) =>
888
- fetchFromConnection(connection, fetchOptions),
889
- ).catch((error: unknown) => {
1173
+ const result = await withRemoteUploadPack(remote, sessionOptions, (connection) => {
1174
+ // transport.c's die_if_server_options: command-line options need v2
1175
+ if (connection.version !== 2 && this.serverOptions.length > 0) {
1176
+ throw new TransportError(
1177
+ "hint: see protocol.version in 'git help config' for more details\n" +
1178
+ "fatal: server options require protocol version 2 or later",
1179
+ );
1180
+ }
1181
+ return fetchFromConnection(connection, fetchOptions);
1182
+ }).catch((error: unknown) => {
1183
+ if (error instanceof ShallowRemoteRejectedError) {
1184
+ throw new TransportError(`fatal: ${error.message}`);
1185
+ }
890
1186
  if (!(error instanceof FetchCheckError)) throw error;
891
1187
  // what was received is refused before any ref is written: index-pack died, or
892
1188
  // update_remote_refs' check of the refs found history missing (git then removes the
@@ -925,17 +1221,31 @@ export class CloneCommand extends TransportCommand<CloneResult> {
925
1221
 
926
1222
  // git's update_remote_refs (before update_head): refs/remotes/<name>/HEAD names the tracking ref of the
927
1223
  // remote's default branch, when the clone took that branch
928
- const remoteHead = advertisedDefaultBranch?.startsWith("refs/heads/")
929
- ? toBranchName(advertisedDefaultBranch)
1224
+ const remoteHead =
1225
+ this.revision === undefined && advertisedDefaultBranch?.startsWith("refs/heads/")
1226
+ ? toBranchName(advertisedDefaultBranch)
1227
+ : undefined;
1228
+ // (guess_remote_head over the mapped refs: the first mapping of the remote HEAD's branch,
1229
+ // configured refspecs before the clone's own, whose peer ref HEAD then names)
1230
+ const headMapping = remoteHead
1231
+ ? result.fetched.find((f) => f.remoteRef === advertisedDefaultBranch)
930
1232
  : undefined;
931
- if (!this.bare && remoteHead) {
932
- const target = `refs/remotes/${this.remoteName}/${remoteHead}`;
1233
+ if (!this.bare && remoteHead && headMapping?.localRef) {
1234
+ const target = headMapping.localRef;
933
1235
  if ((await this.refsStore.resolve(target))?.objectId) {
934
1236
  await this.refsStore.setSymbolic(`refs/remotes/${this.remoteName}/HEAD`, target, cloneLog);
935
1237
  }
936
1238
  }
937
1239
 
938
- if (detachedTag) {
1240
+ if (revisionRef) {
1241
+ // update_head with opts->detach: HEAD detached at the revision's commit (a tag peeled,
1242
+ // lookup_commit_or_die), bare or not
1243
+ defaultBranch = toBranchName(advertisedDefaultBranch);
1244
+ const id = await this.revisionCommit(revisionRef, messages);
1245
+ await this.refsStore.set("HEAD", id, cloneLog);
1246
+ headCommit = id;
1247
+ if (!this.bare && !this.noCheckout) checkoutId = id;
1248
+ } else if (detachedTag) {
939
1249
  // git clone --branch <tag>: a detached HEAD at the tag's commit
940
1250
  defaultBranch = toBranchName(advertisedDefaultBranch);
941
1251
  const tag = await this.refsStore.resolve(detachedTag);
@@ -984,6 +1294,7 @@ export class CloneCommand extends TransportCommand<CloneResult> {
984
1294
  remoteHead,
985
1295
  checkedOutBranch,
986
1296
  isEmpty: result.isEmpty,
1297
+ revision: this.revision !== undefined,
987
1298
  });
988
1299
 
989
1300
  // Build fetch result
@@ -1040,10 +1351,59 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1040
1351
  false,
1041
1352
  );
1042
1353
  if (code !== 0) cloneResult.hookExitCode = code;
1354
+ // checkout(): the submodules, once the hook succeeded
1355
+ else if (this.recurseSubmodules.length > 0) {
1356
+ cloneResult.submodules = await this.updateSubmodules();
1357
+ }
1043
1358
  }
1044
1359
  return cloneResult;
1045
1360
  }
1046
1361
 
1362
+ /**
1363
+ * clone.c's `git submodule update --require-init --recursive [--depth=1] [--remote
1364
+ * --no-fetch] [--filter=<spec>] [--[no-]single-branch]` in the new repository: what it
1365
+ * printed and its exit status.
1366
+ */
1367
+ private async updateSubmodules(): Promise<SubmoduleCommandResult> {
1368
+ const store = RemoteConfigStore.from(this.workingCopy);
1369
+ const configured = store.value("clone.filterSubmodules");
1370
+ const filterSubmodules =
1371
+ this.alsoFilterSubmodules ??
1372
+ (configured === undefined ? false : (parseGitBool(configured) ?? false));
1373
+ const update = new SubmoduleUpdateCommand(this.workingCopy)
1374
+ .setRequireInit(true)
1375
+ .setRecursive(true)
1376
+ .setCompatibility(this.compatibility ?? this.hooks.compatibility);
1377
+ update.shareHooksOf(this);
1378
+ if (this.shallowSubmodules) update.setDepth(1);
1379
+ if (this.remoteSubmodules) update.setRemote(true).setNoFetch(true);
1380
+ if (filterSubmodules && this.filterSpec !== undefined) update.setFilter(this.filterSpec);
1381
+ // option_single_branch, settled before (a deepening clone is a single-branch one, a
1382
+ // --revision clone none): always passed on, as --single-branch or --no-single-branch
1383
+ update.setSingleBranch(
1384
+ this.revision !== undefined
1385
+ ? false
1386
+ : (this.singleBranch ??
1387
+ (this.depth !== undefined ||
1388
+ this.shallowSince !== undefined ||
1389
+ this.shallowExcludes.length > 0)),
1390
+ );
1391
+ update.setTransports(this.getTransports());
1392
+ if (this.credentials) update.setCredentials(this.credentials);
1393
+ if (this.headers) update.setHeaders(this.headers);
1394
+ if (this.timeout !== undefined) update.setTimeout(this.timeout);
1395
+ try {
1396
+ return await update.call();
1397
+ } catch (error) {
1398
+ if (!(error instanceof SubmoduleCommandError)) throw error;
1399
+ return {
1400
+ stdout: error.result.stdout,
1401
+ stderr: `${error.result.stderr}${error.message}\n`,
1402
+ exitCode: error.exitCode,
1403
+ };
1404
+ }
1405
+ }
1406
+
1047
1407
  /**
1048
1408
  * The alternates `git clone` writes before it fetches: each `--reference` (a required one
1049
1409
  * that is no usable repository fails the clone; an optional one is reported in the returned
@@ -1136,14 +1496,17 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1136
1496
  * resolves to (`git clone . .`). The directory is named as the worktree's top is
1137
1497
  * ({@link setDirectory}, else its last component, `.` for the root).
1138
1498
  */
1139
- private async refuseNonEmptyDestination(source: OpenedRepository | undefined): Promise<void> {
1140
- const refuse = () => {
1141
- const root = repositoryPlaceOf(this._workingCopy)?.getRoot?.() ?? "";
1142
- const name = this.directory ?? (root.replace(/\/+$/, "").split("/").pop() || ".");
1143
- return new CloneDestinationError(
1144
- `fatal: destination path '${name}' already exists and is not an empty directory.`,
1145
- );
1146
- };
1499
+ /** git's "destination path ... already exists and is not an empty directory." */
1500
+ private destinationRefused(): CloneDestinationError {
1501
+ const root = repositoryPlaceOf(this._workingCopy)?.getRoot?.() ?? "";
1502
+ const name = this.directory ?? (root.replace(/\/+$/, "").split("/").pop() || ".");
1503
+ return new CloneDestinationError(
1504
+ `fatal: destination path '${name}' already exists and is not an empty directory.`,
1505
+ );
1506
+ }
1507
+
1508
+ private async refuseNonEmptyDestination(): Promise<void> {
1509
+ const refuse = () => this.destinationRefused();
1147
1510
  const history = this._workingCopy.history;
1148
1511
  for await (const ref of history.refs.list()) {
1149
1512
  if (!isSymbolicRef(ref)) throw refuse();
@@ -1168,17 +1531,122 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1168
1531
  if (own && (entry.path === own || entry.path.startsWith(`${own}/`))) continue;
1169
1532
  throw refuse();
1170
1533
  }
1171
- if (source) {
1172
- const self = await worktree
1173
- .openRepository?.(".", { checkOwnership: false })
1174
- .catch(() => undefined);
1175
- if (self && (self.commonDir ?? self.gitDir) === (source.commonDir ?? source.gitDir)) {
1176
- throw refuse();
1177
- }
1178
- }
1179
1534
  }
1180
1535
  }
1181
1536
 
1537
+ /** A local source that is the destination itself is refused as a non-empty destination. */
1538
+ private async refuseSourceAsDestination(source: OpenedRepository): Promise<void> {
1539
+ const worktree = this.bare ? undefined : this.worktreeAccess;
1540
+ if (!worktree) return;
1541
+ const self = await worktree
1542
+ .openRepository?.(".", { checkOwnership: false })
1543
+ .catch(() => undefined);
1544
+ if (self && (self.commonDir ?? self.gitDir) === (source.commonDir ?? source.gitDir)) {
1545
+ throw this.destinationRefused();
1546
+ }
1547
+ }
1548
+
1549
+ /**
1550
+ * clone.c's `write_config`: each `-c` entry parsed as `git_config_parse_parameter` (split at
1551
+ * the first `=`, no `=` meaning `true`), its key canonical (`git_config_parse_key`), then
1552
+ * added to the new repository's config file (`CONFIG_REGEX_NONE`), saved before the fetch.
1553
+ * Every entry is checked before the first is written.
1554
+ */
1555
+ private async writeCommandLineConfig(extra: string[] = []): Promise<void> {
1556
+ const entries = [...this.configEntries, ...extra];
1557
+ if (entries.length === 0) return;
1558
+ const parsed: { key: string; value: string }[] = [];
1559
+ for (const entry of entries) {
1560
+ const eq = entry.indexOf("=");
1561
+ const rawKey = eq < 0 ? entry : entry.slice(0, eq);
1562
+ const die = (error: string) =>
1563
+ new GitApiError(`error: ${error}\nfatal: unable to write parameters to config file`);
1564
+ if (rawKey === "") throw die(`bogus config parameter: ${entry}`);
1565
+ const key = parseConfigKey(rawKey);
1566
+ if ("error" in key) throw die(key.error);
1567
+ parsed.push({ key: key.key, value: eq < 0 ? "true" : entry.slice(eq + 1) });
1568
+ }
1569
+ for (const { key, value } of parsed) await this.writeConfigValue(key, value, "add");
1570
+ }
1571
+
1572
+ /**
1573
+ * One config write as git's config writer places it (`repo_config_set_multivar`): through
1574
+ * `git config` (`ConfigCommand`) where the config is a file, so a value added to an existing
1575
+ * section goes at its end; pending edits are saved first and the config is read again
1576
+ * after. `add` is `CONFIG_REGEX_NONE`; `set-empty` replaces an empty value, else adds (the
1577
+ * `^$` pattern of `write_refspec_config`).
1578
+ */
1579
+ private async writeConfigValue(
1580
+ key: string,
1581
+ value: string,
1582
+ mode: "add" | "set-empty",
1583
+ ): Promise<void> {
1584
+ const store = RemoteConfigStore.from(this.workingCopy);
1585
+ const config = this.workingCopy.config;
1586
+ if (!(config instanceof GitWorkingCopyConfig)) {
1587
+ const values = store.localValues(key);
1588
+ const empty = values.indexOf("");
1589
+ if (mode === "set-empty" && empty >= 0) {
1590
+ store.setValues(
1591
+ key,
1592
+ values.map((v, i) => (i === empty ? value : (v ?? "true"))),
1593
+ );
1594
+ } else store.addValue(key, value);
1595
+ await store.save();
1596
+ return;
1597
+ }
1598
+ // config.c's writer over the file's text (as `git config` edits it), then read again
1599
+ await store.save();
1600
+ const files = config.configFiles;
1601
+ const path = config.filePath;
1602
+ const bytes = await files.read(path);
1603
+ const written = setConfigMultivarText(
1604
+ bytes === undefined ? undefined : new TextDecoder().decode(bytes),
1605
+ path,
1606
+ key,
1607
+ value,
1608
+ { valuePattern: mode === "add" ? CONFIG_REGEX_NONE : "^$" },
1609
+ );
1610
+ if (written.status !== 0 || written.text === undefined) {
1611
+ throw new GitApiError(written.stderr.join("\n") || `fatal: could not write ${key}`);
1612
+ }
1613
+ await files.write(path, new TextEncoder().encode(written.text));
1614
+ await config.load();
1615
+ }
1616
+
1617
+ /**
1618
+ * `--revision`'s commit: the fetched object, tags peeled (lookup_commit_or_die, its
1619
+ * "is not a commit!" warning added to `messages`); anything else dies as git
1620
+ * ("object <id> is a tree, not a commit", "could not parse <name>").
1621
+ */
1622
+ private async revisionCommit(
1623
+ revision: { name: string; oid: string },
1624
+ messages: string[],
1625
+ ): Promise<ObjectId> {
1626
+ const tags = this.tagsStore ?? this._workingCopy.history.tags;
1627
+ let id = revision.oid;
1628
+ for (let i = 0; i < 16; i++) {
1629
+ if (!(await tags.has(id))) break;
1630
+ const target = await tags.getTarget(id);
1631
+ if (!target) break;
1632
+ id = target;
1633
+ }
1634
+ if (!(await this.commits.load(id).catch(() => undefined))) {
1635
+ const type = (await this.trees.has(id).catch(() => false))
1636
+ ? "tree"
1637
+ : (await this.blobs.has(id).catch(() => false))
1638
+ ? "blob"
1639
+ : undefined;
1640
+ throw new GitApiError(
1641
+ `${type ? `error: object ${id} is a ${type}, not a commit\n` : ""}fatal: could not parse ${revision.name}`,
1642
+ );
1643
+ }
1644
+ if (id !== revision.oid) {
1645
+ messages.push(`warning: ${revision.name} ${revision.oid} is not a commit!\n`);
1646
+ }
1647
+ return id;
1648
+ }
1649
+
1182
1650
  /**
1183
1651
  * Writes the configuration `git clone` writes (clone.c): `remote.<name>.url`,
1184
1652
  * `remote.<name>.tagOpt` for `--no-tags` and `--mirror` (git 2.49+), the `remote.<name>.fetch` refspec of what was
@@ -1194,6 +1662,8 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1194
1662
  remoteHead?: string;
1195
1663
  checkedOutBranch?: string;
1196
1664
  isEmpty?: boolean;
1665
+ /** --revision: no fetch refspec (write_refspec_config is skipped) */
1666
+ revision?: boolean;
1197
1667
  }): Promise<void> {
1198
1668
  const store = RemoteConfigStore.from(this.workingCopy);
1199
1669
  // git init probes the filesystem: what the worktree cannot represent is turned off
@@ -1213,7 +1683,7 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1213
1683
  let fetchRefspec: string | undefined;
1214
1684
  if (this.mirror) {
1215
1685
  fetchRefspec = "+refs/*:refs/*";
1216
- } else if (!this.bare) {
1686
+ } else if (!this.bare && !clone.revision) {
1217
1687
  const top = `refs/remotes/${this.remoteName}/`;
1218
1688
  if (!clone.singleBranch) fetchRefspec = `+refs/heads/*:${top}*`;
1219
1689
  else if (clone.detachedTag) fetchRefspec = `+${clone.detachedTag}:${clone.detachedTag}`;
@@ -1224,7 +1694,9 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1224
1694
  fetchRefspec = `+refs/heads/${clone.remoteHead}:${top}${clone.remoteHead}`;
1225
1695
  }
1226
1696
  if (fetchRefspec) {
1227
- store.setValue(`${remote}.fetch`, fetchRefspec);
1697
+ // repo_config_set_multivar(key, value, "^$", 0): at the end of the section, after the
1698
+ // values -c wrote, or in place of an empty one
1699
+ await this.writeConfigValue(`${remote}.fetch`, fetchRefspec, "set-empty");
1228
1700
  if (this.mirror) store.setValue(`${remote}.mirror`, "true");
1229
1701
  }
1230
1702
  if (this.filterSpec !== undefined) {
@@ -1235,6 +1707,16 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1235
1707
  store.setValue(`${remote}.promisor`, "true");
1236
1708
  store.setValue(`${remote}.partialclonefilter`, this.filterSpec);
1237
1709
  }
1710
+ // git 2.43 initialized the sparse checkout before update_head's branch config
1711
+ if (
1712
+ this.sparse &&
1713
+ !this.sparseInitialized &&
1714
+ clone.worktree &&
1715
+ (this.compatibility ?? this.hooks.compatibility) === "2.43"
1716
+ ) {
1717
+ await store.save();
1718
+ await this.initSparseCheckout();
1719
+ }
1238
1720
  if (!this.bare && clone.checkedOutBranch) {
1239
1721
  store.setValue(`branch.${clone.checkedOutBranch}.remote`, this.remoteName);
1240
1722
  store.setValue(
@@ -1280,7 +1762,7 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1280
1762
  const sparse =
1281
1763
  this.sparse && worktree
1282
1764
  ? await (async () => {
1283
- await new SparseCheckoutCommand(this.workingCopy).setArguments(["set"]).call();
1765
+ if (!this.sparseInitialized) await this.initSparseCheckout();
1284
1766
  return SparseUnpack.start({
1285
1767
  workingCopy: this.workingCopy,
1286
1768
  worktree,
@@ -1296,6 +1778,7 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1296
1778
  worktree,
1297
1779
  symlinks: worktree ? this.symlinksEnabled(worktree) : false,
1298
1780
  ignoreCase: coreBool(this.workingCopy, "ignorecase", false),
1781
+ pathRules: worktreePathRules(this.workingCopy, worktree),
1299
1782
  ...(sparse ? { writes: (path: string) => sparse.writes(path) } : {}),
1300
1783
  },
1301
1784
  commit.tree,
@@ -1311,6 +1794,14 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1311
1794
  return collided;
1312
1795
  }
1313
1796
 
1797
+ /** `git sparse-checkout set` in the new repository (git_sparse_checkout_init), once. */
1798
+ private async initSparseCheckout(): Promise<void> {
1799
+ this.sparseInitialized = true;
1800
+ await new SparseCheckoutCommand(this.workingCopy).setArguments(["set"]).call();
1801
+ }
1802
+
1803
+ private sparseInitialized = false;
1804
+
1314
1805
  /** Whether symlinks are written as links: the worktree can, and `core.symlinks` allows. */
1315
1806
  private symlinksEnabled(worktree: Worktree): boolean {
1316
1807
  return worktreeModeTrust(this.workingCopy, worktree).symlinks;
@@ -1325,6 +1816,68 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1325
1816
  * bare name (`main`) is equally legitimate. Both are accepted, and both yield
1326
1817
  * the bare name the ref-building code below prefixes.
1327
1818
  */
1819
+ /** A complete object id (SHA-1 or SHA-256), as a refspec source names one. */
1820
+ const FULL_HEX_ID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
1821
+
1822
+ /**
1823
+ * Whether `--revision`'s value parses as a fetch refspec's source (refspec.c: a complete
1824
+ * object id, or a ref name allowed one level, `HEAD` included): `refs/heads/main^` does not.
1825
+ */
1826
+ function isRevisionRefspec(revision: string): boolean {
1827
+ return FULL_HEX_ID.test(revision) || isValidRefName(revision, { allowOneLevel: true });
1828
+ }
1829
+
1830
+ /**
1831
+ * The clone's refspecs after the configured `remote.<name>.fetch` ones (remote_get_early,
1832
+ * then the clone's own appended): every remote ref is mapped through them, or, for a
1833
+ * single-branch clone (`selected`), only the one ref it clones (wanted_peer_refs narrows the
1834
+ * list before mapping).
1835
+ */
1836
+ function withConfiguredRefspecs(
1837
+ own: string[] | RefspecResolver,
1838
+ configured: string[],
1839
+ selected: ((remoteRefs: readonly RemoteRef[]) => RemoteRef | undefined) | undefined,
1840
+ allTags: boolean,
1841
+ ): RefspecResolver {
1842
+ return {
1843
+ prefixes: [
1844
+ ...refPrefixes(configured),
1845
+ ...(Array.isArray(own) ? refPrefixes(own) : own.prefixes),
1846
+ ],
1847
+ resolve: (remoteRefs) => {
1848
+ const ownSpecs = Array.isArray(own) ? own : own.resolve(remoteRefs);
1849
+ // get_fetch_map with missing_ok 0: an exact source the (narrowed) list lacks dies
1850
+ const ref = selected?.(remoteRefs);
1851
+ const mappedOver = selected ? (ref ? [ref] : []) : remoteRefs;
1852
+ const listsRefs = remoteRefs.some((r) => r.oid);
1853
+ const missing = listsRefs ? missingSources(mappedOver, configured) : [];
1854
+ if (missing.length > 0) {
1855
+ throw new TransportError(`fatal: couldn't find remote ref ${missing[0]}`);
1856
+ }
1857
+ const mapped = selected
1858
+ ? mapRefs(mappedOver, configured)
1859
+ .filter((p) => p.localRef !== undefined)
1860
+ .map((p) => `${p.force ? "+" : ""}${p.remoteRef}:${p.localRef}`)
1861
+ : configured;
1862
+ const specs = [...mapped, ...ownSpecs];
1863
+ // write_remote_refs' one transaction refuses a ref two mappings write (wanted_peer_refs
1864
+ // removes no duplicate): ref_transaction's "multiple updates", the first name in order
1865
+ const counts = new Map<string, number>();
1866
+ for (const spec of allTags ? [...specs, "refs/tags/*:refs/tags/*"] : specs) {
1867
+ for (const p of mapRefs(remoteRefs, [spec])) {
1868
+ if (p.localRef !== undefined) counts.set(p.localRef, (counts.get(p.localRef) ?? 0) + 1);
1869
+ }
1870
+ }
1871
+ const twice = [...counts].filter(([, n]) => n > 1).map(([name]) => name);
1872
+ if (twice.length > 0) {
1873
+ twice.sort(compareRefNames);
1874
+ throw new TransportError(`fatal: multiple updates for ref '${twice[0]}' not allowed`);
1875
+ }
1876
+ return specs;
1877
+ },
1878
+ };
1879
+ }
1880
+
1328
1881
  /**
1329
1882
  * clone.c's `absolute_pathdup` of a local source: an absolute path as given, a relative one
1330
1883
  * after the directory clone runs in (the worktree top, as the host sees it when the storage