@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
package/src/commands/patch-id.ts
CHANGED
|
@@ -311,3 +311,221 @@ export class PatchIds<K> {
|
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
+
|
|
315
|
+
/** How `git patch-id` hashes a patch: `--unstable`, `--stable`, `--verbatim`. */
|
|
316
|
+
export interface PatchIdTextOptions {
|
|
317
|
+
/** Each file's hash summed apart, so the files' order does not matter (`--stable`) */
|
|
318
|
+
stable?: boolean;
|
|
319
|
+
/** Whitespace kept (`--verbatim`, which git makes stable too) */
|
|
320
|
+
verbatim?: boolean;
|
|
321
|
+
/** The hash (git's `the_hash_algo`: the repository's, SHA-1 outside one) */
|
|
322
|
+
objectFormat?: ObjectFormat;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const isAlpha = (c: number) => (c >= 0x41 && c <= 0x5a) || (c >= 0x61 && c <= 0x7a);
|
|
326
|
+
const isHex = (c: number) =>
|
|
327
|
+
(c >= 0x30 && c <= 0x39) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66);
|
|
328
|
+
|
|
329
|
+
function startsWith(line: Uint8Array, prefix: string, at = 0): boolean {
|
|
330
|
+
if (line.length - at < prefix.length) return false;
|
|
331
|
+
for (let i = 0; i < prefix.length; i++) if (line[at + i] !== prefix.charCodeAt(i)) return false;
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** `strspn(digits)` then `atoi` from `at`: [value, digits read]. */
|
|
336
|
+
function digitsAt(line: Uint8Array, at: number): [number, number] {
|
|
337
|
+
let n = 0;
|
|
338
|
+
let value = 0;
|
|
339
|
+
while (
|
|
340
|
+
at + n < line.length &&
|
|
341
|
+
(line[at + n] as number) >= 0x30 &&
|
|
342
|
+
(line[at + n] as number) <= 0x39
|
|
343
|
+
) {
|
|
344
|
+
value = value * 10 + ((line[at + n] as number) - 0x30);
|
|
345
|
+
n++;
|
|
346
|
+
}
|
|
347
|
+
return [value, n];
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* builtin/patch-id.c's `scan_hunk_header` over `@@ -a,b +c,d @@`: the counts it set, which
|
|
352
|
+
* on a malformed header may be the old count alone (git ignores its failure).
|
|
353
|
+
*/
|
|
354
|
+
function scanHunkHeader(line: Uint8Array): { before: number; after?: number } {
|
|
355
|
+
let q = 4;
|
|
356
|
+
let [, n] = digitsAt(line, q);
|
|
357
|
+
let before = 1;
|
|
358
|
+
if (line[q + n] === 0x2c /* , */) {
|
|
359
|
+
q += n + 1;
|
|
360
|
+
[before, n] = digitsAt(line, q);
|
|
361
|
+
}
|
|
362
|
+
if (n === 0 || line[q + n] !== 0x20 || line[q + n + 1] !== 0x2b /* + */) return { before };
|
|
363
|
+
let r = q + n + 2;
|
|
364
|
+
let after = 1;
|
|
365
|
+
[, n] = digitsAt(line, r);
|
|
366
|
+
if (line[r + n] === 0x2c) {
|
|
367
|
+
r += n + 1;
|
|
368
|
+
[after, n] = digitsAt(line, r);
|
|
369
|
+
}
|
|
370
|
+
return { before, after };
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** `remove_space`: the line without git's isspace bytes. */
|
|
374
|
+
function withoutSpace(line: Uint8Array): Uint8Array {
|
|
375
|
+
const out = new Uint8Array(line.length);
|
|
376
|
+
let n = 0;
|
|
377
|
+
for (const c of line) if (c !== 0x20 && c !== 0x09 && c !== 0x0a && c !== 0x0d) out[n++] = c;
|
|
378
|
+
return out.subarray(0, n);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* `git patch-id`'s output for a patch (or several, as `git log -p` and `git format-patch`
|
|
383
|
+
* write them): a `<patch-id> <commit>` line for each commit whose diff is not empty, the
|
|
384
|
+
* commit read from its `commit <id>` or `From <id>` line (the null id before the first). The
|
|
385
|
+
* diff text is hashed as builtin/patch-id.c reads it: the commit message and hunk headers
|
|
386
|
+
* skipped, whitespace dropped unless `verbatim`, the `index` line's ids standing for a
|
|
387
|
+
* binary diff, each file's hash summed apart when `stable`.
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```typescript
|
|
391
|
+
* patchIdsOfPatchText(new TextEncoder().encode(logOutput), { stable: true });
|
|
392
|
+
* // "f0b2a1... 3d4e5f...\n"
|
|
393
|
+
* ```
|
|
394
|
+
*/
|
|
395
|
+
export function patchIdsOfPatchText(input: Uint8Array, options: PatchIdTextOptions = {}): string {
|
|
396
|
+
const format = options.objectFormat ?? SHA1_OBJECT_FORMAT;
|
|
397
|
+
const verbatim = options.verbatim === true;
|
|
398
|
+
const stable = options.stable === true || verbatim;
|
|
399
|
+
const hexLength = format.rawLength * 2;
|
|
400
|
+
let pos = 0;
|
|
401
|
+
/** strbuf_getwholeline, then the line as C sees it: up to its first NUL */
|
|
402
|
+
const nextLine = (): Uint8Array | undefined => {
|
|
403
|
+
if (pos >= input.length) return undefined;
|
|
404
|
+
const nl = input.indexOf(0x0a, pos);
|
|
405
|
+
const end = nl < 0 ? input.length : nl + 1;
|
|
406
|
+
let line = input.subarray(pos, end);
|
|
407
|
+
pos = end;
|
|
408
|
+
const nul = line.indexOf(0);
|
|
409
|
+
if (nul >= 0) line = line.subarray(0, nul);
|
|
410
|
+
return line;
|
|
411
|
+
};
|
|
412
|
+
const hexAt = (line: Uint8Array, at: number): string | undefined => {
|
|
413
|
+
if (line.length - at < hexLength) return undefined;
|
|
414
|
+
for (let i = 0; i < hexLength; i++) if (!isHex(line[at + i] as number)) return undefined;
|
|
415
|
+
return new TextDecoder().decode(line.subarray(at, at + hexLength)).toLowerCase();
|
|
416
|
+
};
|
|
417
|
+
const addInto = (result: Uint8Array, h: Hasher) => {
|
|
418
|
+
const digest = h.digest();
|
|
419
|
+
let carry = 0;
|
|
420
|
+
for (let i = 0; i < result.length; i++) {
|
|
421
|
+
carry += (result[i] as number) + (digest[i] as number);
|
|
422
|
+
result[i] = carry & 0xff;
|
|
423
|
+
carry >>= 8;
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
/** get_one_patchid: [patch length, patch-id, the next commit] */
|
|
428
|
+
const getOne = (): [number, string, string] => {
|
|
429
|
+
let patchlen = 0;
|
|
430
|
+
let next = format.nullId;
|
|
431
|
+
let before = -1;
|
|
432
|
+
let after = -1;
|
|
433
|
+
let binary = false;
|
|
434
|
+
let preId = new Uint8Array(0);
|
|
435
|
+
let postId = new Uint8Array(0);
|
|
436
|
+
let h = format.createHasher();
|
|
437
|
+
const result = new Uint8Array(format.rawLength);
|
|
438
|
+
const flush = () => {
|
|
439
|
+
addInto(result, h);
|
|
440
|
+
h = format.createHasher();
|
|
441
|
+
};
|
|
442
|
+
for (let line = nextLine(); line !== undefined; line = nextLine()) {
|
|
443
|
+
let p = 0;
|
|
444
|
+
if (startsWith(line, "commit ")) p = 7;
|
|
445
|
+
else if (startsWith(line, "From ")) p = 5;
|
|
446
|
+
else if (startsWith(line, "\\ ") && line.length > 12) {
|
|
447
|
+
// ""
|
|
448
|
+
if (verbatim) h.update(line);
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
const id = hexAt(line, p);
|
|
452
|
+
if (id !== undefined) {
|
|
453
|
+
next = id;
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
// the commit message
|
|
457
|
+
if (!patchlen && !startsWith(line, "diff ")) continue;
|
|
458
|
+
// a diff header
|
|
459
|
+
if (before === -1) {
|
|
460
|
+
if (startsWith(line, "GIT binary patch") || startsWith(line, "Binary files")) {
|
|
461
|
+
binary = true;
|
|
462
|
+
before = 0;
|
|
463
|
+
h.update(preId);
|
|
464
|
+
h.update(postId);
|
|
465
|
+
if (stable) flush();
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if (startsWith(line, "index ")) {
|
|
469
|
+
// the ids around `..`, up to a space or the line's last byte (64 at most)
|
|
470
|
+
let dots = -1;
|
|
471
|
+
for (let i = 0; i + 1 < line.length; i++) {
|
|
472
|
+
if (line[i] === 0x2e && line[i + 1] === 0x2e) {
|
|
473
|
+
dots = i;
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (dots >= 0) {
|
|
478
|
+
const space = line.indexOf(0x20, dots);
|
|
479
|
+
const end = space >= 0 ? space : line.length - 1;
|
|
480
|
+
preId = line.slice(6, Math.min(dots, 6 + 64));
|
|
481
|
+
postId = line.slice(dots + 2, Math.min(Math.max(end, dots + 2), dots + 2 + 64));
|
|
482
|
+
}
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
if (startsWith(line, "--- ")) {
|
|
486
|
+
before = 1;
|
|
487
|
+
after = 1;
|
|
488
|
+
} else if (!isAlpha(line[0] ?? 0)) break;
|
|
489
|
+
}
|
|
490
|
+
if (binary) {
|
|
491
|
+
if (startsWith(line, "diff ")) {
|
|
492
|
+
binary = false;
|
|
493
|
+
before = -1;
|
|
494
|
+
}
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
// looking for a hunk header
|
|
498
|
+
if (before === 0 && after === 0) {
|
|
499
|
+
if (startsWith(line, "@@ -")) {
|
|
500
|
+
const counts = scanHunkHeader(line);
|
|
501
|
+
before = counts.before;
|
|
502
|
+
if (counts.after !== undefined) after = counts.after;
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
// the end of the patch
|
|
506
|
+
if (!startsWith(line, "diff ")) break;
|
|
507
|
+
// another file's header
|
|
508
|
+
if (stable) flush();
|
|
509
|
+
before = -1;
|
|
510
|
+
after = -1;
|
|
511
|
+
}
|
|
512
|
+
// a line of a hunk
|
|
513
|
+
if (line[0] === 0x2d /* - */ || line[0] === 0x20) before--;
|
|
514
|
+
if (line[0] === 0x2b /* + */ || line[0] === 0x20) after--;
|
|
515
|
+
const hashed = verbatim ? line : withoutSpace(line);
|
|
516
|
+
patchlen += hashed.length;
|
|
517
|
+
h.update(hashed);
|
|
518
|
+
}
|
|
519
|
+
flush();
|
|
520
|
+
return [patchlen, bytesToHex(result), next];
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
let out = "";
|
|
524
|
+
let commit = format.nullId;
|
|
525
|
+
while (pos < input.length) {
|
|
526
|
+
const [patchlen, id, next] = getOne();
|
|
527
|
+
if (patchlen) out += `${id} ${commit}\n`;
|
|
528
|
+
commit = next;
|
|
529
|
+
}
|
|
530
|
+
return out;
|
|
531
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The common shape of git's listing plumbing (`cat-file`, `ls-files`, `ls-tree`, `show-ref`):
|
|
3
|
+
* stdout is bytes written to a sink as git writes them (`setStdout`), stderr is git's text,
|
|
4
|
+
* and the exit status is git's, so a CLI shim over the library can print what git prints.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // git show-ref --verify refs/heads/main
|
|
9
|
+
* const { stdout, stderr, exitCode } = await git.showRef().setVerify(true).addPattern("refs/heads/main").callOutput();
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { encodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
14
|
+
import { GitApiError } from "../errors/index.js";
|
|
15
|
+
import { GitCommand } from "../git-command.js";
|
|
16
|
+
|
|
17
|
+
/** Where a plumbing command writes its stdout: each chunk is the caller's to keep. */
|
|
18
|
+
export type ByteSink = (chunk: Uint8Array) => void | Promise<void>;
|
|
19
|
+
|
|
20
|
+
/** How a plumbing command ended when it did not die. */
|
|
21
|
+
export interface PlumbingResult {
|
|
22
|
+
/** git's exit status (0, or 1 where git reports a miss without dying) */
|
|
23
|
+
exitCode: number;
|
|
24
|
+
/** git's stderr (warnings and `error:` lines it printed and went on past) */
|
|
25
|
+
stderr: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** {@link PlumbingResult} with stdout collected, deaths included. */
|
|
29
|
+
export interface PlumbingOutput extends PlumbingResult {
|
|
30
|
+
/** Everything written to stdout, also before a death */
|
|
31
|
+
stdout: Uint8Array;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A death of a plumbing command: git's stderr lines (`fatal: ...`, with the lines before it)
|
|
36
|
+
* as the message, its exit status in `exitCode` (128 by default).
|
|
37
|
+
*/
|
|
38
|
+
export class PlumbingError extends GitApiError {
|
|
39
|
+
constructor(message: string, exitCode = 128) {
|
|
40
|
+
super(message, { exitCode });
|
|
41
|
+
this.name = "PlumbingError";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Errors the object stores throw for bytes they refuse to read. */
|
|
46
|
+
const STORE_READ_ERRORS = new Set([
|
|
47
|
+
"CorruptObjectError",
|
|
48
|
+
"ObjectIdMismatchError",
|
|
49
|
+
"InvalidTreeEntryNameError",
|
|
50
|
+
"MissingObjectError",
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The base of the listing plumbing commands: {@link run} writes through {@link write} and
|
|
55
|
+
* {@link warn}; {@link call} gives the exit status and stderr, {@link callOutput} also
|
|
56
|
+
* collects stdout and turns a death into its output.
|
|
57
|
+
*/
|
|
58
|
+
export abstract class PlumbingCommand extends GitCommand<PlumbingResult> {
|
|
59
|
+
private sink?: ByteSink;
|
|
60
|
+
private stderrText = "";
|
|
61
|
+
|
|
62
|
+
/** Where stdout goes (default: discarded unless {@link callOutput} collects it). */
|
|
63
|
+
setStdout(sink: ByteSink): this {
|
|
64
|
+
this.checkCallable();
|
|
65
|
+
this.sink = sink;
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The command's work: write stdout, add stderr, return the exit status. */
|
|
70
|
+
protected abstract run(): Promise<number>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Writes bytes or text to stdout. Text is encoded as a git path ({@link encodeGitPath}):
|
|
74
|
+
* UTF-8, with the bytes a path read from a tree or the index escapes (U+DC80..U+DCFF)
|
|
75
|
+
* written back as they were, so names that are not UTF-8 keep their bytes.
|
|
76
|
+
*/
|
|
77
|
+
protected async write(chunk: Uint8Array | string): Promise<void> {
|
|
78
|
+
const bytes = typeof chunk === "string" ? encodeGitPath(chunk) : chunk;
|
|
79
|
+
if (bytes.length > 0) await this.sink?.(bytes);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Adds a line (its newline added) to stderr. */
|
|
83
|
+
protected warn(line: string): void {
|
|
84
|
+
this.stderrText += `${line}\n`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** What was written to stderr so far. */
|
|
88
|
+
getStderr(): string {
|
|
89
|
+
return this.stderrText;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Runs the command.
|
|
94
|
+
*
|
|
95
|
+
* @throws PlumbingError (or another GitApiError) where git dies
|
|
96
|
+
*/
|
|
97
|
+
async call(): Promise<PlumbingResult> {
|
|
98
|
+
this.checkCallable();
|
|
99
|
+
this.setCallable(false);
|
|
100
|
+
let exitCode: number;
|
|
101
|
+
try {
|
|
102
|
+
exitCode = await this.run();
|
|
103
|
+
} catch (e) {
|
|
104
|
+
// a store's refusal of what it read (a corrupt object, a tree it will not decode) is a
|
|
105
|
+
// death of the command, as git dies on such objects; anything else is a bug and rethrown
|
|
106
|
+
if (e instanceof Error && !(e instanceof GitApiError) && STORE_READ_ERRORS.has(e.name)) {
|
|
107
|
+
throw new PlumbingError(`fatal: ${e.message}`);
|
|
108
|
+
}
|
|
109
|
+
throw e;
|
|
110
|
+
}
|
|
111
|
+
return { exitCode, stderr: this.stderrText };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Runs the command, collecting stdout; a death is returned as its stderr and status. */
|
|
115
|
+
async callOutput(): Promise<PlumbingOutput> {
|
|
116
|
+
const chunks: Uint8Array[] = [];
|
|
117
|
+
const outer = this.sink;
|
|
118
|
+
this.sink = async (chunk) => {
|
|
119
|
+
chunks.push(chunk);
|
|
120
|
+
await outer?.(chunk);
|
|
121
|
+
};
|
|
122
|
+
let exitCode: number;
|
|
123
|
+
let stderr: string;
|
|
124
|
+
try {
|
|
125
|
+
({ exitCode, stderr } = await this.call());
|
|
126
|
+
} catch (e) {
|
|
127
|
+
if (!(e instanceof GitApiError)) throw e;
|
|
128
|
+
exitCode = e.exitCode;
|
|
129
|
+
stderr = `${this.stderrText}${e.message}\n`;
|
|
130
|
+
}
|
|
131
|
+
let size = 0;
|
|
132
|
+
for (const c of chunks) size += c.length;
|
|
133
|
+
const stdout = new Uint8Array(size);
|
|
134
|
+
let at = 0;
|
|
135
|
+
for (const c of chunks) {
|
|
136
|
+
stdout.set(c, at);
|
|
137
|
+
at += c.length;
|
|
138
|
+
}
|
|
139
|
+
return { exitCode, stderr, stdout };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the plumbing commands reading paths or entries from stdin share: `git check-attr` and
|
|
3
|
+
* `git check-ignore`'s `--stdin` records (lines, a line starting with `"` unquoted as a C
|
|
4
|
+
* string, or NUL-terminated with `-z`) and their paths read against the current directory
|
|
5
|
+
* (`prefix_path`); `update-index --stdin`/`--index-info` and `checkout-index --stdin` lines
|
|
6
|
+
* (git's `strbuf_getline_lf` / `strbuf_getline_nul` and `unquote_c_style`).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { decodeGitPath, encodeGitPath, unquoteGitPath } from "@statewalker/vcs-utils/encoding";
|
|
10
|
+
|
|
11
|
+
import { prefixPathGently } from "./git-paths.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* `--stdin`'s records: `strbuf_getline_lf` lines (only the LF dropped), each starting with
|
|
15
|
+
* `"` unquoted (`unquote_c_style`, anything after the closing quote ignored), or with `nul`
|
|
16
|
+
* NUL-terminated records taken as they are. Undefined at the first line git cannot unquote
|
|
17
|
+
* (`fatal: line is badly quoted`), with the records before it.
|
|
18
|
+
*/
|
|
19
|
+
export function inputRecords(
|
|
20
|
+
input: Uint8Array,
|
|
21
|
+
nul: boolean,
|
|
22
|
+
): { records: string[]; badlyQuoted: boolean } {
|
|
23
|
+
const records: string[] = [];
|
|
24
|
+
const sep = nul ? 0 : 0x0a;
|
|
25
|
+
let pos = 0;
|
|
26
|
+
while (pos < input.length) {
|
|
27
|
+
const end = input.indexOf(sep, pos);
|
|
28
|
+
const stop = end < 0 ? input.length : end;
|
|
29
|
+
const line = input.subarray(pos, stop);
|
|
30
|
+
pos = stop + 1;
|
|
31
|
+
if (!nul && line[0] === 0x22) {
|
|
32
|
+
const unquoted = unquoteGitPath(line, 0);
|
|
33
|
+
if (!unquoted) return { records, badlyQuoted: true };
|
|
34
|
+
records.push(unquoted.path);
|
|
35
|
+
} else records.push(decodeGitPath(line));
|
|
36
|
+
}
|
|
37
|
+
return { records, badlyQuoted: false };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* git's `prefix_path`: `path` read against the current directory `prefix` (`""` at the top,
|
|
42
|
+
* else ending with `/`) and normalized, an absolute path against `top` (the worktree's host
|
|
43
|
+
* directory, `prefixPathGently`); undefined when it leaves the worktree.
|
|
44
|
+
*/
|
|
45
|
+
export function prefixPath(
|
|
46
|
+
prefix: string,
|
|
47
|
+
path: string,
|
|
48
|
+
top: string | undefined,
|
|
49
|
+
): string | undefined {
|
|
50
|
+
return prefixPathGently(prefix, path, top);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A current directory as `prefixPath` takes it: `""`, or the path with one trailing `/`. */
|
|
54
|
+
export function directoryPrefix(dir: string): string {
|
|
55
|
+
const trimmed = dir.replace(/^\/+|\/+$/g, "");
|
|
56
|
+
return trimmed === "" || trimmed === "." ? "" : `${trimmed}/`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The lines of `input` (LF- or, with `nul`, NUL-separated; a last empty one dropped). */
|
|
60
|
+
export function inputLines(input: string | Uint8Array, nul: boolean): string[] {
|
|
61
|
+
const text = typeof input === "string" ? input : decodeGitPath(input);
|
|
62
|
+
const lines = text.split(nul ? "\0" : "\n");
|
|
63
|
+
if (lines[lines.length - 1] === "") lines.pop();
|
|
64
|
+
return lines;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* `unquote_c_style` of a line starting with `"` (what follows the closing quote ignored);
|
|
69
|
+
* undefined when it is badly quoted.
|
|
70
|
+
*/
|
|
71
|
+
export function unquoteLine(line: string): string | undefined {
|
|
72
|
+
return unquoteGitPath(encodeGitPath(line))?.path;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* `--stdin`'s paths: {@link inputLines}, each LF-separated line starting with `"`
|
|
77
|
+
* unquoted; `badlyQuoted` is thrown for one that cannot be.
|
|
78
|
+
*/
|
|
79
|
+
export function inputPaths(
|
|
80
|
+
input: string | Uint8Array,
|
|
81
|
+
nul: boolean,
|
|
82
|
+
badlyQuoted: () => never,
|
|
83
|
+
): string[] {
|
|
84
|
+
const lines = inputLines(input, nul);
|
|
85
|
+
if (nul) return lines;
|
|
86
|
+
return lines.map((line) => (line.startsWith('"') ? (unquoteLine(line) ?? badlyQuoted()) : line));
|
|
87
|
+
}
|