@statewalker/vcs-commands 0.14.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/remote-archive-command.d.ts +4 -1
- package/dist/commands/archive/remote-archive-command.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/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 +2 -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 +21 -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 +17 -1
- 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 +21 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +28 -0
- 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 +29 -1
- 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/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 +2 -0
- 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 +21 -2
- 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/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/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 +17 -1
- 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 +10 -4
- package/dist/commands/signing.d.ts.map +1 -1
- 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-C9M78Chn.js → commands-DT3VEv50.js} +14879 -16703
- package/dist/errors/commit-errors.d.ts +23 -3
- 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 +30 -4
- package/dist/{fsck-C4US3l0B.js → fsck-BZ508Elg.js} +1 -1
- 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-C43eykfK.js → local-transport-D98U6p4d.js} +184 -683
- package/dist/{maintenance-run-command-CoJFKr2p.js → maintenance-run-command-DZFnbnbo.js} +2285 -79
- 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-B0CWLCAp.js → results-rF81cQse.js} +1425 -202
- package/dist/transport-command.d.ts +10 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/commands/add-command.ts +15 -2
- package/src/commands/add-patch/patch-backend.ts +6 -44
- package/src/commands/archive/remote-archive-command.ts +10 -3
- package/src/commands/branch-command.ts +57 -4
- package/src/commands/cat-file/batch-format.ts +17 -18
- package/src/commands/cat-file/cat-file-command.ts +181 -15
- package/src/commands/check-ignore-command.ts +61 -17
- 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 +13 -0
- 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 +61 -21
- package/src/commands/config-command.ts +28 -0
- package/src/commands/credential-helper.ts +807 -0
- package/src/commands/default-branch.ts +38 -0
- 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 +103 -14
- package/src/commands/git-hooks.ts +85 -0
- 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 +34 -1
- package/src/commands/legacy-remotes.ts +4 -20
- package/src/commands/local-transport.ts +130 -9
- package/src/commands/log-command.ts +39 -1
- package/src/commands/log-output.ts +31 -4
- package/src/commands/maintenance-schedule-command.ts +418 -0
- package/src/commands/merge-command.ts +10 -0
- package/src/commands/merge-index-command.ts +202 -0
- package/src/commands/merge-one-file.ts +451 -0
- package/src/commands/merge-support.ts +127 -11
- package/src/commands/object-disk-info.ts +169 -0
- package/src/commands/octopus-merge.ts +37 -128
- package/src/commands/promisor-remote.ts +14 -3
- package/src/commands/pull-command.ts +173 -27
- package/src/commands/push-command.ts +50 -5
- package/src/commands/range-diff/range-diff-command.ts +86 -3
- 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/ref-filter.ts +59 -4
- package/src/commands/ref-filter/ref-format.ts +83 -10
- 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 +34 -8
- package/src/commands/served-lazy-fetch.ts +164 -0
- package/src/commands/signing.ts +18 -10
- 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 +31 -3
- 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 +48 -2
|
@@ -93,7 +93,7 @@ export interface ParsedRevisionArgs {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/** The state of a revision parse that options share (git's `rev_info`). */
|
|
96
|
-
interface RevisionArgState {
|
|
96
|
+
export interface RevisionArgState {
|
|
97
97
|
/** `--exclude=` patterns, for the next ref option */
|
|
98
98
|
excludes: string[];
|
|
99
99
|
inputGiven: boolean;
|
|
@@ -112,7 +112,7 @@ const hasGlobSpecials = (text: string) => /[*?[\\]/.test(text);
|
|
|
112
112
|
* `main` for `--branches`, `refs/heads/main` for `--all` and `--glob`), and clears the
|
|
113
113
|
* patterns.
|
|
114
114
|
*/
|
|
115
|
-
async function handleRefOption(
|
|
115
|
+
export async function handleRefOption(
|
|
116
116
|
args: readonly string[],
|
|
117
117
|
at: number,
|
|
118
118
|
exclude: boolean,
|
|
@@ -127,6 +127,12 @@ export interface ResolveOptions {
|
|
|
127
127
|
* length), the storage and mapped compatibility ids disambiguated together
|
|
128
128
|
*/
|
|
129
129
|
hashAny?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* git's `GET_OID_REQUIRE_PATH` (`cat-file --textconv`/`--filters` without `--path`): a name
|
|
132
|
+
* that reads no path (`HEAD`, an id) dies `<object>:<path> required, only <object> '<name>'
|
|
133
|
+
* given`
|
|
134
|
+
*/
|
|
135
|
+
requirePath?: boolean;
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
/** git's `get_short_oid` result. */
|
|
@@ -206,6 +212,12 @@ export class RevisionResolver {
|
|
|
206
212
|
* name that read no entry (`S_IFINVALID`), `<rev>:` (the tree itself) included
|
|
207
213
|
*/
|
|
208
214
|
lastMode: number | undefined;
|
|
215
|
+
/**
|
|
216
|
+
* The path the last {@link resolve} read an entry at (git's `GET_OID_RECORD_PATH`
|
|
217
|
+
* `object_context.path`: `<rev>:<path>`'s and `:<path>`'s path from the top, "" for
|
|
218
|
+
* `<rev>:`); undefined for a name that reads no path
|
|
219
|
+
*/
|
|
220
|
+
lastPath: string | undefined;
|
|
209
221
|
private config?: RemoteConfigStore;
|
|
210
222
|
private disambiguateChecked = false;
|
|
211
223
|
/**
|
|
@@ -241,8 +253,14 @@ export class RevisionResolver {
|
|
|
241
253
|
async resolve(name: string, options: ResolveOptions = {}): Promise<ObjectId | undefined> {
|
|
242
254
|
this.checkDisambiguateConfig(name);
|
|
243
255
|
this.lastMode = undefined;
|
|
256
|
+
this.lastPath = undefined;
|
|
244
257
|
const direct = await this.oid1(name, options);
|
|
245
|
-
if (direct !== undefined)
|
|
258
|
+
if (direct !== undefined) {
|
|
259
|
+
if (options.requirePath) {
|
|
260
|
+
this.die(name, `fatal: <object>:<path> required, only <object> '${name}' given`);
|
|
261
|
+
}
|
|
262
|
+
return direct;
|
|
263
|
+
}
|
|
246
264
|
if (name.startsWith(":")) {
|
|
247
265
|
if (!options.onlyToDie && name.length > 2 && name[1] === "/") {
|
|
248
266
|
return this.oneline(name.slice(2), await this.allRefCommits());
|
|
@@ -254,6 +272,7 @@ export class RevisionResolver {
|
|
|
254
272
|
path = name.slice(3);
|
|
255
273
|
}
|
|
256
274
|
const resolved = this.relativePath(path, name);
|
|
275
|
+
this.lastPath = resolved;
|
|
257
276
|
const found = await this.indexEntry(resolved, stage);
|
|
258
277
|
if (found === undefined && options.onlyToDie && name.length > 1 && name[1] !== "/") {
|
|
259
278
|
await this.diagnoseIndexPath(name, stage, resolved);
|
|
@@ -277,6 +296,7 @@ export class RevisionResolver {
|
|
|
277
296
|
return undefined;
|
|
278
297
|
}
|
|
279
298
|
const filename = this.relativePath(name.slice(i + 1), name);
|
|
299
|
+
this.lastPath = filename;
|
|
280
300
|
const tree = await this.peelToType(treeish, "tree");
|
|
281
301
|
const found = tree === undefined ? undefined : await this.treeEntry(tree, filename);
|
|
282
302
|
if (found === undefined && options.onlyToDie) {
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
servedUseBitmaps,
|
|
30
30
|
withReceiveTransactionHook,
|
|
31
31
|
} from "./local-transport.js";
|
|
32
|
+
import { type ServedLazyFetchOptions, uploadPackHistory } from "./served-lazy-fetch.js";
|
|
32
33
|
|
|
33
34
|
/** Options of {@link servedRepositoryOf}. */
|
|
34
35
|
export interface ServedRepositoryOptions {
|
|
@@ -53,6 +54,15 @@ export interface ServedRepositoryOptions {
|
|
|
53
54
|
* host's hook runner in the git directory (`packObjectsHookOf`); `false` runs none
|
|
54
55
|
*/
|
|
55
56
|
packObjectsHook?: "protected" | false;
|
|
57
|
+
/**
|
|
58
|
+
* Lets upload-pack fetch the absent promisor objects a pack needs from the served
|
|
59
|
+
* repository's own promisor remotes, through these transports, as git's upload-pack does
|
|
60
|
+
* when its environment sets `GIT_NO_LAZY_FETCH=0`. Off by default, as git's (`could not
|
|
61
|
+
* fetch <id> from promisor remote`); never read from the repository's config. The fetch
|
|
62
|
+
* carries no static credentials or headers: the promisor URLs are the repository's
|
|
63
|
+
* configuration.
|
|
64
|
+
*/
|
|
65
|
+
lazyFetch?: ServedLazyFetchOptions;
|
|
56
66
|
}
|
|
57
67
|
|
|
58
68
|
/** What the served repository's config decides: left to `serveGitService`'s layering. */
|
|
@@ -135,16 +145,25 @@ export async function servedRepositoryOf(
|
|
|
135
145
|
const hook = await packObjectsHookOf(hooks);
|
|
136
146
|
if (hook) settings.packObjectsHook = hook;
|
|
137
147
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
history
|
|
148
|
+
const facadeOf = (history: typeof remote.history) =>
|
|
149
|
+
createRepositoryFacade({
|
|
150
|
+
history,
|
|
141
151
|
// git's pack.useBitmaps (pack-objects reads it from the served repository)
|
|
142
152
|
useBitmaps: servedUseBitmaps(remote),
|
|
143
153
|
// a sparse:oid filter's patterns
|
|
144
154
|
sparseFilterPatterns: sparseFilterMatcher,
|
|
145
155
|
// core.maxTreeDepth (pack-objects' walk)
|
|
146
156
|
maxTreeDepth: servedMaxTreeDepth(remote),
|
|
147
|
-
})
|
|
157
|
+
});
|
|
158
|
+
// receive-pack never fetches lazily (rev-list --exclude-promisor-objects): the history's
|
|
159
|
+
// view without lazy fetch
|
|
160
|
+
const plain = historyWithoutLazyFetch(remote.history);
|
|
161
|
+
// upload-pack: a view of its own refusing absent promisor objects as git's under its
|
|
162
|
+
// GIT_NO_LAZY_FETCH, or fetching them when the operator opted in (`lazyFetch`)
|
|
163
|
+
const forUploadPack = await uploadPackHistory(remote, options.lazyFetch, hooks?.hostEnvironment);
|
|
164
|
+
return {
|
|
165
|
+
repository: facadeOf(plain),
|
|
166
|
+
...(forUploadPack !== plain ? { uploadPackRepository: facadeOf(forUploadPack) } : {}),
|
|
148
167
|
refStore: createTransportRefStore(remote.history.refs),
|
|
149
168
|
config: remote.config ?? EMPTY_CONFIG,
|
|
150
169
|
settings: settings as GitServeSettings,
|
|
@@ -158,14 +177,15 @@ export async function servedRepositoryOf(
|
|
|
158
177
|
return uploadArchive ? { uploadArchive } : {};
|
|
159
178
|
})(),
|
|
160
179
|
around: <T>(service: string, serve: () => Promise<T>, client?: ServedRequestContext) => {
|
|
161
|
-
// a served partial clone never fetches lazily (upload-pack's GIT_NO_LAZY_FETCH,
|
|
162
|
-
// receive-pack's rev-list --exclude-promisor-objects): the facade reads through the
|
|
163
|
-
// history's view without lazy fetch
|
|
164
180
|
if (service !== "git-receive-pack") return serve();
|
|
165
181
|
if (!hooks?.enabled) return serve();
|
|
166
182
|
// the client's variables (http-backend's REMOTE_USER, ...) reach the
|
|
167
183
|
// reference-transaction hook too, as every child of receive-pack inherits them
|
|
168
|
-
|
|
184
|
+
// (GIT_NAMESPACE too, when the push is served in a namespace)
|
|
185
|
+
const env: Record<string, string> = {
|
|
186
|
+
...(client?.namespace ? { GIT_NAMESPACE: client.namespace } : {}),
|
|
187
|
+
...httpBackendEnv(hooks, client),
|
|
188
|
+
};
|
|
169
189
|
const session = Object.keys(env).length > 0 ? hooks.withEnv(env) : hooks;
|
|
170
190
|
return withReceiveTransactionHook(remote, session, serve);
|
|
171
191
|
},
|
|
@@ -180,6 +200,10 @@ export async function servedRepositoryOf(
|
|
|
180
200
|
* pack-objects ...` through the shell, in the git directory). Undefined when none is set or
|
|
181
201
|
* no runner can start it.
|
|
182
202
|
*
|
|
203
|
+
* With `commandLine: false` the command line's entries (scope `command`) do not count: git's
|
|
204
|
+
* local transport starts `git-upload-pack '<path>'` with connect.c's `local_repo_env` cleared
|
|
205
|
+
* (`GIT_CONFIG_PARAMETERS`, `GIT_CONFIG_COUNT`), so only the system and global files reach it.
|
|
206
|
+
*
|
|
183
207
|
* @example
|
|
184
208
|
* ```ts
|
|
185
209
|
* // ~/.gitconfig: [uploadpack] packObjectsHook = /srv/bin/pack-cache
|
|
@@ -188,11 +212,13 @@ export async function servedRepositoryOf(
|
|
|
188
212
|
*/
|
|
189
213
|
export async function packObjectsHookOf(
|
|
190
214
|
hooks: HookSession | undefined,
|
|
215
|
+
options: { commandLine?: boolean } = {},
|
|
191
216
|
): Promise<PackObjectsHook | undefined> {
|
|
192
217
|
const environment = hooks?.hostEnvironment;
|
|
193
218
|
if (!hooks?.enabled || !environment) return undefined;
|
|
194
219
|
let command: string | undefined;
|
|
195
220
|
for (const entry of await readProtectedConfig(environment)) {
|
|
221
|
+
if (options.commandLine === false && entry.scope === "command") continue;
|
|
196
222
|
if (entry.key.toLowerCase() === "uploadpack.packobjectshook") command = entry.value;
|
|
197
223
|
}
|
|
198
224
|
if (!command) return undefined;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lazy fetch of a served partial clone while upload-pack builds a pack (git's
|
|
3
|
+
* upload-pack, whose pack-objects reads an absent promisor object through
|
|
4
|
+
* promisor_remote_get_direct).
|
|
5
|
+
*
|
|
6
|
+
* Since git 2.45 (and the 2.43.4 backport) upload-pack sets `GIT_NO_LAZY_FETCH=1` unless its
|
|
7
|
+
* environment already sets the variable, so by default a pack that needs an absent promisor
|
|
8
|
+
* object fails: pack-objects prints `warning: lazy fetching disabled; some objects may not be
|
|
9
|
+
* available` and dies `could not fetch <id> from promisor remote`. Ours does the same unless
|
|
10
|
+
* lazy fetching is opted in: the operator's `servedRepositoryOf(opened, { lazyFetch })`, or a
|
|
11
|
+
* local remote's upload-pack when the client's host environment says `GIT_NO_LAZY_FETCH=0`
|
|
12
|
+
* (git's child inherits it). Then the absent object is fetched from the served repository's
|
|
13
|
+
* own promisor remotes, through the transports given, and the pack holds it.
|
|
14
|
+
*
|
|
15
|
+
* Promisor URLs come from the served repository's configuration, which is repository content:
|
|
16
|
+
* the fetch never carries static credentials or headers, only a per-URL credential helper.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const served = await servedRepositoryOf(opened, {
|
|
21
|
+
* lazyFetch: { transports: createDefaultTransports() },
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import {
|
|
27
|
+
type History,
|
|
28
|
+
historyWithoutLazyFetch,
|
|
29
|
+
historyWithPromisorFetcher,
|
|
30
|
+
type ObjectId,
|
|
31
|
+
type PromisorFetcher,
|
|
32
|
+
} from "@statewalker/vcs-core";
|
|
33
|
+
import type { GitTransportRegistry, HttpCredentialHelper } from "@statewalker/vcs-transport";
|
|
34
|
+
import type {
|
|
35
|
+
GitHostEnvironment,
|
|
36
|
+
OpenedRepository,
|
|
37
|
+
WorkingCopy,
|
|
38
|
+
} from "@statewalker/vcs-working-tree";
|
|
39
|
+
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
40
|
+
import {
|
|
41
|
+
createPromisorFetcher,
|
|
42
|
+
hasPromisorRemote,
|
|
43
|
+
LAZY_FETCH_DISABLED_WARNING,
|
|
44
|
+
} from "./promisor-remote.js";
|
|
45
|
+
import { worktreeAdminWorkingCopy } from "./worktree-support.js";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* How a served repository fetches its absent promisor objects (see the module
|
|
49
|
+
* documentation). Static credentials and headers are deliberately not among them.
|
|
50
|
+
*/
|
|
51
|
+
export interface ServedLazyFetchOptions {
|
|
52
|
+
/** The transports the promisor remotes are reached through (default: smart HTTP) */
|
|
53
|
+
transports?: GitTransportRegistry;
|
|
54
|
+
/** Asked for HTTP credentials after a 401, per URL */
|
|
55
|
+
credentialHelper?: HttpCredentialHelper;
|
|
56
|
+
timeout?: number;
|
|
57
|
+
/** git's `warning:` lines of the HTTP client */
|
|
58
|
+
warningCallback?: (line: string) => void;
|
|
59
|
+
/**
|
|
60
|
+
* The host environment the fetch runs in (its file reads, hook runner and git version);
|
|
61
|
+
* by default the served repository's hooks' environment
|
|
62
|
+
*/
|
|
63
|
+
environment?: GitHostEnvironment;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The history upload-pack reads for `remote`, as git's upload-pack reads it: a view of its
|
|
68
|
+
* own whose absent promisor objects are refused with git's warning and death
|
|
69
|
+
* (`GIT_NO_LAZY_FETCH=1`), or, when `lazyFetch` opts in, fetched from the repository's
|
|
70
|
+
* promisor remotes through its transports. The store's promisor and fetcher are left as
|
|
71
|
+
* they are, so receive-pack and every other reader of the store are untouched. A repository
|
|
72
|
+
* without worktrees or promisor remotes, or without promisor packs unless `lazyFetch` is
|
|
73
|
+
* given, is read through its view without lazy fetch.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const history = await uploadPackHistory(opened, { transports }, hooks.hostEnvironment);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export async function uploadPackHistory(
|
|
81
|
+
remote: OpenedRepository,
|
|
82
|
+
lazyFetch: ServedLazyFetchOptions | undefined,
|
|
83
|
+
environment: GitHostEnvironment | undefined,
|
|
84
|
+
): Promise<History> {
|
|
85
|
+
const plain = historyWithoutLazyFetch(remote.history);
|
|
86
|
+
const promisor = (() => {
|
|
87
|
+
try {
|
|
88
|
+
return remote.history.objects?.promisor;
|
|
89
|
+
} catch {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
})();
|
|
93
|
+
if (!promisor || !remote.worktrees) return plain;
|
|
94
|
+
// not a partial clone: nothing to refuse (git's refusal dies only for promisor objects)
|
|
95
|
+
if (!lazyFetch && (await promisor.promisorPacks().catch(() => [])).length === 0) return plain;
|
|
96
|
+
let view: History | undefined;
|
|
97
|
+
const workingCopy = await servedWorkingCopy(
|
|
98
|
+
remote,
|
|
99
|
+
() => view ?? plain,
|
|
100
|
+
lazyFetch?.environment ?? environment,
|
|
101
|
+
).catch(() => undefined);
|
|
102
|
+
if (!workingCopy || !hasPromisorRemote(RemoteConfigStore.from(workingCopy))) return plain;
|
|
103
|
+
// never the operator's or a client's static credentials: the promisor URL is the served
|
|
104
|
+
// repository's configuration
|
|
105
|
+
const fetcher = lazyFetch
|
|
106
|
+
? createPromisorFetcher(workingCopy, {
|
|
107
|
+
...(lazyFetch.transports ? { transports: lazyFetch.transports } : {}),
|
|
108
|
+
...(lazyFetch.credentialHelper ? { credentialHelper: lazyFetch.credentialHelper } : {}),
|
|
109
|
+
...(lazyFetch.timeout !== undefined ? { timeout: lazyFetch.timeout } : {}),
|
|
110
|
+
...(lazyFetch.warningCallback ? { warningCallback: lazyFetch.warningCallback } : {}),
|
|
111
|
+
})
|
|
112
|
+
: refusingFetcher(() => view?.objects?.promisor?.warnings);
|
|
113
|
+
view = historyWithPromisorFetcher(remote.history, fetcher);
|
|
114
|
+
return view ?? plain;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* upload-pack's `GIT_NO_LAZY_FETCH=1`: every read of an absent object still asks (git's
|
|
119
|
+
* pack-objects reads with `fetch_if_missing`), fetch_objects refuses with its warning (once
|
|
120
|
+
* per upload-pack process: a refusal of a promisor object is its death), and
|
|
121
|
+
* promisor_remote_get_direct dies for a promisor object.
|
|
122
|
+
*/
|
|
123
|
+
function refusingFetcher(warnings: () => string[] | undefined): PromisorFetcher {
|
|
124
|
+
return {
|
|
125
|
+
hasPromisorRemote: () => true,
|
|
126
|
+
invalidate: () => {},
|
|
127
|
+
fetchIfMissing: () => true,
|
|
128
|
+
async fetch(ids: readonly ObjectId[]) {
|
|
129
|
+
warnings()?.push(LAZY_FETCH_DISABLED_WARNING);
|
|
130
|
+
return ids;
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The served repository as a working copy the promisor fetcher reads (its configuration,
|
|
137
|
+
* remotes, local paths), over the history `history` gives (upload-pack's view: the fetch's
|
|
138
|
+
* warnings go to its promisor, its objects to the store) and in `environment`.
|
|
139
|
+
*/
|
|
140
|
+
async function servedWorkingCopy(
|
|
141
|
+
remote: OpenedRepository,
|
|
142
|
+
history: () => History,
|
|
143
|
+
environment: GitHostEnvironment | undefined,
|
|
144
|
+
): Promise<WorkingCopy | undefined> {
|
|
145
|
+
const worktrees = remote.worktrees;
|
|
146
|
+
if (!worktrees) return undefined;
|
|
147
|
+
const base = worktreeAdminWorkingCopy(await worktrees.openAdmin());
|
|
148
|
+
const own = <O extends object>(target: O, key: string | symbol): unknown => {
|
|
149
|
+
const value = Reflect.get(target, key, target);
|
|
150
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
151
|
+
};
|
|
152
|
+
const config = environment
|
|
153
|
+
? new Proxy(base.config, {
|
|
154
|
+
get: (target, key) => (key === "environment" ? environment : own(target, key)),
|
|
155
|
+
})
|
|
156
|
+
: base.config;
|
|
157
|
+
return new Proxy(base, {
|
|
158
|
+
get: (target, key) => {
|
|
159
|
+
if (key === "history") return history();
|
|
160
|
+
if (key === "config") return config;
|
|
161
|
+
return own(target, key);
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
}
|
package/src/commands/signing.ts
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
* `commit_tree_extended` / `add_header_signature` do. `commit -S` and `tag -s`/`-u` sign (the
|
|
12
12
|
* tag's signature appended to its message, builtin/tag.c's `do_sign`), and so do the
|
|
13
13
|
* commands that write commits for the user: rebase, cherry-pick, revert, merge and am
|
|
14
|
-
* (statewalker/statewalker-root#319, each through {@link signCommit})
|
|
15
|
-
*
|
|
14
|
+
* (statewalker/statewalker-root#319, each through {@link signCommit}). `push --signed` signs
|
|
15
|
+
* its push certificate too (send-pack's `generate_push_cert`): `PushCommand`'s push
|
|
16
|
+
* certificate signer hands the certificate to {@link signPayload}.
|
|
16
17
|
*
|
|
17
18
|
* Without a signer every request to sign fails as native git fails when its signing program
|
|
18
19
|
* cannot sign (gpg-interface.c `sign_buffer_gpg`: `error: gpg failed to sign the data:` with
|
|
@@ -498,12 +499,15 @@ function sshPublicKeyBlob(text: string): Uint8Array | undefined {
|
|
|
498
499
|
* (a command's {@link HookSession}).
|
|
499
500
|
*/
|
|
500
501
|
export interface SigningKeyHost {
|
|
501
|
-
/**
|
|
502
|
-
|
|
502
|
+
/**
|
|
503
|
+
* Runs an argv without a shell in the directory git runs in (the worktree top), as git's
|
|
504
|
+
* `pipe_command` with `use_shell = 0` runs it (`HookSession.runArgv`): `startError` is git's
|
|
505
|
+
* line for a program it cannot start
|
|
506
|
+
*/
|
|
507
|
+
runArgv(
|
|
503
508
|
name: string,
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
): Promise<{ exitCode: number; stdout: string; stderr: string } | undefined>;
|
|
509
|
+
argv: readonly string[],
|
|
510
|
+
): Promise<{ exitCode: number; stdout: string; stderr: string; startError?: string } | undefined>;
|
|
507
511
|
/** That directory on the host, where the repository's files have one */
|
|
508
512
|
hostWorkingDirectory(): Promise<string | undefined>;
|
|
509
513
|
}
|
|
@@ -543,12 +547,16 @@ async function defaultSshSigningKey(
|
|
|
543
547
|
128,
|
|
544
548
|
);
|
|
545
549
|
}
|
|
546
|
-
const
|
|
550
|
+
const program = argv[0] ?? "";
|
|
547
551
|
const messages: string[] = [];
|
|
548
552
|
// pipe_command of an empty program: execvp("") fails, start_command names no program
|
|
549
|
-
let ran: { exitCode: number; stdout: string; stderr: string } | undefined;
|
|
553
|
+
let ran: { exitCode: number; stdout: string; stderr: string; startError?: string } | undefined;
|
|
550
554
|
if (program === "") messages.push("error: cannot run : No such file or directory");
|
|
551
|
-
else
|
|
555
|
+
else {
|
|
556
|
+
// pipe_command with use_shell = 0: execvp of the split words, no shell
|
|
557
|
+
ran = await host?.runArgv("gpg.ssh.defaultKeyCommand", argv);
|
|
558
|
+
if (ran?.startError !== undefined) messages.push(ran.startError);
|
|
559
|
+
}
|
|
552
560
|
const stdout = ran?.stdout ?? "";
|
|
553
561
|
const stderr = ran?.stderr ?? "";
|
|
554
562
|
if (ran?.exitCode === 0) {
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colors of `git status` (and `git commit --dry-run`) as builtin/commit.c's
|
|
3
|
+
* `git_status_config` reads them: `color.status` or `status.color` (a color bool, the last
|
|
4
|
+
* one read wins), else `color.ui`; the slots through `color.status.<slot>` or
|
|
5
|
+
* `status.color.<slot>` (`header`, `updated` or `added`, `changed`, `untracked`,
|
|
6
|
+
* `noBranch`, `unmerged`, `localBranch`, `remoteBranch`, `branch`), each parsed as git's
|
|
7
|
+
* colors. A slot git does not know is ignored, a known one without a value or with a value
|
|
8
|
+
* git refuses dies as git dies. Without a terminal `auto` means no color.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const colors = readStatusColors(workingCopy); // undefined: no color
|
|
13
|
+
* formatStatusText(status, header, { format: "short", colors });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { WorkingCopy } from "@statewalker/vcs-working-tree";
|
|
20
|
+
|
|
21
|
+
import { InvalidConfigError } from "../errors/index.js";
|
|
22
|
+
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
23
|
+
import { parseGitColor } from "./config-value-types.js";
|
|
24
|
+
import { badConfigVariableLine, readColorBool } from "./diff-color-config.js";
|
|
25
|
+
import { DEFAULT_STATUS_COLORS, type StatusColors } from "./status-format.js";
|
|
26
|
+
|
|
27
|
+
/** builtin/commit.c's `color_status_slots` (and `added`), by lowercased name */
|
|
28
|
+
const STATUS_SLOTS: Record<string, keyof StatusColors> = {
|
|
29
|
+
header: "header",
|
|
30
|
+
updated: "updated",
|
|
31
|
+
added: "updated",
|
|
32
|
+
changed: "changed",
|
|
33
|
+
untracked: "untracked",
|
|
34
|
+
nobranch: "noBranch",
|
|
35
|
+
unmerged: "unmerged",
|
|
36
|
+
localbranch: "localBranch",
|
|
37
|
+
remotebranch: "remoteBranch",
|
|
38
|
+
branch: "branch",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** What the caller says about colors (each unset: the configuration's) */
|
|
42
|
+
export interface StatusColorOptions {
|
|
43
|
+
/** A color option: true is `always`, false `never` */
|
|
44
|
+
color?: boolean | "always" | "never" | "auto";
|
|
45
|
+
/** 2.43 knows no `#rgb` colors (default 2.56) */
|
|
46
|
+
compatibility?: "2.43" | "2.56";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The palette of status's human formats, or undefined for no color.
|
|
51
|
+
*
|
|
52
|
+
* @throws InvalidConfigError for a value git refuses (exit 128)
|
|
53
|
+
*/
|
|
54
|
+
export function readStatusColors(
|
|
55
|
+
workingCopy: WorkingCopy,
|
|
56
|
+
options: StatusColorOptions = {},
|
|
57
|
+
): StatusColors | undefined {
|
|
58
|
+
const compatibility = options.compatibility ?? "2.56";
|
|
59
|
+
const colors: StatusColors = { ...DEFAULT_STATUS_COLORS };
|
|
60
|
+
let ui: "never" | "always" | "auto" | undefined;
|
|
61
|
+
let status: "never" | "always" | "auto" | undefined;
|
|
62
|
+
const entries = workingCopy.config
|
|
63
|
+
? (RemoteConfigStore.from(workingCopy).allEntriesWithOrigin() ?? [])
|
|
64
|
+
: [];
|
|
65
|
+
for (const { key, text, file, line } of entries) {
|
|
66
|
+
if (key === "color.ui") ui = readColorBool(key, text);
|
|
67
|
+
else if (key === "color.status" || key === "status.color") status = readColorBool(key, text);
|
|
68
|
+
else if (key.startsWith("color.status.") || key.startsWith("status.color.")) {
|
|
69
|
+
const slot = STATUS_SLOTS[key.slice(13).toLowerCase()];
|
|
70
|
+
if (!slot) continue;
|
|
71
|
+
if (text === undefined) {
|
|
72
|
+
throw new InvalidConfigError(
|
|
73
|
+
key,
|
|
74
|
+
`error: missing value for '${key}'\n${badConfigVariableLine(key, file, line)}`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
const color = parseGitColor(text, compatibility);
|
|
78
|
+
if (color === undefined) {
|
|
79
|
+
throw new InvalidConfigError(
|
|
80
|
+
key,
|
|
81
|
+
`error: invalid color value: ${text}\n${badConfigVariableLine(key, file, line)}`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
colors[slot] = color;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
let want = status ?? ui ?? "auto";
|
|
88
|
+
if (options.color !== undefined) {
|
|
89
|
+
want = options.color === true ? "always" : options.color === false ? "never" : options.color;
|
|
90
|
+
}
|
|
91
|
+
return want === "always" ? colors : undefined;
|
|
92
|
+
}
|
|
@@ -50,6 +50,12 @@ import {
|
|
|
50
50
|
type StatusSide,
|
|
51
51
|
submoduleToken,
|
|
52
52
|
} from "../results/status-result.js";
|
|
53
|
+
import {
|
|
54
|
+
applyColumnOption,
|
|
55
|
+
columnConfigOf,
|
|
56
|
+
finalizeColopts,
|
|
57
|
+
terminalColumnsOf,
|
|
58
|
+
} from "./column/index.js";
|
|
53
59
|
import { coreBool, worktreeModeTrust } from "./core-config.js";
|
|
54
60
|
import { DiffCommand } from "./diff-command.js";
|
|
55
61
|
import { hostEnvironmentOf } from "./git-ident.js";
|
|
@@ -65,6 +71,7 @@ import {
|
|
|
65
71
|
untrackedScanPathspec,
|
|
66
72
|
} from "./pathspec.js";
|
|
67
73
|
import { PathspecAttributes } from "./pathspec-attributes.js";
|
|
74
|
+
import { readStatusColors } from "./status-color-config.js";
|
|
68
75
|
import {
|
|
69
76
|
type CommitWhence,
|
|
70
77
|
formatStatusText,
|
|
@@ -593,6 +600,21 @@ export class StatusCommand extends GitCommand<Status> {
|
|
|
593
600
|
? !cfgBool(config, "status.aheadBehind", true)
|
|
594
601
|
: false;
|
|
595
602
|
const showStash = options.showStash ?? cfgBool(config, "status.showStash", false);
|
|
603
|
+
// git_status_config: the colors (a bad slot dies before anything is read, the commit
|
|
604
|
+
// template's run too); never in a file (the commit template: GIT_COLOR_NEVER)
|
|
605
|
+
const palette = readStatusColors(this.workingCopy, {
|
|
606
|
+
...(options.color !== undefined ? { color: options.color } : {}),
|
|
607
|
+
...(options.colorCompatibility ? { compatibility: options.colorCompatibility } : {}),
|
|
608
|
+
});
|
|
609
|
+
const colors = options.toFile ? undefined : palette;
|
|
610
|
+
// git_status_config's column.ui/column.status (a bad value dies), then --column; the
|
|
611
|
+
// commit template's s.colopts is 0
|
|
612
|
+
let colopts: number | undefined;
|
|
613
|
+
if (options.commitTemplate !== true) {
|
|
614
|
+
colopts = columnConfigOf(this.workingCopy, "status");
|
|
615
|
+
if (options.column !== undefined) colopts = applyColumnOption(colopts, options.column);
|
|
616
|
+
colopts = finalizeColopts(colopts);
|
|
617
|
+
}
|
|
596
618
|
const status = await this.call();
|
|
597
619
|
const hints = options.hints ?? cfgBool(config, "advice.statusHints", true);
|
|
598
620
|
const commentPrefix =
|
|
@@ -621,6 +643,7 @@ export class StatusCommand extends GitCommand<Status> {
|
|
|
621
643
|
worktreeChanges: info.worktreeChanges,
|
|
622
644
|
referenceId,
|
|
623
645
|
commentPrefix,
|
|
646
|
+
headerColor: colors?.header ?? "",
|
|
624
647
|
});
|
|
625
648
|
}
|
|
626
649
|
const summaryLimit = resolvedFormat === "long" ? this.submoduleSummaryLimit() : 0;
|
|
@@ -646,6 +669,11 @@ export class StatusCommand extends GitCommand<Status> {
|
|
|
646
669
|
aheadBehindQuick: quick,
|
|
647
670
|
...(verbose !== undefined ? { verbose } : {}),
|
|
648
671
|
...(submoduleSummary ? { submoduleSummary } : {}),
|
|
672
|
+
...(colors ? { colors } : {}),
|
|
673
|
+
...(options.colorCompatibility ? { compatibility: options.colorCompatibility } : {}),
|
|
674
|
+
...(colopts
|
|
675
|
+
? { colopts, termColumns: terminalColumnsOf(this.workingCopy, options.columns) }
|
|
676
|
+
: {}),
|
|
649
677
|
});
|
|
650
678
|
return {
|
|
651
679
|
...out,
|
|
@@ -752,10 +780,15 @@ export class StatusCommand extends GitCommand<Status> {
|
|
|
752
780
|
worktreeChanges: boolean;
|
|
753
781
|
referenceId: ObjectId | undefined;
|
|
754
782
|
commentPrefix: string | undefined;
|
|
783
|
+
/** The header's color (`-vv`'s headers are status_printf_ln in it) */
|
|
784
|
+
headerColor: string;
|
|
755
785
|
},
|
|
756
786
|
): Promise<string> {
|
|
757
|
-
const p = (text: string) =>
|
|
758
|
-
|
|
787
|
+
const p = (text: string) => {
|
|
788
|
+
const line =
|
|
789
|
+
o.commentPrefix !== undefined ? `${o.commentPrefix}${text ? ` ${text}` : ""}` : text;
|
|
790
|
+
return o.headerColor ? `${o.headerColor}${line}\x1b[m\n` : `${line}\n`;
|
|
791
|
+
};
|
|
759
792
|
let out = "";
|
|
760
793
|
if (o.toFile && !o.cutLineAdded) out += cutLine(o.commentPrefix ?? "#");
|
|
761
794
|
const twoLevels = level > 1;
|
|
@@ -1592,6 +1625,21 @@ export interface StatusCallTextOptions {
|
|
|
1592
1625
|
toFile?: boolean;
|
|
1593
1626
|
/** The cut line was written already (`s->added_cut_line`) */
|
|
1594
1627
|
cutLineAdded?: boolean;
|
|
1628
|
+
/**
|
|
1629
|
+
* A color option over `color.status`/`color.ui` (true is `always`); the long and short
|
|
1630
|
+
* formats only, never in a file ({@link toFile}). `auto` is no color (no terminal).
|
|
1631
|
+
*/
|
|
1632
|
+
color?: boolean | "always" | "never" | "auto";
|
|
1633
|
+
/** 2.43 knows no `#rgb` colors and leaves `-s -z`'s `??`/`!!` uncolored (default 2.56) */
|
|
1634
|
+
colorCompatibility?: "2.43" | "2.56";
|
|
1635
|
+
/**
|
|
1636
|
+
* `--column` (`true`: `always`), `--column=<options>` or `--no-column` (`false`) over
|
|
1637
|
+
* `column.ui`/`column.status`: the long format's untracked and ignored lists in columns
|
|
1638
|
+
* (`auto` never: no terminal). The commit template never lays out.
|
|
1639
|
+
*/
|
|
1640
|
+
column?: string | boolean;
|
|
1641
|
+
/** The terminal's width columns fill (`$COLUMNS`; default the host's, else 80) */
|
|
1642
|
+
columns?: number;
|
|
1595
1643
|
}
|
|
1596
1644
|
|
|
1597
1645
|
/** What `StatusCommand.callText` gives: the text, the status, and git's warnings. */
|