@statewalker/vcs-commands 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/dist/commands/add-command.d.ts +38 -0
  2. package/dist/commands/add-command.d.ts.map +1 -1
  3. package/dist/commands/am/am-command.d.ts +55 -1
  4. package/dist/commands/am/am-command.d.ts.map +1 -1
  5. package/dist/commands/am/index.d.ts +1 -0
  6. package/dist/commands/am/index.d.ts.map +1 -1
  7. package/dist/commands/am/mailsplit.d.ts +88 -0
  8. package/dist/commands/am/mailsplit.d.ts.map +1 -0
  9. package/dist/commands/apply/apply-command.d.ts.map +1 -1
  10. package/dist/commands/apply/apply-engine.d.ts.map +1 -1
  11. package/dist/commands/apply/apply-parse.d.ts.map +1 -1
  12. package/dist/commands/bisect/bisect-command.d.ts +2 -0
  13. package/dist/commands/bisect/bisect-command.d.ts.map +1 -1
  14. package/dist/commands/branch-command.d.ts +148 -18
  15. package/dist/commands/branch-command.d.ts.map +1 -1
  16. package/dist/commands/branch-info-command.d.ts +55 -0
  17. package/dist/commands/branch-info-command.d.ts.map +1 -0
  18. package/dist/commands/branch-tracking.d.ts +106 -17
  19. package/dist/commands/branch-tracking.d.ts.map +1 -1
  20. package/dist/commands/branch-upstream-command.d.ts +83 -0
  21. package/dist/commands/branch-upstream-command.d.ts.map +1 -0
  22. package/dist/commands/checkout-command.d.ts +19 -3
  23. package/dist/commands/checkout-command.d.ts.map +1 -1
  24. package/dist/commands/cherry-pick-command.d.ts +59 -0
  25. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  26. package/dist/commands/clean-command.d.ts +12 -0
  27. package/dist/commands/clean-command.d.ts.map +1 -1
  28. package/dist/commands/clone-command.d.ts.map +1 -1
  29. package/dist/commands/commit-command.d.ts +191 -5
  30. package/dist/commands/commit-command.d.ts.map +1 -1
  31. package/dist/commands/commit-reuse.d.ts +33 -0
  32. package/dist/commands/commit-reuse.d.ts.map +1 -0
  33. package/dist/commands/config-command.d.ts +236 -0
  34. package/dist/commands/config-command.d.ts.map +1 -0
  35. package/dist/commands/config-value-types.d.ts +91 -0
  36. package/dist/commands/config-value-types.d.ts.map +1 -0
  37. package/dist/commands/core-config.d.ts +20 -0
  38. package/dist/commands/core-config.d.ts.map +1 -1
  39. package/dist/commands/diff-color-config.d.ts +73 -0
  40. package/dist/commands/diff-color-config.d.ts.map +1 -0
  41. package/dist/commands/diff-command.d.ts +252 -5
  42. package/dist/commands/diff-command.d.ts.map +1 -1
  43. package/dist/commands/fetch-command.d.ts +20 -0
  44. package/dist/commands/fetch-command.d.ts.map +1 -1
  45. package/dist/commands/fmt-merge-msg-command.d.ts +124 -0
  46. package/dist/commands/fmt-merge-msg-command.d.ts.map +1 -0
  47. package/dist/commands/fork-point.d.ts +38 -0
  48. package/dist/commands/fork-point.d.ts.map +1 -0
  49. package/dist/commands/format-patch-command.d.ts +41 -1
  50. package/dist/commands/format-patch-command.d.ts.map +1 -1
  51. package/dist/commands/fsck/fetch-fsck.d.ts +51 -0
  52. package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -1
  53. package/dist/commands/gc-command.d.ts +8 -0
  54. package/dist/commands/gc-command.d.ts.map +1 -1
  55. package/dist/commands/git-describe.d.ts +4 -0
  56. package/dist/commands/git-describe.d.ts.map +1 -1
  57. package/dist/commands/git-hooks.d.ts +35 -0
  58. package/dist/commands/git-hooks.d.ts.map +1 -1
  59. package/dist/commands/grep/grep-command.d.ts +210 -0
  60. package/dist/commands/grep/grep-command.d.ts.map +1 -0
  61. package/dist/commands/grep/grep-engine.d.ts +218 -0
  62. package/dist/commands/grep/grep-engine.d.ts.map +1 -0
  63. package/dist/commands/grep/index.d.ts +3 -0
  64. package/dist/commands/grep/index.d.ts.map +1 -0
  65. package/dist/commands/index-adder.d.ts +13 -2
  66. package/dist/commands/index-adder.d.ts.map +1 -1
  67. package/dist/commands/index.d.ts +26 -0
  68. package/dist/commands/index.d.ts.map +1 -1
  69. package/dist/commands/index.js +3 -3
  70. package/dist/commands/interpret-trailers-command.d.ts +90 -0
  71. package/dist/commands/interpret-trailers-command.d.ts.map +1 -0
  72. package/dist/commands/local-transport.d.ts +36 -5
  73. package/dist/commands/local-transport.d.ts.map +1 -1
  74. package/dist/commands/log-command.d.ts +296 -11
  75. package/dist/commands/log-command.d.ts.map +1 -1
  76. package/dist/commands/log-graph.d.ts +26 -1
  77. package/dist/commands/log-graph.d.ts.map +1 -1
  78. package/dist/commands/log-output.d.ts +133 -5
  79. package/dist/commands/log-output.d.ts.map +1 -1
  80. package/dist/commands/ls-remote-command.d.ts +2 -0
  81. package/dist/commands/ls-remote-command.d.ts.map +1 -1
  82. package/dist/commands/mailmap.d.ts +30 -0
  83. package/dist/commands/mailmap.d.ts.map +1 -1
  84. package/dist/commands/merge-base-command.d.ts +60 -0
  85. package/dist/commands/merge-base-command.d.ts.map +1 -0
  86. package/dist/commands/merge-bases.d.ts +23 -0
  87. package/dist/commands/merge-bases.d.ts.map +1 -1
  88. package/dist/commands/merge-command.d.ts +96 -9
  89. package/dist/commands/merge-command.d.ts.map +1 -1
  90. package/dist/commands/merge-support.d.ts.map +1 -1
  91. package/dist/commands/mv-command.d.ts +4 -0
  92. package/dist/commands/mv-command.d.ts.map +1 -1
  93. package/dist/commands/name-rev.d.ts +48 -0
  94. package/dist/commands/name-rev.d.ts.map +1 -0
  95. package/dist/commands/notes-command.d.ts.map +1 -1
  96. package/dist/commands/pathspec-file.d.ts +39 -0
  97. package/dist/commands/pathspec-file.d.ts.map +1 -0
  98. package/dist/commands/pathspec.d.ts +3 -0
  99. package/dist/commands/pathspec.d.ts.map +1 -1
  100. package/dist/commands/pretty-format.d.ts +43 -3
  101. package/dist/commands/pretty-format.d.ts.map +1 -1
  102. package/dist/commands/promisor-remote.d.ts.map +1 -1
  103. package/dist/commands/pull-command.d.ts +10 -0
  104. package/dist/commands/pull-command.d.ts.map +1 -1
  105. package/dist/commands/push-command.d.ts +160 -9
  106. package/dist/commands/push-command.d.ts.map +1 -1
  107. package/dist/commands/read-tree-command.d.ts +6 -0
  108. package/dist/commands/read-tree-command.d.ts.map +1 -1
  109. package/dist/commands/rebase-command.d.ts +168 -6
  110. package/dist/commands/rebase-command.d.ts.map +1 -1
  111. package/dist/commands/ref-filter/for-each-ref-command.d.ts +121 -0
  112. package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -0
  113. package/dist/commands/ref-filter/index.d.ts +8 -0
  114. package/dist/commands/ref-filter/index.d.ts.map +1 -0
  115. package/dist/commands/ref-filter/ref-atoms.d.ts +88 -0
  116. package/dist/commands/ref-filter/ref-atoms.d.ts.map +1 -0
  117. package/dist/commands/ref-filter/ref-filter.d.ts +178 -0
  118. package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -0
  119. package/dist/commands/ref-filter/ref-format.d.ts +222 -0
  120. package/dist/commands/ref-filter/ref-format.d.ts.map +1 -0
  121. package/dist/commands/ref-filter/ref-listing-command.d.ts +56 -0
  122. package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -0
  123. package/dist/commands/ref-filter/ref-quote.d.ts +20 -0
  124. package/dist/commands/ref-filter/ref-quote.d.ts.map +1 -0
  125. package/dist/commands/ref-filter/version-compare.d.ts +20 -0
  126. package/dist/commands/ref-filter/version-compare.d.ts.map +1 -0
  127. package/dist/commands/reflog-command.d.ts +120 -0
  128. package/dist/commands/reflog-command.d.ts.map +1 -1
  129. package/dist/commands/reflog-walk.d.ts +72 -0
  130. package/dist/commands/reflog-walk.d.ts.map +1 -0
  131. package/dist/commands/remote-command.d.ts +138 -29
  132. package/dist/commands/remote-command.d.ts.map +1 -1
  133. package/dist/commands/remote-transport.d.ts +7 -1
  134. package/dist/commands/remote-transport.d.ts.map +1 -1
  135. package/dist/commands/reset-command.d.ts +2 -3
  136. package/dist/commands/reset-command.d.ts.map +1 -1
  137. package/dist/commands/restore-command.d.ts +2 -3
  138. package/dist/commands/restore-command.d.ts.map +1 -1
  139. package/dist/commands/rev-filter/commit-filter.d.ts +95 -0
  140. package/dist/commands/rev-filter/commit-filter.d.ts.map +1 -0
  141. package/dist/commands/rev-filter/commit-grep.d.ts +91 -0
  142. package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -0
  143. package/dist/commands/rev-filter/index.d.ts +3 -0
  144. package/dist/commands/rev-filter/index.d.ts.map +1 -0
  145. package/dist/commands/rev-list-command.d.ts +154 -2
  146. package/dist/commands/rev-list-command.d.ts.map +1 -1
  147. package/dist/commands/revert-command.d.ts +32 -0
  148. package/dist/commands/revert-command.d.ts.map +1 -1
  149. package/dist/commands/revision-range.d.ts +32 -1
  150. package/dist/commands/revision-range.d.ts.map +1 -1
  151. package/dist/commands/revision-resolver.d.ts +15 -0
  152. package/dist/commands/revision-resolver.d.ts.map +1 -1
  153. package/dist/commands/rm-command.d.ts +70 -2
  154. package/dist/commands/rm-command.d.ts.map +1 -1
  155. package/dist/commands/sequencer-pick.d.ts +84 -4
  156. package/dist/commands/sequencer-pick.d.ts.map +1 -1
  157. package/dist/commands/sequencer-support.d.ts +2 -0
  158. package/dist/commands/sequencer-support.d.ts.map +1 -1
  159. package/dist/commands/serve-repository.d.ts +7 -0
  160. package/dist/commands/serve-repository.d.ts.map +1 -1
  161. package/dist/commands/show-command.d.ts +130 -0
  162. package/dist/commands/show-command.d.ts.map +1 -0
  163. package/dist/commands/show-commit.d.ts +11 -0
  164. package/dist/commands/show-commit.d.ts.map +1 -0
  165. package/dist/commands/signature-check.d.ts +164 -0
  166. package/dist/commands/signature-check.d.ts.map +1 -0
  167. package/dist/commands/signing.d.ts +160 -0
  168. package/dist/commands/signing.d.ts.map +1 -0
  169. package/dist/commands/sparse-checkout-command.d.ts.map +1 -1
  170. package/dist/commands/sparse-index-view.d.ts +45 -0
  171. package/dist/commands/sparse-index-view.d.ts.map +1 -0
  172. package/dist/commands/ssh-signer.d.ts +29 -0
  173. package/dist/commands/ssh-signer.d.ts.map +1 -0
  174. package/dist/commands/ssh-verifier.d.ts +42 -0
  175. package/dist/commands/ssh-verifier.d.ts.map +1 -0
  176. package/dist/commands/stash-apply-command.d.ts +5 -0
  177. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  178. package/dist/commands/stash-branch-command.d.ts +34 -0
  179. package/dist/commands/stash-branch-command.d.ts.map +1 -0
  180. package/dist/commands/stash-create-command.d.ts +17 -0
  181. package/dist/commands/stash-create-command.d.ts.map +1 -1
  182. package/dist/commands/stash-info.d.ts +93 -0
  183. package/dist/commands/stash-info.d.ts.map +1 -0
  184. package/dist/commands/stash-list-command.d.ts +16 -0
  185. package/dist/commands/stash-list-command.d.ts.map +1 -1
  186. package/dist/commands/stash-pop-command.d.ts +39 -0
  187. package/dist/commands/stash-pop-command.d.ts.map +1 -0
  188. package/dist/commands/stash-show-command.d.ts +48 -0
  189. package/dist/commands/stash-show-command.d.ts.map +1 -0
  190. package/dist/commands/stash-store-command.d.ts +29 -0
  191. package/dist/commands/stash-store-command.d.ts.map +1 -0
  192. package/dist/commands/stash-working-tree.d.ts.map +1 -1
  193. package/dist/commands/status-command.d.ts.map +1 -1
  194. package/dist/commands/status-header.d.ts +5 -0
  195. package/dist/commands/status-header.d.ts.map +1 -1
  196. package/dist/commands/submodule-add-command.d.ts +89 -0
  197. package/dist/commands/submodule-add-command.d.ts.map +1 -0
  198. package/dist/commands/submodule-auth.d.ts +90 -0
  199. package/dist/commands/submodule-auth.d.ts.map +1 -0
  200. package/dist/commands/submodule-commands.d.ts +375 -0
  201. package/dist/commands/submodule-commands.d.ts.map +1 -0
  202. package/dist/commands/submodule-model.d.ts +288 -0
  203. package/dist/commands/submodule-model.d.ts.map +1 -0
  204. package/dist/commands/submodule-update-command.d.ts +198 -0
  205. package/dist/commands/submodule-update-command.d.ts.map +1 -0
  206. package/dist/commands/switch-command.d.ts.map +1 -1
  207. package/dist/commands/tag-command.d.ts +259 -10
  208. package/dist/commands/tag-command.d.ts.map +1 -1
  209. package/dist/commands/trailers.d.ts +218 -17
  210. package/dist/commands/trailers.d.ts.map +1 -1
  211. package/dist/commands/tree-restore.d.ts +7 -0
  212. package/dist/commands/tree-restore.d.ts.map +1 -1
  213. package/dist/commands/verify-command.d.ts +92 -0
  214. package/dist/commands/verify-command.d.ts.map +1 -0
  215. package/dist/commands/worktree-add-command.d.ts +79 -7
  216. package/dist/commands/worktree-add-command.d.ts.map +1 -1
  217. package/dist/commands/worktree-path-rules.d.ts +66 -0
  218. package/dist/commands/worktree-path-rules.d.ts.map +1 -0
  219. package/dist/commands/worktree-remove-command.d.ts +10 -3
  220. package/dist/commands/worktree-remove-command.d.ts.map +1 -1
  221. package/dist/commands/worktree-repair-command.d.ts +15 -2
  222. package/dist/commands/worktree-repair-command.d.ts.map +1 -1
  223. package/dist/commands/worktree-support.d.ts +5 -0
  224. package/dist/commands/worktree-support.d.ts.map +1 -1
  225. package/dist/{commands-DIJ91NnD.js → commands-ISM52N0n.js} +70736 -54492
  226. package/dist/errors/checkout-errors.d.ts +19 -0
  227. package/dist/errors/checkout-errors.d.ts.map +1 -1
  228. package/dist/errors/command-errors.d.ts.map +1 -1
  229. package/dist/errors/index.js +57 -3
  230. package/dist/errors/ref-errors.d.ts +19 -0
  231. package/dist/errors/ref-errors.d.ts.map +1 -1
  232. package/dist/errors/worktree-errors.d.ts +6 -1
  233. package/dist/errors/worktree-errors.d.ts.map +1 -1
  234. package/dist/{git-command-BGiOJ8Zk.js → fsck-DLRpbwTj.js} +6230 -71
  235. package/dist/git-command.d.ts +27 -1
  236. package/dist/git-command.d.ts.map +1 -1
  237. package/dist/git.d.ts +267 -1
  238. package/dist/git.d.ts.map +1 -1
  239. package/dist/index.js +5 -5
  240. package/dist/remote-config/index.d.ts +1 -1
  241. package/dist/remote-config/index.d.ts.map +1 -1
  242. package/dist/remote-config/remote-config-store.d.ts +55 -0
  243. package/dist/remote-config/remote-config-store.d.ts.map +1 -1
  244. package/dist/results/combined-diff.d.ts +3 -0
  245. package/dist/results/combined-diff.d.ts.map +1 -1
  246. package/dist/results/diff-check.d.ts +38 -0
  247. package/dist/results/diff-check.d.ts.map +1 -0
  248. package/dist/results/diff-color.d.ts +135 -0
  249. package/dist/results/diff-color.d.ts.map +1 -0
  250. package/dist/results/diff-output.d.ts +85 -1
  251. package/dist/results/diff-output.d.ts.map +1 -1
  252. package/dist/results/diff-pickaxe.d.ts +67 -0
  253. package/dist/results/diff-pickaxe.d.ts.map +1 -0
  254. package/dist/results/diff-words.d.ts +55 -0
  255. package/dist/results/diff-words.d.ts.map +1 -0
  256. package/dist/results/index.d.ts +4 -0
  257. package/dist/results/index.d.ts.map +1 -1
  258. package/dist/results/index.js +2 -2
  259. package/dist/results/push-result.d.ts +7 -0
  260. package/dist/results/push-result.d.ts.map +1 -1
  261. package/dist/results/rebase-result.d.ts +2 -0
  262. package/dist/results/rebase-result.d.ts.map +1 -1
  263. package/dist/results/stash-result.d.ts +6 -0
  264. package/dist/results/stash-result.d.ts.map +1 -1
  265. package/dist/{results-WVlBhVb1.js → results-TB2IJ64h.js} +2168 -403
  266. package/dist/whitespace/index.d.ts +2 -0
  267. package/dist/whitespace/index.d.ts.map +1 -0
  268. package/dist/whitespace/whitespace-rule.d.ts +94 -0
  269. package/dist/whitespace/whitespace-rule.d.ts.map +1 -0
  270. package/package.json +12 -12
  271. package/src/commands/add-command.ts +178 -17
  272. package/src/commands/am/am-command.ts +262 -42
  273. package/src/commands/am/index.ts +1 -0
  274. package/src/commands/am/mailsplit.ts +326 -0
  275. package/src/commands/apply/apply-command.ts +6 -6
  276. package/src/commands/apply/apply-engine.ts +1 -1
  277. package/src/commands/apply/apply-parse.ts +7 -8
  278. package/src/commands/bisect/bisect-command.ts +18 -5
  279. package/src/commands/branch-command.ts +528 -53
  280. package/src/commands/branch-info-command.ts +150 -0
  281. package/src/commands/branch-tracking.ts +335 -60
  282. package/src/commands/branch-upstream-command.ts +218 -0
  283. package/src/commands/checkout-command.ts +69 -43
  284. package/src/commands/cherry-pick-command.ts +143 -0
  285. package/src/commands/clean-command.ts +34 -3
  286. package/src/commands/clone-command.ts +2 -1
  287. package/src/commands/commit-command.ts +782 -64
  288. package/src/commands/commit-reuse.ts +94 -0
  289. package/src/commands/config-command.ts +1256 -0
  290. package/src/commands/config-value-types.ts +358 -0
  291. package/src/commands/core-config.ts +40 -0
  292. package/src/commands/diff-color-config.ts +274 -0
  293. package/src/commands/diff-command.ts +1009 -49
  294. package/src/commands/fetch-command.ts +142 -8
  295. package/src/commands/fmt-merge-msg-command.ts +715 -0
  296. package/src/commands/fork-point.ts +63 -0
  297. package/src/commands/format-patch-command.ts +314 -46
  298. package/src/commands/fsck/fetch-fsck.ts +172 -18
  299. package/src/commands/gc-command.ts +31 -1
  300. package/src/commands/git-describe.ts +31 -11
  301. package/src/commands/git-hooks.ts +81 -0
  302. package/src/commands/grep/grep-command.ts +1077 -0
  303. package/src/commands/grep/grep-engine.ts +1024 -0
  304. package/src/commands/grep/index.ts +2 -0
  305. package/src/commands/index-adder.ts +46 -7
  306. package/src/commands/index.ts +26 -0
  307. package/src/commands/interpret-trailers-command.ts +256 -0
  308. package/src/commands/local-transport.ts +109 -10
  309. package/src/commands/log-command.ts +1246 -210
  310. package/src/commands/log-graph.ts +123 -26
  311. package/src/commands/log-output.ts +280 -21
  312. package/src/commands/ls-remote-command.ts +5 -0
  313. package/src/commands/mailmap.ts +119 -0
  314. package/src/commands/merge-base-command.ts +170 -0
  315. package/src/commands/merge-bases.ts +63 -8
  316. package/src/commands/merge-command.ts +330 -82
  317. package/src/commands/merge-support.ts +14 -1
  318. package/src/commands/mv-command.ts +6 -3
  319. package/src/commands/name-rev.ts +171 -0
  320. package/src/commands/notes-command.ts +11 -1
  321. package/src/commands/pathspec-file.ts +72 -0
  322. package/src/commands/pathspec.ts +14 -2
  323. package/src/commands/pretty-format.ts +103 -19
  324. package/src/commands/promisor-remote.ts +10 -1
  325. package/src/commands/pull-command.ts +26 -7
  326. package/src/commands/push-command.ts +682 -65
  327. package/src/commands/read-tree-command.ts +28 -1
  328. package/src/commands/rebase-command.ts +933 -129
  329. package/src/commands/ref-filter/for-each-ref-command.ts +298 -0
  330. package/src/commands/ref-filter/index.ts +7 -0
  331. package/src/commands/ref-filter/ref-atoms.ts +581 -0
  332. package/src/commands/ref-filter/ref-filter.ts +651 -0
  333. package/src/commands/ref-filter/ref-format.ts +1070 -0
  334. package/src/commands/ref-filter/ref-listing-command.ts +421 -0
  335. package/src/commands/ref-filter/ref-quote.ts +69 -0
  336. package/src/commands/ref-filter/version-compare.ts +177 -0
  337. package/src/commands/reflog-command.ts +492 -2
  338. package/src/commands/reflog-walk.ts +234 -0
  339. package/src/commands/remote-command.ts +449 -69
  340. package/src/commands/remote-transport.ts +9 -1
  341. package/src/commands/reset-command.ts +36 -31
  342. package/src/commands/restore-command.ts +12 -41
  343. package/src/commands/rev-filter/commit-filter.ts +159 -0
  344. package/src/commands/rev-filter/commit-grep.ts +444 -0
  345. package/src/commands/rev-filter/index.ts +2 -0
  346. package/src/commands/rev-list-command.ts +402 -15
  347. package/src/commands/revert-command.ts +82 -0
  348. package/src/commands/revision-range.ts +204 -4
  349. package/src/commands/revision-resolver.ts +23 -8
  350. package/src/commands/rm-command.ts +282 -21
  351. package/src/commands/sequencer-pick.ts +498 -85
  352. package/src/commands/sequencer-support.ts +20 -2
  353. package/src/commands/serve-repository.ts +18 -3
  354. package/src/commands/show-command.ts +490 -0
  355. package/src/commands/show-commit.ts +24 -0
  356. package/src/commands/signature-check.ts +657 -0
  357. package/src/commands/signing.ts +385 -0
  358. package/src/commands/sparse-checkout-command.ts +2 -9
  359. package/src/commands/sparse-checkout-support.ts +2 -2
  360. package/src/commands/sparse-index-view.ts +135 -0
  361. package/src/commands/ssh-signer.ts +199 -0
  362. package/src/commands/ssh-verifier.ts +523 -0
  363. package/src/commands/stash-apply-command.ts +16 -4
  364. package/src/commands/stash-branch-command.ts +88 -0
  365. package/src/commands/stash-create-command.ts +28 -0
  366. package/src/commands/stash-info.ts +243 -0
  367. package/src/commands/stash-list-command.ts +33 -0
  368. package/src/commands/stash-pop-command.ts +83 -0
  369. package/src/commands/stash-show-command.ts +141 -0
  370. package/src/commands/stash-store-command.ts +82 -0
  371. package/src/commands/stash-working-tree.ts +2 -2
  372. package/src/commands/status-command.ts +5 -2
  373. package/src/commands/status-header.ts +41 -7
  374. package/src/commands/submodule-add-command.ts +509 -0
  375. package/src/commands/submodule-auth.ts +276 -0
  376. package/src/commands/submodule-commands.ts +1517 -0
  377. package/src/commands/submodule-model.ts +930 -0
  378. package/src/commands/submodule-update-command.ts +1092 -0
  379. package/src/commands/switch-command.ts +3 -1
  380. package/src/commands/tag-command.ts +876 -64
  381. package/src/commands/trailers.ts +837 -100
  382. package/src/commands/tree-restore.ts +38 -10
  383. package/src/commands/verify-command.ts +235 -0
  384. package/src/commands/worktree-add-command.ts +268 -24
  385. package/src/commands/worktree-path-rules.ts +183 -0
  386. package/src/commands/worktree-remove-command.ts +39 -5
  387. package/src/commands/worktree-repair-command.ts +52 -5
  388. package/src/commands/worktree-support.ts +22 -1
  389. package/src/errors/checkout-errors.ts +29 -0
  390. package/src/errors/command-errors.ts +2 -1
  391. package/src/errors/ref-errors.ts +23 -0
  392. package/src/errors/worktree-errors.ts +8 -1
  393. package/src/git-command.ts +66 -1
  394. package/src/git.ts +404 -1
  395. package/src/remote-config/index.ts +2 -0
  396. package/src/remote-config/remote-config-store.ts +101 -0
  397. package/src/results/combined-diff.ts +38 -18
  398. package/src/results/diff-check.ts +185 -0
  399. package/src/results/diff-color.ts +868 -0
  400. package/src/results/diff-output.ts +195 -30
  401. package/src/results/diff-pickaxe.ts +304 -0
  402. package/src/results/diff-words.ts +395 -0
  403. package/src/results/index.ts +4 -0
  404. package/src/results/push-result.ts +7 -0
  405. package/src/results/rebase-result.ts +3 -0
  406. package/src/results/stash-result.ts +7 -0
  407. package/src/whitespace/index.ts +1 -0
  408. package/src/{commands/apply/whitespace.ts → whitespace/whitespace-rule.ts} +173 -23
  409. package/dist/commands/apply/whitespace.d.ts +0 -58
  410. package/dist/commands/apply/whitespace.d.ts.map +0 -1
@@ -1,6 +1,21 @@
1
- import type { ReflogEntry } from "@statewalker/vcs-core";
2
-
1
+ import type { FilesApi, GitObjects, ReflogEntry } from "@statewalker/vcs-core";
2
+ import { isValidRefName, PromisorFetchError } from "@statewalker/vcs-core";
3
+ import {
4
+ dropReflogs,
5
+ type ExpireReflogsOptions,
6
+ expireReflogs,
7
+ parseExpiryDate,
8
+ type ReflogEntrySelector,
9
+ ReflogExpiryAbortedError,
10
+ ReflogExpiryConfigError,
11
+ writeReflogEntry,
12
+ } from "@statewalker/vcs-store-files";
13
+ import { approxidateCareful } from "@statewalker/vcs-utils";
14
+ import { GitApiError } from "../errors/index.js";
3
15
  import { GitCommand } from "../git-command.js";
16
+ import { hostEnvironmentOf } from "./git-ident.js";
17
+ import type { LogOutputOptions } from "./log-output.js";
18
+ import { RevListCommand } from "./rev-list-command.js";
4
19
 
5
20
  /**
6
21
  * Read reflog entries for a ref.
@@ -26,10 +41,108 @@ import { GitCommand } from "../git-command.js";
26
41
  * for (const entry of entries) {
27
42
  * console.log(`${entry.newId.slice(0, 7)} ${entry.comment}`);
28
43
  * }
44
+ *
45
+ * // git reflog show -2 main: "1a2b3c4 main@{0}: commit: Second\n..."
46
+ * const text = await git.reflog().setRef("main").setMaxCount(2).callText();
47
+ *
48
+ * // git reflog exists refs/heads/main
49
+ * const exists = await git.reflog().setRef("refs/heads/main").callExists();
50
+ *
51
+ * // git reflog expire --expire=now --all; git reflog delete --rewrite main@{1}
52
+ * await git.reflog().setExpire("now").setAll(true).callExpire();
53
+ * await git.reflog().setRewrite(true).callDelete("main@{1}");
29
54
  * ```
30
55
  */
31
56
  export class ReflogCommand extends GitCommand<ReflogEntry[]> {
32
57
  private ref = "HEAD";
58
+ private maxCount?: number;
59
+ private warnings: string[] = [];
60
+ private compatibility?: "2.43" | "2.56";
61
+ private expire?: string | number;
62
+ private expireUnreachable?: string | number;
63
+ private all = false;
64
+ private singleWorktree = false;
65
+ private staleFix = false;
66
+ private rewrite = false;
67
+ private updateRef = false;
68
+ private dryRun = false;
69
+ private verbose = false;
70
+
71
+ /**
72
+ * The git version to follow: 2.43 has no `reflog write` and `reflog drop` (git reads them
73
+ * as a revision and dies). Default: the hooks' compatibility.
74
+ */
75
+ setCompatibility(version: "2.43" | "2.56"): this {
76
+ this.checkCallable();
77
+ this.compatibility = version;
78
+ return this;
79
+ }
80
+
81
+ /**
82
+ * `--expire=<time>` of `expire`: entries older go (a git expiry date: `now`/`all`,
83
+ * `never`/`false`, `90.days.ago`, an epoch; a number is seconds since the epoch).
84
+ */
85
+ setExpire(time: string | number): this {
86
+ this.checkCallable();
87
+ this.expire = time;
88
+ return this;
89
+ }
90
+
91
+ /** `--expire-unreachable=<time>` of `expire`: older entries the ref's tip does not reach go. */
92
+ setExpireUnreachable(time: string | number): this {
93
+ this.checkCallable();
94
+ this.expireUnreachable = time;
95
+ return this;
96
+ }
97
+
98
+ /** `--all` of `expire` and `drop`: every reflog of every worktree. */
99
+ setAll(all: boolean): this {
100
+ this.checkCallable();
101
+ this.all = all;
102
+ return this;
103
+ }
104
+
105
+ /** `--single-worktree` (with `--all`): the current worktree's reflogs and the shared ones. */
106
+ setSingleWorktree(single: boolean): this {
107
+ this.checkCallable();
108
+ this.singleWorktree = single;
109
+ return this;
110
+ }
111
+
112
+ /** `--stale-fix` of `expire`: entries naming commits with missing history or trees go. */
113
+ setStaleFix(staleFix: boolean): this {
114
+ this.checkCallable();
115
+ this.staleFix = staleFix;
116
+ return this;
117
+ }
118
+
119
+ /** `--rewrite`: each kept entry's old id becomes the new id of the kept entry before it. */
120
+ setRewrite(rewrite: boolean): this {
121
+ this.checkCallable();
122
+ this.rewrite = rewrite;
123
+ return this;
124
+ }
125
+
126
+ /** `--updateref`: the ref (not a symbolic one) set to the newest kept entry's new id. */
127
+ setUpdateRef(updateRef: boolean): this {
128
+ this.checkCallable();
129
+ this.updateRef = updateRef;
130
+ return this;
131
+ }
132
+
133
+ /** `-n`/`--dry-run`: nothing written. */
134
+ setDryRun(dryRun: boolean): this {
135
+ this.checkCallable();
136
+ this.dryRun = dryRun;
137
+ return this;
138
+ }
139
+
140
+ /** `--verbose`: `keep`/`prune`/`would prune <message>` per entry in the output. */
141
+ setVerbose(verbose: boolean): this {
142
+ this.checkCallable();
143
+ this.verbose = verbose;
144
+ return this;
145
+ }
33
146
 
34
147
  /**
35
148
  * Set the ref to show reflog for.
@@ -42,6 +155,334 @@ export class ReflogCommand extends GitCommand<ReflogEntry[]> {
42
155
  return this;
43
156
  }
44
157
 
158
+ /** `-<n>` / `-n <n>` of `git reflog show`: at most `n` entries. */
159
+ setMaxCount(maxCount: number): this {
160
+ this.checkCallable();
161
+ this.maxCount = maxCount;
162
+ return this;
163
+ }
164
+
165
+ /**
166
+ * `git reflog [show] [<ref>]`'s output: `git log -g --abbrev-commit --pretty=oneline` of
167
+ * the ref (`%h <ref>@{n}: <message>` per entry; the ref may carry a selector, `main@{2}`,
168
+ * `HEAD@{now}`). `options` are log options over those defaults (`{ pretty: "short" }`
169
+ * still abbreviates, `{ abbrevCommit: false }` is `--no-abbrev-commit`). Throws where git
170
+ * dies (a ref that names nothing: `ambiguous argument`); {@link getWarnings} holds what it
171
+ * warned.
172
+ */
173
+ async callText(options: LogOutputOptions = {}): Promise<string> {
174
+ this.checkCallable();
175
+ this.setCallable(false);
176
+ const command = new RevListCommand(this._workingCopy)
177
+ .setWalkReflogs(true)
178
+ .addRevision(this.ref);
179
+ if (this.maxCount !== undefined) command.setMaxCount(this.maxCount);
180
+ try {
181
+ const pretty = options.oneline ? {} : { pretty: "oneline" };
182
+ return await command.callLogText({ ...pretty, abbrevCommit: true, ...options });
183
+ } finally {
184
+ this.warnings = command.getWarnings();
185
+ }
186
+ }
187
+
188
+ /** What {@link callText} warned while reading the ref (`warning: log for ...`). */
189
+ getWarnings(): string[] {
190
+ return [...this.warnings];
191
+ }
192
+
193
+ /**
194
+ * `git reflog exists <ref>`: whether the ref (a full name, `refs/heads/main`, or `HEAD`)
195
+ * has a reflog, an empty one too.
196
+ */
197
+ async callExists(): Promise<boolean> {
198
+ this.checkCallable();
199
+ this.setCallable(false);
200
+ if (!isValidRefName(this.ref, { allowOneLevel: true })) {
201
+ throw new GitApiError(`fatal: invalid ref format: ${this.ref}`);
202
+ }
203
+ const reader = await this.refsStore.getReflog?.(this.ref).catch(() => undefined);
204
+ return reader !== undefined;
205
+ }
206
+
207
+ /**
208
+ * `git reflog expire [<refs>...]` (builtin/reflog.c, reflog.c, files_reflog_expire /
209
+ * reftable_be_reflog_expire): the entries of each reflog named (`main`, `HEAD`, by git's
210
+ * ref rules), or of every reflog with {@link setAll}, older than `--expire` (default
211
+ * `gc.reflogExpire`, `gc.<pattern>.reflogExpire`, 90 days; `refs/stash` never), or older
212
+ * than `--expire-unreachable` (`gc.reflogExpireUnreachable`, 30 days) and not reached from
213
+ * the ref's tip (a HEAD's: from any ref), go. Returns git's stdout (`--verbose`), its error
214
+ * lines and its exit status (255 when a reflog could not be found or locked); throws where
215
+ * git dies (an invalid time, a bad `gc.reflogExpire*` value).
216
+ */
217
+ async callExpire(...refs: string[]): Promise<ReflogUpdateResult> {
218
+ this.checkCallable();
219
+ this.setCallable(false);
220
+ const repository = await this.reflogRepository();
221
+ const now = this.clock();
222
+ const flag = (value: string | number | undefined, name: string) => {
223
+ if (value === undefined || typeof value === "number") return value;
224
+ try {
225
+ return parseExpiryDate(value, now, `--${name}`);
226
+ } catch (error) {
227
+ if (!(error instanceof ReflogExpiryConfigError)) throw error;
228
+ throw new GitApiError(`fatal: invalid timestamp '${value}' given to '--${name}'`);
229
+ }
230
+ };
231
+ const expire = flag(this.expire, "expire");
232
+ const expireUnreachable = flag(this.expireUnreachable, "expire-unreachable");
233
+ const base = {
234
+ ...repository.options,
235
+ now,
236
+ ...(expire !== undefined ? { expire } : {}),
237
+ ...(expireUnreachable !== undefined ? { expireUnreachable } : {}),
238
+ staleFix: this.staleFix,
239
+ rewrite: this.rewrite,
240
+ updateRef: this.updateRef,
241
+ dryRun: this.dryRun,
242
+ verbose: this.verbose,
243
+ singleWorktree: this.singleWorktree,
244
+ compatibility: this.compatibility ?? this.hooks.compatibility,
245
+ };
246
+ const result: ReflogUpdateResult = { status: 0, output: "", errors: [] };
247
+ const run = async (options: ExpireReflogsOptions) => {
248
+ try {
249
+ const r = await expireReflogs(options);
250
+ result.output += r.output;
251
+ result.errors.push(...(r.warnings ?? []));
252
+ if (r.errors.length > 0) {
253
+ result.errors.push(...r.errors);
254
+ result.status = 255;
255
+ }
256
+ } catch (error) {
257
+ if (error instanceof ReflogExpiryConfigError) {
258
+ throw new GitApiError(`fatal: ${error.message}`);
259
+ }
260
+ const fetch = error instanceof ReflogExpiryAbortedError ? error.cause : undefined;
261
+ if (fetch instanceof PromisorFetchError) {
262
+ // promisor_remote_get_direct dies: the fetch's lines, then its own
263
+ result.output += (error as ReflogExpiryAbortedError).output;
264
+ result.errors.push(...fetch.warnings, `fatal: ${fetch.message}`);
265
+ result.status = 128;
266
+ return;
267
+ }
268
+ throw error instanceof ReflogExpiryAbortedError ? error.cause : error;
269
+ }
270
+ };
271
+ // --stale-fix marks once, then every reflog (--all) and those named are expired
272
+ const names: string[] = [];
273
+ for (const ref of refs) {
274
+ const found = await this.dwimLog(ref, repository.worktree);
275
+ if (!found) {
276
+ result.errors.push(
277
+ base.compatibility === "2.43"
278
+ ? `error: ${ref} points nowhere!`
279
+ : `error: reflog could not be found: '${ref}'`,
280
+ );
281
+ result.status = 255;
282
+ continue;
283
+ }
284
+ names.push(found);
285
+ }
286
+ if (this.all || names.length > 0) await run({ ...base, names, all: this.all });
287
+ return result;
288
+ }
289
+
290
+ /**
291
+ * `git reflog delete <ref>@{<n>|<date>}...` (reflog_delete): the entry each selector
292
+ * names is removed (`@{<date>}`: the newest entry older than the date), honouring
293
+ * {@link setRewrite}, {@link setUpdateRef}, {@link setDryRun} and {@link setVerbose}. A
294
+ * selector past the end deletes nothing.
295
+ */
296
+ async callDelete(...revisions: string[]): Promise<ReflogUpdateResult> {
297
+ this.checkCallable();
298
+ this.setCallable(false);
299
+ const result: ReflogUpdateResult = { status: 0, output: "", errors: [] };
300
+ if (revisions.length === 0) {
301
+ return { status: 255, output: "", errors: ["error: no reflog specified to delete"] };
302
+ }
303
+ const repository = await this.reflogRepository();
304
+ for (const rev of revisions) {
305
+ const at = rev.indexOf("@{");
306
+ if (at < 0) {
307
+ result.errors.push(`error: not a reflog: ${rev}`);
308
+ result.status = 255;
309
+ continue;
310
+ }
311
+ const found = await this.dwimLog(rev.slice(0, at), repository.worktree);
312
+ if (!found) {
313
+ result.errors.push(`error: no reflog for '${rev}'`);
314
+ result.status = 255;
315
+ continue;
316
+ }
317
+ const spec = rev.slice(at + 2);
318
+ const recno = strtoulPrefix(spec);
319
+ let select: ReflogEntrySelector;
320
+ if (spec[recno.end] === "}") select = { index: recno.value };
321
+ else {
322
+ const text = spec.endsWith("}") ? spec.slice(0, -1) : spec;
323
+ select = { before: approxidateCareful(text, this.clock()).timestamp };
324
+ }
325
+ const r = await expireReflogs({
326
+ ...repository.options,
327
+ now: this.clock(),
328
+ names: [found],
329
+ select,
330
+ rewrite: this.rewrite,
331
+ updateRef: this.updateRef,
332
+ dryRun: this.dryRun,
333
+ verbose: this.verbose,
334
+ });
335
+ result.output += r.output;
336
+ if (r.errors.length > 0) {
337
+ result.errors.push(...r.errors);
338
+ result.status = 255;
339
+ }
340
+ }
341
+ return result;
342
+ }
343
+
344
+ /**
345
+ * `git reflog drop [--all [--single-worktree] | <refs>...]` (git 2.5x): each reflog named,
346
+ * or every one, removed whole. Refused under 2.43 compatibility as git 2.43 refuses it.
347
+ */
348
+ async callDrop(...refs: string[]): Promise<ReflogUpdateResult> {
349
+ this.checkCallable();
350
+ this.setCallable(false);
351
+ this.refuseBefore251("drop");
352
+ if (refs.length > 0 && this.all) {
353
+ throw new GitApiError("usage: references specified along with --all", { exitCode: 129 });
354
+ }
355
+ const repository = await this.reflogRepository();
356
+ const { files, gitDir, refs: store } = repository.options;
357
+ const result: ReflogUpdateResult = { status: 0, output: "", errors: [] };
358
+ if (this.all) {
359
+ await dropReflogs({
360
+ files,
361
+ gitDir,
362
+ refs: store,
363
+ singleWorktree: this.singleWorktree,
364
+ ...(repository.worktree !== undefined ? { worktree: repository.worktree } : {}),
365
+ });
366
+ return result;
367
+ }
368
+ for (const ref of refs) {
369
+ const found = await this.dwimLog(ref, repository.worktree);
370
+ if (!found) {
371
+ result.errors.push(`error: reflog could not be found: '${ref}'`);
372
+ result.status = 255;
373
+ continue;
374
+ }
375
+ await dropReflogs({ files, gitDir, refs: store, names: [found] });
376
+ }
377
+ return result;
378
+ }
379
+
380
+ /**
381
+ * `git reflog write <ref> <old-oid> <new-oid> <message>` (git 2.5x): one line appended to
382
+ * the reflog of `ref` (a full name or a root ref; created when absent) with the committer
383
+ * ident, the ref left alone. Throws where git dies (an invalid name, an id that is not a
384
+ * full one or names a missing object); refused under 2.43 compatibility.
385
+ */
386
+ async callWrite(
387
+ ref: string,
388
+ oldId: string,
389
+ newId: string,
390
+ message: string,
391
+ ): Promise<ReflogUpdateResult> {
392
+ this.checkCallable();
393
+ this.setCallable(false);
394
+ this.refuseBefore251("write");
395
+ if (!isRootRef(ref) && !isValidRefName(ref)) {
396
+ throw new GitApiError(`fatal: invalid reference name: ${ref}`);
397
+ }
398
+ const format = this.objectFormat;
399
+ const objects = this.historyObjects();
400
+ const check = async (id: string, which: "old" | "new") => {
401
+ const m = new RegExp(`^[0-9a-fA-F]{${format.hexLength}}`).exec(id);
402
+ if (!m) throw new GitApiError(`fatal: invalid ${which} object ID: '${id}'`);
403
+ const full = m[0].toLowerCase();
404
+ if (!/^0+$/.test(full) && !(await objects.has(full))) {
405
+ throw new GitApiError(`fatal: ${which} object '${id}' does not exist`);
406
+ }
407
+ return full;
408
+ };
409
+ const oldFull = await check(oldId, "old");
410
+ const newFull = await check(newId, "new");
411
+ const repository = await this.reflogRepository();
412
+ const ident = this.reflogLine(message).ident as string;
413
+ const worktree = repository.worktree;
414
+ const name =
415
+ worktree !== undefined && isPerWorktree(ref) ? `worktrees/${worktree}/${ref}` : ref;
416
+ await writeReflogEntry({
417
+ files: repository.options.files,
418
+ gitDir: repository.options.gitDir,
419
+ refs: repository.options.refs,
420
+ name,
421
+ line: { oldId: oldFull, newId: newFull, ident, message },
422
+ });
423
+ return { status: 0, output: "", errors: [] };
424
+ }
425
+
426
+ /** git 2.43's cmd_reflog reads `write`/`drop` as a revision of `git reflog show`. */
427
+ private refuseBefore251(subcommand: string): void {
428
+ if ((this.compatibility ?? this.hooks.compatibility) !== "2.43") return;
429
+ throw new GitApiError(
430
+ `fatal: ambiguous argument '${subcommand}': unknown revision or path not in the working tree.\n` +
431
+ "Use '--' to separate paths from revisions, like this:\n" +
432
+ "'git <command> [<revision>...] -- [<file>...]'",
433
+ );
434
+ }
435
+
436
+ /** The objects of the repository (for the existence checks of `write`). */
437
+ private historyObjects(): GitObjects {
438
+ return (this.workingCopy.history as unknown as { objects: GitObjects }).objects;
439
+ }
440
+
441
+ /**
442
+ * What the reflog engine works on: the common git directory and its FilesApi, the refs,
443
+ * the objects, and the linked worktree this command runs in (its id).
444
+ */
445
+ private async reflogRepository(): Promise<{
446
+ options: ExpireReflogsOptions & { gitDir: string; files: FilesApi };
447
+ worktree: string | undefined;
448
+ }> {
449
+ const common = await this.hooks.commonGitFile("objects");
450
+ const own = await this.hooks.gitFile("objects");
451
+ if (!common || !own) throw new GitApiError("fatal: not a files repository");
452
+ const gitDir = common.path.replace(/\/?objects$/, "");
453
+ const ownDir = own.path.replace(/\/?objects$/, "");
454
+ const m = /\/worktrees\/([^/]+)$/.exec(ownDir);
455
+ const worktree = ownDir !== gitDir && m ? m[1] : undefined;
456
+ const environment = hostEnvironmentOf(this.workingCopy);
457
+ return {
458
+ options: {
459
+ files: common.files,
460
+ gitDir,
461
+ refs: this.refsStore,
462
+ objects: this.historyObjects(),
463
+ ...(environment ? { environment } : {}),
464
+ ...(worktree !== undefined ? { worktree } : {}),
465
+ },
466
+ worktree,
467
+ };
468
+ }
469
+
470
+ /**
471
+ * repo_dwim_log: the reflog `name` names by the ref rules, as the engine names it (a
472
+ * linked worktree's own refs as `worktrees/<id>/<ref>`); undefined when there is none.
473
+ */
474
+ private async dwimLog(name: string, worktree: string | undefined): Promise<string | undefined> {
475
+ const found = (
476
+ await this.revisionResolver()
477
+ .dwimLogRefs(name)
478
+ .catch(() => [])
479
+ )[0];
480
+ if (found === undefined) return undefined;
481
+ return worktree !== undefined && isPerWorktree(found)
482
+ ? `worktrees/${worktree}/${found}`
483
+ : found;
484
+ }
485
+
45
486
  /**
46
487
  * Execute the reflog command.
47
488
  *
@@ -66,3 +507,52 @@ export class ReflogCommand extends GitCommand<ReflogEntry[]> {
66
507
  return reader.getReverseEntries();
67
508
  }
68
509
  }
510
+
511
+ /** What `git reflog expire`, `delete`, `drop` and `write` print and exit with. */
512
+ export interface ReflogUpdateResult {
513
+ /** git's exit status: 0, or 255 when a reflog was not found or could not be changed */
514
+ status: number;
515
+ /** git's stdout (`--verbose` lines) */
516
+ output: string;
517
+ /** git's stderr lines (`error: ...`) */
518
+ errors: string[];
519
+ }
520
+
521
+ /** refs.c's is_root_ref (HEAD, `*_HEAD`, AUTO_MERGE and kin). */
522
+ function isRootRef(name: string): boolean {
523
+ if (!/^[A-Z_-]+$/.test(name)) return false;
524
+ if (name === "FETCH_HEAD" || name === "MERGE_HEAD") return false;
525
+ if (name.endsWith("_HEAD") || name === "HEAD") return true;
526
+ return [
527
+ "AUTO_MERGE",
528
+ "BISECT_EXPECTED_REV",
529
+ "NOTES_MERGE_PARTIAL",
530
+ "NOTES_MERGE_REF",
531
+ "MERGE_AUTOSTASH",
532
+ ].includes(name);
533
+ }
534
+
535
+ /** A ref every worktree has its own of (HEAD, root refs, `refs/bisect/` ...). */
536
+ function isPerWorktree(name: string): boolean {
537
+ return (
538
+ !name.startsWith("refs/") ||
539
+ name.startsWith("refs/bisect/") ||
540
+ name.startsWith("refs/worktree/") ||
541
+ name.startsWith("refs/rewritten/")
542
+ );
543
+ }
544
+
545
+ /**
546
+ * C's `strtoul(text, &end, 10)` as reflog_delete reads `@{<n>}`, the result then stored in an
547
+ * int: leading whitespace skipped, an optional sign (`-1` wraps to -1, a selector past the
548
+ * end), the digits; with no digits nothing is read (`end` 0, value 0).
549
+ */
550
+ function strtoulPrefix(text: string): { value: number; end: number } {
551
+ const m = /^[ \t\n\v\f\r]*([+-]?)(\d+)/.exec(text);
552
+ if (!m) return { value: 0, end: 0 };
553
+ let value = 0n;
554
+ for (const d of m[2] as string) value = (value * 10n + BigInt(d)) & 0xffffffffffffffffn;
555
+ if (m[1] === "-") value = (0x10000000000000000n - value) & 0xffffffffffffffffn;
556
+ // (int) of the unsigned long
557
+ return { value: Number(BigInt.asIntN(32, value)), end: m[0].length };
558
+ }