@statewalker/vcs-commands 0.13.0 → 0.15.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 (304) hide show
  1. package/dist/commands/add-command.d.ts.map +1 -1
  2. package/dist/commands/add-patch/patch-backend.d.ts +1 -1
  3. package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
  4. package/dist/commands/archive/archive-command.d.ts +6 -2
  5. package/dist/commands/archive/archive-command.d.ts.map +1 -1
  6. package/dist/commands/archive/remote-archive-command.d.ts +27 -2
  7. package/dist/commands/archive/remote-archive-command.d.ts.map +1 -1
  8. package/dist/commands/archive/upload-archive-writer.d.ts +11 -5
  9. package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -1
  10. package/dist/commands/branch-command.d.ts +14 -2
  11. package/dist/commands/branch-command.d.ts.map +1 -1
  12. package/dist/commands/bundle/bundle-format.d.ts +6 -1
  13. package/dist/commands/bundle/bundle-format.d.ts.map +1 -1
  14. package/dist/commands/bundle/bundle-uri-host.d.ts +12 -1
  15. package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -1
  16. package/dist/commands/bundle/bundle-uri.d.ts +7 -1
  17. package/dist/commands/bundle/bundle-uri.d.ts.map +1 -1
  18. package/dist/commands/bundle/bundle-verify.d.ts +4 -1
  19. package/dist/commands/bundle/bundle-verify.d.ts.map +1 -1
  20. package/dist/commands/cat-file/batch-format.d.ts +8 -12
  21. package/dist/commands/cat-file/batch-format.d.ts.map +1 -1
  22. package/dist/commands/cat-file/cat-file-command.d.ts +39 -5
  23. package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -1
  24. package/dist/commands/check-ignore-command.d.ts.map +1 -1
  25. package/dist/commands/checkout-command.d.ts +4 -0
  26. package/dist/commands/checkout-command.d.ts.map +1 -1
  27. package/dist/commands/checkout-paths.d.ts +9 -0
  28. package/dist/commands/checkout-paths.d.ts.map +1 -1
  29. package/dist/commands/cherry-pick-command.d.ts +3 -0
  30. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  31. package/dist/commands/clean-interactive.d.ts +0 -9
  32. package/dist/commands/clean-interactive.d.ts.map +1 -1
  33. package/dist/commands/clone-command.d.ts +17 -0
  34. package/dist/commands/clone-command.d.ts.map +1 -1
  35. package/dist/commands/column/column-config.d.ts +23 -0
  36. package/dist/commands/column/column-config.d.ts.map +1 -0
  37. package/dist/commands/column/column-layout.d.ts +129 -0
  38. package/dist/commands/column/column-layout.d.ts.map +1 -0
  39. package/dist/commands/column/index.d.ts +3 -0
  40. package/dist/commands/column/index.d.ts.map +1 -0
  41. package/dist/commands/column-command.d.ts +59 -0
  42. package/dist/commands/column-command.d.ts.map +1 -0
  43. package/dist/commands/comment-char-config.d.ts +15 -0
  44. package/dist/commands/comment-char-config.d.ts.map +1 -1
  45. package/dist/commands/commit-command.d.ts +30 -2
  46. package/dist/commands/commit-command.d.ts.map +1 -1
  47. package/dist/commands/config-command.d.ts +12 -0
  48. package/dist/commands/config-command.d.ts.map +1 -1
  49. package/dist/commands/credential-helper.d.ts +214 -0
  50. package/dist/commands/credential-helper.d.ts.map +1 -0
  51. package/dist/commands/default-branch.d.ts +33 -3
  52. package/dist/commands/default-branch.d.ts.map +1 -1
  53. package/dist/commands/diff-color-config.d.ts +4 -0
  54. package/dist/commands/diff-color-config.d.ts.map +1 -1
  55. package/dist/commands/diff-command.d.ts +12 -0
  56. package/dist/commands/diff-command.d.ts.map +1 -1
  57. package/dist/commands/fast-export/fast-export-command.d.ts +89 -2
  58. package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -1
  59. package/dist/commands/fast-export/fast-import-command.d.ts +113 -8
  60. package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -1
  61. package/dist/commands/fast-export/fast-stream-support.d.ts +0 -9
  62. package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -1
  63. package/dist/commands/fetch-command.d.ts +23 -1
  64. package/dist/commands/fetch-command.d.ts.map +1 -1
  65. package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -1
  66. package/dist/commands/git-hooks.d.ts +31 -3
  67. package/dist/commands/git-hooks.d.ts.map +1 -1
  68. package/dist/commands/history-command.d.ts +173 -7
  69. package/dist/commands/history-command.d.ts.map +1 -1
  70. package/dist/commands/index-host.d.ts +19 -0
  71. package/dist/commands/index-host.d.ts.map +1 -1
  72. package/dist/commands/index-refresh.d.ts +36 -0
  73. package/dist/commands/index-refresh.d.ts.map +1 -0
  74. package/dist/commands/index.d.ts +9 -0
  75. package/dist/commands/index.d.ts.map +1 -1
  76. package/dist/commands/index.js +7 -6
  77. package/dist/commands/init-command.d.ts +20 -0
  78. package/dist/commands/init-command.d.ts.map +1 -1
  79. package/dist/commands/local-transport.d.ts +40 -2
  80. package/dist/commands/local-transport.d.ts.map +1 -1
  81. package/dist/commands/log-command.d.ts +7 -0
  82. package/dist/commands/log-command.d.ts.map +1 -1
  83. package/dist/commands/log-output.d.ts +11 -0
  84. package/dist/commands/log-output.d.ts.map +1 -1
  85. package/dist/commands/ls-tree-command.d.ts +10 -0
  86. package/dist/commands/ls-tree-command.d.ts.map +1 -1
  87. package/dist/commands/maintenance-schedule-command.d.ts +122 -0
  88. package/dist/commands/maintenance-schedule-command.d.ts.map +1 -0
  89. package/dist/commands/merge-command.d.ts +13 -1
  90. package/dist/commands/merge-command.d.ts.map +1 -1
  91. package/dist/commands/merge-index-command.d.ts +42 -0
  92. package/dist/commands/merge-index-command.d.ts.map +1 -0
  93. package/dist/commands/merge-one-file.d.ts +129 -0
  94. package/dist/commands/merge-one-file.d.ts.map +1 -0
  95. package/dist/commands/merge-support.d.ts +40 -4
  96. package/dist/commands/merge-support.d.ts.map +1 -1
  97. package/dist/commands/object-disk-info.d.ts +35 -0
  98. package/dist/commands/object-disk-info.d.ts.map +1 -0
  99. package/dist/commands/octopus-merge.d.ts +3 -3
  100. package/dist/commands/octopus-merge.d.ts.map +1 -1
  101. package/dist/commands/plumbing-input.d.ts.map +1 -1
  102. package/dist/commands/promisor-remote-reply.d.ts +31 -4
  103. package/dist/commands/promisor-remote-reply.d.ts.map +1 -1
  104. package/dist/commands/promisor-remote.d.ts +8 -1
  105. package/dist/commands/promisor-remote.d.ts.map +1 -1
  106. package/dist/commands/pull-command.d.ts +55 -7
  107. package/dist/commands/pull-command.d.ts.map +1 -1
  108. package/dist/commands/push-command.d.ts +18 -1
  109. package/dist/commands/push-command.d.ts.map +1 -1
  110. package/dist/commands/range-diff/range-diff-command.d.ts +37 -1
  111. package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -1
  112. package/dist/commands/rebase-command.d.ts +13 -1
  113. package/dist/commands/rebase-command.d.ts.map +1 -1
  114. package/dist/commands/ref-filter/for-each-ref-command.d.ts +3 -2
  115. package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -1
  116. package/dist/commands/ref-filter/index.d.ts +1 -0
  117. package/dist/commands/ref-filter/index.d.ts.map +1 -1
  118. package/dist/commands/ref-filter/peel-limit.d.ts +8 -0
  119. package/dist/commands/ref-filter/peel-limit.d.ts.map +1 -0
  120. package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -1
  121. package/dist/commands/ref-filter/ref-format.d.ts +26 -1
  122. package/dist/commands/ref-filter/ref-format.d.ts.map +1 -1
  123. package/dist/commands/ref-filter/ref-listing-command.d.ts +9 -0
  124. package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -1
  125. package/dist/commands/remote-transport.d.ts +27 -0
  126. package/dist/commands/remote-transport.d.ts.map +1 -1
  127. package/dist/commands/repack-command.d.ts +18 -2
  128. package/dist/commands/repack-command.d.ts.map +1 -1
  129. package/dist/commands/repo-command.d.ts +2 -7
  130. package/dist/commands/repo-command.d.ts.map +1 -1
  131. package/dist/commands/reset-command.d.ts +4 -1
  132. package/dist/commands/reset-command.d.ts.map +1 -1
  133. package/dist/commands/restore-command.d.ts.map +1 -1
  134. package/dist/commands/rev-list-command.d.ts +65 -0
  135. package/dist/commands/rev-list-command.d.ts.map +1 -1
  136. package/dist/commands/revert-command.d.ts +3 -0
  137. package/dist/commands/revert-command.d.ts.map +1 -1
  138. package/dist/commands/revision-filenames.d.ts.map +1 -1
  139. package/dist/commands/revision-range.d.ts +17 -0
  140. package/dist/commands/revision-range.d.ts.map +1 -1
  141. package/dist/commands/revision-resolver.d.ts +12 -0
  142. package/dist/commands/revision-resolver.d.ts.map +1 -1
  143. package/dist/commands/serve-repository.d.ts +21 -4
  144. package/dist/commands/serve-repository.d.ts.map +1 -1
  145. package/dist/commands/served-lazy-fetch.d.ts +61 -0
  146. package/dist/commands/served-lazy-fetch.d.ts.map +1 -0
  147. package/dist/commands/signing.d.ts +37 -4
  148. package/dist/commands/signing.d.ts.map +1 -1
  149. package/dist/commands/split-cmdline.d.ts +6 -0
  150. package/dist/commands/split-cmdline.d.ts.map +1 -0
  151. package/dist/commands/status-color-config.d.ts +33 -0
  152. package/dist/commands/status-color-config.d.ts.map +1 -0
  153. package/dist/commands/status-command.d.ts +15 -0
  154. package/dist/commands/status-command.d.ts.map +1 -1
  155. package/dist/commands/status-format.d.ts +46 -4
  156. package/dist/commands/status-format.d.ts.map +1 -1
  157. package/dist/commands/tag-command.d.ts +15 -1
  158. package/dist/commands/tag-command.d.ts.map +1 -1
  159. package/dist/commands/tree-restore.d.ts +14 -0
  160. package/dist/commands/tree-restore.d.ts.map +1 -1
  161. package/dist/commands/verify-command.d.ts +22 -2
  162. package/dist/commands/verify-command.d.ts.map +1 -1
  163. package/dist/commands/worktree-add-command.d.ts.map +1 -1
  164. package/dist/commands/worktree-overwrite-checks.d.ts +31 -6
  165. package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
  166. package/dist/{commands-CPceUCP2.js → commands-DT3VEv50.js} +15168 -16842
  167. package/dist/errors/commit-errors.d.ts +37 -1
  168. package/dist/errors/commit-errors.d.ts.map +1 -1
  169. package/dist/errors/git-api-error.d.ts +6 -0
  170. package/dist/errors/git-api-error.d.ts.map +1 -1
  171. package/dist/errors/index.js +44 -3
  172. package/dist/{fsck-tbrPZX2q.js → fsck-BZ508Elg.js} +2 -2
  173. package/dist/git-command.d.ts +33 -1
  174. package/dist/git-command.d.ts.map +1 -1
  175. package/dist/git.d.ts +104 -1
  176. package/dist/git.d.ts.map +1 -1
  177. package/dist/index.js +8 -7
  178. package/dist/{remote-transport-C0OSJtor.js → local-transport-D98U6p4d.js} +228 -692
  179. package/dist/{maintenance-run-command-UiSIaeP8.js → maintenance-run-command-DZFnbnbo.js} +2366 -108
  180. package/dist/remote-config/remote-config-store.d.ts +6 -0
  181. package/dist/remote-config/remote-config-store.d.ts.map +1 -1
  182. package/dist/remote-transport-zvSqwpOB.js +4865 -0
  183. package/dist/results/cherry-pick-result.d.ts +4 -3
  184. package/dist/results/cherry-pick-result.d.ts.map +1 -1
  185. package/dist/results/diff-output.d.ts +7 -0
  186. package/dist/results/diff-output.d.ts.map +1 -1
  187. package/dist/results/diff-words.d.ts +14 -3
  188. package/dist/results/diff-words.d.ts.map +1 -1
  189. package/dist/results/index.js +1 -1
  190. package/dist/results/line-prefix-sink.d.ts +50 -0
  191. package/dist/results/line-prefix-sink.d.ts.map +1 -0
  192. package/dist/results/merge-result.d.ts +4 -3
  193. package/dist/results/merge-result.d.ts.map +1 -1
  194. package/dist/results/rebase-result.d.ts +5 -0
  195. package/dist/results/rebase-result.d.ts.map +1 -1
  196. package/dist/results/revert-result.d.ts +4 -3
  197. package/dist/results/revert-result.d.ts.map +1 -1
  198. package/dist/{results-CkS1p1CH.js → results-rF81cQse.js} +1788 -247
  199. package/dist/transport-command.d.ts +13 -0
  200. package/dist/transport-command.d.ts.map +1 -1
  201. package/package.json +21 -13
  202. package/src/commands/add-command.ts +15 -2
  203. package/src/commands/add-patch/patch-backend.ts +6 -44
  204. package/src/commands/archive/archive-command.ts +7 -3
  205. package/src/commands/archive/remote-archive-command.ts +45 -4
  206. package/src/commands/archive/upload-archive-writer.ts +34 -22
  207. package/src/commands/branch-command.ts +57 -4
  208. package/src/commands/bundle/bundle-format.ts +10 -2
  209. package/src/commands/bundle/bundle-uri-host.ts +71 -11
  210. package/src/commands/bundle/bundle-uri.ts +11 -4
  211. package/src/commands/bundle/bundle-verify.ts +4 -1
  212. package/src/commands/cat-file/batch-format.ts +17 -18
  213. package/src/commands/cat-file/cat-file-command.ts +182 -48
  214. package/src/commands/check-ignore-command.ts +110 -21
  215. package/src/commands/checkout-command.ts +149 -21
  216. package/src/commands/checkout-index-command.ts +2 -1
  217. package/src/commands/checkout-paths.ts +13 -0
  218. package/src/commands/cherry-pick-command.ts +9 -0
  219. package/src/commands/clean-interactive.ts +20 -74
  220. package/src/commands/clone-command.ts +102 -11
  221. package/src/commands/column/column-config.ts +63 -0
  222. package/src/commands/column/column-layout.ts +396 -0
  223. package/src/commands/column/index.ts +2 -0
  224. package/src/commands/column-command.ts +171 -0
  225. package/src/commands/comment-char-config.ts +42 -0
  226. package/src/commands/commit-command.ts +93 -18
  227. package/src/commands/config-command.ts +28 -0
  228. package/src/commands/credential-helper.ts +807 -0
  229. package/src/commands/default-branch.ts +57 -5
  230. package/src/commands/diff-color-config.ts +23 -10
  231. package/src/commands/diff-command.ts +25 -2
  232. package/src/commands/fast-export/fast-export-command.ts +661 -35
  233. package/src/commands/fast-export/fast-import-command.ts +694 -94
  234. package/src/commands/fast-export/fast-stream-support.ts +18 -1
  235. package/src/commands/fetch-command.ts +116 -16
  236. package/src/commands/fsck/fsck-object-checks.ts +3 -1
  237. package/src/commands/git-hooks.ts +96 -5
  238. package/src/commands/history-command.ts +952 -20
  239. package/src/commands/index-host.ts +51 -0
  240. package/src/commands/index-refresh.ts +121 -0
  241. package/src/commands/index.ts +9 -0
  242. package/src/commands/init-command.ts +57 -4
  243. package/src/commands/legacy-remotes.ts +4 -20
  244. package/src/commands/local-transport.ts +183 -18
  245. package/src/commands/log-command.ts +39 -1
  246. package/src/commands/log-output.ts +31 -4
  247. package/src/commands/ls-tree-command.ts +20 -12
  248. package/src/commands/maintenance-schedule-command.ts +418 -0
  249. package/src/commands/merge-command.ts +42 -8
  250. package/src/commands/merge-index-command.ts +202 -0
  251. package/src/commands/merge-one-file.ts +451 -0
  252. package/src/commands/merge-support.ts +169 -15
  253. package/src/commands/object-disk-info.ts +169 -0
  254. package/src/commands/octopus-merge.ts +37 -128
  255. package/src/commands/plumbing-input.ts +3 -1
  256. package/src/commands/promisor-remote-reply.ts +338 -56
  257. package/src/commands/promisor-remote.ts +39 -6
  258. package/src/commands/pull-command.ts +173 -27
  259. package/src/commands/push-command.ts +55 -6
  260. package/src/commands/range-diff/range-diff-command.ts +86 -3
  261. package/src/commands/read-tree-command.ts +2 -2
  262. package/src/commands/rebase-command.ts +46 -1
  263. package/src/commands/ref-filter/for-each-ref-command.ts +4 -3
  264. package/src/commands/ref-filter/index.ts +1 -0
  265. package/src/commands/ref-filter/peel-limit.ts +7 -0
  266. package/src/commands/ref-filter/ref-filter.ts +68 -7
  267. package/src/commands/ref-filter/ref-format.ts +85 -11
  268. package/src/commands/ref-filter/ref-listing-command.ts +30 -0
  269. package/src/commands/remote-command.ts +2 -2
  270. package/src/commands/remote-transport.ts +66 -3
  271. package/src/commands/repack-command.ts +75 -9
  272. package/src/commands/repo-command.ts +6 -70
  273. package/src/commands/reset-command.ts +11 -1
  274. package/src/commands/restore-command.ts +1 -0
  275. package/src/commands/rev-list-command.ts +205 -3
  276. package/src/commands/revert-command.ts +9 -0
  277. package/src/commands/revision-filenames.ts +32 -4
  278. package/src/commands/revision-range.ts +2 -2
  279. package/src/commands/revision-resolver.ts +21 -1
  280. package/src/commands/serve-repository.ts +42 -11
  281. package/src/commands/served-lazy-fetch.ts +164 -0
  282. package/src/commands/signing.ts +103 -12
  283. package/src/commands/split-cmdline.ts +32 -0
  284. package/src/commands/status-color-config.ts +92 -0
  285. package/src/commands/status-command.ts +50 -2
  286. package/src/commands/status-format.ts +198 -50
  287. package/src/commands/tag-command.ts +57 -2
  288. package/src/commands/tree-restore.ts +17 -0
  289. package/src/commands/verify-command.ts +84 -12
  290. package/src/commands/worktree-add-command.ts +2 -0
  291. package/src/commands/worktree-overwrite-checks.ts +75 -14
  292. package/src/errors/commit-errors.ts +52 -2
  293. package/src/errors/git-api-error.ts +7 -0
  294. package/src/git-command.ts +105 -4
  295. package/src/git.ts +153 -0
  296. package/src/remote-config/remote-config-store.ts +16 -0
  297. package/src/results/cherry-pick-result.ts +4 -3
  298. package/src/results/diff-output.ts +8 -0
  299. package/src/results/diff-words.ts +160 -32
  300. package/src/results/line-prefix-sink.ts +102 -0
  301. package/src/results/merge-result.ts +4 -3
  302. package/src/results/rebase-result.ts +5 -0
  303. package/src/results/revert-result.ts +4 -3
  304. package/src/transport-command.ts +79 -3
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Where diff.c's `diff_line_prefix` (the graph's padding under `log --graph`) goes in a diff
3
+ * output: a sink recording a position before every line pushed to it, except in the bytes a
4
+ * writer marks as placing the prefix itself (git's word diff writes it only where
5
+ * `fn_out_diff_words_write_helper` and `color_words_output_graph_prefix` put it). The log
6
+ * inserts the prefix afterwards ({@link insertLinePrefix}), once its graph has printed the
7
+ * commit's header and the padding is known.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const sink = new LinePrefixSink();
12
+ * sink.text("diff --git a/f b/f\n");
13
+ * sink.push(markLinePrefix(encodeGitPath("-old\n"), { before: 0, own: true }));
14
+ * insertLinePrefix(sink.bytes(), sink.points, encodeGitPath("| ")); // "| diff --git a/f b/f\n-old\n"
15
+ * ```
16
+ *
17
+ * Marks follow the chunk itself (a `WeakMap` of arrays), so they survive a sink that holds
18
+ * chunks before passing them on unchanged (`MovedLineBuffer`), but not one that joins them.
19
+ *
20
+ * @module
21
+ */
22
+
23
+ import { ByteSink } from "@statewalker/vcs-utils";
24
+
25
+ /** Where a marked chunk has the line prefix */
26
+ export interface LinePrefixMark {
27
+ /** How many prefixes go right before the chunk */
28
+ before: number;
29
+ /** The chunk places its prefixes itself: none at its line starts */
30
+ own: boolean;
31
+ }
32
+
33
+ const MARKS = new WeakMap<Uint8Array, LinePrefixMark>();
34
+
35
+ /**
36
+ * Marks `bytes` for a {@link LinePrefixSink}. The mark belongs to the array object: mark a
37
+ * view of its own (`bytes.subarray(0)`) for each push of shared bytes.
38
+ */
39
+ export function markLinePrefix(bytes: Uint8Array, mark: LinePrefixMark): Uint8Array {
40
+ MARKS.set(bytes, mark);
41
+ return bytes;
42
+ }
43
+
44
+ /** A byte sink recording where the line prefix goes: each line start, marked chunks aside */
45
+ export class LinePrefixSink extends ByteSink {
46
+ /** The offsets in the output where a prefix goes, ascending (one offset may repeat) */
47
+ readonly points: number[] = [];
48
+ private offset = 0;
49
+ private atLineStart = true;
50
+
51
+ /**
52
+ * A prefix at the current end of the output, written straight to the file (diff.c's
53
+ * `fputs(line_prefix)`): ahead of what a `MovedLineBuffer` still holds
54
+ */
55
+ addPoint(): void {
56
+ this.points.push(this.offset);
57
+ }
58
+
59
+ override push(bytes: Uint8Array): void {
60
+ if (bytes.length === 0) return;
61
+ const mark = MARKS.get(bytes);
62
+ for (let i = 0; i < (mark?.before ?? 0); i++) this.points.push(this.offset);
63
+ if (mark?.own) {
64
+ super.push(bytes);
65
+ this.offset += bytes.length;
66
+ // whatever git writes next through emit_line_0 (a context line, a hunk header, the
67
+ // next file's header) starts with the prefix
68
+ this.atLineStart = true;
69
+ return;
70
+ }
71
+ super.push(bytes);
72
+ let at = 0;
73
+ while (at < bytes.length) {
74
+ if (this.atLineStart) this.points.push(this.offset + at);
75
+ const nl = bytes.indexOf(0x0a, at);
76
+ this.atLineStart = nl >= 0;
77
+ at = nl < 0 ? bytes.length : nl + 1;
78
+ }
79
+ this.offset += bytes.length;
80
+ }
81
+ }
82
+
83
+ /** `bytes` with `prefix` inserted at each of `points` (ascending offsets) */
84
+ export function insertLinePrefix(
85
+ bytes: Uint8Array,
86
+ points: readonly number[],
87
+ prefix: Uint8Array,
88
+ ): Uint8Array {
89
+ if (points.length === 0 || prefix.length === 0) return bytes;
90
+ const out = new Uint8Array(bytes.length + points.length * prefix.length);
91
+ let size = 0;
92
+ let from = 0;
93
+ for (const point of points) {
94
+ out.set(bytes.subarray(from, point), size);
95
+ size += point - from;
96
+ out.set(prefix, size);
97
+ size += prefix.length;
98
+ from = point;
99
+ }
100
+ out.set(bytes.subarray(from), size);
101
+ return out;
102
+ }
@@ -136,9 +136,10 @@ export interface MergeResult {
136
136
  */
137
137
  readonly output?: string[];
138
138
  /**
139
- * What the sparse checkout printed on stderr while the result was written, line by line:
140
- * the patterns' warnings, git's "The following paths are not up to date and were left
141
- * despite sparse patterns:" block. Absent when there was nothing to say.
139
+ * Warnings git printed on stderr, line by line: first git 2.5x's `core.commentChar=auto`
140
+ * deprecation warning and its advice, then what the sparse checkout printed while the
141
+ * result was written (the patterns' warnings, git's "The following paths are not up to
142
+ * date and were left despite sparse patterns:" block). Absent when there was nothing to say.
142
143
  */
143
144
  readonly warnings?: string[];
144
145
  /**
@@ -173,6 +173,11 @@ export interface RebaseResult {
173
173
  * said nothing.
174
174
  */
175
175
  readonly rerereOutput?: string[];
176
+ /**
177
+ * What git printed on stderr as it started, line by line: git 2.5x's
178
+ * `core.commentChar=auto` deprecation warning and its advice. Absent when it said nothing.
179
+ */
180
+ readonly warnings?: string[];
176
181
  }
177
182
 
178
183
  /**
@@ -37,9 +37,10 @@ export interface RevertResult {
37
37
  /** What is printed on stdout: merge-ort's `Auto-merging f`, `CONFLICT (...)` lines */
38
38
  readonly output?: string[];
39
39
  /**
40
- * What the sparse checkout printed on stderr while the result was written, line by line:
41
- * the patterns' warnings, git's "The following paths are not up to date and were left
42
- * despite sparse patterns:" block. Absent when there was nothing to say.
40
+ * Warnings git printed on stderr, line by line: first git 2.5x's `core.commentChar=auto`
41
+ * deprecation warning and its advice, then what the sparse checkout printed while the
42
+ * result was written (the patterns' warnings, git's "The following paths are not up to
43
+ * date and were left despite sparse patterns:" block). Absent when there was nothing to say.
43
44
  */
44
45
  readonly warnings?: string[];
45
46
  /**
@@ -6,18 +6,23 @@ import {
6
6
  type HttpCredentialHelper,
7
7
  type ProgressInfo,
8
8
  } from "@statewalker/vcs-transport";
9
+ import type { ObjectFormat } from "@statewalker/vcs-utils/hash";
9
10
  import type { WorkingCopy } from "@statewalker/vcs-working-tree";
10
11
  import {
11
12
  type BundleUriHost,
12
13
  createBundleUriHost,
13
14
  fetchBundleUri,
14
15
  } from "./commands/bundle/index.js";
16
+ import { configuresCredentialHelper, credentialHelperOf } from "./commands/credential-helper.js";
17
+ import { hookRunnerOf } from "./commands/git-hooks.js";
15
18
  import { hostEnvironmentOf } from "./commands/git-ident.js";
16
19
  import { httpClientSettingsOf } from "./commands/http-config.js";
20
+ import { remoteHookSession } from "./commands/local-transport.js";
17
21
  import { createPromisorFetcher, promisorOf } from "./commands/promisor-remote.js";
18
22
  import {
19
23
  bundleRemoteOf,
20
24
  httpSessionSettings,
25
+ localLazyFetchOf,
21
26
  openResolvedRemote,
22
27
  type PreparedRemote,
23
28
  prepareRemote,
@@ -81,17 +86,21 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
81
86
  protected credentialHelper?: HttpCredentialHelper;
82
87
  /** git's `warning:` lines of the HTTP client */
83
88
  protected warningCallback?: (line: string) => void;
89
+ /** The helper built from `credential.helper` for this command (see {@link httpCredentialHelper}) */
90
+ private configCredentialHelper?: HttpCredentialHelper | null;
84
91
 
85
92
  constructor(workingCopy: WorkingCopy) {
86
93
  super(workingCopy);
87
94
  // a partial clone's lazy fetch during the call (a clone's checkout, a pull's merge) reaches
88
- // the promisor remote as this command does: its transports, credentials, headers, timeout;
95
+ // the promisor remote as this command does: its transports, credentials, headers, timeout,
96
+ // credential helper and warning sink;
89
97
  // the store's previous fetcher comes back when the call ends
90
98
  this.aroundEntryPoints(() => {
91
99
  if (
92
100
  !this.transportRegistry &&
93
101
  !this.credentials &&
94
102
  !this.headers &&
103
+ !this.credentialHelper &&
95
104
  this.timeout === undefined
96
105
  ) {
97
106
  return undefined;
@@ -102,6 +111,10 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
102
111
  const fetcher = createPromisorFetcher(this._workingCopy, {
103
112
  ...this.promisorFetcherAuth(),
104
113
  ...(this.timeout !== undefined ? { timeout: this.timeout } : {}),
114
+ // git's child fetch reads credential.helper: the helper is asked per URL, so the
115
+ // guarded commands hand it over too
116
+ ...(this.credentialHelper ? { credentialHelper: this.credentialHelper } : {}),
117
+ ...(this.warningCallback ? { warningCallback: this.warningCallback } : {}),
105
118
  });
106
119
  promisor.setFetcher(fetcher);
107
120
  return () => {
@@ -232,6 +245,24 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
232
245
  return this;
233
246
  }
234
247
 
248
+ /**
249
+ * The credential helper this command's HTTP requests ask: the one given to
250
+ * {@link setCredentialHelper}, else, when the configuration names a `credential.helper`
251
+ * and the host has a hook runner, git's helpers of that configuration (credential.c through
252
+ * {@link credentialHelperOf}: their stderr in the hook output), as git's transports read
253
+ * them; else none.
254
+ */
255
+ protected httpCredentialHelper(): HttpCredentialHelper | undefined {
256
+ if (this.credentialHelper) return this.credentialHelper;
257
+ if (this.configCredentialHelper === undefined) {
258
+ this.configCredentialHelper =
259
+ hookRunnerOf(this._workingCopy) && configuresCredentialHelper(this._workingCopy)
260
+ ? credentialHelperOf(this._workingCopy, { hooks: this.hooks })
261
+ : null;
262
+ }
263
+ return this.configCredentialHelper ?? undefined;
264
+ }
265
+
235
266
  /**
236
267
  * Receives the `warning:` lines git's HTTP client prints on stderr (`rate limited, waiting
237
268
  * <n> seconds before retry`).
@@ -349,8 +380,23 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
349
380
  ...(this.gzipRequests !== undefined ? { gzipRequests: this.gzipRequests } : {}),
350
381
  protocolVersion: protocolVersionOf(RemoteConfigStore.from(this._workingCopy)),
351
382
  httpSettings: (url) => this.httpSettingsFor(url),
352
- ...(this.credentialHelper ? { credentialHelper: this.credentialHelper } : {}),
383
+ ...credentialHelperOption(this.httpCredentialHelper()),
353
384
  ...httpSessionSettings(this._workingCopy),
385
+ // a local remote's upload-pack runs the protected uploadpack.packObjectsHook through
386
+ // this host's runner, in the remote's git directory, with local_repo_env cleared
387
+ localHooks: (remote) => remoteHookSession(this._workingCopy, remote, { localPush: true }),
388
+ // GIT_NAMESPACE: what a local remote's upload-pack and receive-pack serve
389
+ ...(() => {
390
+ const namespace = hostEnvironmentOf(this._workingCopy)?.namespace;
391
+ return namespace ? { namespace } : {};
392
+ })(),
393
+ // GIT_NO_LAZY_FETCH=0: a local remote's upload-pack fetches what it lacks
394
+ ...localLazyFetchOf(hostEnvironmentOf(this._workingCopy), {
395
+ transports: this.getTransports(),
396
+ ...(this.credentialHelper ? { credentialHelper: this.credentialHelper } : {}),
397
+ ...(this.timeout !== undefined ? { timeout: this.timeout } : {}),
398
+ ...(this.warningCallback ? { warningCallback: this.warningCallback } : {}),
399
+ }),
354
400
  };
355
401
  }
356
402
 
@@ -398,10 +444,33 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
398
444
  message(line: string): void;
399
445
  setConfigValue?(key: string, value: string): Promise<void>;
400
446
  tempFileName?(): string;
447
+ /** The hash bundle headers are read in (default the repository's) */
448
+ objectFormat?: ObjectFormat;
401
449
  }): BundleUriHost {
402
450
  const store = RemoteConfigStore.from(this._workingCopy);
403
451
  const worktree = repositoryPlaceOf(this._workingCopy);
452
+ const environment = hostEnvironmentOf(this._workingCopy);
404
453
  return createBundleUriHost({
454
+ ...(options.objectFormat ? { objectFormat: options.objectFormat } : {}),
455
+ // git 2.46+'s unbundle_from_file: VERIFY_BUNDLE_FSCK under fetch_pack_fsck_objects, an
456
+ // index-pack --fsck-objects given no message types (fetch.fsck.* is not read)
457
+ ...(options.compatibility !== "2.43"
458
+ ? {
459
+ fsckObjects: async () => {
460
+ const { fetchFsckOf } = await import("./commands/fsck/index.js");
461
+ return fetchFsckOf({
462
+ value: (key) => (/^fetch\.fsck\./i.test(key) ? undefined : store.value(key)),
463
+ compatibility: options.compatibility,
464
+ ...(environment
465
+ ? {
466
+ readFile: (path: string) => environment.readFile(path),
467
+ home: environment.home,
468
+ }
469
+ : {}),
470
+ });
471
+ },
472
+ }
473
+ : {}),
405
474
  workingCopy: this._workingCopy,
406
475
  setRef: (name, id, log) => this.refsStore.set(name, id, log),
407
476
  getRef: async (name) => (await this.refsStore.resolve(name).catch(() => undefined))?.objectId,
@@ -411,7 +480,7 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
411
480
  ...(options.remoteUrl !== undefined ? { remoteUrl: options.remoteUrl } : {}),
412
481
  ...(this.credentials ? { credentials: this.credentials } : {}),
413
482
  ...(this.headers ? { headers: this.headers } : {}),
414
- ...(this.credentialHelper ? { credentialHelper: this.credentialHelper } : {}),
483
+ ...credentialHelperOption(this.httpCredentialHelper()),
415
484
  httpSettings: (url) => this.httpSettingsFor(url),
416
485
  configValue: (key) => store.value(key),
417
486
  setConfigValue:
@@ -475,3 +544,10 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
475
544
  };
476
545
  }
477
546
  }
547
+
548
+ /** The `credentialHelper` option of a session or host, when there is one. */
549
+ function credentialHelperOption(helper: HttpCredentialHelper | undefined): {
550
+ credentialHelper?: HttpCredentialHelper;
551
+ } {
552
+ return helper ? { credentialHelper: helper } : {};
553
+ }