@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
|
@@ -103,6 +103,11 @@ import {
|
|
|
103
103
|
saveAutostash,
|
|
104
104
|
} from "./sequencer-support.js";
|
|
105
105
|
import { showCommit } from "./show-commit.js";
|
|
106
|
+
import {
|
|
107
|
+
readStoredObjectBytes,
|
|
108
|
+
type SignatureCheck,
|
|
109
|
+
verifyCommitBytes,
|
|
110
|
+
} from "./signature-check.js";
|
|
106
111
|
import { SigningFailedError, type SignRequest, signRequestOf } from "./signing.js";
|
|
107
112
|
import {
|
|
108
113
|
amendWithTrailers,
|
|
@@ -374,7 +379,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
374
379
|
private readonly subjects = new Map<ObjectId, string>();
|
|
375
380
|
/** The refs' decorations, for `%d` in rebase.instructionFormat (loaded once) */
|
|
376
381
|
private decorations?: RefDecorations;
|
|
377
|
-
/**
|
|
382
|
+
/**
|
|
383
|
+
* What writing the todo list printed: loading the decorations (`warning: invalid replace
|
|
384
|
+
* ref <name>`), the `%G` checks (check_signature's `error:` lines)
|
|
385
|
+
*/
|
|
378
386
|
private decorationWarnings: string[] = [];
|
|
379
387
|
/** `--exec <command>` (each run after every pick) */
|
|
380
388
|
private execCommands: string[] = [];
|
|
@@ -1013,6 +1021,15 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1013
1021
|
return this;
|
|
1014
1022
|
}
|
|
1015
1023
|
|
|
1024
|
+
/** git sets `warn_on_auto_comment_char`: 2.5x warns of `core.commentChar=auto` here. */
|
|
1025
|
+
protected override autoCommentCharWarningEntryPoints(): readonly string[] {
|
|
1026
|
+
return ["call"];
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
protected override gitCompatibility(): "2.43" | "2.56" {
|
|
1030
|
+
return this.compatibility ?? this.hooks.compatibility;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1016
1033
|
async call(): Promise<RebaseResult> {
|
|
1017
1034
|
this.checkCallable();
|
|
1018
1035
|
this.setCallable(false);
|
|
@@ -1532,6 +1549,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1532
1549
|
action: "checkout",
|
|
1533
1550
|
operation: "rebase",
|
|
1534
1551
|
targetTree: ontoTreeId,
|
|
1552
|
+
// reset_head of onto, detached (no ref): the commit for the filter process
|
|
1553
|
+
metadata: { treeish: onto },
|
|
1535
1554
|
});
|
|
1536
1555
|
if (refused) {
|
|
1537
1556
|
await unstash();
|
|
@@ -1731,6 +1750,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1731
1750
|
action: "checkout",
|
|
1732
1751
|
operation: "rebase",
|
|
1733
1752
|
targetTree: ontoTreeId,
|
|
1753
|
+
// reset_head of onto, detached (no ref): the commit for the filter process
|
|
1754
|
+
metadata: { treeish: onto },
|
|
1734
1755
|
});
|
|
1735
1756
|
if (!refused) {
|
|
1736
1757
|
await state.setRef("ORIG_HEAD", origHead);
|
|
@@ -1784,6 +1805,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1784
1805
|
action: "checkout",
|
|
1785
1806
|
operation: "rebase",
|
|
1786
1807
|
targetTree: startTreeId,
|
|
1808
|
+
// checkout_onto: the commit for a long-running filter process
|
|
1809
|
+
metadata: { treeish: start },
|
|
1787
1810
|
});
|
|
1788
1811
|
if (refused) {
|
|
1789
1812
|
await state.remove(DIR);
|
|
@@ -3862,6 +3885,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3862
3885
|
action: "checkout",
|
|
3863
3886
|
operation: "rebase",
|
|
3864
3887
|
targetTree: ontoTreeId,
|
|
3888
|
+
// reset_head of onto, detached (no ref): the commit for the filter process
|
|
3889
|
+
metadata: { treeish: onto },
|
|
3865
3890
|
});
|
|
3866
3891
|
if (refused) {
|
|
3867
3892
|
await unstash();
|
|
@@ -5048,10 +5073,28 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
5048
5073
|
...(this.decorations ? { decorations: this.decorations } : {}),
|
|
5049
5074
|
...(format.includes("%(trailers") ? { trailers: trailerConfigOf(this.workingCopy) } : {}),
|
|
5050
5075
|
...(format.includes("%(describe") ? { describe: this.describer() } : {}),
|
|
5076
|
+
...(format.includes("%G") ? { signature: () => this.instructionSignature(id) } : {}),
|
|
5051
5077
|
});
|
|
5052
5078
|
return text.replace(/[ \t]+$/, "");
|
|
5053
5079
|
}
|
|
5054
5080
|
|
|
5081
|
+
/**
|
|
5082
|
+
* The `%G` placeholders of rebase.instructionFormat: the commit's signature checked through
|
|
5083
|
+
* the host's verifier (pretty.c's check_commit_signature, as log's), the check's own error
|
|
5084
|
+
* lines on stderr with the rebase's other messages.
|
|
5085
|
+
*/
|
|
5086
|
+
private async instructionSignature(id: ObjectId): Promise<SignatureCheck> {
|
|
5087
|
+
const bytes = await readStoredObjectBytes(this._workingCopy, id);
|
|
5088
|
+
if (!bytes) return { result: "N", trustLevel: "undefined", failed: true, messages: [] };
|
|
5089
|
+
const cwd = await this.hostWorkingDir();
|
|
5090
|
+
const check = await verifyCommitBytes(this._workingCopy, bytes, {
|
|
5091
|
+
objectFormat: this.objectFormat,
|
|
5092
|
+
...(cwd !== undefined ? { cwd } : {}),
|
|
5093
|
+
});
|
|
5094
|
+
this.decorationWarnings.push(...check.messages);
|
|
5095
|
+
return check;
|
|
5096
|
+
}
|
|
5097
|
+
|
|
5055
5098
|
/** `%(describe)` of rebase.instructionFormat: git describe over this repository's tags. */
|
|
5056
5099
|
private describer(): (id: ObjectId, options: DescribeOptions) => Promise<string> {
|
|
5057
5100
|
const abbreviator = createIdAbbreviator(this._workingCopy);
|
|
@@ -5300,6 +5343,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
5300
5343
|
action: "checkout",
|
|
5301
5344
|
operation: "rebase",
|
|
5302
5345
|
targetTree: targetTreeId,
|
|
5346
|
+
// reset_head with the branch: its full name and commit for the filter process
|
|
5347
|
+
metadata: { ...(headName.startsWith("refs/") ? { ref: headName } : {}), treeish: origHead },
|
|
5303
5348
|
});
|
|
5304
5349
|
if (refused) {
|
|
5305
5350
|
return {
|
|
@@ -62,8 +62,9 @@ export const DEFAULT_FOR_EACH_REF_FORMAT = "%(objectname) %(objecttype)\t%(refna
|
|
|
62
62
|
* names as paths (`refs/heads` matches `refs/heads/x`) or as globs. Sort keys are given in
|
|
63
63
|
* command-line order (the last one is the primary key), `refname` after them unless
|
|
64
64
|
* {@link setNoSort}; `-key` reverses and `version:key` compares as versions
|
|
65
|
-
* (`versionsort.suffix`).
|
|
66
|
-
*
|
|
65
|
+
* (`versionsort.suffix`). `%(signature...)` checks a commit's signature through the host's
|
|
66
|
+
* verifier, as `verify-commit` does (its error lines in `warnings`). `%(objectsize:disk)` and
|
|
67
|
+
* `%(deltabase)` read the object's pack entry header or loose file (`objectDiskInfoOf`).
|
|
67
68
|
*/
|
|
68
69
|
export class ForEachRefCommand extends RefListingCommand<ForEachRefResult> {
|
|
69
70
|
private format = DEFAULT_FOR_EACH_REF_FORMAT;
|
|
@@ -292,7 +293,7 @@ export class ForEachRefCommand extends RefListingCommand<ForEachRefResult> {
|
|
|
292
293
|
output: result.output,
|
|
293
294
|
lines: result.lines,
|
|
294
295
|
refs: result.items.map((i: RefFilterItem) => ({ refname: i.refname, objectId: i.objectId })),
|
|
295
|
-
warnings: [...baseWarnings, ...result.warnings],
|
|
296
|
+
warnings: [...baseWarnings, ...result.warnings, ...format.messages],
|
|
296
297
|
};
|
|
297
298
|
}
|
|
298
299
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many tags the ref filter peels through before it gives up. git's own peeling has no
|
|
3
|
+
* bound, so a tag cycle made through replace refs (tag A replaced by tag B, which names A)
|
|
4
|
+
* makes native `--points-at`, `--contains` and `%(*atom)` loop forever; ours stops here and
|
|
5
|
+
* treats the chain as reaching nothing (statewalker/webrun-vcs#263).
|
|
6
|
+
*/
|
|
7
|
+
export const MAX_REF_FILTER_PEEL_DEPTH = 1000;
|
|
@@ -20,6 +20,7 @@ import { decodeGitPath, encodeGitPath } from "@statewalker/vcs-utils";
|
|
|
20
20
|
import { wildmatch } from "@statewalker/vcs-working-tree";
|
|
21
21
|
|
|
22
22
|
import { RefFilterError } from "../../errors/index.js";
|
|
23
|
+
import { MAX_REF_FILTER_PEEL_DEPTH } from "./peel-limit.js";
|
|
23
24
|
import {
|
|
24
25
|
type RefFilterItem,
|
|
25
26
|
type RefFormat,
|
|
@@ -213,7 +214,7 @@ export interface FilteredRefs {
|
|
|
213
214
|
/** The commit an object peels to (lookup_commit_reference_gently), undefined when none. */
|
|
214
215
|
async function commitOf(source: RefFilterSource, id: ObjectId): Promise<ObjectId | undefined> {
|
|
215
216
|
let current = id;
|
|
216
|
-
for (let depth = 0; depth <
|
|
217
|
+
for (let depth = 0; depth < MAX_REF_FILTER_PEEL_DEPTH; depth++) {
|
|
217
218
|
const object = await source.readObject(current);
|
|
218
219
|
if (!object) return undefined;
|
|
219
220
|
if (object.type === "commit") return current;
|
|
@@ -225,7 +226,11 @@ async function commitOf(source: RefFilterSource, id: ObjectId): Promise<ObjectId
|
|
|
225
226
|
return undefined;
|
|
226
227
|
}
|
|
227
228
|
|
|
228
|
-
/**
|
|
229
|
+
/**
|
|
230
|
+
* match_points_at: the ref's object, or one a tag on the way names, is wanted. A chain longer
|
|
231
|
+
* than {@link MAX_REF_FILTER_PEEL_DEPTH} (a tag cycle through replace refs, where git loops
|
|
232
|
+
* forever) does not match.
|
|
233
|
+
*/
|
|
229
234
|
async function matchPointsAt(
|
|
230
235
|
source: RefFilterSource,
|
|
231
236
|
wanted: ReadonlySet<ObjectId>,
|
|
@@ -235,7 +240,8 @@ async function matchPointsAt(
|
|
|
235
240
|
if (wanted.has(id)) return true;
|
|
236
241
|
let object = await source.readObject(id);
|
|
237
242
|
let current = id;
|
|
238
|
-
|
|
243
|
+
for (let depth = 0; object && object.type === "tag"; depth++) {
|
|
244
|
+
if (depth >= MAX_REF_FILTER_PEEL_DEPTH) return false;
|
|
239
245
|
const target = tagHeader(decodeGitPath(object.bytes)).object;
|
|
240
246
|
if (!target) {
|
|
241
247
|
object = undefined;
|
|
@@ -417,7 +423,6 @@ export async function sortRefs(
|
|
|
417
423
|
warnings: string[] = [],
|
|
418
424
|
): Promise<void> {
|
|
419
425
|
if (sorting.length === 0) return;
|
|
420
|
-
for (const item of items) for (const key of sorting) await format.value(item, key.atom);
|
|
421
426
|
let suffixes: string[] | undefined;
|
|
422
427
|
const compareKey = (key: RefSortKey, a: RefFilterItem, b: RefFilterItem): number => {
|
|
423
428
|
const va = (a.values as NonNullable<RefFilterItem["values"]>)[key.atom];
|
|
@@ -439,15 +444,67 @@ export async function sortRefs(
|
|
|
439
444
|
return key.reverse && !detached ? -cmp : cmp;
|
|
440
445
|
};
|
|
441
446
|
const first = sorting[0] as RefSortKey;
|
|
442
|
-
|
|
447
|
+
// compare_refs: each key's values, `a`'s then `b`'s, computed when first asked (every atom
|
|
448
|
+
// of a ref at once, populate_value: the order git's checks print their errors in)
|
|
449
|
+
const compare = async (a: RefFilterItem, b: RefFilterItem): Promise<number> => {
|
|
443
450
|
for (const key of sorting) {
|
|
451
|
+
await format.value(a, key.atom);
|
|
452
|
+
await format.value(b, key.atom);
|
|
444
453
|
const cmp = compareKey(key, a, b);
|
|
445
454
|
if (cmp) return cmp;
|
|
446
455
|
}
|
|
447
456
|
return first.icase
|
|
448
457
|
? compareBytesIcase(a.refname, b.refname)
|
|
449
458
|
: compareBytes(a.refname, b.refname);
|
|
450
|
-
}
|
|
459
|
+
};
|
|
460
|
+
const sorted = await mergeSort(items, compare);
|
|
461
|
+
for (let i = 0; i < sorted.length; i++) items[i] = sorted[i] as RefFilterItem;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* compat/qsort_s.c's msort_with_tmp (git's QSORT_S on platforms without an ISO qsort_s):
|
|
466
|
+
* a stable merge sort comparing in the order git does, the left half sorted first.
|
|
467
|
+
*/
|
|
468
|
+
async function mergeSort<T>(
|
|
469
|
+
items: readonly T[],
|
|
470
|
+
compare: (a: T, b: T) => Promise<number>,
|
|
471
|
+
): Promise<T[]> {
|
|
472
|
+
if (items.length <= 1) return [...items];
|
|
473
|
+
const n1 = Math.floor(items.length / 2);
|
|
474
|
+
const left = await mergeSort(items.slice(0, n1), compare);
|
|
475
|
+
const right = await mergeSort(items.slice(n1), compare);
|
|
476
|
+
const out: T[] = [];
|
|
477
|
+
let i = 0;
|
|
478
|
+
let j = 0;
|
|
479
|
+
while (i < left.length && j < right.length) {
|
|
480
|
+
if ((await compare(left[i] as T, right[j] as T)) <= 0) out.push(left[i++] as T);
|
|
481
|
+
else out.push(right[j++] as T);
|
|
482
|
+
}
|
|
483
|
+
while (i < left.length) out.push(left[i++] as T);
|
|
484
|
+
while (j < right.length) out.push(right[j++] as T);
|
|
485
|
+
return out;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* can_do_iterative_format (git 2.47+): refs sorted by `refname` alone (any of its forms, no
|
|
490
|
+
* flag), no `%(ahead-behind)` or `%(is-base)` and no `--[no-]merged` are formatted in the
|
|
491
|
+
* order the ref backends list them (full names, byte order), never sorted by the key, each
|
|
492
|
+
* ref's values computed in that order.
|
|
493
|
+
*/
|
|
494
|
+
function formatsIteratively(
|
|
495
|
+
sorting: readonly RefSortKey[],
|
|
496
|
+
format: RefFormat,
|
|
497
|
+
filter: RefFilterOptions,
|
|
498
|
+
): boolean {
|
|
499
|
+
if (format.compatibility === "2.43") return false;
|
|
500
|
+
if (sorting.length > 1) return false;
|
|
501
|
+
const key = sorting[0];
|
|
502
|
+
if (key) {
|
|
503
|
+
if (key.reverse || key.version || key.icase || key.detachedHeadFirst) return false;
|
|
504
|
+
if (format.atoms[key.atom]?.type !== "refname") return false;
|
|
505
|
+
}
|
|
506
|
+
if (format.atoms.some((a) => a.type === "ahead-behind" || a.type === "is-base")) return false;
|
|
507
|
+
return !filter.merged?.length && !filter.noMerged?.length;
|
|
451
508
|
}
|
|
452
509
|
|
|
453
510
|
/**
|
|
@@ -635,7 +692,11 @@ export async function filterAndFormatRefs(
|
|
|
635
692
|
const { items, warnings } = await filterRefs(source, filter);
|
|
636
693
|
await fillAheadBehind(items, options.aheadBehindBases ?? [], source, warnings);
|
|
637
694
|
await fillIsBase(items, options.isBaseTips ?? [], source);
|
|
638
|
-
|
|
695
|
+
if (formatsIteratively(sorting, format, filter)) {
|
|
696
|
+
// the ref backends' iteration order: full names, byte by byte (whatever form of
|
|
697
|
+
// `refname` the key asked for)
|
|
698
|
+
items.sort((a, b) => compareBytes(a.refname, b.refname));
|
|
699
|
+
} else await sortRefs(items, sorting, format, source, warnings);
|
|
639
700
|
const total = options.count && options.count < items.length ? options.count : items.length;
|
|
640
701
|
const shown = items.slice(0, total);
|
|
641
702
|
const lines: string[] = [];
|
|
@@ -23,7 +23,9 @@ import { RefFilterError } from "../../errors/index.js";
|
|
|
23
23
|
import { type DateMode, parseDateMode, type ShowDateContext, showDate } from "../date-format.js";
|
|
24
24
|
import type { Mailmap } from "../mailmap.js";
|
|
25
25
|
import { sanitizedSubject } from "../pretty-format.js";
|
|
26
|
+
import type { SignatureCheck } from "../signature-check.js";
|
|
26
27
|
import { appendTrailers, type TrailerConfig } from "../trailers.js";
|
|
28
|
+
import { MAX_REF_FILTER_PEEL_DEPTH } from "./peel-limit.js";
|
|
27
29
|
import { type AtomCmpType, parseAtom, type UsedAtom } from "./ref-atoms.js";
|
|
28
30
|
import { quoteRefValue, type RefQuoteStyle } from "./ref-quote.js";
|
|
29
31
|
|
|
@@ -117,6 +119,18 @@ export interface RefFormatSource {
|
|
|
117
119
|
headDescription?(): Promise<string>;
|
|
118
120
|
/** The clock and local zone dates are shown with */
|
|
119
121
|
dateContext?: ShowDateContext;
|
|
122
|
+
/**
|
|
123
|
+
* check_commit_signature: a commit's signature (its bytes as stored) checked through the
|
|
124
|
+
* host's verifier, as `verify-commit` checks it; without this, `%(signature)` of a signed
|
|
125
|
+
* commit refuses.
|
|
126
|
+
*/
|
|
127
|
+
commitSignature?(bytes: Uint8Array): Promise<SignatureCheck>;
|
|
128
|
+
/**
|
|
129
|
+
* An object's size on disk (its pack entry or loose file) and delta base (the null id when
|
|
130
|
+
* not stored as a delta), for `%(objectsize:disk)` and `%(deltabase)`; undefined when no
|
|
131
|
+
* pack or loose file of the repository holds it. Without this, those atoms refuse.
|
|
132
|
+
*/
|
|
133
|
+
objectOnDisk?(id: ObjectId): Promise<{ diskSize: number; deltaBase: ObjectId } | undefined>;
|
|
120
134
|
}
|
|
121
135
|
|
|
122
136
|
/** How {@link RefFormat} expands its format. */
|
|
@@ -431,9 +445,13 @@ export class RefFormat {
|
|
|
431
445
|
private readonly quoteStyle: RefQuoteStyle;
|
|
432
446
|
private readonly useColor: boolean;
|
|
433
447
|
private readonly peelNested: boolean;
|
|
448
|
+
/** The git version followed (see {@link RefFormatOptions.compatibility}) */
|
|
449
|
+
readonly compatibility: "2.43" | "2.56";
|
|
434
450
|
private headTarget?: Promise<string | undefined>;
|
|
435
451
|
private mailmapLoad?: Promise<Mailmap>;
|
|
436
452
|
private dateModes = new Map<string, DateMode>();
|
|
453
|
+
/** What the signature checks printed on stderr (`error: cannot run gpg: ...`), in order */
|
|
454
|
+
readonly messages: string[] = [];
|
|
437
455
|
|
|
438
456
|
/**
|
|
439
457
|
* `format` verified as git's verify_ref_format does (atoms parsed, `%(rest)` refused,
|
|
@@ -449,6 +467,7 @@ export class RefFormat {
|
|
|
449
467
|
this.quoteStyle = options.quoteStyle ?? "none";
|
|
450
468
|
this.useColor = options.useColor ?? false;
|
|
451
469
|
this.peelNested = options.compatibility !== "2.43";
|
|
470
|
+
this.compatibility = options.compatibility ?? "2.56";
|
|
452
471
|
let cp = 0;
|
|
453
472
|
for (;;) {
|
|
454
473
|
const sp = findNext(format, cp);
|
|
@@ -715,7 +734,7 @@ export class RefFormat {
|
|
|
715
734
|
private async peel(id: ObjectId, object: RefFormatObject): Promise<ObjectId | undefined> {
|
|
716
735
|
let current = object;
|
|
717
736
|
let currentId = id;
|
|
718
|
-
for (let depth = 0; current.type === "tag" && depth <
|
|
737
|
+
for (let depth = 0; current.type === "tag" && depth < MAX_REF_FILTER_PEEL_DEPTH; depth++) {
|
|
719
738
|
const header = tagHeader(decodeGitPath(current.bytes));
|
|
720
739
|
if (!header.object || !header.type) return undefined;
|
|
721
740
|
const next = await this.source.readObject(header.object);
|
|
@@ -806,6 +825,20 @@ export class RefFormat {
|
|
|
806
825
|
}
|
|
807
826
|
}
|
|
808
827
|
|
|
828
|
+
/** `disk_sizep` and `delta_base_oid` of get_object's object info. */
|
|
829
|
+
private async onDisk(
|
|
830
|
+
id: ObjectId,
|
|
831
|
+
atom: UsedAtom,
|
|
832
|
+
refname: string,
|
|
833
|
+
): Promise<{ diskSize: number; deltaBase: ObjectId }> {
|
|
834
|
+
if (!this.source.objectOnDisk) {
|
|
835
|
+
throw fatal(`%(${atom.name}) is not supported: this store does not keep objects on disk`);
|
|
836
|
+
}
|
|
837
|
+
const found = await this.source.objectOnDisk(id);
|
|
838
|
+
if (!found) throw fatal(`missing object ${id} for ${refname}`);
|
|
839
|
+
return found;
|
|
840
|
+
}
|
|
841
|
+
|
|
809
842
|
/** grab_values (and grab_common_values) of one object, the ref's own or the peeled one. */
|
|
810
843
|
private async grabValues(
|
|
811
844
|
values: AtomValue[],
|
|
@@ -823,12 +856,15 @@ export class RefFormat {
|
|
|
823
856
|
if (atom.type === "objecttype") v.s = object.type;
|
|
824
857
|
else if (atom.type === "objectsize") {
|
|
825
858
|
if (atom.objectsize === "disk") {
|
|
826
|
-
|
|
859
|
+
const { diskSize } = await this.onDisk(id, atom, refname);
|
|
860
|
+
v.value = diskSize;
|
|
861
|
+
v.s = String(diskSize);
|
|
862
|
+
continue;
|
|
827
863
|
}
|
|
828
864
|
v.value = object.bytes.length;
|
|
829
865
|
v.s = String(object.bytes.length);
|
|
830
866
|
} else if (atom.type === "deltabase") {
|
|
831
|
-
|
|
867
|
+
v.s = (await this.onDisk(id, atom, refname)).deltaBase;
|
|
832
868
|
} else if (atom.type === "objectname" && deref) v.s = await this.oidText(id, atom);
|
|
833
869
|
}
|
|
834
870
|
if (object.type === "tag") {
|
|
@@ -861,7 +897,7 @@ export class RefFormat {
|
|
|
861
897
|
await this.grabContents(mine, object, buf);
|
|
862
898
|
await this.grabPerson("author", mine, buf);
|
|
863
899
|
await this.grabPerson("committer", mine, buf);
|
|
864
|
-
this.grabSignature(mine, buf);
|
|
900
|
+
await this.grabSignature(mine, object.bytes, buf);
|
|
865
901
|
await this.grabDescribe(mine, id, object);
|
|
866
902
|
} else {
|
|
867
903
|
await this.grabContents(mine, object, buf);
|
|
@@ -991,17 +1027,55 @@ export class RefFormat {
|
|
|
991
1027
|
v.value = timestamp;
|
|
992
1028
|
}
|
|
993
1029
|
|
|
994
|
-
/**
|
|
995
|
-
|
|
1030
|
+
/**
|
|
1031
|
+
* grab_signature: the commit's signature checked once (check_commit_signature) and each
|
|
1032
|
+
* `%(signature...)` atom given its field; an unsigned commit is `N`, trust `undefined`.
|
|
1033
|
+
*/
|
|
1034
|
+
private async grabSignature(values: AtomValue[], bytes: Uint8Array, buf: string) {
|
|
996
1035
|
const atoms = values.filter((v) => v.atom.type === "signature");
|
|
997
1036
|
if (atoms.length === 0) return;
|
|
998
|
-
|
|
999
|
-
if (
|
|
1000
|
-
|
|
1037
|
+
let check: SignatureCheck;
|
|
1038
|
+
if (this.source.commitSignature) {
|
|
1039
|
+
check = await this.source.commitSignature(bytes);
|
|
1040
|
+
for (const line of check.messages) this.messages.push(line);
|
|
1041
|
+
} else {
|
|
1042
|
+
const header = buf.slice(0, Math.max(buf.indexOf("\n\n"), 0));
|
|
1043
|
+
if (/(^|\n)gpgsig(-sha256)? /.test(header)) {
|
|
1044
|
+
throw fatal("%(signature) is not supported: signatures cannot be verified");
|
|
1045
|
+
}
|
|
1046
|
+
check = { result: "N", trustLevel: "undefined", failed: true, messages: [] };
|
|
1001
1047
|
}
|
|
1002
1048
|
for (const v of atoms) {
|
|
1003
|
-
|
|
1004
|
-
|
|
1049
|
+
switch (v.atom.signature) {
|
|
1050
|
+
case "":
|
|
1051
|
+
v.s = check.output ?? "";
|
|
1052
|
+
break;
|
|
1053
|
+
case "signer":
|
|
1054
|
+
v.s = check.signer ?? "";
|
|
1055
|
+
break;
|
|
1056
|
+
case "grade":
|
|
1057
|
+
v.s =
|
|
1058
|
+
check.result === "G"
|
|
1059
|
+
? check.trustLevel === "undefined" || check.trustLevel === "never"
|
|
1060
|
+
? "U"
|
|
1061
|
+
: "G"
|
|
1062
|
+
: check.result;
|
|
1063
|
+
break;
|
|
1064
|
+
case "key":
|
|
1065
|
+
v.s = check.key ?? "";
|
|
1066
|
+
break;
|
|
1067
|
+
case "fingerprint":
|
|
1068
|
+
v.s = check.fingerprint ?? "";
|
|
1069
|
+
break;
|
|
1070
|
+
case "primarykeyfingerprint":
|
|
1071
|
+
v.s = check.primaryKeyFingerprint ?? "";
|
|
1072
|
+
break;
|
|
1073
|
+
case "trustlevel":
|
|
1074
|
+
v.s = check.trustLevel;
|
|
1075
|
+
break;
|
|
1076
|
+
default:
|
|
1077
|
+
v.s = "";
|
|
1078
|
+
}
|
|
1005
1079
|
}
|
|
1006
1080
|
}
|
|
1007
1081
|
|
|
@@ -24,6 +24,8 @@ import { applyRefspecs } from "../branch-tracking.js";
|
|
|
24
24
|
import { createDescriber } from "../git-describe.js";
|
|
25
25
|
import { hostEnvironmentOf } from "../git-ident.js";
|
|
26
26
|
import { type Mailmap, readRepositoryMailmap } from "../mailmap.js";
|
|
27
|
+
import { type ObjectDiskInfo, objectDiskInfoOf } from "../object-disk-info.js";
|
|
28
|
+
import { verifyCommitBytes } from "../signature-check.js";
|
|
27
29
|
import { trailerConfigOf } from "../trailers.js";
|
|
28
30
|
import type { ListedRef, RefFilterSource } from "./ref-filter.js";
|
|
29
31
|
import type { RefFormatObject, RefFormatSource } from "./ref-format.js";
|
|
@@ -51,6 +53,26 @@ export abstract class RefListingCommand<T> extends GitCommand<T> {
|
|
|
51
53
|
private objectCache = new Map<ObjectId, Promise<RefFormatObject | undefined>>();
|
|
52
54
|
private replacements?: Promise<ReadonlyMap<ObjectId, ObjectId> | undefined>;
|
|
53
55
|
private worktreeHeads?: Promise<Map<string, string>>;
|
|
56
|
+
private diskInfo?: Promise<ObjectDiskInfo>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* An object's on-disk size and delta base, through replace refs as {@link readObjectForFilter}
|
|
60
|
+
* (ref-filter.c's `oid_object_info_extended(..., OBJECT_INFO_LOOKUP_REPLACE)`).
|
|
61
|
+
*/
|
|
62
|
+
protected async objectOnDisk(
|
|
63
|
+
id: ObjectId,
|
|
64
|
+
): Promise<{ diskSize: number; deltaBase: ObjectId } | undefined> {
|
|
65
|
+
this.replacements ??= this.objectReplacements().then((r) =>
|
|
66
|
+
r?.replace.size ? r.replace : undefined,
|
|
67
|
+
);
|
|
68
|
+
const replace = await this.replacements;
|
|
69
|
+
const read = replace ? replacementOf(replace, id) : id;
|
|
70
|
+
this.diskInfo ??= objectDiskInfoOf(this._workingCopy);
|
|
71
|
+
const info = await this.diskInfo;
|
|
72
|
+
const diskSize = await info.diskSize(read);
|
|
73
|
+
const deltaBase = await info.deltaBase(read);
|
|
74
|
+
return diskSize === undefined || deltaBase === undefined ? undefined : { diskSize, deltaBase };
|
|
75
|
+
}
|
|
54
76
|
|
|
55
77
|
/** An object's type and content, through replace refs (git's OBJECT_INFO_LOOKUP_REPLACE). */
|
|
56
78
|
protected readObjectForFilter(id: ObjectId): Promise<RefFormatObject | undefined> {
|
|
@@ -312,6 +334,7 @@ export abstract class RefListingCommand<T> extends GitCommand<T> {
|
|
|
312
334
|
let describer: ReturnType<typeof createDescriber> | undefined;
|
|
313
335
|
return {
|
|
314
336
|
readObject: (id) => this.readObjectForFilter(id),
|
|
337
|
+
objectOnDisk: (id) => this.objectOnDisk(id),
|
|
315
338
|
abbreviate: async (id, minLength) => {
|
|
316
339
|
if (minLength === undefined) return this.abbreviateObjectId(id);
|
|
317
340
|
const lengths = await this.idAbbreviator().lengths([id], minLength);
|
|
@@ -372,6 +395,13 @@ export abstract class RefListingCommand<T> extends GitCommand<T> {
|
|
|
372
395
|
});
|
|
373
396
|
},
|
|
374
397
|
trailerConfig: () => trailerConfigOf(this._workingCopy),
|
|
398
|
+
commitSignature: async (bytes) => {
|
|
399
|
+
const cwd = await this.hostWorkingDir();
|
|
400
|
+
return verifyCommitBytes(this._workingCopy, bytes, {
|
|
401
|
+
objectFormat: this.objectFormat,
|
|
402
|
+
...(cwd !== undefined ? { cwd } : {}),
|
|
403
|
+
});
|
|
404
|
+
},
|
|
375
405
|
};
|
|
376
406
|
}
|
|
377
407
|
|
|
@@ -1072,7 +1072,7 @@ export class RemoteSetUrlCommand extends GitCommand<RemoteConfig> {
|
|
|
1072
1072
|
const hits = values.filter((v) => matchesUrl(regex, v)).length;
|
|
1073
1073
|
if (this.deleteMode) {
|
|
1074
1074
|
if (hits === 0) throw new GitApiError(`fatal: could not unset '${key}'`);
|
|
1075
|
-
store.
|
|
1075
|
+
store.editValues(
|
|
1076
1076
|
key,
|
|
1077
1077
|
values.filter((v): v is string => v !== undefined && !matchesUrl(regex, v)),
|
|
1078
1078
|
);
|
|
@@ -1118,7 +1118,7 @@ function replaceMatching(
|
|
|
1118
1118
|
store.addValue(key, newValue);
|
|
1119
1119
|
return;
|
|
1120
1120
|
}
|
|
1121
|
-
store.
|
|
1121
|
+
store.editValues(
|
|
1122
1122
|
key,
|
|
1123
1123
|
values.map((v) => (matchesUrl(regex, v) ? newValue : (v ?? ""))),
|
|
1124
1124
|
);
|
|
@@ -30,7 +30,7 @@ import type {
|
|
|
30
30
|
OpenedRepository,
|
|
31
31
|
WorkingCopy,
|
|
32
32
|
} from "@statewalker/vcs-working-tree";
|
|
33
|
-
import { InvalidConfigError, TransportError } from "../errors/index.js";
|
|
33
|
+
import { GitApiError, InvalidConfigError, TransportError } from "../errors/index.js";
|
|
34
34
|
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
35
35
|
import { type BundleRemote, withBundleUploadPack } from "./bundle/bundle-transport.js";
|
|
36
36
|
import { openBundle, verifyBundleIn } from "./bundle/bundle-verify.js";
|
|
@@ -43,6 +43,8 @@ import {
|
|
|
43
43
|
withLocalReceivePack,
|
|
44
44
|
withLocalUploadPack,
|
|
45
45
|
} from "./local-transport.js";
|
|
46
|
+
import { packObjectsHookOf } from "./serve-repository.js";
|
|
47
|
+
import type { ServedLazyFetchOptions } from "./served-lazy-fetch.js";
|
|
46
48
|
import { repositoryPlaceOf } from "./worktree-support.js";
|
|
47
49
|
|
|
48
50
|
/** A remote URL resolved to the transport that reaches it. */
|
|
@@ -354,6 +356,37 @@ export interface RemoteSessionOptions {
|
|
|
354
356
|
alternateAllowed?: (scheme: string) => boolean;
|
|
355
357
|
/** HTTP: `$GIT_SMART_HTTP` (false: the dumb protocol) */
|
|
356
358
|
smartHttp?: boolean;
|
|
359
|
+
/**
|
|
360
|
+
* A local remote's hooks, as the upload-pack git's local transport spawns runs them
|
|
361
|
+
* (`remoteHookSession(workingCopy, remote, { localPush: true })`): its
|
|
362
|
+
* `uploadpack.packObjectsHook`, from the system and global files only
|
|
363
|
+
*/
|
|
364
|
+
localHooks?: (remote: OpenedRepository) => HookSession | undefined;
|
|
365
|
+
/**
|
|
366
|
+
* `$GIT_NAMESPACE` (the host environment's `namespace`): the ref namespace a local remote's
|
|
367
|
+
* upload-pack and receive-pack serve, as git's spawned ones inherit it
|
|
368
|
+
*/
|
|
369
|
+
namespace?: string;
|
|
370
|
+
/**
|
|
371
|
+
* The host environment's `GIT_NO_LAZY_FETCH=0`, which git's spawned upload-pack inherits: a
|
|
372
|
+
* local remote's upload-pack then fetches the absent promisor objects a pack needs from the
|
|
373
|
+
* remote's own promisor remotes (see `localLazyFetchOf`); unset, it refuses them as git's
|
|
374
|
+
*/
|
|
375
|
+
localLazyFetch?: ServedLazyFetchOptions;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* What a local remote's upload-pack inherits of the client for its lazy fetch: only under
|
|
380
|
+
* the host environment's `GIT_NO_LAZY_FETCH=0` (git's upload-pack sets it to 1 unless the
|
|
381
|
+
* variable is set), through the client's transports and per-URL credential helper. Static
|
|
382
|
+
* credentials and headers never go: the promisor URLs are the remote repository's config.
|
|
383
|
+
*/
|
|
384
|
+
export function localLazyFetchOf(
|
|
385
|
+
environment: GitHostEnvironment | undefined,
|
|
386
|
+
options: Omit<ServedLazyFetchOptions, "environment">,
|
|
387
|
+
): { localLazyFetch?: ServedLazyFetchOptions } {
|
|
388
|
+
if (environment?.noLazyFetch !== false) return {};
|
|
389
|
+
return { localLazyFetch: { ...options, environment } };
|
|
357
390
|
}
|
|
358
391
|
|
|
359
392
|
/**
|
|
@@ -427,12 +460,33 @@ export async function withRemoteSession<T>(
|
|
|
427
460
|
run: (session: GitSession, request: GitConnectRequest) => Promise<T>,
|
|
428
461
|
): Promise<T> {
|
|
429
462
|
const request = connectRequest(remote, service, options);
|
|
430
|
-
|
|
463
|
+
let session: GitSession | undefined;
|
|
431
464
|
try {
|
|
465
|
+
session = closingOnce(await remote.connector.connect(request));
|
|
432
466
|
return await run(session, request);
|
|
467
|
+
} catch (error) {
|
|
468
|
+
throw connectorDeath(error);
|
|
433
469
|
} finally {
|
|
434
|
-
if (session
|
|
470
|
+
if (session?.kind === "native") await session.duplex.close?.().catch(() => undefined);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* A connector's or the protocol layer's own death in git's words (a plain transport error
|
|
476
|
+
* whose message is git's `fatal:` lines: a refused ssh host, an `ext::` placeholder, a
|
|
477
|
+
* remote that closed before it spoke) as the command error git's exit status goes with (128);
|
|
478
|
+
* anything else unchanged.
|
|
479
|
+
*/
|
|
480
|
+
function connectorDeath(error: unknown): unknown {
|
|
481
|
+
if (
|
|
482
|
+
error instanceof Error &&
|
|
483
|
+
!(error instanceof GitApiError) &&
|
|
484
|
+
error.name === "TransportError" &&
|
|
485
|
+
/^fatal: /m.test(error.message)
|
|
486
|
+
) {
|
|
487
|
+
return new TransportError(error.message, undefined, { cause: error, exitCode: 128 });
|
|
435
488
|
}
|
|
489
|
+
return error;
|
|
436
490
|
}
|
|
437
491
|
|
|
438
492
|
/**
|
|
@@ -446,8 +500,16 @@ export async function withRemoteUploadPack<T>(
|
|
|
446
500
|
run: (connection: UploadPackConnection) => Promise<T>,
|
|
447
501
|
): Promise<T> {
|
|
448
502
|
if (remote.kind === "local") {
|
|
503
|
+
// git-upload-pack '<path>' reads the system and global files, never the command line's
|
|
504
|
+
// config (connect.c's local_repo_env) nor the repository's
|
|
505
|
+
const packObjectsHook = await packObjectsHookOf(options.localHooks?.(remote.repository), {
|
|
506
|
+
commandLine: false,
|
|
507
|
+
});
|
|
449
508
|
return withLocalUploadPack(remote.repository, run, {
|
|
450
509
|
protocolVersion: options.protocolVersion,
|
|
510
|
+
...(options.localLazyFetch ? { lazyFetch: options.localLazyFetch } : {}),
|
|
511
|
+
...(options.namespace ? { namespace: options.namespace } : {}),
|
|
512
|
+
...(packObjectsHook ? { packObjectsHook } : {}),
|
|
451
513
|
});
|
|
452
514
|
}
|
|
453
515
|
if (remote.kind === "bundle") return withBundleUploadPack(remote.remote, createDuplexPair, run);
|
|
@@ -488,6 +550,7 @@ export async function withRemoteReceivePack<T>(
|
|
|
488
550
|
if (remote.kind === "local") {
|
|
489
551
|
return withLocalReceivePack(remote.repository, run, hooks, transactionHooks, {
|
|
490
552
|
protocolVersion: options.protocolVersion,
|
|
553
|
+
...(options.namespace ? { namespace: options.namespace } : {}),
|
|
491
554
|
...local,
|
|
492
555
|
});
|
|
493
556
|
}
|