@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
@@ -10,6 +10,14 @@ import { wildmatch } from "@statewalker/vcs-working-tree";
10
10
 
11
11
  import { quotePath } from "../results/quote-path.js";
12
12
  import type { PatchRequest, PatchSelector } from "./add-patch/index.js";
13
+ import {
14
+ COL_COLUMN,
15
+ COL_DENSE,
16
+ COL_ENABLED,
17
+ COL_PLAIN,
18
+ COL_ROW,
19
+ printColumns,
20
+ } from "./column/index.js";
13
21
 
14
22
  /** What `git clean -i` printed. */
15
23
  export interface CleanInteractiveResult {
@@ -56,74 +64,11 @@ export function parseColumnLayout(values: readonly string[]): ColumnLayout {
56
64
  return out;
57
65
  }
58
66
 
59
- /** utf8_strnwidth: the display width (one column per character here). */
60
- const itemLength = (s: string) => [...s].length;
61
-
62
- /**
63
- * column.c's `print_columns` with the layout always enabled: `indent` before each line,
64
- * `padding` spaces between cells, `width` the terminal's columns less one.
65
- */
66
- export function printColumns(
67
- list: readonly string[],
68
- layout: ColumnLayout,
69
- options: { indent: string; padding: number; width: number },
70
- ): string {
71
- if (list.length === 0) return "";
72
- const { indent, padding } = options;
73
- if (layout.layout === "plain") return list.map((s) => `${indent}${s}\n`).join("");
74
- const n = list.length;
75
- const len = list.map(itemLength);
76
- const column = layout.layout === "column";
77
- let initialWidth = Math.max(...len) + padding;
78
- let cols = Math.floor((options.width - indent.length) / initialWidth);
79
- if (cols === 0) cols = 1;
80
- let rows = Math.ceil(n / cols);
81
- const linear = (x: number, y: number) => (column ? x * rows + y : y * cols + x);
82
- let width: number[] | undefined;
83
- const computeWidths = () => {
84
- const w: number[] = [];
85
- for (let x = 0; x < cols; x++) {
86
- w[x] = linear(x, 0);
87
- for (let y = 0; y < rows; y++) {
88
- const i = linear(x, y);
89
- if (i < n && len[w[x] as number] < len[i]) w[x] = i;
90
- }
91
- }
92
- return w;
93
- };
94
- if (layout.dense) {
95
- while (rows > 1) {
96
- const oldRows = rows;
97
- const oldCols = cols;
98
- rows--;
99
- cols = Math.ceil(n / rows);
100
- const w = computeWidths();
101
- let total = indent.length;
102
- for (let x = 0; x < cols; x++) total += len[w[x] as number] + padding;
103
- if (total > options.width) {
104
- rows = oldRows;
105
- cols = oldCols;
106
- break;
107
- }
108
- }
109
- width = computeWidths();
110
- }
111
- initialWidth = Math.max(...len) + padding;
112
- let out = "";
113
- for (let y = 0; y < rows; y++) {
114
- for (let x = 0; x < cols; x++) {
115
- const i = linear(x, y);
116
- if (i >= n) break;
117
- let l = len[i] as number;
118
- if (width && len[width[x] as number] < initialWidth) {
119
- l += initialWidth - len[width[x] as number];
120
- l -= padding;
121
- }
122
- const newline = column ? i + rows >= n : x === cols - 1 || i === n - 1;
123
- out += `${x === 0 ? indent : ""}${list[i]}${newline ? "\n" : " ".repeat(Math.max(0, initialWidth - l))}`;
124
- }
125
- }
126
- return out;
67
+ /** The finalized `colopts` of a layout git clean always uses (column_active). */
68
+ function layoutColopts(layout: ColumnLayout): number {
69
+ const bits =
70
+ layout.layout === "row" ? COL_ROW : layout.layout === "plain" ? COL_PLAIN : COL_COLUMN;
71
+ return COL_ENABLED | bits | (layout.dense ? COL_DENSE : 0);
127
72
  }
128
73
 
129
74
  interface MenuItem {
@@ -187,11 +132,12 @@ function firstPieceOf(input: string): string {
187
132
  class CleanInteractiveSession {
188
133
  private out = "";
189
134
  private del: string[];
190
- private readonly width: number;
135
+ /** term_columns(); git's pretty_print_dels and menus leave copts.width 0 (term_columns - 1) */
136
+ private readonly termColumns: number;
191
137
 
192
138
  constructor(private readonly options: CleanInteractiveOptions) {
193
139
  this.del = [...options.items];
194
- this.width = (options.columns ?? 80) - 1;
140
+ this.termColumns = options.columns ?? 80;
195
141
  }
196
142
 
197
143
  private quote(item: string): string {
@@ -201,8 +147,8 @@ class CleanInteractiveSession {
201
147
  private prettyPrintDels(): void {
202
148
  this.out += printColumns(
203
149
  this.del.map((item) => this.quote(item)),
204
- this.options.layout ?? { layout: "column", dense: false },
205
- { indent: " ", padding: 2, width: this.width },
150
+ layoutColopts(this.options.layout ?? { layout: "column", dense: false }),
151
+ { indent: " ", padding: 2, termColumns: this.termColumns },
206
152
  );
207
153
  }
208
154
 
@@ -366,8 +312,8 @@ class CleanInteractiveSession {
366
312
  this.out += printColumns(
367
313
  titles.map((_, i) => label(i, chosen[i] === 1)),
368
314
  // pretty_print_menus: always in rows
369
- { layout: "row", dense: false },
370
- { indent: " ", padding: 2, width: this.width },
315
+ COL_ENABLED | COL_ROW,
316
+ { indent: " ", padding: 2, termColumns: this.termColumns },
371
317
  );
372
318
  const prompt = `${opts.prompt}${opts.singleton ? "> " : ">> "}`;
373
319
  this.out += prompt;
@@ -4,6 +4,7 @@ import {
4
4
  historyWithoutLazyFetch,
5
5
  isSymbolicRef,
6
6
  isValidRefName,
7
+ ObjectFilterError,
7
8
  type ObjectId,
8
9
  parseObjectFilter,
9
10
  } from "@statewalker/vcs-core";
@@ -58,7 +59,9 @@ import {
58
59
  } from "./bundle/index.js";
59
60
  import { coreBool, worktreeModeTrust } from "./core-config.js";
60
61
  import {
62
+ type DefaultBranch,
61
63
  defaultInitialBranch,
64
+ type NewRepositoryConfig,
62
65
  UnsupportedObjectStorageError,
63
66
  unknownObjectStorageFormat,
64
67
  } from "./default-branch.js";
@@ -68,7 +71,11 @@ import { runPostCheckoutHook } from "./git-hooks.js";
68
71
  import { hostEnvironmentOf } from "./git-ident.js";
69
72
  import { copyLocalObjects } from "./local-clone.js";
70
73
  import { promisorOf } from "./promisor-remote.js";
71
- import { promisorRemoteReplyOf } from "./promisor-remote-reply.js";
74
+ import {
75
+ promisorAutoFilter,
76
+ promisorRemoteReplyOf,
77
+ resetPromisorAcceptance,
78
+ } from "./promisor-remote-reply.js";
72
79
  import { reflogMessages } from "./reflog-messages.js";
73
80
  import { isValidRemoteName } from "./remote-command.js";
74
81
  import { withRemoteUploadPack } from "./remote-transport.js";
@@ -98,6 +105,7 @@ const CLONE_SETTINGS = [
98
105
  "rejectShallow",
99
106
  "serverOptions",
100
107
  "compatibility",
108
+ "bundleUri",
101
109
  "cloneAllBranches",
102
110
  "mirror",
103
111
  "singleBranch",
@@ -222,6 +230,11 @@ export class CloneCommand extends TransportCommand<CloneResult> {
222
230
  /** The git version reproduced; default the hooks' */
223
231
  private compatibility?: "2.43" | "2.56";
224
232
  private bundleUri?: string;
233
+ /**
234
+ * The hash `--bundle-uri`'s bundles are read in: git 2.43 fetches them before it learns the
235
+ * remote's hash, in the destination's first one (set on a clone reopened under 2.43)
236
+ */
237
+ private bundleObjectFormat?: ObjectFormat;
225
238
  private cloneAllBranches = true;
226
239
  private mirror = false;
227
240
  private singleBranch?: boolean;
@@ -338,11 +351,21 @@ export class CloneCommand extends TransportCommand<CloneResult> {
338
351
  * Objects left out are fetched lazily from the remote when read (the checkout fetches the
339
352
  * blobs it writes in one batch, as git's).
340
353
  *
354
+ * `auto` (git 2.54) takes the filter the promisor remotes accepted from the server's
355
+ * `promisor-remote` capability advertise (none: no filter) and is recorded as `auto`, so
356
+ * later fetches resolve it again.
357
+ *
341
358
  * @param spec The filter spec; `blob:limit=1k` is recorded and sent as `blob:limit=1024`
342
359
  * @throws ObjectFilterError with git's message for a spec git refuses
343
360
  */
344
361
  setFilter(spec: string): this {
345
362
  this.checkCallable();
363
+ // `auto` (git 2.54): the filter the promisor remotes the server advertises and this
364
+ // clone accepts propose (promisor_remote_construct_filter), recorded as `auto`
365
+ if (spec === "auto") {
366
+ this.filterSpec = spec;
367
+ return this;
368
+ }
346
369
  const filter = parseObjectFilter(spec);
347
370
  // expand_list_objects_filter_spec: a blob limit in bytes
348
371
  this.filterSpec = filter.choice === "blob:limit" ? `blob:limit=${filter.limit}` : spec;
@@ -852,6 +875,12 @@ export class CloneCommand extends TransportCommand<CloneResult> {
852
875
  const self = this as unknown as Record<string, unknown>;
853
876
  const other = next as unknown as Record<string, unknown>;
854
877
  for (const key of CLONE_SETTINGS) if (key in self) other[key] = self[key];
878
+ // 2.43's clone ran fetch_bundle_uri in the repository GIT_DEFAULT_HASH had initialized,
879
+ // before transport_get_remote_refs: its bundles were read in that hash (a SHA-1 bundle in a
880
+ // SHA-256 destination is no bundle there); 2.5x reads them in the remote's
881
+ if ((this.compatibility ?? this.hooks.compatibility) === "2.43") {
882
+ other.bundleObjectFormat = this.bundleObjectFormat ?? this.objectFormat;
883
+ }
855
884
  next.shareHooksOf(this);
856
885
  const result = await next.call();
857
886
  this.reopenedListener?.(workingCopy);
@@ -906,6 +935,10 @@ export class CloneCommand extends TransportCommand<CloneResult> {
906
935
  );
907
936
  }
908
937
  const compatibility = this.compatibility ?? this.hooks.compatibility;
938
+ // git 2.43 has no `auto` filter
939
+ if (this.filterSpec === "auto" && compatibility === "2.43") {
940
+ throw new ObjectFilterError("invalid filter-spec 'auto'");
941
+ }
909
942
  // parse_options: --revision is unknown to 2.43
910
943
  if (this.revision !== undefined && compatibility === "2.43") {
911
944
  throw new GitApiError(`error: unknown option \`revision=${this.revision}'`, {
@@ -1013,6 +1046,14 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1013
1046
  }
1014
1047
 
1015
1048
  this.repoUrl = repo;
1049
+ // clone.c writes remote.<name>.url (and tagOpt) before it asks for the refs: what the
1050
+ // server's promisor-remote capability makes the fetch write (an auto-created remote)
1051
+ // comes after that section
1052
+ store.setValue(`remote.${this.remoteName}.url`, repo);
1053
+ if (this.tagOption === TagOption.NO_TAGS || this.mirror) {
1054
+ store.setValue(`remote.${this.remoteName}.tagOpt`, "--no-tags");
1055
+ }
1056
+ await store.save();
1016
1057
  const sourceUrl = store.aliasUrl(repo) ?? repo;
1017
1058
  const remote = await this.prepareRemote(bundleFile ?? sourceUrl);
1018
1059
  if (remote.kind === "bundle" && remote.remote.bundle.header.filter !== undefined) {
@@ -1221,6 +1262,8 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1221
1262
  });
1222
1263
 
1223
1264
  const sessionId = clientSessionIdOf(this.workingCopy);
1265
+ // a new git process: no promisor remote accepted yet (--filter=auto, lazy-fetch order)
1266
+ resetPromisorAcceptance(this.workingCopy);
1224
1267
  const fetchOptions: TransportFetchOptions = {
1225
1268
  ...(sessionId !== undefined ? { sessionId } : {}),
1226
1269
  // fetch.uriProtocols: the packs a v2 server offloads to packfile URIs
@@ -1233,6 +1276,9 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1233
1276
  repository: createRepositoryFacade({ history: historyWithoutLazyFetch(history) }),
1234
1277
  refStore: createTransportRefStore(history.refs),
1235
1278
  refspecs,
1279
+ // clone maps what wanted_peer_refs finds: its own refspecs never die on a source the
1280
+ // remote lacks (an unborn HEAD's branch); the configured ones are checked above
1281
+ missingRefsOk: true,
1236
1282
  tags,
1237
1283
  depth,
1238
1284
  deepenSince: shallowSince,
@@ -1254,6 +1300,8 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1254
1300
  onWarning: (line: string) => messages.push(`${line}\n`),
1255
1301
  // the server's promisor-remote capability (promisor.acceptFromServer, storeFields)
1256
1302
  promisorRemote: promisorRemoteReplyOf(this.workingCopy, (line) => messages.push(`${line}\n`)),
1303
+ // --filter=auto: the accepted promisor remotes' advertised filter
1304
+ autoFilter: () => promisorAutoFilter(this.workingCopy, (line) => messages.push(`${line}\n`)),
1257
1305
  ...(fsck ? { fsckObjects: fsck } : {}),
1258
1306
  ...(serverOptions.length > 0 ? { serverOptions } : {}),
1259
1307
  ...(rejectShallow ? { rejectShallow: true } : {}),
@@ -1341,7 +1389,7 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1341
1389
  (r) =>
1342
1390
  r.name.startsWith("refs/heads/") && cloned.has(r.name) && r.oid === remoteHeadRef.oid,
1343
1391
  );
1344
- const preferred = (await defaultInitialBranch(hostEnvironmentOf(this._workingCopy))).name;
1392
+ const preferred = (await this.defaultInitialBranch()).name;
1345
1393
  advertisedDefaultBranch = (
1346
1394
  branches.find((r) => r.name === `refs/heads/${preferred}`) ??
1347
1395
  branches.find((r) => r.name === "refs/heads/master") ??
@@ -1349,15 +1397,18 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1349
1397
  )?.name;
1350
1398
  }
1351
1399
  let defaultBranch = branchToClone ?? toBranchName(advertisedDefaultBranch);
1400
+ // the remote HEAD names a branch it does not have (ls-refs' `unborn`)
1401
+ const unbornHead =
1402
+ remoteHeadRef !== undefined &&
1403
+ remoteHeadRef.oid === undefined &&
1404
+ remoteHeadRef.symref !== undefined;
1352
1405
  let headCommit: ObjectId | undefined;
1353
1406
  let checkedOutBranch: string | undefined;
1354
1407
  // the commit to check out once refs and configuration are in place (git: last)
1355
1408
  let checkoutId: ObjectId | undefined;
1356
1409
  // an empty remote without unborn HEAD: git's default branch (the one init named)
1357
1410
  if (!detachedTag && !this.bare && defaultBranch === undefined && result.isEmpty) {
1358
- defaultBranch =
1359
- (await this.localHeadBranch()) ??
1360
- (await defaultInitialBranch(hostEnvironmentOf(this._workingCopy))).name;
1411
+ defaultBranch = (await this.localHeadBranch()) ?? (await this.defaultInitialBranch()).name;
1361
1412
  }
1362
1413
 
1363
1414
  // git's update_remote_refs (before update_head): refs/remotes/<name>/HEAD names the tracking ref of the
@@ -1428,8 +1479,9 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1428
1479
  headCommit = tip.objectId;
1429
1480
  if (!this.noCheckout) checkoutId = tip.objectId;
1430
1481
  }
1431
- // git's install_branch_config: the branch tracks its remote counterpart
1432
- if (tip?.objectId || result.isEmpty) checkedOutBranch = defaultBranch;
1482
+ // git's install_branch_config: the branch tracks its remote counterpart, also when the
1483
+ // remote's HEAD is unborn (v2's unborn_head_target), refs or not
1484
+ if (tip?.objectId || result.isEmpty || unbornHead) checkedOutBranch = defaultBranch;
1433
1485
  } else if (this.bare || this.mirror) {
1434
1486
  // For bare/mirror repos, HEAD points to default branch
1435
1487
  if (defaultBranch) {
@@ -1445,7 +1497,9 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1445
1497
  detachedTag,
1446
1498
  remoteHead,
1447
1499
  checkedOutBranch,
1448
- isEmpty: result.isEmpty,
1500
+ // a single-branch clone of an unborn HEAD maps no ref (wanted_peer_refs): git's empty
1501
+ // clone, without a fetch refspec
1502
+ isEmpty: result.isEmpty || (singleBranch && unbornHead && branchToClone === undefined),
1449
1503
  revision: this.revision !== undefined,
1450
1504
  });
1451
1505
 
@@ -1469,9 +1523,7 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1469
1523
  fetchResult,
1470
1524
  // as the empty-remote case above: the local HEAD's branch, else git's default
1471
1525
  defaultBranch:
1472
- defaultBranch ??
1473
- (await this.localHeadBranch()) ??
1474
- (await defaultInitialBranch(hostEnvironmentOf(this._workingCopy))).name,
1526
+ defaultBranch ?? (await this.localHeadBranch()) ?? (await this.defaultInitialBranch()).name,
1475
1527
  remoteName: this.remoteName,
1476
1528
  bare: this.bare,
1477
1529
  headCommit,
@@ -1496,11 +1548,20 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1496
1548
  if (this.dissociate) await history.objects?.alternates?.dissociate?.();
1497
1549
 
1498
1550
  if (checkoutId) {
1551
+ // what the checkout's lazy fetches print (git's child `git fetch` shares its stderr)
1552
+ const promisorWarnings = promisorOf(this._workingCopy)?.warnings;
1553
+ const warned = promisorWarnings?.length ?? 0;
1499
1554
  try {
1500
1555
  const collided = await this.checkoutHead(checkoutId);
1501
1556
  if (collided.length > 0) cloneResult.collidedPaths = collided;
1502
1557
  } catch (error) {
1503
1558
  throw new CloneCheckoutError(cloneResult, error);
1559
+ } finally {
1560
+ const lines = promisorWarnings?.slice(warned) ?? [];
1561
+ if (lines.length > 0) {
1562
+ messages.push(...lines.map((line) => `${line}\n`));
1563
+ if (cloneResult.messages === undefined) cloneResult.messages = messages;
1564
+ }
1504
1565
  }
1505
1566
  // checkout()'s post-checkout hook: from no commit to the one checked out, a branch
1506
1567
  // switch; its exit code becomes the clone's exit status
@@ -1547,6 +1608,9 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1547
1608
  remoteUrl,
1548
1609
  compatibility,
1549
1610
  message,
1611
+ ...(this.bundleUri !== undefined && this.bundleObjectFormat
1612
+ ? { objectFormat: this.bundleObjectFormat }
1613
+ : {}),
1550
1614
  setConfigValue: (key, value) => this.writeConfigValue(key, value, "add"),
1551
1615
  // odb_mkstemp's `<objects>/bundles/tmp_uri_XXXXXX`, as git's errors name the list
1552
1616
  tempFileName: () =>
@@ -1960,6 +2024,28 @@ export class CloneCommand extends TransportCommand<CloneResult> {
1960
2024
  if (this.filterSpec !== undefined) promisorOf(this._workingCopy)?.fetcher?.invalidate?.();
1961
2025
  }
1962
2026
 
2027
+ /**
2028
+ * git's `repo_default_branch_name` in the new repository: its whole configuration
2029
+ * (`includeIf "gitdir:"` matching its git directory), as the working copy's config reads it
2030
+ * when that is the user's chain (it has the environment); else the protected configuration.
2031
+ */
2032
+ private defaultInitialBranch(): Promise<DefaultBranch> {
2033
+ const config = this._workingCopy.config as Partial<NewRepositoryConfig> | undefined;
2034
+ const environment = hostEnvironmentOf(this._workingCopy);
2035
+ return defaultInitialBranch(
2036
+ environment,
2037
+ environment && config?.listWithOrigin ? (config as NewRepositoryConfig) : undefined,
2038
+ );
2039
+ }
2040
+
2041
+ /** The full name of the branch HEAD names (`refs/heads/<name>`), none when detached. */
2042
+ private async headBranchRef(): Promise<string | undefined> {
2043
+ const head = await this.refsStore.get("HEAD").catch(() => undefined);
2044
+ return head && "target" in head && head.target.startsWith("refs/heads/")
2045
+ ? head.target
2046
+ : undefined;
2047
+ }
2048
+
1963
2049
  /** The branch the local HEAD names (`init.defaultBranch` of the new repository), if any. */
1964
2050
  private async localHeadBranch(): Promise<string | undefined> {
1965
2051
  const head = await this.refsStore.get("HEAD");
@@ -2012,6 +2098,11 @@ export class CloneCommand extends TransportCommand<CloneResult> {
2012
2098
  pathRules: worktreePathRules(this.workingCopy, worktree),
2013
2099
  ...(sparse ? { writes: (path: string) => sparse.writes(path) } : {}),
2014
2100
  ...(this.progress ? { progress: this.progress } : {}),
2101
+ // clone's checkout(): HEAD's branch (none when detached) and its commit
2102
+ metadata: {
2103
+ ...(await this.headBranchRef().then((ref) => (ref ? { ref } : {}))),
2104
+ treeish: commitId,
2105
+ },
2015
2106
  },
2016
2107
  commit.tree,
2017
2108
  CLONE,
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The column settings of a command as git reads them: `column.ui` and `column.<command>`
3
+ * in the configuration's order (git_column_config), then the command line's `--column`.
4
+ *
5
+ * @module
6
+ */
7
+
8
+ import type { WorkingCopy } from "@statewalker/vcs-working-tree";
9
+
10
+ import { InvalidConfigError } from "../../errors/index.js";
11
+ import { RemoteConfigStore } from "../../remote-config/index.js";
12
+ import { hostEnvironmentOf } from "../git-ident.js";
13
+ import {
14
+ applyColumnOption,
15
+ finalizeColopts,
16
+ readColumnConfig,
17
+ termColumns,
18
+ } from "./column-layout.js";
19
+
20
+ /**
21
+ * `colopts` from `column.ui` and `column.<command>` (none: `column.ui` alone).
22
+ *
23
+ * @throws InvalidConfigError with git's lines for a value git refuses (exit 128)
24
+ */
25
+ export function columnConfigOf(workingCopy: WorkingCopy, command?: string): number {
26
+ if (!workingCopy.config) return 0;
27
+ const config = RemoteConfigStore.from(workingCopy);
28
+ const keys = command === undefined ? ["column.ui"] : ["column.ui", `column.${command}`];
29
+ const entries = (
30
+ config.entriesWithOriginFor(keys) ??
31
+ keys.flatMap((key) => config.valuesWithOrigin(key).map((where) => ({ key, ...where })))
32
+ ).map(({ key, text, file, line }) => ({
33
+ key: key.toLowerCase(),
34
+ value: text,
35
+ ...(file !== undefined ? { file } : {}),
36
+ ...(line !== undefined ? { line } : {}),
37
+ }));
38
+ const read = readColumnConfig(entries, command);
39
+ if ("message" in read) throw new InvalidConfigError(read.key, read.message);
40
+ return read.colopts;
41
+ }
42
+
43
+ /**
44
+ * A listing's finalized `colopts`: the configuration's, then `option` (`--column`,
45
+ * `--column=<options>`, `--no-column`), `auto` off (no terminal).
46
+ *
47
+ * @throws InvalidConfigError for a bad configured value, ColumnOptionError for a bad option
48
+ */
49
+ export function columnSettingsOf(
50
+ workingCopy: WorkingCopy,
51
+ command: string,
52
+ option: string | boolean | undefined,
53
+ ): number {
54
+ let colopts = columnConfigOf(workingCopy, command);
55
+ if (option !== undefined) colopts = applyColumnOption(colopts, option);
56
+ return finalizeColopts(colopts);
57
+ }
58
+
59
+ /** term_columns: the explicit width, else the host's `$COLUMNS`, else 80. */
60
+ export function terminalColumnsOf(workingCopy: WorkingCopy, explicit?: number): number {
61
+ if (explicit !== undefined && explicit > 0) return explicit;
62
+ return termColumns(hostEnvironmentOf(workingCopy)?.columns);
63
+ }