@statewalker/vcs-commands 0.9.0 → 0.11.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.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 +41 -2
- package/dist/commands/am/am-command.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 +43 -1
- package/dist/commands/blame-command.d.ts.map +1 -1
- 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 +144 -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-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.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/cherry-pick-command.d.ts +10 -0
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +28 -0
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +9 -1
- 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 +54 -0
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +132 -5
- 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 +65 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fetch-multiple-command.d.ts.map +1 -1
- package/dist/commands/format-rev-command.d.ts +60 -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-ipc.d.ts +30 -0
- package/dist/commands/fsmonitor-ipc.d.ts.map +1 -0
- 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-hooks.d.ts +32 -0
- 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 +45 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +6 -5
- 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/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +26 -0
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +28 -1
- 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/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 +7 -0
- 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 +67 -5
- package/dist/commands/merge-drivers.d.ts.map +1 -1
- package/dist/commands/merge-support.d.ts +6 -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/mktag-command.d.ts +51 -0
- package/dist/commands/mktag-command.d.ts.map +1 -0
- 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/ort-merge.d.ts +24 -0
- package/dist/commands/ort-merge.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 +24 -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.map +1 -1
- package/dist/commands/push-command.d.ts +17 -2
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +108 -2
- 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/remote-object-info-command.d.ts +55 -0
- package/dist/commands/remote-object-info-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 +158 -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 -2
- package/dist/commands/reset-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 +3 -0
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/rev-parse-command.d.ts +5 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +10 -0
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +5 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +27 -1
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +18 -0
- package/dist/commands/sequencer-pick.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/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 +30 -2
- 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 +16 -2
- 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 +22 -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 +9 -1
- package/dist/commands/submodule-commands.d.ts.map +1 -1
- package/dist/commands/submodule-update-command.d.ts +27 -1
- package/dist/commands/submodule-update-command.d.ts.map +1 -1
- package/dist/commands/tag-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 +131 -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-CNvli5bl.js → commands-bQQ9OmCh.js} +52514 -44630
- package/dist/errors/command-errors.d.ts +33 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +39 -1
- package/dist/{fsck-CPeDh9fh.js → fsck-BHT9bUS-.js} +184 -143
- package/dist/git-command.d.ts +66 -4
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +532 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +3 -1
- package/dist/guarded-transport-command.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/maintenance-run-command-Cx2PlGV9.js +13544 -0
- package/dist/{remote-transport-CCmBadm-.js → remote-transport-BrQZfyHu.js} +1009 -10
- package/dist/results/cherry-pick-result.d.ts +6 -0
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/diff-entry.d.ts +10 -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 +49 -3
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/fetch-result.d.ts +12 -0
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/merge-result.d.ts +5 -0
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +5 -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-BDuEgdLU.js → results-CNHQnU5Y.js} +13707 -10608
- package/dist/transport-command.d.ts +79 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/commands/add-command.ts +3 -0
- package/src/commands/add-patch/patch-backend.ts +4 -1
- 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 +193 -22
- package/src/commands/apply/index.ts +1 -0
- 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 +118 -19
- 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 +895 -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-ref-format-command.ts +129 -0
- package/src/commands/checkout-command.ts +61 -22
- package/src/commands/checkout-index-command.ts +568 -0
- package/src/commands/checkout-paths.ts +7 -0
- package/src/commands/cherry-pick-command.ts +21 -1
- package/src/commands/clone-command.ts +249 -9
- package/src/commands/commit-command.ts +22 -4
- package/src/commands/config-command.ts +9 -0
- package/src/commands/daemon-access-hook.ts +78 -0
- package/src/commands/default-branch.ts +118 -1
- package/src/commands/diff-command.ts +592 -47
- 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 +312 -8
- package/src/commands/fetch-multiple-command.ts +4 -1
- package/src/commands/format-rev-command.ts +267 -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-ipc.ts +121 -0
- package/src/commands/fsmonitor-refresh.ts +320 -0
- package/src/commands/gc-command.ts +10 -0
- package/src/commands/git-hooks.ts +123 -6
- 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 +46 -0
- package/src/commands/init-command.ts +14 -0
- 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/local-transport.ts +252 -4
- package/src/commands/log-command.ts +104 -5
- package/src/commands/log-output.ts +66 -5
- 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 +708 -0
- package/src/commands/maintenance-run-command.ts +949 -0
- package/src/commands/merge-command.ts +78 -32
- package/src/commands/merge-config.ts +23 -1
- package/src/commands/merge-drivers.ts +109 -20
- package/src/commands/merge-support.ts +29 -5
- package/src/commands/merge-tree-command.ts +786 -0
- package/src/commands/mktag-command.ts +149 -0
- 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/ort-merge.ts +92 -25
- package/src/commands/patch-id-command.ts +65 -0
- package/src/commands/patch-id.ts +218 -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 +2 -0
- package/src/commands/push-command.ts +87 -5
- package/src/commands/rebase-command.ts +507 -19
- package/src/commands/refs-command.ts +274 -0
- package/src/commands/remote-object-info-command.ts +109 -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 +1066 -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 +75 -3
- package/src/commands/rev-filter/commit-grep.ts +7 -2
- package/src/commands/rev-list-command.ts +9 -0
- package/src/commands/rev-parse-command.ts +49 -5
- package/src/commands/revert-command.ts +21 -1
- package/src/commands/revision-range.ts +7 -2
- package/src/commands/revision-resolver.ts +97 -14
- package/src/commands/sequencer-pick.ts +47 -0
- package/src/commands/serve-repository.ts +65 -0
- package/src/commands/session-id.ts +31 -0
- package/src/commands/show-branch-command.ts +981 -0
- package/src/commands/show-command.ts +1 -1
- package/src/commands/show-ref-command.ts +439 -0
- package/src/commands/signature-check.ts +37 -5
- package/src/commands/signing.ts +176 -23
- package/src/commands/stash-apply-command.ts +3 -0
- package/src/commands/stash-export-command.ts +397 -0
- package/src/commands/status-command.ts +74 -8
- package/src/commands/stripspace-command.ts +118 -0
- package/src/commands/submodule-add-command.ts +40 -2
- package/src/commands/submodule-auth.ts +61 -6
- package/src/commands/submodule-commands.ts +12 -2
- package/src/commands/submodule-update-command.ts +47 -1
- package/src/commands/tag-command.ts +33 -11
- package/src/commands/textconv-cache.ts +143 -0
- package/src/commands/tree-restore.ts +14 -0
- package/src/commands/unpack-objects-command.ts +235 -0
- package/src/commands/update-index-command.ts +1148 -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/errors/command-errors.ts +45 -0
- package/src/git-command.ts +177 -3
- package/src/git.ts +808 -1
- package/src/guarded-transport-command.ts +6 -1
- package/src/results/cherry-pick-result.ts +6 -0
- package/src/results/diff-entry.ts +12 -0
- package/src/results/diff-formatter.ts +7 -4
- package/src/results/diff-output.ts +117 -11
- package/src/results/diff-pickaxe.ts +1 -1
- package/src/results/fetch-result.ts +12 -0
- package/src/results/merge-result.ts +5 -0
- package/src/results/push-result.ts +5 -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/transport-command.ts +182 -1
|
@@ -0,0 +1,895 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `git cat-file` (builtin/cat-file.c): an object's type, size, existence or content, one
|
|
3
|
+
* object named on the command line (`-t`, `-s`, `-e`, `-p`, `<type> <object>`) or many read
|
|
4
|
+
* from stdin (`--batch`, `--batch-check`, `--batch-command`, `--batch-all-objects`).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // git cat-file -p HEAD:README.md
|
|
9
|
+
* await git.catFile().setMode("pretty").setObject("HEAD:README.md").setStdout(write).call();
|
|
10
|
+
* // printf 'HEAD\nHEAD:a.txt\n' | git cat-file --batch-check
|
|
11
|
+
* const { stdout } = await git.catFile().setBatch("info").setStdin("HEAD\nHEAD:a.txt\n").callOutput();
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
type CompatObjects,
|
|
17
|
+
decodeTreeBytes,
|
|
18
|
+
type GitObjects,
|
|
19
|
+
type ObjectId,
|
|
20
|
+
} from "@statewalker/vcs-core";
|
|
21
|
+
import { ObjectInfoError } from "@statewalker/vcs-transport";
|
|
22
|
+
import { parseGitBool } from "@statewalker/vcs-utils";
|
|
23
|
+
import { decodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
24
|
+
import { RemoteConfigStore } from "../../remote-config/index.js";
|
|
25
|
+
import { quotePath } from "../../results/quote-path.js";
|
|
26
|
+
import { PlumbingCommand, PlumbingError } from "../plumbing-command.js";
|
|
27
|
+
import {
|
|
28
|
+
RemoteObjectInfoCommand,
|
|
29
|
+
type RemoteObjectInfoResult,
|
|
30
|
+
RemoteObjectInfoUnsupportedError,
|
|
31
|
+
} from "../remote-object-info-command.js";
|
|
32
|
+
import { applyMailmapToHeader } from "../rev-filter/index.js";
|
|
33
|
+
import type { RevisionResolver } from "../revision-resolver.js";
|
|
34
|
+
import {
|
|
35
|
+
type BatchFormat,
|
|
36
|
+
type BatchObjectData,
|
|
37
|
+
DEFAULT_BATCH_FORMAT,
|
|
38
|
+
expandBatchFormat,
|
|
39
|
+
parseBatchFormat,
|
|
40
|
+
} from "./batch-format.js";
|
|
41
|
+
|
|
42
|
+
/** `-t`, `-s`, `-e`, `-p`. */
|
|
43
|
+
export type CatFileMode = "type" | "size" | "exists" | "pretty";
|
|
44
|
+
|
|
45
|
+
/** `--batch` (contents), `--batch-check` (info), `--batch-command` (command). */
|
|
46
|
+
export type CatFileBatchMode = "contents" | "info" | "command";
|
|
47
|
+
|
|
48
|
+
/** What `--batch*` reads as stdin: text, bytes, or chunks read as they come. */
|
|
49
|
+
export type CatFileInput = string | Uint8Array | AsyncIterable<Uint8Array> | Iterable<Uint8Array>;
|
|
50
|
+
|
|
51
|
+
const OBJECT_TYPES = new Set(["blob", "tree", "commit", "tag"]);
|
|
52
|
+
const S_IFMT = 0o170000;
|
|
53
|
+
const S_IFGITLINK = 0o160000;
|
|
54
|
+
const encoder = new TextEncoder();
|
|
55
|
+
const MAILMAP_HEADERS = ["author ", "committer ", "tagger "].map((h) => encoder.encode(h));
|
|
56
|
+
/** git's `MAXREPLACEDEPTH` */
|
|
57
|
+
const MAX_REPLACE_DEPTH = 5;
|
|
58
|
+
|
|
59
|
+
interface ObjectInfo {
|
|
60
|
+
type: string;
|
|
61
|
+
size: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* `git cat-file`. Stdout goes to {@link setStdout} as git writes it: a blob's content is
|
|
66
|
+
* streamed chunk by chunk as the store reads it (never held whole), and `--batch` input is
|
|
67
|
+
* read line by line as {@link setStdin}'s chunks arrive, so a caller can feed names while it
|
|
68
|
+
* reads the answers.
|
|
69
|
+
*
|
|
70
|
+
* Replace refs apply as in git (`OBJECT_INFO_LOOKUP_REPLACE`): the name printed is the one
|
|
71
|
+
* asked, the type, size and content the replacement's; `--batch-all-objects` reads none.
|
|
72
|
+
*
|
|
73
|
+
* `--batch-command`'s `remote-object-info <remote> <id>...` (2.56) asks the remote's v2
|
|
74
|
+
* `object-info` through {@link setRemoteObjectInfo}'s command: only the atoms the server
|
|
75
|
+
* answered expand (`%(objectname)` always), and an object it lacks prints `<id> missing`.
|
|
76
|
+
*
|
|
77
|
+
* Not implemented: `--textconv`, `--filters`, `--path`, `--follow-symlinks`, `--filter`
|
|
78
|
+
* (2.5x), and the `%(objectsize:disk)` and `%(deltabase)` atoms (refused: the stores report
|
|
79
|
+
* neither; git's `remote-object-info` would print them empty). `--unordered` lists objects in
|
|
80
|
+
* the store's listing order, not pack order. The promisor-remote warning of
|
|
81
|
+
* `--batch-all-objects` is not printed.
|
|
82
|
+
*/
|
|
83
|
+
export class CatFileCommand extends PlumbingCommand {
|
|
84
|
+
private mode?: CatFileMode;
|
|
85
|
+
private type?: string;
|
|
86
|
+
private object?: string;
|
|
87
|
+
private batch?: CatFileBatchMode;
|
|
88
|
+
private format?: string;
|
|
89
|
+
private buffer?: boolean;
|
|
90
|
+
private nulInput = false;
|
|
91
|
+
private nulTerminated = false;
|
|
92
|
+
private allObjects = false;
|
|
93
|
+
private unordered = false;
|
|
94
|
+
private useMailmap = false;
|
|
95
|
+
private stdin?: CatFileInput;
|
|
96
|
+
private compatibility: "2.43" | "2.56" = "2.56";
|
|
97
|
+
|
|
98
|
+
/** `-t` (type), `-s` (size), `-e` (exists: exit 1 when absent), `-p` (pretty). */
|
|
99
|
+
setMode(mode: CatFileMode): this {
|
|
100
|
+
this.checkCallable();
|
|
101
|
+
this.mode = mode;
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** `<type> <object>`: the object peeled to this type (`blob`, `tree`, `commit`, `tag`). */
|
|
106
|
+
setType(type: string): this {
|
|
107
|
+
this.checkCallable();
|
|
108
|
+
this.type = type;
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** The object named on the command line. */
|
|
113
|
+
setObject(name: string): this {
|
|
114
|
+
this.checkCallable();
|
|
115
|
+
this.object = name;
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* `--batch[=<format>]` (`contents`), `--batch-check[=<format>]` (`info`),
|
|
121
|
+
* `--batch-command[=<format>]` (`command`).
|
|
122
|
+
*/
|
|
123
|
+
setBatch(mode: CatFileBatchMode, format?: string): this {
|
|
124
|
+
this.checkCallable();
|
|
125
|
+
this.batch = mode;
|
|
126
|
+
this.format = format;
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** `--buffer` (`--batch-command`'s `flush` needs it; output itself is the same). */
|
|
131
|
+
setBuffer(buffer: boolean): this {
|
|
132
|
+
this.checkCallable();
|
|
133
|
+
this.buffer = buffer;
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** `-z`: stdin is NUL-terminated. */
|
|
138
|
+
setNulInput(nul: boolean): this {
|
|
139
|
+
this.checkCallable();
|
|
140
|
+
this.nulInput = nul;
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** `-Z`: stdin and stdout are NUL-terminated. */
|
|
145
|
+
setNulTerminated(nul: boolean): this {
|
|
146
|
+
this.checkCallable();
|
|
147
|
+
this.nulTerminated = nul;
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** `--batch-all-objects`: every object of the repository, stdin ignored. */
|
|
152
|
+
setBatchAllObjects(all: boolean): this {
|
|
153
|
+
this.checkCallable();
|
|
154
|
+
this.allObjects = all;
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** `--unordered` (with `--batch-all-objects`): the store's order, not sorted by id. */
|
|
159
|
+
setUnordered(unordered: boolean): this {
|
|
160
|
+
this.checkCallable();
|
|
161
|
+
this.unordered = unordered;
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The `remote-object-info` command a `--batch-command` line runs (default: one over the
|
|
167
|
+
* default transports; `Git.catFile()` gives the facade's): its credentials and transports.
|
|
168
|
+
*/
|
|
169
|
+
setRemoteObjectInfo(factory: () => RemoteObjectInfoCommand): this {
|
|
170
|
+
this.checkCallable();
|
|
171
|
+
this.remoteObjectInfoFactory = factory;
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private remoteObjectInfoFactory?: () => RemoteObjectInfoCommand;
|
|
176
|
+
|
|
177
|
+
/** `--use-mailmap`: idents of commits and tags mapped through the mailmap. */
|
|
178
|
+
setUseMailmap(use: boolean): this {
|
|
179
|
+
this.checkCallable();
|
|
180
|
+
this.useMailmap = use;
|
|
181
|
+
return this;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** The batch modes' stdin. */
|
|
185
|
+
setStdin(input: CatFileInput): this {
|
|
186
|
+
this.checkCallable();
|
|
187
|
+
this.stdin = input;
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** The git version whose behaviour to follow (default 2.56). */
|
|
192
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
193
|
+
this.checkCallable();
|
|
194
|
+
this.compatibility = version;
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
protected override writesNoObjects(): boolean {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
protected async run(): Promise<number> {
|
|
203
|
+
this.checkOptions();
|
|
204
|
+
if (this.batch) return this.runBatch();
|
|
205
|
+
return this.catOne(this.object as string);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** The option checks of cmd_cat_file that the setters can still break. */
|
|
209
|
+
private checkOptions(): void {
|
|
210
|
+
const usage = (message: string) => new PlumbingError(`fatal: ${message}`, 129);
|
|
211
|
+
if (this.batch) {
|
|
212
|
+
if (this.mode) throw usage(`'-${modeLetter(this.mode)}' is incompatible with batch mode`);
|
|
213
|
+
if (this.object !== undefined || this.type !== undefined) {
|
|
214
|
+
throw usage("batch modes take no arguments");
|
|
215
|
+
}
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const batchOption =
|
|
219
|
+
this.buffer !== undefined
|
|
220
|
+
? "--buffer"
|
|
221
|
+
: this.allObjects
|
|
222
|
+
? "--batch-all-objects"
|
|
223
|
+
: this.nulInput
|
|
224
|
+
? "-z"
|
|
225
|
+
: this.nulTerminated
|
|
226
|
+
? "-Z"
|
|
227
|
+
: undefined;
|
|
228
|
+
if (batchOption) throw usage(`'${batchOption}' requires a batch mode`);
|
|
229
|
+
if (this.mode) {
|
|
230
|
+
if (this.object === undefined) {
|
|
231
|
+
throw usage(`<object> required with '-${modeLetter(this.mode)}'`);
|
|
232
|
+
}
|
|
233
|
+
if (this.type !== undefined) throw usage("too many arguments");
|
|
234
|
+
} else if (this.object === undefined || this.type === undefined) {
|
|
235
|
+
throw usage("only two arguments allowed in <type> <object> mode, not 1");
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
private get objects(): GitObjects {
|
|
240
|
+
const objects = this._workingCopy.history?.objects;
|
|
241
|
+
if (!objects) throw new Error("WorkingCopy.history is required for commands");
|
|
242
|
+
return objects;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** `lookup_replace_object`: the object reads go to. */
|
|
246
|
+
private async replaced(id: ObjectId): Promise<ObjectId> {
|
|
247
|
+
const replacements = await this.objectReplacements();
|
|
248
|
+
if (!replacements) return id;
|
|
249
|
+
let current = id;
|
|
250
|
+
for (let depth = 0; ; depth++) {
|
|
251
|
+
const next = replacements.replace.get(current);
|
|
252
|
+
if (next === undefined) return current;
|
|
253
|
+
if (depth >= MAX_REPLACE_DEPTH) {
|
|
254
|
+
throw new PlumbingError(`fatal: replace depth too high for object ${id}`);
|
|
255
|
+
}
|
|
256
|
+
current = next;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** `oid_object_info`: type and size from the headers, else from a read. */
|
|
261
|
+
private async info(id: ObjectId): Promise<ObjectInfo | undefined> {
|
|
262
|
+
const objects = this.objects;
|
|
263
|
+
const header = await objects.header?.(id).catch(() => undefined);
|
|
264
|
+
if (header) return header;
|
|
265
|
+
const object = await objects.get(id).catch(() => undefined);
|
|
266
|
+
if (!object) return undefined;
|
|
267
|
+
await object.content[Symbol.asyncIterator]().return?.();
|
|
268
|
+
return { type: object.type, size: object.size };
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** The whole content of a (small) object. */
|
|
272
|
+
private async read(id: ObjectId): Promise<{ type: string; bytes: Uint8Array } | undefined> {
|
|
273
|
+
const object = await this.objects.get(id).catch(() => undefined);
|
|
274
|
+
if (!object) return undefined;
|
|
275
|
+
if (object.bytes) {
|
|
276
|
+
await object.content[Symbol.asyncIterator]().return?.();
|
|
277
|
+
return { type: object.type, bytes: object.bytes };
|
|
278
|
+
}
|
|
279
|
+
const chunks: Uint8Array[] = [];
|
|
280
|
+
for await (const c of object.content) chunks.push(c.slice());
|
|
281
|
+
return { type: object.type, bytes: concat(chunks) };
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** `stream_blob`: the blob's content written chunk by chunk. */
|
|
285
|
+
private async streamBlob(id: ObjectId): Promise<void> {
|
|
286
|
+
const object = await this.objects.get(id).catch(() => undefined);
|
|
287
|
+
if (!object) throw new PlumbingError(`fatal: unable to stream ${id} to stdout`);
|
|
288
|
+
for await (const chunk of object.content) await this.write(chunk.slice());
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
private mailmapped?: Promise<(bytes: Uint8Array) => Uint8Array>;
|
|
292
|
+
|
|
293
|
+
/** `replace_idents_using_mailmap` (identity without `--use-mailmap`). */
|
|
294
|
+
private async mapIdents(bytes: Uint8Array): Promise<Uint8Array> {
|
|
295
|
+
if (!this.useMailmap) return bytes;
|
|
296
|
+
this.mailmapped ??= this.readMailmap().then(
|
|
297
|
+
(mailmap) => (raw: Uint8Array) => applyMailmapToHeader(raw, mailmap, MAILMAP_HEADERS),
|
|
298
|
+
);
|
|
299
|
+
return (await this.mailmapped)(bytes);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** cat_one_file */
|
|
303
|
+
private async catOne(name: string): Promise<number> {
|
|
304
|
+
const resolver = this.revisionResolver();
|
|
305
|
+
let id: ObjectId | undefined;
|
|
306
|
+
try {
|
|
307
|
+
// GET_OID_HASH_ANY: an id of the compatibility format (full or abbreviated) names the
|
|
308
|
+
// object as that format sees it (its storage object converted)
|
|
309
|
+
id = await resolver.resolve(name, { onlyToDie: true, hashAny: true });
|
|
310
|
+
} finally {
|
|
311
|
+
for (const line of resolver.warnings) this.warn(line);
|
|
312
|
+
resolver.warnings.length = 0;
|
|
313
|
+
}
|
|
314
|
+
if (id === undefined) throw new PlumbingError(`fatal: Not a valid object name ${name}`);
|
|
315
|
+
const compat = this.compatIdOf(id);
|
|
316
|
+
if (compat) return this.catOneCompat(id, compat);
|
|
317
|
+
const couldNotGetInfo = () =>
|
|
318
|
+
new PlumbingError("fatal: git cat-file: could not get object info");
|
|
319
|
+
switch (this.mode) {
|
|
320
|
+
case "type": {
|
|
321
|
+
const info = await this.info(await this.replaced(id));
|
|
322
|
+
if (!info) throw couldNotGetInfo();
|
|
323
|
+
await this.write(`${info.type}\n`);
|
|
324
|
+
return 0;
|
|
325
|
+
}
|
|
326
|
+
case "size": {
|
|
327
|
+
const target = await this.replaced(id);
|
|
328
|
+
const info = await this.info(target);
|
|
329
|
+
if (!info) throw couldNotGetInfo();
|
|
330
|
+
let size = info.size;
|
|
331
|
+
if (this.useMailmap && (info.type === "commit" || info.type === "tag")) {
|
|
332
|
+
const object = await this.read(target);
|
|
333
|
+
if (object) size = (await this.mapIdents(object.bytes)).length;
|
|
334
|
+
}
|
|
335
|
+
await this.write(`${size}\n`);
|
|
336
|
+
return 0;
|
|
337
|
+
}
|
|
338
|
+
case "exists":
|
|
339
|
+
return (await this.objects.has(id)) ? 0 : 1;
|
|
340
|
+
case "pretty":
|
|
341
|
+
return this.pretty(name, await this.replaced(id));
|
|
342
|
+
default:
|
|
343
|
+
return this.catTyped(name, id, this.type as string);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** The compatibility objects when `id` is an id of the compatibility format (not storage's) */
|
|
348
|
+
private compatIdOf(id: ObjectId): CompatObjects | undefined {
|
|
349
|
+
const compat = this.compatObjects;
|
|
350
|
+
return compat && id.length !== this.objectFormat.hexLength ? compat : undefined;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* cat_one_file for an id of the compatibility format: the object read through the map and
|
|
355
|
+
* converted (`odb_read_object_info_extended` with an id of the other format).
|
|
356
|
+
*/
|
|
357
|
+
private async catOneCompat(name: string, compat: CompatObjects): Promise<number> {
|
|
358
|
+
const read = (id: string) => compat.readAsCompat(id);
|
|
359
|
+
if (this.mode === "exists")
|
|
360
|
+
return (await compat.toStorage(name)) !== undefined && (await read(name)) !== undefined
|
|
361
|
+
? 0
|
|
362
|
+
: 1;
|
|
363
|
+
const object = await read(name);
|
|
364
|
+
if (!object) {
|
|
365
|
+
if (this.mode === "type" || this.mode === "size") {
|
|
366
|
+
throw new PlumbingError("fatal: git cat-file: could not get object info");
|
|
367
|
+
}
|
|
368
|
+
throw new PlumbingError(`fatal: Not a valid object name ${name}`);
|
|
369
|
+
}
|
|
370
|
+
switch (this.mode) {
|
|
371
|
+
case "type":
|
|
372
|
+
await this.write(`${object.type}\n`);
|
|
373
|
+
return 0;
|
|
374
|
+
case "size":
|
|
375
|
+
await this.write(`${object.content.length}\n`);
|
|
376
|
+
return 0;
|
|
377
|
+
case "pretty":
|
|
378
|
+
if (object.type === "tree") {
|
|
379
|
+
const config = RemoteConfigStore.from(this._workingCopy);
|
|
380
|
+
const quoteFully = parseGitBool(config.value("core.quotePath")) ?? true;
|
|
381
|
+
let out = "";
|
|
382
|
+
for (const entry of decodeTreeBytes(object.content, {
|
|
383
|
+
idLength: compat.compat.rawLength,
|
|
384
|
+
checkNames: false,
|
|
385
|
+
})) {
|
|
386
|
+
const kind = entry.mode & S_IFMT;
|
|
387
|
+
const type = kind === 0o040000 ? "tree" : kind === S_IFGITLINK ? "commit" : "blob";
|
|
388
|
+
const mode = entry.mode.toString(8).padStart(6, "0");
|
|
389
|
+
out += `${mode} ${type} ${entry.id}\t${quotePath(entry.name, quoteFully)}\n`;
|
|
390
|
+
}
|
|
391
|
+
await this.write(out);
|
|
392
|
+
return 0;
|
|
393
|
+
}
|
|
394
|
+
await this.write(
|
|
395
|
+
object.type === "blob" ? object.content : await this.mapIdents(object.content),
|
|
396
|
+
);
|
|
397
|
+
return 0;
|
|
398
|
+
default: {
|
|
399
|
+
const type = this.type as string;
|
|
400
|
+
if (!OBJECT_TYPES.has(type)) {
|
|
401
|
+
throw new PlumbingError(`fatal: invalid object type "${type}"`);
|
|
402
|
+
}
|
|
403
|
+
// odb_read_object_peeled, through the compatibility ids
|
|
404
|
+
let current: { type: string; content: Uint8Array } | undefined = object;
|
|
405
|
+
while (current && current.type !== type) {
|
|
406
|
+
const text = new TextDecoder().decode(current.content.subarray(0, 200));
|
|
407
|
+
let next: RegExpExecArray | null = null;
|
|
408
|
+
if (current.type === "tag") next = /^object ([0-9a-f]+)/.exec(text);
|
|
409
|
+
else if (current.type === "commit" && type === "tree") {
|
|
410
|
+
next = /^tree ([0-9a-f]+)/.exec(text);
|
|
411
|
+
}
|
|
412
|
+
current = next ? await read(next[1] as string) : undefined;
|
|
413
|
+
}
|
|
414
|
+
if (!current) throw new PlumbingError(`fatal: git cat-file ${name}: bad file`);
|
|
415
|
+
await this.write(
|
|
416
|
+
current.type === "blob" ? current.content : await this.mapIdents(current.content),
|
|
417
|
+
);
|
|
418
|
+
return 0;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** `-p` */
|
|
424
|
+
private async pretty(name: string, id: ObjectId): Promise<number> {
|
|
425
|
+
const info = await this.info(id);
|
|
426
|
+
if (!info) throw new PlumbingError(`fatal: Not a valid object name ${name}`);
|
|
427
|
+
if (info.type === "tree") {
|
|
428
|
+
await this.listTree(id);
|
|
429
|
+
return 0;
|
|
430
|
+
}
|
|
431
|
+
if (info.type === "blob") {
|
|
432
|
+
await this.streamBlob(id);
|
|
433
|
+
return 0;
|
|
434
|
+
}
|
|
435
|
+
const object = await this.read(id);
|
|
436
|
+
if (!object) throw new PlumbingError(`fatal: Cannot read object ${name}`);
|
|
437
|
+
await this.write(await this.mapIdents(object.bytes));
|
|
438
|
+
return 0;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/** `git ls-tree <tree>`, as `-p` prints a tree. */
|
|
442
|
+
private async listTree(id: ObjectId): Promise<void> {
|
|
443
|
+
const config = RemoteConfigStore.from(this._workingCopy);
|
|
444
|
+
const quoteFully = parseGitBool(config.value("core.quotePath")) ?? true;
|
|
445
|
+
const entries = await this.listedTreeEntries(id);
|
|
446
|
+
if (!entries) throw new PlumbingError(`fatal: Cannot read object ${id}`);
|
|
447
|
+
let out = "";
|
|
448
|
+
for (const entry of entries) {
|
|
449
|
+
const kind = entry.mode & S_IFMT;
|
|
450
|
+
const type = kind === 0o040000 ? "tree" : kind === S_IFGITLINK ? "commit" : "blob";
|
|
451
|
+
const mode = entry.mode.toString(8).padStart(6, "0");
|
|
452
|
+
out += `${mode} ${type} ${entry.id}\t${quotePath(entry.name, quoteFully)}\n`;
|
|
453
|
+
if (out.length >= 1 << 16) {
|
|
454
|
+
await this.write(out);
|
|
455
|
+
out = "";
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
await this.write(out);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** `<type> <object>` */
|
|
462
|
+
private async catTyped(name: string, id: ObjectId, type: string): Promise<number> {
|
|
463
|
+
if (!OBJECT_TYPES.has(type)) throw new PlumbingError(`fatal: invalid object type "${type}"`);
|
|
464
|
+
if (type === "blob") {
|
|
465
|
+
let blob = id;
|
|
466
|
+
const target = await this.replaced(id);
|
|
467
|
+
if ((await this.info(target))?.type === "tag") {
|
|
468
|
+
const tag = await this.read(target);
|
|
469
|
+
const match = tag && /^object ([0-9a-f]+)/.exec(new TextDecoder().decode(tag.bytes));
|
|
470
|
+
if (!match || !this.isFullObjectId(match[1] as string)) {
|
|
471
|
+
throw new PlumbingError(`fatal: ${id} not a valid tag`);
|
|
472
|
+
}
|
|
473
|
+
blob = match[1] as string;
|
|
474
|
+
}
|
|
475
|
+
const blobTarget = await this.replaced(blob);
|
|
476
|
+
if ((await this.info(blobTarget))?.type === "blob") {
|
|
477
|
+
await this.streamBlob(blobTarget);
|
|
478
|
+
return 0;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
const bytes = await this.peeled(id, type);
|
|
482
|
+
if (!bytes) throw new PlumbingError(`fatal: git cat-file ${name}: bad file`);
|
|
483
|
+
await this.write(await this.mapIdents(bytes));
|
|
484
|
+
return 0;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** `odb_read_object_peeled`: tags followed, a commit's tree for a tree. */
|
|
488
|
+
private async peeled(id: ObjectId, type: string): Promise<Uint8Array | undefined> {
|
|
489
|
+
let current = id;
|
|
490
|
+
for (;;) {
|
|
491
|
+
const object = await this.read(await this.replaced(current));
|
|
492
|
+
if (!object) return undefined;
|
|
493
|
+
if (object.type === type) return object.bytes;
|
|
494
|
+
const text = new TextDecoder().decode(object.bytes.subarray(0, 200));
|
|
495
|
+
let next: RegExpExecArray | null = null;
|
|
496
|
+
if (object.type === "tag") next = /^object ([0-9a-f]+)/.exec(text);
|
|
497
|
+
else if (object.type === "commit" && type === "tree") next = /^tree ([0-9a-f]+)/.exec(text);
|
|
498
|
+
if (!next || !this.isFullObjectId(next[1] as string)) return undefined;
|
|
499
|
+
current = next[1] as string;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/** batch_objects */
|
|
504
|
+
private async runBatch(): Promise<number> {
|
|
505
|
+
const compatibility = this.compatibility;
|
|
506
|
+
// --batch-command defers %(objectsize:disk)/%(deltabase) to the first local object: a
|
|
507
|
+
// remote-object-info line prints them empty, as git
|
|
508
|
+
const format = parseBatchFormat(this.format ?? DEFAULT_BATCH_FORMAT, compatibility, {
|
|
509
|
+
deferUnsupported: this.batch === "command",
|
|
510
|
+
});
|
|
511
|
+
const plain = this.format === undefined || this.format === DEFAULT_BATCH_FORMAT;
|
|
512
|
+
const state: BatchState = {
|
|
513
|
+
format,
|
|
514
|
+
plain,
|
|
515
|
+
delim: this.nulTerminated ? "\0" : "\n",
|
|
516
|
+
contents: this.batch === "contents",
|
|
517
|
+
replace: !this.allObjects,
|
|
518
|
+
};
|
|
519
|
+
if (this.allObjects) {
|
|
520
|
+
const ids: ObjectId[] = [];
|
|
521
|
+
for await (const id of this.objects.list()) ids.push(id);
|
|
522
|
+
const listed = this.unordered ? ids : [...new Set(ids)].sort();
|
|
523
|
+
const seen = new Set<ObjectId>();
|
|
524
|
+
for (const id of listed) {
|
|
525
|
+
if (seen.has(id)) continue;
|
|
526
|
+
seen.add(id);
|
|
527
|
+
await this.batchObjectWrite(state, undefined, { id });
|
|
528
|
+
}
|
|
529
|
+
return 0;
|
|
530
|
+
}
|
|
531
|
+
const resolver = this.revisionResolver();
|
|
532
|
+
const lines = readLines(this.stdin ?? "", this.nulTerminated || this.nulInput ? 0 : 0x0a);
|
|
533
|
+
if (this.batch === "command") {
|
|
534
|
+
await this.batchCommands(state, resolver, lines);
|
|
535
|
+
return 0;
|
|
536
|
+
}
|
|
537
|
+
for await (const line of lines) {
|
|
538
|
+
let name = line;
|
|
539
|
+
let rest: string | undefined;
|
|
540
|
+
if (format.splitOnWhitespace) {
|
|
541
|
+
const split = /[ \t]/.exec(line);
|
|
542
|
+
if (split) {
|
|
543
|
+
name = line.slice(0, split.index);
|
|
544
|
+
rest = line.slice(split.index).replace(/^[ \t]+/, "");
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
await this.batchOne(state, resolver, name, rest);
|
|
548
|
+
}
|
|
549
|
+
return 0;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/** batch_objects_command: `contents`, `info`, `flush` (and 2.5x's `mailmap`). */
|
|
553
|
+
private async batchCommands(
|
|
554
|
+
state: BatchState,
|
|
555
|
+
resolver: RevisionResolver,
|
|
556
|
+
lines: AsyncIterable<string>,
|
|
557
|
+
): Promise<void> {
|
|
558
|
+
const buffer = this.buffer ?? false;
|
|
559
|
+
const commands =
|
|
560
|
+
this.compatibility === "2.43"
|
|
561
|
+
? [
|
|
562
|
+
["contents", true],
|
|
563
|
+
["info", true],
|
|
564
|
+
["flush", false],
|
|
565
|
+
]
|
|
566
|
+
: [
|
|
567
|
+
["contents", true],
|
|
568
|
+
["flush", false],
|
|
569
|
+
["info", true],
|
|
570
|
+
["mailmap", true],
|
|
571
|
+
["remote-object-info", true],
|
|
572
|
+
];
|
|
573
|
+
const queue: { name: string; arg: string }[] = [];
|
|
574
|
+
const dispatch = async (name: string, arg: string) => {
|
|
575
|
+
if (name === "mailmap") {
|
|
576
|
+
const value = parseGitBool(arg);
|
|
577
|
+
if (value === undefined)
|
|
578
|
+
throw new PlumbingError(`fatal: mailmap: invalid boolean '${arg}'`);
|
|
579
|
+
this.useMailmap = value;
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
if (name === "remote-object-info") {
|
|
583
|
+
await this.remoteObjectInfo(state, arg);
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
await this.batchOne({ ...state, contents: name === "contents" }, resolver, arg, undefined);
|
|
587
|
+
};
|
|
588
|
+
const flush = async () => {
|
|
589
|
+
if (!buffer) throw new PlumbingError("fatal: flush is only for --buffer mode");
|
|
590
|
+
for (const call of queue.splice(0)) await dispatch(call.name, call.arg);
|
|
591
|
+
};
|
|
592
|
+
for await (const line of lines) {
|
|
593
|
+
if (line === "") throw new PlumbingError("fatal: empty command in input");
|
|
594
|
+
if (/^[ \t\n\v\f\r]/.test(line)) {
|
|
595
|
+
throw new PlumbingError(`fatal: whitespace before command: '${line}'`);
|
|
596
|
+
}
|
|
597
|
+
let found: { name: string; arg: string } | undefined;
|
|
598
|
+
for (const [name, takesArgs] of commands as [string, boolean][]) {
|
|
599
|
+
if (!line.startsWith(name)) continue;
|
|
600
|
+
const end = line.slice(name.length);
|
|
601
|
+
if (takesArgs) {
|
|
602
|
+
if (end[0] !== " ") throw new PlumbingError(`fatal: ${name} requires arguments`);
|
|
603
|
+
} else if (end !== "") {
|
|
604
|
+
throw new PlumbingError(`fatal: ${name} takes no arguments`);
|
|
605
|
+
}
|
|
606
|
+
found = { name, arg: end.slice(1) };
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
if (!found) throw new PlumbingError(`fatal: unknown command: '${line}'`);
|
|
610
|
+
if (found.name === "flush") await flush();
|
|
611
|
+
else if (!buffer) await dispatch(found.name, found.arg);
|
|
612
|
+
else queue.push(found);
|
|
613
|
+
}
|
|
614
|
+
if (buffer && queue.length > 0) await flush();
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* parse_cmd_remote_object_info: `<remote> <id>...` split as git's `split_cmdline` (quotes
|
|
619
|
+
* and backslashes), the ids checked before the remote is asked, then one line per id in
|
|
620
|
+
* order: `<id> missing` for an object the server lacks, else the format with only the
|
|
621
|
+
* atoms the server answered (the default format prints the type and size it got).
|
|
622
|
+
*/
|
|
623
|
+
private async remoteObjectInfo(state: BatchState, line: string): Promise<void> {
|
|
624
|
+
if (line.length >= MAX_REMOTE_OBJ_INFO_LINE) {
|
|
625
|
+
throw new PlumbingError("fatal: remote-object-info command too long");
|
|
626
|
+
}
|
|
627
|
+
const argv = splitCmdline(line);
|
|
628
|
+
if (typeof argv === "string") {
|
|
629
|
+
throw new PlumbingError(`fatal: remote-object-info: failed to parse command line: ${argv}`);
|
|
630
|
+
}
|
|
631
|
+
if (argv.length - 1 > MAX_ALLOWED_OBJ_LIMIT) {
|
|
632
|
+
throw new PlumbingError(
|
|
633
|
+
`fatal: remote-object-info supports at most ${MAX_ALLOWED_OBJ_LIMIT} objects`,
|
|
634
|
+
);
|
|
635
|
+
}
|
|
636
|
+
// get_remote_info: get_oid_hex reads the first hexsz digits (any case) and nothing after
|
|
637
|
+
const hexLength = this.objectFormat.hexLength;
|
|
638
|
+
const ids: string[] = [];
|
|
639
|
+
for (const arg of argv.slice(1)) {
|
|
640
|
+
const head = arg.slice(0, hexLength);
|
|
641
|
+
if (head.length === hexLength && /^[0-9a-fA-F]+$/.test(head)) {
|
|
642
|
+
ids.push(head.toLowerCase());
|
|
643
|
+
continue;
|
|
644
|
+
}
|
|
645
|
+
if (arg.length < hexLength && arg.length >= 4 && /^[0-9a-fA-F]+$/.test(arg)) {
|
|
646
|
+
throw new PlumbingError(
|
|
647
|
+
`fatal: remote-object-info does not support short oids, ${hexLength} characters required`,
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
throw new PlumbingError(`fatal: not a valid object name '${arg}'`);
|
|
651
|
+
}
|
|
652
|
+
if (ids.length === 0) throw new PlumbingError("fatal: remote-object-info requires objects");
|
|
653
|
+
const command = (
|
|
654
|
+
this.remoteObjectInfoFactory?.() ?? new RemoteObjectInfoCommand(this.workingCopy)
|
|
655
|
+
)
|
|
656
|
+
.setRemote(argv[0] as string)
|
|
657
|
+
.setSize(state.plain || state.format.needsSize)
|
|
658
|
+
.setType(state.plain || state.format.needsType);
|
|
659
|
+
for (const id of ids) command.addObjectId(id);
|
|
660
|
+
let answer: RemoteObjectInfoResult;
|
|
661
|
+
try {
|
|
662
|
+
answer = await command.call();
|
|
663
|
+
} catch (error) {
|
|
664
|
+
if (error instanceof ObjectInfoError || error instanceof RemoteObjectInfoUnsupportedError) {
|
|
665
|
+
throw new PlumbingError(`fatal: ${error.message}`);
|
|
666
|
+
}
|
|
667
|
+
throw error;
|
|
668
|
+
}
|
|
669
|
+
const remote = { size: answer.size, type: answer.type };
|
|
670
|
+
for (const object of answer.objects) {
|
|
671
|
+
if (object.missing) {
|
|
672
|
+
await this.write(`${object.id} missing${state.delim}`);
|
|
673
|
+
continue;
|
|
674
|
+
}
|
|
675
|
+
const data: BatchObjectData = {
|
|
676
|
+
id: object.id,
|
|
677
|
+
...(object.type !== undefined ? { type: object.type } : {}),
|
|
678
|
+
...(object.size !== undefined ? { size: object.size } : {}),
|
|
679
|
+
};
|
|
680
|
+
await this.write(
|
|
681
|
+
state.plain
|
|
682
|
+
? `${data.id} ${data.type ?? ""} ${data.size ?? 0}${state.delim}`
|
|
683
|
+
: `${expandBatchFormat(state.format, data, remote)}${state.delim}`,
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/** batch_one_object */
|
|
689
|
+
private async batchOne(
|
|
690
|
+
state: BatchState,
|
|
691
|
+
resolver: RevisionResolver,
|
|
692
|
+
name: string,
|
|
693
|
+
rest: string | undefined,
|
|
694
|
+
): Promise<void> {
|
|
695
|
+
let id: ObjectId | undefined;
|
|
696
|
+
try {
|
|
697
|
+
id = await resolver.resolve(name, { hashAny: true });
|
|
698
|
+
} finally {
|
|
699
|
+
for (const line of resolver.warnings) this.warn(line);
|
|
700
|
+
}
|
|
701
|
+
const ambiguous = resolver.warnings.some((l) => l.startsWith("error: short object ID "));
|
|
702
|
+
resolver.warnings.length = 0;
|
|
703
|
+
if (id === undefined) {
|
|
704
|
+
await this.write(`${name} ${ambiguous ? "ambiguous" : "missing"}${state.delim}`);
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
await this.batchObjectWrite(state, name, {
|
|
708
|
+
id,
|
|
709
|
+
...(resolver.lastMode !== undefined ? { mode: resolver.lastMode } : {}),
|
|
710
|
+
...(rest !== undefined ? { rest } : {}),
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* batch_object_write for an id of the compatibility format (`GET_OID_HASH_ANY` in
|
|
716
|
+
* batch_one_object): the object read through the map and converted, so its id, type, size
|
|
717
|
+
* and content are the compatibility format's. Replace refs are storage ids: they do not
|
|
718
|
+
* apply to it.
|
|
719
|
+
*/
|
|
720
|
+
private async batchCompatWrite(
|
|
721
|
+
state: BatchState,
|
|
722
|
+
name: string | undefined,
|
|
723
|
+
data: BatchObjectData,
|
|
724
|
+
compat: CompatObjects,
|
|
725
|
+
): Promise<void> {
|
|
726
|
+
const object = await compat.readAsCompat(data.id);
|
|
727
|
+
if (!object) {
|
|
728
|
+
await this.write(`${name ?? data.id} missing${state.delim}`);
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
let content = object.content;
|
|
732
|
+
if (this.useMailmap && (object.type === "commit" || object.type === "tag")) {
|
|
733
|
+
content = await this.mapIdents(content);
|
|
734
|
+
}
|
|
735
|
+
data.type = object.type;
|
|
736
|
+
data.size = content.length;
|
|
737
|
+
const header = state.plain
|
|
738
|
+
? `${data.id} ${data.type} ${data.size}${state.delim}`
|
|
739
|
+
: `${expandBatchFormat(state.format, data)}${state.delim}`;
|
|
740
|
+
await this.write(header);
|
|
741
|
+
if (!state.contents) return;
|
|
742
|
+
await this.write(content);
|
|
743
|
+
await this.write(state.delim);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/** batch_object_write */
|
|
747
|
+
private async batchObjectWrite(
|
|
748
|
+
state: BatchState,
|
|
749
|
+
name: string | undefined,
|
|
750
|
+
data: BatchObjectData,
|
|
751
|
+
): Promise<void> {
|
|
752
|
+
const compat = this.compatIdOf(data.id);
|
|
753
|
+
if (compat) return this.batchCompatWrite(state, name, data, compat);
|
|
754
|
+
const target = state.replace ? await this.replaced(data.id) : data.id;
|
|
755
|
+
const info = await this.info(target);
|
|
756
|
+
if (!info) {
|
|
757
|
+
if (this.compatibility !== "2.43" && data.mode !== undefined) {
|
|
758
|
+
if ((data.mode & S_IFMT) === S_IFGITLINK) {
|
|
759
|
+
await this.write(`${data.id} submodule${state.delim}`);
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
await this.write(`${name ?? data.id} missing${state.delim}`);
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
data.type = info.type;
|
|
767
|
+
data.size = info.size;
|
|
768
|
+
let content: Uint8Array | undefined;
|
|
769
|
+
if (this.useMailmap && (info.type === "commit" || info.type === "tag")) {
|
|
770
|
+
const object = await this.read(target);
|
|
771
|
+
if (!object) throw new PlumbingError(`fatal: unable to read ${data.id}`);
|
|
772
|
+
content = await this.mapIdents(object.bytes);
|
|
773
|
+
data.size = content.length;
|
|
774
|
+
}
|
|
775
|
+
const header = state.plain
|
|
776
|
+
? `${data.id} ${data.type} ${data.size}${state.delim}`
|
|
777
|
+
: `${expandBatchFormat(state.format, data)}${state.delim}`;
|
|
778
|
+
await this.write(header);
|
|
779
|
+
if (!state.contents) return;
|
|
780
|
+
if (info.type === "blob") {
|
|
781
|
+
await this.streamBlob(target);
|
|
782
|
+
} else {
|
|
783
|
+
if (!content) {
|
|
784
|
+
const object = await this.read(target);
|
|
785
|
+
if (!object) throw new PlumbingError(`fatal: object ${data.id} disappeared`);
|
|
786
|
+
content = object.bytes;
|
|
787
|
+
}
|
|
788
|
+
await this.write(content);
|
|
789
|
+
}
|
|
790
|
+
await this.write(state.delim);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
interface BatchState {
|
|
795
|
+
format: BatchFormat;
|
|
796
|
+
/** No format, or the default one: git's print_default_format */
|
|
797
|
+
plain: boolean;
|
|
798
|
+
delim: string;
|
|
799
|
+
/** `--batch`, or a `contents` command: the content follows the header */
|
|
800
|
+
contents: boolean;
|
|
801
|
+
/** Replace refs apply (not under `--batch-all-objects`) */
|
|
802
|
+
replace: boolean;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/** cat-file.c's MAX_ALLOWED_OBJ_LIMIT: ids one remote-object-info line may ask about. */
|
|
806
|
+
const MAX_ALLOWED_OBJ_LIMIT = 10000;
|
|
807
|
+
|
|
808
|
+
/** cat-file.c's MAX_REMOTE_OBJ_INFO_LINE: a URL of 8 KiB and the ids (GIT_MAX_HEXSZ + 1 each). */
|
|
809
|
+
const MAX_REMOTE_OBJ_INFO_LINE = 8 * 1024 + MAX_ALLOWED_OBJ_LIMIT * (64 + 1);
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* alias.c's split_cmdline: words split on whitespace, quotes removed, a backslash escaping
|
|
813
|
+
* the next character outside single quotes; split_cmdline_strerror's text on an error.
|
|
814
|
+
*/
|
|
815
|
+
function splitCmdline(line: string): string[] | string {
|
|
816
|
+
// one word to begin with; every whitespace run ends one and starts the next (a trailing
|
|
817
|
+
// run leaves an empty last word, as git's)
|
|
818
|
+
const args: string[] = [];
|
|
819
|
+
let current = "";
|
|
820
|
+
let quoted = "";
|
|
821
|
+
for (let i = 0; i < line.length; i++) {
|
|
822
|
+
const c = line[i] as string;
|
|
823
|
+
if (!quoted && /[ \t\n\r]/.test(c)) {
|
|
824
|
+
args.push(current);
|
|
825
|
+
current = "";
|
|
826
|
+
while (i + 1 < line.length && /[ \t\n\r]/.test(line[i + 1] as string)) i++;
|
|
827
|
+
} else if (!quoted && (c === "'" || c === '"')) {
|
|
828
|
+
quoted = c;
|
|
829
|
+
} else if (c === quoted) {
|
|
830
|
+
quoted = "";
|
|
831
|
+
} else {
|
|
832
|
+
if (c === "\\" && quoted !== "'") {
|
|
833
|
+
i++;
|
|
834
|
+
if (i >= line.length) return "cmdline ends with \\";
|
|
835
|
+
}
|
|
836
|
+
current += line[i];
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
if (quoted) return "unclosed quote";
|
|
840
|
+
args.push(current);
|
|
841
|
+
return args;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
function modeLetter(mode: CatFileMode): string {
|
|
845
|
+
return mode === "type" ? "t" : mode === "size" ? "s" : mode === "exists" ? "e" : "p";
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
function concat(chunks: Uint8Array[]): Uint8Array {
|
|
849
|
+
if (chunks.length === 1) return chunks[0] as Uint8Array;
|
|
850
|
+
let size = 0;
|
|
851
|
+
for (const c of chunks) size += c.length;
|
|
852
|
+
const out = new Uint8Array(size);
|
|
853
|
+
let at = 0;
|
|
854
|
+
for (const c of chunks) {
|
|
855
|
+
out.set(c, at);
|
|
856
|
+
at += c.length;
|
|
857
|
+
}
|
|
858
|
+
return out;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* `strbuf_getline` (`strbuf_getdelim_strip_crlf`) over the input as it arrives: each record
|
|
863
|
+
* without its delimiter, and for newline-terminated input without a CR before it (`-z`'s
|
|
864
|
+
* `strbuf_getline_nul` keeps the CR); a last record without a delimiter is read too.
|
|
865
|
+
* Records are bytes: they are decoded as git paths ({@link decodeGitPath}), so a name that
|
|
866
|
+
* is not UTF-8 resolves and is echoed (`<name> missing`) with its bytes.
|
|
867
|
+
*/
|
|
868
|
+
async function* readLines(input: CatFileInput, delimiter: number): AsyncGenerator<string> {
|
|
869
|
+
const chunks: AsyncIterable<Uint8Array> | Iterable<Uint8Array> =
|
|
870
|
+
typeof input === "string"
|
|
871
|
+
? [encoder.encode(input)]
|
|
872
|
+
: input instanceof Uint8Array
|
|
873
|
+
? [input]
|
|
874
|
+
: input;
|
|
875
|
+
let pending: Uint8Array[] = [];
|
|
876
|
+
const emit = (bytes: Uint8Array) => {
|
|
877
|
+
let end = bytes.length;
|
|
878
|
+
if (delimiter === 0x0a && end > 0 && bytes[end - 1] === 0x0d) end--;
|
|
879
|
+
return decodeGitPath(bytes.subarray(0, end));
|
|
880
|
+
};
|
|
881
|
+
for await (const chunk of chunks) {
|
|
882
|
+
let start = 0;
|
|
883
|
+
for (;;) {
|
|
884
|
+
const at = chunk.indexOf(delimiter, start);
|
|
885
|
+
if (at < 0) break;
|
|
886
|
+
const piece = chunk.subarray(start, at);
|
|
887
|
+
const line = pending.length > 0 ? concat([...pending, piece]) : piece;
|
|
888
|
+
pending = [];
|
|
889
|
+
yield emit(line);
|
|
890
|
+
start = at + 1;
|
|
891
|
+
}
|
|
892
|
+
if (start < chunk.length) pending.push(chunk.slice(start));
|
|
893
|
+
}
|
|
894
|
+
if (pending.length > 0) yield emit(concat(pending));
|
|
895
|
+
}
|