@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,14 +1,44 @@
1
- import type { MergeStageValue } from "@statewalker/vcs-working-tree";
1
+ import { FileMode, type ObjectId, type TreeEntry } from "@statewalker/vcs-core";
2
+ import {
3
+ compareWithWorktree,
4
+ type IndexEntry,
5
+ type Worktree,
6
+ withWorktreeEntries,
7
+ } from "@statewalker/vcs-working-tree";
2
8
 
3
- import { NoFilepatternError } from "../errors/index.js";
9
+ import { InvalidConfigError, NoFilepatternError, RmFailedError } from "../errors/index.js";
4
10
  import { GitCommand } from "../git-command.js";
11
+ import { worktreeModeTrust } from "./core-config.js";
12
+ import { IndexAdder } from "./index-adder.js";
13
+ import { configBool } from "./merge-config.js";
14
+ import {
15
+ DO_MATCH_DIRECTORY,
16
+ MATCHED_RECURSIVELY,
17
+ matchPathspecSeen,
18
+ parsePathspec,
19
+ } from "./pathspec.js";
20
+ import { PathspecAttributes } from "./pathspec-attributes.js";
21
+ import { sparsePathAdvice } from "./sparse-checkout-support.js";
22
+ import { StatusCommand } from "./status-command.js";
23
+ import { parseGitmodules } from "./submodule-config.js";
24
+ import {
25
+ pruneEmptyParents,
26
+ removeDirectoryIfEmpty,
27
+ statThroughLeadingLinks,
28
+ } from "./worktree-overwrite-checks.js";
5
29
 
6
30
  /**
7
31
  * Result of RmCommand execution.
8
32
  */
9
33
  export interface RmResult {
10
- /** Paths that were removed from the index */
34
+ /** Paths that were removed from the index (each once, whatever its stages) */
11
35
  removedPaths: string[];
36
+ /**
37
+ * What could not be done once the removal was under way, the index written all the same:
38
+ * a file that could not be deleted after another one was (git passes over it silently),
39
+ * a submodule `.gitmodules` names no section for (git's warning)
40
+ */
41
+ warnings?: string[];
12
42
  }
13
43
 
14
44
  /**
@@ -31,15 +61,80 @@ export interface RmResult {
31
61
  * .setCached(true)
32
62
  * .call();
33
63
  *
34
- * // Remove directory recursively
64
+ * // Remove directory recursively (`git rm -r`)
35
65
  * await git.rm()
36
66
  * .addFilepattern("src/old/")
67
+ * .setRecursive(true)
37
68
  * .call();
38
69
  * ```
39
70
  */
40
71
  export class RmCommand extends GitCommand<RmResult> {
41
72
  private filepatterns: string[] = [];
42
73
  private cached = false;
74
+ private sparse = false;
75
+ private recursive = false;
76
+ private ignoreUnmatch = false;
77
+ private force = false;
78
+ private compatibility: "2.43" | "2.56" = "2.56";
79
+
80
+ /**
81
+ * `--sparse`: entries outside the sparse checkout (skip-worktree, or out of the patterns)
82
+ * are removed too. Without it a pattern that matches only such entries is refused with
83
+ * git's advice ({@link RmFailedError}), the other patterns removed all the same.
84
+ */
85
+ setSparse(sparse: boolean): this {
86
+ this.checkCallable();
87
+ this.sparse = sparse;
88
+ return this;
89
+ }
90
+
91
+ /**
92
+ * `-r`: a pattern may name a directory (or `.`), removing every entry beneath. Without it
93
+ * such a pattern is refused before anything changes ("not removing 'd' recursively
94
+ * without -r"), as git does.
95
+ */
96
+ setRecursive(recursive: boolean): this {
97
+ this.checkCallable();
98
+ this.recursive = recursive;
99
+ return this;
100
+ }
101
+
102
+ /**
103
+ * `--ignore-unmatch`: a pattern that matches no entry is passed over. Without it git dies
104
+ * before anything changes ("pathspec 'x' did not match any files").
105
+ */
106
+ setIgnoreUnmatch(ignoreUnmatch: boolean): this {
107
+ this.checkCallable();
108
+ this.ignoreUnmatch = ignoreUnmatch;
109
+ return this;
110
+ }
111
+
112
+ /**
113
+ * `-f`: remove entries whatever they hold. Without it git's `check_local_mod` refuses,
114
+ * before anything changes ({@link RmFailedError}), an entry whose staged content differs
115
+ * from both its file and HEAD (with `--cached` too, unless it is intent-to-add), and,
116
+ * without `--cached`, one whose staged content differs from HEAD or whose file differs
117
+ * from the index: a submodule whose own worktree holds changes (modified, staged or
118
+ * untracked files, ignored ones aside) included, as a file reached through a symbolic link
119
+ * among the leading directories. Even forced, nothing is removed through such a link.
120
+ */
121
+ setForce(force: boolean): this {
122
+ this.checkCallable();
123
+ this.force = force;
124
+ return this;
125
+ }
126
+
127
+ /**
128
+ * The git version whose behaviour is reproduced where versions differ (default 2.56): the
129
+ * advice's last hint, as `AddCommand.setCompatibility`, and 2.43's pathspec matching, where
130
+ * an element that named an entry exactly matches no later entry (`rm 'b*'` with an entry
131
+ * `b*` removes only that one).
132
+ */
133
+ setCompatibility(version: "2.43" | "2.56"): this {
134
+ this.checkCallable();
135
+ this.compatibility = version;
136
+ return this;
137
+ }
43
138
 
44
139
  /**
45
140
  * Add a file pattern to remove.
@@ -56,7 +151,12 @@ export class RmCommand extends GitCommand<RmResult> {
56
151
  * Set whether to only remove from index (keep in working tree).
57
152
  *
58
153
  * When true, files are only removed from the staging area
59
- * but remain in the working directory (like `git rm --cached`).
154
+ * but remain in the working directory (like `git rm --cached`). Otherwise the files of
155
+ * the removed entries are deleted too and the directories they leave empty pruned (git's
156
+ * `remove_path`); a submodule's directory goes with everything in it where its repository
157
+ * lives in the superproject (a gitfile), its `.gitmodules` section is removed and the
158
+ * file staged again. A submodule holding its own `.git` directory keeps its directory (git
159
+ * absorbs the repository first, which is not reproduced).
60
160
  *
61
161
  * @param cached true to only remove from index
62
162
  */
@@ -81,98 +181,544 @@ export class RmCommand extends GitCommand<RmResult> {
81
181
  async call(): Promise<RmResult> {
82
182
  this.checkCallable();
83
183
  this.setCallable(false);
184
+ // the index as it is now, before the worktree or a ref is touched: one another writer
185
+ // replaced is read again (git reads the index at its start), unless this instance holds
186
+ // unwritten edits (refused)
187
+ await this.readCurrentIndex();
84
188
 
85
189
  if (this.filepatterns.length === 0) {
86
190
  throw new NoFilepatternError("At least one file pattern is required");
87
191
  }
88
192
 
89
193
  const removedPaths: string[] = [];
194
+ const removedEntries: IndexEntry[] = [];
195
+ // (the index as readCurrentIndex left it: reading it again would bring back the
196
+ // skip-worktree flags cleared for files present in a sparse checkout)
90
197
 
91
- // Read current staging area
92
- await this.staging.read();
198
+ // cmd_rm: a skip-worktree entry, and with a sparse checkout an entry out of its
199
+ // patterns, is passed over unless --sparse (whether or not core.sparseCheckout is set);
200
+ // a pattern that matched only those is advised on (matches_skip_worktree)
201
+ const patterns = this.sparse ? undefined : await this.sparseCheckoutPatterns();
202
+ // git's pathspec (parse_pathspec, then ce_path_match): `.` and `./d` name everything
203
+ // beneath, a directory its files, a glob's `*` crosses slashes; `seen` tells which
204
+ // elements matched (git's ps_matched)
205
+ const items = parsePathspec(this.filepatterns, { attr: true });
206
+ // `:(attr:...)`: the attributes of the index's paths (match_pathspec_attrs)
207
+ const attributes = PathspecAttributes.forWorktree(items, this.worktreeAccess);
208
+ if (attributes) {
209
+ const paths: string[] = [];
210
+ for await (const entry of this.staging.entries()) paths.push(entry.path);
211
+ await attributes.load(paths);
212
+ }
213
+ const seen = items.map(() => 0);
214
+ const seenOutside = items.map(() => 0);
215
+ const exactStopsGlobs = this.compatibility === "2.43";
216
+ const removedSet = new Set<string>();
217
+ let gitmodulesEntry: IndexEntry | undefined;
218
+ let removesSubmodule = false;
219
+ for await (const entry of this.staging.entries()) {
220
+ if (entry.path === ".gitmodules" && entry.stage === 0) gitmodulesEntry = entry;
221
+ // ce_path_match: a submodule matches `sub/` as a directory would
222
+ const flags = entry.mode === FileMode.GITLINK ? DO_MATCH_DIRECTORY : 0;
223
+ const outside =
224
+ !this.sparse &&
225
+ (entry.skipWorktree || (patterns !== undefined && !patterns.includes(entry.path)));
226
+ if (outside) {
227
+ matchPathspecSeen(items, entry.path, flags, seenOutside, exactStopsGlobs);
228
+ continue;
229
+ }
230
+ if (matchPathspecSeen(items, entry.path, flags, seen, exactStopsGlobs)) {
231
+ if (!removedSet.has(entry.path)) removedPaths.push(entry.path);
232
+ removedSet.add(entry.path);
233
+ removedEntries.push(entry);
234
+ if (entry.mode === FileMode.GITLINK) removesSubmodule = true;
235
+ }
236
+ }
237
+ // is_staging_gitmodules_ok: a submodule is not removed while .gitmodules holds changes
238
+ // the index does not
239
+ const worktree = this.worktreeAccess;
240
+ if (removesSubmodule && gitmodulesEntry && worktree) {
241
+ const compared = await compareWithWorktree(worktree, gitmodulesEntry, {
242
+ trust: worktreeModeTrust(this.workingCopy, worktree),
243
+ indexTime: this.staging.getUpdateTime(),
244
+ }).catch(() => undefined);
245
+ if (
246
+ compared?.kind === "modified" &&
247
+ compared.worktreeEntry &&
248
+ !compared.worktreeEntry.isDirectory
249
+ ) {
250
+ const staged = compared.hashedId ?? (await worktree.computeHash(".gitmodules"));
251
+ if (staged !== gitmodulesEntry.objectId) {
252
+ throw new RmFailedError(
253
+ "fatal: please stage your changes to .gitmodules or stash them to proceed",
254
+ [],
255
+ { removedPaths: [] },
256
+ );
257
+ }
258
+ }
259
+ }
260
+ // cmd_rm's check of each element, in order, before anything is written: one that matched
261
+ // nothing dies (unless --ignore-unmatch, or it matched only entries outside the sparse
262
+ // checkout), one that named a directory needs -r (an implicit `.` is shown as `.`)
263
+ const sparsePaths: string[] = [];
264
+ let seenAny = false;
265
+ for (let i = 0; i < items.length; i++) {
266
+ const original = this.filepatterns[i] ?? "";
267
+ if (seen[i]) seenAny = true;
268
+ else if (this.ignoreUnmatch) continue;
269
+ else if (seenOutside[i]) sparsePaths.push(original);
270
+ else {
271
+ throw new RmFailedError(`fatal: pathspec '${original}' did not match any files`, [], {
272
+ removedPaths: [],
273
+ });
274
+ }
275
+ if (!this.recursive && seen[i] === MATCHED_RECURSIVELY) {
276
+ throw new RmFailedError(
277
+ `fatal: not removing '${original || "."}' recursively without -r`,
278
+ [],
279
+ { removedPaths: [] },
280
+ );
281
+ }
282
+ }
283
+ const matched = seenAny;
284
+ const advise = (result: RmResult = { removedPaths }) =>
285
+ new RmFailedError(
286
+ sparsePathAdvice(
287
+ sparsePaths,
288
+ configBool(this.workingCopy, "advice.updateSparsePath", true),
289
+ this.compatibility,
290
+ ).join("\n"),
291
+ sparsePaths,
292
+ result,
293
+ );
294
+ // nothing else matched: git exits before writing anything
295
+ if (sparsePaths.length > 0 && !matched) throw advise();
296
+ // nothing matched at all (every element passed over by --ignore-unmatch)
297
+ if (!matched) return { removedPaths: [] };
93
298
 
94
- // Get all entries from staging
95
- const entriesToKeep: Array<{
96
- path: string;
97
- mode: number;
98
- objectId: string;
99
- stage: MergeStageValue;
100
- }> = [];
299
+ // remove_path_from_gitmodules dies on an unmerged .gitmodules (checked before anything
300
+ // changes here, where git has removed the files already)
301
+ const editsGitmodules = removesSubmodule && !this.cached && worktree !== undefined;
302
+ if (editsGitmodules && (await this.gitmodulesUnmerged())) {
303
+ throw new RmFailedError(
304
+ "fatal: Cannot change unmerged .gitmodules, resolve merge conflicts first",
305
+ [],
306
+ { removedPaths: [] },
307
+ );
308
+ }
101
309
 
102
- for await (const entry of this.staging.entries()) {
103
- const shouldRemove = this.matchesPattern(entry.path);
310
+ // check_local_mod: unless forced, nothing is removed that the index alone holds
311
+ if (!this.force) {
312
+ const refusal = await this.checkLocalMod(removedEntries, worktree);
313
+ if (refusal) throw new RmFailedError(refusal, [], { removedPaths: [] });
314
+ }
104
315
 
105
- if (shouldRemove) {
106
- removedPaths.push(entry.path);
107
- } else {
108
- entriesToKeep.push({
109
- path: entry.path,
110
- mode: entry.mode,
111
- objectId: entry.objectId,
112
- stage: entry.stage,
113
- });
316
+ // the files first (git commits the index only once they are gone): the first that cannot
317
+ // be removed dies before anything changes, a later one is passed over (the index is
318
+ // written all the same)
319
+ const warnings: string[] = [];
320
+ const removedSubmodules: string[] = [];
321
+ if (!this.cached && worktree) {
322
+ let removed = false;
323
+ const done = new Set<string>();
324
+ for (const entry of removedEntries) {
325
+ if (done.has(entry.path)) continue;
326
+ done.add(entry.path);
327
+ let failure: string | undefined;
328
+ try {
329
+ if (!(await removeWorktreePath(worktree, entry))) failure = "Is a directory";
330
+ } catch (error) {
331
+ failure = errnoMessage(error);
332
+ }
333
+ if (failure === undefined) {
334
+ removed = true;
335
+ if (entry.mode === FileMode.GITLINK) removedSubmodules.push(entry.path);
336
+ } else if (!removed) {
337
+ throw new RmFailedError(`fatal: git rm: '${entry.path}': ${failure}`, [], {
338
+ removedPaths: [],
339
+ });
340
+ } else {
341
+ warnings.push(`warning: git rm: '${entry.path}': ${failure}`);
342
+ }
114
343
  }
115
344
  }
345
+ // remove_path_from_gitmodules of each submodule removed, then the file staged again
346
+ // (stage_updated_gitmodules)
347
+ let gitmodulesEdited = false;
348
+ if (worktree && removedSubmodules.length > 0) {
349
+ gitmodulesEdited = await this.removeFromGitmodules(worktree, removedSubmodules, warnings);
350
+ }
116
351
 
117
- // Rebuild staging with entries that weren't removed
118
- const builder = this.staging.createBuilder();
119
- for (const entry of entriesToKeep) {
120
- builder.add(entry);
352
+ // git's remove_file_from_index: every stage of each path goes (conflicts kept as
353
+ // resolve-undo); the kept entries go on as they are, flags and stat data included
354
+ const trust = worktree
355
+ ? worktreeModeTrust(this.workingCopy, worktree)
356
+ : { executable: true, symlinks: true };
357
+ const adder = await IndexAdder.open(this.staging, this.blobs, trust);
358
+ for (const path of removedPaths) adder.remove(path);
359
+ if (gitmodulesEdited && worktree) {
360
+ const entry = await worktree.getEntry(".gitmodules");
361
+ if (entry && !entry.isDirectory) await adder.add(worktree, ".gitmodules", entry);
121
362
  }
122
- await builder.finish();
363
+ await adder.finish();
123
364
  await this.staging.write();
124
365
 
125
- // Note: Working tree removal is not implemented here since
126
- // WorkingCopy may not have worktree access for file deletion.
127
- // The cached flag controls whether working tree should be modified,
128
- // but actual deletion requires filesystem access which is
129
- // implementation-specific.
366
+ const result: RmResult = { removedPaths, ...(warnings.length > 0 ? { warnings } : {}) };
367
+ if (sparsePaths.length > 0) throw advise(result);
368
+ return result;
369
+ }
130
370
 
131
- return { removedPaths };
371
+ /** Whether `.gitmodules` has conflict stages in the index (git's `is_gitmodules_unmerged`). */
372
+ private async gitmodulesUnmerged(): Promise<boolean> {
373
+ for await (const entry of this.staging.entries()) {
374
+ if (entry.path === ".gitmodules" && entry.stage !== 0) return true;
375
+ }
376
+ return false;
132
377
  }
133
378
 
134
379
  /**
135
- * Check if a path matches any of the configured patterns.
380
+ * git's `remove_path_from_gitmodules` for each removed submodule: the `.gitmodules`
381
+ * section naming its path removed from the worktree's file (every line from its header to
382
+ * the next header, as `git_config_rename_section_in_file` drops it). Returns whether the
383
+ * file is to be staged again (git restages it once a section was looked for, even when
384
+ * none matched); nothing without a `.gitmodules`.
136
385
  */
137
- private matchesPattern(path: string): boolean {
138
- for (const pattern of this.filepatterns) {
139
- // Exact match
140
- if (path === pattern) {
141
- return true;
386
+ private async removeFromGitmodules(
387
+ worktree: Worktree,
388
+ paths: readonly string[],
389
+ warnings: string[],
390
+ ): Promise<boolean> {
391
+ let modified = false;
392
+ for (const path of paths) {
393
+ const file = await worktree.getEntry(".gitmodules");
394
+ if (!file || file.isDirectory) return modified;
395
+ const text = await readText(worktree, ".gitmodules");
396
+ const declared = parseGitmodules(text).filter((s) => s.path === path);
397
+ const submodule = declared[declared.length - 1];
398
+ if (!submodule) {
399
+ warnings.push(`warning: Could not find section in .gitmodules where path=${path}`);
400
+ continue;
142
401
  }
143
-
144
- // Directory pattern (ends with /)
145
- if (pattern.endsWith("/")) {
146
- const dirPrefix = pattern;
147
- if (path.startsWith(dirPrefix)) {
148
- return true;
402
+ const section = `submodule.${submodule.name}`;
403
+ const lines = text.split(/(?<=\n)/);
404
+ let removing = false;
405
+ const kept: string[] = [];
406
+ for (const line of lines) {
407
+ const at = line.search(/\S/);
408
+ if (at >= 0 && line[at] === "[") removing = sectionNameMatch(line.slice(at), section);
409
+ if (!removing) kept.push(line);
410
+ }
411
+ await worktree.writeContent(".gitmodules", new TextEncoder().encode(kept.join("")), {
412
+ raw: true,
413
+ });
414
+ modified = true;
415
+ }
416
+ return modified;
417
+ }
418
+ /**
419
+ * git's `check_local_mod`: the entries whose removal would lose content, as git's error
420
+ * lines (singular or plural, each list with its hint unless `advice.rmHints` is off), or
421
+ * undefined. An unmerged entry, a file gone from the worktree or a directory standing at
422
+ * a file is passed over; a submodule is checked against its index entry only.
423
+ */
424
+ private async checkLocalMod(
425
+ entries: readonly IndexEntry[],
426
+ worktree: Worktree | undefined,
427
+ ): Promise<string | undefined> {
428
+ const headTree = await this.headTree();
429
+ const staged: string[] = [];
430
+ const cached: string[] = [];
431
+ const local: string[] = [];
432
+ // an unmerged path is passed over, unless its stage 2 (ours) is a populated submodule,
433
+ // which could lose history (get_ours_cache_pos)
434
+ const candidates: IndexEntry[] = [];
435
+ const stage0 = new Set(entries.filter((e) => e.stage === 0).map((e) => e.path));
436
+ for (const entry of entries) {
437
+ if (entry.stage === 0) candidates.push(entry);
438
+ else if (entry.stage === 2 && entry.mode === FileMode.GITLINK && !stage0.has(entry.path)) {
439
+ if (worktree && !(await isEmptyDirectory(worktree, entry.path))) candidates.push(entry);
440
+ }
441
+ }
442
+ const trust = worktree ? worktreeModeTrust(this.workingCopy, worktree) : undefined;
443
+ const indexTime = this.staging.getUpdateTime();
444
+ const lookup = treeLookup(this.trees);
445
+ const stated = worktree
446
+ ? withWorktreeEntries(worktree, candidates)
447
+ : candidates.map((item) => ({ item, current: null }));
448
+ for await (const { item: entry, current } of stated) {
449
+ if (!worktree) continue;
450
+ let localChanges = false;
451
+ if (!current) {
452
+ // lstat follows a symbolic link among the leading directories (refresh_index passed
453
+ // the path over): what stands there is a change, a directory as a vanished file
454
+ // (the removal then fails on it); nothing there, the file already vanished
455
+ const through = await statThroughLeadingLinks(worktree, entry.path);
456
+ if (!through || (!through.unknown && !through.entry)) continue;
457
+ if (through.entry?.isDirectory && entry.mode !== FileMode.GITLINK) continue;
458
+ localChanges = true;
459
+ } else {
460
+ // a directory standing at a file: the same as a vanished file
461
+ if (current.isDirectory && entry.mode !== FileMode.GITLINK) continue;
462
+ // ie_match_stat: skip-worktree and assume-unchanged entries match by definition, an
463
+ // intent-to-add one never does
464
+ if (entry.intentToAdd) localChanges = true;
465
+ else if (!entry.skipWorktree && !entry.assumeValid) {
466
+ const compared = await compareWithWorktree(
467
+ worktree,
468
+ entry,
469
+ { trust, indexTime },
470
+ current,
471
+ );
472
+ localChanges = compared.kind !== undefined;
473
+ }
474
+ // a submodule whose own worktree holds changes (bad_to_remove_submodule)
475
+ if (!localChanges && entry.mode === FileMode.GITLINK && current.isDirectory) {
476
+ localChanges = await badToRemoveSubmodule(worktree, entry.path, this.cached);
149
477
  }
150
478
  }
151
-
152
- // Prefix match for directories without trailing slash
153
- if (path.startsWith(`${pattern}/`)) {
154
- return true;
479
+ const inHead = headTree ? await lookup(headTree, entry.path) : undefined;
480
+ const stagedChanges = !inHead || inHead.mode !== entry.mode || inHead.id !== entry.objectId;
481
+ if (localChanges && stagedChanges) {
482
+ if (!this.cached || !entry.intentToAdd) staged.push(entry.path);
483
+ } else if (!this.cached) {
484
+ if (stagedChanges) cached.push(entry.path);
485
+ if (localChanges) local.push(entry.path);
155
486
  }
487
+ }
488
+ const hints = configBool(this.workingCopy, "advice.rmHints", true);
489
+ const lines: string[] = [];
490
+ const report = (files: string[], one: string, many: string, hint: string) => {
491
+ if (files.length === 0) return;
492
+ let message = `error: ${files.length === 1 ? one : many}`;
493
+ for (const file of files) message += `\n ${file}`;
494
+ if (hints) message += `\n${hint}`;
495
+ lines.push(message);
496
+ };
497
+ report(
498
+ staged,
499
+ "the following file has staged content different from both the\nfile and the HEAD:",
500
+ "the following files have staged content different from both the\nfile and the HEAD:",
501
+ "(use -f to force removal)",
502
+ );
503
+ const keep = "(use --cached to keep the file, or -f to force removal)";
504
+ report(
505
+ cached,
506
+ "the following file has changes staged in the index:",
507
+ "the following files have changes staged in the index:",
508
+ keep,
509
+ );
510
+ report(
511
+ local,
512
+ "the following file has local modifications:",
513
+ "the following files have local modifications:",
514
+ keep,
515
+ );
516
+ return lines.length > 0 ? lines.join("\n") : undefined;
517
+ }
156
518
 
157
- // Simple glob matching for * patterns
158
- if (pattern.includes("*")) {
159
- const regex = this.patternToRegex(pattern);
160
- if (regex.test(path)) {
161
- return true;
162
- }
519
+ /** HEAD's tree; undefined before the first commit (everything staged counts as changed). */
520
+ private async headTree(): Promise<ObjectId | undefined> {
521
+ const head = await this.refsStore.resolve("HEAD");
522
+ if (!head?.objectId) return undefined;
523
+ return this.commits.getTree(head.objectId);
524
+ }
525
+ }
526
+
527
+ /**
528
+ * The entry at `path` in a tree (git's `get_tree_entry`), each directory read once.
529
+ */
530
+ function treeLookup(trees: {
531
+ getEntry(treeId: ObjectId, name: string): Promise<TreeEntry | undefined>;
532
+ }): (treeId: ObjectId, path: string) => Promise<TreeEntry | undefined> {
533
+ const dirs = new Map<string, Promise<TreeEntry | undefined>>();
534
+ const at = (treeId: ObjectId, dir: string, name: string) => {
535
+ const key = `${treeId}\0${dir}\0${name}`;
536
+ let found = dirs.get(key);
537
+ if (!found) {
538
+ found = trees.getEntry(treeId, name);
539
+ dirs.set(key, found);
540
+ }
541
+ return found;
542
+ };
543
+ return async (treeId, path) => {
544
+ const parts = path.split("/");
545
+ let id = treeId;
546
+ let entry: TreeEntry | undefined;
547
+ for (let k = 0; k < parts.length; k++) {
548
+ entry = await at(id, parts.slice(0, k).join("/"), parts[k] ?? "");
549
+ if (!entry) return undefined;
550
+ if (k < parts.length - 1) {
551
+ if (entry.mode !== FileMode.TREE) return undefined;
552
+ id = entry.id;
163
553
  }
164
554
  }
555
+ return entry;
556
+ };
557
+ }
558
+
559
+ /**
560
+ * git's `remove_path` for a removed entry: its file unlinked (one already gone is no error),
561
+ * then each parent directory left empty removed, bottom-up. A directory standing at a file
562
+ * cannot be unlinked (false: git's EISDIR), nor one reached through a symbolic link among
563
+ * the leading directories; a file reached that way is left alone (nothing is ever removed
564
+ * through a link). A submodule's directory goes with everything in it (git's
565
+ * `remove_dir_recursively`) where its repository lives elsewhere (a gitfile, nested
566
+ * submodules alike); one holding its own `.git` directory stays (git absorbs it into the
567
+ * superproject first, which is not reproduced).
568
+ */
569
+ async function removeWorktreePath(worktree: Worktree, entry: IndexEntry): Promise<boolean> {
570
+ const current = await worktree.getEntry(entry.path);
571
+ if (current?.isDirectory) {
572
+ if (entry.mode !== FileMode.GITLINK) return false;
573
+ if (!(await removeDirectoryIfEmpty(worktree, entry.path))) {
574
+ if (!(await usesGitfile(worktree, entry.path))) return true;
575
+ await worktree.remove(entry.path, { recursive: true });
576
+ }
577
+ } else if (current) {
578
+ await worktree.remove(entry.path);
579
+ } else {
580
+ const through = await statThroughLeadingLinks(worktree, entry.path);
581
+ if (through?.entry?.isDirectory) return false;
582
+ if (through) return true;
583
+ }
584
+ await pruneEmptyParents(worktree, entry.path);
585
+ return true;
586
+ }
587
+
588
+ /** Whether the directory at `path` holds nothing (git's `is_empty_dir`: false when absent). */
589
+ async function isEmptyDirectory(worktree: Worktree, path: string): Promise<boolean> {
590
+ const entry = await worktree.getEntry(path);
591
+ if (!entry?.isDirectory) return false;
592
+ if (await worktree.getEntry(`${path}/.git`)) return false;
593
+ for await (const _ of worktree.walk({
594
+ pathPrefix: path,
595
+ includeIgnored: true,
596
+ includeDirectories: true,
597
+ })) {
165
598
  return false;
166
599
  }
600
+ return true;
601
+ }
167
602
 
168
- /**
169
- * Convert a simple glob pattern to regex.
170
- */
171
- private patternToRegex(pattern: string): RegExp {
172
- // Escape special regex characters except *
173
- const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
174
- // Convert * to .*
175
- const regexStr = escaped.replace(/\*/g, ".*");
176
- return new RegExp(`^${regexStr}$`);
603
+ /**
604
+ * git's `submodule_uses_gitfile`: the submodule at `path` has a `.git` file (its repository
605
+ * lives elsewhere), and so does every populated submodule nested in it.
606
+ */
607
+ async function usesGitfile(worktree: Worktree, path: string, depth = 0): Promise<boolean> {
608
+ const dotGit = await worktree.getEntry(`${path}/.git`);
609
+ if (!dotGit || dotGit.isDirectory) return false;
610
+ if (depth > 32) return false;
611
+ const inner = await worktree.openGitlink?.(path).catch(() => undefined);
612
+ if (!inner) return false;
613
+ for await (const entry of inner.checkout.staging.entries()) {
614
+ if (entry.mode !== FileMode.GITLINK) continue;
615
+ const nested = `${path}/${entry.path}`;
616
+ if (!(await worktree.getEntry(`${nested}/.git`))) continue;
617
+ if (!(await usesGitfile(worktree, nested, depth + 1))) return false;
618
+ }
619
+ return true;
620
+ }
621
+
622
+ /**
623
+ * git's `bad_to_remove_submodule` with `SUBMODULE_REMOVAL_DIE_ON_ERROR |
624
+ * SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED`: a populated submodule whose
625
+ * `git status --porcelain --ignore-submodules=none -uall` shows anything (a modified,
626
+ * staged or untracked file, a nested submodule's changes; ignored files do not count). An
627
+ * empty or absent directory is not. With `--cached` git has not absorbed the submodule's
628
+ * repository first, so one without a gitfile counts; without it git has, and its status is
629
+ * read here as it is. A submodule whose repository cannot be opened counts (git dies); a
630
+ * configuration the inner status cannot read (a bad `status.showUntrackedFiles`) fails the
631
+ * whole removal with its messages and git's "could not run 'git status'", nothing removed.
632
+ */
633
+ async function badToRemoveSubmodule(
634
+ worktree: Worktree,
635
+ path: string,
636
+ cached: boolean,
637
+ ): Promise<boolean> {
638
+ if (await isEmptyDirectory(worktree, path)) return false;
639
+ const dotGit = await worktree.getEntry(`${path}/.git`);
640
+ if (!dotGit) return true;
641
+ if (cached && !(await usesGitfile(worktree, path))) return true;
642
+ const inner = await worktree.openGitlink?.(path).catch(() => undefined);
643
+ if (!inner) return true;
644
+ try {
645
+ // `git status --porcelain --ignore-submodules=none -uall` there: every untracked file
646
+ // counts, whatever the submodule's status.showUntrackedFiles says
647
+ const status = await new StatusCommand(inner)
648
+ .setRenames(false)
649
+ .setUntrackedFiles("all")
650
+ .setIgnoreSubmodules("none")
651
+ .call();
652
+ return status.files.some((f) => f.index !== "!");
653
+ } catch (error) {
654
+ // the child status dies on its configuration (its own messages), then git rm does
655
+ if (error instanceof InvalidConfigError) {
656
+ throw new RmFailedError(
657
+ `${error.message}\nfatal: could not run 'git status' in submodule '${path}'`,
658
+ [],
659
+ { removedPaths: [] },
660
+ );
661
+ }
662
+ return true;
663
+ }
664
+ }
665
+
666
+ /** git's `strerror` for a failed removal, from the error's code where it has one. */
667
+ function errnoMessage(error: unknown): string {
668
+ const code = (error as { code?: unknown } | undefined)?.code;
669
+ const known: Record<string, string> = {
670
+ EACCES: "Permission denied",
671
+ EPERM: "Operation not permitted",
672
+ EISDIR: "Is a directory",
673
+ EBUSY: "Device or resource busy",
674
+ EROFS: "Read-only file system",
675
+ ENOTEMPTY: "Directory not empty",
676
+ EIO: "Input/output error",
677
+ };
678
+ if (typeof code === "string" && known[code]) return known[code];
679
+ return error instanceof Error ? error.message : String(error);
680
+ }
681
+
682
+ /** The worktree file at `path` as text (UTF-8). */
683
+ async function readText(worktree: Worktree, path: string): Promise<string> {
684
+ const chunks: Uint8Array[] = [];
685
+ for await (const chunk of worktree.readContent(path)) chunks.push(chunk);
686
+ let size = 0;
687
+ for (const c of chunks) size += c.length;
688
+ const bytes = new Uint8Array(size);
689
+ let at = 0;
690
+ for (const c of chunks) {
691
+ bytes.set(c, at);
692
+ at += c.length;
693
+ }
694
+ return new TextDecoder().decode(bytes);
695
+ }
696
+
697
+ /**
698
+ * git's `section_name_match`: whether the header beginning `line` (at its `[`) names
699
+ * `name` (`submodule.<name>`), as `[submodule "<name>"]` with its escapes or the old
700
+ * `[submodule.<name>]`; bytes compared as they are (case included).
701
+ */
702
+ function sectionNameMatch(line: string, name: string): boolean {
703
+ if (line[0] !== "[") return false;
704
+ const space = (c: string | undefined) => c !== undefined && /\s/.test(c);
705
+ let i = 1;
706
+ let j = 0;
707
+ let dot = false;
708
+ for (; i < line.length && line[i] !== "]"; i++) {
709
+ if (!dot && space(line[i])) {
710
+ dot = true;
711
+ if (name[j++] !== ".") break;
712
+ for (i++; space(line[i]); i++);
713
+ if (line[i] !== '"') break;
714
+ continue;
715
+ }
716
+ if (line[i] === "\\" && dot) i++;
717
+ else if (line[i] === '"' && dot) {
718
+ for (i++; space(line[i]); i++);
719
+ break;
720
+ }
721
+ if (line[i] !== name[j++]) break;
177
722
  }
723
+ return line[i] === "]" && j === name.length;
178
724
  }