@statewalker/vcs-commands 0.8.0 → 0.10.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/README.md +1 -1
- package/dist/commands/add-command.d.ts +32 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/add-patch.d.ts +7 -0
- package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts +2 -0
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-modes.d.ts +6 -2
- package/dist/commands/add-patch/patch-modes.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-session.d.ts +4 -0
- package/dist/commands/add-patch/patch-session.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +88 -2
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-command.d.ts +2 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.d.ts +7 -0
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/apply/index.d.ts +1 -1
- package/dist/commands/apply/index.d.ts.map +1 -1
- package/dist/commands/archive/archive-command.d.ts +169 -0
- package/dist/commands/archive/archive-command.d.ts.map +1 -0
- package/dist/commands/archive/archive-entry.d.ts +60 -0
- package/dist/commands/archive/archive-entry.d.ts.map +1 -0
- package/dist/commands/archive/index.d.ts +8 -0
- package/dist/commands/archive/index.d.ts.map +1 -0
- package/dist/commands/archive/remote-archive-command.d.ts +56 -0
- package/dist/commands/archive/remote-archive-command.d.ts.map +1 -0
- package/dist/commands/archive/tar-archive.d.ts +31 -0
- package/dist/commands/archive/tar-archive.d.ts.map +1 -0
- package/dist/commands/archive/tar-commit-id.d.ts +13 -0
- package/dist/commands/archive/tar-commit-id.d.ts.map +1 -0
- package/dist/commands/archive/upload-archive-writer.d.ts +48 -0
- package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -0
- package/dist/commands/archive/zip-archive.d.ts +42 -0
- package/dist/commands/archive/zip-archive.d.ts.map +1 -0
- package/dist/commands/attributes-source.d.ts +10 -0
- package/dist/commands/attributes-source.d.ts.map +1 -1
- package/dist/commands/blame-command.d.ts +345 -8
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/blame-ignore.d.ts +48 -0
- package/dist/commands/blame-ignore.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-create-command.d.ts +67 -0
- package/dist/commands/bundle/bundle-create-command.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-format.d.ts +89 -0
- package/dist/commands/bundle/bundle-format.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-list.d.ts +92 -0
- package/dist/commands/bundle/bundle-list.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts +81 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-support.d.ts +32 -0
- package/dist/commands/bundle/bundle-support.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-transport.d.ts +38 -0
- package/dist/commands/bundle/bundle-transport.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts +43 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri.d.ts +55 -0
- package/dist/commands/bundle/bundle-uri.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-verify.d.ts +63 -0
- package/dist/commands/bundle/bundle-verify.d.ts.map +1 -0
- package/dist/commands/bundle/index.d.ts +14 -0
- package/dist/commands/bundle/index.d.ts.map +1 -0
- package/dist/commands/cat-file/batch-format.d.ts +58 -0
- package/dist/commands/cat-file/batch-format.d.ts.map +1 -0
- package/dist/commands/cat-file/cat-file-command.d.ts +135 -0
- package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -0
- package/dist/commands/cat-file/index.d.ts +3 -0
- package/dist/commands/cat-file/index.d.ts.map +1 -0
- package/dist/commands/check-attr-command.d.ts +66 -0
- package/dist/commands/check-attr-command.d.ts.map +1 -0
- package/dist/commands/check-ignore-command.d.ts +58 -0
- package/dist/commands/check-ignore-command.d.ts.map +1 -0
- package/dist/commands/check-mailmap-command.d.ts +49 -0
- package/dist/commands/check-mailmap-command.d.ts.map +1 -0
- package/dist/commands/check-ref-format-command.d.ts +60 -0
- package/dist/commands/check-ref-format-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +7 -0
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-index-command.d.ts +96 -0
- package/dist/commands/checkout-index-command.d.ts.map +1 -0
- package/dist/commands/checkout-paths.d.ts +4 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-command.d.ts +61 -0
- package/dist/commands/cherry-command.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +33 -1
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +32 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +56 -0
- package/dist/commands/clean-interactive.d.ts.map +1 -0
- package/dist/commands/clone-command.d.ts +135 -2
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +59 -3
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/config-command.d.ts +2 -0
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/daemon-access-hook.d.ts +36 -0
- package/dist/commands/daemon-access-hook.d.ts.map +1 -0
- package/dist/commands/default-branch.d.ts +42 -0
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/describe-command.d.ts +71 -64
- package/dist/commands/describe-command.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +249 -10
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/diff-external.d.ts +43 -0
- package/dist/commands/diff-external.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts +27 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts +129 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/index.d.ts +3 -0
- package/dist/commands/diff-plumbing/index.d.ts.map +1 -0
- package/dist/commands/diff-textconv.d.ts +5 -1
- package/dist/commands/diff-textconv.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-export-command.d.ts +135 -0
- package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-import-command.d.ts +182 -0
- package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts +64 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -0
- package/dist/commands/fast-export/index.d.ts +4 -0
- package/dist/commands/fast-export/index.d.ts.map +1 -0
- package/dist/commands/fetch-command.d.ts +125 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fetch-multiple-command.d.ts +193 -0
- package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
- package/dist/commands/format-patch-command.d.ts +28 -2
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/format-rev-command.d.ts +58 -0
- package/dist/commands/format-rev-command.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-msg-ids.d.ts +18 -3
- package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -1
- package/dist/commands/fsmonitor-refresh.d.ts +69 -0
- package/dist/commands/fsmonitor-refresh.d.ts.map +1 -0
- package/dist/commands/gc-command.d.ts +5 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +77 -4
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +47 -1
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/git-paths.d.ts +26 -0
- package/dist/commands/git-paths.d.ts.map +1 -0
- package/dist/commands/grep/grep-command.d.ts +2 -1
- package/dist/commands/grep/grep-command.d.ts.map +1 -1
- package/dist/commands/history-command.d.ts +156 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/http-config.d.ts +38 -0
- package/dist/commands/http-config.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +12 -1
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index-host.d.ts.map +1 -1
- package/dist/commands/index.d.ts +56 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +6 -3
- package/dist/commands/init-command.d.ts +89 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/last-modified-command.d.ts +102 -0
- package/dist/commands/last-modified-command.d.ts.map +1 -0
- package/dist/commands/lfs/go-url.d.ts +43 -0
- package/dist/commands/lfs/go-url.d.ts.map +1 -0
- package/dist/commands/lfs/index.d.ts +3 -0
- package/dist/commands/lfs/index.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-config.d.ts +174 -0
- package/dist/commands/lfs/lfs-config.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-endpoint-command.d.ts +83 -0
- package/dist/commands/lfs/lfs-endpoint-command.d.ts.map +1 -0
- package/dist/commands/line-log.d.ts +161 -0
- package/dist/commands/line-log.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +261 -6
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +4 -2
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +88 -2
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-files-command.d.ts +153 -0
- package/dist/commands/ls-files-command.d.ts.map +1 -0
- package/dist/commands/ls-remote-command.d.ts +5 -0
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/ls-tree-command.d.ts +105 -0
- package/dist/commands/ls-tree-command.d.ts.map +1 -0
- package/dist/commands/mailmap.d.ts +24 -1
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/maintenance-run-command.d.ts +122 -0
- package/dist/commands/maintenance-run-command.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +58 -1
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-config.d.ts +7 -0
- package/dist/commands/merge-config.d.ts.map +1 -1
- package/dist/commands/merge-drivers.d.ts +69 -5
- package/dist/commands/merge-drivers.d.ts.map +1 -1
- package/dist/commands/merge-strategy-options.d.ts +69 -0
- package/dist/commands/merge-strategy-options.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +16 -0
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/merge-tree-command.d.ts +122 -0
- package/dist/commands/merge-tree-command.d.ts.map +1 -0
- package/dist/commands/message-cleanup.d.ts +2 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -1
- package/dist/commands/mktag-command.d.ts +51 -0
- package/dist/commands/mktag-command.d.ts.map +1 -0
- package/dist/commands/name-rev-command.d.ts +65 -0
- package/dist/commands/name-rev-command.d.ts.map +1 -0
- package/dist/commands/name-rev.d.ts +110 -22
- package/dist/commands/name-rev.d.ts.map +1 -1
- package/dist/commands/object-store/count-objects-command.d.ts +58 -0
- package/dist/commands/object-store/count-objects-command.d.ts.map +1 -0
- package/dist/commands/object-store/index.d.ts +5 -0
- package/dist/commands/object-store/index.d.ts.map +1 -0
- package/dist/commands/object-store/objects-directory.d.ts +12 -0
- package/dist/commands/object-store/objects-directory.d.ts.map +1 -0
- package/dist/commands/object-store/prune-command.d.ts +38 -0
- package/dist/commands/object-store/prune-command.d.ts.map +1 -0
- package/dist/commands/object-store/show-index-command.d.ts +23 -0
- package/dist/commands/object-store/show-index-command.d.ts.map +1 -0
- package/dist/commands/octopus-merge.d.ts +26 -1
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/ort-merge.d.ts +40 -0
- package/dist/commands/ort-merge.d.ts.map +1 -1
- package/dist/commands/ort-recursive.d.ts.map +1 -1
- package/dist/commands/patch-id-command.d.ts +30 -0
- package/dist/commands/patch-id-command.d.ts.map +1 -0
- package/dist/commands/patch-id.d.ts +82 -0
- package/dist/commands/patch-id.d.ts.map +1 -1
- package/dist/commands/plumbing-command.d.ts +66 -0
- package/dist/commands/plumbing-command.d.ts.map +1 -0
- package/dist/commands/plumbing-input.d.ts +38 -0
- package/dist/commands/plumbing-input.d.ts.map +1 -0
- package/dist/commands/promisor-remote-reply.d.ts +35 -0
- package/dist/commands/promisor-remote-reply.d.ts.map +1 -0
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +182 -38
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +82 -2
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/index.d.ts +4 -0
- package/dist/commands/range-diff/index.d.ts.map +1 -0
- package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
- package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff.d.ts +106 -0
- package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
- package/dist/commands/read-tree-command.d.ts +14 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +129 -4
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/refs-command.d.ts +81 -0
- package/dist/commands/refs-command.d.ts.map +1 -0
- package/dist/commands/remerge-diff.d.ts +59 -0
- package/dist/commands/remerge-diff.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +41 -0
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-object-info-command.d.ts +55 -0
- package/dist/commands/remote-object-info-command.d.ts.map +1 -0
- package/dist/commands/remote-show-command.d.ts +204 -0
- package/dist/commands/remote-show-command.d.ts.map +1 -0
- package/dist/commands/remote-transport.d.ts +40 -3
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/repack-command.d.ts +115 -0
- package/dist/commands/repack-command.d.ts.map +1 -0
- package/dist/commands/replace-command.d.ts +143 -0
- package/dist/commands/replace-command.d.ts.map +1 -0
- package/dist/commands/replay-command.d.ts +117 -0
- package/dist/commands/replay-command.d.ts.map +1 -0
- package/dist/commands/repo-command.d.ts +136 -0
- package/dist/commands/repo-command.d.ts.map +1 -0
- package/dist/commands/request-pull-command.d.ts +82 -0
- package/dist/commands/request-pull-command.d.ts.map +1 -0
- package/dist/commands/rerere-command.d.ts +36 -0
- package/dist/commands/rerere-command.d.ts.map +1 -0
- package/dist/commands/rerere.d.ts +102 -0
- package/dist/commands/rerere.d.ts.map +1 -0
- package/dist/commands/reset-command.d.ts +19 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +7 -0
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-filter/commit-grep.d.ts +3 -1
- package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -1
- package/dist/commands/rev-list-command.d.ts +78 -3
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/rev-parse-command.d.ts +9 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +32 -1
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +7 -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/sequencer-pick.d.ts +120 -1
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +10 -1
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +23 -1
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/session-id.d.ts +18 -0
- package/dist/commands/session-id.d.ts.map +1 -0
- package/dist/commands/shortlog-command.d.ts +109 -0
- package/dist/commands/shortlog-command.d.ts.map +1 -0
- package/dist/commands/shortlog.d.ts +151 -0
- package/dist/commands/shortlog.d.ts.map +1 -0
- package/dist/commands/show-branch-command.d.ts +59 -0
- package/dist/commands/show-branch-command.d.ts.map +1 -0
- package/dist/commands/show-ref-command.d.ts +112 -0
- package/dist/commands/show-ref-command.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +9 -2
- package/dist/commands/signature-check.d.ts.map +1 -1
- package/dist/commands/signing.d.ts +22 -1
- package/dist/commands/signing.d.ts.map +1 -1
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-export-command.d.ts +115 -0
- package/dist/commands/stash-export-command.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +33 -3
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/stripspace-command.d.ts +44 -0
- package/dist/commands/stripspace-command.d.ts.map +1 -0
- package/dist/commands/submodule-add-command.d.ts +10 -1
- package/dist/commands/submodule-add-command.d.ts.map +1 -1
- package/dist/commands/submodule-auth.d.ts +3 -1
- package/dist/commands/submodule-auth.d.ts.map +1 -1
- package/dist/commands/submodule-commands.d.ts +99 -3
- package/dist/commands/submodule-commands.d.ts.map +1 -1
- package/dist/commands/submodule-fetch.d.ts +149 -0
- package/dist/commands/submodule-fetch.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +8 -0
- package/dist/commands/submodule-model.d.ts.map +1 -1
- package/dist/commands/submodule-unpack.d.ts +120 -0
- package/dist/commands/submodule-unpack.d.ts.map +1 -0
- package/dist/commands/submodule-update-command.d.ts +21 -1
- package/dist/commands/submodule-update-command.d.ts.map +1 -1
- package/dist/commands/subtree-shift.d.ts +27 -0
- package/dist/commands/subtree-shift.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts +3 -0
- package/dist/commands/switch-command.d.ts.map +1 -1
- package/dist/commands/textconv-cache.d.ts +58 -0
- package/dist/commands/textconv-cache.d.ts.map +1 -0
- package/dist/commands/tree-restore.d.ts +5 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/unpack-objects-command.d.ts +47 -0
- package/dist/commands/unpack-objects-command.d.ts.map +1 -0
- package/dist/commands/update-index-command.d.ts +110 -0
- package/dist/commands/update-index-command.d.ts.map +1 -0
- package/dist/commands/uri-protocols.d.ts +13 -0
- package/dist/commands/uri-protocols.d.ts.map +1 -0
- package/dist/commands/url-parse-command.d.ts +30 -0
- package/dist/commands/url-parse-command.d.ts.map +1 -0
- package/dist/commands/var-command.d.ts +42 -0
- package/dist/commands/var-command.d.ts.map +1 -0
- package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/{commands-ISM52N0n.js → commands-Mlo1dxQN.js} +56133 -70269
- package/dist/errors/command-errors.d.ts +58 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +67 -1
- package/dist/fsck-CrhVMNIH.js +5179 -0
- package/dist/git-command.d.ts +89 -3
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +628 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +84 -0
- package/dist/guarded-transport-command.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/maintenance-run-command-Bw21HEkH.js +13539 -0
- package/dist/remote-transport-Bu4PGSMD.js +2605 -0
- package/dist/rename/detect-renames.d.ts +20 -0
- package/dist/rename/detect-renames.d.ts.map +1 -1
- package/dist/rename/diffcore-break.d.ts +51 -0
- package/dist/rename/diffcore-break.d.ts.map +1 -0
- package/dist/rename/index.d.ts +1 -0
- package/dist/rename/index.d.ts.map +1 -1
- package/dist/results/blame-format.d.ts +62 -1
- package/dist/results/blame-format.d.ts.map +1 -1
- package/dist/results/cherry-pick-result.d.ts +6 -0
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +9 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/diff-dirstat.d.ts +36 -0
- package/dist/results/diff-dirstat.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +20 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +67 -3
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/fetch-result.d.ts +24 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +2 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/init-result.d.ts +8 -1
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/line-range-hunks.d.ts +27 -0
- package/dist/results/line-range-hunks.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +13 -1
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +11 -0
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +10 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +7 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +6 -0
- package/dist/results/revert-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +5 -0
- package/dist/results/stash-result.d.ts.map +1 -1
- package/dist/results/status-result.d.ts +1 -1
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-ERo9vELd.js +49673 -0
- package/dist/transport-command.d.ts +93 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/commands/add-command.ts +118 -0
- package/src/commands/add-patch/add-patch.ts +8 -0
- package/src/commands/add-patch/patch-backend.ts +24 -3
- package/src/commands/add-patch/patch-modes.ts +26 -2
- package/src/commands/add-patch/patch-session.ts +6 -0
- package/src/commands/am/am-command.ts +301 -12
- package/src/commands/apply/apply-command.ts +52 -9
- package/src/commands/apply/apply-parse.ts +10 -0
- package/src/commands/apply/index.ts +9 -1
- package/src/commands/archive/archive-command.ts +1148 -0
- package/src/commands/archive/archive-entry.ts +93 -0
- package/src/commands/archive/index.ts +7 -0
- package/src/commands/archive/remote-archive-command.ts +140 -0
- package/src/commands/archive/tar-archive.ts +207 -0
- package/src/commands/archive/tar-commit-id.ts +72 -0
- package/src/commands/archive/upload-archive-writer.ts +213 -0
- package/src/commands/archive/zip-archive.ts +317 -0
- package/src/commands/attributes-source.ts +26 -12
- package/src/commands/blame-command.ts +1551 -53
- package/src/commands/blame-ignore.ts +307 -0
- package/src/commands/bundle/bundle-create-command.ts +405 -0
- package/src/commands/bundle/bundle-format.ts +228 -0
- package/src/commands/bundle/bundle-list.ts +276 -0
- package/src/commands/bundle/bundle-read-commands.ts +157 -0
- package/src/commands/bundle/bundle-support.ts +85 -0
- package/src/commands/bundle/bundle-transport.ts +107 -0
- package/src/commands/bundle/bundle-uri-host.ts +204 -0
- package/src/commands/bundle/bundle-uri.ts +236 -0
- package/src/commands/bundle/bundle-verify.ts +152 -0
- package/src/commands/bundle/index.ts +14 -0
- package/src/commands/cat-file/batch-format.ts +193 -0
- package/src/commands/cat-file/cat-file-command.ts +857 -0
- package/src/commands/cat-file/index.ts +2 -0
- package/src/commands/check-attr-command.ts +333 -0
- package/src/commands/check-ignore-command.ts +261 -0
- package/src/commands/check-mailmap-command.ts +129 -0
- package/src/commands/check-ref-format-command.ts +129 -0
- package/src/commands/checkout-command.ts +131 -28
- package/src/commands/checkout-index-command.ts +568 -0
- package/src/commands/checkout-paths.ts +35 -0
- package/src/commands/cherry-command.ts +187 -0
- package/src/commands/cherry-pick-command.ts +63 -2
- package/src/commands/clean-command.ts +92 -12
- package/src/commands/clean-interactive.ts +522 -0
- package/src/commands/clone-command.ts +803 -50
- package/src/commands/commit-command.ts +202 -51
- package/src/commands/config-command.ts +9 -0
- package/src/commands/daemon-access-hook.ts +78 -0
- package/src/commands/default-branch.ts +99 -1
- package/src/commands/describe-command.ts +341 -254
- package/src/commands/diff-command.ts +1186 -99
- package/src/commands/diff-external.ts +131 -0
- package/src/commands/diff-plumbing/diff-pairs-command.ts +193 -0
- package/src/commands/diff-plumbing/diff-plumbing-command.ts +424 -0
- package/src/commands/diff-plumbing/index.ts +2 -0
- package/src/commands/diff-textconv.ts +5 -1
- package/src/commands/fast-export/fast-export-command.ts +911 -0
- package/src/commands/fast-export/fast-import-command.ts +1553 -0
- package/src/commands/fast-export/fast-stream-support.ts +162 -0
- package/src/commands/fast-export/index.ts +3 -0
- package/src/commands/fetch-command.ts +665 -14
- package/src/commands/fetch-multiple-command.ts +668 -0
- package/src/commands/format-patch-command.ts +189 -77
- package/src/commands/format-rev-command.ts +251 -0
- package/src/commands/fsck/fsck-command.ts +47 -20
- package/src/commands/fsck/fsck-msg-ids.ts +19 -3
- package/src/commands/fsck/fsck-pack.ts +2 -2
- package/src/commands/fsmonitor-refresh.ts +315 -0
- package/src/commands/gc-command.ts +10 -0
- package/src/commands/git-describe.ts +456 -217
- package/src/commands/git-hooks.ts +165 -9
- package/src/commands/git-paths.ts +136 -0
- package/src/commands/grep/grep-command.ts +38 -15
- package/src/commands/history-command.ts +617 -0
- package/src/commands/http-config.ts +139 -0
- package/src/commands/index-adder.ts +37 -3
- package/src/commands/index-host.ts +6 -1
- package/src/commands/index.ts +62 -0
- package/src/commands/init-command.ts +617 -49
- package/src/commands/last-modified-command.ts +804 -0
- package/src/commands/lfs/go-url.ts +370 -0
- package/src/commands/lfs/index.ts +2 -0
- package/src/commands/lfs/lfs-config.ts +738 -0
- package/src/commands/lfs/lfs-endpoint-command.ts +180 -0
- package/src/commands/line-log.ts +931 -0
- package/src/commands/local-transport.ts +252 -4
- package/src/commands/log-command.ts +1518 -182
- package/src/commands/log-graph.ts +6 -3
- package/src/commands/log-output.ts +228 -15
- package/src/commands/ls-files-command.ts +1177 -0
- package/src/commands/ls-remote-command.ts +6 -0
- package/src/commands/ls-tree-command.ts +684 -0
- package/src/commands/mailmap.ts +41 -5
- package/src/commands/maintenance-run-command.ts +949 -0
- package/src/commands/merge-command.ts +351 -47
- package/src/commands/merge-config.ts +23 -1
- package/src/commands/merge-drivers.ts +112 -20
- package/src/commands/merge-strategy-options.ts +224 -0
- package/src/commands/merge-support.ts +130 -26
- package/src/commands/merge-tree-command.ts +786 -0
- package/src/commands/message-cleanup.ts +1 -1
- package/src/commands/mktag-command.ts +149 -0
- package/src/commands/name-rev-command.ts +184 -0
- package/src/commands/name-rev.ts +700 -109
- package/src/commands/object-store/count-objects-command.ts +404 -0
- package/src/commands/object-store/index.ts +4 -0
- package/src/commands/object-store/objects-directory.ts +24 -0
- package/src/commands/object-store/prune-command.ts +129 -0
- package/src/commands/object-store/show-index-command.ts +151 -0
- package/src/commands/octopus-merge.ts +35 -11
- package/src/commands/ort-merge.ts +124 -23
- package/src/commands/ort-recursive.ts +40 -2
- package/src/commands/patch-id-command.ts +65 -0
- package/src/commands/patch-id.ts +327 -0
- package/src/commands/plumbing-command.ts +141 -0
- package/src/commands/plumbing-input.ts +87 -0
- package/src/commands/promisor-remote-reply.ts +276 -0
- package/src/commands/promisor-remote.ts +25 -2
- package/src/commands/pull-command.ts +720 -224
- package/src/commands/push-command.ts +440 -8
- package/src/commands/range-diff/index.ts +3 -0
- package/src/commands/range-diff/linear-assignment.ts +203 -0
- package/src/commands/range-diff/range-diff-command.ts +433 -0
- package/src/commands/range-diff/range-diff.ts +617 -0
- package/src/commands/read-tree-command.ts +74 -3
- package/src/commands/rebase-command.ts +647 -83
- package/src/commands/refs-command.ts +274 -0
- package/src/commands/remerge-diff.ts +241 -0
- package/src/commands/remote-command.ts +98 -10
- package/src/commands/remote-object-info-command.ts +109 -0
- package/src/commands/remote-show-command.ts +836 -0
- package/src/commands/remote-transport.ts +116 -1
- package/src/commands/repack-command.ts +383 -0
- package/src/commands/replace-command.ts +816 -0
- package/src/commands/replay-command.ts +674 -0
- package/src/commands/repo-command.ts +967 -0
- package/src/commands/request-pull-command.ts +356 -0
- package/src/commands/rerere-command.ts +179 -0
- package/src/commands/rerere.ts +925 -0
- package/src/commands/reset-command.ts +78 -3
- package/src/commands/restore-command.ts +15 -0
- package/src/commands/rev-filter/commit-grep.ts +7 -2
- package/src/commands/rev-list-command.ts +196 -11
- package/src/commands/rev-parse-command.ts +62 -4
- package/src/commands/revert-command.ts +62 -2
- package/src/commands/revision-range.ts +10 -3
- package/src/commands/revision-resolver.ts +44 -3
- package/src/commands/sequencer-pick.ts +370 -29
- package/src/commands/sequencer-support.ts +164 -2
- package/src/commands/serve-repository.ts +65 -0
- package/src/commands/session-id.ts +31 -0
- package/src/commands/shortlog-command.ts +354 -0
- package/src/commands/shortlog.ts +361 -0
- package/src/commands/show-branch-command.ts +981 -0
- package/src/commands/show-command.ts +3 -2
- package/src/commands/show-ref-command.ts +439 -0
- package/src/commands/signature-check.ts +37 -5
- package/src/commands/signing.ts +122 -16
- package/src/commands/stash-apply-command.ts +3 -0
- package/src/commands/stash-export-command.ts +397 -0
- package/src/commands/status-command.ts +158 -31
- package/src/commands/status-format.ts +1 -1
- package/src/commands/stripspace-command.ts +118 -0
- package/src/commands/submodule-add-command.ts +22 -1
- package/src/commands/submodule-auth.ts +61 -6
- package/src/commands/submodule-commands.ts +333 -5
- package/src/commands/submodule-fetch.ts +789 -0
- package/src/commands/submodule-model.ts +9 -1
- package/src/commands/submodule-unpack.ts +265 -0
- package/src/commands/submodule-update-command.ts +68 -5
- package/src/commands/subtree-shift.ts +215 -0
- package/src/commands/switch-command.ts +9 -0
- package/src/commands/textconv-cache.ts +143 -0
- package/src/commands/tree-restore.ts +20 -1
- package/src/commands/unpack-objects-command.ts +235 -0
- package/src/commands/update-index-command.ts +1016 -0
- package/src/commands/uri-protocols.ts +13 -0
- package/src/commands/url-parse-command.ts +67 -0
- package/src/commands/var-command.ts +219 -0
- package/src/commands/worktree-overwrite-checks.ts +5 -0
- package/src/errors/command-errors.ts +80 -0
- package/src/git-command.ts +218 -2
- package/src/git.ts +1033 -80
- package/src/guarded-transport-command.ts +176 -0
- package/src/index.ts +1 -0
- package/src/rename/detect-renames.ts +42 -8
- package/src/rename/diffcore-break.ts +166 -0
- package/src/rename/index.ts +1 -0
- package/src/results/blame-format.ts +268 -43
- package/src/results/cherry-pick-result.ts +6 -0
- package/src/results/clone-result.ts +6 -0
- package/src/results/diff-dirstat.ts +117 -0
- package/src/results/diff-entry.ts +24 -0
- package/src/results/diff-formatter.ts +8 -4
- package/src/results/diff-output.ts +239 -8
- package/src/results/diff-pickaxe.ts +1 -1
- package/src/results/fetch-result.ts +24 -1
- package/src/results/index.ts +2 -0
- package/src/results/init-result.ts +10 -1
- package/src/results/line-range-hunks.ts +126 -0
- package/src/results/merge-result.ts +14 -0
- package/src/results/pull-result.ts +7 -0
- package/src/results/push-result.ts +10 -0
- package/src/results/rebase-result.ts +7 -0
- package/src/results/revert-result.ts +6 -0
- package/src/results/stash-result.ts +6 -0
- package/src/results/status-result.ts +2 -2
- package/src/transport-command.ts +216 -4
- package/dist/fsck-DLRpbwTj.js +0 -13405
- package/dist/results-TB2IJ64h.js +0 -4700
|
@@ -34,6 +34,11 @@ export interface LsRemoteResult {
|
|
|
34
34
|
refs: RemoteRef[];
|
|
35
35
|
/** Default branch (from HEAD symref) */
|
|
36
36
|
defaultBranch?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The object HEAD names, git ls-remote's first line (`<id>\tHEAD`); undefined when the
|
|
39
|
+
* remote has no HEAD or it is unborn, or with `--heads`/`--tags`
|
|
40
|
+
*/
|
|
41
|
+
head?: ObjectId;
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
/**
|
|
@@ -218,6 +223,7 @@ export class LsRemoteCommand extends TransportCommand<LsRemoteResult> {
|
|
|
218
223
|
uri: remoteUrl,
|
|
219
224
|
refs: filteredRefs,
|
|
220
225
|
defaultBranch,
|
|
226
|
+
...(head?.oid && !this.heads && !this.tags ? { head: head.oid } : {}),
|
|
221
227
|
};
|
|
222
228
|
}
|
|
223
229
|
|
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `git ls-tree` (builtin/ls-tree.c): the entries of a tree, byte for byte as git prints them.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* // git ls-tree -r --name-only HEAD src/
|
|
7
|
+
* const { stdout } = await git.lsTree().setTreeish("HEAD").setRecursive(true)
|
|
8
|
+
* .setNameOnly().addPaths("src/").callOutput();
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { parseGitBool } from "@statewalker/vcs-utils";
|
|
13
|
+
import { encodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
14
|
+
import { RefNotFoundError } from "../errors/index.js";
|
|
15
|
+
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
16
|
+
import { quoteCStyleBody } from "../results/quote-path.js";
|
|
17
|
+
import { prefixPathGently, relativePath } from "./git-paths.js";
|
|
18
|
+
import {
|
|
19
|
+
ALL_ENTRIES_INTERESTING,
|
|
20
|
+
ALL_ENTRIES_NOT_INTERESTING,
|
|
21
|
+
ENTRY_NOT_INTERESTING,
|
|
22
|
+
latin1Bytes,
|
|
23
|
+
latin1String,
|
|
24
|
+
type PathspecItem,
|
|
25
|
+
pathspecItemBytes,
|
|
26
|
+
type TreePathspec,
|
|
27
|
+
treeEntryInteresting,
|
|
28
|
+
treePathspec,
|
|
29
|
+
} from "./pathspec.js";
|
|
30
|
+
import { PlumbingCommand, PlumbingError } from "./plumbing-command.js";
|
|
31
|
+
|
|
32
|
+
/** ls-tree's `cmdmode`: the output options that exclude one another. */
|
|
33
|
+
export type LsTreeMode = "long" | "name-only" | "name-status" | "object-only";
|
|
34
|
+
|
|
35
|
+
/** The fast paths ls-tree takes for a `--format` equal to a mode's own format. */
|
|
36
|
+
const MODE_FORMATS: ["default" | "long" | "name-only" | "object-only", string][] = [
|
|
37
|
+
["default", "%(objectmode) %(objecttype) %(objectname)%x09%(path)"],
|
|
38
|
+
["long", "%(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path)"],
|
|
39
|
+
["name-only", "%(path)"],
|
|
40
|
+
["object-only", "%(objectname)"],
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
const USAGE = "usage: git ls-tree [<options>] <tree-ish> [<path>...]";
|
|
44
|
+
|
|
45
|
+
/** pathspec.c's `pathspec_magic`: the bits, mnemonics and names, in its order */
|
|
46
|
+
const MAGIC = [
|
|
47
|
+
{ name: "top", mnemonic: "/" },
|
|
48
|
+
{ name: "literal", mnemonic: "" },
|
|
49
|
+
{ name: "glob", mnemonic: "" },
|
|
50
|
+
{ name: "icase", mnemonic: "" },
|
|
51
|
+
{ name: "exclude", mnemonic: "!" },
|
|
52
|
+
{ name: "attr", mnemonic: "" },
|
|
53
|
+
] as const;
|
|
54
|
+
|
|
55
|
+
/** ctype.c's GIT_PATHSPEC_MAGIC characters (and `/`, `^`) */
|
|
56
|
+
const SHORT_MAGIC = new Set([..."!\"#%&',-;<=>@_`~^/"]);
|
|
57
|
+
|
|
58
|
+
const FLUSH_AT = 64 * 1024;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* `git ls-tree [<options>] <tree-ish> [<path>...]`.
|
|
62
|
+
*
|
|
63
|
+
* Paths are ls-tree's own: literal pathspecs (only `:(top)` and `:(literal)` magic), a tree
|
|
64
|
+
* shown or entered by leading path components (`show_recursive`), not wildcard matches.
|
|
65
|
+
* Output paths are relative to {@link setPrefix} unless `--full-name`/`--full-tree`.
|
|
66
|
+
*
|
|
67
|
+
* git 2.43 (`setCompatibility("2.43")`) words the conflict of two output modes as
|
|
68
|
+
* `error: <b> is incompatible with <a>`, 2.45 and later as `error: options '<b>' and '<a>'
|
|
69
|
+
* cannot be used together`. Usage errors exit 129 with that first line only (git prints its
|
|
70
|
+
* usage after it).
|
|
71
|
+
*/
|
|
72
|
+
export class LsTreeCommand extends PlumbingCommand {
|
|
73
|
+
private treeish?: string;
|
|
74
|
+
private readonly paths: string[] = [];
|
|
75
|
+
private treesOnly = false;
|
|
76
|
+
private recursive = false;
|
|
77
|
+
private showTrees = false;
|
|
78
|
+
private nul = false;
|
|
79
|
+
private readonly modes: { mode: LsTreeMode; option: string }[] = [];
|
|
80
|
+
private fullName?: boolean;
|
|
81
|
+
private fullTree = false;
|
|
82
|
+
private format?: string;
|
|
83
|
+
private abbrev = 0;
|
|
84
|
+
private prefix = "";
|
|
85
|
+
private compatibility: "2.43" | "2.56" = "2.56";
|
|
86
|
+
|
|
87
|
+
/** The `<tree-ish>` argument. */
|
|
88
|
+
setTreeish(name: string): this {
|
|
89
|
+
this.checkCallable();
|
|
90
|
+
this.treeish = name;
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** `<path>...` arguments, read against {@link setPrefix}. */
|
|
95
|
+
addPaths(...paths: string[]): this {
|
|
96
|
+
this.checkCallable();
|
|
97
|
+
this.paths.push(...paths);
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** `-d`: only trees (and gitlinks). */
|
|
102
|
+
setTreesOnly(on = true): this {
|
|
103
|
+
this.checkCallable();
|
|
104
|
+
this.treesOnly = on;
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** `-r`: recurse into subtrees. */
|
|
109
|
+
setRecursive(on = true): this {
|
|
110
|
+
this.checkCallable();
|
|
111
|
+
this.recursive = on;
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** `-t`: show the trees recursed into. */
|
|
116
|
+
setShowTrees(on = true): this {
|
|
117
|
+
this.checkCallable();
|
|
118
|
+
this.showTrees = on;
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** `-z`: entries end with NUL, paths unquoted. */
|
|
123
|
+
setNullTerminated(on = true): this {
|
|
124
|
+
this.checkCallable();
|
|
125
|
+
this.nul = on;
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* An output mode option (`-l`/`--long`, `--name-only`, `--name-status`, `--object-only`),
|
|
131
|
+
* `option` its spelling for git's conflict message; a second, different mode is refused.
|
|
132
|
+
*/
|
|
133
|
+
addMode(mode: LsTreeMode, option = `--${mode}`): this {
|
|
134
|
+
this.checkCallable();
|
|
135
|
+
this.modes.push({ mode, option });
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** `-l`/`--long`: object sizes. */
|
|
140
|
+
setLong(option = "--long"): this {
|
|
141
|
+
return this.addMode("long", option);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** `--name-only`: paths only. */
|
|
145
|
+
setNameOnly(): this {
|
|
146
|
+
return this.addMode("name-only");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** `--name-status`: as `--name-only`. */
|
|
150
|
+
setNameStatus(): this {
|
|
151
|
+
return this.addMode("name-status");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** `--object-only`: object names only. */
|
|
155
|
+
setObjectOnly(): this {
|
|
156
|
+
return this.addMode("object-only");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** `--[no-]full-name`: paths from the top (default: on when there is no prefix). */
|
|
160
|
+
setFullName(on = true): this {
|
|
161
|
+
this.checkCallable();
|
|
162
|
+
this.fullName = on;
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** `--full-tree`: the whole tree, paths from the top, the prefix ignored. */
|
|
167
|
+
setFullTree(on = true): this {
|
|
168
|
+
this.checkCallable();
|
|
169
|
+
this.fullTree = on;
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** `--format=<format>`. */
|
|
174
|
+
setFormat(format: string): this {
|
|
175
|
+
this.checkCallable();
|
|
176
|
+
this.format = format;
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* `--abbrev[=<n>]`: `undefined` is `--abbrev` (core.abbrev, else automatic), 0 the full
|
|
182
|
+
* id (`--no-abbrev`), else at least `n` digits (4 at least).
|
|
183
|
+
*/
|
|
184
|
+
setAbbrev(length?: number): this {
|
|
185
|
+
this.checkCallable();
|
|
186
|
+
this.abbrev = length === undefined ? -1 : length;
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** The directory git runs in, relative to the top of the worktree (git's prefix). */
|
|
191
|
+
setPrefix(prefix: string): this {
|
|
192
|
+
this.checkCallable();
|
|
193
|
+
const p = prefix.replace(/^\/+|\/+$/g, "");
|
|
194
|
+
this.prefix = p ? `${p}/` : "";
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** The git version whose messages to follow (default 2.56). */
|
|
199
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
200
|
+
this.checkCallable();
|
|
201
|
+
this.compatibility = version;
|
|
202
|
+
return this;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
protected override writesNoObjects(): boolean {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
private out: Uint8Array[] = [];
|
|
210
|
+
private outSize = 0;
|
|
211
|
+
|
|
212
|
+
private emit(bytes: Uint8Array): Promise<void> | undefined {
|
|
213
|
+
this.out.push(bytes);
|
|
214
|
+
this.outSize += bytes.length;
|
|
215
|
+
return this.outSize >= FLUSH_AT ? this.flush() : undefined;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
private async flush(): Promise<void> {
|
|
219
|
+
if (this.outSize === 0) return;
|
|
220
|
+
const all = new Uint8Array(this.outSize);
|
|
221
|
+
let at = 0;
|
|
222
|
+
for (const c of this.out) {
|
|
223
|
+
all.set(c, at);
|
|
224
|
+
at += c.length;
|
|
225
|
+
}
|
|
226
|
+
this.out = [];
|
|
227
|
+
this.outSize = 0;
|
|
228
|
+
await this.write(all);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
protected async run(): Promise<number> {
|
|
232
|
+
// parse_options: OPT_CMDMODE refuses a second, different mode
|
|
233
|
+
let mode: LsTreeMode | undefined;
|
|
234
|
+
let modeOption = "";
|
|
235
|
+
for (const m of this.modes) {
|
|
236
|
+
if (mode !== undefined && m.mode !== mode) {
|
|
237
|
+
throw new PlumbingError(
|
|
238
|
+
this.compatibility === "2.43"
|
|
239
|
+
? `error: ${m.option} is incompatible with ${modeOption}`
|
|
240
|
+
: `error: options '${m.option}' and '${modeOption}' cannot be used together`,
|
|
241
|
+
129,
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
mode = m.mode;
|
|
245
|
+
modeOption = m.option;
|
|
246
|
+
}
|
|
247
|
+
if (mode === "name-status") mode = "name-only";
|
|
248
|
+
let prefix: string | undefined = this.prefix || undefined;
|
|
249
|
+
if (this.fullTree) prefix = undefined;
|
|
250
|
+
const fullName = this.fullName ?? !this.prefix;
|
|
251
|
+
const outputPrefix = fullName ? undefined : prefix;
|
|
252
|
+
let showTrees = this.showTrees;
|
|
253
|
+
// -d -r implies -t
|
|
254
|
+
if (this.treesOnly && this.recursive) showTrees = true;
|
|
255
|
+
if (this.format !== undefined && mode !== undefined) {
|
|
256
|
+
throw new PlumbingError(
|
|
257
|
+
"fatal: --format can't be combined with other format-altering options",
|
|
258
|
+
129,
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
if (this.treeish === undefined) throw new PlumbingError(USAGE, 129);
|
|
262
|
+
|
|
263
|
+
const resolver = this.revisionResolver();
|
|
264
|
+
let id: string | undefined;
|
|
265
|
+
try {
|
|
266
|
+
id = await resolver.resolve(this.treeish);
|
|
267
|
+
} catch (e) {
|
|
268
|
+
if (!(e instanceof RefNotFoundError)) throw e;
|
|
269
|
+
}
|
|
270
|
+
for (const w of resolver.warnings) this.warn(w);
|
|
271
|
+
resolver.warnings.length = 0;
|
|
272
|
+
if (id === undefined) throw new PlumbingError(`fatal: Not a valid object name ${this.treeish}`);
|
|
273
|
+
|
|
274
|
+
const items = await this.parsePaths(prefix);
|
|
275
|
+
const tree = await this.peelToTree(id);
|
|
276
|
+
if (tree === undefined) throw new PlumbingError("fatal: not a tree object");
|
|
277
|
+
|
|
278
|
+
let fn: "default" | "long" | "name-only" | "object-only" | "format";
|
|
279
|
+
if (this.format !== undefined) {
|
|
280
|
+
const fast = MODE_FORMATS.find(([, f]) => f === this.format);
|
|
281
|
+
fn = fast ? fast[0] : "format";
|
|
282
|
+
} else fn = mode ?? "default";
|
|
283
|
+
|
|
284
|
+
const config = this._workingCopy.config ? RemoteConfigStore.from(this._workingCopy) : undefined;
|
|
285
|
+
const quotePathValue = config?.value("core.quotePath");
|
|
286
|
+
const quoteFully = quotePathValue === undefined ? true : (parseGitBool(quotePathValue) ?? true);
|
|
287
|
+
|
|
288
|
+
const ctx: WalkContext = {
|
|
289
|
+
items,
|
|
290
|
+
ps: items.length > 0 ? treePathspec(items) : undefined,
|
|
291
|
+
fn,
|
|
292
|
+
treesOnly: this.treesOnly,
|
|
293
|
+
recursive: this.recursive,
|
|
294
|
+
showTrees,
|
|
295
|
+
outputPrefix:
|
|
296
|
+
outputPrefix === undefined ? undefined : latin1String(encodeGitPath(outputPrefix)),
|
|
297
|
+
quoteFully,
|
|
298
|
+
nulTerminated: this.nul,
|
|
299
|
+
};
|
|
300
|
+
let ok: boolean;
|
|
301
|
+
try {
|
|
302
|
+
ok = await this.walk(ctx, tree, "");
|
|
303
|
+
} finally {
|
|
304
|
+
await this.flush();
|
|
305
|
+
}
|
|
306
|
+
return ok ? 0 : 1;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** parse_pathspec with ls-tree's magic mask and PATHSPEC_PREFER_CWD: literal elements. */
|
|
310
|
+
private async parsePaths(prefix: string | undefined): Promise<PathspecItem[]> {
|
|
311
|
+
const literal = (match: string): PathspecItem =>
|
|
312
|
+
pathspecItemBytes({
|
|
313
|
+
match,
|
|
314
|
+
nowildcardLen: match.length,
|
|
315
|
+
oneStar: false,
|
|
316
|
+
exclude: false,
|
|
317
|
+
glob: false,
|
|
318
|
+
icase: false,
|
|
319
|
+
});
|
|
320
|
+
if (this.paths.length === 0) return prefix ? [literal(prefix)] : [];
|
|
321
|
+
for (const p of this.paths) {
|
|
322
|
+
if (p === "") {
|
|
323
|
+
throw new PlumbingError(
|
|
324
|
+
"fatal: empty string is not a valid pathspec. please use . instead if you meant to match all paths",
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
const items: PathspecItem[] = [];
|
|
329
|
+
for (const elem of this.paths) {
|
|
330
|
+
const { magic, rest } = parseElementMagic(elem);
|
|
331
|
+
if (magic.has("literal") && magic.has("glob")) {
|
|
332
|
+
throw new PlumbingError(`fatal: ${elem}: 'literal' and 'glob' are incompatible`);
|
|
333
|
+
}
|
|
334
|
+
let match: string;
|
|
335
|
+
if (magic.has("top")) match = rest;
|
|
336
|
+
else {
|
|
337
|
+
const normalized = await this.prefixPath(prefix ?? "", rest);
|
|
338
|
+
if (normalized === undefined) {
|
|
339
|
+
const top = (await this.hostWorkingDir()) ?? "";
|
|
340
|
+
throw new PlumbingError(
|
|
341
|
+
`fatal: ${elem}: '${rest}' is outside repository at '${top.replace(/\/+$/, "") || "/"}'`,
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
match = normalized;
|
|
345
|
+
}
|
|
346
|
+
const unsupported = MAGIC.filter((m) => m.name !== "top" && m.name !== "literal").filter(
|
|
347
|
+
(m) => magic.has(m.name),
|
|
348
|
+
);
|
|
349
|
+
if (unsupported.length > 0) {
|
|
350
|
+
const names = unsupported
|
|
351
|
+
.map((m) => (m.mnemonic ? `'${m.name}' (mnemonic: '${m.mnemonic}')` : `'${m.name}'`))
|
|
352
|
+
.join(", ");
|
|
353
|
+
throw new PlumbingError(
|
|
354
|
+
`fatal: ${elem}: pathspec magic not supported by this command: ${names}`,
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
items.push(literal(match));
|
|
358
|
+
}
|
|
359
|
+
return items;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** prefix_path_gently: the path from the top, undefined when it leaves the worktree. */
|
|
363
|
+
private async prefixPath(prefix: string, path: string): Promise<string | undefined> {
|
|
364
|
+
return prefixPathGently(
|
|
365
|
+
prefix,
|
|
366
|
+
path,
|
|
367
|
+
path.startsWith("/") ? await this.hostWorkingDir() : undefined,
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/** parse_tree_indirect: a commit's tree, a tag's object peeled, a tree itself. */
|
|
372
|
+
private async peelToTree(id: string): Promise<string | undefined> {
|
|
373
|
+
const peeled = await this.revisionResolver().peelTags(id);
|
|
374
|
+
if (peeled.type === "tree") return peeled.id;
|
|
375
|
+
if (peeled.type === "commit") {
|
|
376
|
+
const commit = await this.commits.load(peeled.id).catch(() => undefined);
|
|
377
|
+
return commit?.tree;
|
|
378
|
+
}
|
|
379
|
+
return undefined;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** read_tree_at: false when a tree could not be read (git's `-1`). */
|
|
383
|
+
private async walk(ctx: WalkContext, tree: string, base: string): Promise<boolean> {
|
|
384
|
+
const entries = await this.listedTreeEntries(tree);
|
|
385
|
+
if (!entries) {
|
|
386
|
+
this.warn(`error: Could not read ${tree}`);
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
389
|
+
const baseBytes = latin1Bytes(base);
|
|
390
|
+
let all = false;
|
|
391
|
+
for (const e of entries) {
|
|
392
|
+
const nameBytes = encodeGitPath(e.name);
|
|
393
|
+
const mode = e.mode;
|
|
394
|
+
if (ctx.ps && !all) {
|
|
395
|
+
const r = treeEntryInteresting(ctx.ps, nameBytes, 0, nameBytes.length, mode, baseBytes);
|
|
396
|
+
if (r === ALL_ENTRIES_NOT_INTERESTING) break;
|
|
397
|
+
if (r === ENTRY_NOT_INTERESTING) continue;
|
|
398
|
+
if (r === ALL_ENTRIES_INTERESTING) all = true;
|
|
399
|
+
}
|
|
400
|
+
const name = latin1String(nameBytes);
|
|
401
|
+
const type = objectTypeOfMode(mode);
|
|
402
|
+
// show_tree_common / show_tree_fmt
|
|
403
|
+
let recurse = false;
|
|
404
|
+
let show = true;
|
|
405
|
+
if (type === "blob") {
|
|
406
|
+
if (ctx.treesOnly) show = false;
|
|
407
|
+
} else if (type === "tree" && this.showRecursive(ctx, base, name)) {
|
|
408
|
+
recurse = true;
|
|
409
|
+
if (!ctx.showTrees) show = false;
|
|
410
|
+
}
|
|
411
|
+
if (show) {
|
|
412
|
+
const pending = this.emit(await this.entryLine(ctx, e.id, mode, type, base + name));
|
|
413
|
+
if (pending) await pending;
|
|
414
|
+
}
|
|
415
|
+
if (recurse && !(await this.walk(ctx, e.id, `${base + name}/`))) return false;
|
|
416
|
+
}
|
|
417
|
+
return true;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/** show_recursive: whether a tree is entered. */
|
|
421
|
+
private showRecursive(ctx: WalkContext, base: string, pathname: string): boolean {
|
|
422
|
+
if (ctx.recursive) return true;
|
|
423
|
+
for (const item of ctx.items) {
|
|
424
|
+
const spec = item.match;
|
|
425
|
+
if (!spec.startsWith(base)) continue;
|
|
426
|
+
const rest = spec.slice(base.length);
|
|
427
|
+
const len = pathname.length;
|
|
428
|
+
if (rest.length <= len) continue;
|
|
429
|
+
if (rest[len] !== "/") continue;
|
|
430
|
+
if (rest.slice(0, len) !== pathname) continue;
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
private async abbreviated(id: string): Promise<string> {
|
|
437
|
+
if (this.abbrev === 0) return id;
|
|
438
|
+
const hex = this.objectFormat.hexLength;
|
|
439
|
+
const min =
|
|
440
|
+
this.abbrev < 0 ? undefined : this.abbrev < 4 ? 4 : this.abbrev > hex ? hex : this.abbrev;
|
|
441
|
+
const length = (await this.idAbbreviator().lengths([id], min)).get(id) ?? hex;
|
|
442
|
+
return id.slice(0, length);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** The blob's size, undefined when it cannot be read. */
|
|
446
|
+
private async blobSize(id: string): Promise<number | undefined> {
|
|
447
|
+
const objects = this._workingCopy.history?.objects;
|
|
448
|
+
try {
|
|
449
|
+
if (objects) {
|
|
450
|
+
// the entry headers when the store can read them (oid_object_info), else the object
|
|
451
|
+
const header = await objects.header?.(id);
|
|
452
|
+
if (header) return header.size;
|
|
453
|
+
const obj = await objects.get(id);
|
|
454
|
+
if (!obj) return undefined;
|
|
455
|
+
await obj.content[Symbol.asyncIterator]().return?.();
|
|
456
|
+
return obj.size;
|
|
457
|
+
}
|
|
458
|
+
return await this.blobs.size(id);
|
|
459
|
+
} catch {
|
|
460
|
+
return undefined;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/** The path (a byte string) as the fast paths print it. */
|
|
465
|
+
private fastPath(ctx: WalkContext, path: string): Uint8Array {
|
|
466
|
+
const rel = relativePath(path, ctx.outputPrefix);
|
|
467
|
+
if (ctx.nulTerminated) return latin1Bytes(`${rel}\0`);
|
|
468
|
+
return latin1Bytes(`${quoteBytes(rel, ctx.quoteFully)}\n`);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
private async entryLine(
|
|
472
|
+
ctx: WalkContext,
|
|
473
|
+
id: string,
|
|
474
|
+
mode: number,
|
|
475
|
+
type: string,
|
|
476
|
+
path: string,
|
|
477
|
+
): Promise<Uint8Array> {
|
|
478
|
+
const modeText = mode.toString(8).padStart(6, "0");
|
|
479
|
+
switch (ctx.fn) {
|
|
480
|
+
case "default":
|
|
481
|
+
return concat(
|
|
482
|
+
latin1Bytes(`${modeText} ${type} ${await this.abbreviated(id)}\t`),
|
|
483
|
+
this.fastPath(ctx, path),
|
|
484
|
+
);
|
|
485
|
+
case "long": {
|
|
486
|
+
let size = "-";
|
|
487
|
+
if (type === "blob") size = String((await this.blobSize(id)) ?? "BAD");
|
|
488
|
+
return concat(
|
|
489
|
+
latin1Bytes(`${modeText} ${type} ${await this.abbreviated(id)} ${size.padStart(7)}\t`),
|
|
490
|
+
this.fastPath(ctx, path),
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
case "name-only":
|
|
494
|
+
return this.fastPath(ctx, path);
|
|
495
|
+
case "object-only":
|
|
496
|
+
return latin1Bytes(`${await this.abbreviated(id)}${this.nul ? "\0" : "\n"}`);
|
|
497
|
+
default:
|
|
498
|
+
return latin1Bytes(
|
|
499
|
+
`${await this.expandFormat(ctx, id, modeText, type, path)}${this.nul ? "\0" : "\n"}`,
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/** show_tree_fmt's expansion (a byte string). */
|
|
505
|
+
private async expandFormat(
|
|
506
|
+
ctx: WalkContext,
|
|
507
|
+
id: string,
|
|
508
|
+
modeText: string,
|
|
509
|
+
type: string,
|
|
510
|
+
path: string,
|
|
511
|
+
): Promise<string> {
|
|
512
|
+
const format = latin1String(encodeGitPath(this.format ?? ""));
|
|
513
|
+
let out = "";
|
|
514
|
+
let i = 0;
|
|
515
|
+
const size = async (padded: boolean) => {
|
|
516
|
+
let text = "-";
|
|
517
|
+
if (type === "blob") {
|
|
518
|
+
const s = await this.blobSize(id);
|
|
519
|
+
if (s === undefined)
|
|
520
|
+
throw new PlumbingError(`fatal: could not get object info about '${id}'`);
|
|
521
|
+
text = String(s);
|
|
522
|
+
}
|
|
523
|
+
return padded ? text.padStart(7) : text;
|
|
524
|
+
};
|
|
525
|
+
while (i < format.length) {
|
|
526
|
+
const at = format.indexOf("%", i);
|
|
527
|
+
if (at < 0) {
|
|
528
|
+
out += format.slice(i);
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
out += format.slice(i, at);
|
|
532
|
+
i = at + 1;
|
|
533
|
+
const rest = format.slice(i);
|
|
534
|
+
if (rest.startsWith("%")) {
|
|
535
|
+
out += "%";
|
|
536
|
+
i += 1;
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
if (rest.startsWith("n")) {
|
|
540
|
+
out += "\n";
|
|
541
|
+
i += 1;
|
|
542
|
+
continue;
|
|
543
|
+
}
|
|
544
|
+
const hex = /^x([0-9a-fA-F]{2})/.exec(rest);
|
|
545
|
+
if (hex) {
|
|
546
|
+
out += String.fromCharCode(Number.parseInt(hex[1] as string, 16));
|
|
547
|
+
i += 3;
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
const atom = /^\((objectmode|objecttype|objectsize:padded|objectsize|objectname|path)\)/.exec(
|
|
551
|
+
rest,
|
|
552
|
+
);
|
|
553
|
+
if (!atom) {
|
|
554
|
+
const shown = decodeLatin1Path(rest);
|
|
555
|
+
if (!rest.startsWith("(")) {
|
|
556
|
+
throw new PlumbingError(
|
|
557
|
+
`fatal: bad ls-tree format: element '${shown}' does not start with '('`,
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
const close = rest.indexOf(")", 1);
|
|
561
|
+
if (close < 0) {
|
|
562
|
+
throw new PlumbingError(
|
|
563
|
+
`fatal: bad ls-tree format: element '${shown}' does not end in ')'`,
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
throw new PlumbingError(
|
|
567
|
+
`fatal: bad ls-tree format: %${decodeLatin1Path(rest.slice(0, close + 1))}`,
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
i += atom[0].length;
|
|
571
|
+
switch (atom[1]) {
|
|
572
|
+
case "objectmode":
|
|
573
|
+
out += modeText;
|
|
574
|
+
break;
|
|
575
|
+
case "objecttype":
|
|
576
|
+
out += type;
|
|
577
|
+
break;
|
|
578
|
+
case "objectsize:padded":
|
|
579
|
+
out += await size(true);
|
|
580
|
+
break;
|
|
581
|
+
case "objectsize":
|
|
582
|
+
out += await size(false);
|
|
583
|
+
break;
|
|
584
|
+
case "objectname":
|
|
585
|
+
out += await this.abbreviated(id);
|
|
586
|
+
break;
|
|
587
|
+
default:
|
|
588
|
+
out += quoteBytes(relativePath(path, ctx.outputPrefix), ctx.quoteFully);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return out;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
interface WalkContext {
|
|
596
|
+
items: PathspecItem[];
|
|
597
|
+
ps: TreePathspec | undefined;
|
|
598
|
+
fn: "default" | "long" | "name-only" | "object-only" | "format";
|
|
599
|
+
treesOnly: boolean;
|
|
600
|
+
recursive: boolean;
|
|
601
|
+
showTrees: boolean;
|
|
602
|
+
/** The prefix paths are printed relative to (a byte string), if any */
|
|
603
|
+
outputPrefix: string | undefined;
|
|
604
|
+
quoteFully: boolean;
|
|
605
|
+
nulTerminated: boolean;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
function objectTypeOfMode(mode: number): "tree" | "commit" | "blob" {
|
|
609
|
+
const kind = mode & 0o170000;
|
|
610
|
+
if (kind === 0o040000) return "tree";
|
|
611
|
+
if (kind === 0o160000) return "commit";
|
|
612
|
+
return "blob";
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
function concat(a: Uint8Array, b: Uint8Array): Uint8Array {
|
|
616
|
+
const out = new Uint8Array(a.length + b.length);
|
|
617
|
+
out.set(a);
|
|
618
|
+
out.set(b, a.length);
|
|
619
|
+
return out;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/** A byte string as git prints it in an error message (bytes as they are). */
|
|
623
|
+
function decodeLatin1Path(s: string): string {
|
|
624
|
+
return new TextDecoder().decode(latin1Bytes(s));
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/** quote_c_style of a byte string, as a byte string. */
|
|
628
|
+
function quoteBytes(path: string, quoteFully: boolean): string {
|
|
629
|
+
const body = quoteCStyleBody(latin1Bytes(path), quoteFully);
|
|
630
|
+
if (body === undefined) return path;
|
|
631
|
+
return latin1String(encodeGitPath(`"${body}"`));
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/** parse_element_magic: the magic names an element carries and the path after them. */
|
|
635
|
+
function parseElementMagic(elem: string): { magic: Set<string>; rest: string } {
|
|
636
|
+
const magic = new Set<string>();
|
|
637
|
+
if (!elem.startsWith(":")) return { magic, rest: elem };
|
|
638
|
+
if (elem[1] === "(") {
|
|
639
|
+
let pos = 2;
|
|
640
|
+
while (pos < elem.length && elem[pos] !== ")") {
|
|
641
|
+
let len = 0;
|
|
642
|
+
while (pos + len < elem.length && elem[pos + len] !== "," && elem[pos + len] !== ")") {
|
|
643
|
+
if (elem[pos + len] === "\\" && pos + len + 1 < elem.length) len++;
|
|
644
|
+
len++;
|
|
645
|
+
}
|
|
646
|
+
const next = elem[pos + len] === "," ? pos + len + 1 : pos + len;
|
|
647
|
+
const word = elem.slice(pos, pos + len);
|
|
648
|
+
pos = next;
|
|
649
|
+
if (!word) continue;
|
|
650
|
+
if (word.startsWith("prefix:")) {
|
|
651
|
+
if (!/^-?\d+$/.test(word.slice(7))) {
|
|
652
|
+
throw new PlumbingError("fatal: invalid parameter for pathspec magic 'prefix'");
|
|
653
|
+
}
|
|
654
|
+
continue;
|
|
655
|
+
}
|
|
656
|
+
if (word.startsWith("attr:")) {
|
|
657
|
+
magic.add("attr");
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
if (!MAGIC.some((m) => m.name === word)) {
|
|
661
|
+
throw new PlumbingError(`fatal: Invalid pathspec magic '${word}' in '${elem}'`);
|
|
662
|
+
}
|
|
663
|
+
magic.add(word);
|
|
664
|
+
}
|
|
665
|
+
if (elem[pos] !== ")") {
|
|
666
|
+
throw new PlumbingError(`fatal: Missing ')' at the end of pathspec magic in '${elem}'`);
|
|
667
|
+
}
|
|
668
|
+
return { magic, rest: elem.slice(pos + 1) };
|
|
669
|
+
}
|
|
670
|
+
let pos = 1;
|
|
671
|
+
for (; pos < elem.length && elem[pos] !== ":"; pos++) {
|
|
672
|
+
const ch = elem[pos] as string;
|
|
673
|
+
if (ch === "^") {
|
|
674
|
+
magic.add("exclude");
|
|
675
|
+
continue;
|
|
676
|
+
}
|
|
677
|
+
if (!SHORT_MAGIC.has(ch)) break;
|
|
678
|
+
const m = MAGIC.find((x) => x.mnemonic === ch);
|
|
679
|
+
if (!m) throw new PlumbingError(`fatal: Unimplemented pathspec magic '${ch}' in '${elem}'`);
|
|
680
|
+
magic.add(m.name);
|
|
681
|
+
}
|
|
682
|
+
if (elem[pos] === ":") pos++;
|
|
683
|
+
return { magic, rest: elem.slice(pos) };
|
|
684
|
+
}
|