@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
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * The initial branch of a new repository, as git's `repo_default_branch_name` (refs.c) picks
3
- * it: `init.defaultBranch` from the configuration a new repository sees (system, global, the
4
- * command line), else `master`, or `main` in a git built with `WITH_BREAKING_CHANGES`
3
+ * it: `init.defaultBranch` from the configuration the new repository sees (system, global, its
4
+ * own config with what a template brought in, the command line; `includeIf "gitdir:..."`
5
+ * matched against the new repository's git directory), else `master`, or `main` in a git built with `WITH_BREAKING_CHANGES`
5
6
  * (`GitHostEnvironment.breakingChanges`, git 3.0). With no name configured, git explains the
6
7
  * default in an `advice.defaultBranchName` hint, which {@link DefaultBranch.hint} holds.
7
8
  *
@@ -68,16 +69,34 @@ export function isValidBranchName(name: string): boolean {
68
69
  }
69
70
 
70
71
  /**
71
- * The initial branch of a repository created now. Reads the protected configuration (the
72
- * repository's own does not exist yet); without an environment, nothing is configured.
72
+ * The configuration of the new repository, as git's `repo_config_get_string` reads it once
73
+ * `create_repository` made it: a loaded `GitWorkingCopyConfig` of its git directory (its
74
+ * values with their origins, in git's order).
75
+ */
76
+ export interface NewRepositoryConfig {
77
+ listWithOrigin(): { key: string; text: string | undefined; file?: string; line?: number }[];
78
+ }
79
+
80
+ /**
81
+ * The initial branch of a repository created now, from `config` (the new repository's, see
82
+ * {@link NewRepositoryConfig}); without one, from the protected configuration (system,
83
+ * global, command line, `gitdir:` conditions false). Without either, nothing is configured.
84
+ *
85
+ * The hint follows `options.compatibility` (default: the hook runner's, else 2.56): git 2.43
86
+ * calls `advise()` with its own text, whatever `advice.defaultBranchName` says, 2.5x
87
+ * `advise_if_enabled()`; `options.quiet` (`git init -q`) gives none in every version.
73
88
  *
74
89
  * @throws InvalidDefaultBranchError when `init.defaultBranch` names no valid branch (empty too)
75
90
  * @throws MissingDefaultBranchValueError when `init.defaultBranch` has no value
76
91
  */
77
92
  export async function defaultInitialBranch(
78
93
  environment: GitHostEnvironment | undefined,
94
+ repositoryConfig?: NewRepositoryConfig,
95
+ options: DefaultInitialBranchOptions = {},
79
96
  ): Promise<DefaultBranch> {
80
- const config = await readProtectedConfig(environment);
97
+ const config = repositoryConfig
98
+ ? repositoryConfig.listWithOrigin().map((e) => ({ ...e, value: e.text }))
99
+ : await readProtectedConfig(environment);
81
100
  const last = (key: string) => config.filter((e) => e.key === key).at(-1);
82
101
  const configured = last("init.defaultbranch");
83
102
  if (configured && configured.value === undefined) {
@@ -91,11 +110,44 @@ export async function defaultInitialBranch(
91
110
  return { name: configured.value };
92
111
  }
93
112
  const name = environment?.breakingChanges ? "main" : "master";
113
+ if (options.quiet) return { name };
114
+ const compatibility = options.compatibility ?? environment?.hookRunner?.compatibility ?? "2.56";
115
+ // git 3.0 (the breaking-changes build) is git master's advise_if_enabled
116
+ if (compatibility === "2.43" && !environment?.breakingChanges) {
117
+ return { name, hint: defaultBranchHint243(name) };
118
+ }
94
119
  const advice = last("advice.defaultbranchname");
95
120
  const enabled = advice === undefined || parseGitBool(advice.value ?? "true") !== false;
96
121
  return enabled ? { name, hint: defaultBranchHint(name, environment?.breakingChanges) } : { name };
97
122
  }
98
123
 
124
+ /** How {@link defaultInitialBranch} words its hint. */
125
+ export interface DefaultInitialBranchOptions {
126
+ /** The git version whose hint is given; default the hook runner's, else `2.56` */
127
+ compatibility?: "2.43" | "2.56";
128
+ /** `git init -q`: no hint (`repo_default_branch_name(r, quiet)`) */
129
+ quiet?: boolean;
130
+ }
131
+
132
+ /**
133
+ * git 2.43's `default_branch_name_advice`, as its `advise()` prints it (an empty line is
134
+ * `hint: `, with its space; no "Disable this message" line).
135
+ */
136
+ export function defaultBranchHint243(name: string): string[] {
137
+ return [
138
+ `Using '${name}' as the name for the initial branch. This default branch name`,
139
+ "is subject to change. To configure the initial branch name to use in all",
140
+ "of your new repositories, which will suppress this warning, call:",
141
+ "",
142
+ "\tgit config --global init.defaultBranch <name>",
143
+ "",
144
+ "Names commonly chosen instead of 'master' are 'main', 'trunk' and",
145
+ "'development'. The just-created branch can be renamed via this command:",
146
+ "",
147
+ "\tgit branch -m <name>",
148
+ ].map((line) => `hint: ${line}`);
149
+ }
150
+
99
151
  /** git's `default_branch_name_advice` (2.5x, or 3.0), as `advise_if_enabled` prints it. */
100
152
  export function defaultBranchHint(name: string, breakingChanges: boolean | undefined): string[] {
101
153
  const text = breakingChanges
@@ -88,14 +88,18 @@ export interface DiffColorSettings {
88
88
  }
89
89
 
90
90
  /** Where a variable was read, as git names it when it dies */
91
- function where(key: string, file: string | undefined, line: number | undefined): string {
91
+ export function badConfigVariableLine(
92
+ key: string,
93
+ file: string | undefined,
94
+ line: number | undefined,
95
+ ): string {
92
96
  return file !== undefined && line !== undefined
93
97
  ? `fatal: bad config variable '${key}' in file '${file}' at line ${line}`
94
98
  : `fatal: unable to parse '${key}' from command-line config`;
95
99
  }
96
100
 
97
101
  /** color.c's `git_config_colorbool` (`undefined` for git's unknown) */
98
- function colorBool(key: string, value: string | undefined): "never" | "always" | "auto" {
102
+ export function readColorBool(key: string, value: string | undefined): "never" | "always" | "auto" {
99
103
  if (value !== undefined) {
100
104
  const lower = value.toLowerCase();
101
105
  if (lower === "never" || lower === "always" || lower === "auto") return lower;
@@ -153,16 +157,22 @@ export function readDiffColorSettings(
153
157
  : [];
154
158
  for (const { key, text, file, line } of entries) {
155
159
  const missing = () =>
156
- new InvalidConfigError(key, `error: missing value for '${key}'\n${where(key, file, line)}`);
160
+ new InvalidConfigError(
161
+ key,
162
+ `error: missing value for '${key}'\n${badConfigVariableLine(key, file, line)}`,
163
+ );
157
164
  if (key === "color.ui") {
158
- if (uiConfig) ui = colorBool(key, text);
165
+ if (uiConfig) ui = readColorBool(key, text);
159
166
  } else if (key === "diff.color" || key === "color.diff") {
160
- if (uiConfig) diff = colorBool(key, text);
167
+ if (uiConfig) diff = readColorBool(key, text);
161
168
  } else if (key === "diff.colormoved") {
162
169
  if (!uiConfig) continue;
163
170
  const mode = parseColorMoved(text);
164
171
  if (mode === undefined) {
165
- throw new InvalidConfigError(key, `${COLOR_MOVED_MODE_ERROR}\n${where(key, file, line)}`);
172
+ throw new InvalidConfigError(
173
+ key,
174
+ `${COLOR_MOVED_MODE_ERROR}\n${badConfigVariableLine(key, file, line)}`,
175
+ );
166
176
  }
167
177
  colorMoved = mode;
168
178
  } else if (key === "diff.colormovedws") {
@@ -170,7 +180,10 @@ export function readDiffColorSettings(
170
180
  if (text === undefined) throw missing();
171
181
  const parsed = parseColorMovedWs(text);
172
182
  if (parsed.errors.length > 0) {
173
- throw new InvalidConfigError(key, `${parsed.errors.join("\n")}\n${where(key, file, line)}`);
183
+ throw new InvalidConfigError(
184
+ key,
185
+ `${parsed.errors.join("\n")}\n${badConfigVariableLine(key, file, line)}`,
186
+ );
174
187
  }
175
188
  colorMovedWs = parsed.flags;
176
189
  } else if (key === "diff.wserrorhighlight") {
@@ -179,7 +192,7 @@ export function readDiffColorSettings(
179
192
  if (val === undefined) {
180
193
  throw new InvalidConfigError(
181
194
  key,
182
- `error: unknown value for config '${key}': ${text}\n${where(key, file, line)}`,
195
+ `error: unknown value for config '${key}': ${text}\n${badConfigVariableLine(key, file, line)}`,
183
196
  );
184
197
  }
185
198
  wsErrorHighlight = val;
@@ -191,7 +204,7 @@ export function readDiffColorSettings(
191
204
  if (color === undefined) {
192
205
  throw new InvalidConfigError(
193
206
  key,
194
- `error: invalid color value: ${text}\n${where(key, file, line)}`,
207
+ `error: invalid color value: ${text}\n${badConfigVariableLine(key, file, line)}`,
195
208
  );
196
209
  }
197
210
  colors[slot] = color;
@@ -204,7 +217,7 @@ export function readDiffColorSettings(
204
217
  if (color === undefined) {
205
218
  throw new InvalidConfigError(
206
219
  key,
207
- `error: invalid color value: ${text}\n${where(key, file, line)}`,
220
+ `error: invalid color value: ${text}\n${badConfigVariableLine(key, file, line)}`,
208
221
  );
209
222
  }
210
223
  decorationColors[slot] = color;
@@ -84,6 +84,7 @@ import {
84
84
  writePairPatch,
85
85
  } from "../results/diff-output.js";
86
86
  import { DiffPickaxe } from "../results/diff-pickaxe.js";
87
+ import { LinePrefixSink } from "../results/line-prefix-sink.js";
87
88
  import { quotePath } from "../results/quote-path.js";
88
89
  import {
89
90
  parseWhitespaceRule,
@@ -817,6 +818,8 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
817
818
  private mergeBase = false;
818
819
  /** Whether `--rotate-to`/`--skip-to` need their exact path (`git diff`; not `git log`) */
819
820
  private rotateStrict = true;
821
+ /** {@link callFormats} reports where diff.c's `diff_line_prefix` goes (`log --graph`) */
822
+ private linePrefix = false;
820
823
  /** git's `has_changes` of the last call */
821
824
  private changesFound = false;
822
825
  /** git's `check_failed`: `--check` found an error in the last call */
@@ -884,6 +887,19 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
884
887
  return this;
885
888
  }
886
889
 
890
+ /**
891
+ * diff.c's `diff_line_prefix` (`log --graph`'s padding): {@link callFormats} gives the
892
+ * offsets in its output where it goes (`prefixPoints`, for `insertLinePrefix`): before
893
+ * every line, except where git's word diff leaves it out
894
+ *
895
+ * @internal
896
+ */
897
+ setLinePrefixPoints(on: boolean): this {
898
+ this.checkCallable();
899
+ this.linePrefix = on;
900
+ return this;
901
+ }
902
+
887
903
  /**
888
904
  * The exit status `git diff` ends with (`diff_result_code`): bit 1 when `--exit-code` or
889
905
  * `--quiet` is set and the last call found differences, bit 2 when its `--check` (the
@@ -1518,6 +1534,8 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
1518
1534
  follow?: string,
1519
1535
  ): Promise<{
1520
1536
  bytes?: Uint8Array;
1537
+ /** With {@link setLinePrefixPoints}: where the line prefix goes in `bytes` */
1538
+ prefixPoints?: number[];
1521
1539
  followPath?: string;
1522
1540
  followChange?: ChangeType.RENAME | ChangeType.COPY;
1523
1541
  }> {
@@ -1564,11 +1582,15 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
1564
1582
  const withHeaders = this.includesConflictHeaders(headers);
1565
1583
  if (collected.entries.length === 0 && collected.combined.length === 0 && !withHeaders)
1566
1584
  return followed;
1567
- const sink = new ByteSink();
1585
+ const sink = this.linePrefix ? new LinePrefixSink() : new ByteSink();
1568
1586
  const queued = await this.writeFormats(sink, formats, collected, headers);
1569
1587
  // diffcore_std left nothing (`--diff-filter`, `--skip-to`): no diff, as an empty one
1570
1588
  if (queued === 0 && collected.combined.length === 0 && !withHeaders) return followed;
1571
- return { bytes: sink.bytes(), ...followed };
1589
+ return {
1590
+ bytes: sink.bytes(),
1591
+ ...(sink instanceof LinePrefixSink ? { prefixPoints: sink.points } : {}),
1592
+ ...followed,
1593
+ };
1572
1594
  });
1573
1595
  }
1574
1596
 
@@ -1632,6 +1654,7 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
1632
1654
  this.resetExternal();
1633
1655
  const options = this.outputOptions();
1634
1656
  Object.assign(options, this.prefixes());
1657
+ if (sink instanceof LinePrefixSink) options.linePrefix = sink;
1635
1658
  if (this.textOptions.reverse) {
1636
1659
  // diff -R swaps the prefixes with the sides (`diff --git b/f a/f`)
1637
1660
  [options.srcPrefix, options.dstPrefix] = [