@statewalker/vcs-commands 0.9.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.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 +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-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 +19 -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 +42 -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 +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-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 +44 -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 +22 -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 +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/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 +9 -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 +12 -0
- 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 +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 +2 -1
- 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 +9 -1
- package/dist/commands/submodule-commands.d.ts.map +1 -1
- package/dist/commands/submodule-update-command.d.ts +13 -1
- package/dist/commands/submodule-update-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-CNvli5bl.js → commands-Mlo1dxQN.js} +52078 -44471
- 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-CrhVMNIH.js} +184 -143
- package/dist/git-command.d.ts +58 -2
- 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-Bw21HEkH.js +13539 -0
- package/dist/{remote-transport-CCmBadm-.js → remote-transport-Bu4PGSMD.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-ERo9vELd.js} +28511 -25685
- package/dist/transport-command.d.ts +79 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +12 -12
- 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 +163 -8
- 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 +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-ref-format-command.ts +129 -0
- package/src/commands/checkout-command.ts +39 -21
- 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 +208 -7
- 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 +99 -1
- package/src/commands/diff-command.ts +573 -46
- 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 +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-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 +45 -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 +55 -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 +684 -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 +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/rev-filter/commit-grep.ts +7 -2
- package/src/commands/rev-list-command.ts +9 -0
- package/src/commands/rev-parse-command.ts +62 -4
- package/src/commands/revert-command.ts +21 -1
- package/src/commands/revision-range.ts +7 -2
- package/src/commands/revision-resolver.ts +44 -3
- 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 +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 +43 -6
- 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 +12 -2
- package/src/commands/submodule-update-command.ts +29 -0
- 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 +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/errors/command-errors.ts +45 -0
- package/src/git-command.ts +131 -1
- 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,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the archive writers (archive-tar.c, archive-zip.c) are given: one call per entry, in
|
|
3
|
+
* the order `write_archive_entries` makes them, then the end of the archive.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** An entry of an archive, as archive.c hands it to `write_entry`. */
|
|
7
|
+
export interface ArchiveEntry {
|
|
8
|
+
/** The path in the archive as bytes (prefix included; a directory ends in `/`) */
|
|
9
|
+
path: Uint8Array;
|
|
10
|
+
/** git's mode: `0o40000`/`0o40777` (a directory), `0o160000`, `0o120000`, `0o100644`… */
|
|
11
|
+
mode: number;
|
|
12
|
+
/** The object id in hex (an extra file: git's fake id, its number in the first 8 bytes) */
|
|
13
|
+
id: string;
|
|
14
|
+
/** The content (a symbolic link: its target); empty for directories */
|
|
15
|
+
content: Uint8Array;
|
|
16
|
+
/**
|
|
17
|
+
* The blob is streamed (git's `size > core.bigFileThreshold` with no export-subst): it is
|
|
18
|
+
* written unconverted, and zip writes it with a data descriptor
|
|
19
|
+
*/
|
|
20
|
+
streamed?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* zip's `entry_is_binary`: the userdiff driver's `binary` setting for the path (`true`,
|
|
23
|
+
* `false`), undefined to look at the content (a NUL in its first 8000 bytes)
|
|
24
|
+
*/
|
|
25
|
+
binary?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** What every archive writer is told besides its entries. */
|
|
29
|
+
export interface ArchiveSettings {
|
|
30
|
+
/** The entries' modification time in seconds (a commit's committer date, `--mtime`) */
|
|
31
|
+
time: number;
|
|
32
|
+
/** The commit archived (pax `comment`, zip comment), undefined for a tree */
|
|
33
|
+
commitId?: string;
|
|
34
|
+
/** zlib's level (`-0` … `-9`); -1 for zlib's default */
|
|
35
|
+
compressionLevel: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Writes an archive one entry at a time (`write_archive_entries`' callback). */
|
|
39
|
+
export interface ArchiveWriter {
|
|
40
|
+
/** Writes an entry; a string is git's `error:` message for an entry it refuses */
|
|
41
|
+
entry(entry: ArchiveEntry): string | undefined;
|
|
42
|
+
/** The archive's bytes (the trailer written) */
|
|
43
|
+
finish(): Uint8Array;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A growing byte buffer. */
|
|
47
|
+
export class ByteBuffer {
|
|
48
|
+
private buf: Uint8Array;
|
|
49
|
+
length = 0;
|
|
50
|
+
|
|
51
|
+
constructor(capacity = 16384) {
|
|
52
|
+
this.buf = new Uint8Array(capacity);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private reserve(n: number): void {
|
|
56
|
+
if (this.length + n <= this.buf.length) return;
|
|
57
|
+
let size = this.buf.length * 2;
|
|
58
|
+
while (size < this.length + n) size *= 2;
|
|
59
|
+
const next = new Uint8Array(size);
|
|
60
|
+
next.set(this.buf.subarray(0, this.length));
|
|
61
|
+
this.buf = next;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
push(bytes: Uint8Array): void {
|
|
65
|
+
this.reserve(bytes.length);
|
|
66
|
+
this.buf.set(bytes, this.length);
|
|
67
|
+
this.length += bytes.length;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
zeros(n: number): void {
|
|
71
|
+
this.reserve(n);
|
|
72
|
+
this.buf.fill(0, this.length, this.length + n);
|
|
73
|
+
this.length += n;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The bytes written (a view: copy before writing more). */
|
|
77
|
+
bytes(): Uint8Array {
|
|
78
|
+
return this.buf.subarray(0, this.length);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const ascii = new TextEncoder();
|
|
83
|
+
|
|
84
|
+
/** ASCII text as bytes. */
|
|
85
|
+
export function asciiBytes(text: string): Uint8Array {
|
|
86
|
+
return ascii.encode(text);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** git's `S_ISDIR`, `S_ISGITLINK`, `S_ISLNK`, `S_ISREG` on a mode. */
|
|
90
|
+
export const isDirMode = (mode: number) => (mode & 0o170000) === 0o040000;
|
|
91
|
+
export const isGitlinkMode = (mode: number) => (mode & 0o170000) === 0o160000;
|
|
92
|
+
export const isLinkMode = (mode: number) => (mode & 0o170000) === 0o120000;
|
|
93
|
+
export const isRegMode = (mode: number) => (mode & 0o170000) === 0o100000;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./archive-command.js";
|
|
2
|
+
export type { ArchiveEntry, ArchiveSettings, ArchiveWriter } from "./archive-entry.js";
|
|
3
|
+
export * from "./remote-archive-command.js";
|
|
4
|
+
export * from "./tar-archive.js";
|
|
5
|
+
export * from "./tar-commit-id.js";
|
|
6
|
+
export * from "./upload-archive-writer.js";
|
|
7
|
+
export * from "./zip-archive.js";
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `git archive --remote=<repo> [--exec=<cmd>] [<options>] <tree-ish> [<path>...]`
|
|
3
|
+
* (builtin/archive.c's `run_remote_archiver`): the archive made by the remote's
|
|
4
|
+
* upload-archive.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
type Duplex,
|
|
9
|
+
gitDaemonRequest,
|
|
10
|
+
type RemoteArchiveOutput,
|
|
11
|
+
requestRemoteArchive,
|
|
12
|
+
serveUploadArchive,
|
|
13
|
+
} from "@statewalker/vcs-transport";
|
|
14
|
+
import { GitApiError } from "../../errors/index.js";
|
|
15
|
+
import { RemoteConfigStore } from "../../remote-config/index.js";
|
|
16
|
+
import { TransportCommand } from "../../transport-command.js";
|
|
17
|
+
import { createDuplexPair } from "../local-transport.js";
|
|
18
|
+
import { withRemoteSession } from "../remote-transport.js";
|
|
19
|
+
import { ArchiveCommand } from "./archive-command.js";
|
|
20
|
+
import { uploadArchiveWriterOf } from "./upload-archive-writer.js";
|
|
21
|
+
|
|
22
|
+
/** What `git archive --remote` gave. */
|
|
23
|
+
export interface RemoteArchiveResult {
|
|
24
|
+
/** 0; 1 when the remote reported an error; 128 when the client died */
|
|
25
|
+
exitCode: number;
|
|
26
|
+
/** The archive (git's stdout, or `-o`'s file), the `--list` lines for `--list` */
|
|
27
|
+
archive: Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* git's stderr: the remote's messages as `remote: <line> ` lines (`-v`'s paths, its
|
|
30
|
+
* `fatal:` line), `remote: git upload-archive: archiver died with error` when it failed;
|
|
31
|
+
* for a local repository also the server process's own
|
|
32
|
+
* `fatal: sent error to the client: ...`, which native git prints in no fixed order
|
|
33
|
+
*/
|
|
34
|
+
stderr: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* `git archive --remote`: `git archive`'s arguments (without `--remote`, `--exec` and
|
|
39
|
+
* `--output`) sent to the remote's upload-archive, the archive it makes returned. A local
|
|
40
|
+
* repository is served in process (git runs `git-upload-archive` there); git:// and ssh
|
|
41
|
+
* through the command's transports; smart HTTP has no upload-archive (git's `operation not
|
|
42
|
+
* supported by protocol`).
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* // git archive --remote=origin --format=zip --prefix=p/ v1.0
|
|
47
|
+
* const { archive, exitCode } = await git
|
|
48
|
+
* .archiveRemote()
|
|
49
|
+
* .setRemote("origin")
|
|
50
|
+
* .addArguments("--format=zip", "--prefix=p/", "v1.0")
|
|
51
|
+
* .call();
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export class RemoteArchiveCommand extends TransportCommand<RemoteArchiveResult> {
|
|
55
|
+
private remote?: string;
|
|
56
|
+
private exec?: string;
|
|
57
|
+
private outputName?: string;
|
|
58
|
+
private readonly args: string[] = [];
|
|
59
|
+
|
|
60
|
+
/** `--remote=<repo>`: a remote's name or a URL (a path for a local repository). */
|
|
61
|
+
setRemote(remote: string): this {
|
|
62
|
+
this.checkCallable();
|
|
63
|
+
this.remote = remote;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** `--exec=<cmd>`: the program the remote runs (default `git-upload-archive`). */
|
|
68
|
+
setExec(exec: string): this {
|
|
69
|
+
this.checkCallable();
|
|
70
|
+
this.exec = exec;
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* `-o <file>`: its name's extension, read with this repository's archivers, is sent first
|
|
76
|
+
* as `--format=<format>` (an explicit `--format` wins). Nothing is written.
|
|
77
|
+
*/
|
|
78
|
+
setOutputName(name: string): this {
|
|
79
|
+
this.checkCallable();
|
|
80
|
+
this.outputName = name;
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** `git archive`'s other arguments, as given (`--format=tar`, `-v`, `HEAD`, `--`, paths). */
|
|
85
|
+
addArguments(...args: string[]): this {
|
|
86
|
+
this.checkCallable();
|
|
87
|
+
this.args.push(...args);
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async call(): Promise<RemoteArchiveResult> {
|
|
92
|
+
this.checkCallable();
|
|
93
|
+
this.setCallable(false);
|
|
94
|
+
if (this.remote === undefined) {
|
|
95
|
+
throw new GitApiError("fatal: no remote given: setRemote() names the repository", {
|
|
96
|
+
exitCode: 129,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const formatHint =
|
|
100
|
+
this.outputName !== undefined
|
|
101
|
+
? new ArchiveCommand(this.workingCopy).formatFromFilename(this.outputName)
|
|
102
|
+
: undefined;
|
|
103
|
+
const options = formatHint ? { formatHint } : {};
|
|
104
|
+
const url = RemoteConfigStore.from(this.workingCopy).remoteUrlOf(this.remote);
|
|
105
|
+
const remote = await this.prepareRemote(url);
|
|
106
|
+
if (remote.kind === "bundle") {
|
|
107
|
+
throw new GitApiError("fatal: operation not supported by protocol");
|
|
108
|
+
}
|
|
109
|
+
if (remote.kind === "local") {
|
|
110
|
+
// git spawns git-upload-archive in the repository: ours serves it in process
|
|
111
|
+
const writer = uploadArchiveWriterOf(remote.repository);
|
|
112
|
+
if (!writer) throw new GitApiError("fatal: operation not supported by protocol");
|
|
113
|
+
const [client, server] = createDuplexPair();
|
|
114
|
+
const serving = serveUploadArchive(server, writer).finally(() => server.close?.());
|
|
115
|
+
const [result, served] = await Promise.all([
|
|
116
|
+
requestRemoteArchive(client, this.args, options).finally(() => client.close?.()),
|
|
117
|
+
serving,
|
|
118
|
+
]);
|
|
119
|
+
return served.error ? { ...result, stderr: `${result.stderr}${served.error}\n` } : result;
|
|
120
|
+
}
|
|
121
|
+
const sessionOptions = {
|
|
122
|
+
...this.remoteSessionOptions(),
|
|
123
|
+
protocolVersion: 0 as const,
|
|
124
|
+
...(this.exec !== undefined ? { program: this.exec } : {}),
|
|
125
|
+
};
|
|
126
|
+
return withRemoteSession(
|
|
127
|
+
remote,
|
|
128
|
+
"git-upload-archive",
|
|
129
|
+
sessionOptions,
|
|
130
|
+
async (session, request): Promise<RemoteArchiveOutput> => {
|
|
131
|
+
if (session.kind !== "native") {
|
|
132
|
+
throw new GitApiError("fatal: operation not supported by protocol");
|
|
133
|
+
}
|
|
134
|
+
const duplex: Duplex = session.duplex;
|
|
135
|
+
if (session.handshake === "git-daemon") await duplex.write(gitDaemonRequest(request));
|
|
136
|
+
return requestRemoteArchive(duplex, this.args, options);
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git's tar writer (archive-tar.c): ustar headers with a pax global header carrying the
|
|
3
|
+
* commit id (`comment`), pax extended headers for paths and link targets that do not fit,
|
|
4
|
+
* records of 512 bytes written in blocks of 20 records, and the trailer that ends the
|
|
5
|
+
* archive with at least two zero records and fills its last block.
|
|
6
|
+
*/
|
|
7
|
+
import {
|
|
8
|
+
type ArchiveEntry,
|
|
9
|
+
type ArchiveSettings,
|
|
10
|
+
type ArchiveWriter,
|
|
11
|
+
asciiBytes,
|
|
12
|
+
ByteBuffer,
|
|
13
|
+
isDirMode,
|
|
14
|
+
isGitlinkMode,
|
|
15
|
+
isLinkMode,
|
|
16
|
+
isRegMode,
|
|
17
|
+
} from "./archive-entry.js";
|
|
18
|
+
|
|
19
|
+
const RECORDSIZE = 512;
|
|
20
|
+
const BLOCKSIZE = RECORDSIZE * 20;
|
|
21
|
+
/** The largest size and mtime a ustar header holds (11 octal digits). */
|
|
22
|
+
const USTAR_MAX = 0o77777777777;
|
|
23
|
+
|
|
24
|
+
const TYPEFLAG_REG = 0x30; // '0'
|
|
25
|
+
const TYPEFLAG_LNK = 0x32; // '2'
|
|
26
|
+
const TYPEFLAG_DIR = 0x35; // '5'
|
|
27
|
+
const TYPEFLAG_GLOBAL_HEADER = 0x67; // 'g'
|
|
28
|
+
const TYPEFLAG_EXT_HEADER = 0x78; // 'x'
|
|
29
|
+
|
|
30
|
+
/** Field offsets and sizes of `struct ustar_header`. */
|
|
31
|
+
const NAME = 0;
|
|
32
|
+
const NAME_SIZE = 100;
|
|
33
|
+
const MODE = 100;
|
|
34
|
+
const UID = 108;
|
|
35
|
+
const GID = 116;
|
|
36
|
+
const SIZE = 124;
|
|
37
|
+
const MTIME = 136;
|
|
38
|
+
const CHKSUM = 148;
|
|
39
|
+
const TYPEFLAG = 156;
|
|
40
|
+
const LINKNAME = 157;
|
|
41
|
+
const LINKNAME_SIZE = 100;
|
|
42
|
+
const MAGIC = 257;
|
|
43
|
+
const VERSION = 263;
|
|
44
|
+
const UNAME = 265;
|
|
45
|
+
const GNAME = 297;
|
|
46
|
+
const DEVMAJOR = 329;
|
|
47
|
+
const DEVMINOR = 337;
|
|
48
|
+
const PREFIX = 345;
|
|
49
|
+
const PREFIX_SIZE = 155;
|
|
50
|
+
|
|
51
|
+
/** Options of {@link TarArchiveWriter}. */
|
|
52
|
+
export interface TarArchiveOptions extends ArchiveSettings {
|
|
53
|
+
/** `tar.umask` (default 002) */
|
|
54
|
+
umask?: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** `xsnprintf(field, size, "%0<size-1>o", value)`: octal digits and a NUL. */
|
|
58
|
+
function octal(header: Uint8Array, at: number, size: number, value: number): void {
|
|
59
|
+
const digits = value.toString(8).padStart(size - 1, "0");
|
|
60
|
+
// xsnprintf would BUG on overflow; the callers keep the values in range
|
|
61
|
+
header.set(asciiBytes(digits.slice(-(size - 1))), at);
|
|
62
|
+
header[at + size - 1] = 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** `strbuf_append_ext_header`: one pax record, `"%u %s=%s\n"`. */
|
|
66
|
+
function extRecord(out: ByteBuffer, keyword: string, value: Uint8Array): void {
|
|
67
|
+
let len = 1 + 1 + keyword.length + 1 + value.length + 1;
|
|
68
|
+
for (let tmp = 1; Math.floor(len / 10) >= tmp; tmp *= 10) len++;
|
|
69
|
+
out.push(asciiBytes(`${len} ${keyword}=`));
|
|
70
|
+
out.push(value);
|
|
71
|
+
out.push(asciiBytes("\n"));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** `get_path_prefix`: where a long path is split between the prefix and name fields. */
|
|
75
|
+
function pathPrefix(path: Uint8Array, maxlen: number): number {
|
|
76
|
+
let i = path.length;
|
|
77
|
+
if (i > 1 && path[i - 1] === 0x2f) i--;
|
|
78
|
+
if (i > maxlen) i = maxlen;
|
|
79
|
+
do {
|
|
80
|
+
i--;
|
|
81
|
+
} while (i > 0 && path[i] !== 0x2f);
|
|
82
|
+
return i;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Writes git's tar archive (`git archive --format=tar`). */
|
|
86
|
+
export class TarArchiveWriter implements ArchiveWriter {
|
|
87
|
+
private readonly out = new ByteBuffer(BLOCKSIZE);
|
|
88
|
+
private readonly umask: number;
|
|
89
|
+
private time: number;
|
|
90
|
+
|
|
91
|
+
constructor(private readonly settings: TarArchiveOptions) {
|
|
92
|
+
this.umask = settings.umask ?? 0o002;
|
|
93
|
+
this.time = settings.time;
|
|
94
|
+
this.writeGlobalExtendedHeader();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** `write_blocked`: data padded to a whole record. */
|
|
98
|
+
private writeBlocked(data: Uint8Array): void {
|
|
99
|
+
this.out.push(data);
|
|
100
|
+
const tail = data.length % RECORDSIZE;
|
|
101
|
+
if (tail) this.out.zeros(RECORDSIZE - tail);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** `prepare_header`: the numeric fields, owner, magic and checksum. */
|
|
105
|
+
private prepareHeader(header: Uint8Array, mode: number, size: number): void {
|
|
106
|
+
octal(header, MODE, 8, mode & 0o7777);
|
|
107
|
+
octal(header, SIZE, 12, isRegMode(mode) ? size : 0);
|
|
108
|
+
octal(header, MTIME, 12, this.time);
|
|
109
|
+
octal(header, UID, 8, 0);
|
|
110
|
+
octal(header, GID, 8, 0);
|
|
111
|
+
header.set(asciiBytes("root"), UNAME);
|
|
112
|
+
header.set(asciiBytes("root"), GNAME);
|
|
113
|
+
octal(header, DEVMAJOR, 8, 0);
|
|
114
|
+
octal(header, DEVMINOR, 8, 0);
|
|
115
|
+
header.set(asciiBytes("ustar\0"), MAGIC);
|
|
116
|
+
header.set(asciiBytes("00"), VERSION);
|
|
117
|
+
// ustar_header_chksum: the checksum field counts as spaces
|
|
118
|
+
let sum = 8 * 0x20;
|
|
119
|
+
for (let i = 0; i < RECORDSIZE; i++) {
|
|
120
|
+
if (i < CHKSUM || i >= CHKSUM + 8) sum += header[i] as number;
|
|
121
|
+
}
|
|
122
|
+
octal(header, CHKSUM, 8, sum);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private writeGlobalExtendedHeader(): void {
|
|
126
|
+
const ext = new ByteBuffer(256);
|
|
127
|
+
if (this.settings.commitId) extRecord(ext, "comment", asciiBytes(this.settings.commitId));
|
|
128
|
+
if (this.time > USTAR_MAX) {
|
|
129
|
+
extRecord(ext, "mtime", asciiBytes(String(this.time)));
|
|
130
|
+
this.time = USTAR_MAX;
|
|
131
|
+
}
|
|
132
|
+
if (!ext.length) return;
|
|
133
|
+
const header = new Uint8Array(RECORDSIZE);
|
|
134
|
+
header[TYPEFLAG] = TYPEFLAG_GLOBAL_HEADER;
|
|
135
|
+
header.set(asciiBytes("pax_global_header"), NAME);
|
|
136
|
+
this.prepareHeader(header, 0o100666, ext.length);
|
|
137
|
+
this.writeBlocked(header);
|
|
138
|
+
this.writeBlocked(ext.bytes());
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private writeExtendedHeader(id: string, ext: Uint8Array): void {
|
|
142
|
+
const header = new Uint8Array(RECORDSIZE);
|
|
143
|
+
header[TYPEFLAG] = TYPEFLAG_EXT_HEADER;
|
|
144
|
+
header.set(asciiBytes(`${id}.paxheader`.slice(0, NAME_SIZE - 1)), NAME);
|
|
145
|
+
this.prepareHeader(header, 0o100666, ext.length);
|
|
146
|
+
this.writeBlocked(header);
|
|
147
|
+
this.writeBlocked(ext);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** `write_tar_entry`. */
|
|
151
|
+
entry(entry: ArchiveEntry): string | undefined {
|
|
152
|
+
const { path, id, content } = entry;
|
|
153
|
+
let mode = entry.mode;
|
|
154
|
+
const header = new Uint8Array(RECORDSIZE);
|
|
155
|
+
const ext = new ByteBuffer(256);
|
|
156
|
+
if (isDirMode(mode) || isGitlinkMode(mode)) {
|
|
157
|
+
header[TYPEFLAG] = TYPEFLAG_DIR;
|
|
158
|
+
mode = (mode | 0o777) & ~this.umask;
|
|
159
|
+
} else if (isLinkMode(mode)) {
|
|
160
|
+
header[TYPEFLAG] = TYPEFLAG_LNK;
|
|
161
|
+
mode |= 0o777;
|
|
162
|
+
} else if (isRegMode(mode)) {
|
|
163
|
+
header[TYPEFLAG] = TYPEFLAG_REG;
|
|
164
|
+
mode = (mode | (mode & 0o100 ? 0o777 : 0o666)) & ~this.umask;
|
|
165
|
+
} else {
|
|
166
|
+
return `unsupported file mode: 0${mode.toString(8)} (SHA1: ${id})`;
|
|
167
|
+
}
|
|
168
|
+
if (path.length > NAME_SIZE) {
|
|
169
|
+
const plen = pathPrefix(path, PREFIX_SIZE);
|
|
170
|
+
const rest = path.length - plen - 1;
|
|
171
|
+
if (plen > 0 && rest <= NAME_SIZE) {
|
|
172
|
+
header.set(path.subarray(0, plen), PREFIX);
|
|
173
|
+
header.set(path.subarray(plen + 1), NAME);
|
|
174
|
+
} else {
|
|
175
|
+
header.set(asciiBytes(`${id}.data`.slice(0, NAME_SIZE - 1)), NAME);
|
|
176
|
+
extRecord(ext, "path", path);
|
|
177
|
+
}
|
|
178
|
+
} else header.set(path, NAME);
|
|
179
|
+
|
|
180
|
+
if (isLinkMode(mode)) {
|
|
181
|
+
if (content.length > LINKNAME_SIZE) {
|
|
182
|
+
header.set(asciiBytes(`see ${id}.paxheader`.slice(0, LINKNAME_SIZE - 1)), LINKNAME);
|
|
183
|
+
extRecord(ext, "linkpath", content);
|
|
184
|
+
} else header.set(content, LINKNAME);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
let sizeInHeader = content.length;
|
|
188
|
+
if (isRegMode(mode) && content.length > USTAR_MAX) {
|
|
189
|
+
sizeInHeader = 0;
|
|
190
|
+
extRecord(ext, "size", asciiBytes(String(content.length)));
|
|
191
|
+
}
|
|
192
|
+
this.prepareHeader(header, mode, sizeInHeader);
|
|
193
|
+
if (ext.length > 0) this.writeExtendedHeader(id, ext.bytes());
|
|
194
|
+
this.writeBlocked(header);
|
|
195
|
+
if (isRegMode(mode) && content.length > 0) this.writeBlocked(content);
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** `write_trailer`: the last block filled, another one when fewer than two records remain. */
|
|
200
|
+
finish(): Uint8Array {
|
|
201
|
+
const offset = this.out.length % BLOCKSIZE;
|
|
202
|
+
const tail = BLOCKSIZE - offset;
|
|
203
|
+
this.out.zeros(tail);
|
|
204
|
+
if (tail < 2 * RECORDSIZE) this.out.zeros(BLOCKSIZE);
|
|
205
|
+
return this.out.bytes();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `git get-tar-commit-id` (builtin/get-tar-commit-id.c): the commit id `git archive` put in
|
|
3
|
+
* a tar archive's pax global header (`comment=<id>`).
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const tar = await git.archive().setTree("HEAD").call();
|
|
8
|
+
* getTarCommitId(tar); // { exitCode: 0, output: "<commit id>\n" }
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
import { GitApiError } from "../../errors/index.js";
|
|
12
|
+
|
|
13
|
+
const RECORDSIZE = 512;
|
|
14
|
+
const HEADERSIZE = 2 * RECORDSIZE;
|
|
15
|
+
const TYPEFLAG_GLOBAL_HEADER = 0x67;
|
|
16
|
+
|
|
17
|
+
/** What `git get-tar-commit-id` writes and its exit status. */
|
|
18
|
+
export interface TarCommitIdResult {
|
|
19
|
+
/** 0 with the id (and its newline) on stdout, 1 when the archive carries none */
|
|
20
|
+
exitCode: number;
|
|
21
|
+
output: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const isSpace = (c: number) => c === 0x20 || (c >= 0x09 && c <= 0x0d);
|
|
25
|
+
const isDigit = (c: number) => c >= 0x30 && c <= 0x39;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The commit id of a tar archive's first bytes (git reads exactly 1024 of its stdin).
|
|
29
|
+
*
|
|
30
|
+
* @throws GitApiError (exit 128) when fewer than 1024 bytes are given, as git dies
|
|
31
|
+
*/
|
|
32
|
+
export function getTarCommitId(archive: Uint8Array): TarCommitIdResult {
|
|
33
|
+
if (archive.length < HEADERSIZE) {
|
|
34
|
+
// die_errno with errno still 0
|
|
35
|
+
throw new GitApiError("fatal: git get-tar-commit-id: EOF before reading tar header: Success", {
|
|
36
|
+
exitCode: 128,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const none = { exitCode: 1, output: "" };
|
|
40
|
+
if (archive[156] !== TYPEFLAG_GLOBAL_HEADER) return none;
|
|
41
|
+
// strtol(content, &end, 10) over the second record (NUL-terminated by git's buffer end)
|
|
42
|
+
const content = archive.subarray(RECORDSIZE, HEADERSIZE);
|
|
43
|
+
let i = 0;
|
|
44
|
+
while (i < content.length && isSpace(content[i] as number)) i++;
|
|
45
|
+
let negative = false;
|
|
46
|
+
if (content[i] === 0x2b || content[i] === 0x2d) {
|
|
47
|
+
negative = content[i] === 0x2d;
|
|
48
|
+
i++;
|
|
49
|
+
}
|
|
50
|
+
const digitsStart = i;
|
|
51
|
+
let len = 0;
|
|
52
|
+
while (i < content.length && isDigit(content[i] as number)) {
|
|
53
|
+
len = len * 10 + ((content[i] as number) - 0x30);
|
|
54
|
+
i++;
|
|
55
|
+
}
|
|
56
|
+
if (i === digitsStart || negative) return none;
|
|
57
|
+
if (len > Number.MAX_SAFE_INTEGER) return none;
|
|
58
|
+
const prefix = " comment=";
|
|
59
|
+
for (let k = 0; k < prefix.length; k++) {
|
|
60
|
+
if (content[i + k] !== prefix.charCodeAt(k)) return none;
|
|
61
|
+
}
|
|
62
|
+
const comment = i + prefix.length;
|
|
63
|
+
len -= comment;
|
|
64
|
+
const hashLength = (len - 1) / 2;
|
|
65
|
+
if (len < 1 || len % 2 === 0 || (hashLength !== 20 && hashLength !== 32)) return none;
|
|
66
|
+
let output = "";
|
|
67
|
+
// write_in_full(1, comment, len): bytes up to the buffer's end (git's own buffer is 1024)
|
|
68
|
+
for (let k = comment; k < comment + len && k < content.length; k++) {
|
|
69
|
+
output += String.fromCharCode(content[k] as number);
|
|
70
|
+
}
|
|
71
|
+
return { exitCode: 0, output };
|
|
72
|
+
}
|