@statewalker/vcs-commands 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (546) hide show
  1. package/README.md +123 -8
  2. package/dist/commands/add-command.d.ts +265 -34
  3. package/dist/commands/add-command.d.ts.map +1 -1
  4. package/dist/commands/add-patch/add-interactive.d.ts +46 -0
  5. package/dist/commands/add-patch/add-interactive.d.ts.map +1 -0
  6. package/dist/commands/add-patch/add-patch.d.ts +139 -0
  7. package/dist/commands/add-patch/add-patch.d.ts.map +1 -0
  8. package/dist/commands/add-patch/index.d.ts +6 -0
  9. package/dist/commands/add-patch/index.d.ts.map +1 -0
  10. package/dist/commands/add-patch/patch-backend.d.ts +80 -0
  11. package/dist/commands/add-patch/patch-backend.d.ts.map +1 -0
  12. package/dist/commands/add-patch/patch-modes.d.ts +71 -0
  13. package/dist/commands/add-patch/patch-modes.d.ts.map +1 -0
  14. package/dist/commands/add-patch/patch-session.d.ts +49 -0
  15. package/dist/commands/add-patch/patch-session.d.ts.map +1 -0
  16. package/dist/commands/am/am-command.d.ts +175 -0
  17. package/dist/commands/am/am-command.d.ts.map +1 -0
  18. package/dist/commands/am/index.d.ts +3 -0
  19. package/dist/commands/am/index.d.ts.map +1 -0
  20. package/dist/commands/am/mailinfo.d.ts +58 -0
  21. package/dist/commands/am/mailinfo.d.ts.map +1 -0
  22. package/dist/commands/am/patch-format.d.ts +24 -0
  23. package/dist/commands/am/patch-format.d.ts.map +1 -0
  24. package/dist/commands/apply/apply-command.d.ts +153 -0
  25. package/dist/commands/apply/apply-command.d.ts.map +1 -0
  26. package/dist/commands/apply/apply-engine.d.ts +195 -0
  27. package/dist/commands/apply/apply-engine.d.ts.map +1 -0
  28. package/dist/commands/apply/apply-parse.d.ts +86 -0
  29. package/dist/commands/apply/apply-parse.d.ts.map +1 -0
  30. package/dist/commands/apply/apply-types.d.ts +70 -0
  31. package/dist/commands/apply/apply-types.d.ts.map +1 -0
  32. package/dist/commands/apply/index.d.ts +6 -0
  33. package/dist/commands/apply/index.d.ts.map +1 -0
  34. package/dist/commands/apply/latin1.d.ts +32 -0
  35. package/dist/commands/apply/latin1.d.ts.map +1 -0
  36. package/dist/commands/apply/whitespace.d.ts +58 -0
  37. package/dist/commands/apply/whitespace.d.ts.map +1 -0
  38. package/dist/commands/attributes-source.d.ts +26 -0
  39. package/dist/commands/attributes-source.d.ts.map +1 -0
  40. package/dist/commands/backfill-command.d.ts +110 -0
  41. package/dist/commands/backfill-command.d.ts.map +1 -0
  42. package/dist/commands/bisect/bisect-checkout.d.ts +64 -0
  43. package/dist/commands/bisect/bisect-checkout.d.ts.map +1 -0
  44. package/dist/commands/bisect/bisect-command.d.ts +201 -0
  45. package/dist/commands/bisect/bisect-command.d.ts.map +1 -0
  46. package/dist/commands/bisect/bisect-engine.d.ts +219 -0
  47. package/dist/commands/bisect/bisect-engine.d.ts.map +1 -0
  48. package/dist/commands/bisect/bisect-graph.d.ts +127 -0
  49. package/dist/commands/bisect/bisect-graph.d.ts.map +1 -0
  50. package/dist/commands/bisect/bisect-quote.d.ts +27 -0
  51. package/dist/commands/bisect/bisect-quote.d.ts.map +1 -0
  52. package/dist/commands/bisect/index.d.ts +5 -0
  53. package/dist/commands/bisect/index.d.ts.map +1 -0
  54. package/dist/commands/blame-command.d.ts +122 -131
  55. package/dist/commands/blame-command.d.ts.map +1 -1
  56. package/dist/commands/branch-command.d.ts +52 -2
  57. package/dist/commands/branch-command.d.ts.map +1 -1
  58. package/dist/commands/branch-tracking.d.ts +98 -0
  59. package/dist/commands/branch-tracking.d.ts.map +1 -0
  60. package/dist/commands/checkout-command.d.ts +300 -18
  61. package/dist/commands/checkout-command.d.ts.map +1 -1
  62. package/dist/commands/checkout-paths.d.ts +124 -0
  63. package/dist/commands/checkout-paths.d.ts.map +1 -0
  64. package/dist/commands/cherry-pick-command.d.ts +50 -42
  65. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  66. package/dist/commands/clean-command.d.ts +49 -16
  67. package/dist/commands/clean-command.d.ts.map +1 -1
  68. package/dist/commands/clone-command.d.ts +117 -0
  69. package/dist/commands/clone-command.d.ts.map +1 -1
  70. package/dist/commands/commit-command.d.ts +311 -17
  71. package/dist/commands/commit-command.d.ts.map +1 -1
  72. package/dist/commands/core-config.d.ts +78 -1
  73. package/dist/commands/core-config.d.ts.map +1 -1
  74. package/dist/commands/date-format.d.ts +58 -0
  75. package/dist/commands/date-format.d.ts.map +1 -0
  76. package/dist/commands/describe-command.d.ts.map +1 -1
  77. package/dist/commands/diff-command.d.ts +377 -30
  78. package/dist/commands/diff-command.d.ts.map +1 -1
  79. package/dist/commands/diff-textconv.d.ts +40 -0
  80. package/dist/commands/diff-textconv.d.ts.map +1 -0
  81. package/dist/commands/fetch-command.d.ts +149 -10
  82. package/dist/commands/fetch-command.d.ts.map +1 -1
  83. package/dist/commands/format-patch-command.d.ts +164 -0
  84. package/dist/commands/format-patch-command.d.ts.map +1 -0
  85. package/dist/commands/fsck/fetch-fsck.d.ts +60 -0
  86. package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -0
  87. package/dist/commands/fsck/fsck-command.d.ts +225 -0
  88. package/dist/commands/fsck/fsck-command.d.ts.map +1 -0
  89. package/dist/commands/fsck/fsck-loose.d.ts +68 -0
  90. package/dist/commands/fsck/fsck-loose.d.ts.map +1 -0
  91. package/dist/commands/fsck/fsck-msg-ids.d.ts +122 -0
  92. package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -0
  93. package/dist/commands/fsck/fsck-object-checks.d.ts +148 -0
  94. package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -0
  95. package/dist/commands/fsck/fsck-object-table.d.ts +132 -0
  96. package/dist/commands/fsck/fsck-object-table.d.ts.map +1 -0
  97. package/dist/commands/fsck/fsck-pack.d.ts +115 -0
  98. package/dist/commands/fsck/fsck-pack.d.ts.map +1 -0
  99. package/dist/commands/fsck/index.d.ts +6 -0
  100. package/dist/commands/fsck/index.d.ts.map +1 -0
  101. package/dist/commands/fsck/verify-pack-command.d.ts +81 -0
  102. package/dist/commands/fsck/verify-pack-command.d.ts.map +1 -0
  103. package/dist/commands/gc-command.d.ts +43 -0
  104. package/dist/commands/gc-command.d.ts.map +1 -1
  105. package/dist/commands/git-date.d.ts +66 -0
  106. package/dist/commands/git-date.d.ts.map +1 -0
  107. package/dist/commands/git-describe.d.ts +67 -0
  108. package/dist/commands/git-describe.d.ts.map +1 -0
  109. package/dist/commands/git-hooks.d.ts +416 -0
  110. package/dist/commands/git-hooks.d.ts.map +1 -0
  111. package/dist/commands/git-ident.d.ts +128 -0
  112. package/dist/commands/git-ident.d.ts.map +1 -0
  113. package/dist/commands/hook-command.d.ts +96 -0
  114. package/dist/commands/hook-command.d.ts.map +1 -0
  115. package/dist/commands/index-adder.d.ts +231 -0
  116. package/dist/commands/index-adder.d.ts.map +1 -0
  117. package/dist/commands/index-host.d.ts +86 -0
  118. package/dist/commands/index-host.d.ts.map +1 -0
  119. package/dist/commands/index.d.ts +54 -0
  120. package/dist/commands/index.d.ts.map +1 -1
  121. package/dist/commands/index.js +3 -2
  122. package/dist/commands/init-command.d.ts +12 -1
  123. package/dist/commands/init-command.d.ts.map +1 -1
  124. package/dist/commands/local-clone.d.ts +60 -0
  125. package/dist/commands/local-clone.d.ts.map +1 -0
  126. package/dist/commands/local-transport.d.ts +117 -0
  127. package/dist/commands/local-transport.d.ts.map +1 -0
  128. package/dist/commands/log-command.d.ts +216 -24
  129. package/dist/commands/log-command.d.ts.map +1 -1
  130. package/dist/commands/log-graph.d.ts +120 -0
  131. package/dist/commands/log-graph.d.ts.map +1 -0
  132. package/dist/commands/log-output.d.ts +323 -0
  133. package/dist/commands/log-output.d.ts.map +1 -0
  134. package/dist/commands/ls-remote-command.d.ts +23 -7
  135. package/dist/commands/ls-remote-command.d.ts.map +1 -1
  136. package/dist/commands/mailmap.d.ts +31 -0
  137. package/dist/commands/mailmap.d.ts.map +1 -0
  138. package/dist/commands/merge-bases.d.ts +85 -0
  139. package/dist/commands/merge-bases.d.ts.map +1 -0
  140. package/dist/commands/merge-command.d.ts +209 -74
  141. package/dist/commands/merge-command.d.ts.map +1 -1
  142. package/dist/commands/merge-config.d.ts +13 -0
  143. package/dist/commands/merge-config.d.ts.map +1 -0
  144. package/dist/commands/merge-drivers.d.ts +130 -0
  145. package/dist/commands/merge-drivers.d.ts.map +1 -0
  146. package/dist/commands/merge-support.d.ts +252 -0
  147. package/dist/commands/merge-support.d.ts.map +1 -0
  148. package/dist/commands/message-cleanup.d.ts +86 -0
  149. package/dist/commands/message-cleanup.d.ts.map +1 -0
  150. package/dist/commands/mv-command.d.ts +94 -0
  151. package/dist/commands/mv-command.d.ts.map +1 -0
  152. package/dist/commands/notes-command.d.ts +256 -0
  153. package/dist/commands/notes-command.d.ts.map +1 -0
  154. package/dist/commands/notes-commands.d.ts +41 -0
  155. package/dist/commands/notes-commands.d.ts.map +1 -0
  156. package/dist/commands/notes-merge-command.d.ts +105 -0
  157. package/dist/commands/notes-merge-command.d.ts.map +1 -0
  158. package/dist/commands/notes-support.d.ts +125 -0
  159. package/dist/commands/notes-support.d.ts.map +1 -0
  160. package/dist/commands/notes-tree.d.ts +106 -0
  161. package/dist/commands/notes-tree.d.ts.map +1 -0
  162. package/dist/commands/object-id-input.d.ts +20 -0
  163. package/dist/commands/object-id-input.d.ts.map +1 -0
  164. package/dist/commands/octopus-merge.d.ts +59 -0
  165. package/dist/commands/octopus-merge.d.ts.map +1 -0
  166. package/dist/commands/ort-merge.d.ts +126 -0
  167. package/dist/commands/ort-merge.d.ts.map +1 -0
  168. package/dist/commands/ort-recursive.d.ts +53 -0
  169. package/dist/commands/ort-recursive.d.ts.map +1 -0
  170. package/dist/commands/pack-refs-command.d.ts +20 -0
  171. package/dist/commands/pack-refs-command.d.ts.map +1 -1
  172. package/dist/commands/patch-id.d.ts +41 -0
  173. package/dist/commands/patch-id.d.ts.map +1 -0
  174. package/dist/commands/pathspec-attributes.d.ts +64 -0
  175. package/dist/commands/pathspec-attributes.d.ts.map +1 -0
  176. package/dist/commands/pathspec.d.ts +324 -0
  177. package/dist/commands/pathspec.d.ts.map +1 -0
  178. package/dist/commands/post-index-change.d.ts +33 -0
  179. package/dist/commands/post-index-change.d.ts.map +1 -0
  180. package/dist/commands/pretty-format.d.ts +222 -0
  181. package/dist/commands/pretty-format.d.ts.map +1 -0
  182. package/dist/commands/promisor-remote.d.ts +80 -0
  183. package/dist/commands/promisor-remote.d.ts.map +1 -0
  184. package/dist/commands/pull-command.d.ts +41 -8
  185. package/dist/commands/pull-command.d.ts.map +1 -1
  186. package/dist/commands/push-command.d.ts +24 -8
  187. package/dist/commands/push-command.d.ts.map +1 -1
  188. package/dist/commands/read-tree-command.d.ts +112 -0
  189. package/dist/commands/read-tree-command.d.ts.map +1 -0
  190. package/dist/commands/rebase-command.d.ts +507 -75
  191. package/dist/commands/rebase-command.d.ts.map +1 -1
  192. package/dist/commands/rebase-todo.d.ts +130 -0
  193. package/dist/commands/rebase-todo.d.ts.map +1 -0
  194. package/dist/commands/ref-decoration-filter.d.ts +53 -0
  195. package/dist/commands/ref-decoration-filter.d.ts.map +1 -0
  196. package/dist/commands/reflog-messages.d.ts +98 -0
  197. package/dist/commands/reflog-messages.d.ts.map +1 -0
  198. package/dist/commands/remote-command.d.ts +31 -0
  199. package/dist/commands/remote-command.d.ts.map +1 -1
  200. package/dist/commands/remote-transport.d.ts +120 -0
  201. package/dist/commands/remote-transport.d.ts.map +1 -0
  202. package/dist/commands/reset-command.d.ts +161 -7
  203. package/dist/commands/reset-command.d.ts.map +1 -1
  204. package/dist/commands/restore-command.d.ts +103 -0
  205. package/dist/commands/restore-command.d.ts.map +1 -0
  206. package/dist/commands/rev-list-command.d.ts +78 -0
  207. package/dist/commands/rev-list-command.d.ts.map +1 -0
  208. package/dist/commands/rev-parse-command.d.ts +80 -0
  209. package/dist/commands/rev-parse-command.d.ts.map +1 -0
  210. package/dist/commands/revert-command.d.ts +46 -38
  211. package/dist/commands/revert-command.d.ts.map +1 -1
  212. package/dist/commands/revision-filenames.d.ts +95 -0
  213. package/dist/commands/revision-filenames.d.ts.map +1 -0
  214. package/dist/commands/revision-range.d.ts +67 -0
  215. package/dist/commands/revision-range.d.ts.map +1 -0
  216. package/dist/commands/revision-resolver.d.ts +321 -0
  217. package/dist/commands/revision-resolver.d.ts.map +1 -0
  218. package/dist/commands/rm-command.d.ts +69 -7
  219. package/dist/commands/rm-command.d.ts.map +1 -1
  220. package/dist/commands/sequencer-pick.d.ts +191 -0
  221. package/dist/commands/sequencer-pick.d.ts.map +1 -0
  222. package/dist/commands/sequencer-support.d.ts +125 -0
  223. package/dist/commands/sequencer-support.d.ts.map +1 -0
  224. package/dist/commands/serve-repository.d.ts +52 -0
  225. package/dist/commands/serve-repository.d.ts.map +1 -0
  226. package/dist/commands/sparse-checkout-command.d.ts +190 -0
  227. package/dist/commands/sparse-checkout-command.d.ts.map +1 -0
  228. package/dist/commands/sparse-checkout-support.d.ts +268 -0
  229. package/dist/commands/sparse-checkout-support.d.ts.map +1 -0
  230. package/dist/commands/stash-apply-command.d.ts +42 -8
  231. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  232. package/dist/commands/stash-create-command.d.ts +155 -1
  233. package/dist/commands/stash-create-command.d.ts.map +1 -1
  234. package/dist/commands/stash-drop-command.d.ts +2 -0
  235. package/dist/commands/stash-drop-command.d.ts.map +1 -1
  236. package/dist/commands/stash-working-tree.d.ts +23 -0
  237. package/dist/commands/stash-working-tree.d.ts.map +1 -1
  238. package/dist/commands/status-command.d.ts +300 -15
  239. package/dist/commands/status-command.d.ts.map +1 -1
  240. package/dist/commands/status-format.d.ts +155 -0
  241. package/dist/commands/status-format.d.ts.map +1 -0
  242. package/dist/commands/status-header.d.ts +64 -0
  243. package/dist/commands/status-header.d.ts.map +1 -0
  244. package/dist/commands/strerror.d.ts +7 -0
  245. package/dist/commands/strerror.d.ts.map +1 -0
  246. package/dist/commands/submodule-config.d.ts +38 -0
  247. package/dist/commands/submodule-config.d.ts.map +1 -0
  248. package/dist/commands/submodule-summary-command.d.ts +80 -0
  249. package/dist/commands/submodule-summary-command.d.ts.map +1 -0
  250. package/dist/commands/submodule-summary.d.ts +150 -0
  251. package/dist/commands/submodule-summary.d.ts.map +1 -0
  252. package/dist/commands/switch-command.d.ts +132 -0
  253. package/dist/commands/switch-command.d.ts.map +1 -0
  254. package/dist/commands/tag-command.d.ts +23 -2
  255. package/dist/commands/tag-command.d.ts.map +1 -1
  256. package/dist/commands/tracking-info.d.ts +64 -0
  257. package/dist/commands/tracking-info.d.ts.map +1 -0
  258. package/dist/commands/trailers.d.ts +73 -0
  259. package/dist/commands/trailers.d.ts.map +1 -0
  260. package/dist/commands/tree-restore.d.ts +85 -1
  261. package/dist/commands/tree-restore.d.ts.map +1 -1
  262. package/dist/commands/untracked-cache-support.d.ts +53 -0
  263. package/dist/commands/untracked-cache-support.d.ts.map +1 -0
  264. package/dist/commands/worktree-add-command.d.ts +108 -0
  265. package/dist/commands/worktree-add-command.d.ts.map +1 -0
  266. package/dist/commands/worktree-list-command.d.ts +69 -0
  267. package/dist/commands/worktree-list-command.d.ts.map +1 -0
  268. package/dist/commands/worktree-lock-command.d.ts +44 -0
  269. package/dist/commands/worktree-lock-command.d.ts.map +1 -0
  270. package/dist/commands/worktree-overwrite-checks.d.ts +146 -6
  271. package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
  272. package/dist/commands/worktree-prune-command.d.ts +48 -0
  273. package/dist/commands/worktree-prune-command.d.ts.map +1 -0
  274. package/dist/commands/worktree-remove-command.d.ts +59 -0
  275. package/dist/commands/worktree-remove-command.d.ts.map +1 -0
  276. package/dist/commands/worktree-repair-command.d.ts +35 -0
  277. package/dist/commands/worktree-repair-command.d.ts.map +1 -0
  278. package/dist/commands/worktree-support.d.ts +64 -0
  279. package/dist/commands/worktree-support.d.ts.map +1 -0
  280. package/dist/commands-DnmlfwGV.js +61620 -0
  281. package/dist/core-commands/add.command.impl.d.ts.map +1 -1
  282. package/dist/errors/add-errors.d.ts +55 -0
  283. package/dist/errors/add-errors.d.ts.map +1 -1
  284. package/dist/errors/checkout-errors.d.ts +16 -0
  285. package/dist/errors/checkout-errors.d.ts.map +1 -1
  286. package/dist/errors/command-errors.d.ts +77 -0
  287. package/dist/errors/command-errors.d.ts.map +1 -1
  288. package/dist/errors/commit-errors.d.ts +9 -0
  289. package/dist/errors/commit-errors.d.ts.map +1 -1
  290. package/dist/errors/git-api-error.d.ts +59 -2
  291. package/dist/errors/git-api-error.d.ts.map +1 -1
  292. package/dist/errors/index.d.ts +1 -0
  293. package/dist/errors/index.d.ts.map +1 -1
  294. package/dist/errors/index.js +354 -19
  295. package/dist/errors/rebase-errors.d.ts +9 -0
  296. package/dist/errors/rebase-errors.d.ts.map +1 -1
  297. package/dist/errors/ref-errors.d.ts +32 -0
  298. package/dist/errors/ref-errors.d.ts.map +1 -1
  299. package/dist/errors/transport-errors.d.ts +12 -2
  300. package/dist/errors/transport-errors.d.ts.map +1 -1
  301. package/dist/errors/worktree-errors.d.ts +35 -0
  302. package/dist/errors/worktree-errors.d.ts.map +1 -0
  303. package/dist/git-command-DxvwPrPB.js +7612 -0
  304. package/dist/git-command.d.ts +413 -32
  305. package/dist/git-command.d.ts.map +1 -1
  306. package/dist/git.d.ts +306 -3
  307. package/dist/git.d.ts.map +1 -1
  308. package/dist/index.d.ts +1 -1
  309. package/dist/index.d.ts.map +1 -1
  310. package/dist/index.js +5 -5
  311. package/dist/remote-config/remote-config-store.d.ts +105 -3
  312. package/dist/remote-config/remote-config-store.d.ts.map +1 -1
  313. package/dist/remote-config/remote-refs.d.ts +7 -3
  314. package/dist/remote-config/remote-refs.d.ts.map +1 -1
  315. package/dist/rename/detect-renames.d.ts +148 -0
  316. package/dist/rename/detect-renames.d.ts.map +1 -0
  317. package/dist/rename/git-similarity.d.ts +44 -0
  318. package/dist/rename/git-similarity.d.ts.map +1 -0
  319. package/dist/rename/index.d.ts +2 -0
  320. package/dist/rename/index.d.ts.map +1 -1
  321. package/dist/results/binary-patch.d.ts +11 -0
  322. package/dist/results/binary-patch.d.ts.map +1 -0
  323. package/dist/results/blame-format.d.ts +55 -0
  324. package/dist/results/blame-format.d.ts.map +1 -0
  325. package/dist/results/cherry-pick-result.d.ts +10 -0
  326. package/dist/results/cherry-pick-result.d.ts.map +1 -1
  327. package/dist/results/clone-result.d.ts +10 -0
  328. package/dist/results/clone-result.d.ts.map +1 -1
  329. package/dist/results/combined-diff.d.ts +77 -0
  330. package/dist/results/combined-diff.d.ts.map +1 -0
  331. package/dist/results/diff-entry.d.ts +32 -0
  332. package/dist/results/diff-entry.d.ts.map +1 -1
  333. package/dist/results/diff-formatter.d.ts +34 -60
  334. package/dist/results/diff-formatter.d.ts.map +1 -1
  335. package/dist/results/diff-order.d.ts +25 -0
  336. package/dist/results/diff-order.d.ts.map +1 -0
  337. package/dist/results/diff-output.d.ts +249 -0
  338. package/dist/results/diff-output.d.ts.map +1 -0
  339. package/dist/results/fetch-result.d.ts +15 -0
  340. package/dist/results/fetch-result.d.ts.map +1 -1
  341. package/dist/results/index.d.ts +5 -0
  342. package/dist/results/index.d.ts.map +1 -1
  343. package/dist/results/index.js +2 -252
  344. package/dist/results/merge-result.d.ts +15 -1
  345. package/dist/results/merge-result.d.ts.map +1 -1
  346. package/dist/results/pull-result.d.ts +12 -3
  347. package/dist/results/pull-result.d.ts.map +1 -1
  348. package/dist/results/push-result.d.ts +42 -0
  349. package/dist/results/push-result.d.ts.map +1 -1
  350. package/dist/results/quote-path.d.ts +27 -0
  351. package/dist/results/quote-path.d.ts.map +1 -0
  352. package/dist/results/rebase-result.d.ts +28 -1
  353. package/dist/results/rebase-result.d.ts.map +1 -1
  354. package/dist/results/revert-result.d.ts +10 -0
  355. package/dist/results/revert-result.d.ts.map +1 -1
  356. package/dist/results/stash-result.d.ts +5 -0
  357. package/dist/results/stash-result.d.ts.map +1 -1
  358. package/dist/results/status-result.d.ts +60 -6
  359. package/dist/results/status-result.d.ts.map +1 -1
  360. package/dist/results-BZGa2Z3I.js +2934 -0
  361. package/dist/transport-command.d.ts +44 -1
  362. package/dist/transport-command.d.ts.map +1 -1
  363. package/package.json +15 -11
  364. package/src/commands/add-command.ts +1291 -226
  365. package/src/commands/add-patch/add-interactive.ts +941 -0
  366. package/src/commands/add-patch/add-patch.ts +1169 -0
  367. package/src/commands/add-patch/index.ts +5 -0
  368. package/src/commands/add-patch/patch-backend.ts +239 -0
  369. package/src/commands/add-patch/patch-modes.ts +249 -0
  370. package/src/commands/add-patch/patch-session.ts +159 -0
  371. package/src/commands/am/am-command.ts +1111 -0
  372. package/src/commands/am/index.ts +2 -0
  373. package/src/commands/am/mailinfo.ts +1015 -0
  374. package/src/commands/am/patch-format.ts +121 -0
  375. package/src/commands/apply/apply-command.ts +832 -0
  376. package/src/commands/apply/apply-engine.ts +1603 -0
  377. package/src/commands/apply/apply-parse.ts +1209 -0
  378. package/src/commands/apply/apply-types.ts +112 -0
  379. package/src/commands/apply/index.ts +5 -0
  380. package/src/commands/apply/latin1.ts +171 -0
  381. package/src/commands/apply/whitespace.ts +260 -0
  382. package/src/commands/attributes-source.ts +96 -0
  383. package/src/commands/backfill-command.ts +694 -0
  384. package/src/commands/bisect/bisect-checkout.ts +217 -0
  385. package/src/commands/bisect/bisect-command.ts +788 -0
  386. package/src/commands/bisect/bisect-engine.ts +1079 -0
  387. package/src/commands/bisect/bisect-graph.ts +595 -0
  388. package/src/commands/bisect/bisect-quote.ts +92 -0
  389. package/src/commands/bisect/index.ts +4 -0
  390. package/src/commands/blame-command.ts +711 -986
  391. package/src/commands/branch-command.ts +354 -32
  392. package/src/commands/branch-tracking.ts +331 -0
  393. package/src/commands/checkout-command.ts +1290 -243
  394. package/src/commands/checkout-paths.ts +784 -0
  395. package/src/commands/cherry-pick-command.ts +156 -396
  396. package/src/commands/clean-command.ts +504 -156
  397. package/src/commands/clone-command.ts +634 -67
  398. package/src/commands/commit-command.ts +1781 -166
  399. package/src/commands/core-config.ts +161 -6
  400. package/src/commands/date-format.ts +668 -0
  401. package/src/commands/describe-command.ts +2 -0
  402. package/src/commands/diff-command.ts +1898 -110
  403. package/src/commands/diff-textconv.ts +50 -0
  404. package/src/commands/fetch-command.ts +606 -66
  405. package/src/commands/format-patch-command.ts +969 -0
  406. package/src/commands/fsck/fetch-fsck.ts +229 -0
  407. package/src/commands/fsck/fsck-command.ts +3347 -0
  408. package/src/commands/fsck/fsck-loose.ts +287 -0
  409. package/src/commands/fsck/fsck-msg-ids.ts +176 -0
  410. package/src/commands/fsck/fsck-object-checks.ts +1044 -0
  411. package/src/commands/fsck/fsck-object-table.ts +363 -0
  412. package/src/commands/fsck/fsck-pack.ts +604 -0
  413. package/src/commands/fsck/index.ts +5 -0
  414. package/src/commands/fsck/verify-pack-command.ts +249 -0
  415. package/src/commands/gc-command.ts +147 -1
  416. package/src/commands/git-date.ts +895 -0
  417. package/src/commands/git-describe.ts +316 -0
  418. package/src/commands/git-hooks.ts +1472 -0
  419. package/src/commands/git-ident.ts +344 -0
  420. package/src/commands/hook-command.ts +247 -0
  421. package/src/commands/index-adder.ts +706 -0
  422. package/src/commands/index-host.ts +291 -0
  423. package/src/commands/index.ts +82 -0
  424. package/src/commands/init-command.ts +28 -4
  425. package/src/commands/local-clone.ts +183 -0
  426. package/src/commands/local-transport.ts +762 -0
  427. package/src/commands/log-command.ts +1915 -170
  428. package/src/commands/log-graph.ts +671 -0
  429. package/src/commands/log-output.ts +1359 -0
  430. package/src/commands/ls-remote-command.ts +101 -58
  431. package/src/commands/mailmap.ts +129 -0
  432. package/src/commands/merge-bases.ts +296 -0
  433. package/src/commands/merge-command.ts +1386 -491
  434. package/src/commands/merge-config.ts +25 -0
  435. package/src/commands/merge-drivers.ts +306 -0
  436. package/src/commands/merge-support.ts +1198 -0
  437. package/src/commands/message-cleanup.ts +275 -0
  438. package/src/commands/mv-command.ts +976 -0
  439. package/src/commands/notes-command.ts +890 -0
  440. package/src/commands/notes-commands.ts +87 -0
  441. package/src/commands/notes-merge-command.ts +768 -0
  442. package/src/commands/notes-support.ts +402 -0
  443. package/src/commands/notes-tree.ts +602 -0
  444. package/src/commands/object-id-input.ts +27 -0
  445. package/src/commands/octopus-merge.ts +377 -0
  446. package/src/commands/ort-merge.ts +1660 -0
  447. package/src/commands/ort-recursive.ts +160 -0
  448. package/src/commands/pack-refs-command.ts +39 -22
  449. package/src/commands/patch-id.ts +196 -0
  450. package/src/commands/pathspec-attributes.ts +162 -0
  451. package/src/commands/pathspec.ts +1199 -0
  452. package/src/commands/post-index-change.ts +62 -0
  453. package/src/commands/pretty-format.ts +1431 -0
  454. package/src/commands/promisor-remote.ts +298 -0
  455. package/src/commands/pull-command.ts +207 -22
  456. package/src/commands/push-command.ts +236 -23
  457. package/src/commands/read-tree-command.ts +857 -0
  458. package/src/commands/rebase-command.ts +3808 -371
  459. package/src/commands/rebase-todo.ts +584 -0
  460. package/src/commands/ref-decoration-filter.ts +118 -0
  461. package/src/commands/reflog-messages.ts +177 -0
  462. package/src/commands/remote-command.ts +93 -22
  463. package/src/commands/remote-transport.ts +383 -0
  464. package/src/commands/reset-command.ts +827 -103
  465. package/src/commands/restore-command.ts +350 -0
  466. package/src/commands/rev-list-command.ts +167 -0
  467. package/src/commands/rev-parse-command.ts +277 -0
  468. package/src/commands/revert-command.ts +152 -399
  469. package/src/commands/revision-filenames.ts +254 -0
  470. package/src/commands/revision-range.ts +222 -0
  471. package/src/commands/revision-resolver.ts +1379 -0
  472. package/src/commands/rm-command.ts +613 -67
  473. package/src/commands/sequencer-pick.ts +869 -0
  474. package/src/commands/sequencer-support.ts +869 -0
  475. package/src/commands/serve-repository.ts +125 -0
  476. package/src/commands/sparse-checkout-command.ts +1389 -0
  477. package/src/commands/sparse-checkout-support.ts +793 -0
  478. package/src/commands/stash-apply-command.ts +376 -343
  479. package/src/commands/stash-create-command.ts +625 -42
  480. package/src/commands/stash-drop-command.ts +15 -2
  481. package/src/commands/stash-working-tree.ts +168 -24
  482. package/src/commands/status-command.ts +1328 -105
  483. package/src/commands/status-format.ts +775 -0
  484. package/src/commands/status-header.ts +330 -0
  485. package/src/commands/strerror.ts +29 -0
  486. package/src/commands/submodule-config.ts +94 -0
  487. package/src/commands/submodule-summary-command.ts +334 -0
  488. package/src/commands/submodule-summary.ts +446 -0
  489. package/src/commands/switch-command.ts +402 -0
  490. package/src/commands/tag-command.ts +129 -41
  491. package/src/commands/tracking-info.ts +201 -0
  492. package/src/commands/trailers.ts +417 -0
  493. package/src/commands/tree-restore.ts +204 -4
  494. package/src/commands/untracked-cache-support.ts +194 -0
  495. package/src/commands/worktree-add-command.ts +458 -0
  496. package/src/commands/worktree-list-command.ts +208 -0
  497. package/src/commands/worktree-lock-command.ts +96 -0
  498. package/src/commands/worktree-overwrite-checks.ts +452 -26
  499. package/src/commands/worktree-prune-command.ts +99 -0
  500. package/src/commands/worktree-remove-command.ts +186 -0
  501. package/src/commands/worktree-repair-command.ts +59 -0
  502. package/src/commands/worktree-support.ts +214 -0
  503. package/src/core-commands/add.command.impl.ts +7 -1
  504. package/src/errors/add-errors.ts +45 -0
  505. package/src/errors/checkout-errors.ts +26 -2
  506. package/src/errors/command-errors.ts +101 -1
  507. package/src/errors/commit-errors.ts +18 -2
  508. package/src/errors/git-api-error.ts +82 -2
  509. package/src/errors/index.ts +1 -0
  510. package/src/errors/merge-errors.ts +2 -2
  511. package/src/errors/rebase-errors.ts +12 -0
  512. package/src/errors/ref-errors.ts +56 -2
  513. package/src/errors/remote-errors.ts +2 -2
  514. package/src/errors/stash-errors.ts +1 -1
  515. package/src/errors/transport-errors.ts +20 -4
  516. package/src/errors/worktree-errors.ts +49 -0
  517. package/src/git-command.ts +1177 -118
  518. package/src/git.ts +523 -10
  519. package/src/index.ts +1 -1
  520. package/src/remote-config/remote-config-store.ts +242 -8
  521. package/src/remote-config/remote-refs.ts +22 -6
  522. package/src/rename/detect-renames.ts +711 -0
  523. package/src/rename/git-similarity.ts +116 -0
  524. package/src/rename/index.ts +2 -0
  525. package/src/results/binary-patch.ts +401 -0
  526. package/src/results/blame-format.ts +239 -0
  527. package/src/results/cherry-pick-result.ts +10 -0
  528. package/src/results/clone-result.ts +12 -0
  529. package/src/results/combined-diff.ts +585 -0
  530. package/src/results/diff-entry.ts +35 -0
  531. package/src/results/diff-formatter.ts +152 -288
  532. package/src/results/diff-order.ts +64 -0
  533. package/src/results/diff-output.ts +1051 -0
  534. package/src/results/fetch-result.ts +15 -0
  535. package/src/results/index.ts +5 -0
  536. package/src/results/merge-result.ts +15 -1
  537. package/src/results/pull-result.ts +12 -3
  538. package/src/results/push-result.ts +43 -0
  539. package/src/results/quote-path.ts +103 -0
  540. package/src/results/rebase-result.ts +37 -0
  541. package/src/results/revert-result.ts +10 -0
  542. package/src/results/stash-result.ts +6 -0
  543. package/src/results/status-result.ts +123 -45
  544. package/src/transport-command.ts +121 -2
  545. package/dist/commands-CsLNyvZ1.js +0 -12587
  546. package/dist/status-result-BpyUK1Sg.js +0 -519
@@ -1,24 +1,45 @@
1
1
  import type { ObjectId } from "@statewalker/vcs-core";
2
2
  // Import from the package root only: vcs-core ships a single runtime file
3
3
  // (dist/index.js); its subpaths resolve for types but not at runtime.
4
- import { isSymbolicRef } from "@statewalker/vcs-core";
5
4
  import {
5
+ type FilesApi,
6
+ historyWithoutLazyFetch,
7
+ isSymbolicRef,
8
+ parseCoreAbbrev,
9
+ } from "@statewalker/vcs-core";
10
+ import { writeCommitGraph } from "@statewalker/vcs-store-files";
11
+ import {
12
+ anonymizeUrl,
6
13
  createRepositoryFacade,
7
14
  createTransportRefStore,
8
15
  expandFromDestination,
16
+ FetchCheckError,
9
17
  type FetchClientResult,
18
+ type FetchDisplayEntry,
10
19
  type FetchHeadEntry,
11
20
  type FetchRefUpdate,
21
+ fetchFromConnection,
22
+ fetchRefcolWidth,
23
+ fetchUpdateDisplay,
24
+ formatFetchDisplay,
12
25
  formatFetchHead,
13
26
  matchDestination,
14
27
  matchSource,
15
28
  parseRefSpec,
16
29
  type RefSpec,
17
30
  type TagMode,
18
- fetch as transportFetch,
31
+ type FetchOptions as TransportFetchOptions,
32
+ transportSummaryWidth,
33
+ ZERO_OID,
19
34
  } from "@statewalker/vcs-transport";
20
-
21
- import { InvalidArgumentError, InvalidRemoteError } from "../errors/index.js";
35
+ import { parseGitBool } from "@statewalker/vcs-utils";
36
+ import type { WorktreeAdmin } from "@statewalker/vcs-working-tree";
37
+ import {
38
+ FetchIntoCheckedOutBranchError,
39
+ InvalidArgumentError,
40
+ InvalidRemoteError,
41
+ TransportError,
42
+ } from "../errors/index.js";
22
43
  import { deleteRefs, RemoteConfigStore } from "../remote-config/index.js";
23
44
  import {
24
45
  type FetchResult,
@@ -26,6 +47,16 @@ import {
26
47
  type TrackingRefUpdate,
27
48
  } from "../results/fetch-result.js";
28
49
  import { TransportCommand } from "../transport-command.js";
50
+ import { fetchFsckOf } from "./fsck/index.js";
51
+ import { hostEnvironmentOf } from "./git-ident.js";
52
+ import {
53
+ hasPromisorRemote,
54
+ promisorOf,
55
+ promisorRemotes,
56
+ registerPartialClone,
57
+ } from "./promisor-remote.js";
58
+ import { withRemoteUploadPack } from "./remote-transport.js";
59
+ import { worktreeUsingBranch } from "./worktree-support.js";
29
60
 
30
61
  /**
31
62
  * Tag fetching option.
@@ -76,7 +107,10 @@ export enum TagOption {
76
107
  */
77
108
  export class FetchCommand extends TransportCommand<FetchResult> {
78
109
  private remote = "origin";
110
+ /** Whether the remote was named (it is then in the reflog action, as on git's command line). */
111
+ private remoteGiven = false;
79
112
  private refSpecs: string[] = [];
113
+ private updateHeadOk = false;
80
114
  private removeDeletedRefs?: boolean;
81
115
  private pruneTags?: boolean;
82
116
  private refmap?: string[];
@@ -84,15 +118,26 @@ export class FetchCommand extends TransportCommand<FetchResult> {
84
118
  private tagOptionSet = false;
85
119
  private writeFetchHead = true;
86
120
  private appendFetchHead = false;
121
+ private verbose = false;
122
+ private porcelain = false;
87
123
  private thin = true;
88
124
  private depth?: number;
125
+ private uploadPack?: string;
89
126
  private dryRun = false;
127
+ private writeCommitGraphOption?: boolean;
128
+ private repositoryFiles?: { files: FilesApi; gitDir?: string };
90
129
  private forceUpdate = false;
91
- private checkFetchedObjects = false;
130
+ private atomic = false;
131
+ private checkFetchedObjects?: boolean;
132
+ private compatibility?: "2.43" | "2.56";
92
133
  private initialBranch?: string;
93
134
  private shallowSince?: Date;
94
135
  private shallowExcludes: string[] = [];
95
136
  private unshallow = false;
137
+ private updateShallow = false;
138
+ /** `--filter=<spec>` (a string), `--no-filter` (false), or neither */
139
+ private filterSpec?: string | false;
140
+ private refetch = false;
96
141
 
97
142
  /**
98
143
  * Set the remote to fetch from.
@@ -105,6 +150,7 @@ export class FetchCommand extends TransportCommand<FetchResult> {
105
150
  setRemote(remote: string): this {
106
151
  this.checkCallable();
107
152
  this.remote = remote;
153
+ this.remoteGiven = true;
108
154
  return this;
109
155
  }
110
156
 
@@ -239,6 +285,64 @@ export class FetchCommand extends TransportCommand<FetchResult> {
239
285
  return this.appendFetchHead;
240
286
  }
241
287
 
288
+ /**
289
+ * Set whether refs already up to date are reported too (`git fetch -v`): their lines,
290
+ * ` = [up to date] main -> origin/main`, join {@link FetchResult.display} in
291
+ * git's order, and the remote column is as wide as their names need.
292
+ */
293
+ setVerbose(verbose: boolean): this {
294
+ this.checkCallable();
295
+ this.verbose = verbose;
296
+ return this;
297
+ }
298
+
299
+ /** Whether up-to-date refs are reported (`-v`). */
300
+ isVerbose(): boolean {
301
+ return this.verbose;
302
+ }
303
+
304
+ /**
305
+ * Set whether the ref lines are git's machine-readable ones (`git fetch --porcelain`,
306
+ * printed on stdout): {@link FetchResult.display} then holds `<flag> <old-id> <new-id>
307
+ * <local-ref>` per ref, full ids (zeros for none) and full ref names, without the
308
+ * `From <url>` line; `fetch.output` does not apply.
309
+ */
310
+ setPorcelain(porcelain: boolean): this {
311
+ this.checkCallable();
312
+ this.porcelain = porcelain;
313
+ return this;
314
+ }
315
+
316
+ /** Whether the ref lines are porcelain ones (`--porcelain`). */
317
+ isPorcelain(): boolean {
318
+ return this.porcelain;
319
+ }
320
+
321
+ /**
322
+ * Partial fetch (`git fetch --filter=<spec>`), or `false` for `--no-filter`. Unset, a
323
+ * fetch from a promisor remote of a partial clone uses its `remote.<name>.partialclonefilter`
324
+ * (git's fetch_one_setup_partial); a filter given registers the remote as a promisor remote
325
+ * first when it is not one with a filter (partial_clone_register:
326
+ * `core.repositoryformatversion = 1`, `remote.<name>.promisor`, `.partialclonefilter`). A
327
+ * pack fetched under a filter is kept as a promisor pack.
328
+ */
329
+ setFilter(spec: string | false): this {
330
+ this.checkCallable();
331
+ this.filterSpec = spec;
332
+ return this;
333
+ }
334
+
335
+ /**
336
+ * `git fetch --refetch`: everything the refspecs select is fetched again, as a fresh clone
337
+ * would (no local commit offered as a `have`, no tip counted as here), under the filter in
338
+ * use: how a partial clone changes its filter.
339
+ */
340
+ setRefetch(refetch: boolean): this {
341
+ this.checkCallable();
342
+ this.refetch = refetch;
343
+ return this;
344
+ }
345
+
242
346
  /**
243
347
  * Set thin-pack preference.
244
348
  *
@@ -271,6 +375,45 @@ export class FetchCommand extends TransportCommand<FetchResult> {
271
375
  return this;
272
376
  }
273
377
 
378
+ /**
379
+ * Set the program the remote runs for upload-pack (git's `--upload-pack`, over
380
+ * `remote.<name>.uploadpack`): what an ssh connector runs, and what git:// names in its
381
+ * request line.
382
+ *
383
+ * @param uploadPack Path to git-upload-pack on the remote
384
+ */
385
+ setUploadPack(uploadPack: string): this {
386
+ this.checkCallable();
387
+ this.uploadPack = uploadPack;
388
+ return this;
389
+ }
390
+
391
+ /**
392
+ * `--[no-]write-commit-graph`: after the fetch, write a split commit-graph of everything the
393
+ * refs reach, as git does with `fetch.writeCommitGraph` (which this overrides). It needs the
394
+ * repository's files (`setRepositoryFiles`).
395
+ */
396
+ setWriteCommitGraph(write: boolean): this {
397
+ this.checkCallable();
398
+ this.writeCommitGraphOption = write;
399
+ return this;
400
+ }
401
+
402
+ /**
403
+ * The files of the repository (a files backend), where `fetch.writeCommitGraph` writes the
404
+ * commit-graph. Without them no graph is written.
405
+ *
406
+ * @example
407
+ * ```typescript
408
+ * await git.fetch().setRepositoryFiles({ files }).setWriteCommitGraph(true).call();
409
+ * ```
410
+ */
411
+ setRepositoryFiles(repository: { files: FilesApi; gitDir?: string }): this {
412
+ this.checkCallable();
413
+ this.repositoryFiles = repository;
414
+ return this;
415
+ }
416
+
274
417
  /**
275
418
  * Set dry run mode.
276
419
  *
@@ -291,6 +434,17 @@ export class FetchCommand extends TransportCommand<FetchResult> {
291
434
  return this.dryRun;
292
435
  }
293
436
 
437
+ /**
438
+ * Let the fetch write a branch a worktree has checked out (`git fetch --update-head-ok`,
439
+ * which `git pull` passes). Without it a fetch whose refspecs would write such a branch
440
+ * fails before fetching anything (`FetchIntoCheckedOutBranchError`).
441
+ */
442
+ setUpdateHeadOk(ok: boolean): this {
443
+ this.checkCallable();
444
+ this.updateHeadOk = ok;
445
+ return this;
446
+ }
447
+
294
448
  /**
295
449
  * Set force update mode.
296
450
  *
@@ -304,6 +458,16 @@ export class FetchCommand extends TransportCommand<FetchResult> {
304
458
  return this;
305
459
  }
306
460
 
461
+ /**
462
+ * Update the local refs in one transaction, all or none (`git fetch --atomic`). Each ref
463
+ * is still logged with its own reflog message, as git's transaction logs it.
464
+ */
465
+ setAtomic(atomic: boolean): this {
466
+ this.checkCallable();
467
+ this.atomic = atomic;
468
+ return this;
469
+ }
470
+
307
471
  /**
308
472
  * Whether force update mode is enabled.
309
473
  */
@@ -312,9 +476,18 @@ export class FetchCommand extends TransportCommand<FetchResult> {
312
476
  }
313
477
 
314
478
  /**
315
- * Set whether to check received objects for validity.
479
+ * Set whether to check received objects for validity, over `fetch.fsckObjects` (else
480
+ * `transfer.fsckObjects`), which decide when this is not set.
481
+ *
482
+ * Checked, each received object passes fsck as git's `index-pack --strict` runs it
483
+ * (`fetch.fsck.<msg-id>` severities, `fetch.fsck.skipList`), and every object it names came
484
+ * with the pack or is here; otherwise the fetch fails with `FetchCheckError` (git's
485
+ * `error: object <id>: <msg-id>: <message>`, `fatal: fsck error in packed object`, `fatal:
486
+ * index-pack failed`), leaving no ref and no received object behind.
316
487
  *
317
- * If true, objects received will be verified.
488
+ * Whatever this says, the new ref tips must be connected (git's check_connected): a
489
+ * remote that does not send every object they need fails the fetch (`error: <url> did not
490
+ * send all necessary objects`, exit 1) before any ref is written.
318
491
  *
319
492
  * @param check Whether to check objects
320
493
  */
@@ -325,10 +498,22 @@ export class FetchCommand extends TransportCommand<FetchResult> {
325
498
  }
326
499
 
327
500
  /**
328
- * Whether to check received objects for validity.
501
+ * Whether to check received objects for validity, as set with {@link setCheckFetchedObjects}
502
+ * (false when unset: the configuration is read when the fetch runs).
329
503
  */
330
504
  isCheckFetchedObjects(): boolean {
331
- return this.checkFetchedObjects;
505
+ return this.checkFetchedObjects ?? false;
506
+ }
507
+
508
+ /**
509
+ * Whose output to give where git 2.43 and 2.5x differ (2.43 prints an empty line after
510
+ * `error: <url> did not send all necessary objects`; fsck of a tag's `gpgsig` header).
511
+ * Default: the hook runner's compatibility, else 2.56.
512
+ */
513
+ setCompatibility(version: "2.43" | "2.56"): this {
514
+ this.checkCallable();
515
+ this.compatibility = version;
516
+ return this;
332
517
  }
333
518
 
334
519
  /**
@@ -409,6 +594,18 @@ export class FetchCommand extends TransportCommand<FetchResult> {
409
594
  return this;
410
595
  }
411
596
 
597
+ /**
598
+ * `git fetch --update-shallow`: from a shallow remote, the shallow commits the fetched
599
+ * history needs are added to `.git/shallow`. Without it, each ref whose new history needs
600
+ * one is left alone, as git leaves it (`warning: rejected <ref> because shallow roots are
601
+ * not allowed to be updated` for one that would have been merged).
602
+ */
603
+ setUpdateShallow(updateShallow: boolean): this {
604
+ this.checkCallable();
605
+ this.updateShallow = updateShallow;
606
+ return this;
607
+ }
608
+
412
609
  /**
413
610
  * Whether unshallow mode is enabled.
414
611
  */
@@ -416,6 +613,35 @@ export class FetchCommand extends TransportCommand<FetchResult> {
416
613
  return this.unshallow;
417
614
  }
418
615
 
616
+ /**
617
+ * The options as git's reflog action spells the command line (`GIT_REFLOG_ACTION` is
618
+ * `fetch` and its arguments), in a fixed order since our options have none:
619
+ * `--atomic --force --prune --prune-tags --tags --depth=<n> --unshallow --append
620
+ * --no-write-fetch-head --refmap=<spec>` (and their `--no-` forms where set to false).
621
+ */
622
+ private commandLineOptions(): string[] {
623
+ const flag = (value: boolean | undefined, name: string) =>
624
+ value === true ? [`--${name}`] : value === false ? [`--no-${name}`] : [];
625
+ return [
626
+ ...(this.verbose ? ["-v"] : []),
627
+ ...(this.porcelain ? ["--porcelain"] : []),
628
+ ...(this.atomic ? ["--atomic"] : []),
629
+ ...(this.forceUpdate ? ["--force"] : []),
630
+ ...flag(this.removeDeletedRefs, "prune"),
631
+ ...flag(this.pruneTags, "prune-tags"),
632
+ ...(this.tagOptionSet && this.tagOption === TagOption.FETCH_TAGS ? ["--tags"] : []),
633
+ ...(this.tagOptionSet && this.tagOption === TagOption.NO_TAGS ? ["--no-tags"] : []),
634
+ ...(this.depth !== undefined ? [`--depth=${this.depth}`] : []),
635
+ ...(this.unshallow ? ["--unshallow"] : []),
636
+ ...(this.appendFetchHead ? ["--append"] : []),
637
+ ...(this.writeFetchHead ? [] : ["--no-write-fetch-head"]),
638
+ ...(this.refmap ?? []).map((spec) => `--refmap=${spec}`),
639
+ ...(typeof this.filterSpec === "string" ? [`--filter=${this.filterSpec}`] : []),
640
+ ...(this.filterSpec === false ? ["--no-filter"] : []),
641
+ ...(this.refetch ? ["--refetch"] : []),
642
+ ];
643
+ }
644
+
419
645
  /**
420
646
  * Execute the fetch operation.
421
647
  *
@@ -494,67 +720,189 @@ export class FetchCommand extends TransportCommand<FetchResult> {
494
720
  const errors: string[] = [];
495
721
  const trackingUpdates: TrackingRefUpdate[] = [];
496
722
 
723
+ // transport_get: git's local transport (upload-pack of the repository at the path, in
724
+ // process), or the connector the transport registry names (smart HTTP by default);
725
+ // anything else fails in git's words. The remote is reached before FETCH_HEAD is touched
726
+ // (transport_get_remote_refs comes first in do_fetch)
727
+ const remote = await this.prepareRemote(remoteUrl);
728
+
497
729
  // git truncates FETCH_HEAD when the fetch starts: a failed fetch leaves it empty
498
- const checkout = this._workingCopy.checkout;
730
+ // a bare repository writes FETCH_HEAD in its git directory (no checkout to ask)
731
+ const checkout =
732
+ "checkout" in this._workingCopy
733
+ ? this._workingCopy.checkout
734
+ : (this._workingCopy as Partial<Pick<WorktreeAdmin, "bareRepository">>).bareRepository;
499
735
  const writesFetchHead = !this.dryRun && this.writeFetchHead && !!checkout?.writeFetchHead;
500
736
  if (writesFetchHead && !this.appendFetchHead) await checkout.writeFetchHead?.("");
501
737
 
502
- const result = await transportFetch({
738
+ // fetch_one_setup_partial: the filter given (the remote registered as a promisor remote),
739
+ // else a promisor remote's own filter
740
+ let filter: string | undefined;
741
+ if (this.filterSpec !== false && !this.dryRun) {
742
+ if (typeof this.filterSpec === "string") {
743
+ filter = this.filterSpec;
744
+ if (viaConfig) {
745
+ registerPartialClone(store, this.remote, filter);
746
+ await store.save();
747
+ promisorOf(this._workingCopy)?.fetcher?.invalidate?.();
748
+ }
749
+ } else if (hasPromisorRemote(store)) {
750
+ filter = promisorRemotes(store).find((r) => r.name === this.remote)?.partialCloneFilter;
751
+ }
752
+ } else if (typeof this.filterSpec === "string") filter = this.filterSpec;
753
+
754
+ // fetch.fsckObjects / transfer.fsckObjects: index-pack --strict over each received pack
755
+ const compatibility = this.compatibility ?? this.hooks.compatibility;
756
+ const environment = hostEnvironmentOf(this.workingCopy);
757
+ const fsckWarnings: string[] = [];
758
+ const fsck = await fetchFsckOf(
759
+ {
760
+ value: (key) => store.value(key),
761
+ entries: (prefix) => store.entriesWithPrefix(prefix),
762
+ warnings: fsckWarnings,
763
+ compatibility,
764
+ ...(environment
765
+ ? { readFile: (path: string) => environment.readFile(path), home: environment.home }
766
+ : {}),
767
+ baseDir: await this.hostWorkingDir(),
768
+ },
769
+ this.checkFetchedObjects,
770
+ );
771
+
772
+ const fetchOptions: TransportFetchOptions = {
503
773
  url: remoteUrl,
504
774
  auth: this.credentials,
505
775
  headers: this.headers,
506
776
  timeout: this.timeout,
507
777
  gzipRequests: this.gzipRequests,
508
- repository: createRepositoryFacade({ history }),
778
+ repository: createRepositoryFacade({ history: historyWithoutLazyFetch(history) }),
509
779
  refStore: createTransportRefStore(history.refs),
510
780
  refspecs,
511
781
  opportunisticRefspecs: opportunistic.length > 0 ? opportunistic : undefined,
512
- // fetch.c do_fetch: stale refs are pruned before anything is fetched; with
513
- // command-line refspecs by those, else by the configured ones
514
- beforeFetch: prune
515
- ? async (remoteRefs) => {
516
- const names = new Set(remoteRefs.filter((r) => r.oid).map((r) => r.name));
517
- const pruneSpecs = (fromConfig ? configured : explicitSpecs).map((s) =>
518
- parseRefSpec(s),
519
- );
520
- trackingUpdates.push(
521
- ...(await this.pruneDeletedRefs(names, pruneSpecs, messages, errors)),
522
- );
523
- }
524
- : undefined,
782
+ // fetch.c do_fetch: a branch a worktree has checked out is not fetched into (the
783
+ // whole fetch dies first, unless --update-head-ok); stale refs are pruned before
784
+ // anything is fetched, with command-line refspecs by those, else by the configured ones.
785
+ // With --atomic, prune_refs queues the deletions into the one transaction: a refused
786
+ // update or a failed commit leaves the stale refs too
787
+ beforeFetch: async (remoteRefs, refMap) => {
788
+ // check_not_current_branch over git's ref map: the refs the refspecs took and their
789
+ // opportunistic updates, not every advertised ref the configured refspecs would map
790
+ if (!this.updateHeadOk) await this.refuseCheckedOutBranch(refMap);
791
+ if (!prune) return;
792
+ const names = new Set(remoteRefs.filter((r) => r.oid).map((r) => r.name));
793
+ const pruneSpecs = (fromConfig ? configured : explicitSpecs).map((s) => parseRefSpec(s));
794
+ const defer = this.atomic && !this.dryRun;
795
+ const pruned = await this.pruneDeletedRefs(names, pruneSpecs, messages, errors, defer);
796
+ trackingUpdates.push(...pruned);
797
+ return defer ? { deletes: pruned.map((u) => u.localRef) } : undefined;
798
+ },
525
799
  missingRefsOk: useConfig,
526
800
  tags: toTagMode(this.effectiveTagOption()),
527
801
  depth: this.depth,
528
802
  deepenSince: this.shallowSince,
529
803
  deepenNot: this.shallowExcludes.length > 0 ? this.shallowExcludes : undefined,
530
804
  unshallow: this.unshallow || undefined,
805
+ updateShallow: this.updateShallow || undefined,
531
806
  force: this.forceUpdate,
807
+ atomic: this.atomic || undefined,
532
808
  dryRun: this.dryRun,
533
809
  onProgress: this.progressMessageCallback,
534
- reflogMessage: `fetch: ${remoteUrl}`,
810
+ // git's "fetch <args>: <what>" per ref; the action from the options, the remote and
811
+ // the refspecs given (git's argv)
812
+ reflogAction: this.reflogAction(
813
+ [
814
+ "fetch",
815
+ ...this.commandLineOptions(),
816
+ ...(this.remoteGiven || this.refSpecs.length > 0 ? [this.remote] : []),
817
+ ...this.refSpecs,
818
+ ].join(" "),
819
+ ),
820
+ reflogIdent: this.reflogLine("").ident,
821
+ abbrev: parseCoreAbbrev(store.value("core.abbrev")) ?? -1,
822
+ ...(fsck ? { fsckObjects: fsck } : {}),
823
+ ...(filter ? { filter } : {}),
824
+ ...(this.refetch ? { refetch: true } : {}),
825
+ };
826
+ // --upload-pack, else remote.<name>.uploadpack (transport_get)
827
+ const uploadPack = this.uploadPack ?? this.remoteProgram(this.remote, "uploadpack");
828
+ const sessionOptions = {
829
+ ...this.remoteSessionOptions(),
830
+ ...(uploadPack !== undefined ? { program: uploadPack } : {}),
831
+ };
832
+ // git's fetch runs with fetch_if_missing = 0: its walks read through the history's view
833
+ // without lazy fetch (the facade above), never a store-wide switch
834
+ const result = await withRemoteUploadPack(remote, sessionOptions, (connection) =>
835
+ fetchFromConnection(connection, fetchOptions),
836
+ ).catch((error: unknown) => {
837
+ // git dies on a source that names no remote ref (a hidden one included)
838
+ const message = error instanceof Error ? error.message : "";
839
+ if (message.startsWith("couldn't find remote ref ")) {
840
+ throw new TransportError(`fatal: ${message}`, undefined, { cause: error });
841
+ }
842
+ if (error instanceof FetchCheckError) {
843
+ // fetch-pack ran: its start-up warnings came first
844
+ const lines = [...fsckWarnings, ...error.lines];
845
+ // store_updated_refs: the ref tips' check failed; nothing is written
846
+ if (error.check === "refs") {
847
+ lines.push(`error: ${anonymizeUrl(remoteUrl)} did not send all necessary objects`);
848
+ if (compatibility === "2.43") lines.push("");
849
+ }
850
+ throw new FetchCheckError(error.check, lines, error.exitCode);
851
+ }
852
+ throw error;
535
853
  });
854
+ // fetch-pack's start-up warnings (when it ran), then index-pack's fsck warnings
855
+ if (result.imports.length > 0) messages.push(...fsckWarnings);
856
+ messages.push(...(result.packCheckMessages ?? []));
536
857
 
537
858
  const advertisedRefs = new Map<string, ObjectId>();
538
859
  for (const ref of result.remoteRefs) {
539
860
  if (ref.oid) advertisedRefs.set(ref.name, ref.oid);
540
861
  }
541
862
  trackingUpdates.push(...result.refUpdates.map(toTrackingRefUpdate));
863
+ // a failed --atomic transaction: git's error after the ref lines
864
+ if (result.refTransactionError !== undefined) errors.push(result.refTransactionError);
542
865
 
543
- if (writesFetchHead && checkout?.writeFetchHead) {
544
- const entries = await this.fetchHeadEntries(result, {
545
- given: given.length,
546
- merge: mergeRefs,
547
- // explicit refspecs (and the HEAD of an unconfigured remote) are all to merge;
548
- // configured ones only when the first names one ref and no upstream is set
549
- explicit: !useConfig,
550
- firstIsExact: given.length > 0 && !parseRefSpec(given[0]).wildcard,
551
- hasMerge: upstream !== undefined,
552
- });
866
+ const marked = await this.fetchHeadEntries(result, {
867
+ given: given.length,
868
+ merge: mergeRefs,
869
+ // explicit refspecs (and the HEAD of an unconfigured remote) are all to merge;
870
+ // configured ones only when the first names one ref and no upstream is set
871
+ explicit: !useConfig,
872
+ firstIsExact: given.length > 0 && !parseRefSpec(given[0]).wildcard,
873
+ hasMerge: upstream !== undefined,
874
+ });
875
+ // store_updated_refs: a ref rejected for the shallow commits it needs is skipped, with
876
+ // git's warning when it is for merge
877
+ for (const e of marked) {
878
+ if (e.shallowRejected && !e.notForMerge) {
879
+ messages.push(
880
+ `warning: rejected ${e.localRef ?? e.remoteRef} because shallow roots are not allowed to be updated`,
881
+ );
882
+ }
883
+ }
884
+ const entries: FetchHeadEntry[] = marked
885
+ .filter((e) => !e.shallowRejected)
886
+ .map(({ oid, remoteRef, notForMerge }) => ({ oid, remoteRef, notForMerge }));
887
+ // do_fetch: a ref update refused (non-fast-forward, a tag it would clobber) jumps to the
888
+ // cleanup, past set_head (git 2.48+): the remote HEAD is not followed. FETCH_HEAD has its
889
+ // lines all the same (append_fetch_head writes each as the refs are stored), except with
890
+ // --atomic, where they wait for commit_fetch_head, which a refused or failed update skips:
891
+ // FETCH_HEAD stays as truncated. A failed --atomic transaction (the ref store refused it)
892
+ // jumps to the cleanup as well, past set_head; without --atomic the fetch goes on
893
+ const atomicFailed = this.atomic && result.refUpdates.some((u) => u.status === "rejected");
894
+ const refused = refusedUpdate(result) || atomicFailed;
895
+ if (writesFetchHead && checkout?.writeFetchHead && !atomicFailed) {
553
896
  // after the truncation above, every fetch adds its lines
554
897
  await checkout.writeFetchHead(formatFetchHead(entries, remoteUrl), { append: true });
555
898
  }
899
+ const display = await this.displayLines(remoteUrl, trackingUpdates, result, entries, {
900
+ verbose: this.verbose,
901
+ porcelain: this.porcelain,
902
+ compact: !this.porcelain && store.value("fetch.output") === "compact",
903
+ });
556
904
 
557
- if (followHead) {
905
+ if (followHead && !refused) {
558
906
  // git: "way too many cases where this can go wrong ... fail silently"
559
907
  try {
560
908
  await this.setRemoteHead(result.remoteRefs, followHead, store, messages);
@@ -563,18 +911,172 @@ export class FetchCommand extends TransportCommand<FetchResult> {
563
911
  }
564
912
  }
565
913
 
914
+ // fetch.c: after the fetch (and its submodules), a split graph of what the refs reach
915
+ // (write_commit_graph_reachable with COMMIT_GRAPH_WRITE_SPLIT), on --write-commit-graph
916
+ // or fetch.writeCommitGraph
917
+ const commitGraphHashes = await this.writeCommitGraphAfterFetch(store, messages);
918
+
566
919
  return {
567
920
  uri: remoteUrl,
568
921
  advertisedRefs,
569
922
  trackingRefUpdates: trackingUpdates,
923
+ ...(commitGraphHashes ? { commitGraph: commitGraphHashes } : {}),
570
924
  defaultBranch: result.defaultBranch,
571
925
  bytesReceived: result.packBytes,
572
926
  isEmpty: result.isEmpty,
573
927
  messages,
928
+ display,
574
929
  ...(errors.length > 0 ? { errors } : {}),
575
930
  };
576
931
  }
577
932
 
933
+ /**
934
+ * git's check_not_current_branch: the first branch of the ref map (the refs the refspecs
935
+ * took, then their opportunistic updates) that a worktree has checked out makes the fetch
936
+ * die, naming that worktree's path.
937
+ */
938
+ private async refuseCheckedOutBranch(refMap: readonly { localRef?: string }[]): Promise<void> {
939
+ const worktrees = this._workingCopy.worktrees;
940
+ if (!worktrees) return;
941
+ const branches = refMap
942
+ .map((p) => p.localRef)
943
+ .filter((ref): ref is string => ref?.startsWith("refs/heads/") ?? false);
944
+ for (const ref of new Set(branches)) {
945
+ const wt = await worktreeUsingBranch(worktrees, ref);
946
+ if (wt) throw new FetchIntoCheckedOutBranchError(ref, wt.path);
947
+ }
948
+ }
949
+
950
+ /**
951
+ * The lines git prints on stderr for the refs (fetch.c display_ref_update, full format):
952
+ * `From <url>`, the pruned refs (their summary column as wide as their own ids need), then
953
+ * the refs written or refused, in git's order: those to merge, the others the refspecs and
954
+ * tag following took, the opportunistic updates, the tags found in the fetched history;
955
+ * a ref fetched only into `FETCH_HEAD` as ` * branch <ref> -> FETCH_HEAD`. Refs already up
956
+ * to date are left out unless `verbose` (`-v`: ` = [up to date] …`). With `fetch.output`
957
+ * `compact`, a shared tail is written `*`; `porcelain` gives `--porcelain`'s lines (see
958
+ * {@link porcelainLine}).
959
+ */
960
+ private async displayLines(
961
+ url: string,
962
+ tracking: readonly TrackingRefUpdate[],
963
+ result: FetchClientResult,
964
+ entries: readonly { remoteRef: string; notForMerge: boolean }[],
965
+ format: { verbose: boolean; porcelain: boolean; compact: boolean },
966
+ ): Promise<string[]> {
967
+ const { verbose, porcelain, compact } = format;
968
+ const fetchedLocal = new Set(result.fetched.map((f) => f.localRef).filter((l) => l));
969
+ const backfilled = new Set(result.backfilledTags);
970
+ // refcol_width, once for every line: the ref map's refs written to a local ref (not the
971
+ // backfilled tags, not the pruned refs)
972
+ const refcolWidth = fetchRefcolWidth(
973
+ result.refUpdates
974
+ .filter((u) => !backfilled.has(u.localRef))
975
+ .map((u) => ({
976
+ remote: u.remoteRef,
977
+ local: u.localRef,
978
+ oldOid: u.oldOid,
979
+ newOid: u.newOid,
980
+ })),
981
+ { verbose, compact },
982
+ );
983
+ // the prune's lines come first, with their own summary width (transport_summary_width of
984
+ // the stale refs: each one's absent old value and its value here)
985
+ const lines: string[] = [];
986
+ const pruned = tracking.filter((u) => u.status === RefUpdateStatus.DELETED);
987
+ if (pruned.length > 0) {
988
+ const ids = pruned.flatMap((u) => [ZERO_OID, u.oldObjectId ?? ZERO_OID]);
989
+ const width = transportSummaryWidth(ids, await this.idAbbreviator().lengths(ids));
990
+ const prunedEntries = pruned.map((u) => ({
991
+ code: "-",
992
+ summary: "[deleted]",
993
+ remote: "(none)",
994
+ local: u.localRef,
995
+ // prune_refs passes the stale ref's value as the old id, none as the new one
996
+ oldOid: u.oldObjectId ?? ZERO_OID,
997
+ newOid: ZERO_OID,
998
+ }));
999
+ if (porcelain) lines.push(...prunedEntries.map(porcelainLine));
1000
+ else {
1001
+ lines.push(
1002
+ ...formatFetchDisplay(prunedEntries, { url, summaryWidth: width, refcolWidth, compact }),
1003
+ );
1004
+ }
1005
+ }
1006
+ const shown: FetchDisplayEntry[] = [];
1007
+ const toMerge = new Set(entries.filter((e) => !e.notForMerge).map((e) => e.remoteRef));
1008
+ const byLocal = new Map(result.refUpdates.map((u) => [u.localRef, u]));
1009
+ const taken = new Set<string>();
1010
+ const lineOf = (u: FetchRefUpdate | undefined) => {
1011
+ if (!u || taken.has(u.localRef)) return;
1012
+ taken.add(u.localRef);
1013
+ const entry = fetchUpdateDisplay(u, verbose);
1014
+ if (entry) shown.push(entry);
1015
+ };
1016
+ for (const merge of [true, false]) {
1017
+ for (const f of result.fetched) {
1018
+ if (f.shallowRejected || toMerge.has(f.remoteRef) !== merge) continue;
1019
+ if (f.localRef) {
1020
+ if (!backfilled.has(f.localRef)) lineOf(byLocal.get(f.localRef));
1021
+ } else if (
1022
+ (this.writeFetchHead || this.dryRun) &&
1023
+ // add_merge_config marks a ref the refspecs took already; only one they did not
1024
+ // take gets an entry of its own
1025
+ !result.fetched.some((o) => o.localRef && o.remoteRef === f.remoteRef)
1026
+ ) {
1027
+ shown.push({
1028
+ code: "*",
1029
+ summary: fetchHeadKind(f.remoteRef),
1030
+ remote: f.remoteRef,
1031
+ local: "FETCH_HEAD",
1032
+ oldOid: ZERO_OID,
1033
+ newOid: f.oid,
1034
+ });
1035
+ }
1036
+ }
1037
+ }
1038
+ for (const u of result.refUpdates) if (!fetchedLocal.has(u.localRef)) lineOf(u);
1039
+ for (const tag of result.backfilledTags) lineOf(byLocal.get(tag));
1040
+ // git 2.5x (do_fetch): a ref update refused (non-fast-forward, a tag it would clobber)
1041
+ // jumps to the cleanup before transport_summary_width is computed, so every line is
1042
+ // printed with a summary width of 0 (2.43 printed them as they come, padded)
1043
+ if (porcelain) return [...lines, ...shown.map(porcelainLine)];
1044
+ const summaryWidth = refusedUpdate(result) ? 0 : result.summaryWidth;
1045
+ const main = formatFetchDisplay(shown, { url, summaryWidth, refcolWidth, compact });
1046
+ // the URL line once, before whichever line comes first
1047
+ return lines.length > 0 ? [...lines, ...main.slice(1)] : main;
1048
+ }
1049
+
1050
+ /**
1051
+ * git's write of the commit-graph at the end of a fetch: when `--write-commit-graph` or
1052
+ * `fetch.writeCommitGraph` asks and the repository's files are known, a split layer of the
1053
+ * commits the refs reach (merged with the layers below as `--split` merges them; existing
1054
+ * changed-path filters are kept). Its warnings join `messages` as git prints them. The
1055
+ * layer hashes of the chain written, base first; undefined when nothing was written.
1056
+ */
1057
+ private async writeCommitGraphAfterFetch(
1058
+ store: RemoteConfigStore,
1059
+ messages: string[],
1060
+ ): Promise<string[] | undefined> {
1061
+ const write =
1062
+ this.writeCommitGraphOption ?? configBool(store.value("fetch.writeCommitGraph")) ?? false;
1063
+ const repository = this.repositoryFiles;
1064
+ const history = this._workingCopy.history;
1065
+ if (!write || !repository || !history.objects) return undefined;
1066
+ const environment = hostEnvironmentOf(this._workingCopy);
1067
+ const result = await writeCommitGraph({
1068
+ files: repository.files,
1069
+ gitDir: repository.gitDir,
1070
+ objects: history.objects,
1071
+ refs: history.refs,
1072
+ commitGraph: history.commitGraph,
1073
+ split: true,
1074
+ ...(environment ? { environment } : {}),
1075
+ });
1076
+ for (const warning of result.warnings) messages.push(`warning: ${warning}`);
1077
+ return result.written ? result.hashes : undefined;
1078
+ }
1079
+
578
1080
  /**
579
1081
  * How `refs/remotes/<name>/HEAD` follows the remote HEAD (git 2.48+): the remote's
580
1082
  * `remote.<name>.followRemoteHEAD`, else `fetch.followRemoteHEAD`, else `create`; an
@@ -622,7 +1124,10 @@ export class FetchCommand extends TransportCommand<FetchResult> {
622
1124
  const target = baremirror ? `refs/heads/${headName}` : `refs/remotes/${remote}/${headName}`;
623
1125
  if (!baremirror && !(await this.refsStore.resolve(target))?.objectId) return;
624
1126
  const previous = await this.refsStore.get(name);
625
- if (!createOnly || !previous) await this.refsStore.setSymbolic(name, target);
1127
+ // refs_update_symref_extended(..., "fetch", ...): logged with the literal "fetch"
1128
+ if (!createOnly || !previous) {
1129
+ await this.refsStore.setSymbolic(name, target, this.reflogLine("fetch"));
1130
+ }
626
1131
  if (follow.mode !== "warn" || follow.noWarnBranch === headName || !previous) return;
627
1132
  // warn_set_head
628
1133
  const prefix = `refs/remotes/${remote}/`;
@@ -695,12 +1200,16 @@ export class FetchCommand extends TransportCommand<FetchResult> {
695
1200
  firstIsExact: boolean;
696
1201
  hasMerge: boolean;
697
1202
  },
698
- ): Promise<FetchHeadEntry[]> {
1203
+ ): Promise<Array<FetchHeadEntry & { localRef?: string; shallowRejected?: boolean }>> {
699
1204
  const mergeSpec = (index: number | undefined) =>
700
1205
  index !== undefined && index >= marks.given && index < marks.given + marks.merge.length
701
1206
  ? index - marks.given
702
1207
  : undefined;
703
- const entries: (FetchHeadEntry & { refspec?: number })[] = [];
1208
+ const entries: (FetchHeadEntry & {
1209
+ refspec?: number;
1210
+ localRef?: string;
1211
+ shallowRejected?: boolean;
1212
+ })[] = [];
704
1213
  for (const fetched of result.fetched) {
705
1214
  if (mergeSpec(fetched.refspec) !== undefined) continue;
706
1215
  const fromGiven = fetched.refspec !== undefined && fetched.refspec < marks.given;
@@ -709,6 +1218,8 @@ export class FetchCommand extends TransportCommand<FetchResult> {
709
1218
  remoteRef: fetched.remoteRef,
710
1219
  notForMerge: !(marks.explicit && fromGiven),
711
1220
  refspec: fetched.refspec,
1221
+ localRef: fetched.localRef,
1222
+ ...(fetched.shallowRejected ? { shallowRejected: true } : {}),
712
1223
  });
713
1224
  }
714
1225
  if (!marks.explicit) {
@@ -732,7 +1243,13 @@ export class FetchCommand extends TransportCommand<FetchResult> {
732
1243
  for (const fetched of result.fetched) {
733
1244
  const k = mergeSpec(fetched.refspec);
734
1245
  if (k === undefined || matched.has(k)) continue;
735
- extra.push({ oid: fetched.oid, remoteRef: fetched.remoteRef, notForMerge: false });
1246
+ extra.push({
1247
+ oid: fetched.oid,
1248
+ remoteRef: fetched.remoteRef,
1249
+ notForMerge: false,
1250
+ localRef: fetched.localRef,
1251
+ ...(fetched.shallowRejected ? { shallowRejected: true } : {}),
1252
+ });
736
1253
  }
737
1254
  const tagsAt = entries.findIndex((e) => e.refspec === undefined || e.refspec >= marks.given);
738
1255
  entries.splice(tagsAt < 0 ? entries.length : tagsAt, 0, ...extra);
@@ -740,35 +1257,36 @@ export class FetchCommand extends TransportCommand<FetchResult> {
740
1257
  for (const entry of entries) {
741
1258
  if (!entry.notForMerge && !(await this.peelsToCommit(entry.oid))) entry.notForMerge = true;
742
1259
  }
743
- return entries.map(({ oid, remoteRef, notForMerge }) => ({ oid, remoteRef, notForMerge }));
1260
+ return entries.map(({ oid, remoteRef, notForMerge, localRef, shallowRejected }) => ({
1261
+ oid,
1262
+ remoteRef,
1263
+ notForMerge,
1264
+ ...(localRef !== undefined ? { localRef } : {}),
1265
+ ...(shallowRejected ? { shallowRejected } : {}),
1266
+ }));
744
1267
  }
745
1268
 
746
1269
  /** Whether `id` is a commit, or a tag (chain) of one (git's lookup_commit_reference_gently). */
747
1270
  private async peelsToCommit(id: ObjectId): Promise<boolean> {
748
- const history = this._workingCopy.history;
1271
+ // parse_object reads through replace refs
1272
+ const commits = this.commits;
1273
+ const tags = this.tagsStore;
749
1274
  let current: ObjectId | undefined = id;
750
1275
  for (let i = 0; current && i < 16; i++) {
751
- if (await history.commits.has(current)) return true;
752
- if (!(await history.tags.has(current))) return false;
753
- current = await history.tags.getTarget(current);
1276
+ if (await commits.has(current)) return true;
1277
+ if (!tags || !(await tags.has(current))) return false;
1278
+ current = await tags.getTarget(current);
754
1279
  }
755
1280
  return false;
756
1281
  }
757
1282
 
758
1283
  /**
759
- * Resolve remote name to URL.
760
- *
761
- * A named remote resolves through `remote.<name>.url` in the working copy
762
- * configuration. An unconfigured name is passed through unchanged, so a URL
763
- * given straight to {@link setRemote} still works.
1284
+ * Resolve remote name to URL, as git's `remote_get`: a remote whose configuration gives it
1285
+ * a URL uses that (`remote.<name>.url`); anything else is a URL or path itself. Either is
1286
+ * rewritten by `url.<base>.insteadOf`.
764
1287
  */
765
1288
  private async resolveRemoteUrl(remote: string): Promise<string | undefined> {
766
- // If it looks like a URL, use it directly
767
- if (remote.includes("://") || remote.includes("@")) {
768
- return remote;
769
- }
770
-
771
- return RemoteConfigStore.from(this.workingCopy).urlFor(remote) ?? remote;
1289
+ return RemoteConfigStore.from(this.workingCopy).remoteUrlOf(remote);
772
1290
  }
773
1291
 
774
1292
  /**
@@ -776,7 +1294,8 @@ export class FetchCommand extends TransportCommand<FetchResult> {
776
1294
  * refspecs map from remote refs (all of the matching refspecs: overlapping ones count
777
1295
  * together), none of which the remote has, unless a negative refspec excludes it or it is
778
1296
  * a symbolic ref. They are deleted (reflogs too) in one batch, logged `fetch: prune`, and
779
- * reported as deleted; a dry run reports them only. The symbolic refs left dangling are
1297
+ * reported as deleted; a dry run reports them only, `defer` leaves the deletion to the
1298
+ * --atomic transaction. The symbolic refs left dangling are
780
1299
  * named in `messages` as git does. A refused delete does not stop the fetch: as in git
781
1300
  * (which then exits 1), the error goes into `errors` and nothing is reported deleted.
782
1301
  */
@@ -785,6 +1304,8 @@ export class FetchCommand extends TransportCommand<FetchResult> {
785
1304
  specs: RefSpec[],
786
1305
  messages: string[],
787
1306
  errors: string[],
1307
+ /** Leave the deletion to the caller (the --atomic transaction) */
1308
+ defer = false,
788
1309
  ): Promise<TrackingRefUpdate[]> {
789
1310
  const negative = specs.filter((s) => s.negative && s.source);
790
1311
  const mapping = specs.filter((s) => !s.negative && s.source && s.destination);
@@ -808,12 +1329,13 @@ export class FetchCommand extends TransportCommand<FetchResult> {
808
1329
  if (stale.length === 0) return [];
809
1330
  // refs_warn_dangling_symrefs: listed before the deletion, as the targets go
810
1331
  const dangling = await this.danglingSymrefs(new Set(stale.map((r) => r.name)));
811
- if (!this.dryRun) {
1332
+ if (!this.dryRun && !defer) {
812
1333
  try {
813
1334
  await deleteRefs(
814
1335
  this.refsStore,
815
1336
  stale.map((r) => r.name),
816
1337
  "fetch: prune",
1338
+ { legacy: this.hooks.compatibility === "2.43" },
817
1339
  );
818
1340
  } catch (error) {
819
1341
  errors.push(error instanceof Error ? error.message : String(error));
@@ -854,6 +1376,13 @@ export class FetchCommand extends TransportCommand<FetchResult> {
854
1376
  }
855
1377
  }
856
1378
 
1379
+ /** fetch.c's kind of a ref fetched into `FETCH_HEAD` only: `branch`, `tag`, … (`branch` else). */
1380
+ function fetchHeadKind(name: string): string {
1381
+ if (name.startsWith("refs/tags/")) return "tag";
1382
+ if (name.startsWith("refs/remotes/")) return "remote-tracking branch";
1383
+ return "branch";
1384
+ }
1385
+
857
1386
  /** The transport's tag mode for a {@link TagOption}. */
858
1387
  export function toTagMode(option: TagOption): TagMode {
859
1388
  switch (option) {
@@ -919,13 +1448,7 @@ function parseFollowRemoteHead(
919
1448
  }
920
1449
 
921
1450
  /** A git boolean config value; undefined when unset or not a boolean. */
922
- function configBool(value: string | undefined): boolean | undefined {
923
- if (value === undefined) return undefined;
924
- const v = value.trim().toLowerCase();
925
- if (v === "true" || v === "yes" || v === "on" || v === "1") return true;
926
- if (v === "false" || v === "no" || v === "off" || v === "0" || v === "") return false;
927
- return undefined;
928
- }
1451
+ const configBool = (value: string | undefined): boolean | undefined => parseGitBool(value);
929
1452
 
930
1453
  /** git's refname_match: `ref` (`main`, `heads/main`, `refs/heads/main`) names `fullName`. */
931
1454
  function refNameMatches(ref: string, fullName: string): boolean {
@@ -938,3 +1461,20 @@ function refNameMatches(ref: string, fullName: string): boolean {
938
1461
  `refs/remotes/${ref}/HEAD`,
939
1462
  ].includes(fullName);
940
1463
  }
1464
+
1465
+ /**
1466
+ * Whether a ref update was refused as git's update_local_ref refuses one (a non-fast-forward,
1467
+ * a tag it would clobber), not by the ref store: git 2.5x's do_fetch then goes to its
1468
+ * cleanup.
1469
+ */
1470
+ function refusedUpdate(result: FetchClientResult): boolean {
1471
+ return result.refUpdates.some((u) => u.status === "rejected" && u.storeError === undefined);
1472
+ }
1473
+
1474
+ /**
1475
+ * A ref line of `git fetch --porcelain` (display_ref_update's porcelain format): the flag,
1476
+ * the old and new ids in full (zeros for none), the local ref's full name.
1477
+ */
1478
+ function porcelainLine(entry: FetchDisplayEntry): string {
1479
+ return `${entry.code} ${entry.oldOid ?? ZERO_OID} ${entry.newOid ?? ZERO_OID} ${entry.local}`;
1480
+ }