@statewalker/vcs-commands 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commands/add-command.d.ts +32 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/add-patch.d.ts +7 -0
- package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts +2 -0
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-modes.d.ts +6 -2
- package/dist/commands/add-patch/patch-modes.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-session.d.ts +4 -0
- package/dist/commands/add-patch/patch-session.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +88 -2
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-command.d.ts +2 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.d.ts +7 -0
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/apply/index.d.ts +1 -1
- package/dist/commands/apply/index.d.ts.map +1 -1
- package/dist/commands/archive/archive-command.d.ts +169 -0
- package/dist/commands/archive/archive-command.d.ts.map +1 -0
- package/dist/commands/archive/archive-entry.d.ts +60 -0
- package/dist/commands/archive/archive-entry.d.ts.map +1 -0
- package/dist/commands/archive/index.d.ts +8 -0
- package/dist/commands/archive/index.d.ts.map +1 -0
- package/dist/commands/archive/remote-archive-command.d.ts +56 -0
- package/dist/commands/archive/remote-archive-command.d.ts.map +1 -0
- package/dist/commands/archive/tar-archive.d.ts +31 -0
- package/dist/commands/archive/tar-archive.d.ts.map +1 -0
- package/dist/commands/archive/tar-commit-id.d.ts +13 -0
- package/dist/commands/archive/tar-commit-id.d.ts.map +1 -0
- package/dist/commands/archive/upload-archive-writer.d.ts +48 -0
- package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -0
- package/dist/commands/archive/zip-archive.d.ts +42 -0
- package/dist/commands/archive/zip-archive.d.ts.map +1 -0
- package/dist/commands/attributes-source.d.ts +10 -0
- package/dist/commands/attributes-source.d.ts.map +1 -1
- package/dist/commands/blame-command.d.ts +345 -8
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/blame-ignore.d.ts +48 -0
- package/dist/commands/blame-ignore.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-create-command.d.ts +67 -0
- package/dist/commands/bundle/bundle-create-command.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-format.d.ts +89 -0
- package/dist/commands/bundle/bundle-format.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-list.d.ts +92 -0
- package/dist/commands/bundle/bundle-list.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts +81 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-support.d.ts +32 -0
- package/dist/commands/bundle/bundle-support.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-transport.d.ts +38 -0
- package/dist/commands/bundle/bundle-transport.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts +43 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri.d.ts +55 -0
- package/dist/commands/bundle/bundle-uri.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-verify.d.ts +63 -0
- package/dist/commands/bundle/bundle-verify.d.ts.map +1 -0
- package/dist/commands/bundle/index.d.ts +14 -0
- package/dist/commands/bundle/index.d.ts.map +1 -0
- package/dist/commands/cat-file/batch-format.d.ts +58 -0
- package/dist/commands/cat-file/batch-format.d.ts.map +1 -0
- package/dist/commands/cat-file/cat-file-command.d.ts +135 -0
- package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -0
- package/dist/commands/cat-file/index.d.ts +3 -0
- package/dist/commands/cat-file/index.d.ts.map +1 -0
- package/dist/commands/check-attr-command.d.ts +66 -0
- package/dist/commands/check-attr-command.d.ts.map +1 -0
- package/dist/commands/check-ignore-command.d.ts +58 -0
- package/dist/commands/check-ignore-command.d.ts.map +1 -0
- package/dist/commands/check-mailmap-command.d.ts +49 -0
- package/dist/commands/check-mailmap-command.d.ts.map +1 -0
- package/dist/commands/check-ref-format-command.d.ts +60 -0
- package/dist/commands/check-ref-format-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +7 -0
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-index-command.d.ts +96 -0
- package/dist/commands/checkout-index-command.d.ts.map +1 -0
- package/dist/commands/checkout-paths.d.ts +4 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-command.d.ts +61 -0
- package/dist/commands/cherry-command.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +33 -1
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +32 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +56 -0
- package/dist/commands/clean-interactive.d.ts.map +1 -0
- package/dist/commands/clone-command.d.ts +135 -2
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +59 -3
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/config-command.d.ts +2 -0
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/daemon-access-hook.d.ts +36 -0
- package/dist/commands/daemon-access-hook.d.ts.map +1 -0
- package/dist/commands/default-branch.d.ts +42 -0
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/describe-command.d.ts +71 -64
- package/dist/commands/describe-command.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +249 -10
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/diff-external.d.ts +43 -0
- package/dist/commands/diff-external.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts +27 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts +129 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/index.d.ts +3 -0
- package/dist/commands/diff-plumbing/index.d.ts.map +1 -0
- package/dist/commands/diff-textconv.d.ts +5 -1
- package/dist/commands/diff-textconv.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-export-command.d.ts +135 -0
- package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-import-command.d.ts +182 -0
- package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts +64 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -0
- package/dist/commands/fast-export/index.d.ts +4 -0
- package/dist/commands/fast-export/index.d.ts.map +1 -0
- package/dist/commands/fetch-command.d.ts +125 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fetch-multiple-command.d.ts +193 -0
- package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
- package/dist/commands/format-patch-command.d.ts +28 -2
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/format-rev-command.d.ts +58 -0
- package/dist/commands/format-rev-command.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-msg-ids.d.ts +18 -3
- package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -1
- package/dist/commands/fsmonitor-refresh.d.ts +69 -0
- package/dist/commands/fsmonitor-refresh.d.ts.map +1 -0
- package/dist/commands/gc-command.d.ts +5 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +77 -4
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +47 -1
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/git-paths.d.ts +26 -0
- package/dist/commands/git-paths.d.ts.map +1 -0
- package/dist/commands/grep/grep-command.d.ts +2 -1
- package/dist/commands/grep/grep-command.d.ts.map +1 -1
- package/dist/commands/history-command.d.ts +156 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/http-config.d.ts +38 -0
- package/dist/commands/http-config.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +12 -1
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index-host.d.ts.map +1 -1
- package/dist/commands/index.d.ts +56 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +6 -3
- package/dist/commands/init-command.d.ts +89 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/last-modified-command.d.ts +102 -0
- package/dist/commands/last-modified-command.d.ts.map +1 -0
- package/dist/commands/lfs/go-url.d.ts +43 -0
- package/dist/commands/lfs/go-url.d.ts.map +1 -0
- package/dist/commands/lfs/index.d.ts +3 -0
- package/dist/commands/lfs/index.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-config.d.ts +174 -0
- package/dist/commands/lfs/lfs-config.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-endpoint-command.d.ts +83 -0
- package/dist/commands/lfs/lfs-endpoint-command.d.ts.map +1 -0
- package/dist/commands/line-log.d.ts +161 -0
- package/dist/commands/line-log.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +261 -6
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +4 -2
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +88 -2
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-files-command.d.ts +153 -0
- package/dist/commands/ls-files-command.d.ts.map +1 -0
- package/dist/commands/ls-remote-command.d.ts +5 -0
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/ls-tree-command.d.ts +105 -0
- package/dist/commands/ls-tree-command.d.ts.map +1 -0
- package/dist/commands/mailmap.d.ts +24 -1
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/maintenance-run-command.d.ts +122 -0
- package/dist/commands/maintenance-run-command.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +58 -1
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-config.d.ts +7 -0
- package/dist/commands/merge-config.d.ts.map +1 -1
- package/dist/commands/merge-drivers.d.ts +69 -5
- package/dist/commands/merge-drivers.d.ts.map +1 -1
- package/dist/commands/merge-strategy-options.d.ts +69 -0
- package/dist/commands/merge-strategy-options.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +16 -0
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/merge-tree-command.d.ts +122 -0
- package/dist/commands/merge-tree-command.d.ts.map +1 -0
- package/dist/commands/message-cleanup.d.ts +2 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -1
- package/dist/commands/mktag-command.d.ts +51 -0
- package/dist/commands/mktag-command.d.ts.map +1 -0
- package/dist/commands/name-rev-command.d.ts +65 -0
- package/dist/commands/name-rev-command.d.ts.map +1 -0
- package/dist/commands/name-rev.d.ts +110 -22
- package/dist/commands/name-rev.d.ts.map +1 -1
- package/dist/commands/object-store/count-objects-command.d.ts +58 -0
- package/dist/commands/object-store/count-objects-command.d.ts.map +1 -0
- package/dist/commands/object-store/index.d.ts +5 -0
- package/dist/commands/object-store/index.d.ts.map +1 -0
- package/dist/commands/object-store/objects-directory.d.ts +12 -0
- package/dist/commands/object-store/objects-directory.d.ts.map +1 -0
- package/dist/commands/object-store/prune-command.d.ts +38 -0
- package/dist/commands/object-store/prune-command.d.ts.map +1 -0
- package/dist/commands/object-store/show-index-command.d.ts +23 -0
- package/dist/commands/object-store/show-index-command.d.ts.map +1 -0
- package/dist/commands/octopus-merge.d.ts +26 -1
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/ort-merge.d.ts +40 -0
- package/dist/commands/ort-merge.d.ts.map +1 -1
- package/dist/commands/ort-recursive.d.ts.map +1 -1
- package/dist/commands/patch-id-command.d.ts +30 -0
- package/dist/commands/patch-id-command.d.ts.map +1 -0
- package/dist/commands/patch-id.d.ts +82 -0
- package/dist/commands/patch-id.d.ts.map +1 -1
- package/dist/commands/plumbing-command.d.ts +66 -0
- package/dist/commands/plumbing-command.d.ts.map +1 -0
- package/dist/commands/plumbing-input.d.ts +38 -0
- package/dist/commands/plumbing-input.d.ts.map +1 -0
- package/dist/commands/promisor-remote-reply.d.ts +35 -0
- package/dist/commands/promisor-remote-reply.d.ts.map +1 -0
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +182 -38
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +82 -2
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/index.d.ts +4 -0
- package/dist/commands/range-diff/index.d.ts.map +1 -0
- package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
- package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff.d.ts +106 -0
- package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
- package/dist/commands/read-tree-command.d.ts +14 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +129 -4
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/refs-command.d.ts +81 -0
- package/dist/commands/refs-command.d.ts.map +1 -0
- package/dist/commands/remerge-diff.d.ts +59 -0
- package/dist/commands/remerge-diff.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +41 -0
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-object-info-command.d.ts +55 -0
- package/dist/commands/remote-object-info-command.d.ts.map +1 -0
- package/dist/commands/remote-show-command.d.ts +204 -0
- package/dist/commands/remote-show-command.d.ts.map +1 -0
- package/dist/commands/remote-transport.d.ts +40 -3
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/repack-command.d.ts +115 -0
- package/dist/commands/repack-command.d.ts.map +1 -0
- package/dist/commands/replace-command.d.ts +143 -0
- package/dist/commands/replace-command.d.ts.map +1 -0
- package/dist/commands/replay-command.d.ts +117 -0
- package/dist/commands/replay-command.d.ts.map +1 -0
- package/dist/commands/repo-command.d.ts +136 -0
- package/dist/commands/repo-command.d.ts.map +1 -0
- package/dist/commands/request-pull-command.d.ts +82 -0
- package/dist/commands/request-pull-command.d.ts.map +1 -0
- package/dist/commands/rerere-command.d.ts +36 -0
- package/dist/commands/rerere-command.d.ts.map +1 -0
- package/dist/commands/rerere.d.ts +102 -0
- package/dist/commands/rerere.d.ts.map +1 -0
- package/dist/commands/reset-command.d.ts +19 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +7 -0
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-filter/commit-grep.d.ts +3 -1
- package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -1
- package/dist/commands/rev-list-command.d.ts +78 -3
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/rev-parse-command.d.ts +9 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +32 -1
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +7 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +12 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +120 -1
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +10 -1
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +23 -1
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/session-id.d.ts +18 -0
- package/dist/commands/session-id.d.ts.map +1 -0
- package/dist/commands/shortlog-command.d.ts +109 -0
- package/dist/commands/shortlog-command.d.ts.map +1 -0
- package/dist/commands/shortlog.d.ts +151 -0
- package/dist/commands/shortlog.d.ts.map +1 -0
- package/dist/commands/show-branch-command.d.ts +59 -0
- package/dist/commands/show-branch-command.d.ts.map +1 -0
- package/dist/commands/show-ref-command.d.ts +112 -0
- package/dist/commands/show-ref-command.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +9 -2
- package/dist/commands/signature-check.d.ts.map +1 -1
- package/dist/commands/signing.d.ts +22 -1
- package/dist/commands/signing.d.ts.map +1 -1
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-export-command.d.ts +115 -0
- package/dist/commands/stash-export-command.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +33 -3
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/stripspace-command.d.ts +44 -0
- package/dist/commands/stripspace-command.d.ts.map +1 -0
- package/dist/commands/submodule-add-command.d.ts +10 -1
- package/dist/commands/submodule-add-command.d.ts.map +1 -1
- package/dist/commands/submodule-auth.d.ts +3 -1
- package/dist/commands/submodule-auth.d.ts.map +1 -1
- package/dist/commands/submodule-commands.d.ts +99 -3
- package/dist/commands/submodule-commands.d.ts.map +1 -1
- package/dist/commands/submodule-fetch.d.ts +149 -0
- package/dist/commands/submodule-fetch.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +8 -0
- package/dist/commands/submodule-model.d.ts.map +1 -1
- package/dist/commands/submodule-unpack.d.ts +120 -0
- package/dist/commands/submodule-unpack.d.ts.map +1 -0
- package/dist/commands/submodule-update-command.d.ts +21 -1
- package/dist/commands/submodule-update-command.d.ts.map +1 -1
- package/dist/commands/subtree-shift.d.ts +27 -0
- package/dist/commands/subtree-shift.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts +3 -0
- package/dist/commands/switch-command.d.ts.map +1 -1
- package/dist/commands/textconv-cache.d.ts +58 -0
- package/dist/commands/textconv-cache.d.ts.map +1 -0
- package/dist/commands/tree-restore.d.ts +5 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/unpack-objects-command.d.ts +47 -0
- package/dist/commands/unpack-objects-command.d.ts.map +1 -0
- package/dist/commands/update-index-command.d.ts +110 -0
- package/dist/commands/update-index-command.d.ts.map +1 -0
- package/dist/commands/uri-protocols.d.ts +13 -0
- package/dist/commands/uri-protocols.d.ts.map +1 -0
- package/dist/commands/url-parse-command.d.ts +30 -0
- package/dist/commands/url-parse-command.d.ts.map +1 -0
- package/dist/commands/var-command.d.ts +42 -0
- package/dist/commands/var-command.d.ts.map +1 -0
- package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/{commands-ISM52N0n.js → commands-Mlo1dxQN.js} +56133 -70269
- package/dist/errors/command-errors.d.ts +58 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +67 -1
- package/dist/fsck-CrhVMNIH.js +5179 -0
- package/dist/git-command.d.ts +89 -3
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +628 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +84 -0
- package/dist/guarded-transport-command.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/maintenance-run-command-Bw21HEkH.js +13539 -0
- package/dist/remote-transport-Bu4PGSMD.js +2605 -0
- package/dist/rename/detect-renames.d.ts +20 -0
- package/dist/rename/detect-renames.d.ts.map +1 -1
- package/dist/rename/diffcore-break.d.ts +51 -0
- package/dist/rename/diffcore-break.d.ts.map +1 -0
- package/dist/rename/index.d.ts +1 -0
- package/dist/rename/index.d.ts.map +1 -1
- package/dist/results/blame-format.d.ts +62 -1
- package/dist/results/blame-format.d.ts.map +1 -1
- package/dist/results/cherry-pick-result.d.ts +6 -0
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +9 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/diff-dirstat.d.ts +36 -0
- package/dist/results/diff-dirstat.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +20 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +67 -3
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/fetch-result.d.ts +24 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +2 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/init-result.d.ts +8 -1
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/line-range-hunks.d.ts +27 -0
- package/dist/results/line-range-hunks.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +13 -1
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +11 -0
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +10 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +7 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +6 -0
- package/dist/results/revert-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +5 -0
- package/dist/results/stash-result.d.ts.map +1 -1
- package/dist/results/status-result.d.ts +1 -1
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-ERo9vELd.js +49673 -0
- package/dist/transport-command.d.ts +93 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/commands/add-command.ts +118 -0
- package/src/commands/add-patch/add-patch.ts +8 -0
- package/src/commands/add-patch/patch-backend.ts +24 -3
- package/src/commands/add-patch/patch-modes.ts +26 -2
- package/src/commands/add-patch/patch-session.ts +6 -0
- package/src/commands/am/am-command.ts +301 -12
- package/src/commands/apply/apply-command.ts +52 -9
- package/src/commands/apply/apply-parse.ts +10 -0
- package/src/commands/apply/index.ts +9 -1
- package/src/commands/archive/archive-command.ts +1148 -0
- package/src/commands/archive/archive-entry.ts +93 -0
- package/src/commands/archive/index.ts +7 -0
- package/src/commands/archive/remote-archive-command.ts +140 -0
- package/src/commands/archive/tar-archive.ts +207 -0
- package/src/commands/archive/tar-commit-id.ts +72 -0
- package/src/commands/archive/upload-archive-writer.ts +213 -0
- package/src/commands/archive/zip-archive.ts +317 -0
- package/src/commands/attributes-source.ts +26 -12
- package/src/commands/blame-command.ts +1551 -53
- package/src/commands/blame-ignore.ts +307 -0
- package/src/commands/bundle/bundle-create-command.ts +405 -0
- package/src/commands/bundle/bundle-format.ts +228 -0
- package/src/commands/bundle/bundle-list.ts +276 -0
- package/src/commands/bundle/bundle-read-commands.ts +157 -0
- package/src/commands/bundle/bundle-support.ts +85 -0
- package/src/commands/bundle/bundle-transport.ts +107 -0
- package/src/commands/bundle/bundle-uri-host.ts +204 -0
- package/src/commands/bundle/bundle-uri.ts +236 -0
- package/src/commands/bundle/bundle-verify.ts +152 -0
- package/src/commands/bundle/index.ts +14 -0
- package/src/commands/cat-file/batch-format.ts +193 -0
- package/src/commands/cat-file/cat-file-command.ts +857 -0
- package/src/commands/cat-file/index.ts +2 -0
- package/src/commands/check-attr-command.ts +333 -0
- package/src/commands/check-ignore-command.ts +261 -0
- package/src/commands/check-mailmap-command.ts +129 -0
- package/src/commands/check-ref-format-command.ts +129 -0
- package/src/commands/checkout-command.ts +131 -28
- package/src/commands/checkout-index-command.ts +568 -0
- package/src/commands/checkout-paths.ts +35 -0
- package/src/commands/cherry-command.ts +187 -0
- package/src/commands/cherry-pick-command.ts +63 -2
- package/src/commands/clean-command.ts +92 -12
- package/src/commands/clean-interactive.ts +522 -0
- package/src/commands/clone-command.ts +803 -50
- package/src/commands/commit-command.ts +202 -51
- package/src/commands/config-command.ts +9 -0
- package/src/commands/daemon-access-hook.ts +78 -0
- package/src/commands/default-branch.ts +99 -1
- package/src/commands/describe-command.ts +341 -254
- package/src/commands/diff-command.ts +1186 -99
- package/src/commands/diff-external.ts +131 -0
- package/src/commands/diff-plumbing/diff-pairs-command.ts +193 -0
- package/src/commands/diff-plumbing/diff-plumbing-command.ts +424 -0
- package/src/commands/diff-plumbing/index.ts +2 -0
- package/src/commands/diff-textconv.ts +5 -1
- package/src/commands/fast-export/fast-export-command.ts +911 -0
- package/src/commands/fast-export/fast-import-command.ts +1553 -0
- package/src/commands/fast-export/fast-stream-support.ts +162 -0
- package/src/commands/fast-export/index.ts +3 -0
- package/src/commands/fetch-command.ts +665 -14
- package/src/commands/fetch-multiple-command.ts +668 -0
- package/src/commands/format-patch-command.ts +189 -77
- package/src/commands/format-rev-command.ts +251 -0
- package/src/commands/fsck/fsck-command.ts +47 -20
- package/src/commands/fsck/fsck-msg-ids.ts +19 -3
- package/src/commands/fsck/fsck-pack.ts +2 -2
- package/src/commands/fsmonitor-refresh.ts +315 -0
- package/src/commands/gc-command.ts +10 -0
- package/src/commands/git-describe.ts +456 -217
- package/src/commands/git-hooks.ts +165 -9
- package/src/commands/git-paths.ts +136 -0
- package/src/commands/grep/grep-command.ts +38 -15
- package/src/commands/history-command.ts +617 -0
- package/src/commands/http-config.ts +139 -0
- package/src/commands/index-adder.ts +37 -3
- package/src/commands/index-host.ts +6 -1
- package/src/commands/index.ts +62 -0
- package/src/commands/init-command.ts +617 -49
- package/src/commands/last-modified-command.ts +804 -0
- package/src/commands/lfs/go-url.ts +370 -0
- package/src/commands/lfs/index.ts +2 -0
- package/src/commands/lfs/lfs-config.ts +738 -0
- package/src/commands/lfs/lfs-endpoint-command.ts +180 -0
- package/src/commands/line-log.ts +931 -0
- package/src/commands/local-transport.ts +252 -4
- package/src/commands/log-command.ts +1518 -182
- package/src/commands/log-graph.ts +6 -3
- package/src/commands/log-output.ts +228 -15
- package/src/commands/ls-files-command.ts +1177 -0
- package/src/commands/ls-remote-command.ts +6 -0
- package/src/commands/ls-tree-command.ts +684 -0
- package/src/commands/mailmap.ts +41 -5
- package/src/commands/maintenance-run-command.ts +949 -0
- package/src/commands/merge-command.ts +351 -47
- package/src/commands/merge-config.ts +23 -1
- package/src/commands/merge-drivers.ts +112 -20
- package/src/commands/merge-strategy-options.ts +224 -0
- package/src/commands/merge-support.ts +130 -26
- package/src/commands/merge-tree-command.ts +786 -0
- package/src/commands/message-cleanup.ts +1 -1
- package/src/commands/mktag-command.ts +149 -0
- package/src/commands/name-rev-command.ts +184 -0
- package/src/commands/name-rev.ts +700 -109
- package/src/commands/object-store/count-objects-command.ts +404 -0
- package/src/commands/object-store/index.ts +4 -0
- package/src/commands/object-store/objects-directory.ts +24 -0
- package/src/commands/object-store/prune-command.ts +129 -0
- package/src/commands/object-store/show-index-command.ts +151 -0
- package/src/commands/octopus-merge.ts +35 -11
- package/src/commands/ort-merge.ts +124 -23
- package/src/commands/ort-recursive.ts +40 -2
- package/src/commands/patch-id-command.ts +65 -0
- package/src/commands/patch-id.ts +327 -0
- package/src/commands/plumbing-command.ts +141 -0
- package/src/commands/plumbing-input.ts +87 -0
- package/src/commands/promisor-remote-reply.ts +276 -0
- package/src/commands/promisor-remote.ts +25 -2
- package/src/commands/pull-command.ts +720 -224
- package/src/commands/push-command.ts +440 -8
- package/src/commands/range-diff/index.ts +3 -0
- package/src/commands/range-diff/linear-assignment.ts +203 -0
- package/src/commands/range-diff/range-diff-command.ts +433 -0
- package/src/commands/range-diff/range-diff.ts +617 -0
- package/src/commands/read-tree-command.ts +74 -3
- package/src/commands/rebase-command.ts +647 -83
- package/src/commands/refs-command.ts +274 -0
- package/src/commands/remerge-diff.ts +241 -0
- package/src/commands/remote-command.ts +98 -10
- package/src/commands/remote-object-info-command.ts +109 -0
- package/src/commands/remote-show-command.ts +836 -0
- package/src/commands/remote-transport.ts +116 -1
- package/src/commands/repack-command.ts +383 -0
- package/src/commands/replace-command.ts +816 -0
- package/src/commands/replay-command.ts +674 -0
- package/src/commands/repo-command.ts +967 -0
- package/src/commands/request-pull-command.ts +356 -0
- package/src/commands/rerere-command.ts +179 -0
- package/src/commands/rerere.ts +925 -0
- package/src/commands/reset-command.ts +78 -3
- package/src/commands/restore-command.ts +15 -0
- package/src/commands/rev-filter/commit-grep.ts +7 -2
- package/src/commands/rev-list-command.ts +196 -11
- package/src/commands/rev-parse-command.ts +62 -4
- package/src/commands/revert-command.ts +62 -2
- package/src/commands/revision-range.ts +10 -3
- package/src/commands/revision-resolver.ts +44 -3
- package/src/commands/sequencer-pick.ts +370 -29
- package/src/commands/sequencer-support.ts +164 -2
- package/src/commands/serve-repository.ts +65 -0
- package/src/commands/session-id.ts +31 -0
- package/src/commands/shortlog-command.ts +354 -0
- package/src/commands/shortlog.ts +361 -0
- package/src/commands/show-branch-command.ts +981 -0
- package/src/commands/show-command.ts +3 -2
- package/src/commands/show-ref-command.ts +439 -0
- package/src/commands/signature-check.ts +37 -5
- package/src/commands/signing.ts +122 -16
- package/src/commands/stash-apply-command.ts +3 -0
- package/src/commands/stash-export-command.ts +397 -0
- package/src/commands/status-command.ts +158 -31
- package/src/commands/status-format.ts +1 -1
- package/src/commands/stripspace-command.ts +118 -0
- package/src/commands/submodule-add-command.ts +22 -1
- package/src/commands/submodule-auth.ts +61 -6
- package/src/commands/submodule-commands.ts +333 -5
- package/src/commands/submodule-fetch.ts +789 -0
- package/src/commands/submodule-model.ts +9 -1
- package/src/commands/submodule-unpack.ts +265 -0
- package/src/commands/submodule-update-command.ts +68 -5
- package/src/commands/subtree-shift.ts +215 -0
- package/src/commands/switch-command.ts +9 -0
- package/src/commands/textconv-cache.ts +143 -0
- package/src/commands/tree-restore.ts +20 -1
- package/src/commands/unpack-objects-command.ts +235 -0
- package/src/commands/update-index-command.ts +1016 -0
- package/src/commands/uri-protocols.ts +13 -0
- package/src/commands/url-parse-command.ts +67 -0
- package/src/commands/var-command.ts +219 -0
- package/src/commands/worktree-overwrite-checks.ts +5 -0
- package/src/errors/command-errors.ts +80 -0
- package/src/git-command.ts +218 -2
- package/src/git.ts +1033 -80
- package/src/guarded-transport-command.ts +176 -0
- package/src/index.ts +1 -0
- package/src/rename/detect-renames.ts +42 -8
- package/src/rename/diffcore-break.ts +166 -0
- package/src/rename/index.ts +1 -0
- package/src/results/blame-format.ts +268 -43
- package/src/results/cherry-pick-result.ts +6 -0
- package/src/results/clone-result.ts +6 -0
- package/src/results/diff-dirstat.ts +117 -0
- package/src/results/diff-entry.ts +24 -0
- package/src/results/diff-formatter.ts +8 -4
- package/src/results/diff-output.ts +239 -8
- package/src/results/diff-pickaxe.ts +1 -1
- package/src/results/fetch-result.ts +24 -1
- package/src/results/index.ts +2 -0
- package/src/results/init-result.ts +10 -1
- package/src/results/line-range-hunks.ts +126 -0
- package/src/results/merge-result.ts +14 -0
- package/src/results/pull-result.ts +7 -0
- package/src/results/push-result.ts +10 -0
- package/src/results/rebase-result.ts +7 -0
- package/src/results/revert-result.ts +6 -0
- package/src/results/stash-result.ts +6 -0
- package/src/results/status-result.ts +2 -2
- package/src/transport-command.ts +216 -4
- package/dist/fsck-DLRpbwTj.js +0 -13405
- package/dist/results-TB2IJ64h.js +0 -4700
|
@@ -0,0 +1,911 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `git fast-export` (builtin/fast-export.c): the history the revision arguments name as a
|
|
3
|
+
* fast-import stream, written to stdout as git writes it.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* // git fast-export --all > stream
|
|
8
|
+
* const { stdout, exitCode } = await git.fastExport().addArgument("--all").callOutput();
|
|
9
|
+
* // git fast-export --signed-tags=strip --export-marks=marks main~2..main
|
|
10
|
+
* await git
|
|
11
|
+
* .fastExport()
|
|
12
|
+
* .setSignedTags("strip")
|
|
13
|
+
* .setExportMarks("marks")
|
|
14
|
+
* .setMarksFiles(files)
|
|
15
|
+
* .addArgument("main~2..main")
|
|
16
|
+
* .setStdout((chunk) => out.push(chunk))
|
|
17
|
+
* .call();
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { ObjectId, TreeEntry } from "@statewalker/vcs-core";
|
|
22
|
+
import { encodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
23
|
+
import { quoteCStyleBody } from "../../results/quote-path.js";
|
|
24
|
+
import { configValue } from "../merge-config.js";
|
|
25
|
+
import { PlumbingCommand, PlumbingError } from "../plumbing-command.js";
|
|
26
|
+
import { RevListCommand } from "../rev-list-command.js";
|
|
27
|
+
import {
|
|
28
|
+
type FastMarksFiles,
|
|
29
|
+
latin1,
|
|
30
|
+
latin1Bytes,
|
|
31
|
+
readObjectBytes,
|
|
32
|
+
type SignMode,
|
|
33
|
+
signatureFormatOf,
|
|
34
|
+
signatureStartOf,
|
|
35
|
+
writableSink,
|
|
36
|
+
} from "./fast-stream-support.js";
|
|
37
|
+
|
|
38
|
+
/** `--tag-of-filtered-object=<mode>` */
|
|
39
|
+
export type TagOfFilteredMode = "abort" | "drop" | "rewrite";
|
|
40
|
+
/** `--reencode=<mode>` */
|
|
41
|
+
export type ReencodeMode = "yes" | "no" | "abort";
|
|
42
|
+
|
|
43
|
+
const TREE_MODE = 0o040000;
|
|
44
|
+
const GITLINK_MODE = 0o160000;
|
|
45
|
+
const NULL_SHA1 = "0".repeat(40);
|
|
46
|
+
|
|
47
|
+
/** One changed path of a commit's diff against its parent (diff_filepair). */
|
|
48
|
+
interface FilePair {
|
|
49
|
+
status: "A" | "D" | "M" | "T";
|
|
50
|
+
path: string;
|
|
51
|
+
mode: number;
|
|
52
|
+
id: ObjectId | undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* git's `decoration` hash table of marks (object.c's `add_decoration`): export-marks lists
|
|
57
|
+
* its commits in the table's slot order, which this keeps.
|
|
58
|
+
*/
|
|
59
|
+
class MarkDecoration {
|
|
60
|
+
private slots: ({ id: ObjectId; mark: number; commit: boolean } | undefined)[] = [];
|
|
61
|
+
private count = 0;
|
|
62
|
+
|
|
63
|
+
insert(id: ObjectId, mark: number, commit: boolean): void {
|
|
64
|
+
if ((this.count + 1) * 3 >= this.slots.length * 2) this.grow();
|
|
65
|
+
this.place({ id, mark, commit });
|
|
66
|
+
this.count++;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private place(entry: { id: ObjectId; mark: number; commit: boolean }): void {
|
|
70
|
+
const size = this.slots.length;
|
|
71
|
+
let j = hashObj(entry.id) % size;
|
|
72
|
+
for (;;) {
|
|
73
|
+
const at = this.slots[j];
|
|
74
|
+
if (!at) break;
|
|
75
|
+
if (at.id === entry.id) {
|
|
76
|
+
at.mark = entry.mark;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (++j >= size) j = 0;
|
|
80
|
+
}
|
|
81
|
+
this.slots[j] = entry;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private grow(): void {
|
|
85
|
+
const old = this.slots;
|
|
86
|
+
const size = Math.floor(((old.length + 1000) * 3) / 2);
|
|
87
|
+
this.slots = new Array(size).fill(undefined);
|
|
88
|
+
for (const e of old) if (e) this.place(e);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The commits' marks in slot order (export_marks). */
|
|
92
|
+
commits(): { id: ObjectId; mark: number }[] {
|
|
93
|
+
return this.slots.filter((s) => s?.commit) as { id: ObjectId; mark: number }[];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** object.c's hash_obj: the id's first four bytes as a little-endian unsigned int */
|
|
98
|
+
function hashObj(id: ObjectId): number {
|
|
99
|
+
const b = (i: number) => Number.parseInt(id.slice(i * 2, i * 2 + 2), 16);
|
|
100
|
+
return (b(0) | (b(1) << 8) | (b(2) << 16) | (b(3) << 24)) >>> 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** A fetch refspec as fast-export applies it (`--refspec`): `src:dst`, with one `*` each. */
|
|
104
|
+
interface ExportRefspec {
|
|
105
|
+
src: string;
|
|
106
|
+
dst: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function parseRefspec(spec: string): ExportRefspec {
|
|
110
|
+
const text = spec.startsWith("+") ? spec.slice(1) : spec;
|
|
111
|
+
const colon = text.indexOf(":");
|
|
112
|
+
return colon < 0
|
|
113
|
+
? { src: text, dst: "" }
|
|
114
|
+
: { src: text.slice(0, colon), dst: text.slice(colon + 1) };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** refspec.c's query_refspecs for one name: the first refspec mapping it, else undefined. */
|
|
118
|
+
function applyRefspecs(specs: readonly ExportRefspec[], name: string): string | undefined {
|
|
119
|
+
for (const { src, dst } of specs) {
|
|
120
|
+
if (!src) continue;
|
|
121
|
+
const star = src.indexOf("*");
|
|
122
|
+
if (star < 0) {
|
|
123
|
+
if (src === name) return dst;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const prefix = src.slice(0, star);
|
|
127
|
+
const suffix = src.slice(star + 1);
|
|
128
|
+
if (
|
|
129
|
+
name.length >= prefix.length + suffix.length &&
|
|
130
|
+
name.startsWith(prefix) &&
|
|
131
|
+
name.endsWith(suffix)
|
|
132
|
+
) {
|
|
133
|
+
const matched = name.slice(prefix.length, name.length - suffix.length);
|
|
134
|
+
return dst.replace("*", matched);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Writes the history the revisions name as a fast-import stream (`git fast-export`).
|
|
142
|
+
*
|
|
143
|
+
* Commits come in git's order (a reversed topological walk, `--topo-order`), each with the
|
|
144
|
+
* blobs its diff against its first parent adds before it (all of its tree for a root commit,
|
|
145
|
+
* a commit whose first parent is not exported, or `--full-tree`), and is named by the ref it
|
|
146
|
+
* was reached from (git's `revision_sources`); refs naming exported commits from another
|
|
147
|
+
* name get `reset` lines, annotated tags `tag` commands, at the end. Marks are numbered as
|
|
148
|
+
* git numbers them, so the stream is git's byte for byte.
|
|
149
|
+
*
|
|
150
|
+
* Not supported: pathspecs, `--anonymize`, rename and copy detection (`-M`, `-C`).
|
|
151
|
+
*
|
|
152
|
+
* Version differences (`setCompatibility`): 2.43 finds a tag's signature only as a PGP
|
|
153
|
+
* signature after a newline and words several messages with a capital letter; 2.5x knows
|
|
154
|
+
* every signature format and `--signed-commits`.
|
|
155
|
+
*/
|
|
156
|
+
export class FastExportCommand extends PlumbingCommand {
|
|
157
|
+
private readonly revisions: string[] = [];
|
|
158
|
+
private progressEvery = 0;
|
|
159
|
+
private signedTags: SignMode = "abort";
|
|
160
|
+
private signedCommits: SignMode = "strip";
|
|
161
|
+
private tagOfFiltered: TagOfFilteredMode = "abort";
|
|
162
|
+
private reencode: ReencodeMode = "abort";
|
|
163
|
+
private exportMarksPath?: string;
|
|
164
|
+
private importMarksPath?: string;
|
|
165
|
+
private importMarksIfExistsPath?: string;
|
|
166
|
+
private marksFiles?: FastMarksFiles;
|
|
167
|
+
private fakeMissingTagger = false;
|
|
168
|
+
private fullTree = false;
|
|
169
|
+
private useDoneFeature = false;
|
|
170
|
+
private noData = false;
|
|
171
|
+
private readonly refspecs: ExportRefspec[] = [];
|
|
172
|
+
private referenceExcluded = false;
|
|
173
|
+
private showOriginalIds = false;
|
|
174
|
+
private markTags = false;
|
|
175
|
+
private compatibility: "2.43" | "2.56" = "2.56";
|
|
176
|
+
|
|
177
|
+
// the run's state
|
|
178
|
+
private lastIdnum = 0;
|
|
179
|
+
private readonly marks = new Map<ObjectId, number>();
|
|
180
|
+
private readonly decoration = new MarkDecoration();
|
|
181
|
+
/** Blobs and commits already written or imported (git's SHOWN) */
|
|
182
|
+
private readonly shown = new Set<ObjectId>();
|
|
183
|
+
private progressCounter = 0;
|
|
184
|
+
private quotePathFully = true;
|
|
185
|
+
|
|
186
|
+
private outputStream?: WritableStream<Uint8Array>;
|
|
187
|
+
|
|
188
|
+
/** Where the stream goes, as a Web Stream (in place of `setStdout`); not closed here. */
|
|
189
|
+
setOutput(stream: WritableStream<Uint8Array>): this {
|
|
190
|
+
this.checkCallable();
|
|
191
|
+
this.outputStream = stream;
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
override async call() {
|
|
196
|
+
if (!this.outputStream) return super.call();
|
|
197
|
+
const { sink, release } = writableSink(this.outputStream);
|
|
198
|
+
this.setStdout(sink);
|
|
199
|
+
try {
|
|
200
|
+
return await super.call();
|
|
201
|
+
} finally {
|
|
202
|
+
release();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** A revision argument (`main`, `^v1`, `a..b`, `--all`, ...), as `git rev-list` reads it. */
|
|
207
|
+
addArgument(arg: string): this {
|
|
208
|
+
this.checkCallable();
|
|
209
|
+
this.revisions.push(arg);
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** `--progress=<n>`: a `progress <n> objects` line after every n objects. */
|
|
214
|
+
setProgressEvery(every: number): this {
|
|
215
|
+
this.checkCallable();
|
|
216
|
+
this.progressEvery = every;
|
|
217
|
+
return this;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** `--signed-tags=<mode>` (default `abort`). */
|
|
221
|
+
setSignedTags(mode: SignMode): this {
|
|
222
|
+
this.checkCallable();
|
|
223
|
+
this.signedTags = mode;
|
|
224
|
+
return this;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** `--signed-commits=<mode>` (git 2.50+, default `strip`). */
|
|
228
|
+
setSignedCommits(mode: SignMode): this {
|
|
229
|
+
this.checkCallable();
|
|
230
|
+
this.signedCommits = mode;
|
|
231
|
+
return this;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** `--tag-of-filtered-object=<mode>` (default `abort`). */
|
|
235
|
+
setTagOfFilteredObject(mode: TagOfFilteredMode): this {
|
|
236
|
+
this.checkCallable();
|
|
237
|
+
this.tagOfFiltered = mode;
|
|
238
|
+
return this;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** `--reencode=<mode>` (default `abort`). */
|
|
242
|
+
setReencode(mode: ReencodeMode): this {
|
|
243
|
+
this.checkCallable();
|
|
244
|
+
this.reencode = mode;
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** Where marks files are read and written ({@link setImportMarks}, {@link setExportMarks}). */
|
|
249
|
+
setMarksFiles(files: FastMarksFiles): this {
|
|
250
|
+
this.checkCallable();
|
|
251
|
+
this.marksFiles = files;
|
|
252
|
+
return this;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** `--export-marks=<file>`: written only when the run marked something new. */
|
|
256
|
+
setExportMarks(path: string | undefined): this {
|
|
257
|
+
this.checkCallable();
|
|
258
|
+
this.exportMarksPath = path;
|
|
259
|
+
return this;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** `--import-marks=<file>` (or `--import-marks-if-exists=<file>` with `ifExists`). */
|
|
263
|
+
setImportMarks(path: string | undefined, options: { ifExists?: boolean } = {}): this {
|
|
264
|
+
this.checkCallable();
|
|
265
|
+
if (options.ifExists) this.importMarksIfExistsPath = path;
|
|
266
|
+
else this.importMarksPath = path;
|
|
267
|
+
return this;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** `--fake-missing-tagger` */
|
|
271
|
+
setFakeMissingTagger(fake: boolean): this {
|
|
272
|
+
this.checkCallable();
|
|
273
|
+
this.fakeMissingTagger = fake;
|
|
274
|
+
return this;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** `--full-tree`: every commit lists its whole tree after a `deleteall`. */
|
|
278
|
+
setFullTree(full: boolean): this {
|
|
279
|
+
this.checkCallable();
|
|
280
|
+
this.fullTree = full;
|
|
281
|
+
return this;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** `--use-done-feature` */
|
|
285
|
+
setUseDoneFeature(use: boolean): this {
|
|
286
|
+
this.checkCallable();
|
|
287
|
+
this.useDoneFeature = use;
|
|
288
|
+
return this;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** `--no-data`: blobs are named by id, never written. */
|
|
292
|
+
setNoData(noData: boolean): this {
|
|
293
|
+
this.checkCallable();
|
|
294
|
+
this.noData = noData;
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** `--refspec=<refspec>`: exported ref names are mapped (an empty source deletes). */
|
|
299
|
+
addRefspec(refspec: string): this {
|
|
300
|
+
this.checkCallable();
|
|
301
|
+
this.refspecs.push(parseRefspec(refspec));
|
|
302
|
+
return this;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** `--reference-excluded-parents` */
|
|
306
|
+
setReferenceExcludedParents(reference: boolean): this {
|
|
307
|
+
this.checkCallable();
|
|
308
|
+
this.referenceExcluded = reference;
|
|
309
|
+
return this;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** `--show-original-ids` */
|
|
313
|
+
setShowOriginalIds(show: boolean): this {
|
|
314
|
+
this.checkCallable();
|
|
315
|
+
this.showOriginalIds = show;
|
|
316
|
+
return this;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** `--mark-tags` */
|
|
320
|
+
setMarkTags(mark: boolean): this {
|
|
321
|
+
this.checkCallable();
|
|
322
|
+
this.markTags = mark;
|
|
323
|
+
return this;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** The git version whose output is followed (default 2.56). */
|
|
327
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
328
|
+
this.checkCallable();
|
|
329
|
+
this.compatibility = version;
|
|
330
|
+
return this;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
private die(message: string, message243 = message): never {
|
|
334
|
+
throw new PlumbingError(`fatal: ${this.compatibility === "2.43" ? message243 : message}`);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
private async out(text: string | Uint8Array): Promise<void> {
|
|
338
|
+
await this.write(typeof text === "string" ? latin1Bytes(text) : text);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
private async showProgress(): Promise<void> {
|
|
342
|
+
if (this.progressEvery && !(++this.progressCounter % this.progressEvery)) {
|
|
343
|
+
await this.out(`progress ${this.progressCounter} objects\n`);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
private markNext(id: ObjectId, commit: boolean): number {
|
|
348
|
+
const mark = ++this.lastIdnum;
|
|
349
|
+
this.marks.set(id, mark);
|
|
350
|
+
this.decoration.insert(id, mark, commit);
|
|
351
|
+
return mark;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
private get objects() {
|
|
355
|
+
const objects = this.workingCopy.history?.objects;
|
|
356
|
+
if (!objects) throw new Error("fast-export needs the object store (history.objects)");
|
|
357
|
+
return objects;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
protected async run(): Promise<number> {
|
|
361
|
+
const quote = configValue(this.workingCopy, "core.quotePath");
|
|
362
|
+
this.quotePathFully = quote === undefined ? true : !/^(false|no|off|0)$/i.test(quote);
|
|
363
|
+
|
|
364
|
+
if (this.useDoneFeature) await this.out("feature done\n");
|
|
365
|
+
if (this.importMarksPath !== undefined && this.importMarksIfExistsPath !== undefined) {
|
|
366
|
+
this.die("options '--import-marks' and '--import-marks-if-exists' cannot be used together");
|
|
367
|
+
}
|
|
368
|
+
if (this.importMarksPath !== undefined) await this.importMarks(this.importMarksPath, false);
|
|
369
|
+
else if (this.importMarksIfExistsPath !== undefined) {
|
|
370
|
+
await this.importMarks(this.importMarksIfExistsPath, true);
|
|
371
|
+
}
|
|
372
|
+
const lastImportId = this.lastIdnum;
|
|
373
|
+
|
|
374
|
+
// the command line's entries (rev_cmdline_info), objects as named
|
|
375
|
+
const parsed = await this.revList().setCommittish(false).resolve();
|
|
376
|
+
const extraRefs = new Map<string, ObjectId>();
|
|
377
|
+
const tagRefs: { name: string; tag: ObjectId }[] = [];
|
|
378
|
+
/** revision_sources set before the walk (get_tags_and_duplicates) */
|
|
379
|
+
const preset = new Map<ObjectId, string>();
|
|
380
|
+
/** The first positive entry's commit per name, for the walk's sources */
|
|
381
|
+
const tipOfName = new Map<string, ObjectId>();
|
|
382
|
+
const resolver = this.revisionResolver();
|
|
383
|
+
for (const e of parsed.entries) {
|
|
384
|
+
if (e.exclude || e.name === undefined) continue;
|
|
385
|
+
let full: string;
|
|
386
|
+
const found = await resolver.dwimRef(e.name).catch(() => []);
|
|
387
|
+
const peeledForName = await this.peelToNonTag(e.id);
|
|
388
|
+
if (peeledForName.type === "commit" && !tipOfName.has(e.name)) {
|
|
389
|
+
tipOfName.set(e.name, peeledForName.id);
|
|
390
|
+
}
|
|
391
|
+
if (found.length !== 1) continue;
|
|
392
|
+
full = (found[0] as { ref: string }).ref;
|
|
393
|
+
if (this.refspecs.length > 0) full = applyRefspecs(this.refspecs, full) ?? full;
|
|
394
|
+
|
|
395
|
+
const type = await this.typeOf(e.id);
|
|
396
|
+
let target: { id: ObjectId; type: string } | undefined;
|
|
397
|
+
if (type === "commit") target = { id: e.id, type };
|
|
398
|
+
else if (type === "tag") {
|
|
399
|
+
let id = e.id;
|
|
400
|
+
let t: string | undefined = "tag";
|
|
401
|
+
while (t === "tag") {
|
|
402
|
+
tagRefs.push({ name: full, tag: id });
|
|
403
|
+
id = await this.taggedOf(id);
|
|
404
|
+
t = await this.typeOf(id);
|
|
405
|
+
}
|
|
406
|
+
if (t === undefined) {
|
|
407
|
+
this.die(`tag ${e.name} points nowhere?`, `Tag ${e.name} points nowhere?`);
|
|
408
|
+
}
|
|
409
|
+
target = { id, type: t };
|
|
410
|
+
}
|
|
411
|
+
if (!target) {
|
|
412
|
+
this.warn(
|
|
413
|
+
this.compatibility === "2.43"
|
|
414
|
+
? `warning: ${e.name}: Unexpected object of type ${type}, skipping.`
|
|
415
|
+
: `warning: ${e.name}: unexpected object of type ${type}, skipping.`,
|
|
416
|
+
);
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
if (target.type === "blob") {
|
|
420
|
+
await this.exportBlob(target.id);
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
if (target.type !== "commit") {
|
|
424
|
+
this.warn(
|
|
425
|
+
this.compatibility === "2.43"
|
|
426
|
+
? `warning: Tag points to object of unexpected type ${target.type}, skipping.`
|
|
427
|
+
: `warning: tag points to object of unexpected type ${target.type}, skipping.`,
|
|
428
|
+
);
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
if (type !== "tag" && !extraRefs.has(full)) extraRefs.set(full, target.id);
|
|
432
|
+
if (!preset.has(target.id)) preset.set(target.id, full);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// the walk: git's --topo-order, reversed, with each commit's source
|
|
436
|
+
const walk = this.revList().setOrder("topo").setReverse(true).setSource(true);
|
|
437
|
+
const commits = this.revisions.length > 0 ? await walk.call() : [];
|
|
438
|
+
for await (const commit of commits) {
|
|
439
|
+
if (this.shown.has(commit.id)) continue;
|
|
440
|
+
let name = preset.get(commit.id);
|
|
441
|
+
if (name === undefined) {
|
|
442
|
+
const source = commit.source ?? "";
|
|
443
|
+
const tip = tipOfName.get(source);
|
|
444
|
+
name = (tip !== undefined ? preset.get(tip) : undefined) ?? source;
|
|
445
|
+
}
|
|
446
|
+
extraRefs.delete(name);
|
|
447
|
+
await this.handleCommit(commit.id, name);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const sortedExtras = [...extraRefs.entries()].sort(([a], [b]) => compareBytes(a, b));
|
|
451
|
+
for (let i = sortedExtras.length - 1; i >= 0; i--) {
|
|
452
|
+
const [name, id] = sortedExtras[i] as [string, ObjectId];
|
|
453
|
+
const mark = this.marks.get(id);
|
|
454
|
+
if (!mark) {
|
|
455
|
+
await this.out(`reset ${bin(name)}\nfrom ${this.referenceExcluded ? id : NULL_SHA1}\n\n`);
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
await this.out(`reset ${bin(name)}\nfrom :${mark}\n\n`);
|
|
459
|
+
await this.showProgress();
|
|
460
|
+
}
|
|
461
|
+
for (let i = tagRefs.length - 1; i >= 0; i--) {
|
|
462
|
+
const { name, tag } = tagRefs[i] as { name: string; tag: ObjectId };
|
|
463
|
+
await this.handleTag(name, tag);
|
|
464
|
+
}
|
|
465
|
+
for (const { src, dst } of this.refspecs) {
|
|
466
|
+
if (!src) await this.out(`reset ${bin(dst)}\nfrom ${NULL_SHA1}\n\n`);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (this.exportMarksPath !== undefined && lastImportId !== this.lastIdnum) {
|
|
470
|
+
const text = this.decoration
|
|
471
|
+
.commits()
|
|
472
|
+
.map(({ id, mark }) => `:${mark} ${id}\n`)
|
|
473
|
+
.join("");
|
|
474
|
+
await this.marksFilesOrDie().write(this.exportMarksPath, latin1Bytes(text));
|
|
475
|
+
}
|
|
476
|
+
if (this.useDoneFeature) await this.out("done\n");
|
|
477
|
+
return 0;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
private revList(): RevListCommand {
|
|
481
|
+
const cmd = new RevListCommand(this.workingCopy);
|
|
482
|
+
for (const r of this.revisions) cmd.addRevision(r);
|
|
483
|
+
return cmd;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
private marksFilesOrDie(): FastMarksFiles {
|
|
487
|
+
if (!this.marksFiles) throw new Error("fast-export marks files need setMarksFiles");
|
|
488
|
+
return this.marksFiles;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
private async typeOf(id: ObjectId): Promise<string | undefined> {
|
|
492
|
+
const header = await this.objects.header?.(id).catch(() => undefined);
|
|
493
|
+
if (header) return header.type;
|
|
494
|
+
return (await readObjectBytes(this.objects, id))?.type;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
private async taggedOf(tag: ObjectId): Promise<ObjectId> {
|
|
498
|
+
const raw = await readObjectBytes(this.objects, tag);
|
|
499
|
+
const text = raw ? latin1(raw.bytes) : "";
|
|
500
|
+
return text.startsWith("object ") ? text.slice(7, text.indexOf("\n")) : "";
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
private async peelToNonTag(id: ObjectId): Promise<{ id: ObjectId; type?: string }> {
|
|
504
|
+
let current = id;
|
|
505
|
+
let type = await this.typeOf(current);
|
|
506
|
+
for (let depth = 0; type === "tag" && depth < 64; depth++) {
|
|
507
|
+
current = await this.taggedOf(current);
|
|
508
|
+
type = await this.typeOf(current);
|
|
509
|
+
}
|
|
510
|
+
return { id: current, ...(type ? { type } : {}) };
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
private async importMarks(path: string, ifExists: boolean): Promise<void> {
|
|
514
|
+
const bytes = await this.marksFilesOrDie().read(path);
|
|
515
|
+
if (bytes === undefined) {
|
|
516
|
+
if (ifExists) return;
|
|
517
|
+
this.die(`could not open '${path}' for reading: No such file or directory`);
|
|
518
|
+
}
|
|
519
|
+
const text = latin1(bytes as Uint8Array);
|
|
520
|
+
let at = 0;
|
|
521
|
+
while (at < text.length) {
|
|
522
|
+
const nl = text.indexOf("\n", at);
|
|
523
|
+
const line = nl < 0 ? text.slice(at) : text.slice(at, nl);
|
|
524
|
+
at = nl < 0 ? text.length : nl + 1;
|
|
525
|
+
const m = /^:(\d+) ([0-9a-f]{40}|[0-9a-f]{64})$/.exec(line);
|
|
526
|
+
if (!m || nl < 0 || m[1] === "0" || /^:0+ /.test(line)) {
|
|
527
|
+
this.die(`corrupt mark line: ${line}${nl < 0 ? "" : ""}`);
|
|
528
|
+
}
|
|
529
|
+
const mark = Number((m as RegExpExecArray)[1]);
|
|
530
|
+
const id = (m as RegExpExecArray)[2] as ObjectId;
|
|
531
|
+
if (this.lastIdnum < mark) this.lastIdnum = mark;
|
|
532
|
+
const type = await this.typeOf(id);
|
|
533
|
+
if (type === undefined) this.die(`object not found: ${id}`);
|
|
534
|
+
if (type !== "commit") continue;
|
|
535
|
+
if (this.shown.has(id)) this.warn(`error: object ${id} already has a mark`);
|
|
536
|
+
this.marks.set(id, mark);
|
|
537
|
+
this.decoration.insert(id, mark, true);
|
|
538
|
+
this.shown.add(id);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
private async exportBlob(id: ObjectId | undefined): Promise<void> {
|
|
543
|
+
if (this.noData || id === undefined || /^0+$/.test(id)) return;
|
|
544
|
+
if (this.shown.has(id)) return;
|
|
545
|
+
const raw = await readObjectBytes(this.objects, id);
|
|
546
|
+
if (!raw) this.die(`could not read blob ${id}`);
|
|
547
|
+
const { bytes } = raw as { bytes: Uint8Array };
|
|
548
|
+
const mark = this.markNext(id, false);
|
|
549
|
+
let header = `blob\nmark :${mark}\n`;
|
|
550
|
+
if (this.showOriginalIds) header += `original-oid ${id}\n`;
|
|
551
|
+
header += `data ${bytes.length}\n`;
|
|
552
|
+
await this.out(header);
|
|
553
|
+
await this.out(bytes);
|
|
554
|
+
await this.out("\n");
|
|
555
|
+
await this.showProgress();
|
|
556
|
+
this.shown.add(id);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/** print_path: C-quoted when needed, else in double quotes when it holds a space. */
|
|
560
|
+
private pathText(path: string): string {
|
|
561
|
+
const body = quoteCStyleBody(path, this.quotePathFully);
|
|
562
|
+
if (body !== undefined) return latin1(encodeGitPath(`"${body}"`));
|
|
563
|
+
const bytes = latin1(encodeGitPath(path));
|
|
564
|
+
return bytes.includes(" ") ? `"${bytes}"` : bytes;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
private async handleCommit(id: ObjectId, refname: string): Promise<void> {
|
|
568
|
+
const raw = await readObjectBytes(this.objects, id);
|
|
569
|
+
if (!raw) this.die(`could not read commit ${id}`);
|
|
570
|
+
const buffer = latin1((raw as { bytes: Uint8Array }).bytes);
|
|
571
|
+
const parents: ObjectId[] = [];
|
|
572
|
+
let tree = "";
|
|
573
|
+
const authorAt = buffer.indexOf("\nauthor ");
|
|
574
|
+
if (authorAt < 0) this.die(`could not find author in commit ${id}`);
|
|
575
|
+
const author = buffer.slice(authorAt + 1, lineEnd(buffer, authorAt + 1));
|
|
576
|
+
let cursor = lineEnd(buffer, authorAt + 1);
|
|
577
|
+
const committerAt = buffer.indexOf("\ncommitter ", cursor);
|
|
578
|
+
if (committerAt < 0) this.die(`could not find committer in commit ${id}`);
|
|
579
|
+
const committer = buffer.slice(committerAt + 1, lineEnd(buffer, committerAt + 1));
|
|
580
|
+
cursor = lineEnd(buffer, committerAt + 1);
|
|
581
|
+
for (const line of buffer.slice(0, authorAt + 1).split("\n")) {
|
|
582
|
+
if (line.startsWith("tree ")) tree = line.slice(5);
|
|
583
|
+
else if (line.startsWith("parent ")) parents.push(line.slice(7));
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
// the headers after the committer: encoding, then the signatures
|
|
587
|
+
let encoding: string | undefined;
|
|
588
|
+
const signatures: { text: string; hash: string }[] = [];
|
|
589
|
+
const messageAt = buffer.indexOf("\n\n", cursor);
|
|
590
|
+
const headerEnd = messageAt < 0 ? buffer.length : messageAt;
|
|
591
|
+
const headers = buffer.slice(cursor + 1, headerEnd);
|
|
592
|
+
const headerLines = cursor < headerEnd ? headers.split("\n") : [];
|
|
593
|
+
if (this.compatibility === "2.43") {
|
|
594
|
+
const enc = headerLines.find((l) => l.startsWith("encoding "));
|
|
595
|
+
if (enc !== undefined) encoding = enc.slice(9);
|
|
596
|
+
} else if (headerLines[0]?.startsWith("encoding ")) {
|
|
597
|
+
encoding = headerLines[0].slice(9);
|
|
598
|
+
}
|
|
599
|
+
if (this.compatibility !== "2.43") {
|
|
600
|
+
for (const [header, hash] of [
|
|
601
|
+
["gpgsig", "sha1"],
|
|
602
|
+
["gpgsig-sha256", "sha256"],
|
|
603
|
+
] as const) {
|
|
604
|
+
for (let i = 0; i < headerLines.length; i++) {
|
|
605
|
+
const line = headerLines[i] as string;
|
|
606
|
+
if (!line.startsWith(`${header} `)) continue;
|
|
607
|
+
let value = line.slice(header.length + 1);
|
|
608
|
+
while (headerLines[i + 1]?.startsWith(" ")) {
|
|
609
|
+
value += `\n${(headerLines[++i] as string).slice(1)}`;
|
|
610
|
+
}
|
|
611
|
+
signatures.push({ text: value, hash });
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
let message = messageAt < 0 ? undefined : buffer.slice(messageAt + 2);
|
|
616
|
+
if (message?.includes("\0")) {
|
|
617
|
+
message = message.slice(0, message.indexOf("\0"));
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// the diff against the first parent, when it is exported (or referenced)
|
|
621
|
+
const first = parents[0];
|
|
622
|
+
const pairs =
|
|
623
|
+
first !== undefined && (this.marks.has(first) || this.referenceExcluded) && !this.fullTree
|
|
624
|
+
? await this.diffTrees(await this.treeOf(first), tree)
|
|
625
|
+
: await this.diffTrees(undefined, tree);
|
|
626
|
+
for (const p of pairs) if (p.mode !== GITLINK_MODE) await this.exportBlob(p.id);
|
|
627
|
+
|
|
628
|
+
const mark = this.markNext(id, true);
|
|
629
|
+
let reencoded: string | undefined;
|
|
630
|
+
if (encoding !== undefined) {
|
|
631
|
+
if (this.reencode === "yes") reencoded = reencodeToUtf8(message ?? "", encoding);
|
|
632
|
+
else if (this.reencode === "abort") {
|
|
633
|
+
this.die(
|
|
634
|
+
`encountered commit-specific encoding ${encoding} in commit ${id}; use --reencode=[yes|no] to handle it`,
|
|
635
|
+
`Encountered commit-specific encoding ${encoding} in commit ${id}; use --reencode=[yes|no] to handle it`,
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
let text = "";
|
|
640
|
+
if (parents.length === 0) text += `reset ${bin(refname)}\n`;
|
|
641
|
+
text += `commit ${bin(refname)}\nmark :${mark}\n`;
|
|
642
|
+
if (this.showOriginalIds) text += `original-oid ${id}\n`;
|
|
643
|
+
text += `${author}\n${committer}\n`;
|
|
644
|
+
// git prints as it goes: what came before a death is on stdout
|
|
645
|
+
await this.out(text);
|
|
646
|
+
text = "";
|
|
647
|
+
if (signatures.length > 0) {
|
|
648
|
+
switch (this.signedCommits) {
|
|
649
|
+
case "warn-verbatim":
|
|
650
|
+
case "warn":
|
|
651
|
+
case "verbatim":
|
|
652
|
+
case "ignore":
|
|
653
|
+
if (this.signedCommits === "warn-verbatim" || this.signedCommits === "warn") {
|
|
654
|
+
this.warn(`warning: exporting ${signatures.length} signature(s) for commit ${id}`);
|
|
655
|
+
}
|
|
656
|
+
for (const s of signatures) {
|
|
657
|
+
text += `gpgsig ${s.hash} ${signatureFormatOf(s.text)}\ndata ${utf8Length(s.text)}\n${s.text}\n`;
|
|
658
|
+
}
|
|
659
|
+
break;
|
|
660
|
+
case "warn-strip":
|
|
661
|
+
this.warn(`warning: stripping signature(s) from commit ${id}`);
|
|
662
|
+
break;
|
|
663
|
+
case "strip":
|
|
664
|
+
break;
|
|
665
|
+
default:
|
|
666
|
+
this.die(`encountered signed commit ${id}; use --signed-commits=<mode> to handle it`);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
if (reencoded === undefined && encoding !== undefined) text += `encoding ${encoding}\n`;
|
|
670
|
+
const body = reencoded ?? message ?? "";
|
|
671
|
+
text += `data ${body.length}\n${body}`;
|
|
672
|
+
let i = 0;
|
|
673
|
+
for (const p of parents) {
|
|
674
|
+
const parentMark = this.marks.get(p);
|
|
675
|
+
if (!parentMark && !this.referenceExcluded) continue;
|
|
676
|
+
text += i === 0 ? "from " : "merge ";
|
|
677
|
+
text += parentMark ? `:${parentMark}\n` : `${p}\n`;
|
|
678
|
+
i++;
|
|
679
|
+
}
|
|
680
|
+
if (this.fullTree) text += "deleteall\n";
|
|
681
|
+
text += this.fileChanges(pairs);
|
|
682
|
+
text += "\n";
|
|
683
|
+
await this.out(text);
|
|
684
|
+
await this.showProgress();
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/** show_filemodify: the changes sorted depth first, files below a directory before it. */
|
|
688
|
+
private fileChanges(pairs: readonly FilePair[]): string {
|
|
689
|
+
const sorted = [...pairs].sort((a, b) => depthFirst(a.path, b.path));
|
|
690
|
+
let text = "";
|
|
691
|
+
for (const p of sorted) {
|
|
692
|
+
if (p.status === "D") {
|
|
693
|
+
text += `D ${this.pathText(p.path)}\n`;
|
|
694
|
+
continue;
|
|
695
|
+
}
|
|
696
|
+
const mode = p.mode.toString(8).padStart(6, "0");
|
|
697
|
+
const ref =
|
|
698
|
+
this.noData || p.mode === GITLINK_MODE ? p.id : `:${this.marks.get(p.id as string) ?? 0}`;
|
|
699
|
+
text += `M ${mode} ${ref} ${this.pathText(p.path)}\n`;
|
|
700
|
+
}
|
|
701
|
+
return text;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
private async treeOf(commit: ObjectId): Promise<ObjectId> {
|
|
705
|
+
const raw = await readObjectBytes(this.objects, commit);
|
|
706
|
+
const text = raw ? latin1(raw.bytes.subarray(0, 100)) : "";
|
|
707
|
+
return text.startsWith("tree ") ? text.slice(5, text.indexOf("\n")) : "";
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/** diff_tree_oid with `recursive`, in tree-diff order (no rename detection). */
|
|
711
|
+
private async diffTrees(
|
|
712
|
+
a: ObjectId | undefined,
|
|
713
|
+
b: ObjectId,
|
|
714
|
+
prefix = "",
|
|
715
|
+
out: FilePair[] = [],
|
|
716
|
+
): Promise<FilePair[]> {
|
|
717
|
+
const left = a ? await this.treeEntries(a) : [];
|
|
718
|
+
const right = b ? await this.treeEntries(b) : [];
|
|
719
|
+
const key = (e: TreeEntry) => (isTree(e.mode) ? `${e.name}/` : e.name);
|
|
720
|
+
let i = 0;
|
|
721
|
+
let j = 0;
|
|
722
|
+
while (i < left.length || j < right.length) {
|
|
723
|
+
const l = left[i];
|
|
724
|
+
const r = right[j];
|
|
725
|
+
const cmp = !l ? 1 : !r ? -1 : compareBytes(key(l), key(r));
|
|
726
|
+
if (cmp < 0) {
|
|
727
|
+
await this.side(l as TreeEntry, "D", prefix, out);
|
|
728
|
+
i++;
|
|
729
|
+
} else if (cmp > 0) {
|
|
730
|
+
await this.side(r as TreeEntry, "A", prefix, out);
|
|
731
|
+
j++;
|
|
732
|
+
} else {
|
|
733
|
+
const le = l as TreeEntry;
|
|
734
|
+
const re = r as TreeEntry;
|
|
735
|
+
i++;
|
|
736
|
+
j++;
|
|
737
|
+
if (le.id === re.id && le.mode === re.mode) continue;
|
|
738
|
+
const path = prefix + re.name;
|
|
739
|
+
if (isTree(le.mode)) {
|
|
740
|
+
await this.diffTrees(le.id, re.id, `${path}/`, out);
|
|
741
|
+
continue;
|
|
742
|
+
}
|
|
743
|
+
const typeChanged = (le.mode & 0o170000) !== (re.mode & 0o170000);
|
|
744
|
+
out.push({ status: typeChanged ? "T" : "M", path, mode: re.mode, id: re.id });
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return out;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
private async side(
|
|
751
|
+
e: TreeEntry,
|
|
752
|
+
status: "A" | "D",
|
|
753
|
+
prefix: string,
|
|
754
|
+
out: FilePair[],
|
|
755
|
+
): Promise<void> {
|
|
756
|
+
const path = prefix + e.name;
|
|
757
|
+
if (isTree(e.mode)) {
|
|
758
|
+
for (const child of await this.treeEntries(e.id)) {
|
|
759
|
+
await this.side(child, status, `${path}/`, out);
|
|
760
|
+
}
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
out.push(
|
|
764
|
+
status === "D"
|
|
765
|
+
? { status, path, mode: e.mode, id: undefined }
|
|
766
|
+
: { status, path, mode: e.mode, id: e.id },
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
private async handleTag(name: string, tagId: ObjectId): Promise<void> {
|
|
771
|
+
// tags of trees (or of tags of trees) cannot be expressed
|
|
772
|
+
let tagged = await this.taggedOf(tagId);
|
|
773
|
+
let taggedType = await this.typeOf(tagged);
|
|
774
|
+
const direct = { id: tagged, type: taggedType };
|
|
775
|
+
while (taggedType === "tag") {
|
|
776
|
+
tagged = await this.taggedOf(tagged);
|
|
777
|
+
taggedType = await this.typeOf(tagged);
|
|
778
|
+
}
|
|
779
|
+
if (taggedType === "tree") {
|
|
780
|
+
this.warn(
|
|
781
|
+
this.compatibility === "2.43"
|
|
782
|
+
? `warning: Omitting tag ${tagId},\nsince tags of trees (or tags of tags of trees, etc.) are not supported.`
|
|
783
|
+
: `warning: omitting tag ${tagId},\nsince tags of trees (or tags of tags of trees, etc.) are not supported.`,
|
|
784
|
+
);
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
const raw = await readObjectBytes(this.objects, tagId);
|
|
788
|
+
if (!raw) this.die(`could not read tag ${tagId}`);
|
|
789
|
+
const buf = latin1((raw as { bytes: Uint8Array }).bytes);
|
|
790
|
+
const messageAt = buf.indexOf("\n\n");
|
|
791
|
+
let message: string | undefined;
|
|
792
|
+
if (messageAt >= 0) {
|
|
793
|
+
message = buf.slice(messageAt + 2);
|
|
794
|
+
if (message.includes("\0")) message = message.slice(0, message.indexOf("\0"));
|
|
795
|
+
}
|
|
796
|
+
let messageSize = message?.length ?? 0;
|
|
797
|
+
const headerPart = messageAt >= 0 ? buf.slice(0, messageAt + 2) : buf;
|
|
798
|
+
const taggerAt = headerPart.indexOf("\ntagger ");
|
|
799
|
+
let tagger: string;
|
|
800
|
+
if (taggerAt < 0) {
|
|
801
|
+
tagger = this.fakeMissingTagger
|
|
802
|
+
? "tagger Unspecified Tagger <unspecified-tagger> 0 +0000"
|
|
803
|
+
: "";
|
|
804
|
+
} else {
|
|
805
|
+
tagger = buf.slice(taggerAt + 1, lineEnd(buf, taggerAt + 1));
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
if (message !== undefined) {
|
|
809
|
+
const sigAt = signatureStartOf(message, this.compatibility);
|
|
810
|
+
if (sigAt < message.length) {
|
|
811
|
+
switch (this.signedTags) {
|
|
812
|
+
case "warn-verbatim":
|
|
813
|
+
case "warn":
|
|
814
|
+
this.warn(`warning: exporting signed tag ${tagId}`);
|
|
815
|
+
break;
|
|
816
|
+
case "verbatim":
|
|
817
|
+
case "ignore":
|
|
818
|
+
break;
|
|
819
|
+
case "warn-strip":
|
|
820
|
+
this.warn(`warning: stripping signature from tag ${tagId}`);
|
|
821
|
+
messageSize = sigAt;
|
|
822
|
+
break;
|
|
823
|
+
case "strip":
|
|
824
|
+
messageSize = sigAt;
|
|
825
|
+
break;
|
|
826
|
+
default:
|
|
827
|
+
this.die(`encountered signed tag ${tagId}; use --signed-tags=<mode> to handle it`);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
let taggedMark = this.marks.get(direct.id) ?? 0;
|
|
833
|
+
if (!taggedMark) {
|
|
834
|
+
switch (this.tagOfFiltered) {
|
|
835
|
+
case "abort":
|
|
836
|
+
this.die(
|
|
837
|
+
`tag ${tagId} tags unexported object; use --tag-of-filtered-object=<mode> to handle it`,
|
|
838
|
+
);
|
|
839
|
+
break;
|
|
840
|
+
case "drop":
|
|
841
|
+
return;
|
|
842
|
+
default:
|
|
843
|
+
if (direct.type === "tag" && !this.markTags) {
|
|
844
|
+
this.die(
|
|
845
|
+
"cannot export nested tags unless --mark-tags is specified.",
|
|
846
|
+
"Error: Cannot export nested tags unless --mark-tags is specified.",
|
|
847
|
+
);
|
|
848
|
+
}
|
|
849
|
+
taggedMark = this.marks.get(direct.id) ?? 0;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
let text = "";
|
|
854
|
+
if (direct.type === "tag") text += `reset ${bin(name)}\nfrom ${NULL_SHA1}\n\n`;
|
|
855
|
+
const short = name.startsWith("refs/tags/") ? name.slice(10) : name;
|
|
856
|
+
text += `tag ${bin(short)}\n`;
|
|
857
|
+
if (this.markTags) text += `mark :${this.markNext(tagId, false)}\n`;
|
|
858
|
+
text += taggedMark ? `from :${taggedMark}\n` : `from ${direct.id}\n`;
|
|
859
|
+
if (this.showOriginalIds) text += `original-oid ${tagId}\n`;
|
|
860
|
+
const shown = (message ?? "").slice(0, messageSize);
|
|
861
|
+
text += `${tagger}${tagger === "" ? "" : "\n"}data ${messageSize}\n${shown}\n`;
|
|
862
|
+
await this.out(text);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/** A name as the stream's bytes (a binary string). */
|
|
867
|
+
function bin(name: string): string {
|
|
868
|
+
return latin1(encodeGitPath(name));
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
function isTree(mode: number): boolean {
|
|
872
|
+
return (mode & 0o170000) === TREE_MODE;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
function lineEnd(text: string, from: number): number {
|
|
876
|
+
const nl = text.indexOf("\n", from);
|
|
877
|
+
return nl < 0 ? text.length : nl;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/** Byte order of two binary strings (or of plain ASCII names). */
|
|
881
|
+
function compareBytes(a: string, b: string): number {
|
|
882
|
+
const x = latin1(encodeGitPath(a));
|
|
883
|
+
const y = latin1(encodeGitPath(b));
|
|
884
|
+
return x < y ? -1 : x > y ? 1 : 0;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/** fast-export.c's depth_first: 'd/e' before 'd', otherwise byte order. */
|
|
888
|
+
function depthFirst(a: string, b: string): number {
|
|
889
|
+
const x = latin1(encodeGitPath(a));
|
|
890
|
+
const y = latin1(encodeGitPath(b));
|
|
891
|
+
const len = Math.min(x.length, y.length);
|
|
892
|
+
const px = x.slice(0, len);
|
|
893
|
+
const py = y.slice(0, len);
|
|
894
|
+
if (px !== py) return px < py ? -1 : 1;
|
|
895
|
+
return y.length - x.length;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/** The byte length of a binary string (it is one byte per character). */
|
|
899
|
+
function utf8Length(text: string): number {
|
|
900
|
+
return text.length;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/** reencode_string(message, "UTF-8", encoding): undefined when it cannot convert. */
|
|
904
|
+
function reencodeToUtf8(message: string, encoding: string): string | undefined {
|
|
905
|
+
try {
|
|
906
|
+
const decoded = new TextDecoder(encoding, { fatal: true }).decode(latin1Bytes(message));
|
|
907
|
+
return latin1(new TextEncoder().encode(decoded));
|
|
908
|
+
} catch {
|
|
909
|
+
return undefined;
|
|
910
|
+
}
|
|
911
|
+
}
|