@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
@@ -0,0 +1,793 @@
1
+ /**
2
+ * The sparse checkout's half of unpack-trees, shared by every command that writes the index
3
+ * and the worktree together (`checkout`, `switch`, `reset --hard/--merge/--keep`, the merge
4
+ * family through `switchTrees`, `clone --sparse`) and by `git sparse-checkout` itself.
5
+ *
6
+ * git marks the entries outside the sparse-checkout patterns before it merges
7
+ * (`mark_new_skip_worktree`, loop #1), so the merge functions neither check nor touch the
8
+ * files of entries that stay outside (`verify_uptodate` and `verify_absent` skip
9
+ * `CE_NEW_SKIP_WORKTREE`); new entries are marked once the merge is done (loop #2), then
10
+ * `apply_sparse_checkout` decides, entry by entry and before anything is written, which files
11
+ * leave the checkout (`verify_uptodate_sparse`) and which come back (`verify_absent_sparse`),
12
+ * and `check_updates` removes and writes. A command takes a {@link SparseUnpack} before it
13
+ * changes anything, asks it which paths it may check, write and remove
14
+ * ({@link SparseUnpack.leavesAlone}, {@link SparseUnpack.writes}), unlinks the files
15
+ * {@link SparseUnpack.leaving} returns with its own removals, and once its result is
16
+ * written lets {@link SparseUnpack.finish} set the flags and write the entries that came
17
+ * back. Nothing is written first and taken out again.
18
+ */
19
+
20
+ import type { Blobs } from "@statewalker/vcs-core";
21
+ import { FileMode, type ObjectId } from "@statewalker/vcs-core";
22
+ import { parseGitBool } from "@statewalker/vcs-utils";
23
+ import {
24
+ attributesIndexOf,
25
+ basicStatMatches,
26
+ entryStatOf,
27
+ getWorktreeEntries,
28
+ parseSparseCheckoutPatterns,
29
+ type SparseCheckoutPatterns,
30
+ type Staging,
31
+ type StagingEntry,
32
+ type WorkingCopy,
33
+ type Worktree,
34
+ type WorktreeEntry,
35
+ type WorktreeModeTrust,
36
+ } from "@statewalker/vcs-working-tree";
37
+
38
+ import { RemoteConfigStore } from "../remote-config/index.js";
39
+ import { worktreeModeTrust } from "./core-config.js";
40
+ import { planFlatRestore, writeTreeRestorePlan } from "./tree-restore.js";
41
+ import {
42
+ flaggedEntryDiffers,
43
+ pruneEmptyParents,
44
+ removeDirectoryIfEmpty,
45
+ untrackedUnder,
46
+ } from "./worktree-overwrite-checks.js";
47
+
48
+ /** The sparse checkout's settings, as git reads them into its globals. */
49
+ export interface SparseCheckoutConfig {
50
+ /** `core.sparseCheckout` (git's `core_apply_sparse_checkout`) */
51
+ enabled: boolean;
52
+ /** `core.sparseCheckoutCone` */
53
+ cone: boolean;
54
+ /** `core.ignoreCase` */
55
+ ignoreCase: boolean;
56
+ /** `sparse.expectFilesOutsideOfPatterns` */
57
+ expectFilesOutside: boolean;
58
+ }
59
+
60
+ /** The sparse checkout's configuration of a working copy. */
61
+ export function sparseCheckoutConfig(workingCopy: WorkingCopy): SparseCheckoutConfig {
62
+ if (!workingCopy.config) {
63
+ return { enabled: false, cone: false, ignoreCase: false, expectFilesOutside: false };
64
+ }
65
+ const config = RemoteConfigStore.from(workingCopy);
66
+ const bool = (key: string) => {
67
+ try {
68
+ return parseGitBool(config.value(key)) === true;
69
+ } catch {
70
+ return false;
71
+ }
72
+ };
73
+ return {
74
+ enabled: bool("core.sparseCheckout"),
75
+ cone: bool("core.sparseCheckoutCone"),
76
+ ignoreCase: bool("core.ignoreCase"),
77
+ expectFilesOutside: bool("sparse.expectFilesOutsideOfPatterns"),
78
+ };
79
+ }
80
+
81
+ /** The sparse-checkout file's text (`$GIT_DIR/info/sparse-checkout`), undefined when there is none. */
82
+ export async function readSparseCheckoutFile(
83
+ workingCopy: WorkingCopy,
84
+ ): Promise<string | undefined> {
85
+ const bytes = await workingCopy.checkout
86
+ ?.readStateFile?.("info/sparse-checkout")
87
+ .catch(() => undefined);
88
+ return bytes === undefined ? undefined : new TextDecoder().decode(bytes);
89
+ }
90
+
91
+ /**
92
+ * The sparse checkout's patterns (`$GIT_DIR/info/sparse-checkout`, cone matching with
93
+ * `core.sparseCheckoutCone`, case folded with `core.ignoreCase`) for git's
94
+ * `path_in_sparse_checkout`, or undefined when `core.sparseCheckout` is off (every path
95
+ * is in the checkout).
96
+ */
97
+ export async function readSparseCheckoutPatterns(
98
+ workingCopy: WorkingCopy,
99
+ ): Promise<SparseCheckoutPatterns | undefined> {
100
+ const config = sparseCheckoutConfig(workingCopy);
101
+ if (!config.enabled) return undefined;
102
+ const content = await readSparseCheckoutFile(workingCopy);
103
+ return parseSparseCheckoutPatterns(content, config.cone, config.ignoreCase);
104
+ }
105
+
106
+ /** What unpack-trees reports while it applies the patterns (its sparse warnings). */
107
+ type SparseReportKind = "notUptodate" | "unmerged" | "orphaned";
108
+
109
+ /** The paths unpack-trees reports while it applies the patterns, and what it changed. */
110
+ export interface SparseApplyOutcome {
111
+ /** Files out of the patterns kept for their changes (WARNING_SPARSE_NOT_UPTODATE_FILE) */
112
+ notUptodate: string[];
113
+ /** Unmerged paths left in the worktree (WARNING_SPARSE_UNMERGED_FILE) */
114
+ unmerged: string[];
115
+ /** Files back in the patterns not written over what stands there (WARNING_SPARSE_ORPHANED_NOT_OVERWRITTEN) */
116
+ orphaned: string[];
117
+ /** Every report in index order, as git prints them one by one without porcelain messages */
118
+ reports: { kind: SparseReportKind; path: string }[];
119
+ /** The files removed from the worktree, now skip-worktree */
120
+ removed: string[];
121
+ /** The files written into the worktree, no longer skip-worktree */
122
+ written: string[];
123
+ /** Whether the index was changed (and written) */
124
+ changed: boolean;
125
+ /**
126
+ * check_updates' `unlink_or_warn` lines for files leaving the checkout that could not be
127
+ * removed ("warning: unable to unlink 'p': Is a directory"), printed after the sparse
128
+ * warnings by unpack-trees, before them by `update_sparsity`
129
+ */
130
+ unlinkWarnings: string[];
131
+ }
132
+
133
+ /** The staging's entries in index order. */
134
+ export async function entryList(staging: Staging): Promise<readonly StagingEntry[]> {
135
+ const list = staging.entryList?.();
136
+ if (list) return list;
137
+ const out: StagingEntry[] = [];
138
+ for await (const entry of staging.entries()) out.push(entry);
139
+ return out;
140
+ }
141
+
142
+ /** What {@link SparseUnpack.finish} needs of a command. */
143
+ export interface SparseApplyContext {
144
+ workingCopy: WorkingCopy;
145
+ worktree?: Worktree;
146
+ staging: Staging;
147
+ blobs: Blobs;
148
+ }
149
+
150
+ /** The stage-0 entry a command's result holds at a path, undefined when it removes the path. */
151
+ export type SparseResultLookup = (path: string) => { objectId: ObjectId; mode: number } | undefined;
152
+
153
+ /** Byte order of paths, as the index sorts them (UTF-16 order below the surrogates). */
154
+ const pathOrder = (a: string, b: string) => (a < b ? -1 : a > b ? 1 : 0);
155
+
156
+ /**
157
+ * Whether a leading directory of `path` is a symbolic link: git's `lstat` follows it to
158
+ * whatever it points to, which this worktree never looks into. `seen` caches the answer of
159
+ * each directory.
160
+ */
161
+ async function beneathLink(
162
+ worktree: Worktree,
163
+ path: string,
164
+ seen: Map<string, "dir" | "link" | "none">,
165
+ ): Promise<boolean> {
166
+ for (let k = path.indexOf("/"); k > 0; k = path.indexOf("/", k + 1)) {
167
+ const dir = path.slice(0, k);
168
+ let kind = seen.get(dir);
169
+ if (kind === undefined) {
170
+ const entry = await worktree.getEntry(dir).catch(() => undefined);
171
+ kind = !entry
172
+ ? "none"
173
+ : entry.mode === FileMode.SYMLINK
174
+ ? "link"
175
+ : entry.isDirectory
176
+ ? "dir"
177
+ : "none";
178
+ seen.set(dir, kind);
179
+ }
180
+ if (kind === "link") return true;
181
+ if (kind === "none") return false;
182
+ }
183
+ return false;
184
+ }
185
+
186
+ /**
187
+ * Whether a leading component of `path` is a file or link that `verify_absent_1` would
188
+ * refuse to replace (`check_leading_path`, then `check_ok_to_remove`: an ignored one is
189
+ * expendable).
190
+ */
191
+ async function blockedLeadingPath(
192
+ worktree: Worktree,
193
+ path: string,
194
+ preserveIgnored = false,
195
+ ): Promise<boolean> {
196
+ for (let k = path.indexOf("/"); k > 0; k = path.indexOf("/", k + 1)) {
197
+ const prefix = path.slice(0, k);
198
+ const entry = await worktree.getEntry(prefix).catch(() => undefined);
199
+ if (!entry) return false;
200
+ if (entry.isDirectory && entry.mode !== FileMode.SYMLINK) continue;
201
+ return preserveIgnored || !(await worktree.isIgnored(prefix));
202
+ }
203
+ return false;
204
+ }
205
+
206
+ /**
207
+ * git's sparse checkout over one unpack-trees run (`unpack_trees` with `update`, or
208
+ * `update_sparsity`), taken by a command before it changes anything: the patterns, and the
209
+ * index as the command found it (git's `o->src_index`, with its time for the racy check).
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * const sparse = await SparseUnpack.start(ctx);
214
+ * // the merge's checks and writes skip what stays outside the checkout
215
+ * if (!sparse?.leavesAlone(path)) verifyUptodate(path);
216
+ * // before writing: the files that leave the checkout (verify_uptodate_sparse)
217
+ * const unlink = await sparse.leaving(worktree, (p) => result.get(p));
218
+ * await sparse.unlink(worktree, unlink);
219
+ * // ...the command's own removals and writes, only of paths sparse.writes() accepts...
220
+ * const outcome = await sparse.finish(ctx, { written });
221
+ * ```
222
+ */
223
+ export class SparseUnpack {
224
+ /** The source index's stage-0 entries */
225
+ private readonly src = new Map<string, StagingEntry>();
226
+ /** Paths unmerged in the source index (mark_new_skip_worktree: never skip-worktree) */
227
+ private readonly unmergedSrc = new Set<string>();
228
+ /** The source entries in the checkout that its patterns put outside (copied, in index order) */
229
+ private readonly candidates: StagingEntry[] = [];
230
+ /** Paths whose conflicts the command records */
231
+ private readonly conflicts = new Set<string>();
232
+ private readonly inPatterns = new Map<string, boolean>();
233
+ /** Files going out that were kept for their changes: they lose no flag */
234
+ private readonly kept = new Set<string>();
235
+ /** Kept files changed behind a matching stat (racy): their entries are smudged */
236
+ private readonly smudge = new Set<string>();
237
+ private readonly reports: { kind: SparseReportKind; path: string }[] = [];
238
+ private readonly removed: string[] = [];
239
+ private readonly unlinkWarnings: string[] = [];
240
+
241
+ private constructor(
242
+ readonly patterns: SparseCheckoutPatterns,
243
+ entries: readonly StagingEntry[],
244
+ /** The source index's time (`o->src_index->timestamp`), for `ie_match_stat`'s racy check */
245
+ readonly srcTime: number,
246
+ ) {
247
+ for (const entry of entries) {
248
+ if (entry.stage !== 0) {
249
+ this.unmergedSrc.add(entry.path);
250
+ continue;
251
+ }
252
+ this.src.set(entry.path, entry);
253
+ }
254
+ for (const entry of this.src.values()) {
255
+ if (!entry.skipWorktree && this.outside(entry.path)) this.candidates.push({ ...entry });
256
+ }
257
+ }
258
+
259
+ /**
260
+ * The run of an index-writing command in a sparse checkout (`core.sparseCheckout` on, a
261
+ * worktree to update), undefined otherwise: unpack-trees then has nothing to apply.
262
+ */
263
+ static async start(ctx: {
264
+ workingCopy: WorkingCopy;
265
+ worktree?: Worktree;
266
+ staging: Staging;
267
+ }): Promise<SparseUnpack | undefined> {
268
+ if (!ctx.worktree) return undefined;
269
+ const patterns = await readSparseCheckoutPatterns(ctx.workingCopy);
270
+ if (!patterns) return undefined;
271
+ return SparseUnpack.of(patterns, ctx.staging);
272
+ }
273
+
274
+ /** A run over the index as it is now, with `patterns`. */
275
+ static async of(patterns: SparseCheckoutPatterns, staging: Staging): Promise<SparseUnpack> {
276
+ return new SparseUnpack(patterns, await entryList(staging), staging.getUpdateTime());
277
+ }
278
+
279
+ /**
280
+ * Paths whose conflicts the command records (merge-ort's `record_conflicted_index_entries`,
281
+ * whose stage entries are never skip-worktree). One whose source entry was skip-worktree,
282
+ * or that had none, has its file written whatever the patterns say (the stage-0 entry
283
+ * unpack-trees left skip-worktree is checked out). One whose source entry was in the
284
+ * checkout but is outside the patterns now leaves it as any other entry does:
285
+ * `apply_sparse_checkout` set `CE_WT_REMOVE`, which `checkout_entry` honours by unlinking,
286
+ * so its content is only in the index stages (a changed file is kept, as ever).
287
+ */
288
+ conflict(paths: Iterable<string>): void {
289
+ for (const path of paths) this.conflicts.add(path);
290
+ }
291
+
292
+ /**
293
+ * `CE_NEW_SKIP_WORKTREE` of a stage-0 entry the result holds at `path`: outside the
294
+ * patterns, and neither unmerged in the source index (loop #1 of
295
+ * `mark_new_skip_worktree`) nor conflicted by the command where its file is written
296
+ * (see {@link conflict}).
297
+ */
298
+ outside(path: string): boolean {
299
+ if (this.unmergedSrc.has(path)) return false;
300
+ if (this.conflicts.has(path)) {
301
+ const old = this.src.get(path);
302
+ if (!old || old.skipWorktree) return false;
303
+ }
304
+ let included = this.inPatterns.get(path);
305
+ if (included === undefined) {
306
+ included = this.patterns.includes(path);
307
+ this.inPatterns.set(path, included);
308
+ }
309
+ return !included;
310
+ }
311
+
312
+ /**
313
+ * Whether the command leaves the worktree at `path` alone, its checks included: the path
314
+ * stays outside the patterns and its source entry is skip-worktree, or it has none (a new
315
+ * entry, which loop #2 marks skip-worktree). git's `verify_uptodate` and `verify_absent`
316
+ * skip such an entry, and `apply_sparse_checkout` drops its update and its removal
317
+ * (`was_skip_worktree && ce_skip_worktree`). Its index entry is changed all the same. Ask
318
+ * only for a path the command's source index or target holds.
319
+ */
320
+ leavesAlone(path: string): boolean {
321
+ if (!this.outside(path)) return false;
322
+ const old = this.src.get(path);
323
+ return old ? old.skipWorktree === true : true;
324
+ }
325
+
326
+ /** Whether the command writes the file of the entry its result holds at `path`. */
327
+ writes(path: string): boolean {
328
+ return !this.outside(path);
329
+ }
330
+
331
+ /**
332
+ * `apply_sparse_checkout` for the source entries the patterns take out of the checkout
333
+ * (`!was_skip_worktree && ce_skip_worktree`), decided before anything is written: an
334
+ * entry the result removes is the command's own removal; one it changes, or any with
335
+ * `reset` (`o->reset`: the one-way merge flagged its changed file `CE_UPDATE`), is
336
+ * unlinked (the command checked it as git's merge functions do); an unchanged one is
337
+ * unlinked unless `verify_uptodate_sparse` finds its file changed (by its stat against
338
+ * the source index, racy entries read), in which case it stays, keeps no flag, and is
339
+ * reported. A file reached through a symlinked leading directory is reported, never
340
+ * unlinked: git's `lstat` finds what the link points to. Returns the files to unlink, for
341
+ * {@link unlink} with the command's own removals.
342
+ */
343
+ async leaving(
344
+ worktree: Worktree | undefined,
345
+ result: SparseResultLookup,
346
+ options: { reset?: boolean; trust?: WorktreeModeTrust } = {},
347
+ ): Promise<string[]> {
348
+ if (!worktree) return [];
349
+ const unlink: string[] = [];
350
+ const checking: StagingEntry[] = [];
351
+ for (const old of this.candidates) {
352
+ if (!this.outside(old.path)) continue;
353
+ const now = result(old.path);
354
+ if (!now) continue;
355
+ if (options.reset || now.objectId !== old.objectId || now.mode !== old.mode) {
356
+ unlink.push(old.path);
357
+ } else checking.push(old);
358
+ }
359
+ if (checking.length === 0) return unlink;
360
+ const found = await getWorktreeEntries(
361
+ worktree,
362
+ checking.map((e) => e.path),
363
+ );
364
+ const links = new Map<string, "dir" | "link" | "none">();
365
+ for (let i = 0; i < checking.length; i++) {
366
+ const old = checking[i] as StagingEntry;
367
+ const current: WorktreeEntry | null = found[i] ?? null;
368
+ const changed =
369
+ current === null
370
+ ? await beneathLink(worktree, old.path, links)
371
+ : // verify_uptodate_1 of an entry already skip-worktree: ie_match_stat, no refresh
372
+ await flaggedEntryDiffers(
373
+ worktree,
374
+ old.path,
375
+ { ...old, skipWorktree: true },
376
+ options.trust,
377
+ this.srcTime,
378
+ current,
379
+ );
380
+ if (changed) {
381
+ this.kept.add(old.path);
382
+ this.reports.push({ kind: "notUptodate", path: old.path });
383
+ // a change only the content showed: the index written records size 0, as git's
384
+ // ce_smudge_racily_clean_entry does for an entry racy against the source index
385
+ if (current && basicStatMatches(old, current, options.trust)) this.smudge.add(old.path);
386
+ } else unlink.push(old.path);
387
+ }
388
+ return unlink;
389
+ }
390
+
391
+ /**
392
+ * `check_updates`' `unlink_entry` of the files {@link leaving} gave: a submodule's
393
+ * directory only when empty, the directories left empty after (`schedule_dir_for_removal`).
394
+ * Nothing beneath a symbolic link is touched.
395
+ */
396
+ async unlink(worktree: Worktree, paths: readonly string[]): Promise<void> {
397
+ for (const path of paths) {
398
+ if (this.src.get(path)?.mode === FileMode.GITLINK) {
399
+ await removeDirectoryIfEmpty(worktree, path);
400
+ } else {
401
+ const current = await worktree.getEntry(path).catch(() => undefined);
402
+ if (current?.isDirectory && current.mode !== FileMode.SYMLINK) {
403
+ // unlink_or_warn on a directory: EISDIR, the directory and the flag kept as they are
404
+ this.unlinkWarnings.push(`warning: unable to unlink '${path}': Is a directory\n`);
405
+ continue;
406
+ }
407
+ if (current) await worktree.remove(path);
408
+ }
409
+ await pruneEmptyParents(worktree, path);
410
+ this.removed.push(path);
411
+ }
412
+ }
413
+
414
+ /**
415
+ * The rest of `apply_sparse_checkout` once the command wrote its result: every stage-0
416
+ * entry outside the patterns becomes skip-worktree (but those {@link leaving} kept), every
417
+ * other loses the flag; a skip-worktree entry back in the patterns that the command did
418
+ * not write (`written`) is written unless something stands at its path
419
+ * (`verify_absent_sparse`: an untracked file, or a directory holding one, is kept and
420
+ * reported; an ignored one is replaced; with `overwrite`, `UNPACK_RESET_OVERWRITE_UNTRACKED`,
421
+ * anything is). A directory holding such a file keeps the entry unwritten without a report
422
+ * (verify_clean_subdirectory's ERROR_NOT_UPTODATE_DIR, which unpack-trees never prints with
423
+ * the sparse warnings). With `warnUnmerged` (`update_sparsity`) unmerged paths are reported.
424
+ * With `preserveIgnored` (`update_sparsity`, which runs without `o->internal.dir`) ignored
425
+ * files are no more expendable than untracked ones. The index is written when an entry
426
+ * changed.
427
+ */
428
+ async finish(
429
+ ctx: SparseApplyContext,
430
+ options: {
431
+ written?: ReadonlySet<string>;
432
+ overwrite?: boolean;
433
+ warnUnmerged?: boolean;
434
+ preserveIgnored?: boolean;
435
+ } = {},
436
+ ): Promise<SparseApplyOutcome> {
437
+ const { staging, worktree } = ctx;
438
+ const entries = await entryList(staging);
439
+ const flags = new Map<string, boolean>();
440
+ const back: StagingEntry[] = [];
441
+ let lastUnmerged: string | undefined;
442
+ for (const entry of entries) {
443
+ const path = entry.path;
444
+ if (entry.stage !== 0) {
445
+ // update_sparsity: warn_conflicted_path, once per path
446
+ if (options.warnUnmerged && lastUnmerged !== path) {
447
+ this.reports.push({ kind: "unmerged", path });
448
+ }
449
+ lastUnmerged = path;
450
+ continue;
451
+ }
452
+ const outside = this.outside(path);
453
+ if (!outside && entry.skipWorktree && worktree && !options.written?.has(path)) {
454
+ back.push(entry);
455
+ }
456
+ const flag = outside && !this.kept.has(path);
457
+ if (flag !== (entry.skipWorktree === true)) flags.set(path, flag);
458
+ }
459
+
460
+ const writing: StagingEntry[] = [];
461
+ if (worktree && back.length > 0) {
462
+ const found = options.overwrite
463
+ ? []
464
+ : await getWorktreeEntries(
465
+ worktree,
466
+ back.map((e) => e.path),
467
+ );
468
+ let tracked: Set<string> | undefined;
469
+ for (let i = 0; i < back.length; i++) {
470
+ const entry = back[i] as StagingEntry;
471
+ const current = found[i];
472
+ let present: boolean;
473
+ if (options.overwrite) present = false;
474
+ else if (!current) {
475
+ present = await blockedLeadingPath(worktree, entry.path, options.preserveIgnored);
476
+ } else if (current.isDirectory && current.mode !== FileMode.SYMLINK) {
477
+ // verify_clean_subdirectory: what is untracked there would be lost
478
+ tracked ??= new Set(entries.map((e) => e.path));
479
+ const known = tracked;
480
+ // ERROR_NOT_UPTODATE_DIR: the entry stays unwritten, and nothing is printed
481
+ if (
482
+ entry.mode !== FileMode.GITLINK &&
483
+ (await untrackedUnder(
484
+ worktree,
485
+ entry.path,
486
+ (p) => known.has(p),
487
+ options.preserveIgnored === true,
488
+ ))
489
+ ) {
490
+ continue;
491
+ }
492
+ present = false;
493
+ } else {
494
+ // the rules read now (never the entry's lazy `isIgnored`, which answers before the
495
+ // ignore files are read)
496
+ present = options.preserveIgnored === true || !(await worktree.isIgnored(entry.path));
497
+ }
498
+ if (present) this.reports.push({ kind: "orphaned", path: entry.path });
499
+ else writing.push(entry);
500
+ }
501
+ }
502
+ const written: string[] = [];
503
+ if (worktree && writing.length > 0) {
504
+ const target = new Map<string, { objectId: ObjectId; mode: number }>();
505
+ for (const entry of writing) target.set(entry.path, entry);
506
+ const plan = await planFlatRestore(
507
+ ctx.blobs,
508
+ target,
509
+ new Set(target.keys()),
510
+ "sparse-checkout",
511
+ {
512
+ symlinks: true,
513
+ windows: worktree.capabilities?.windowsPaths === true,
514
+ reservedNames: worktree.capabilities?.reservedNames,
515
+ },
516
+ );
517
+ // the files smudged with the attributes of the index they are written from
518
+ const index = new Map<string, ObjectId>();
519
+ for (const entry of entries) {
520
+ if (entry.stage === 0 && entry.path.endsWith(".gitattributes")) {
521
+ index.set(entry.path, entry.objectId);
522
+ }
523
+ }
524
+ const trust = worktreeModeTrust(ctx.workingCopy, worktree);
525
+ await writeTreeRestorePlan(worktree, ctx.blobs, plan, "sparse-checkout", {
526
+ symlinks: trust.symlinks,
527
+ gitlinks: true,
528
+ replaceInTheWay: true,
529
+ ...(options.overwrite ? { discardUntracked: true } : {}),
530
+ attributes: { direction: "checkout", index: attributesIndexOf(index) },
531
+ });
532
+ written.push(...writing.map((e) => e.path));
533
+ }
534
+
535
+ const outcome = this.outcome(written, false);
536
+ if (flags.size === 0 && written.length === 0 && this.smudge.size === 0) return outcome;
537
+ const writtenSet = new Set(written);
538
+ const stats = worktree && written.length > 0 ? await getWorktreeEntries(worktree, written) : [];
539
+ const statOf = new Map<string, WorktreeEntry | undefined>();
540
+ for (let i = 0; i < written.length; i++) statOf.set(written[i] as string, stats[i]);
541
+ const editor = staging.createEditor();
542
+ for (const path of new Set([...flags.keys(), ...writtenSet, ...this.smudge])) {
543
+ const flag = flags.get(path);
544
+ const stat = statOf.get(path);
545
+ const smudge = this.smudge.has(path);
546
+ editor.add({
547
+ path,
548
+ apply: (existing) => {
549
+ if (!existing) return existing;
550
+ // the stat of the file written (check_updates refreshes the entry)
551
+ return {
552
+ ...existing,
553
+ ...(flag !== undefined ? { skipWorktree: flag } : {}),
554
+ ...(stat && !stat.isDirectory ? entryStatOf(stat) : {}),
555
+ ...(smudge ? { size: 0 } : {}),
556
+ };
557
+ },
558
+ });
559
+ }
560
+ await editor.finish();
561
+ await staging.write();
562
+ outcome.changed = true;
563
+ return outcome;
564
+ }
565
+
566
+ private outcome(written: string[], changed: boolean): SparseApplyOutcome {
567
+ const of = (kind: SparseReportKind) =>
568
+ this.reports.filter((r) => r.kind === kind).map((r) => r.path);
569
+ return {
570
+ notUptodate: of("notUptodate"),
571
+ unmerged: of("unmerged"),
572
+ orphaned: of("orphaned"),
573
+ reports: [...this.reports].sort((a, b) => pathOrder(a.path, b.path)),
574
+ removed: [...this.removed],
575
+ written,
576
+ changed,
577
+ unlinkWarnings: [...this.unlinkWarnings],
578
+ };
579
+ }
580
+ }
581
+
582
+ /**
583
+ * git's `update_sparsity` (`git sparse-checkout set/add/reapply/init/disable`): the index as
584
+ * it is, every stage-0 entry outside `patterns` made skip-worktree and its file removed
585
+ * unless changed (kept, reported), every skip-worktree entry back inside written unless
586
+ * something stands there (reported), unmerged paths reported. The index is written when a
587
+ * flag changed.
588
+ */
589
+ export async function updateSparsity(
590
+ ctx: SparseApplyContext,
591
+ patterns: SparseCheckoutPatterns,
592
+ ): Promise<SparseApplyOutcome> {
593
+ const unpack = await SparseUnpack.of(patterns, ctx.staging);
594
+ const worktree = ctx.worktree;
595
+ if (worktree) {
596
+ const source = new Map<string, StagingEntry>();
597
+ for (const entry of await entryList(ctx.staging)) {
598
+ if (entry.stage === 0) source.set(entry.path, entry);
599
+ }
600
+ const unlink = await unpack.leaving(worktree, (path) => source.get(path), {
601
+ trust: worktreeModeTrust(ctx.workingCopy, worktree),
602
+ });
603
+ await unpack.unlink(worktree, unlink);
604
+ }
605
+ return unpack.finish(ctx, { warnUnmerged: true, preserveIgnored: true });
606
+ }
607
+
608
+ /**
609
+ * git's `clean_tracked_sparse_directories` after `update_sparsity` (cone mode only, an index
610
+ * without unmerged entries): each top-most directory outside the cone whose entries are all
611
+ * skip-worktree, none a submodule and none below a directory holding an intent-to-add entry
612
+ * (what `convert_to_sparse` collapses, `sparseDirectoriesOf`) is removed with what is left
613
+ * in it when that is only ignored files, else warned about. A directory reached through a
614
+ * symbolic link is never entered. Returns git's warning lines.
615
+ */
616
+ export async function cleanTrackedSparseDirectories(
617
+ ctx: { worktree?: Worktree; staging: Staging },
618
+ patterns: SparseCheckoutPatterns,
619
+ ): Promise<string> {
620
+ const worktree = ctx.worktree;
621
+ if (!worktree || !patterns.cone) return "";
622
+ const entries = await entryList(ctx.staging);
623
+ const sparseDirs = sparseDirectoriesOf(entries, patterns);
624
+ if (!sparseDirs) return "";
625
+ let text = "";
626
+ for (const dir of sparseDirs) {
627
+ const path = dir.slice(0, -1);
628
+ const current = await worktree.getEntry(path).catch(() => undefined);
629
+ if (!current?.isDirectory || current.mode === FileMode.SYMLINK) continue;
630
+ const tracked = new Set(entries.map((e) => e.path));
631
+ if (await untrackedUnder(worktree, path, (p) => tracked.has(p))) {
632
+ text += `warning: directory '${dir}' contains untracked files, but is not in the sparse-checkout cone\n`;
633
+ continue;
634
+ }
635
+ const removed = await worktree.remove(path, { recursive: true }).catch(() => false);
636
+ if (!removed) text += `warning: failed to remove directory '${dir}'\n`;
637
+ }
638
+ return text;
639
+ }
640
+
641
+ /**
642
+ * The sparse directories git's `convert_to_sparse` (`SPARSE_INDEX_MEMORY_ONLY` too) makes of
643
+ * a full index under cone-mode `patterns`: top-down, each directory outside the cone whose
644
+ * entries are all skip-worktree, merged and no gitlink, with a trailing slash, in index
645
+ * order. git converts over a cache-tree computed for the index itself (`cache_tree_update`
646
+ * unless fully valid), so the only invalid nodes are the directories holding an
647
+ * intent-to-add entry anywhere below them (`update_one` invalidates up to the root), and
648
+ * `convert_to_sparse_rec` copies an invalid node entry by entry without recursing: no
649
+ * directory at or below such a directory collapses (the root's own validity is never
650
+ * checked). Undefined where git does not convert: no entries, an unmerged entry, patterns
651
+ * not of the cone's shape.
652
+ *
653
+ * @example
654
+ * ```typescript
655
+ * sparseDirectoriesOf(entries, patterns); // ["c/", "e/"]
656
+ * ```
657
+ */
658
+ export function sparseDirectoriesOf(
659
+ entries: readonly StagingEntry[],
660
+ patterns: SparseCheckoutPatterns,
661
+ ): string[] | undefined {
662
+ if (!patterns.cone || entries.length === 0 || entries.some((e) => e.stage !== 0)) {
663
+ return undefined;
664
+ }
665
+ // the directories holding an entry that keeps them from being collapsed
666
+ const blocked = new Set<string>();
667
+ // the directories whose cache-tree node is invalid: an intent-to-add entry below them
668
+ const invalid = new Set<string>();
669
+ const dirs: string[] = [];
670
+ const seen = new Set<string>();
671
+ for (const entry of entries) {
672
+ const stays = !entry.skipWorktree || entry.mode === FileMode.GITLINK || entry.intentToAdd;
673
+ for (let k = entry.path.indexOf("/"); k > 0; k = entry.path.indexOf("/", k + 1)) {
674
+ const dir = entry.path.slice(0, k + 1);
675
+ if (!seen.has(dir)) {
676
+ seen.add(dir);
677
+ dirs.push(dir);
678
+ }
679
+ if (stays) blocked.add(dir);
680
+ if (entry.intentToAdd) invalid.add(dir);
681
+ }
682
+ }
683
+ // the directory or one of its ancestors (the root aside) is an invalid node, which
684
+ // convert_to_sparse_rec copies entry by entry and never enters
685
+ const underInvalid = (dir: string) => {
686
+ for (let k = dir.indexOf("/"); k > 0; k = dir.indexOf("/", k + 1)) {
687
+ if (invalid.has(dir.slice(0, k + 1))) return true;
688
+ }
689
+ return false;
690
+ };
691
+ // convert_to_sparse_rec: the first directory outside the cone that can be collapsed
692
+ // stands for everything beneath it
693
+ const sparseDirs: string[] = [];
694
+ for (const dir of dirs) {
695
+ if (sparseDirs.some((d) => dir.startsWith(d))) continue;
696
+ if (blocked.has(dir) || patterns.includes(dir) || underInvalid(dir)) continue;
697
+ sparseDirs.push(dir);
698
+ }
699
+ return sparseDirs;
700
+ }
701
+
702
+ /**
703
+ * The lines git prints for the paths a sparse run reports, on stderr. With `porcelain`
704
+ * (`setup_unpack_trees_porcelain`: `checkout`, `switch`, the merge family,
705
+ * `sparse-checkout`) one `warning:` block per kind and git's reminder to reapply; without
706
+ * (`reset --merge`, `reset --keep`) one `error:` line per path in index order, as
707
+ * `add_rejected_path` prints them when it does not collect them.
708
+ */
709
+ export function sparseWarningText(outcome: SparseApplyOutcome, porcelain: boolean): string {
710
+ if (!porcelain) {
711
+ const line = {
712
+ notUptodate: (p: string) =>
713
+ `error: Path '${p}' not uptodate; will not remove from working tree.\n`,
714
+ unmerged: (p: string) => `error: Path '${p}' unmerged; will not remove from working tree.\n`,
715
+ orphaned: (p: string) =>
716
+ `error: Path '${p}' already present; will not overwrite with sparse update.\n`,
717
+ };
718
+ return outcome.reports.map((r) => line[r.kind](r.path)).join("");
719
+ }
720
+ const blocks: [string[], string][] = [
721
+ [
722
+ outcome.notUptodate,
723
+ "The following paths are not up to date and were left despite sparse patterns:",
724
+ ],
725
+ [outcome.unmerged, "The following paths are unmerged and were left despite sparse patterns:"],
726
+ [
727
+ outcome.orphaned,
728
+ "The following paths were already present and thus not updated despite sparse patterns:",
729
+ ],
730
+ ];
731
+ let text = "";
732
+ for (const [paths, header] of blocks) {
733
+ if (paths.length === 0) continue;
734
+ text += `warning: ${header}\n${paths.map((p) => `\t${p}\n`).join("")}\n`;
735
+ }
736
+ if (text) {
737
+ text += "After fixing the above paths, you may want to run `git sparse-checkout reapply`.\n";
738
+ }
739
+ return text;
740
+ }
741
+
742
+ /**
743
+ * What a command's sparse run printed (the patterns' warnings, then the sparse warnings),
744
+ * appended to `lines` one entry per line.
745
+ */
746
+ export function pushSparseWarnings(
747
+ lines: string[] | undefined,
748
+ sparse: SparseUnpack | undefined,
749
+ outcome: SparseApplyOutcome | undefined,
750
+ porcelain: boolean,
751
+ ): string {
752
+ if (!sparse || !outcome) return "";
753
+ const text =
754
+ patternWarningText(sparse.patterns) +
755
+ sparseWarningText(outcome, porcelain) +
756
+ outcome.unlinkWarnings.join("");
757
+ if (text) lines?.push(...text.replace(/\n$/, "").split("\n"));
758
+ return text;
759
+ }
760
+
761
+ /** git's `warning: ` lines for the patterns' own warnings (`add_pattern_to_hashsets`). */
762
+ export function patternWarningText(patterns: SparseCheckoutPatterns | undefined): string {
763
+ return (patterns?.warnings ?? []).map((w) => `warning: ${w}\n`).join("");
764
+ }
765
+
766
+ /**
767
+ * git's `advise_on_updating_sparse_paths` (`add`, `rm`): the elements that matched only
768
+ * entries outside the sparse checkout and, unless `advice.updateSparsePath` is off, the
769
+ * hint, its last line as the version words it (2.43: "git config advice...", 2.5x: "git
770
+ * config set advice...").
771
+ */
772
+ export function sparsePathAdvice(
773
+ elements: readonly string[],
774
+ advice: boolean,
775
+ compatibility: "2.43" | "2.56" = "2.56",
776
+ ): string[] {
777
+ const lines = [
778
+ "The following paths and/or pathspecs matched paths that exist",
779
+ "outside of your sparse-checkout definition, so will not be",
780
+ "updated in the index:",
781
+ ...elements,
782
+ ];
783
+ if (advice) {
784
+ const command = compatibility === "2.43" ? "git config" : "git config set";
785
+ lines.push(
786
+ "hint: If you intend to update such entries, try one of the following:",
787
+ "hint: * Use the --sparse option.",
788
+ "hint: * Disable or modify the sparsity rules.",
789
+ `hint: Disable this message with "${command} advice.updateSparsePath false"`,
790
+ );
791
+ }
792
+ return lines;
793
+ }