@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.
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/archive/archive-command.d.ts +6 -2
- package/dist/commands/archive/archive-command.d.ts.map +1 -1
- package/dist/commands/archive/remote-archive-command.d.ts +27 -2
- package/dist/commands/archive/remote-archive-command.d.ts.map +1 -1
- package/dist/commands/archive/upload-archive-writer.d.ts +11 -5
- package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -1
- package/dist/commands/branch-command.d.ts +14 -2
- package/dist/commands/branch-command.d.ts.map +1 -1
- package/dist/commands/bundle/bundle-format.d.ts +6 -1
- package/dist/commands/bundle/bundle-format.d.ts.map +1 -1
- package/dist/commands/bundle/bundle-uri-host.d.ts +12 -1
- package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -1
- package/dist/commands/bundle/bundle-uri.d.ts +7 -1
- package/dist/commands/bundle/bundle-uri.d.ts.map +1 -1
- package/dist/commands/bundle/bundle-verify.d.ts +4 -1
- package/dist/commands/bundle/bundle-verify.d.ts.map +1 -1
- package/dist/commands/cat-file/batch-format.d.ts +8 -12
- package/dist/commands/cat-file/batch-format.d.ts.map +1 -1
- package/dist/commands/cat-file/cat-file-command.d.ts +39 -5
- package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -1
- package/dist/commands/check-ignore-command.d.ts.map +1 -1
- package/dist/commands/checkout-command.d.ts +4 -0
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-paths.d.ts +9 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-pick-command.d.ts +3 -0
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +0 -9
- package/dist/commands/clean-interactive.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +17 -0
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/column/column-config.d.ts +23 -0
- package/dist/commands/column/column-config.d.ts.map +1 -0
- package/dist/commands/column/column-layout.d.ts +129 -0
- package/dist/commands/column/column-layout.d.ts.map +1 -0
- package/dist/commands/column/index.d.ts +3 -0
- package/dist/commands/column/index.d.ts.map +1 -0
- package/dist/commands/column-command.d.ts +59 -0
- package/dist/commands/column-command.d.ts.map +1 -0
- package/dist/commands/comment-char-config.d.ts +15 -0
- package/dist/commands/comment-char-config.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +30 -2
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/config-command.d.ts +12 -0
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/credential-helper.d.ts +214 -0
- package/dist/commands/credential-helper.d.ts.map +1 -0
- package/dist/commands/default-branch.d.ts +33 -3
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/diff-color-config.d.ts +4 -0
- package/dist/commands/diff-color-config.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +12 -0
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-export-command.d.ts +89 -2
- package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-import-command.d.ts +113 -8
- package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-stream-support.d.ts +0 -9
- package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +23 -1
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +31 -3
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/history-command.d.ts +173 -7
- package/dist/commands/history-command.d.ts.map +1 -1
- package/dist/commands/index-host.d.ts +19 -0
- package/dist/commands/index-host.d.ts.map +1 -1
- package/dist/commands/index-refresh.d.ts +36 -0
- package/dist/commands/index-refresh.d.ts.map +1 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +7 -6
- package/dist/commands/init-command.d.ts +20 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/local-transport.d.ts +40 -2
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +7 -0
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +11 -0
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-tree-command.d.ts +10 -0
- package/dist/commands/ls-tree-command.d.ts.map +1 -1
- package/dist/commands/maintenance-schedule-command.d.ts +122 -0
- package/dist/commands/maintenance-schedule-command.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +13 -1
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-index-command.d.ts +42 -0
- package/dist/commands/merge-index-command.d.ts.map +1 -0
- package/dist/commands/merge-one-file.d.ts +129 -0
- package/dist/commands/merge-one-file.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +40 -4
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/object-disk-info.d.ts +35 -0
- package/dist/commands/object-disk-info.d.ts.map +1 -0
- package/dist/commands/octopus-merge.d.ts +3 -3
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/plumbing-input.d.ts.map +1 -1
- package/dist/commands/promisor-remote-reply.d.ts +31 -4
- package/dist/commands/promisor-remote-reply.d.ts.map +1 -1
- package/dist/commands/promisor-remote.d.ts +8 -1
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +55 -7
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +18 -1
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/range-diff-command.d.ts +37 -1
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +13 -1
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/for-each-ref-command.d.ts +3 -2
- package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/index.d.ts +1 -0
- package/dist/commands/ref-filter/index.d.ts.map +1 -1
- package/dist/commands/ref-filter/peel-limit.d.ts +8 -0
- package/dist/commands/ref-filter/peel-limit.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -1
- package/dist/commands/ref-filter/ref-format.d.ts +26 -1
- package/dist/commands/ref-filter/ref-format.d.ts.map +1 -1
- package/dist/commands/ref-filter/ref-listing-command.d.ts +9 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -1
- package/dist/commands/remote-transport.d.ts +27 -0
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/repack-command.d.ts +18 -2
- package/dist/commands/repack-command.d.ts.map +1 -1
- package/dist/commands/repo-command.d.ts +2 -7
- package/dist/commands/repo-command.d.ts.map +1 -1
- package/dist/commands/reset-command.d.ts +4 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-list-command.d.ts +65 -0
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +3 -0
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-filenames.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +17 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +12 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +21 -4
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/served-lazy-fetch.d.ts +61 -0
- package/dist/commands/served-lazy-fetch.d.ts.map +1 -0
- package/dist/commands/signing.d.ts +37 -4
- package/dist/commands/signing.d.ts.map +1 -1
- package/dist/commands/split-cmdline.d.ts +6 -0
- package/dist/commands/split-cmdline.d.ts.map +1 -0
- package/dist/commands/status-color-config.d.ts +33 -0
- package/dist/commands/status-color-config.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +15 -0
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/status-format.d.ts +46 -4
- package/dist/commands/status-format.d.ts.map +1 -1
- package/dist/commands/tag-command.d.ts +15 -1
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts +14 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/verify-command.d.ts +22 -2
- package/dist/commands/verify-command.d.ts.map +1 -1
- package/dist/commands/worktree-add-command.d.ts.map +1 -1
- package/dist/commands/worktree-overwrite-checks.d.ts +31 -6
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/{commands-CPceUCP2.js → commands-DT3VEv50.js} +15168 -16842
- package/dist/errors/commit-errors.d.ts +37 -1
- package/dist/errors/commit-errors.d.ts.map +1 -1
- package/dist/errors/git-api-error.d.ts +6 -0
- package/dist/errors/git-api-error.d.ts.map +1 -1
- package/dist/errors/index.js +44 -3
- package/dist/{fsck-tbrPZX2q.js → fsck-BZ508Elg.js} +2 -2
- package/dist/git-command.d.ts +33 -1
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +104 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/index.js +8 -7
- package/dist/{remote-transport-C0OSJtor.js → local-transport-D98U6p4d.js} +228 -692
- package/dist/{maintenance-run-command-UiSIaeP8.js → maintenance-run-command-DZFnbnbo.js} +2366 -108
- package/dist/remote-config/remote-config-store.d.ts +6 -0
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/remote-transport-zvSqwpOB.js +4865 -0
- package/dist/results/cherry-pick-result.d.ts +4 -3
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +7 -0
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/diff-words.d.ts +14 -3
- package/dist/results/diff-words.d.ts.map +1 -1
- package/dist/results/index.js +1 -1
- package/dist/results/line-prefix-sink.d.ts +50 -0
- package/dist/results/line-prefix-sink.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +4 -3
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +5 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +4 -3
- package/dist/results/revert-result.d.ts.map +1 -1
- package/dist/{results-CkS1p1CH.js → results-rF81cQse.js} +1788 -247
- package/dist/transport-command.d.ts +13 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +21 -13
- package/src/commands/add-command.ts +15 -2
- package/src/commands/add-patch/patch-backend.ts +6 -44
- package/src/commands/archive/archive-command.ts +7 -3
- package/src/commands/archive/remote-archive-command.ts +45 -4
- package/src/commands/archive/upload-archive-writer.ts +34 -22
- package/src/commands/branch-command.ts +57 -4
- package/src/commands/bundle/bundle-format.ts +10 -2
- package/src/commands/bundle/bundle-uri-host.ts +71 -11
- package/src/commands/bundle/bundle-uri.ts +11 -4
- package/src/commands/bundle/bundle-verify.ts +4 -1
- package/src/commands/cat-file/batch-format.ts +17 -18
- package/src/commands/cat-file/cat-file-command.ts +182 -48
- package/src/commands/check-ignore-command.ts +110 -21
- package/src/commands/checkout-command.ts +149 -21
- package/src/commands/checkout-index-command.ts +2 -1
- package/src/commands/checkout-paths.ts +13 -0
- package/src/commands/cherry-pick-command.ts +9 -0
- package/src/commands/clean-interactive.ts +20 -74
- package/src/commands/clone-command.ts +102 -11
- package/src/commands/column/column-config.ts +63 -0
- package/src/commands/column/column-layout.ts +396 -0
- package/src/commands/column/index.ts +2 -0
- package/src/commands/column-command.ts +171 -0
- package/src/commands/comment-char-config.ts +42 -0
- package/src/commands/commit-command.ts +93 -18
- package/src/commands/config-command.ts +28 -0
- package/src/commands/credential-helper.ts +807 -0
- package/src/commands/default-branch.ts +57 -5
- package/src/commands/diff-color-config.ts +23 -10
- package/src/commands/diff-command.ts +25 -2
- package/src/commands/fast-export/fast-export-command.ts +661 -35
- package/src/commands/fast-export/fast-import-command.ts +694 -94
- package/src/commands/fast-export/fast-stream-support.ts +18 -1
- package/src/commands/fetch-command.ts +116 -16
- package/src/commands/fsck/fsck-object-checks.ts +3 -1
- package/src/commands/git-hooks.ts +96 -5
- package/src/commands/history-command.ts +952 -20
- package/src/commands/index-host.ts +51 -0
- package/src/commands/index-refresh.ts +121 -0
- package/src/commands/index.ts +9 -0
- package/src/commands/init-command.ts +57 -4
- package/src/commands/legacy-remotes.ts +4 -20
- package/src/commands/local-transport.ts +183 -18
- package/src/commands/log-command.ts +39 -1
- package/src/commands/log-output.ts +31 -4
- package/src/commands/ls-tree-command.ts +20 -12
- package/src/commands/maintenance-schedule-command.ts +418 -0
- package/src/commands/merge-command.ts +42 -8
- package/src/commands/merge-index-command.ts +202 -0
- package/src/commands/merge-one-file.ts +451 -0
- package/src/commands/merge-support.ts +169 -15
- package/src/commands/object-disk-info.ts +169 -0
- package/src/commands/octopus-merge.ts +37 -128
- package/src/commands/plumbing-input.ts +3 -1
- package/src/commands/promisor-remote-reply.ts +338 -56
- package/src/commands/promisor-remote.ts +39 -6
- package/src/commands/pull-command.ts +173 -27
- package/src/commands/push-command.ts +55 -6
- package/src/commands/range-diff/range-diff-command.ts +86 -3
- package/src/commands/read-tree-command.ts +2 -2
- package/src/commands/rebase-command.ts +46 -1
- package/src/commands/ref-filter/for-each-ref-command.ts +4 -3
- package/src/commands/ref-filter/index.ts +1 -0
- package/src/commands/ref-filter/peel-limit.ts +7 -0
- package/src/commands/ref-filter/ref-filter.ts +68 -7
- package/src/commands/ref-filter/ref-format.ts +85 -11
- package/src/commands/ref-filter/ref-listing-command.ts +30 -0
- package/src/commands/remote-command.ts +2 -2
- package/src/commands/remote-transport.ts +66 -3
- package/src/commands/repack-command.ts +75 -9
- package/src/commands/repo-command.ts +6 -70
- package/src/commands/reset-command.ts +11 -1
- package/src/commands/restore-command.ts +1 -0
- package/src/commands/rev-list-command.ts +205 -3
- package/src/commands/revert-command.ts +9 -0
- package/src/commands/revision-filenames.ts +32 -4
- package/src/commands/revision-range.ts +2 -2
- package/src/commands/revision-resolver.ts +21 -1
- package/src/commands/serve-repository.ts +42 -11
- package/src/commands/served-lazy-fetch.ts +164 -0
- package/src/commands/signing.ts +103 -12
- package/src/commands/split-cmdline.ts +32 -0
- package/src/commands/status-color-config.ts +92 -0
- package/src/commands/status-command.ts +50 -2
- package/src/commands/status-format.ts +198 -50
- package/src/commands/tag-command.ts +57 -2
- package/src/commands/tree-restore.ts +17 -0
- package/src/commands/verify-command.ts +84 -12
- package/src/commands/worktree-add-command.ts +2 -0
- package/src/commands/worktree-overwrite-checks.ts +75 -14
- package/src/errors/commit-errors.ts +52 -2
- package/src/errors/git-api-error.ts +7 -0
- package/src/git-command.ts +105 -4
- package/src/git.ts +153 -0
- package/src/remote-config/remote-config-store.ts +16 -0
- package/src/results/cherry-pick-result.ts +4 -3
- package/src/results/diff-output.ts +8 -0
- package/src/results/diff-words.ts +160 -32
- package/src/results/line-prefix-sink.ts +102 -0
- package/src/results/merge-result.ts +4 -3
- package/src/results/rebase-result.ts +5 -0
- package/src/results/revert-result.ts +4 -3
- 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
|
|
4
|
-
*
|
|
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
|
|
72
|
-
*
|
|
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 =
|
|
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
|
|
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
|
|
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(
|
|
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 =
|
|
165
|
+
if (uiConfig) ui = readColorBool(key, text);
|
|
159
166
|
} else if (key === "diff.color" || key === "color.diff") {
|
|
160
|
-
if (uiConfig) diff =
|
|
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(
|
|
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(
|
|
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${
|
|
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${
|
|
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${
|
|
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 {
|
|
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] = [
|