@statewalker/vcs-commands 0.7.0 → 0.8.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 +38 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +55 -1
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/am/index.d.ts +1 -0
- package/dist/commands/am/index.d.ts.map +1 -1
- package/dist/commands/am/mailsplit.d.ts +88 -0
- package/dist/commands/am/mailsplit.d.ts.map +1 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-engine.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/bisect/bisect-command.d.ts +2 -0
- package/dist/commands/bisect/bisect-command.d.ts.map +1 -1
- package/dist/commands/branch-command.d.ts +148 -18
- package/dist/commands/branch-command.d.ts.map +1 -1
- package/dist/commands/branch-info-command.d.ts +55 -0
- package/dist/commands/branch-info-command.d.ts.map +1 -0
- package/dist/commands/branch-tracking.d.ts +106 -17
- package/dist/commands/branch-tracking.d.ts.map +1 -1
- package/dist/commands/branch-upstream-command.d.ts +83 -0
- package/dist/commands/branch-upstream-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +19 -3
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/cherry-pick-command.d.ts +59 -0
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +12 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +191 -5
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/commit-reuse.d.ts +33 -0
- package/dist/commands/commit-reuse.d.ts.map +1 -0
- package/dist/commands/config-command.d.ts +236 -0
- package/dist/commands/config-command.d.ts.map +1 -0
- package/dist/commands/config-value-types.d.ts +91 -0
- package/dist/commands/config-value-types.d.ts.map +1 -0
- package/dist/commands/core-config.d.ts +20 -0
- package/dist/commands/core-config.d.ts.map +1 -1
- package/dist/commands/diff-color-config.d.ts +73 -0
- package/dist/commands/diff-color-config.d.ts.map +1 -0
- package/dist/commands/diff-command.d.ts +252 -5
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +20 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fmt-merge-msg-command.d.ts +124 -0
- package/dist/commands/fmt-merge-msg-command.d.ts.map +1 -0
- package/dist/commands/fork-point.d.ts +38 -0
- package/dist/commands/fork-point.d.ts.map +1 -0
- package/dist/commands/format-patch-command.d.ts +41 -1
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/fsck/fetch-fsck.d.ts +51 -0
- package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -1
- package/dist/commands/gc-command.d.ts +8 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +4 -0
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +35 -0
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/grep/grep-command.d.ts +210 -0
- package/dist/commands/grep/grep-command.d.ts.map +1 -0
- package/dist/commands/grep/grep-engine.d.ts +218 -0
- package/dist/commands/grep/grep-engine.d.ts.map +1 -0
- package/dist/commands/grep/index.d.ts +3 -0
- package/dist/commands/grep/index.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +13 -2
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index.d.ts +26 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -3
- package/dist/commands/interpret-trailers-command.d.ts +90 -0
- package/dist/commands/interpret-trailers-command.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts +36 -5
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +296 -11
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +26 -1
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +133 -5
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-remote-command.d.ts +2 -0
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/mailmap.d.ts +30 -0
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/merge-base-command.d.ts +60 -0
- package/dist/commands/merge-base-command.d.ts.map +1 -0
- package/dist/commands/merge-bases.d.ts +23 -0
- package/dist/commands/merge-bases.d.ts.map +1 -1
- package/dist/commands/merge-command.d.ts +96 -9
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/mv-command.d.ts +4 -0
- package/dist/commands/mv-command.d.ts.map +1 -1
- package/dist/commands/name-rev.d.ts +48 -0
- package/dist/commands/name-rev.d.ts.map +1 -0
- package/dist/commands/notes-command.d.ts.map +1 -1
- package/dist/commands/pathspec-file.d.ts +39 -0
- package/dist/commands/pathspec-file.d.ts.map +1 -0
- package/dist/commands/pathspec.d.ts +3 -0
- package/dist/commands/pathspec.d.ts.map +1 -1
- package/dist/commands/pretty-format.d.ts +43 -3
- package/dist/commands/pretty-format.d.ts.map +1 -1
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +10 -0
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +160 -9
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/read-tree-command.d.ts +6 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +168 -6
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/for-each-ref-command.d.ts +121 -0
- package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -0
- package/dist/commands/ref-filter/index.d.ts +8 -0
- package/dist/commands/ref-filter/index.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-atoms.d.ts +88 -0
- package/dist/commands/ref-filter/ref-atoms.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-filter.d.ts +178 -0
- package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-format.d.ts +222 -0
- package/dist/commands/ref-filter/ref-format.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts +56 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-quote.d.ts +20 -0
- package/dist/commands/ref-filter/ref-quote.d.ts.map +1 -0
- package/dist/commands/ref-filter/version-compare.d.ts +20 -0
- package/dist/commands/ref-filter/version-compare.d.ts.map +1 -0
- package/dist/commands/reflog-command.d.ts +120 -0
- package/dist/commands/reflog-command.d.ts.map +1 -1
- package/dist/commands/reflog-walk.d.ts +72 -0
- package/dist/commands/reflog-walk.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +138 -29
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-transport.d.ts +7 -1
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/reset-command.d.ts +2 -3
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +2 -3
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-filter/commit-filter.d.ts +95 -0
- package/dist/commands/rev-filter/commit-filter.d.ts.map +1 -0
- package/dist/commands/rev-filter/commit-grep.d.ts +91 -0
- package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -0
- package/dist/commands/rev-filter/index.d.ts +3 -0
- package/dist/commands/rev-filter/index.d.ts.map +1 -0
- package/dist/commands/rev-list-command.d.ts +154 -2
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +32 -0
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +32 -1
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +15 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/rm-command.d.ts +70 -2
- package/dist/commands/rm-command.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +84 -4
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +2 -0
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +7 -0
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/show-command.d.ts +130 -0
- package/dist/commands/show-command.d.ts.map +1 -0
- package/dist/commands/show-commit.d.ts +11 -0
- package/dist/commands/show-commit.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +164 -0
- package/dist/commands/signature-check.d.ts.map +1 -0
- package/dist/commands/signing.d.ts +160 -0
- package/dist/commands/signing.d.ts.map +1 -0
- package/dist/commands/sparse-checkout-command.d.ts.map +1 -1
- package/dist/commands/sparse-index-view.d.ts +45 -0
- package/dist/commands/sparse-index-view.d.ts.map +1 -0
- package/dist/commands/ssh-signer.d.ts +29 -0
- package/dist/commands/ssh-signer.d.ts.map +1 -0
- package/dist/commands/ssh-verifier.d.ts +42 -0
- package/dist/commands/ssh-verifier.d.ts.map +1 -0
- package/dist/commands/stash-apply-command.d.ts +5 -0
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-branch-command.d.ts +34 -0
- package/dist/commands/stash-branch-command.d.ts.map +1 -0
- package/dist/commands/stash-create-command.d.ts +17 -0
- package/dist/commands/stash-create-command.d.ts.map +1 -1
- package/dist/commands/stash-info.d.ts +93 -0
- package/dist/commands/stash-info.d.ts.map +1 -0
- package/dist/commands/stash-list-command.d.ts +16 -0
- package/dist/commands/stash-list-command.d.ts.map +1 -1
- package/dist/commands/stash-pop-command.d.ts +39 -0
- package/dist/commands/stash-pop-command.d.ts.map +1 -0
- package/dist/commands/stash-show-command.d.ts +48 -0
- package/dist/commands/stash-show-command.d.ts.map +1 -0
- package/dist/commands/stash-store-command.d.ts +29 -0
- package/dist/commands/stash-store-command.d.ts.map +1 -0
- package/dist/commands/stash-working-tree.d.ts.map +1 -1
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/status-header.d.ts +5 -0
- package/dist/commands/status-header.d.ts.map +1 -1
- package/dist/commands/submodule-add-command.d.ts +89 -0
- package/dist/commands/submodule-add-command.d.ts.map +1 -0
- package/dist/commands/submodule-auth.d.ts +90 -0
- package/dist/commands/submodule-auth.d.ts.map +1 -0
- package/dist/commands/submodule-commands.d.ts +375 -0
- package/dist/commands/submodule-commands.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +288 -0
- package/dist/commands/submodule-model.d.ts.map +1 -0
- package/dist/commands/submodule-update-command.d.ts +198 -0
- package/dist/commands/submodule-update-command.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts.map +1 -1
- package/dist/commands/tag-command.d.ts +259 -10
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/trailers.d.ts +218 -17
- package/dist/commands/trailers.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts +7 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/verify-command.d.ts +92 -0
- package/dist/commands/verify-command.d.ts.map +1 -0
- package/dist/commands/worktree-add-command.d.ts +79 -7
- package/dist/commands/worktree-add-command.d.ts.map +1 -1
- package/dist/commands/worktree-path-rules.d.ts +66 -0
- package/dist/commands/worktree-path-rules.d.ts.map +1 -0
- package/dist/commands/worktree-remove-command.d.ts +10 -3
- package/dist/commands/worktree-remove-command.d.ts.map +1 -1
- package/dist/commands/worktree-repair-command.d.ts +15 -2
- package/dist/commands/worktree-repair-command.d.ts.map +1 -1
- package/dist/commands/worktree-support.d.ts +5 -0
- package/dist/commands/worktree-support.d.ts.map +1 -1
- package/dist/{commands-DIJ91NnD.js → commands-ISM52N0n.js} +70736 -54492
- package/dist/errors/checkout-errors.d.ts +19 -0
- package/dist/errors/checkout-errors.d.ts.map +1 -1
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +57 -3
- package/dist/errors/ref-errors.d.ts +19 -0
- package/dist/errors/ref-errors.d.ts.map +1 -1
- package/dist/errors/worktree-errors.d.ts +6 -1
- package/dist/errors/worktree-errors.d.ts.map +1 -1
- package/dist/{git-command-BGiOJ8Zk.js → fsck-DLRpbwTj.js} +6230 -71
- package/dist/git-command.d.ts +27 -1
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +267 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/remote-config/index.d.ts +1 -1
- package/dist/remote-config/index.d.ts.map +1 -1
- package/dist/remote-config/remote-config-store.d.ts +55 -0
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/results/combined-diff.d.ts +3 -0
- package/dist/results/combined-diff.d.ts.map +1 -1
- package/dist/results/diff-check.d.ts +38 -0
- package/dist/results/diff-check.d.ts.map +1 -0
- package/dist/results/diff-color.d.ts +135 -0
- package/dist/results/diff-color.d.ts.map +1 -0
- package/dist/results/diff-output.d.ts +85 -1
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/diff-pickaxe.d.ts +67 -0
- package/dist/results/diff-pickaxe.d.ts.map +1 -0
- package/dist/results/diff-words.d.ts +55 -0
- package/dist/results/diff-words.d.ts.map +1 -0
- package/dist/results/index.d.ts +4 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/push-result.d.ts +7 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +2 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +6 -0
- package/dist/results/stash-result.d.ts.map +1 -1
- package/dist/{results-WVlBhVb1.js → results-TB2IJ64h.js} +2168 -403
- package/dist/whitespace/index.d.ts +2 -0
- package/dist/whitespace/index.d.ts.map +1 -0
- package/dist/whitespace/whitespace-rule.d.ts +94 -0
- package/dist/whitespace/whitespace-rule.d.ts.map +1 -0
- package/package.json +12 -12
- package/src/commands/add-command.ts +178 -17
- package/src/commands/am/am-command.ts +262 -42
- package/src/commands/am/index.ts +1 -0
- package/src/commands/am/mailsplit.ts +326 -0
- package/src/commands/apply/apply-command.ts +6 -6
- package/src/commands/apply/apply-engine.ts +1 -1
- package/src/commands/apply/apply-parse.ts +7 -8
- package/src/commands/bisect/bisect-command.ts +18 -5
- package/src/commands/branch-command.ts +528 -53
- package/src/commands/branch-info-command.ts +150 -0
- package/src/commands/branch-tracking.ts +335 -60
- package/src/commands/branch-upstream-command.ts +218 -0
- package/src/commands/checkout-command.ts +69 -43
- package/src/commands/cherry-pick-command.ts +143 -0
- package/src/commands/clean-command.ts +34 -3
- package/src/commands/clone-command.ts +2 -1
- package/src/commands/commit-command.ts +782 -64
- package/src/commands/commit-reuse.ts +94 -0
- package/src/commands/config-command.ts +1256 -0
- package/src/commands/config-value-types.ts +358 -0
- package/src/commands/core-config.ts +40 -0
- package/src/commands/diff-color-config.ts +274 -0
- package/src/commands/diff-command.ts +1009 -49
- package/src/commands/fetch-command.ts +142 -8
- package/src/commands/fmt-merge-msg-command.ts +715 -0
- package/src/commands/fork-point.ts +63 -0
- package/src/commands/format-patch-command.ts +314 -46
- package/src/commands/fsck/fetch-fsck.ts +172 -18
- package/src/commands/gc-command.ts +31 -1
- package/src/commands/git-describe.ts +31 -11
- package/src/commands/git-hooks.ts +81 -0
- package/src/commands/grep/grep-command.ts +1077 -0
- package/src/commands/grep/grep-engine.ts +1024 -0
- package/src/commands/grep/index.ts +2 -0
- package/src/commands/index-adder.ts +46 -7
- package/src/commands/index.ts +26 -0
- package/src/commands/interpret-trailers-command.ts +256 -0
- package/src/commands/local-transport.ts +109 -10
- package/src/commands/log-command.ts +1246 -210
- package/src/commands/log-graph.ts +123 -26
- package/src/commands/log-output.ts +280 -21
- package/src/commands/ls-remote-command.ts +5 -0
- package/src/commands/mailmap.ts +119 -0
- package/src/commands/merge-base-command.ts +170 -0
- package/src/commands/merge-bases.ts +63 -8
- package/src/commands/merge-command.ts +330 -82
- package/src/commands/merge-support.ts +14 -1
- package/src/commands/mv-command.ts +6 -3
- package/src/commands/name-rev.ts +171 -0
- package/src/commands/notes-command.ts +11 -1
- package/src/commands/pathspec-file.ts +72 -0
- package/src/commands/pathspec.ts +14 -2
- package/src/commands/pretty-format.ts +103 -19
- package/src/commands/promisor-remote.ts +10 -1
- package/src/commands/pull-command.ts +26 -7
- package/src/commands/push-command.ts +682 -65
- package/src/commands/read-tree-command.ts +28 -1
- package/src/commands/rebase-command.ts +933 -129
- package/src/commands/ref-filter/for-each-ref-command.ts +298 -0
- package/src/commands/ref-filter/index.ts +7 -0
- package/src/commands/ref-filter/ref-atoms.ts +581 -0
- package/src/commands/ref-filter/ref-filter.ts +651 -0
- package/src/commands/ref-filter/ref-format.ts +1070 -0
- package/src/commands/ref-filter/ref-listing-command.ts +421 -0
- package/src/commands/ref-filter/ref-quote.ts +69 -0
- package/src/commands/ref-filter/version-compare.ts +177 -0
- package/src/commands/reflog-command.ts +492 -2
- package/src/commands/reflog-walk.ts +234 -0
- package/src/commands/remote-command.ts +449 -69
- package/src/commands/remote-transport.ts +9 -1
- package/src/commands/reset-command.ts +36 -31
- package/src/commands/restore-command.ts +12 -41
- package/src/commands/rev-filter/commit-filter.ts +159 -0
- package/src/commands/rev-filter/commit-grep.ts +444 -0
- package/src/commands/rev-filter/index.ts +2 -0
- package/src/commands/rev-list-command.ts +402 -15
- package/src/commands/revert-command.ts +82 -0
- package/src/commands/revision-range.ts +204 -4
- package/src/commands/revision-resolver.ts +23 -8
- package/src/commands/rm-command.ts +282 -21
- package/src/commands/sequencer-pick.ts +498 -85
- package/src/commands/sequencer-support.ts +20 -2
- package/src/commands/serve-repository.ts +18 -3
- package/src/commands/show-command.ts +490 -0
- package/src/commands/show-commit.ts +24 -0
- package/src/commands/signature-check.ts +657 -0
- package/src/commands/signing.ts +385 -0
- package/src/commands/sparse-checkout-command.ts +2 -9
- package/src/commands/sparse-checkout-support.ts +2 -2
- package/src/commands/sparse-index-view.ts +135 -0
- package/src/commands/ssh-signer.ts +199 -0
- package/src/commands/ssh-verifier.ts +523 -0
- package/src/commands/stash-apply-command.ts +16 -4
- package/src/commands/stash-branch-command.ts +88 -0
- package/src/commands/stash-create-command.ts +28 -0
- package/src/commands/stash-info.ts +243 -0
- package/src/commands/stash-list-command.ts +33 -0
- package/src/commands/stash-pop-command.ts +83 -0
- package/src/commands/stash-show-command.ts +141 -0
- package/src/commands/stash-store-command.ts +82 -0
- package/src/commands/stash-working-tree.ts +2 -2
- package/src/commands/status-command.ts +5 -2
- package/src/commands/status-header.ts +41 -7
- package/src/commands/submodule-add-command.ts +509 -0
- package/src/commands/submodule-auth.ts +276 -0
- package/src/commands/submodule-commands.ts +1517 -0
- package/src/commands/submodule-model.ts +930 -0
- package/src/commands/submodule-update-command.ts +1092 -0
- package/src/commands/switch-command.ts +3 -1
- package/src/commands/tag-command.ts +876 -64
- package/src/commands/trailers.ts +837 -100
- package/src/commands/tree-restore.ts +38 -10
- package/src/commands/verify-command.ts +235 -0
- package/src/commands/worktree-add-command.ts +268 -24
- package/src/commands/worktree-path-rules.ts +183 -0
- package/src/commands/worktree-remove-command.ts +39 -5
- package/src/commands/worktree-repair-command.ts +52 -5
- package/src/commands/worktree-support.ts +22 -1
- package/src/errors/checkout-errors.ts +29 -0
- package/src/errors/command-errors.ts +2 -1
- package/src/errors/ref-errors.ts +23 -0
- package/src/errors/worktree-errors.ts +8 -1
- package/src/git-command.ts +66 -1
- package/src/git.ts +404 -1
- package/src/remote-config/index.ts +2 -0
- package/src/remote-config/remote-config-store.ts +101 -0
- package/src/results/combined-diff.ts +38 -18
- package/src/results/diff-check.ts +185 -0
- package/src/results/diff-color.ts +868 -0
- package/src/results/diff-output.ts +195 -30
- package/src/results/diff-pickaxe.ts +304 -0
- package/src/results/diff-words.ts +395 -0
- package/src/results/index.ts +4 -0
- package/src/results/push-result.ts +7 -0
- package/src/results/rebase-result.ts +3 -0
- package/src/results/stash-result.ts +7 -0
- package/src/whitespace/index.ts +1 -0
- package/src/{commands/apply/whitespace.ts → whitespace/whitespace-rule.ts} +173 -23
- package/dist/commands/apply/whitespace.d.ts +0 -58
- package/dist/commands/apply/whitespace.d.ts.map +0 -1
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
FileMode,
|
|
9
9
|
isValidWorktreePath,
|
|
10
10
|
type ObjectId,
|
|
11
|
+
type WorktreePathOptions,
|
|
11
12
|
} from "@statewalker/vcs-core";
|
|
12
13
|
import { compareGitPaths, foldAsciiCase } from "@statewalker/vcs-utils/encoding";
|
|
13
14
|
import {
|
|
@@ -30,6 +31,7 @@ import {
|
|
|
30
31
|
wholeSeconds,
|
|
31
32
|
} from "@statewalker/vcs-working-tree";
|
|
32
33
|
import { storeWorktreeFile } from "../core-commands/index.js";
|
|
34
|
+
import { strerror } from "./strerror.js";
|
|
33
35
|
|
|
34
36
|
const SURROGATE = /[\ud800-\udfff]/;
|
|
35
37
|
|
|
@@ -58,6 +60,19 @@ export interface AddToIndexOptions {
|
|
|
58
60
|
indexed?: StagingEntry;
|
|
59
61
|
}
|
|
60
62
|
|
|
63
|
+
/**
|
|
64
|
+
* A file `index_path` cannot open (an errno such as EACCES): git's `error_errno` of its
|
|
65
|
+
* `open`, then add_to_index's "unable to index file" line. Anything else is rethrown.
|
|
66
|
+
*/
|
|
67
|
+
function unreadable(path: string, error: unknown): never {
|
|
68
|
+
const code = (error as { code?: unknown })?.code;
|
|
69
|
+
if (typeof code !== "string" || !/^E[A-Z]+$/.test(code) || code === "ENOENT") throw error;
|
|
70
|
+
throw new AddToIndexError(path, [
|
|
71
|
+
`error: open("${path}"): ${strerror(error)}`,
|
|
72
|
+
`error: unable to index file '${path}'`,
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
|
|
61
76
|
/** A path `add_to_index` cannot add: git's error lines (`fatal: adding files failed` follows). */
|
|
62
77
|
export class AddToIndexError extends Error {
|
|
63
78
|
constructor(
|
|
@@ -184,13 +199,29 @@ export async function chmodIndexEntries(
|
|
|
184
199
|
staging: Staging,
|
|
185
200
|
flip: "+" | "-",
|
|
186
201
|
matches: (entry: StagingEntry) => boolean,
|
|
187
|
-
|
|
202
|
+
/**
|
|
203
|
+
* `includeSkipWorktree`: skip-worktree entries too (`git add --sparse --chmod`);
|
|
204
|
+
* `collapsed`: sparse directories git holds as one entry each (`out/`), refused as any
|
|
205
|
+
* entry that is no regular file when matched
|
|
206
|
+
*/
|
|
207
|
+
options: { pretend?: boolean; includeSkipWorktree?: boolean; collapsed?: readonly string[] } = {},
|
|
188
208
|
): Promise<string[]> {
|
|
189
209
|
const errors: string[] = [];
|
|
190
210
|
const editor = staging.createEditor();
|
|
191
211
|
const touched: string[] = [];
|
|
212
|
+
const collapsed = options.collapsed ?? [];
|
|
213
|
+
let lastDir: string | undefined;
|
|
192
214
|
for await (const entry of staging.entries()) {
|
|
193
|
-
|
|
215
|
+
const dir = collapsed.find((d) => entry.path.startsWith(d));
|
|
216
|
+
if (dir) {
|
|
217
|
+
if (dir !== lastDir) {
|
|
218
|
+
lastDir = dir;
|
|
219
|
+
const dirEntry: StagingEntry = { ...entry, path: dir, mode: FileMode.TREE };
|
|
220
|
+
if (matches(dirEntry)) errors.push(`error: cannot chmod ${flip}x '${dir}'`);
|
|
221
|
+
}
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if ((entry.skipWorktree && !options.includeSkipWorktree) || !matches(entry)) continue;
|
|
194
225
|
if ((entry.mode & 0o170000) !== 0o100000) {
|
|
195
226
|
errors.push(`error: cannot chmod ${flip}x '${entry.path}'`);
|
|
196
227
|
continue;
|
|
@@ -261,6 +292,8 @@ export class IndexAdder {
|
|
|
261
292
|
private readonly trust: WorktreeModeTrust,
|
|
262
293
|
/** git's `ADD_CACHE_PRETEND` (`add --dry-run`): nothing is written or edited */
|
|
263
294
|
private readonly pretend: boolean,
|
|
295
|
+
/** `verify_path`'s rules (`core.protectNTFS`, `core.protectHFS`; default both on) */
|
|
296
|
+
private readonly pathRules: WorktreePathOptions = {},
|
|
264
297
|
) {
|
|
265
298
|
this.editor = staging.createEditor();
|
|
266
299
|
this.indexTime = staging.getUpdateTime();
|
|
@@ -274,9 +307,15 @@ export class IndexAdder {
|
|
|
274
307
|
staging: Staging,
|
|
275
308
|
blobs: Blobs,
|
|
276
309
|
trust: WorktreeModeTrust,
|
|
277
|
-
options: { pretend?: boolean } = {},
|
|
310
|
+
options: { pretend?: boolean; pathRules?: WorktreePathOptions } = {},
|
|
278
311
|
): Promise<IndexAdder> {
|
|
279
|
-
const adder = new IndexAdder(
|
|
312
|
+
const adder = new IndexAdder(
|
|
313
|
+
staging,
|
|
314
|
+
blobs,
|
|
315
|
+
trust,
|
|
316
|
+
options.pretend === true,
|
|
317
|
+
options.pathRules,
|
|
318
|
+
);
|
|
280
319
|
const take = (entry: StagingEntry) => {
|
|
281
320
|
if (entry.stage === 0) {
|
|
282
321
|
adder.basePaths.push(entry.path);
|
|
@@ -396,7 +435,7 @@ export class IndexAdder {
|
|
|
396
435
|
// add_index_entry's verify_path (after the file is hashed; never with ADD_CACHE_PRETEND)
|
|
397
436
|
if (!this.pretend) {
|
|
398
437
|
const mode = modeFromWorktree(entry.mode, indexed?.mode, this.trust);
|
|
399
|
-
if (!isValidWorktreePath(name, mode)) {
|
|
438
|
+
if (!isValidWorktreePath(name, mode, this.pathRules)) {
|
|
400
439
|
const shown = options.displayPath ?? path;
|
|
401
440
|
throw new AddToIndexError(path, [
|
|
402
441
|
`error: invalid path '${shown}'`,
|
|
@@ -437,7 +476,7 @@ export class IndexAdder {
|
|
|
437
476
|
const known = indexed ?? this.unmerged.get(name)?.[0];
|
|
438
477
|
if (this.pretend) {
|
|
439
478
|
// git's ADD_CACHE_PRETEND: hashed, never written
|
|
440
|
-
const id = await worktree.computeHash(path);
|
|
479
|
+
const id = await worktree.computeHash(path).catch((error) => unreadable(path, error));
|
|
441
480
|
const mode = modeFromWorktree(entry.mode, known?.mode, this.trust);
|
|
442
481
|
return indexed && indexed.objectId === id && indexed.mode === mode ? "same" : "added";
|
|
443
482
|
}
|
|
@@ -445,7 +484,7 @@ export class IndexAdder {
|
|
|
445
484
|
const stored = await storeWorktreeFile(this.blobs, worktree, path, entry, {
|
|
446
485
|
onWarning: options.onWarning,
|
|
447
486
|
...(options.renormalize ? { renormalize: true } : {}),
|
|
448
|
-
});
|
|
487
|
+
}).catch((error) => unreadable(path, error));
|
|
449
488
|
const mode = modeFromWorktree(stored.entry.mode, known?.mode, this.trust);
|
|
450
489
|
this.stage(name, stored.id, mode, entryStatOf(stored.entry));
|
|
451
490
|
return indexed && indexed.objectId === stored.id && indexed.mode === mode ? "same" : "added";
|
package/src/commands/index.ts
CHANGED
|
@@ -6,7 +6,9 @@ export * from "./backfill-command.js";
|
|
|
6
6
|
export * from "./bisect/index.js";
|
|
7
7
|
export * from "./blame-command.js";
|
|
8
8
|
export * from "./branch-command.js";
|
|
9
|
+
export * from "./branch-info-command.js";
|
|
9
10
|
export { TrackMode } from "./branch-tracking.js";
|
|
11
|
+
export * from "./branch-upstream-command.js";
|
|
10
12
|
export * from "./checkout-command.js";
|
|
11
13
|
export * from "./checkout-paths.js";
|
|
12
14
|
export * from "./cherry-pick-command.js";
|
|
@@ -14,18 +16,22 @@ export * from "./clean-command.js";
|
|
|
14
16
|
export * from "./clone-command.js";
|
|
15
17
|
export * from "./comment-char-config.js";
|
|
16
18
|
export * from "./commit-command.js";
|
|
19
|
+
export * from "./config-command.js";
|
|
17
20
|
export * from "./date-format.js";
|
|
18
21
|
export * from "./default-branch.js";
|
|
19
22
|
export * from "./describe-command.js";
|
|
23
|
+
export * from "./diff-color-config.js";
|
|
20
24
|
export * from "./diff-command.js";
|
|
21
25
|
export * from "./diff-textconv.js";
|
|
22
26
|
export * from "./fetch-command.js";
|
|
27
|
+
export * from "./fmt-merge-msg-command.js";
|
|
23
28
|
export * from "./format-patch-command.js";
|
|
24
29
|
export * from "./fsck/index.js";
|
|
25
30
|
export * from "./gc-command.js";
|
|
26
31
|
export * from "./git-describe.js";
|
|
27
32
|
export * from "./git-hooks.js";
|
|
28
33
|
export * from "./git-ident.js";
|
|
34
|
+
export * from "./grep/index.js";
|
|
29
35
|
export * from "./hook-command.js";
|
|
30
36
|
export {
|
|
31
37
|
IndexVersionConfigError,
|
|
@@ -34,12 +40,14 @@ export {
|
|
|
34
40
|
takeIndexWarnings,
|
|
35
41
|
} from "./index-host.js";
|
|
36
42
|
export * from "./init-command.js";
|
|
43
|
+
export * from "./interpret-trailers-command.js";
|
|
37
44
|
export { httpBackendEnv, quarantineEnv, remoteHookSession } from "./local-transport.js";
|
|
38
45
|
export * from "./log-command.js";
|
|
39
46
|
export * from "./log-graph.js";
|
|
40
47
|
export * from "./log-output.js";
|
|
41
48
|
export * from "./ls-remote-command.js";
|
|
42
49
|
export * from "./mailmap.js";
|
|
50
|
+
export * from "./merge-base-command.js";
|
|
43
51
|
export * from "./merge-command.js";
|
|
44
52
|
export {
|
|
45
53
|
createMergeDriver,
|
|
@@ -73,6 +81,7 @@ export * from "./push-command.js";
|
|
|
73
81
|
export * from "./read-tree-command.js";
|
|
74
82
|
export * from "./rebase-command.js";
|
|
75
83
|
export * from "./ref-decoration-filter.js";
|
|
84
|
+
export * from "./ref-filter/index.js";
|
|
76
85
|
export * from "./reflog-command.js";
|
|
77
86
|
export {
|
|
78
87
|
committerIdent,
|
|
@@ -82,6 +91,7 @@ export {
|
|
|
82
91
|
export * from "./remote-command.js";
|
|
83
92
|
export * from "./reset-command.js";
|
|
84
93
|
export * from "./restore-command.js";
|
|
94
|
+
export * from "./rev-filter/index.js";
|
|
85
95
|
export * from "./rev-list-command.js";
|
|
86
96
|
export * from "./rev-parse-command.js";
|
|
87
97
|
export * from "./revert-command.js";
|
|
@@ -91,19 +101,35 @@ export * from "./revision-resolver.js";
|
|
|
91
101
|
export * from "./rm-command.js";
|
|
92
102
|
export { SequencerOperation } from "./sequencer-pick.js";
|
|
93
103
|
export * from "./serve-repository.js";
|
|
104
|
+
export * from "./show-command.js";
|
|
105
|
+
export * from "./signature-check.js";
|
|
106
|
+
export * from "./signing.js";
|
|
94
107
|
export * from "./sparse-checkout-command.js";
|
|
108
|
+
export * from "./ssh-signer.js";
|
|
109
|
+
export * from "./ssh-verifier.js";
|
|
95
110
|
export * from "./stash-apply-command.js";
|
|
111
|
+
export * from "./stash-branch-command.js";
|
|
96
112
|
export * from "./stash-create-command.js";
|
|
97
113
|
export * from "./stash-drop-command.js";
|
|
114
|
+
export * from "./stash-info.js";
|
|
98
115
|
export * from "./stash-list-command.js";
|
|
116
|
+
export * from "./stash-pop-command.js";
|
|
117
|
+
export * from "./stash-show-command.js";
|
|
118
|
+
export * from "./stash-store-command.js";
|
|
99
119
|
export * from "./stash-working-tree.js";
|
|
100
120
|
export * from "./status-command.js";
|
|
101
121
|
export * from "./status-format.js";
|
|
122
|
+
export * from "./submodule-add-command.js";
|
|
123
|
+
export * from "./submodule-auth.js";
|
|
124
|
+
export * from "./submodule-commands.js";
|
|
125
|
+
export * from "./submodule-model.js";
|
|
102
126
|
export * from "./submodule-summary.js";
|
|
103
127
|
export * from "./submodule-summary-command.js";
|
|
128
|
+
export * from "./submodule-update-command.js";
|
|
104
129
|
export * from "./switch-command.js";
|
|
105
130
|
export * from "./tag-command.js";
|
|
106
131
|
export * from "./trailers.js";
|
|
132
|
+
export * from "./verify-command.js";
|
|
107
133
|
export * from "./worktree-add-command.js";
|
|
108
134
|
export * from "./worktree-list-command.js";
|
|
109
135
|
export * from "./worktree-lock-command.js";
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `git interpret-trailers` (builtin/interpret-trailers.c) as a library command.
|
|
3
|
+
*
|
|
4
|
+
* ```typescript
|
|
5
|
+
* const { stdout } = await git
|
|
6
|
+
* .interpretTrailers()
|
|
7
|
+
* .setInput("Fix the parser\n")
|
|
8
|
+
* .addTrailer("Reviewed-by: R <r@example.com>")
|
|
9
|
+
* .setWhere("start")
|
|
10
|
+
* .addTrailer("Bug: 42")
|
|
11
|
+
* .call();
|
|
12
|
+
* // "Fix the parser\n\nBug: 42\nReviewed-by: R <r@example.com>\n"
|
|
13
|
+
*
|
|
14
|
+
* const parsed = await git.interpretTrailers().setInput(message).setParse(true).call();
|
|
15
|
+
* parsed.stdout; // the trailers alone, unfolded
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { GitApiError } from "../errors/index.js";
|
|
20
|
+
import { GitCommand } from "../git-command.js";
|
|
21
|
+
import {
|
|
22
|
+
type NewTrailer,
|
|
23
|
+
processTrailers,
|
|
24
|
+
type TrailerCommandRunner,
|
|
25
|
+
type TrailerIfExists,
|
|
26
|
+
type TrailerIfMissing,
|
|
27
|
+
type TrailerWhere,
|
|
28
|
+
trailerConfigOf,
|
|
29
|
+
} from "./trailers.js";
|
|
30
|
+
|
|
31
|
+
/** What {@link InterpretTrailersCommand} gave. */
|
|
32
|
+
export interface InterpretTrailersCommandResult {
|
|
33
|
+
/** git's stdout: each input with its trailers (nothing for files edited in place) */
|
|
34
|
+
stdout: string;
|
|
35
|
+
/**
|
|
36
|
+
* git's stderr: the configuration's warnings, `error:` lines (an empty trailer token, a
|
|
37
|
+
* failed trailer command) and what the trailer commands wrote there
|
|
38
|
+
*/
|
|
39
|
+
stderr: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const encoder = new TextEncoder();
|
|
43
|
+
const decoder = new TextDecoder();
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Add or parse the trailers of messages, as `git interpret-trailers [--in-place]
|
|
47
|
+
* [--trim-empty] [(--trailer <key>[(=|:)<value>])...] [--parse] [<file>...]`.
|
|
48
|
+
*
|
|
49
|
+
* The input is {@link setInput} (git's stdin) or the files added with {@link addFile} (paths
|
|
50
|
+
* from the worktree top, through the repository's FilesApi), each completed with a line end.
|
|
51
|
+
* The `trailer.*` configuration applies (`trailer.<key>.key`, `.where`, `.ifexists`,
|
|
52
|
+
* `.ifmissing`, `.cmd`, `.command`, `trailer.separators`, the defaults); `--where`,
|
|
53
|
+
* `--if-exists` and `--if-missing` apply to the trailers added after them, as on git's
|
|
54
|
+
* command line ({@link setWhere} with undefined is `--no-where`). Trailer commands run through
|
|
55
|
+
* the host environment's hook runner (`sh -c`, in the worktree top, without the variables
|
|
56
|
+
* naming the repository); without a runner none runs: a trailer keeps the value given and
|
|
57
|
+
* `trailer.<key>.command` adds no trailer of its own.
|
|
58
|
+
*/
|
|
59
|
+
export class InterpretTrailersCommand extends GitCommand<InterpretTrailersCommandResult> {
|
|
60
|
+
private input = "";
|
|
61
|
+
private files: string[] = [];
|
|
62
|
+
private inPlace = false;
|
|
63
|
+
private trimEmpty = false;
|
|
64
|
+
private onlyTrailers = false;
|
|
65
|
+
private onlyInput = false;
|
|
66
|
+
private unfold = false;
|
|
67
|
+
private noDivider = false;
|
|
68
|
+
private where?: TrailerWhere;
|
|
69
|
+
private ifExists?: TrailerIfExists;
|
|
70
|
+
private ifMissing?: TrailerIfMissing;
|
|
71
|
+
private trailers: NewTrailer[] = [];
|
|
72
|
+
private compatibility?: "2.43" | "2.56";
|
|
73
|
+
|
|
74
|
+
/** The message to read when no file is given (git's stdin). */
|
|
75
|
+
setInput(input: string | Uint8Array): this {
|
|
76
|
+
this.checkCallable();
|
|
77
|
+
this.input = typeof input === "string" ? input : decoder.decode(input);
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** A file to read (`<file>`), from the worktree top; several are output one after another. */
|
|
82
|
+
addFile(path: string): this {
|
|
83
|
+
this.checkCallable();
|
|
84
|
+
this.files.push(path);
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** `--in-place`: write each file back instead of the output. */
|
|
89
|
+
setInPlace(inPlace: boolean): this {
|
|
90
|
+
this.checkCallable();
|
|
91
|
+
this.inPlace = inPlace;
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** `--trim-empty`: leave out trailers whose value is empty. */
|
|
96
|
+
setTrimEmpty(trim: boolean): this {
|
|
97
|
+
this.checkCallable();
|
|
98
|
+
this.trimEmpty = trim;
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** `--only-trailers`: output only the trailers. */
|
|
103
|
+
setOnlyTrailers(only: boolean): this {
|
|
104
|
+
this.checkCallable();
|
|
105
|
+
this.onlyTrailers = only;
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** `--only-input`: apply no `trailer.<key>.command` trailers. */
|
|
110
|
+
setOnlyInput(only: boolean): this {
|
|
111
|
+
this.checkCallable();
|
|
112
|
+
this.onlyInput = only;
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** `--unfold`: join continuation lines into one. */
|
|
117
|
+
setUnfold(unfold: boolean): this {
|
|
118
|
+
this.checkCallable();
|
|
119
|
+
this.unfold = unfold;
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** `--parse`: `--only-trailers --only-input --unfold` (true sets the three). */
|
|
124
|
+
setParse(parse: boolean): this {
|
|
125
|
+
this.checkCallable();
|
|
126
|
+
if (parse) {
|
|
127
|
+
this.onlyTrailers = true;
|
|
128
|
+
this.onlyInput = true;
|
|
129
|
+
this.unfold = true;
|
|
130
|
+
}
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** `--no-divider`: a `---` line does not end the message. */
|
|
135
|
+
setNoDivider(noDivider: boolean): this {
|
|
136
|
+
this.checkCallable();
|
|
137
|
+
this.noDivider = noDivider;
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** `--where <placement>` for the trailers added next; undefined is `--no-where`. */
|
|
142
|
+
setWhere(where: TrailerWhere | undefined): this {
|
|
143
|
+
this.checkCallable();
|
|
144
|
+
this.where = where;
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** `--if-exists <action>` for the trailers added next; undefined is `--no-if-exists`. */
|
|
149
|
+
setIfExists(action: TrailerIfExists | undefined): this {
|
|
150
|
+
this.checkCallable();
|
|
151
|
+
this.ifExists = action;
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** `--if-missing <action>` for the trailers added next; undefined is `--no-if-missing`. */
|
|
156
|
+
setIfMissing(action: TrailerIfMissing | undefined): this {
|
|
157
|
+
this.checkCallable();
|
|
158
|
+
this.ifMissing = action;
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** `--trailer <key>[(=|:)<value>]`, with the placement and actions set so far. */
|
|
163
|
+
addTrailer(text: string): this {
|
|
164
|
+
this.checkCallable();
|
|
165
|
+
this.trailers.push({
|
|
166
|
+
text,
|
|
167
|
+
...(this.where ? { where: this.where } : {}),
|
|
168
|
+
...(this.ifExists ? { ifExists: this.ifExists } : {}),
|
|
169
|
+
...(this.ifMissing ? { ifMissing: this.ifMissing } : {}),
|
|
170
|
+
});
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** `--no-trailer`: forget the trailers added so far. */
|
|
175
|
+
clearTrailers(): this {
|
|
176
|
+
this.checkCallable();
|
|
177
|
+
this.trailers = [];
|
|
178
|
+
return this;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** The git version to follow where versions differ (default: the hook runner's, else 2.56). */
|
|
182
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
183
|
+
this.checkCallable();
|
|
184
|
+
this.compatibility = version;
|
|
185
|
+
return this;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async call(): Promise<InterpretTrailersCommandResult> {
|
|
189
|
+
this.checkCallable();
|
|
190
|
+
this.setCallable(false);
|
|
191
|
+
const hooks = this.hooks;
|
|
192
|
+
const compatibility = this.compatibility ?? hooks.compatibility;
|
|
193
|
+
const config = { ...trailerConfigOf(this.workingCopy), compatibility };
|
|
194
|
+
let stderr = (config.warnings ?? []).map((w) => `${w}\n`).join("");
|
|
195
|
+
if (this.onlyInput && this.trailers.length > 0) {
|
|
196
|
+
throw new GitApiError("fatal: --trailer with --only-input does not make sense", {
|
|
197
|
+
exitCode: 129,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (this.files.length === 0 && this.inPlace) {
|
|
201
|
+
throw new GitApiError("fatal: no input file given for in-place editing", { exitCode: 128 });
|
|
202
|
+
}
|
|
203
|
+
const runCommand: TrailerCommandRunner | undefined = hooks.enabled
|
|
204
|
+
? (command) => hooks.runShellCommand("trailer", command.command, command.args)
|
|
205
|
+
: undefined;
|
|
206
|
+
const process = async (text: string) => {
|
|
207
|
+
// read_input_file: strbuf_complete_line (2.44+; 2.43 reads the input as it is)
|
|
208
|
+
const complete = compatibility !== "2.43" && text.length > 0 && !text.endsWith("\n");
|
|
209
|
+
const input = complete ? `${text}\n` : text;
|
|
210
|
+
const result = await processTrailers(
|
|
211
|
+
input,
|
|
212
|
+
{
|
|
213
|
+
trailers: this.trailers,
|
|
214
|
+
trimEmpty: this.trimEmpty,
|
|
215
|
+
onlyTrailers: this.onlyTrailers,
|
|
216
|
+
onlyInput: this.onlyInput,
|
|
217
|
+
unfold: this.unfold,
|
|
218
|
+
noDivider: this.noDivider,
|
|
219
|
+
...(runCommand ? { runCommand } : {}),
|
|
220
|
+
},
|
|
221
|
+
config,
|
|
222
|
+
);
|
|
223
|
+
stderr += result.errors;
|
|
224
|
+
return result.output;
|
|
225
|
+
};
|
|
226
|
+
if (this.files.length === 0) return { stdout: await process(this.input), stderr };
|
|
227
|
+
let stdout = "";
|
|
228
|
+
for (const name of this.files) {
|
|
229
|
+
const file = await hooks.fileAt(name);
|
|
230
|
+
const stats = file ? await file.files.stats(file.path) : undefined;
|
|
231
|
+
if (!file || stats?.kind !== "file") {
|
|
232
|
+
const reason = stats ? "Is a directory" : "No such file or directory";
|
|
233
|
+
throw new GitApiError(`fatal: could not read input file '${name}': ${reason}`, {
|
|
234
|
+
exitCode: 128,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
const chunks: Uint8Array[] = [];
|
|
238
|
+
for await (const chunk of file.files.read(file.path)) chunks.push(chunk);
|
|
239
|
+
const output = await process(decoder.decode(concat(chunks)));
|
|
240
|
+
if (this.inPlace) await file.files.write(file.path, [encoder.encode(output)]);
|
|
241
|
+
else stdout += output;
|
|
242
|
+
}
|
|
243
|
+
return { stdout, stderr };
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function concat(chunks: Uint8Array[]): Uint8Array {
|
|
248
|
+
if (chunks.length === 1) return chunks[0] as Uint8Array;
|
|
249
|
+
const out = new Uint8Array(chunks.reduce((n, c) => n + c.length, 0));
|
|
250
|
+
let at = 0;
|
|
251
|
+
for (const c of chunks) {
|
|
252
|
+
out.set(c, at);
|
|
253
|
+
at += c.length;
|
|
254
|
+
}
|
|
255
|
+
return out;
|
|
256
|
+
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { historyWithoutLazyFetch, type RefTransactionHook } from "@statewalker/vcs-core";
|
|
9
|
+
import { configFilesApiOf, readConfinedFile } from "@statewalker/vcs-store-files";
|
|
9
10
|
import {
|
|
10
11
|
createRepositoryFacade,
|
|
11
12
|
createTransportRefStore,
|
|
@@ -25,8 +26,9 @@ import {
|
|
|
25
26
|
type UploadPackConnection,
|
|
26
27
|
} from "@statewalker/vcs-transport";
|
|
27
28
|
import { parseGitBool, parseGitInt } from "@statewalker/vcs-utils/encoding";
|
|
28
|
-
import type
|
|
29
|
+
import { type FilesApi, readFile } from "@statewalker/vcs-utils/files";
|
|
29
30
|
import {
|
|
31
|
+
type GitHostEnvironment,
|
|
30
32
|
type LinkedWorktrees,
|
|
31
33
|
type OpenedRepository,
|
|
32
34
|
sparseFilterMatcher,
|
|
@@ -34,6 +36,7 @@ import {
|
|
|
34
36
|
} from "@statewalker/vcs-working-tree";
|
|
35
37
|
import { GitApiError, TransportError } from "../errors/index.js";
|
|
36
38
|
import { quoteCStyleBody } from "../results/index.js";
|
|
39
|
+
import { type ReceiveFsckSettings, receiveFsckOf } from "./fsck/index.js";
|
|
37
40
|
import {
|
|
38
41
|
HookSession,
|
|
39
42
|
hookHostOf,
|
|
@@ -217,6 +220,7 @@ const DEFAULT_SETTINGS: ServerConfigSettings = {
|
|
|
217
220
|
denyCurrentBranch: "unconfigured",
|
|
218
221
|
denyDeleteCurrent: "unconfigured",
|
|
219
222
|
shallowUpdate: false,
|
|
223
|
+
advertisePushOptions: false,
|
|
220
224
|
uploadPackHideRefs: [],
|
|
221
225
|
receivePackHideRefs: [],
|
|
222
226
|
};
|
|
@@ -340,8 +344,17 @@ export async function withLocalReceivePack<T>(
|
|
|
340
344
|
* output reaches the pushing user's stderr directly, not as "remote: " lines
|
|
341
345
|
*/
|
|
342
346
|
transactionHooks: HookSession | undefined = hooks,
|
|
343
|
-
/**
|
|
344
|
-
|
|
347
|
+
/**
|
|
348
|
+
* `protocol.version`: 1 has receive-pack answer `version 1` first (2 is v0 for a push);
|
|
349
|
+
* `host`: where receive-pack runs ({@link ReceivePackHost}); `onWarning`: receive-pack's own
|
|
350
|
+
* warnings as it reads its config (`warning: skipping unknown msg id '<id>'`), which git's
|
|
351
|
+
* local transport shows on the pushing user's stderr
|
|
352
|
+
*/
|
|
353
|
+
options: {
|
|
354
|
+
protocolVersion?: 0 | 1 | 2;
|
|
355
|
+
host?: ReceivePackHost;
|
|
356
|
+
onWarning?: (line: string) => void;
|
|
357
|
+
} = {},
|
|
345
358
|
): Promise<T> {
|
|
346
359
|
// receive-pack's enter_repo(path, 0): a repository another user owns is refused (git's
|
|
347
360
|
// die_upon_dubious_ownership in the child), and the client sees the connection fail
|
|
@@ -357,7 +370,7 @@ export async function withLocalReceivePack<T>(
|
|
|
357
370
|
// the remote's reference-transaction hook on its ref store while receive-pack runs (its
|
|
358
371
|
// output goes to the pushing user's stderr directly, not through the side-band)
|
|
359
372
|
return withReceiveTransactionHook(remote, transactionHooks, () =>
|
|
360
|
-
receiveOver(remote, run, hooks, receiveHooks, options.protocolVersion === 1),
|
|
373
|
+
receiveOver(remote, run, hooks, receiveHooks, options.protocolVersion === 1, options),
|
|
361
374
|
);
|
|
362
375
|
}
|
|
363
376
|
|
|
@@ -414,11 +427,83 @@ export async function withReceiveTransactionHook<T>(
|
|
|
414
427
|
}
|
|
415
428
|
}
|
|
416
429
|
|
|
430
|
+
/** Where receive-pack runs: what it reads besides the served repository. */
|
|
431
|
+
export interface ReceivePackHost {
|
|
432
|
+
/** The host environment (absolute and `~/` skip lists, `$HOME`) */
|
|
433
|
+
environment?: GitHostEnvironment;
|
|
434
|
+
/** Whose messages to give where git 2.43 and 2.5x differ (default 2.5x) */
|
|
435
|
+
compatibility?: "2.43" | "2.56";
|
|
436
|
+
/**
|
|
437
|
+
* The repository is someone else's (served): files its configuration names (a
|
|
438
|
+
* `receive.fsck.skipList`) are read only inside its own git directories, as confined
|
|
439
|
+
* includes (`configIncludes: "files"`), never from the host; a local push into one's own
|
|
440
|
+
* repository reads them as git does
|
|
441
|
+
*/
|
|
442
|
+
confineFiles?: boolean;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* receive-pack's `receive.fsckObjects` / `transfer.fsckObjects` settings of the repository it
|
|
447
|
+
* serves (`receiveFsckOf`): skip lists named by a relative path are read from its git
|
|
448
|
+
* directory (receive-pack's working directory), absolute ones from the host; with
|
|
449
|
+
* `confineFiles` (a served repository) only files inside its own git directories, where their
|
|
450
|
+
* links lead and capped as confined includes (`readConfinedFile`), anything else unreadable.
|
|
451
|
+
*/
|
|
452
|
+
export function receiveFsckSettingsOf(
|
|
453
|
+
remote: OpenedRepository,
|
|
454
|
+
host: ReceivePackHost = {},
|
|
455
|
+
): ReceiveFsckSettings {
|
|
456
|
+
const config = remote.config;
|
|
457
|
+
if (!config) return { warnings: [] };
|
|
458
|
+
const gitDir = remote.gitDir.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
459
|
+
const files = remote.files;
|
|
460
|
+
const environment = host.environment;
|
|
461
|
+
const listWithOrigin = config.listWithOrigin?.bind(config);
|
|
462
|
+
// receive-pack runs in the git directory: git names its files from there (`config`)
|
|
463
|
+
const entries = () =>
|
|
464
|
+
listWithOrigin
|
|
465
|
+
? listWithOrigin().map((e) =>
|
|
466
|
+
e.file?.replace(/^\/+/, "").startsWith(`${gitDir}/`)
|
|
467
|
+
? { ...e, file: e.file.replace(/^\/+/, "").slice(gitDir.length + 1) }
|
|
468
|
+
: e,
|
|
469
|
+
)
|
|
470
|
+
: config.list();
|
|
471
|
+
if (host.confineFiles) {
|
|
472
|
+
// a served repository's skip list: only its own files, where their links lead, capped
|
|
473
|
+
const roots = [gitDir];
|
|
474
|
+
const common = remote.commonDir?.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
475
|
+
if (common !== undefined && common !== gitDir) roots.push(common);
|
|
476
|
+
const confined = files ? configFilesApiOf(files) : undefined;
|
|
477
|
+
return receiveFsckOf({
|
|
478
|
+
entries,
|
|
479
|
+
compatibility: host.compatibility ?? "2.56",
|
|
480
|
+
readFile: async (path) =>
|
|
481
|
+
confined
|
|
482
|
+
? readConfinedFile(confined, path, { baseDir: gitDir, roots }).catch(() => undefined)
|
|
483
|
+
: undefined,
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
return receiveFsckOf({
|
|
487
|
+
entries,
|
|
488
|
+
compatibility: host.compatibility ?? "2.56",
|
|
489
|
+
...(environment?.home ? { home: environment.home } : {}),
|
|
490
|
+
readFile: async (path) => {
|
|
491
|
+
if (path.startsWith("/") && environment) return environment.readFile(path);
|
|
492
|
+
if (!files) return undefined;
|
|
493
|
+
const full = path.startsWith("/") ? path : `${gitDir}/${path}`;
|
|
494
|
+
// a missing file reads as no bytes in some FilesApis: ask first
|
|
495
|
+
if ((await files.stats(full).catch(() => undefined))?.kind !== "file") return undefined;
|
|
496
|
+
return readFile(files, full);
|
|
497
|
+
},
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
|
|
417
501
|
/**
|
|
418
502
|
* The settings git's receive-pack takes from the repository it serves: the policies and hidden
|
|
419
503
|
* refs of its config (`serverSettingsFromConfig`), its current branch and the branches its
|
|
420
|
-
* worktrees have checked out, `updateInstead` (push-to-checkout, push-to-deploy),
|
|
421
|
-
*
|
|
504
|
+
* worktrees have checked out, `updateInstead` (push-to-checkout, push-to-deploy), the fsck of
|
|
505
|
+
* pushed objects (`receive.fsckObjects`, {@link receiveFsckSettingsOf}) and, with hooks,
|
|
506
|
+
* pre-receive / update / post-receive run as git's receive-pack runs them.
|
|
422
507
|
*/
|
|
423
508
|
export async function receivePackSettingsOf(
|
|
424
509
|
remote: OpenedRepository,
|
|
@@ -426,9 +511,15 @@ export async function receivePackSettingsOf(
|
|
|
426
511
|
receiveHooks: ReceivePackHooks | undefined = hooks?.enabled
|
|
427
512
|
? scriptReceiveHooks(hooks)
|
|
428
513
|
: undefined,
|
|
514
|
+
host: ReceivePackHost = {},
|
|
429
515
|
): Promise<GitServeSettings> {
|
|
430
516
|
const head = await remote.history.refs.get("HEAD").catch(() => undefined);
|
|
431
517
|
const settings = serverSettingsOf(remote);
|
|
518
|
+
const fsck = receiveFsckSettingsOf(remote, {
|
|
519
|
+
compatibility: hooks?.compatibility,
|
|
520
|
+
...host,
|
|
521
|
+
});
|
|
522
|
+
const configError = settings.receivePackConfigError ?? fsck.configError;
|
|
432
523
|
const checkedOut = await checkedOutBranches(remote.worktrees);
|
|
433
524
|
const worktrees = remote.worktrees;
|
|
434
525
|
return {
|
|
@@ -439,6 +530,8 @@ export async function receivePackSettingsOf(
|
|
|
439
530
|
denyCurrentBranch: settings.denyCurrentBranch,
|
|
440
531
|
denyDeleteCurrent: settings.denyDeleteCurrent,
|
|
441
532
|
shallowUpdate: settings.shallowUpdate,
|
|
533
|
+
// receive.advertisePushOptions (git's default false)
|
|
534
|
+
advertisePushOptions: settings.advertisePushOptions,
|
|
442
535
|
uploadPackHideRefs: settings.uploadPackHideRefs,
|
|
443
536
|
receivePackHideRefs: settings.receivePackHideRefs,
|
|
444
537
|
...(receiveHooks ? { hooks: receiveHooks, relayPostReceive: true } : {}),
|
|
@@ -448,9 +541,9 @@ export async function receivePackSettingsOf(
|
|
|
448
541
|
preReceiveSeesRefused: true,
|
|
449
542
|
// receive.procReceiveRefs: the commands the proc-receive hook takes
|
|
450
543
|
...(settings.procReceiveRefs?.length ? { procReceiveRefs: settings.procReceiveRefs } : {}),
|
|
451
|
-
...(
|
|
452
|
-
|
|
453
|
-
|
|
544
|
+
...(configError !== undefined ? { receivePackConfigError: configError } : {}),
|
|
545
|
+
// receive.fsckObjects: unpack-objects / index-pack --strict
|
|
546
|
+
...(fsck.fsckObjects ? { fsckObjects: fsck.fsckObjects } : {}),
|
|
454
547
|
// git 2.5x updates the refs of a push that is not atomic in two batches
|
|
455
548
|
...(hooks?.enabled && hooks.compatibility !== "2.43" ? { batchNonAtomic: true } : {}),
|
|
456
549
|
// ... git 2.43 updates each ref after its update hook
|
|
@@ -473,9 +566,15 @@ async function receiveOver<T>(
|
|
|
473
566
|
hooks: HookSession | undefined,
|
|
474
567
|
receiveHooks: ReceivePackHooks | undefined,
|
|
475
568
|
version1: boolean,
|
|
569
|
+
options: { host?: ReceivePackHost; onWarning?: (line: string) => void } = {},
|
|
476
570
|
): Promise<T> {
|
|
477
571
|
const [client, server] = createDuplexPair();
|
|
478
|
-
const
|
|
572
|
+
const host = options.host ?? {};
|
|
573
|
+
const settings = await receivePackSettingsOf(remote, hooks, receiveHooks, host);
|
|
574
|
+
// receive-pack's warnings as it reads its config, on the shared stderr
|
|
575
|
+
if (options.onWarning) {
|
|
576
|
+
for (const line of receiveFsckSettingsOf(remote, host).warnings) options.onWarning(line);
|
|
577
|
+
}
|
|
479
578
|
const serving = serveOverDuplex({
|
|
480
579
|
...settings,
|
|
481
580
|
duplex: server,
|