@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
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
* @module
|
|
15
15
|
*/
|
|
16
16
|
import type { ObjectId } from "@statewalker/vcs-core";
|
|
17
|
+
import { encodeGitPath } from "@statewalker/vcs-utils";
|
|
17
18
|
|
|
18
19
|
import { GitApiError, RefNotFoundError } from "../errors/index.js";
|
|
19
|
-
import {
|
|
20
|
+
import { RefFormat, RefListingCommand, refKindOf } from "./ref-filter/index.js";
|
|
20
21
|
import { type SignatureCheck, verifyCommitBytes, verifyTagBytes } from "./signature-check.js";
|
|
21
22
|
|
|
22
23
|
/** What `git verify-commit` / `git verify-tag` printed and its exit status. */
|
|
@@ -33,17 +34,50 @@ export interface VerifyResult {
|
|
|
33
34
|
|
|
34
35
|
/** One object's verification as the command's loop runs it. */
|
|
35
36
|
interface VerifyOutput {
|
|
37
|
+
/** stdout as written to the file descriptor, in order */
|
|
36
38
|
out: Uint8Array[];
|
|
39
|
+
/** stdio's buffer: what `fputs`/`fwrite` wrote and stdout has not got yet */
|
|
40
|
+
stdio: Uint8Array[];
|
|
37
41
|
err: string[];
|
|
38
42
|
checks: { name: string; id?: ObjectId; check?: SignatureCheck }[];
|
|
39
43
|
}
|
|
40
44
|
|
|
45
|
+
/** glibc's stdout buffer over a pipe (its st_blksize) */
|
|
46
|
+
const STDIO_BUFFER = 4096;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A write through stdio (`fputs`, `fwrite`, `putchar`): held in the buffer, which reaches
|
|
50
|
+
* stdout in whole buffers as it fills and the rest at exit, after any `write_in_full` made in
|
|
51
|
+
* between (git writes a tag without signature that way).
|
|
52
|
+
*/
|
|
53
|
+
function writeStdio(output: VerifyOutput, bytes: Uint8Array): void {
|
|
54
|
+
output.stdio.push(bytes);
|
|
55
|
+
const size = output.stdio.reduce((n, b) => n + b.length, 0);
|
|
56
|
+
if (size < STDIO_BUFFER) return;
|
|
57
|
+
const all = concatBytes(output.stdio);
|
|
58
|
+
const cut = size - (size % STDIO_BUFFER);
|
|
59
|
+
output.out.push(all.subarray(0, cut));
|
|
60
|
+
output.stdio = cut < size ? [all.subarray(cut)] : [];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function concatBytes(chunks: readonly Uint8Array[]): Uint8Array {
|
|
64
|
+
const bytes = new Uint8Array(chunks.reduce((n, b) => n + b.length, 0));
|
|
65
|
+
let at = 0;
|
|
66
|
+
for (const b of chunks) {
|
|
67
|
+
bytes.set(b, at);
|
|
68
|
+
at += b.length;
|
|
69
|
+
}
|
|
70
|
+
return bytes;
|
|
71
|
+
}
|
|
72
|
+
|
|
41
73
|
const TYPE_NAMES = new Set(["commit", "tree", "blob", "tag"]);
|
|
42
74
|
|
|
43
|
-
abstract class VerifyCommandBase extends
|
|
75
|
+
abstract class VerifyCommandBase extends RefListingCommand<VerifyResult> {
|
|
44
76
|
protected readonly names: string[] = [];
|
|
45
77
|
protected verbose = false;
|
|
46
78
|
protected raw = false;
|
|
79
|
+
/** GPG_VERIFY_OMIT_STATUS: nothing of a check printed (verify-tag `--format`) */
|
|
80
|
+
protected omitStatus = false;
|
|
47
81
|
|
|
48
82
|
/** `-v` / `--verbose`: the object's contents on stdout. */
|
|
49
83
|
setVerbose(verbose: boolean): this {
|
|
@@ -94,7 +128,8 @@ abstract class VerifyCommandBase extends GitCommand<VerifyResult> {
|
|
|
94
128
|
|
|
95
129
|
/** gpg-interface.c's `print_signature_buffer` */
|
|
96
130
|
protected print(check: SignatureCheck, output: VerifyOutput): void {
|
|
97
|
-
if (this.
|
|
131
|
+
if (this.omitStatus) return;
|
|
132
|
+
if (this.verbose && check.payload) writeStdio(output, check.payload);
|
|
98
133
|
const text = this.raw ? check.status : check.output;
|
|
99
134
|
if (text) output.err.push(text);
|
|
100
135
|
}
|
|
@@ -107,18 +142,14 @@ abstract class VerifyCommandBase extends GitCommand<VerifyResult> {
|
|
|
107
142
|
if (this.names.length === 0) {
|
|
108
143
|
throw new GitApiError(this.usage(), { exitCode: 129 });
|
|
109
144
|
}
|
|
110
|
-
const output: VerifyOutput = { out: [], err: [], checks: [] };
|
|
145
|
+
const output: VerifyOutput = { out: [], stdio: [], err: [], checks: [] };
|
|
146
|
+
await this.prepare();
|
|
111
147
|
let failed = false;
|
|
112
148
|
for (const name of this.names) {
|
|
113
149
|
if (!(await this.verifyOne(name, output))) failed = true;
|
|
114
150
|
}
|
|
115
|
-
|
|
116
|
-
const stdout =
|
|
117
|
-
let at = 0;
|
|
118
|
-
for (const b of output.out) {
|
|
119
|
-
stdout.set(b, at);
|
|
120
|
-
at += b.length;
|
|
121
|
-
}
|
|
151
|
+
// stdio's buffer flushed at exit
|
|
152
|
+
const stdout = concatBytes([...output.out, ...output.stdio]);
|
|
122
153
|
return {
|
|
123
154
|
exitCode: failed ? 1 : 0,
|
|
124
155
|
stdout,
|
|
@@ -129,6 +160,9 @@ abstract class VerifyCommandBase extends GitCommand<VerifyResult> {
|
|
|
129
160
|
|
|
130
161
|
protected abstract usage(): string;
|
|
131
162
|
|
|
163
|
+
/** What runs once before the objects are checked (the format verified). */
|
|
164
|
+
protected async prepare(): Promise<void> {}
|
|
165
|
+
|
|
132
166
|
/** The check's own lines (git's `error()`/`warning()` on the way), with newlines. */
|
|
133
167
|
protected messages(check: SignatureCheck, output: VerifyOutput): void {
|
|
134
168
|
for (const line of check.messages) output.err.push(`${line}\n`);
|
|
@@ -192,6 +226,9 @@ export class VerifyCommitCommand extends VerifyCommandBase {
|
|
|
192
226
|
* signature `error: no signature found` (`-v` prints the tag first). Exit 1 when any fails.
|
|
193
227
|
*/
|
|
194
228
|
export class VerifyTagCommand extends VerifyCommandBase {
|
|
229
|
+
private format?: string;
|
|
230
|
+
private refFormat?: RefFormat;
|
|
231
|
+
|
|
195
232
|
/** A tag to verify (any revision naming a tag object). */
|
|
196
233
|
addTag(name: string): this {
|
|
197
234
|
this.checkCallable();
|
|
@@ -199,6 +236,39 @@ export class VerifyTagCommand extends VerifyCommandBase {
|
|
|
199
236
|
return this;
|
|
200
237
|
}
|
|
201
238
|
|
|
239
|
+
/**
|
|
240
|
+
* `--format=<format>`: each tag whose signature is good printed through the ref-filter
|
|
241
|
+
* format (`%(refname)` is the name as given), and nothing of the checks themselves, not
|
|
242
|
+
* even with `-v` or `--raw` (git's GPG_VERIFY_OMIT_STATUS); a tag without signature still
|
|
243
|
+
* goes to stdout under `-v`.
|
|
244
|
+
*/
|
|
245
|
+
setFormat(format: string | undefined): this {
|
|
246
|
+
this.checkCallable();
|
|
247
|
+
this.format = format;
|
|
248
|
+
return this;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** verify_ref_format, before any tag is read. */
|
|
252
|
+
protected override async prepare(): Promise<void> {
|
|
253
|
+
if (this.format === undefined) return;
|
|
254
|
+
this.refFormat = new RefFormat(this.format, this.formatSource());
|
|
255
|
+
this.omitStatus = true;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** pretty_print_ref: the tag as a ref named `name`, the expanded format and a newline. */
|
|
259
|
+
private async prettyPrint(name: string, id: ObjectId, output: VerifyOutput): Promise<void> {
|
|
260
|
+
const format = this.refFormat;
|
|
261
|
+
if (!format) return;
|
|
262
|
+
const line = await format.format({
|
|
263
|
+
refname: name,
|
|
264
|
+
objectId: id,
|
|
265
|
+
flags: { symref: false, packed: false },
|
|
266
|
+
kind: refKindOf(name),
|
|
267
|
+
});
|
|
268
|
+
for (const message of format.messages.splice(0)) output.err.push(`${message}\n`);
|
|
269
|
+
writeStdio(output, encodeGitPath(`${line}\n`));
|
|
270
|
+
}
|
|
271
|
+
|
|
202
272
|
protected usage(): string {
|
|
203
273
|
return "usage: git verify-tag [-v | --verbose] [--format=<format>] [--raw] <tag>...";
|
|
204
274
|
}
|
|
@@ -230,6 +300,8 @@ export class VerifyTagCommand extends VerifyCommandBase {
|
|
|
230
300
|
this.messages(check, output);
|
|
231
301
|
this.print(check, output);
|
|
232
302
|
output.checks.push({ name, id, check });
|
|
233
|
-
|
|
303
|
+
if (check.failed) return false;
|
|
304
|
+
await this.prettyPrint(name, id, output);
|
|
305
|
+
return true;
|
|
234
306
|
}
|
|
235
307
|
}
|
|
@@ -676,6 +676,8 @@ export class WorktreeAddCommand extends GitCommand<WorktreeAddResult> {
|
|
|
676
676
|
symlinks: worktreeModeTrust(workingCopy, worktree).symlinks,
|
|
677
677
|
ignoreCase: coreBool(workingCopy, "ignorecase", false),
|
|
678
678
|
pathRules: worktreePathRules(workingCopy, worktree),
|
|
679
|
+
// the child `git reset --hard`'s metadata: HEAD's commit, no ref
|
|
680
|
+
metadata: { treeish: headId },
|
|
679
681
|
},
|
|
680
682
|
commit.tree,
|
|
681
683
|
"worktree add",
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { FileMode, type ObjectId } from "@statewalker/vcs-core";
|
|
9
|
-
import { foldAsciiCase } from "@statewalker/vcs-utils/encoding";
|
|
9
|
+
import { compareGitPaths, foldAsciiCase } from "@statewalker/vcs-utils/encoding";
|
|
10
10
|
import {
|
|
11
11
|
basicStatMatches,
|
|
12
12
|
IndexPathLookup,
|
|
@@ -29,11 +29,12 @@ export interface CheckedEntry {
|
|
|
29
29
|
/**
|
|
30
30
|
* Whether the worktree file at `path` no longer holds the index entry (git's
|
|
31
31
|
* `verify_uptodate`): changed content, type, or executable bit where the worktree shows it.
|
|
32
|
-
* A missing file is no local change, but one beneath a symbolically linked directory
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
32
|
+
* A missing file is no local change, but one beneath a symbolically linked directory or a
|
|
33
|
+
* file is. With `indexTime` (the index file's mtime, as the caller's index was last read or
|
|
34
|
+
* written: git's `istate->timestamp`), a stat that matches as git's `ie_match_stat` compares
|
|
35
|
+
* it, on an entry older than the index (not racy), settles it without reading the file, as
|
|
36
|
+
* in git; a racy entry is read. A caller that rewrites the index where git does
|
|
37
|
+
* (`write_index_as_tree`) passes the new file's time.
|
|
37
38
|
*/
|
|
38
39
|
export async function worktreeDiffers(
|
|
39
40
|
worktree: Worktree,
|
|
@@ -45,19 +46,23 @@ export async function worktreeDiffers(
|
|
|
45
46
|
const current = await worktree.getEntry(path);
|
|
46
47
|
if (!current) {
|
|
47
48
|
// git's lstat follows a symbolic link on a leading directory to whatever the file there
|
|
48
|
-
// is, never the one the index recorded: a change (the worktree never looks beyond links)
|
|
49
|
-
|
|
49
|
+
// is, never the one the index recorded: a change (the worktree never looks beyond links);
|
|
50
|
+
// so is a file among the leading components (verify_uptodate_1 takes only ENOENT as a
|
|
51
|
+
// file deleted, ENOTDIR is a change)
|
|
52
|
+
return entry.mode !== FileMode.GITLINK && (await leadingPathBlocked(worktree, path));
|
|
50
53
|
}
|
|
51
54
|
return differsFrom(worktree, path, entry, current, trust, indexTime);
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
/**
|
|
55
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Whether `path` is missing for another reason than ENOENT: a leading directory of it is a
|
|
59
|
+
* symbolic link, or a file (ENOTDIR).
|
|
60
|
+
*/
|
|
61
|
+
async function leadingPathBlocked(worktree: Worktree, path: string): Promise<boolean> {
|
|
56
62
|
for (let k = path.indexOf("/"); k > 0; k = path.indexOf("/", k + 1)) {
|
|
57
63
|
const entry = await worktree.getEntry(path.slice(0, k)).catch(() => undefined);
|
|
58
64
|
if (!entry) return false;
|
|
59
|
-
if (entry.mode === FileMode.SYMLINK) return true;
|
|
60
|
-
if (!entry.isDirectory) return false;
|
|
65
|
+
if (entry.mode === FileMode.SYMLINK || !entry.isDirectory) return true;
|
|
61
66
|
}
|
|
62
67
|
return false;
|
|
63
68
|
}
|
|
@@ -477,7 +482,7 @@ export function overwriteMessage(
|
|
|
477
482
|
* before overwriting or removing its file: `ie_match_stat` with `CE_MATCH_IGNORE_VALID`, so
|
|
478
483
|
* a stat that no longer matches is a change (the content is not compared), and a matching
|
|
479
484
|
* one on a racy entry has its content checked. A missing file is no change, but one
|
|
480
|
-
* beneath a symbolically linked directory is.
|
|
485
|
+
* beneath a symbolically linked directory or a file is.
|
|
481
486
|
*/
|
|
482
487
|
export async function flaggedEntryDiffers(
|
|
483
488
|
worktree: Worktree,
|
|
@@ -493,7 +498,7 @@ export async function flaggedEntryDiffers(
|
|
|
493
498
|
// git's lstat follows a symbolic link among the leading directories to whatever is
|
|
494
499
|
// there, never the file the index recorded: a change, as for an unflagged entry (the
|
|
495
500
|
// switch then never writes through the link)
|
|
496
|
-
return entry.mode !== FileMode.GITLINK && (await
|
|
501
|
+
return entry.mode !== FileMode.GITLINK && (await leadingPathBlocked(worktree, path));
|
|
497
502
|
}
|
|
498
503
|
if (current.isDirectory) return entry.mode !== FileMode.GITLINK;
|
|
499
504
|
if (entry.mode === FileMode.GITLINK) return false;
|
|
@@ -534,6 +539,62 @@ export async function entryNotUptodate(
|
|
|
534
539
|
return worktreeDiffers(worktree, path, entry, trust, indexTime);
|
|
535
540
|
}
|
|
536
541
|
|
|
542
|
+
/**
|
|
543
|
+
* git's `verify_clean_subdirectory` for a two-way switch that finds a directory at `path`
|
|
544
|
+
* where it writes a new file or deletes one the index lacks (`verify_absent`): the stage-0
|
|
545
|
+
* index entries below it are checked in index order (`verify_uptodate`), and each clean one
|
|
546
|
+
* is taken out of the switch (removed with its file, its own path then merged as if the
|
|
547
|
+
* index lacked it). The first local change stops the check: the switch refuses it.
|
|
548
|
+
*
|
|
549
|
+
* @param taken entries taken out so far (added to)
|
|
550
|
+
* @returns the entries taken by this call, or the entry whose local change refuses
|
|
551
|
+
*/
|
|
552
|
+
export async function takeCleanSubdirectory(
|
|
553
|
+
worktree: Worktree,
|
|
554
|
+
path: string,
|
|
555
|
+
index: ReadonlyMap<string, CheckedEntry>,
|
|
556
|
+
taken: Set<string>,
|
|
557
|
+
trust?: WorktreeModeTrust,
|
|
558
|
+
indexTime?: number,
|
|
559
|
+
): Promise<{ taken: string[]; notUptodate?: string }> {
|
|
560
|
+
const below = [...index.keys()].filter((p) => p.startsWith(`${path}/`) && !taken.has(p));
|
|
561
|
+
below.sort(compareGitPaths);
|
|
562
|
+
const out: string[] = [];
|
|
563
|
+
for (const p of below) {
|
|
564
|
+
if (await entryNotUptodate(worktree, p, index.get(p) as CheckedEntry, trust, indexTime)) {
|
|
565
|
+
return { taken: out, notUptodate: p };
|
|
566
|
+
}
|
|
567
|
+
taken.add(p);
|
|
568
|
+
out.push(p);
|
|
569
|
+
}
|
|
570
|
+
return { taken: out };
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* The first leading directory of `path` that is a file or a link in the worktree (git's
|
|
575
|
+
* `check_leading_path`), whose removal a switch deleting `path` must check too.
|
|
576
|
+
*/
|
|
577
|
+
export async function leadingFileOf(worktree: Worktree, path: string): Promise<string | undefined> {
|
|
578
|
+
for (let k = path.indexOf("/"); k > 0; k = path.indexOf("/", k + 1)) {
|
|
579
|
+
const entry = await worktree.getEntry(path.slice(0, k));
|
|
580
|
+
if (!entry) return undefined;
|
|
581
|
+
if (!entry.isDirectory) return path.slice(0, k);
|
|
582
|
+
}
|
|
583
|
+
return undefined;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Whether a leading directory of `path` was refused: git's traverse_trees never enters the
|
|
588
|
+
* subtree of a path whose merge failed, so nothing below it is checked or reported.
|
|
589
|
+
*/
|
|
590
|
+
export function belowRefused(path: string, refused: ReadonlySet<string>): boolean {
|
|
591
|
+
if (refused.size === 0) return false;
|
|
592
|
+
for (let k = path.indexOf("/"); k > 0; k = path.indexOf("/", k + 1)) {
|
|
593
|
+
if (refused.has(path.slice(0, k))) return true;
|
|
594
|
+
}
|
|
595
|
+
return false;
|
|
596
|
+
}
|
|
597
|
+
|
|
537
598
|
/** What {@link statThroughLeadingLinks} found beyond a link. */
|
|
538
599
|
export interface LinkedStat {
|
|
539
600
|
/** The entry the path reaches through the link(s); undefined when nothing is there */
|
|
@@ -12,15 +12,65 @@ export class NoMessageError extends GitApiError {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* builtin/commit.c's `empty_amend_advice`: what `git commit --amend` prints on stderr when
|
|
17
|
+
* the amended commit would have its first parent's tree (the same text in 2.43 and 2.5x).
|
|
18
|
+
*/
|
|
19
|
+
export const EMPTY_AMEND_ADVICE =
|
|
20
|
+
"You asked to amend the most recent commit, but doing so would make\n" +
|
|
21
|
+
"it empty. You can repeat your command with --allow-empty, or you can\n" +
|
|
22
|
+
'remove the commit entirely with "git reset HEAD^".\n';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* builtin/commit.c's `empty_cherry_pick_advice`: what `git commit` prints on stderr when it
|
|
26
|
+
* refuses an empty commit while a cherry-pick or a rebase pick is in progress, followed by
|
|
27
|
+
* {@link EMPTY_CHERRY_PICK_ADVICE_SINGLE} or {@link EMPTY_REBASE_PICK_ADVICE} (the same text
|
|
28
|
+
* in 2.43 and 2.5x).
|
|
29
|
+
*/
|
|
30
|
+
export const EMPTY_CHERRY_PICK_ADVICE =
|
|
31
|
+
"The previous cherry-pick is now empty, possibly due to conflict resolution.\n" +
|
|
32
|
+
"If you wish to commit it anyway, use:\n" +
|
|
33
|
+
"\n" +
|
|
34
|
+
" git commit --allow-empty\n" +
|
|
35
|
+
"\n";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* builtin/commit.c's `empty_cherry_pick_advice_single`, after {@link EMPTY_CHERRY_PICK_ADVICE}
|
|
39
|
+
* during a cherry-pick. git's `empty_cherry_pick_advice_multi` is never printed:
|
|
40
|
+
* sequencer_determine_whence overwrites `FROM_CHERRY_PICK_MULTI` with
|
|
41
|
+
* `FROM_CHERRY_PICK_SINGLE`, so a sequence of picks gets this text too.
|
|
42
|
+
*/
|
|
43
|
+
export const EMPTY_CHERRY_PICK_ADVICE_SINGLE = "Otherwise, please use 'git cherry-pick --skip'\n";
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* builtin/commit.c's `empty_rebase_pick_advice`, after {@link EMPTY_CHERRY_PICK_ADVICE} during
|
|
47
|
+
* a rebase stopped at a pick (CHERRY_PICK_HEAD the same commit as REBASE_HEAD).
|
|
48
|
+
*/
|
|
49
|
+
export const EMPTY_REBASE_PICK_ADVICE = "Otherwise, please use 'git rebase --skip'\n";
|
|
50
|
+
|
|
15
51
|
/**
|
|
16
52
|
* Thrown when trying to create an empty commit without allow-empty.
|
|
17
53
|
*
|
|
54
|
+
* git's prepare_to_commit refuses it with exit status 1, printing the status of what would
|
|
55
|
+
* be committed on stdout ({@link stdout}, `git commit --dry-run`'s text) and on stderr
|
|
56
|
+
* ({@link stderr}, also the message then) {@link EMPTY_AMEND_ADVICE} when amending, else
|
|
57
|
+
* {@link EMPTY_CHERRY_PICK_ADVICE} and its sequel during a cherry-pick or a rebase pick.
|
|
58
|
+
*
|
|
18
59
|
* Based on JGit's EmptyCommitException.
|
|
19
60
|
*/
|
|
20
61
|
export class EmptyCommitError extends GitApiError {
|
|
21
|
-
|
|
22
|
-
|
|
62
|
+
/** git's stdout: the status run_status prints before the refusal (when computed) */
|
|
63
|
+
readonly stdout?: string;
|
|
64
|
+
/** git's stderr: the amend or empty cherry-pick advice, or nothing */
|
|
65
|
+
readonly stderr: string;
|
|
66
|
+
|
|
67
|
+
constructor(message?: string, output?: { stdout?: string; stderr?: string }) {
|
|
68
|
+
super(message ?? (output?.stderr ? output.stderr.replace(/\n$/, "") : "Nothing to commit"), {
|
|
69
|
+
exitCode: 1,
|
|
70
|
+
});
|
|
23
71
|
this.name = "EmptyCommitError";
|
|
72
|
+
this.stdout = output?.stdout;
|
|
73
|
+
this.stderr = output?.stderr ?? "";
|
|
24
74
|
}
|
|
25
75
|
}
|
|
26
76
|
|
|
@@ -29,6 +29,13 @@ export class GitApiError extends Error {
|
|
|
29
29
|
*/
|
|
30
30
|
messages?: string[];
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* What git printed on stderr before this failure, line by line: git 2.5x's
|
|
34
|
+
* `core.commentChar=auto` deprecation warning and its advice (commit, merge, rebase,
|
|
35
|
+
* revert, cherry-pick). Absent when it printed nothing first.
|
|
36
|
+
*/
|
|
37
|
+
warnings?: readonly string[];
|
|
38
|
+
|
|
32
39
|
constructor(message: string, options?: GitApiErrorOptions) {
|
|
33
40
|
super(message, options);
|
|
34
41
|
this.name = "GitApiError";
|
package/src/git-command.ts
CHANGED
|
@@ -53,7 +53,10 @@ import {
|
|
|
53
53
|
type Worktree,
|
|
54
54
|
} from "@statewalker/vcs-working-tree";
|
|
55
55
|
import { attributesSourceResolver } from "./commands/attributes-source.js";
|
|
56
|
-
import {
|
|
56
|
+
import {
|
|
57
|
+
checkAutoCommentChar,
|
|
58
|
+
enterAutoCommentCharWarning,
|
|
59
|
+
} from "./commands/comment-char-config.js";
|
|
57
60
|
import {
|
|
58
61
|
configLoadError,
|
|
59
62
|
createIdAbbreviator,
|
|
@@ -91,7 +94,9 @@ import {
|
|
|
91
94
|
import { type ResolveOptions, RevisionResolver } from "./commands/revision-resolver.js";
|
|
92
95
|
import { type SignRequest, signCommit } from "./commands/signing.js";
|
|
93
96
|
import { readSparseCheckoutPatterns } from "./commands/sparse-checkout-support.js";
|
|
97
|
+
import type { CheckoutRef } from "./commands/tree-restore.js";
|
|
94
98
|
import {
|
|
99
|
+
GitApiError,
|
|
95
100
|
InvalidConfigError,
|
|
96
101
|
NoHeadError,
|
|
97
102
|
NotACommitError,
|
|
@@ -372,6 +377,76 @@ export abstract class GitCommand<T> {
|
|
|
372
377
|
const promisor = promisorOf(workingCopy);
|
|
373
378
|
if (promisor && !promisor.fetcher) promisor.setFetcher(createPromisorFetcher(workingCopy));
|
|
374
379
|
this.releaseHooksAfterCalls();
|
|
380
|
+
this.warnOfAutoCommentChar();
|
|
381
|
+
this.holdFilterProcessesDuringCalls();
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Each entry point keeps the worktree's long-running filter processes
|
|
386
|
+
* (`filter.<driver>.process`) running until it ends, then shuts them down (unless an outer
|
|
387
|
+
* call still holds them): git starts such a process once per command run and stops it at
|
|
388
|
+
* its exit, whatever the number of files filtered.
|
|
389
|
+
*/
|
|
390
|
+
private holdFilterProcessesDuringCalls(): void {
|
|
391
|
+
this.aroundEntryPoints(() => {
|
|
392
|
+
let worktree: Worktree | undefined;
|
|
393
|
+
try {
|
|
394
|
+
worktree = this._workingCopy.worktree;
|
|
395
|
+
} catch {
|
|
396
|
+
// a bare repository's working copy refuses its worktree
|
|
397
|
+
return undefined;
|
|
398
|
+
}
|
|
399
|
+
return worktree?.contentFilter?.holdProcesses?.();
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* The entry points that give git 2.5x's `core.commentChar=auto` deprecation warning (the
|
|
405
|
+
* commands setting `warn_on_auto_comment_char`: commit, merge, rebase, revert,
|
|
406
|
+
* cherry-pick); none by default.
|
|
407
|
+
*/
|
|
408
|
+
protected autoCommentCharWarningEntryPoints(): readonly string[] {
|
|
409
|
+
return [];
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** The git version whose rules this command follows (default the hook runner's). */
|
|
413
|
+
protected gitCompatibility(): "2.43" | "2.56" {
|
|
414
|
+
return this.hooks.compatibility;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Wraps {@link autoCommentCharWarningEntryPoints}: the warning's lines go in front of the
|
|
419
|
+
* result's `warnings` (git prints them as the configuration is first read), or of a
|
|
420
|
+
* {@link GitApiError}'s `warnings` when the call fails; an inner call (a command this one
|
|
421
|
+
* runs) adds none, as git's children see `GIT_AUTO_COMMENT_CHAR_CONFIG_WARNING_GIVEN`.
|
|
422
|
+
*/
|
|
423
|
+
private warnOfAutoCommentChar(): void {
|
|
424
|
+
const names = this.autoCommentCharWarningEntryPoints();
|
|
425
|
+
if (names.length === 0) return;
|
|
426
|
+
const self = this as unknown as Record<string, unknown>;
|
|
427
|
+
for (const name of names) {
|
|
428
|
+
const method = self[name];
|
|
429
|
+
if (typeof method !== "function") continue;
|
|
430
|
+
self[name] = async (...args: unknown[]) => {
|
|
431
|
+
const { lines, leave } = enterAutoCommentCharWarning(
|
|
432
|
+
this._workingCopy,
|
|
433
|
+
this.gitCompatibility(),
|
|
434
|
+
);
|
|
435
|
+
try {
|
|
436
|
+
const result = await (method as (...a: unknown[]) => Promise<unknown>).apply(this, args);
|
|
437
|
+
if (!lines || !result || typeof result !== "object") return result;
|
|
438
|
+
const earlier = (result as { warnings?: string[] }).warnings ?? [];
|
|
439
|
+
return { ...(result as object), warnings: [...lines, ...earlier] };
|
|
440
|
+
} catch (error) {
|
|
441
|
+
if (lines && error instanceof GitApiError) {
|
|
442
|
+
error.warnings = [...lines, ...(error.warnings ?? [])];
|
|
443
|
+
}
|
|
444
|
+
throw error;
|
|
445
|
+
} finally {
|
|
446
|
+
leave();
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
375
450
|
}
|
|
376
451
|
|
|
377
452
|
/**
|
|
@@ -405,7 +480,7 @@ export abstract class GitCommand<T> {
|
|
|
405
480
|
* function it returns runs when that call ends, whatever the outcome (subclasses scope
|
|
406
481
|
* state to their calls with it: a transport command's promisor fetcher).
|
|
407
482
|
*/
|
|
408
|
-
protected aroundEntryPoints(enter: () => (() => void) | undefined): void {
|
|
483
|
+
protected aroundEntryPoints(enter: () => (() => void | Promise<void>) | undefined): void {
|
|
409
484
|
const self = this as unknown as Record<string, unknown>;
|
|
410
485
|
for (const name of entryPointNames(Object.getPrototypeOf(this))) {
|
|
411
486
|
const method = self[name];
|
|
@@ -416,13 +491,14 @@ export abstract class GitCommand<T> {
|
|
|
416
491
|
try {
|
|
417
492
|
result = (method as (...a: unknown[]) => unknown).apply(this, args);
|
|
418
493
|
} catch (error) {
|
|
419
|
-
leave?.();
|
|
494
|
+
void Promise.resolve(leave?.()).catch(() => {});
|
|
420
495
|
throw error;
|
|
421
496
|
}
|
|
422
497
|
if (leave && result && typeof (result as Promise<unknown>).finally === "function") {
|
|
498
|
+
// a leave returning a promise is awaited before the call settles
|
|
423
499
|
return (result as Promise<unknown>).finally(leave);
|
|
424
500
|
}
|
|
425
|
-
leave?.();
|
|
501
|
+
void Promise.resolve(leave?.()).catch(() => {});
|
|
426
502
|
return result;
|
|
427
503
|
};
|
|
428
504
|
}
|
|
@@ -1558,6 +1634,31 @@ export abstract class GitCommand<T> {
|
|
|
1558
1634
|
}
|
|
1559
1635
|
}
|
|
1560
1636
|
|
|
1637
|
+
/**
|
|
1638
|
+
* git's checkout metadata (`init_checkout_metadata`) of a checkout of `name` (the revision
|
|
1639
|
+
* as given) at `id`: the ref the name names (`repo_dwim_ref`; with `fullRefsOnly` only one
|
|
1640
|
+
* under `refs/`, as `git reset` keeps it), and `id` peeled to its commit (else `id` as it
|
|
1641
|
+
* is: a tree). A long-running filter process is told them with each file's blob.
|
|
1642
|
+
*/
|
|
1643
|
+
protected async checkoutRefOf(
|
|
1644
|
+
name: string | undefined,
|
|
1645
|
+
id: ObjectId | undefined,
|
|
1646
|
+
options: { fullRefsOnly?: boolean } = {},
|
|
1647
|
+
): Promise<CheckoutRef> {
|
|
1648
|
+
const resolver = this.revisionResolver();
|
|
1649
|
+
let ref: string | undefined;
|
|
1650
|
+
if (name !== undefined) {
|
|
1651
|
+
ref = (await resolver.dwimRef(name).catch(() => []))[0]?.ref;
|
|
1652
|
+
if (ref !== undefined && options.fullRefsOnly && !ref.startsWith("refs/")) ref = undefined;
|
|
1653
|
+
}
|
|
1654
|
+
let treeish = id;
|
|
1655
|
+
if (id !== undefined) {
|
|
1656
|
+
const peeled = await resolver.peelTags(id).catch(() => undefined);
|
|
1657
|
+
if (peeled?.type === "commit") treeish = peeled.id;
|
|
1658
|
+
}
|
|
1659
|
+
return { ...(ref !== undefined ? { ref } : {}), ...(treeish ? { treeish } : {}) };
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1561
1662
|
/**
|
|
1562
1663
|
* A resolver for git's revision syntax over this command's stores (see
|
|
1563
1664
|
* {@link RevisionResolver}); its `warnings` hold what git would print.
|