@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,4 +1,5 @@
|
|
|
1
1
|
import { type Credentials, type GitTransportRegistry, type HttpClientSettings, type HttpCredentialHelper, type ProgressInfo } from "@statewalker/vcs-transport";
|
|
2
|
+
import type { ObjectFormat } from "@statewalker/vcs-utils/hash";
|
|
2
3
|
import type { WorkingCopy } from "@statewalker/vcs-working-tree";
|
|
3
4
|
import { type BundleUriHost } from "./commands/bundle/index.js";
|
|
4
5
|
import { type PreparedRemote, type RemoteSessionOptions, type ResolvedRemote } from "./commands/remote-transport.js";
|
|
@@ -51,6 +52,8 @@ export declare abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
51
52
|
protected credentialHelper?: HttpCredentialHelper;
|
|
52
53
|
/** git's `warning:` lines of the HTTP client */
|
|
53
54
|
protected warningCallback?: (line: string) => void;
|
|
55
|
+
/** The helper built from `credential.helper` for this command (see {@link httpCredentialHelper}) */
|
|
56
|
+
private configCredentialHelper?;
|
|
54
57
|
constructor(workingCopy: WorkingCopy);
|
|
55
58
|
/**
|
|
56
59
|
* What a lazy fetch during the call reaches the promisor remote with: this command's
|
|
@@ -128,6 +131,14 @@ export declare abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
128
131
|
* ```
|
|
129
132
|
*/
|
|
130
133
|
setCredentialHelper(helper: HttpCredentialHelper): this;
|
|
134
|
+
/**
|
|
135
|
+
* The credential helper this command's HTTP requests ask: the one given to
|
|
136
|
+
* {@link setCredentialHelper}, else, when the configuration names a `credential.helper`
|
|
137
|
+
* and the host has a hook runner, git's helpers of that configuration (credential.c through
|
|
138
|
+
* {@link credentialHelperOf}: their stderr in the hook output), as git's transports read
|
|
139
|
+
* them; else none.
|
|
140
|
+
*/
|
|
141
|
+
protected httpCredentialHelper(): HttpCredentialHelper | undefined;
|
|
131
142
|
/**
|
|
132
143
|
* Receives the `warning:` lines git's HTTP client prints on stderr (`rate limited, waiting
|
|
133
144
|
* <n> seconds before retry`).
|
|
@@ -206,6 +217,8 @@ export declare abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
206
217
|
message(line: string): void;
|
|
207
218
|
setConfigValue?(key: string, value: string): Promise<void>;
|
|
208
219
|
tempFileName?(): string;
|
|
220
|
+
/** The hash bundle headers are read in (default the repository's) */
|
|
221
|
+
objectFormat?: ObjectFormat;
|
|
209
222
|
}): BundleUriHost;
|
|
210
223
|
/**
|
|
211
224
|
* `git -c fetch.bundleURI=<uri> fetch`: the bundle URI this fetch downloads before talking
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport-command.d.ts","sourceRoot":"","sources":["../src/transport-command.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"transport-command.d.ts","sourceRoot":"","sources":["../src/transport-command.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,4BAA4B,CAAC;AAOpC,OAAO,EAKL,KAAK,cAAc,EAGnB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EAGpB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iCAAiC;IACjC,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oFAAoF;IACpF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,wBAAwB;IACxB,UAAU,CAAC,EAAE,gBAAgB,CAAC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CAAC,MAAM,EAAE,CAAC,CAYnB;IAED;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,gBAAgB,CAShD;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statewalker/vcs-commands",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Git-like VCS commands (commit, checkout, merge, diff, log)",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/statewalker/webrun-vcs/issues"
|
|
@@ -43,16 +43,24 @@
|
|
|
43
43
|
},
|
|
44
44
|
"files": [
|
|
45
45
|
"dist",
|
|
46
|
-
"src"
|
|
46
|
+
"src",
|
|
47
|
+
"!**/__tests__",
|
|
48
|
+
"!**/__mocks__",
|
|
49
|
+
"!**/__fixtures__",
|
|
50
|
+
"!**/fixtures",
|
|
51
|
+
"!**/tests",
|
|
52
|
+
"!**/test",
|
|
53
|
+
"!**/*.test.*",
|
|
54
|
+
"!**/*.spec.*"
|
|
47
55
|
],
|
|
48
56
|
"dependencies": {
|
|
49
57
|
"@statewalker/webrun-rpc": "^0.15.0",
|
|
50
|
-
"@statewalker/vcs-core": "^0.
|
|
51
|
-
"@statewalker/vcs-
|
|
52
|
-
"@statewalker/vcs-store-mem": "^0.
|
|
53
|
-
"@statewalker/vcs-
|
|
54
|
-
"@statewalker/vcs-
|
|
55
|
-
"@statewalker/vcs-working-tree": "^0.
|
|
58
|
+
"@statewalker/vcs-core": "^0.14.0",
|
|
59
|
+
"@statewalker/vcs-transport": "^0.15.0",
|
|
60
|
+
"@statewalker/vcs-store-mem": "^0.14.0",
|
|
61
|
+
"@statewalker/vcs-store-files": "^0.14.0",
|
|
62
|
+
"@statewalker/vcs-utils": "^0.12.0",
|
|
63
|
+
"@statewalker/vcs-working-tree": "^0.14.0"
|
|
56
64
|
},
|
|
57
65
|
"devDependencies": {
|
|
58
66
|
"@types/node": "^26.6.4",
|
|
@@ -61,11 +69,11 @@
|
|
|
61
69
|
"typescript": "^7.0.2",
|
|
62
70
|
"vitest": "^5.1.0",
|
|
63
71
|
"ws": "^8.22.0",
|
|
64
|
-
"@statewalker/vcs-store-
|
|
65
|
-
"@statewalker/vcs-store-
|
|
66
|
-
"@statewalker/vcs-transport-adapters": "^0.
|
|
67
|
-
"@statewalker/vcs-transport-lfs": "^0.
|
|
68
|
-
"@statewalker/vcs-utils-node": "^0.
|
|
72
|
+
"@statewalker/vcs-store-sql": "^0.14.0",
|
|
73
|
+
"@statewalker/vcs-store-kv": "^0.14.0",
|
|
74
|
+
"@statewalker/vcs-transport-adapters": "^0.15.0",
|
|
75
|
+
"@statewalker/vcs-transport-lfs": "^0.11.0",
|
|
76
|
+
"@statewalker/vcs-utils-node": "^0.13.0"
|
|
69
77
|
},
|
|
70
78
|
"scripts": {
|
|
71
79
|
"build": "rm -rf dist && rolldown -c && tsc --emitDeclarationOnly --declaration",
|
|
@@ -3,6 +3,7 @@ import { compareGitPaths } from "@statewalker/vcs-utils/encoding";
|
|
|
3
3
|
import {
|
|
4
4
|
applyStatUpdate,
|
|
5
5
|
compareWithWorktree,
|
|
6
|
+
FilterDriverError,
|
|
6
7
|
IndexPathLookup,
|
|
7
8
|
type IndexStatUpdate,
|
|
8
9
|
type NestedRepositoryState,
|
|
@@ -994,7 +995,7 @@ export class AddCommand extends GitCommand<AddResult> {
|
|
|
994
995
|
if (outcome === "added") output.push(`add '${displayPath}'`);
|
|
995
996
|
return "ok";
|
|
996
997
|
} catch (error) {
|
|
997
|
-
if (!(error instanceof AddToIndexError)) throw error;
|
|
998
|
+
if (!(error instanceof AddToIndexError)) throw withEarlierWarnings(error, warnings);
|
|
998
999
|
errors.push(...error.lines);
|
|
999
1000
|
failed.push(path);
|
|
1000
1001
|
return "failed";
|
|
@@ -1666,7 +1667,7 @@ export class AddCommand extends GitCommand<AddResult> {
|
|
|
1666
1667
|
onWarning: (message) => warnings.push(message),
|
|
1667
1668
|
});
|
|
1668
1669
|
} catch (error) {
|
|
1669
|
-
if (!(error instanceof AddToIndexError)) throw error;
|
|
1670
|
+
if (!(error instanceof AddToIndexError)) throw withEarlierWarnings(error, warnings);
|
|
1670
1671
|
errors.push(...error.lines);
|
|
1671
1672
|
failed.push(path);
|
|
1672
1673
|
continue;
|
|
@@ -1829,3 +1830,15 @@ function embeddedRepoAdvice(path: string): string[] {
|
|
|
1829
1830
|
'hint: See "git help submodule" for more information.',
|
|
1830
1831
|
];
|
|
1831
1832
|
}
|
|
1833
|
+
|
|
1834
|
+
/**
|
|
1835
|
+
* A required filter's death (`FilterDriverError`) with the lines git printed before it (the
|
|
1836
|
+
* conversion's warnings so far: a filter's `error:` lines and stderr); other errors as
|
|
1837
|
+
* they are.
|
|
1838
|
+
*/
|
|
1839
|
+
function withEarlierWarnings(error: unknown, warnings: readonly string[]): unknown {
|
|
1840
|
+
if (error instanceof FilterDriverError && warnings.length > 0) {
|
|
1841
|
+
error.warnings = [...warnings, ...(error.warnings ?? [])];
|
|
1842
|
+
}
|
|
1843
|
+
return error;
|
|
1844
|
+
}
|
|
@@ -8,20 +8,14 @@ import { EMPTY_TREE_ID, FileMode } from "@statewalker/vcs-core";
|
|
|
8
8
|
import { MemoryStagingStore } from "@statewalker/vcs-store-mem";
|
|
9
9
|
import type { XdiffAlgorithm } from "@statewalker/vcs-utils";
|
|
10
10
|
import { compareGitPaths } from "@statewalker/vcs-utils/encoding";
|
|
11
|
-
import {
|
|
12
|
-
applyStatUpdate,
|
|
13
|
-
compareWithWorktree,
|
|
14
|
-
type IndexStatUpdate,
|
|
15
|
-
type StagingEntry,
|
|
16
|
-
statUpdateOf,
|
|
17
|
-
withWorktreeEntries,
|
|
18
|
-
} from "@statewalker/vcs-working-tree";
|
|
11
|
+
import type { StagingEntry } from "@statewalker/vcs-working-tree";
|
|
19
12
|
|
|
20
13
|
import { GitCommand } from "../../git-command.js";
|
|
21
14
|
import type { WorkingCopy } from "../../types.js";
|
|
22
15
|
import { ApplyCommand, bytesToLatin1, latin1ToBytes } from "../apply/index.js";
|
|
23
16
|
import { worktreeModeTrust } from "../core-config.js";
|
|
24
17
|
import { DiffCommand } from "../diff-command.js";
|
|
18
|
+
import { applyIndexStatUpdates, refreshIndexEntries } from "../index-refresh.js";
|
|
25
19
|
import type { PatchBackend } from "./add-patch.js";
|
|
26
20
|
import type { PatchMode } from "./patch-modes.js";
|
|
27
21
|
|
|
@@ -207,46 +201,14 @@ export class IndexRefresh extends GitCommand<string> {
|
|
|
207
201
|
await this.readCurrentIndex(false);
|
|
208
202
|
const staging = this.staging;
|
|
209
203
|
const worktree = this.workingCopy.worktree;
|
|
210
|
-
const entries: StagingEntry[] = [];
|
|
211
|
-
for await (const entry of staging.entryList?.() ?? staging.entries()) entries.push(entry);
|
|
212
204
|
let out = "";
|
|
213
205
|
let hasErrors = false;
|
|
214
|
-
const updates: IndexStatUpdate[] = [];
|
|
215
206
|
if (worktree) {
|
|
216
207
|
const trust = worktreeModeTrust(this.workingCopy, worktree);
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
!entry.skipWorktree &&
|
|
222
|
-
!entry.assumeValid &&
|
|
223
|
-
!entry.intentToAdd &&
|
|
224
|
-
entry.mode !== FileMode.GITLINK;
|
|
225
|
-
let lastUnmerged: string | undefined;
|
|
226
|
-
for await (const { item: entry, current } of withWorktreeEntries(worktree, entries, stated)) {
|
|
227
|
-
if (entry.stage !== 0) {
|
|
228
|
-
if (entry.path !== lastUnmerged) out += `${entry.path}: needs merge\n`;
|
|
229
|
-
hasErrors = true;
|
|
230
|
-
lastUnmerged = entry.path;
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
if (!stated(entry)) continue;
|
|
234
|
-
const compared = await compareWithWorktree(worktree, entry, { trust, indexTime }, current);
|
|
235
|
-
if (compared.kind) continue;
|
|
236
|
-
const update = statUpdateOf(entry, compared);
|
|
237
|
-
if (update && !update.smudge) updates.push(update);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
if (updates.length > 0) {
|
|
241
|
-
const now = Date.now();
|
|
242
|
-
const editor = staging.createEditor();
|
|
243
|
-
for (const update of updates) {
|
|
244
|
-
editor.add({
|
|
245
|
-
path: update.path,
|
|
246
|
-
apply: (existing) => applyStatUpdate(existing, update, now) ?? existing,
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
await editor.finish();
|
|
208
|
+
const refresh = await refreshIndexEntries(staging, worktree, { trust });
|
|
209
|
+
for (const path of refresh.unmerged) out += `${path}: needs merge\n`;
|
|
210
|
+
hasErrors = refresh.unmerged.length > 0;
|
|
211
|
+
await applyIndexStatUpdates(staging, refresh.updates);
|
|
250
212
|
}
|
|
251
213
|
// written whether or not an entry changed (write_locked_index); a gentle refresh that
|
|
252
214
|
// cannot take the lock keeps its result in memory
|
|
@@ -334,9 +334,13 @@ export class ArchiveCommand extends GitCommand<Uint8Array> {
|
|
|
334
334
|
return this;
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
-
/**
|
|
338
|
-
|
|
339
|
-
|
|
337
|
+
/**
|
|
338
|
+
* What git printed on stderr (`-v`'s paths, warnings), from the `from`th message on: read
|
|
339
|
+
* while {@link callStream} runs, the messages so far (upload-archive sends them on as they
|
|
340
|
+
* come).
|
|
341
|
+
*/
|
|
342
|
+
getMessages(from = 0): string[] {
|
|
343
|
+
return this.messages.slice(from);
|
|
340
344
|
}
|
|
341
345
|
|
|
342
346
|
/** `git archive --list`: the formats, as git lists them. */
|
|
@@ -19,11 +19,24 @@ import { withRemoteSession } from "../remote-transport.js";
|
|
|
19
19
|
import { ArchiveCommand } from "./archive-command.js";
|
|
20
20
|
import { uploadArchiveWriterOf } from "./upload-archive-writer.js";
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* What either end of the in-process upload-archive may write ahead of the other: a Linux
|
|
24
|
+
* pipe's capacity, as git's pipes to its upload-archive child (so a request the writer stops
|
|
25
|
+
* reading fails the client as git's does, statewalker/webrun-vcs#516).
|
|
26
|
+
*/
|
|
27
|
+
const LOCAL_HIGH_WATER_MARK = 1 << 16;
|
|
28
|
+
|
|
22
29
|
/** What `git archive --remote` gave. */
|
|
23
30
|
export interface RemoteArchiveResult {
|
|
24
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* 0; 1 when the remote reported an error; 128 when the client died; 141 when the request
|
|
33
|
+
* could not be written (git's client killed by SIGPIPE)
|
|
34
|
+
*/
|
|
25
35
|
exitCode: number;
|
|
26
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* The archive (git's stdout, or `-o`'s file), the `--list` lines for `--list`; empty when
|
|
38
|
+
* {@link RemoteArchiveCommand.setOutput} took them
|
|
39
|
+
*/
|
|
27
40
|
archive: Uint8Array;
|
|
28
41
|
/**
|
|
29
42
|
* git's stderr: the remote's messages as `remote: <line> ` lines (`-v`'s paths, its
|
|
@@ -56,6 +69,7 @@ export class RemoteArchiveCommand extends TransportCommand<RemoteArchiveResult>
|
|
|
56
69
|
private exec?: string;
|
|
57
70
|
private outputName?: string;
|
|
58
71
|
private readonly args: string[] = [];
|
|
72
|
+
private output?: (chunk: Uint8Array) => void | Promise<void>;
|
|
59
73
|
|
|
60
74
|
/** `--remote=<repo>`: a remote's name or a URL (a path for a local repository). */
|
|
61
75
|
setRemote(remote: string): this {
|
|
@@ -81,6 +95,29 @@ export class RemoteArchiveCommand extends TransportCommand<RemoteArchiveResult>
|
|
|
81
95
|
return this;
|
|
82
96
|
}
|
|
83
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Takes the archive as it arrives, chunk by chunk (git writing its stdout or `-o`'s file),
|
|
100
|
+
* instead of collecting it in {@link RemoteArchiveResult.archive}: the next chunk is read
|
|
101
|
+
* once the returned promise settles, so neither end holds the archive whole. A rejection
|
|
102
|
+
* is the client's death (exit 128).
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const writer = file.getWriter();
|
|
107
|
+
* const { exitCode } = await git
|
|
108
|
+
* .archiveRemote()
|
|
109
|
+
* .setRemote("origin")
|
|
110
|
+
* .addArguments("HEAD")
|
|
111
|
+
* .setOutput((chunk) => writer.write(chunk))
|
|
112
|
+
* .call();
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
setOutput(output: (chunk: Uint8Array) => void | Promise<void>): this {
|
|
116
|
+
this.checkCallable();
|
|
117
|
+
this.output = output;
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
|
|
84
121
|
/** `git archive`'s other arguments, as given (`--format=tar`, `-v`, `HEAD`, `--`, paths). */
|
|
85
122
|
addArguments(...args: string[]): this {
|
|
86
123
|
this.checkCallable();
|
|
@@ -100,7 +137,10 @@ export class RemoteArchiveCommand extends TransportCommand<RemoteArchiveResult>
|
|
|
100
137
|
this.outputName !== undefined
|
|
101
138
|
? new ArchiveCommand(this.workingCopy).formatFromFilename(this.outputName)
|
|
102
139
|
: undefined;
|
|
103
|
-
const options =
|
|
140
|
+
const options = {
|
|
141
|
+
...(formatHint ? { formatHint } : {}),
|
|
142
|
+
...(this.output ? { output: this.output } : {}),
|
|
143
|
+
};
|
|
104
144
|
const url = RemoteConfigStore.from(this.workingCopy).remoteUrlOf(this.remote);
|
|
105
145
|
const remote = await this.prepareRemote(url);
|
|
106
146
|
if (remote.kind === "bundle") {
|
|
@@ -110,7 +150,8 @@ export class RemoteArchiveCommand extends TransportCommand<RemoteArchiveResult>
|
|
|
110
150
|
// git spawns git-upload-archive in the repository: ours serves it in process
|
|
111
151
|
const writer = uploadArchiveWriterOf(remote.repository);
|
|
112
152
|
if (!writer) throw new GitApiError("fatal: operation not supported by protocol");
|
|
113
|
-
|
|
153
|
+
// bounded, as git's pipe to its upload-archive child: the server waits for the client
|
|
154
|
+
const [client, server] = createDuplexPair({ highWaterMark: LOCAL_HIGH_WATER_MARK });
|
|
114
155
|
const serving = serveUploadArchive(server, writer).finally(() => server.close?.());
|
|
115
156
|
const [result, served] = await Promise.all([
|
|
116
157
|
requestRemoteArchive(client, this.args, options).finally(() => client.close?.()),
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* upload-archive protocol (vcs-transport `serveUploadArchive`).
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type { UploadArchiveSink, UploadArchiveWriter } from "@statewalker/vcs-transport";
|
|
9
9
|
import { parseGitBool } from "@statewalker/vcs-utils";
|
|
10
10
|
import type { OpenedRepository, WorkingCopy } from "@statewalker/vcs-working-tree";
|
|
11
11
|
import { GitApiError } from "../../errors/index.js";
|
|
@@ -25,20 +25,34 @@ export interface ArchiveWriterOptions {
|
|
|
25
25
|
/**
|
|
26
26
|
* Runs `git archive <args>` as upload-archive's writer runs it in `workingCopy` (a
|
|
27
27
|
* repository's, its worktree never read): git's options parsed from `args`, only formats
|
|
28
|
-
* served remotely, a tree-ish only by ref unless `allowUnreachable`.
|
|
29
|
-
*
|
|
28
|
+
* served remotely, a tree-ish only by ref unless `allowUnreachable`. The archive goes to
|
|
29
|
+
* `sink` as it is written ({@link ArchiveCommand.callStream}: never held whole, the writer
|
|
30
|
+
* waiting on each chunk), stderr's lines with it as they are printed; resolves with git's
|
|
31
|
+
* exit status. Never throws: git's deaths are a stderr line and the status (a sink that
|
|
32
|
+
* rejects, the client gone, stops the writer the same way).
|
|
30
33
|
*
|
|
31
34
|
* @example
|
|
32
35
|
* ```ts
|
|
33
|
-
* const
|
|
36
|
+
* const exitCode = await runArchiveWriter(workingCopy, ["--format=zip", "HEAD"], {
|
|
37
|
+
* stdout: async (chunk) => file.write(chunk),
|
|
38
|
+
* stderr: async (text) => log(text),
|
|
39
|
+
* });
|
|
34
40
|
* ```
|
|
35
41
|
*/
|
|
36
42
|
export async function runArchiveWriter(
|
|
37
43
|
workingCopy: WorkingCopy,
|
|
38
44
|
args: readonly string[],
|
|
45
|
+
sink: UploadArchiveSink,
|
|
39
46
|
options: ArchiveWriterOptions = {},
|
|
40
|
-
): Promise<
|
|
47
|
+
): Promise<number> {
|
|
41
48
|
let command: ArchiveCommand | undefined;
|
|
49
|
+
let sent = 0;
|
|
50
|
+
const flushMessages = async () => {
|
|
51
|
+
if (!command) return;
|
|
52
|
+
const lines = command.getMessages(sent);
|
|
53
|
+
sent += lines.length;
|
|
54
|
+
if (lines.length > 0) await sink.stderr(lines.map((m) => `${m}\n`).join(""));
|
|
55
|
+
};
|
|
42
56
|
try {
|
|
43
57
|
command = new ArchiveCommand(workingCopy).setUploadArchive({
|
|
44
58
|
allowUnreachable: options.allowUnreachable === true,
|
|
@@ -47,29 +61,27 @@ export async function runArchiveWriter(
|
|
|
47
61
|
const list = applyArchiveArgs(command, args);
|
|
48
62
|
if (list) {
|
|
49
63
|
const lines = command.listFormats().map((name) => `${name}\n`);
|
|
50
|
-
|
|
64
|
+
await sink.stdout(encoder.encode(lines.join("")));
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
for await (const chunk of command.callStream()) {
|
|
68
|
+
// what was printed while this chunk was made goes first (git's -v: the path, then
|
|
69
|
+
// its entry)
|
|
70
|
+
await flushMessages();
|
|
71
|
+
await sink.stdout(chunk);
|
|
51
72
|
}
|
|
52
|
-
|
|
53
|
-
return
|
|
73
|
+
await flushMessages();
|
|
74
|
+
return 0;
|
|
54
75
|
} catch (error) {
|
|
55
76
|
const message = (error as Error).message ?? String(error);
|
|
56
77
|
const exitCode = error instanceof GitApiError ? error.exitCode : 128;
|
|
57
78
|
const text = /^(fatal|error|usage|warning):/.test(message) ? message : `fatal: ${message}`;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
stderr: `${command ? messagesOf(command) : ""}${text}\n`,
|
|
62
|
-
};
|
|
79
|
+
await flushMessages().catch(() => {});
|
|
80
|
+
await sink.stderr(`${text}\n`).catch(() => {});
|
|
81
|
+
return exitCode;
|
|
63
82
|
}
|
|
64
83
|
}
|
|
65
84
|
|
|
66
|
-
function messagesOf(command: ArchiveCommand): string {
|
|
67
|
-
return command
|
|
68
|
-
.getMessages()
|
|
69
|
-
.map((m) => `${m}\n`)
|
|
70
|
-
.join("");
|
|
71
|
-
}
|
|
72
|
-
|
|
73
85
|
/**
|
|
74
86
|
* {@link runArchiveWriter} for an opened repository (`Worktree.openRepository`), as git's
|
|
75
87
|
* upload-archive serves it: in its git directory (no worktree), `uploadarchive.allowUnreachable`
|
|
@@ -88,11 +100,11 @@ export function uploadArchiveWriterOf(
|
|
|
88
100
|
): UploadArchiveWriter | undefined {
|
|
89
101
|
const worktrees = repository.worktrees;
|
|
90
102
|
if (!worktrees) return undefined;
|
|
91
|
-
return async (args) => {
|
|
103
|
+
return async (args, sink) => {
|
|
92
104
|
const value = repository.config?.getAll("uploadarchive.allowUnreachable").at(-1);
|
|
93
105
|
const allowUnreachable = value === undefined ? false : (parseGitBool(value ?? "true") ?? false);
|
|
94
106
|
const admin = await worktrees.openAdmin();
|
|
95
|
-
return runArchiveWriter(withoutWorktree(worktreeAdminWorkingCopy(admin)), args, {
|
|
107
|
+
return runArchiveWriter(withoutWorktree(worktreeAdminWorkingCopy(admin)), args, sink, {
|
|
96
108
|
allowUnreachable,
|
|
97
109
|
...options,
|
|
98
110
|
});
|
|
@@ -28,6 +28,16 @@ import {
|
|
|
28
28
|
trackableStart,
|
|
29
29
|
upstreamMissingError,
|
|
30
30
|
} from "./branch-tracking.js";
|
|
31
|
+
import {
|
|
32
|
+
applyColumnOption,
|
|
33
|
+
ColumnOptionError,
|
|
34
|
+
columnActive,
|
|
35
|
+
columnConfigOf,
|
|
36
|
+
explicitlyEnableColumn,
|
|
37
|
+
finalizeColopts,
|
|
38
|
+
printColumns,
|
|
39
|
+
terminalColumnsOf,
|
|
40
|
+
} from "./column/index.js";
|
|
31
41
|
import { configBool } from "./merge-config.js";
|
|
32
42
|
import { OperationState } from "./merge-support.js";
|
|
33
43
|
import { canonicalObjectId } from "./object-id-input.js";
|
|
@@ -508,8 +518,10 @@ const quoteLiteral = (s: string) => s.replaceAll("%", "%%");
|
|
|
508
518
|
* `for-each-ref` language, and the reachability filters (`setContains`, `setNoContains`,
|
|
509
519
|
* `setMerged`, `setNoMerged`, `setPointsAt`) take revision names (HEAD when none is given).
|
|
510
520
|
* Colors follow `--color` or `color.branch`/`color.ui` set to `always` (no terminal is
|
|
511
|
-
* assumed), with `color.branch.<slot>`.
|
|
512
|
-
*
|
|
521
|
+
* assumed), with `color.branch.<slot>`. `setColumn` and `column.ui`/`column.branch` lay the
|
|
522
|
+
* lines out in columns as column.c does (`auto` never: no terminal), {@link setColumns} wide
|
|
523
|
+
* (else the host's `$COLUMNS`, else 80); `-v` turns a configured layout off and dies with an
|
|
524
|
+
* explicit `--column`.
|
|
513
525
|
*
|
|
514
526
|
* Based on JGit's ListBranchCommand and git's builtin/branch.c.
|
|
515
527
|
*
|
|
@@ -549,6 +561,8 @@ export class ListBranchCommand extends RefListingCommand<Ref[]> {
|
|
|
549
561
|
private merged: string[] = [];
|
|
550
562
|
private noMerged: string[] = [];
|
|
551
563
|
private compatibility: "2.43" | "2.56" = "2.56";
|
|
564
|
+
private columnOptions: (string | boolean)[] = [];
|
|
565
|
+
private columns?: number;
|
|
552
566
|
|
|
553
567
|
/**
|
|
554
568
|
* Set the listing mode: local branches (default), `-r` (remote-tracking) or `-a` (both).
|
|
@@ -568,6 +582,24 @@ export class ListBranchCommand extends RefListingCommand<Ref[]> {
|
|
|
568
582
|
return this;
|
|
569
583
|
}
|
|
570
584
|
|
|
585
|
+
/**
|
|
586
|
+
* `--column` (`true`: `always`), `--column=<options>` (`column`, `row`, `plain`, `dense`,
|
|
587
|
+
* `nodense`, `always`, `never`, `auto`) or `--no-column` (`false`), over `column.ui` and
|
|
588
|
+
* `column.branch`; each call applies after the previous ones, as git's options do.
|
|
589
|
+
*/
|
|
590
|
+
setColumn(option: string | boolean = true): this {
|
|
591
|
+
this.checkCallable();
|
|
592
|
+
this.columnOptions.push(option);
|
|
593
|
+
return this;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/** The terminal's width columns fill (`$COLUMNS`; default the host's, else 80). */
|
|
597
|
+
setColumns(columns: number): this {
|
|
598
|
+
this.checkCallable();
|
|
599
|
+
this.columns = columns;
|
|
600
|
+
return this;
|
|
601
|
+
}
|
|
602
|
+
|
|
571
603
|
/** `-v` (1) or `-vv` (2): ids and subjects, then upstreams and worktree paths. */
|
|
572
604
|
setVerbose(level: number): this {
|
|
573
605
|
this.checkCallable();
|
|
@@ -727,6 +759,8 @@ export class ListBranchCommand extends RefListingCommand<Ref[]> {
|
|
|
727
759
|
this.checkCallable();
|
|
728
760
|
this.setCallable(false);
|
|
729
761
|
const config = RemoteConfigStore.from(this.workingCopy);
|
|
762
|
+
// git_branch_config: column.ui and column.branch die on a value git refuses
|
|
763
|
+
let colopts = columnConfigOf(this.workingCopy, "branch");
|
|
730
764
|
// refs_resolve_refdup("HEAD")
|
|
731
765
|
const head = await this.refsStore.get("HEAD").catch(() => undefined);
|
|
732
766
|
if (!head) throw new RefFilterError("fatal: failed to resolve HEAD as a valid ref", 128);
|
|
@@ -734,6 +768,18 @@ export class ListBranchCommand extends RefListingCommand<Ref[]> {
|
|
|
734
768
|
if (!detached && !head.target.startsWith("refs/heads/")) {
|
|
735
769
|
throw new RefFilterError("fatal: HEAD not found below refs/heads!", 128);
|
|
736
770
|
}
|
|
771
|
+
// parse_options, then finalize_colopts and -v's check
|
|
772
|
+
for (const option of this.columnOptions) colopts = applyColumnOption(colopts, option);
|
|
773
|
+
colopts = finalizeColopts(colopts);
|
|
774
|
+
if (this.verbose) {
|
|
775
|
+
if (explicitlyEnableColumn(colopts)) {
|
|
776
|
+
throw new ColumnOptionError(
|
|
777
|
+
"fatal: options '--column' and '--verbose' cannot be used together",
|
|
778
|
+
128,
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
colopts = 0;
|
|
782
|
+
}
|
|
737
783
|
// branch.sort keys first, then --sort (parse_opt_ref_sorting appends)
|
|
738
784
|
const sortKeys = [...config.values("branch.sort"), ...this.sortKeys];
|
|
739
785
|
if (sortKeys.length === 0) sortKeys.push("refname");
|
|
@@ -806,13 +852,20 @@ export class ListBranchCommand extends RefListingCommand<Ref[]> {
|
|
|
806
852
|
await sortRefs(items, sorting, format, source, warnings);
|
|
807
853
|
const lines: string[] = [];
|
|
808
854
|
let output = "";
|
|
855
|
+
const columns = columnActive(colopts);
|
|
809
856
|
for (const item of items) {
|
|
810
857
|
const line = await format.format(item);
|
|
811
|
-
|
|
858
|
+
// the column layout keeps every line (print_columns, no --omit-empty)
|
|
859
|
+
if (columns || line.length || !this.omitEmpty) {
|
|
812
860
|
lines.push(line);
|
|
813
|
-
output += `${line}\n`;
|
|
861
|
+
if (!columns) output += `${line}\n`;
|
|
814
862
|
}
|
|
815
863
|
}
|
|
864
|
+
if (columns) {
|
|
865
|
+
output = printColumns(lines, colopts, {
|
|
866
|
+
termColumns: terminalColumnsOf(this.workingCopy, this.columns),
|
|
867
|
+
});
|
|
868
|
+
}
|
|
816
869
|
return {
|
|
817
870
|
output,
|
|
818
871
|
lines,
|
|
@@ -85,7 +85,15 @@ const HEX = /^[0-9a-fA-F]$/;
|
|
|
85
85
|
* if (!parsed.ok) console.error(`error: ${parsed.error}`);
|
|
86
86
|
* ```
|
|
87
87
|
*/
|
|
88
|
-
export function parseBundleHeader(
|
|
88
|
+
export function parseBundleHeader(
|
|
89
|
+
bytes: Uint8Array,
|
|
90
|
+
name = "<bundle>",
|
|
91
|
+
/**
|
|
92
|
+
* The hash a header without `@object-format=` names ids in (git's `the_hash_algo`: the
|
|
93
|
+
* repository's)
|
|
94
|
+
*/
|
|
95
|
+
defaultFormat: ObjectFormat = SHA1_OBJECT_FORMAT,
|
|
96
|
+
): ParsedBundleHeader {
|
|
89
97
|
let at = 0;
|
|
90
98
|
/** strbuf_getwholeline_fd: the next line with its LF; undefined at the end */
|
|
91
99
|
const nextLine = (): Uint8Array | undefined => {
|
|
@@ -106,7 +114,7 @@ export function parseBundleHeader(bytes: Uint8Array, name = "<bundle>"): ParsedB
|
|
|
106
114
|
notABundle: true,
|
|
107
115
|
};
|
|
108
116
|
}
|
|
109
|
-
let objectFormat: ObjectFormat =
|
|
117
|
+
let objectFormat: ObjectFormat = defaultFormat;
|
|
110
118
|
let filter: string | undefined;
|
|
111
119
|
const prerequisites: BundlePrerequisite[] = [];
|
|
112
120
|
const references: BundleRef[] = [];
|