@statewalker/vcs-commands 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts +2 -0
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-modes.d.ts +6 -2
- package/dist/commands/add-patch/patch-modes.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-session.d.ts +4 -0
- package/dist/commands/add-patch/patch-session.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +41 -2
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/apply/index.d.ts +1 -1
- package/dist/commands/apply/index.d.ts.map +1 -1
- package/dist/commands/archive/archive-command.d.ts +169 -0
- package/dist/commands/archive/archive-command.d.ts.map +1 -0
- package/dist/commands/archive/archive-entry.d.ts +60 -0
- package/dist/commands/archive/archive-entry.d.ts.map +1 -0
- package/dist/commands/archive/index.d.ts +8 -0
- package/dist/commands/archive/index.d.ts.map +1 -0
- package/dist/commands/archive/remote-archive-command.d.ts +56 -0
- package/dist/commands/archive/remote-archive-command.d.ts.map +1 -0
- package/dist/commands/archive/tar-archive.d.ts +31 -0
- package/dist/commands/archive/tar-archive.d.ts.map +1 -0
- package/dist/commands/archive/tar-commit-id.d.ts +13 -0
- package/dist/commands/archive/tar-commit-id.d.ts.map +1 -0
- package/dist/commands/archive/upload-archive-writer.d.ts +48 -0
- package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -0
- package/dist/commands/archive/zip-archive.d.ts +42 -0
- package/dist/commands/archive/zip-archive.d.ts.map +1 -0
- package/dist/commands/attributes-source.d.ts +10 -0
- package/dist/commands/attributes-source.d.ts.map +1 -1
- package/dist/commands/blame-command.d.ts +43 -1
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/bundle/bundle-create-command.d.ts +67 -0
- package/dist/commands/bundle/bundle-create-command.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-format.d.ts +89 -0
- package/dist/commands/bundle/bundle-format.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-list.d.ts +92 -0
- package/dist/commands/bundle/bundle-list.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts +81 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-support.d.ts +32 -0
- package/dist/commands/bundle/bundle-support.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-transport.d.ts +38 -0
- package/dist/commands/bundle/bundle-transport.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts +43 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri.d.ts +55 -0
- package/dist/commands/bundle/bundle-uri.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-verify.d.ts +63 -0
- package/dist/commands/bundle/bundle-verify.d.ts.map +1 -0
- package/dist/commands/bundle/index.d.ts +14 -0
- package/dist/commands/bundle/index.d.ts.map +1 -0
- package/dist/commands/cat-file/batch-format.d.ts +58 -0
- package/dist/commands/cat-file/batch-format.d.ts.map +1 -0
- package/dist/commands/cat-file/cat-file-command.d.ts +144 -0
- package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -0
- package/dist/commands/cat-file/index.d.ts +3 -0
- package/dist/commands/cat-file/index.d.ts.map +1 -0
- package/dist/commands/check-attr-command.d.ts +66 -0
- package/dist/commands/check-attr-command.d.ts.map +1 -0
- package/dist/commands/check-ignore-command.d.ts +58 -0
- package/dist/commands/check-ignore-command.d.ts.map +1 -0
- package/dist/commands/check-ref-format-command.d.ts +60 -0
- package/dist/commands/check-ref-format-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-index-command.d.ts +96 -0
- package/dist/commands/checkout-index-command.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +10 -0
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +28 -0
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +9 -1
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/config-command.d.ts +2 -0
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/daemon-access-hook.d.ts +36 -0
- package/dist/commands/daemon-access-hook.d.ts.map +1 -0
- package/dist/commands/default-branch.d.ts +54 -0
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +132 -5
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/diff-external.d.ts +43 -0
- package/dist/commands/diff-external.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts +27 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts +129 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/index.d.ts +3 -0
- package/dist/commands/diff-plumbing/index.d.ts.map +1 -0
- package/dist/commands/diff-textconv.d.ts +5 -1
- package/dist/commands/diff-textconv.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-export-command.d.ts +135 -0
- package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-import-command.d.ts +182 -0
- package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts +64 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -0
- package/dist/commands/fast-export/index.d.ts +4 -0
- package/dist/commands/fast-export/index.d.ts.map +1 -0
- package/dist/commands/fetch-command.d.ts +65 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fetch-multiple-command.d.ts.map +1 -1
- package/dist/commands/format-rev-command.d.ts +60 -0
- package/dist/commands/format-rev-command.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-msg-ids.d.ts +18 -3
- package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -1
- package/dist/commands/fsmonitor-ipc.d.ts +30 -0
- package/dist/commands/fsmonitor-ipc.d.ts.map +1 -0
- package/dist/commands/fsmonitor-refresh.d.ts +69 -0
- package/dist/commands/fsmonitor-refresh.d.ts.map +1 -0
- package/dist/commands/gc-command.d.ts +5 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +32 -0
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/git-paths.d.ts +26 -0
- package/dist/commands/git-paths.d.ts.map +1 -0
- package/dist/commands/grep/grep-command.d.ts +2 -1
- package/dist/commands/grep/grep-command.d.ts.map +1 -1
- package/dist/commands/history-command.d.ts +156 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/http-config.d.ts +38 -0
- package/dist/commands/http-config.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +12 -1
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index-host.d.ts.map +1 -1
- package/dist/commands/index.d.ts +45 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +6 -5
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/last-modified-command.d.ts +102 -0
- package/dist/commands/last-modified-command.d.ts.map +1 -0
- package/dist/commands/lfs/go-url.d.ts +43 -0
- package/dist/commands/lfs/go-url.d.ts.map +1 -0
- package/dist/commands/lfs/index.d.ts +3 -0
- package/dist/commands/lfs/index.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-config.d.ts +174 -0
- package/dist/commands/lfs/lfs-config.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-endpoint-command.d.ts +83 -0
- package/dist/commands/lfs/lfs-endpoint-command.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +26 -0
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +28 -1
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-files-command.d.ts +153 -0
- package/dist/commands/ls-files-command.d.ts.map +1 -0
- package/dist/commands/ls-remote-command.d.ts +5 -0
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/ls-tree-command.d.ts +105 -0
- package/dist/commands/ls-tree-command.d.ts.map +1 -0
- package/dist/commands/maintenance-run-command.d.ts +122 -0
- package/dist/commands/maintenance-run-command.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +7 -0
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-config.d.ts +7 -0
- package/dist/commands/merge-config.d.ts.map +1 -1
- package/dist/commands/merge-drivers.d.ts +67 -5
- package/dist/commands/merge-drivers.d.ts.map +1 -1
- package/dist/commands/merge-support.d.ts +6 -0
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/merge-tree-command.d.ts +122 -0
- package/dist/commands/merge-tree-command.d.ts.map +1 -0
- package/dist/commands/mktag-command.d.ts +51 -0
- package/dist/commands/mktag-command.d.ts.map +1 -0
- package/dist/commands/object-store/count-objects-command.d.ts +58 -0
- package/dist/commands/object-store/count-objects-command.d.ts.map +1 -0
- package/dist/commands/object-store/index.d.ts +5 -0
- package/dist/commands/object-store/index.d.ts.map +1 -0
- package/dist/commands/object-store/objects-directory.d.ts +12 -0
- package/dist/commands/object-store/objects-directory.d.ts.map +1 -0
- package/dist/commands/object-store/prune-command.d.ts +38 -0
- package/dist/commands/object-store/prune-command.d.ts.map +1 -0
- package/dist/commands/object-store/show-index-command.d.ts +23 -0
- package/dist/commands/object-store/show-index-command.d.ts.map +1 -0
- package/dist/commands/ort-merge.d.ts +24 -0
- package/dist/commands/ort-merge.d.ts.map +1 -1
- package/dist/commands/patch-id-command.d.ts +30 -0
- package/dist/commands/patch-id-command.d.ts.map +1 -0
- package/dist/commands/patch-id.d.ts +24 -0
- package/dist/commands/patch-id.d.ts.map +1 -1
- package/dist/commands/plumbing-command.d.ts +66 -0
- package/dist/commands/plumbing-command.d.ts.map +1 -0
- package/dist/commands/plumbing-input.d.ts +38 -0
- package/dist/commands/plumbing-input.d.ts.map +1 -0
- package/dist/commands/promisor-remote-reply.d.ts +35 -0
- package/dist/commands/promisor-remote-reply.d.ts.map +1 -0
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +17 -2
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +108 -2
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/refs-command.d.ts +81 -0
- package/dist/commands/refs-command.d.ts.map +1 -0
- package/dist/commands/remote-object-info-command.d.ts +55 -0
- package/dist/commands/remote-object-info-command.d.ts.map +1 -0
- package/dist/commands/remote-transport.d.ts +40 -3
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/repack-command.d.ts +115 -0
- package/dist/commands/repack-command.d.ts.map +1 -0
- package/dist/commands/replace-command.d.ts +143 -0
- package/dist/commands/replace-command.d.ts.map +1 -0
- package/dist/commands/replay-command.d.ts +117 -0
- package/dist/commands/replay-command.d.ts.map +1 -0
- package/dist/commands/repo-command.d.ts +158 -0
- package/dist/commands/repo-command.d.ts.map +1 -0
- package/dist/commands/request-pull-command.d.ts +82 -0
- package/dist/commands/request-pull-command.d.ts.map +1 -0
- package/dist/commands/rerere-command.d.ts +36 -0
- package/dist/commands/rerere-command.d.ts.map +1 -0
- package/dist/commands/rerere.d.ts +102 -0
- package/dist/commands/rerere.d.ts.map +1 -0
- package/dist/commands/reset-command.d.ts +19 -2
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/rev-filter/commit-grep.d.ts +3 -1
- package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -1
- package/dist/commands/rev-list-command.d.ts +3 -0
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/rev-parse-command.d.ts +5 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +10 -0
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +5 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +27 -1
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +18 -0
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +23 -1
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/session-id.d.ts +18 -0
- package/dist/commands/session-id.d.ts.map +1 -0
- package/dist/commands/show-branch-command.d.ts +59 -0
- package/dist/commands/show-branch-command.d.ts.map +1 -0
- package/dist/commands/show-ref-command.d.ts +112 -0
- package/dist/commands/show-ref-command.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +9 -2
- package/dist/commands/signature-check.d.ts.map +1 -1
- package/dist/commands/signing.d.ts +30 -2
- package/dist/commands/signing.d.ts.map +1 -1
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-export-command.d.ts +115 -0
- package/dist/commands/stash-export-command.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +16 -2
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/stripspace-command.d.ts +44 -0
- package/dist/commands/stripspace-command.d.ts.map +1 -0
- package/dist/commands/submodule-add-command.d.ts +22 -1
- package/dist/commands/submodule-add-command.d.ts.map +1 -1
- package/dist/commands/submodule-auth.d.ts +3 -1
- package/dist/commands/submodule-auth.d.ts.map +1 -1
- package/dist/commands/submodule-commands.d.ts +9 -1
- package/dist/commands/submodule-commands.d.ts.map +1 -1
- package/dist/commands/submodule-update-command.d.ts +27 -1
- package/dist/commands/submodule-update-command.d.ts.map +1 -1
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/textconv-cache.d.ts +58 -0
- package/dist/commands/textconv-cache.d.ts.map +1 -0
- package/dist/commands/tree-restore.d.ts +5 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/unpack-objects-command.d.ts +47 -0
- package/dist/commands/unpack-objects-command.d.ts.map +1 -0
- package/dist/commands/update-index-command.d.ts +131 -0
- package/dist/commands/update-index-command.d.ts.map +1 -0
- package/dist/commands/uri-protocols.d.ts +13 -0
- package/dist/commands/uri-protocols.d.ts.map +1 -0
- package/dist/commands/url-parse-command.d.ts +30 -0
- package/dist/commands/url-parse-command.d.ts.map +1 -0
- package/dist/commands/var-command.d.ts +42 -0
- package/dist/commands/var-command.d.ts.map +1 -0
- package/dist/{commands-CNvli5bl.js → commands-bQQ9OmCh.js} +52514 -44630
- package/dist/errors/command-errors.d.ts +33 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +39 -1
- package/dist/{fsck-CPeDh9fh.js → fsck-BHT9bUS-.js} +184 -143
- package/dist/git-command.d.ts +66 -4
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +532 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +3 -1
- package/dist/guarded-transport-command.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/maintenance-run-command-Cx2PlGV9.js +13544 -0
- package/dist/{remote-transport-CCmBadm-.js → remote-transport-BrQZfyHu.js} +1009 -10
- package/dist/results/cherry-pick-result.d.ts +6 -0
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/diff-entry.d.ts +10 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +49 -3
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/fetch-result.d.ts +12 -0
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/merge-result.d.ts +5 -0
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +5 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +7 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +6 -0
- package/dist/results/revert-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +5 -0
- package/dist/results/stash-result.d.ts.map +1 -1
- package/dist/{results-BDuEgdLU.js → results-CNHQnU5Y.js} +13707 -10608
- package/dist/transport-command.d.ts +79 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/commands/add-command.ts +3 -0
- package/src/commands/add-patch/patch-backend.ts +4 -1
- package/src/commands/add-patch/patch-modes.ts +26 -2
- package/src/commands/add-patch/patch-session.ts +6 -0
- package/src/commands/am/am-command.ts +193 -22
- package/src/commands/apply/index.ts +1 -0
- package/src/commands/archive/archive-command.ts +1148 -0
- package/src/commands/archive/archive-entry.ts +93 -0
- package/src/commands/archive/index.ts +7 -0
- package/src/commands/archive/remote-archive-command.ts +140 -0
- package/src/commands/archive/tar-archive.ts +207 -0
- package/src/commands/archive/tar-commit-id.ts +72 -0
- package/src/commands/archive/upload-archive-writer.ts +213 -0
- package/src/commands/archive/zip-archive.ts +317 -0
- package/src/commands/attributes-source.ts +26 -12
- package/src/commands/blame-command.ts +118 -19
- package/src/commands/bundle/bundle-create-command.ts +405 -0
- package/src/commands/bundle/bundle-format.ts +228 -0
- package/src/commands/bundle/bundle-list.ts +276 -0
- package/src/commands/bundle/bundle-read-commands.ts +157 -0
- package/src/commands/bundle/bundle-support.ts +85 -0
- package/src/commands/bundle/bundle-transport.ts +107 -0
- package/src/commands/bundle/bundle-uri-host.ts +204 -0
- package/src/commands/bundle/bundle-uri.ts +236 -0
- package/src/commands/bundle/bundle-verify.ts +152 -0
- package/src/commands/bundle/index.ts +14 -0
- package/src/commands/cat-file/batch-format.ts +193 -0
- package/src/commands/cat-file/cat-file-command.ts +895 -0
- package/src/commands/cat-file/index.ts +2 -0
- package/src/commands/check-attr-command.ts +333 -0
- package/src/commands/check-ignore-command.ts +261 -0
- package/src/commands/check-ref-format-command.ts +129 -0
- package/src/commands/checkout-command.ts +61 -22
- package/src/commands/checkout-index-command.ts +568 -0
- package/src/commands/checkout-paths.ts +7 -0
- package/src/commands/cherry-pick-command.ts +21 -1
- package/src/commands/clone-command.ts +249 -9
- package/src/commands/commit-command.ts +22 -4
- package/src/commands/config-command.ts +9 -0
- package/src/commands/daemon-access-hook.ts +78 -0
- package/src/commands/default-branch.ts +118 -1
- package/src/commands/diff-command.ts +592 -47
- package/src/commands/diff-external.ts +131 -0
- package/src/commands/diff-plumbing/diff-pairs-command.ts +193 -0
- package/src/commands/diff-plumbing/diff-plumbing-command.ts +424 -0
- package/src/commands/diff-plumbing/index.ts +2 -0
- package/src/commands/diff-textconv.ts +5 -1
- package/src/commands/fast-export/fast-export-command.ts +911 -0
- package/src/commands/fast-export/fast-import-command.ts +1553 -0
- package/src/commands/fast-export/fast-stream-support.ts +162 -0
- package/src/commands/fast-export/index.ts +3 -0
- package/src/commands/fetch-command.ts +312 -8
- package/src/commands/fetch-multiple-command.ts +4 -1
- package/src/commands/format-rev-command.ts +267 -0
- package/src/commands/fsck/fsck-command.ts +47 -20
- package/src/commands/fsck/fsck-msg-ids.ts +19 -3
- package/src/commands/fsck/fsck-pack.ts +2 -2
- package/src/commands/fsmonitor-ipc.ts +121 -0
- package/src/commands/fsmonitor-refresh.ts +320 -0
- package/src/commands/gc-command.ts +10 -0
- package/src/commands/git-hooks.ts +123 -6
- package/src/commands/git-paths.ts +136 -0
- package/src/commands/grep/grep-command.ts +38 -15
- package/src/commands/history-command.ts +617 -0
- package/src/commands/http-config.ts +139 -0
- package/src/commands/index-adder.ts +37 -3
- package/src/commands/index-host.ts +6 -1
- package/src/commands/index.ts +46 -0
- package/src/commands/init-command.ts +14 -0
- package/src/commands/last-modified-command.ts +804 -0
- package/src/commands/lfs/go-url.ts +370 -0
- package/src/commands/lfs/index.ts +2 -0
- package/src/commands/lfs/lfs-config.ts +738 -0
- package/src/commands/lfs/lfs-endpoint-command.ts +180 -0
- package/src/commands/local-transport.ts +252 -4
- package/src/commands/log-command.ts +104 -5
- package/src/commands/log-output.ts +66 -5
- package/src/commands/ls-files-command.ts +1177 -0
- package/src/commands/ls-remote-command.ts +6 -0
- package/src/commands/ls-tree-command.ts +708 -0
- package/src/commands/maintenance-run-command.ts +949 -0
- package/src/commands/merge-command.ts +78 -32
- package/src/commands/merge-config.ts +23 -1
- package/src/commands/merge-drivers.ts +109 -20
- package/src/commands/merge-support.ts +29 -5
- package/src/commands/merge-tree-command.ts +786 -0
- package/src/commands/mktag-command.ts +149 -0
- package/src/commands/object-store/count-objects-command.ts +404 -0
- package/src/commands/object-store/index.ts +4 -0
- package/src/commands/object-store/objects-directory.ts +24 -0
- package/src/commands/object-store/prune-command.ts +129 -0
- package/src/commands/object-store/show-index-command.ts +151 -0
- package/src/commands/ort-merge.ts +92 -25
- package/src/commands/patch-id-command.ts +65 -0
- package/src/commands/patch-id.ts +218 -0
- package/src/commands/plumbing-command.ts +141 -0
- package/src/commands/plumbing-input.ts +87 -0
- package/src/commands/promisor-remote-reply.ts +276 -0
- package/src/commands/promisor-remote.ts +25 -2
- package/src/commands/pull-command.ts +2 -0
- package/src/commands/push-command.ts +87 -5
- package/src/commands/rebase-command.ts +507 -19
- package/src/commands/refs-command.ts +274 -0
- package/src/commands/remote-object-info-command.ts +109 -0
- package/src/commands/remote-transport.ts +116 -1
- package/src/commands/repack-command.ts +383 -0
- package/src/commands/replace-command.ts +816 -0
- package/src/commands/replay-command.ts +674 -0
- package/src/commands/repo-command.ts +1066 -0
- package/src/commands/request-pull-command.ts +356 -0
- package/src/commands/rerere-command.ts +179 -0
- package/src/commands/rerere.ts +925 -0
- package/src/commands/reset-command.ts +75 -3
- package/src/commands/rev-filter/commit-grep.ts +7 -2
- package/src/commands/rev-list-command.ts +9 -0
- package/src/commands/rev-parse-command.ts +49 -5
- package/src/commands/revert-command.ts +21 -1
- package/src/commands/revision-range.ts +7 -2
- package/src/commands/revision-resolver.ts +97 -14
- package/src/commands/sequencer-pick.ts +47 -0
- package/src/commands/serve-repository.ts +65 -0
- package/src/commands/session-id.ts +31 -0
- package/src/commands/show-branch-command.ts +981 -0
- package/src/commands/show-command.ts +1 -1
- package/src/commands/show-ref-command.ts +439 -0
- package/src/commands/signature-check.ts +37 -5
- package/src/commands/signing.ts +176 -23
- package/src/commands/stash-apply-command.ts +3 -0
- package/src/commands/stash-export-command.ts +397 -0
- package/src/commands/status-command.ts +74 -8
- package/src/commands/stripspace-command.ts +118 -0
- package/src/commands/submodule-add-command.ts +40 -2
- package/src/commands/submodule-auth.ts +61 -6
- package/src/commands/submodule-commands.ts +12 -2
- package/src/commands/submodule-update-command.ts +47 -1
- package/src/commands/tag-command.ts +33 -11
- package/src/commands/textconv-cache.ts +143 -0
- package/src/commands/tree-restore.ts +14 -0
- package/src/commands/unpack-objects-command.ts +235 -0
- package/src/commands/update-index-command.ts +1148 -0
- package/src/commands/uri-protocols.ts +13 -0
- package/src/commands/url-parse-command.ts +67 -0
- package/src/commands/var-command.ts +219 -0
- package/src/errors/command-errors.ts +45 -0
- package/src/git-command.ts +177 -3
- package/src/git.ts +808 -1
- package/src/guarded-transport-command.ts +6 -1
- package/src/results/cherry-pick-result.ts +6 -0
- package/src/results/diff-entry.ts +12 -0
- package/src/results/diff-formatter.ts +7 -4
- package/src/results/diff-output.ts +117 -11
- package/src/results/diff-pickaxe.ts +1 -1
- package/src/results/fetch-result.ts +12 -0
- package/src/results/merge-result.ts +5 -0
- package/src/results/push-result.ts +5 -0
- package/src/results/rebase-result.ts +7 -0
- package/src/results/revert-result.ts +6 -0
- package/src/results/stash-result.ts +6 -0
- package/src/transport-command.ts +182 -1
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `git request-pull` (git-request-pull.sh) as a library command: the text asking someone to
|
|
3
|
+
* pull a branch or tag of a published repository, with the range's shortlog and diffstat.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* // git request-pull v1.0 https://example.com/repo.git main:for-linus
|
|
8
|
+
* const { stdout, stderr, exitCode } = await git
|
|
9
|
+
* .requestPull()
|
|
10
|
+
* .setStart("v1.0")
|
|
11
|
+
* .setUrl("https://example.com/repo.git")
|
|
12
|
+
* .setEnd("main:for-linus")
|
|
13
|
+
* .call();
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { isSymbolicRef, type ObjectId } from "@statewalker/vcs-core";
|
|
18
|
+
import { decodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
19
|
+
import { GitApiError } from "../errors/index.js";
|
|
20
|
+
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
21
|
+
import { TransportCommand } from "../transport-command.js";
|
|
22
|
+
import type { PlumbingTextOutput } from "./check-ref-format-command.js";
|
|
23
|
+
import { DiffCommand } from "./diff-command.js";
|
|
24
|
+
import { LsRemoteCommand } from "./ls-remote-command.js";
|
|
25
|
+
import { MergeBaseCommand } from "./merge-base-command.js";
|
|
26
|
+
import { formatCommitPretty } from "./pretty-format.js";
|
|
27
|
+
import { ShortlogCommand } from "./shortlog-command.js";
|
|
28
|
+
import { ShowRefCommand } from "./show-ref-command.js";
|
|
29
|
+
|
|
30
|
+
const RULE = "----------------------------------------------------------------";
|
|
31
|
+
|
|
32
|
+
/** What `"$0" -h` prints (stdout) when the start or the URL is missing; git then exits 1. */
|
|
33
|
+
const USAGE =
|
|
34
|
+
"usage: git request-pull [options] start url [end]\n\n" +
|
|
35
|
+
" -p show patch text as well\n\n";
|
|
36
|
+
|
|
37
|
+
/** git-sh-setup's `die`: the message on stderr, exit 1. */
|
|
38
|
+
class RequestPullDeath extends Error {}
|
|
39
|
+
|
|
40
|
+
/** A line of `git ls-remote` output: an object id and the ref (`^{}` for a peeled tag). */
|
|
41
|
+
type ListedRef = readonly [sha1: string, ref: string];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* `git request-pull [-p] <start> <url> [<end>]`. The result is git's stdout, stderr and exit
|
|
45
|
+
* status: 1 with git's `warn:` lines when `<url>` has no ref of the remote name (default
|
|
46
|
+
* `HEAD`) at the commit asked for, or one at another object (the text is still printed), 1
|
|
47
|
+
* with git's `fatal:` line when a revision names nothing or the two have no common history.
|
|
48
|
+
*
|
|
49
|
+
* The remote's refs are listed through the command's transports (credentials and headers as
|
|
50
|
+
* {@link TransportCommand} gives them); everything else is read from the repository: the
|
|
51
|
+
* merge base, the shortlog (`git shortlog ^<start> <end>`, mailmap applied) and `git diff -M
|
|
52
|
+
* --stat --summary [-p]` of the merge base and the end.
|
|
53
|
+
*/
|
|
54
|
+
export class RequestPullCommand extends TransportCommand<PlumbingTextOutput> {
|
|
55
|
+
private start = "";
|
|
56
|
+
private url = "";
|
|
57
|
+
private end = "";
|
|
58
|
+
private patch = false;
|
|
59
|
+
private compatibility: "2.43" | "2.56" = "2.56";
|
|
60
|
+
|
|
61
|
+
/** `<start>`: the commit the changes are based on (the upstream's), any committish. */
|
|
62
|
+
setStart(start: string): this {
|
|
63
|
+
this.checkCallable();
|
|
64
|
+
this.start = start;
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** `<url>`: the repository to pull from, a URL or a remote's name. */
|
|
69
|
+
setUrl(url: string): this {
|
|
70
|
+
this.checkCallable();
|
|
71
|
+
this.url = url;
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* `<end>`: what to pull, `<local>[:<remote>]` (default `HEAD`, asked as the remote's
|
|
77
|
+
* `HEAD`); the remote side is the name looked for among the remote's refs.
|
|
78
|
+
*/
|
|
79
|
+
setEnd(end: string): this {
|
|
80
|
+
this.checkCallable();
|
|
81
|
+
this.end = end;
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** `-p`: the patch after the diffstat. */
|
|
86
|
+
setPatch(patch: boolean): this {
|
|
87
|
+
this.checkCallable();
|
|
88
|
+
this.patch = patch;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The git version to follow (default 2.56). Before 2.50 a Perl script matched the remote's
|
|
94
|
+
* refs and kept the last ref matching, from 2.50 a shell loop keeps the first.
|
|
95
|
+
*/
|
|
96
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
97
|
+
this.checkCallable();
|
|
98
|
+
this.compatibility = version;
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async call(): Promise<PlumbingTextOutput> {
|
|
103
|
+
this.checkCallable();
|
|
104
|
+
this.setCallable(false);
|
|
105
|
+
if (!this.start || !this.url) return { exitCode: 1, stdout: USAGE, stderr: "" };
|
|
106
|
+
const out: string[] = [];
|
|
107
|
+
const err: string[] = [];
|
|
108
|
+
try {
|
|
109
|
+
const status = await this.run(out, err);
|
|
110
|
+
return { exitCode: status, stdout: out.join(""), stderr: err.join("") };
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (!(error instanceof RequestPullDeath)) throw error;
|
|
113
|
+
return { exitCode: 1, stdout: out.join(""), stderr: `${err.join("")}${error.message}\n` };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private async run(out: string[], err: string[]): Promise<number> {
|
|
118
|
+
let status = 0;
|
|
119
|
+
const base = this.start;
|
|
120
|
+
const url = this.url;
|
|
121
|
+
const baserev = await this.verify(`${base}^0`);
|
|
122
|
+
if (baserev === undefined) throw new RequestPullDeath(`fatal: Not a valid revision: ${base}`);
|
|
123
|
+
|
|
124
|
+
// $3 is `<local>[:<remote>]`: ${3%:*} and ${3#*:}
|
|
125
|
+
const end = this.end;
|
|
126
|
+
const lastColon = end.lastIndexOf(":");
|
|
127
|
+
const firstColon = end.indexOf(":");
|
|
128
|
+
const local = (lastColon >= 0 ? end.slice(0, lastColon) : end) || "HEAD";
|
|
129
|
+
const remote = firstColon >= 0 ? end.slice(firstColon + 1) : end;
|
|
130
|
+
let prettyRemote = remote.startsWith("refs/") ? remote.slice(5) : remote;
|
|
131
|
+
if (prettyRemote.startsWith("heads/")) prettyRemote = prettyRemote.slice(6);
|
|
132
|
+
const head =
|
|
133
|
+
(await this.symbolicRef(local)) ||
|
|
134
|
+
(await this.showRef(local)) ||
|
|
135
|
+
(await this.verify(local)) ||
|
|
136
|
+
"";
|
|
137
|
+
if (!head) throw new RequestPullDeath(`fatal: Not a valid revision: ${local}`);
|
|
138
|
+
// this also verifies that the head is unique: show-ref could have listed several refs
|
|
139
|
+
const headrev = await this.verify(`${head}^0`);
|
|
140
|
+
if (headrev === undefined) throw new RequestPullDeath(`fatal: Ambiguous revision: ${local}`);
|
|
141
|
+
const localSha1 = (await this.verify(head)) ?? "";
|
|
142
|
+
|
|
143
|
+
// was it a branch with a description?
|
|
144
|
+
const config = RemoteConfigStore.from(this._workingCopy);
|
|
145
|
+
const branchName = head.startsWith("refs/heads/") ? head.slice("refs/heads/".length) : head;
|
|
146
|
+
const description = config.value(`branch.${branchName}.description`);
|
|
147
|
+
|
|
148
|
+
const mergeBase = (
|
|
149
|
+
await new MergeBaseCommand(this._workingCopy).addCommit(baserev).addCommit(headrev).call()
|
|
150
|
+
).bases[0];
|
|
151
|
+
if (mergeBase === undefined) {
|
|
152
|
+
throw new RequestPullDeath(`fatal: No commits in common between ${base} and ${head}`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// a ref of the remote's name at the remote, at the commit asked for
|
|
156
|
+
const asked = remote || "HEAD";
|
|
157
|
+
const found = this.matchRef(await this.listRemote(url, err), asked, headrev);
|
|
158
|
+
if (!found) {
|
|
159
|
+
err.push(`warn: No match for commit ${headrev} found at ${url}\n`);
|
|
160
|
+
err.push(`warn: Are you sure you pushed '${asked}' there?\n`);
|
|
161
|
+
status = 1;
|
|
162
|
+
} else if (localSha1 !== found.remoteSha1) {
|
|
163
|
+
err.push(`warn: ${head} found at ${url} but points to a different object\n`);
|
|
164
|
+
err.push(`warn: Are you sure you pushed '${asked}' there?\n`);
|
|
165
|
+
status = 1;
|
|
166
|
+
}
|
|
167
|
+
// special case: turn "for_linus" to "tags/for_linus" when it is correct
|
|
168
|
+
if (found?.ref === `refs/tags/${prettyRemote}`) prettyRemote = `tags/${prettyRemote}`;
|
|
169
|
+
|
|
170
|
+
const fetchUrl = await this.configureChild(new LsRemoteCommand(this._workingCopy))
|
|
171
|
+
.setRemote(url)
|
|
172
|
+
.callGetUrl();
|
|
173
|
+
|
|
174
|
+
out.push(
|
|
175
|
+
await this.show(
|
|
176
|
+
mergeBase,
|
|
177
|
+
"The following changes since commit %H:\n\n %s (%ci)\n\nare available in the Git repository at:\n",
|
|
178
|
+
),
|
|
179
|
+
);
|
|
180
|
+
out.push(` ${fetchUrl} ${prettyRemote}\n`);
|
|
181
|
+
out.push(
|
|
182
|
+
await this.show(headrev, `\nfor you to fetch changes up to %H:\n\n %s (%ci)\n\n${RULE}`),
|
|
183
|
+
);
|
|
184
|
+
const tag = await this.tagMessage(localSha1);
|
|
185
|
+
if (tag !== undefined) out.push(`${tag}\n${RULE}\n`);
|
|
186
|
+
if (branchName && description !== undefined) {
|
|
187
|
+
out.push(`(from the branch description for ${branchName} local branch)\n\n`);
|
|
188
|
+
out.push(`${description}\n${RULE}\n`);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const shortlog = new ShortlogCommand(this._workingCopy)
|
|
192
|
+
.addArgument(`^${baserev}`)
|
|
193
|
+
.addArgument(headrev);
|
|
194
|
+
out.push(await shortlog.callText());
|
|
195
|
+
for (const line of shortlog.getErrors()) err.push(`${line}\n`);
|
|
196
|
+
|
|
197
|
+
const diff = new DiffCommand(this._workingCopy)
|
|
198
|
+
.setOldTree(mergeBase)
|
|
199
|
+
.setNewTree(headrev)
|
|
200
|
+
.setOptions({ findRenames: true });
|
|
201
|
+
const { bytes } = await diff.callFormats(
|
|
202
|
+
this.patch ? ["stat", "summary", "patch"] : ["stat", "summary"],
|
|
203
|
+
);
|
|
204
|
+
if (bytes) out.push(decodeGitPath(bytes));
|
|
205
|
+
return status;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** `git rev-parse --verify --quiet <name>`: undefined when it names no single object. */
|
|
209
|
+
private async verify(name: string): Promise<ObjectId | undefined> {
|
|
210
|
+
if (name.includes("\n")) return undefined;
|
|
211
|
+
try {
|
|
212
|
+
return await this.revisionResolver().resolve(name);
|
|
213
|
+
} catch {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** `git symbolic-ref -q <name>`: the ref a symbolic ref names, else undefined. */
|
|
219
|
+
private async symbolicRef(name: string): Promise<string | undefined> {
|
|
220
|
+
try {
|
|
221
|
+
const ref = await this.refsStore.get(name);
|
|
222
|
+
return ref && isSymbolicRef(ref) ? ref.target : undefined;
|
|
223
|
+
} catch {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* `git show-ref --heads --tags <name> | cut -d' ' -f2`: the branches and tags the name ends
|
|
230
|
+
* (several lines when it names several, which `rev-parse` then refuses).
|
|
231
|
+
*/
|
|
232
|
+
private async showRef(name: string): Promise<string | undefined> {
|
|
233
|
+
const r = await new ShowRefCommand(this._workingCopy)
|
|
234
|
+
.setHeads(true)
|
|
235
|
+
.setTags(true)
|
|
236
|
+
.addPattern(name)
|
|
237
|
+
.callOutput();
|
|
238
|
+
const text = decodeGitPath(r.stdout).replace(/\n+$/, "");
|
|
239
|
+
if (!text) return undefined;
|
|
240
|
+
return text
|
|
241
|
+
.split("\n")
|
|
242
|
+
.map((line) => line.split(" ")[1] ?? "")
|
|
243
|
+
.join("\n");
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* `git ls-remote <url>`: HEAD first, then each ref and its peeled object (`<ref>^{}`). A
|
|
248
|
+
* listing that fails leaves its lines on stderr and lists nothing, as the pipe does.
|
|
249
|
+
*/
|
|
250
|
+
private async listRemote(url: string, err: string[]): Promise<ListedRef[]> {
|
|
251
|
+
try {
|
|
252
|
+
const r = await this.configureChild(new LsRemoteCommand(this._workingCopy))
|
|
253
|
+
.setRemote(url)
|
|
254
|
+
.call();
|
|
255
|
+
const lines: ListedRef[] = [];
|
|
256
|
+
if (r.head) lines.push([r.head, "HEAD"]);
|
|
257
|
+
for (const ref of r.refs) {
|
|
258
|
+
lines.push([ref.objectId, ref.name]);
|
|
259
|
+
if (ref.peeledObjectId) lines.push([ref.peeledObjectId, `${ref.name}^{}`]);
|
|
260
|
+
}
|
|
261
|
+
return lines;
|
|
262
|
+
} catch (error) {
|
|
263
|
+
if (!(error instanceof GitApiError)) throw error;
|
|
264
|
+
err.push(`${error.message}\n`);
|
|
265
|
+
return [];
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* find_matching_ref: the remote ref named `asked` (or ending in `/<asked>`) at `headrev`,
|
|
271
|
+
* with the object the remote's matching unpeeled ref names. 2.50+ (a shell loop) stops at
|
|
272
|
+
* the first match; 2.43's Perl script meant to (`break` is no Perl statement) and keeps the
|
|
273
|
+
* last one, the object of the last unpeeled matching ref.
|
|
274
|
+
*/
|
|
275
|
+
private matchRef(
|
|
276
|
+
lines: ListedRef[],
|
|
277
|
+
asked: string,
|
|
278
|
+
headrev: ObjectId,
|
|
279
|
+
): { remoteSha1: string; ref: string } | undefined {
|
|
280
|
+
const matches = (ref: string) => ref === asked || ref.endsWith(`/${asked}`);
|
|
281
|
+
if (this.compatibility === "2.43") {
|
|
282
|
+
let remoteSha1: string | undefined;
|
|
283
|
+
let found: string | undefined;
|
|
284
|
+
for (const [sha1, line] of lines) {
|
|
285
|
+
// /^(\S+)\s+([^^]+)(\S*)$/
|
|
286
|
+
const caret = line.indexOf("^");
|
|
287
|
+
const ref = caret >= 0 ? line.slice(0, caret) : line;
|
|
288
|
+
const deref = caret >= 0 ? line.slice(caret) : "";
|
|
289
|
+
if (!ref) continue;
|
|
290
|
+
if (sha1 === asked) found = remoteSha1 = sha1;
|
|
291
|
+
if (matches(ref)) {
|
|
292
|
+
if (deref === "") remoteSha1 = sha1;
|
|
293
|
+
if (sha1 === headrev) found = ref;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return found ? { remoteSha1: remoteSha1 ?? headrev, ref: found } : undefined;
|
|
297
|
+
}
|
|
298
|
+
let remoteSha1 = "";
|
|
299
|
+
for (const [sha1, line] of lines) {
|
|
300
|
+
// *"^"?*: ${ref%"^"*}
|
|
301
|
+
const caret = line.lastIndexOf("^");
|
|
302
|
+
const deref = caret >= 0 && caret < line.length - 1;
|
|
303
|
+
const ref = deref ? line.slice(0, caret) : line;
|
|
304
|
+
if (sha1 === asked) return { remoteSha1: sha1, ref: sha1 };
|
|
305
|
+
if (matches(ref)) {
|
|
306
|
+
if (!deref) remoteSha1 = sha1;
|
|
307
|
+
if (sha1 === headrev) return { remoteSha1: remoteSha1 || headrev, ref };
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return undefined;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** `git show -s --format=<format> <id>` */
|
|
314
|
+
private async show(id: ObjectId, format: string): Promise<string> {
|
|
315
|
+
const commit = await this.commits.load(id);
|
|
316
|
+
if (!commit) return "";
|
|
317
|
+
return `${await formatCommitPretty(format, commit, id)}\n`;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* `git cat-file tag <head> | sed -n -e '1,/^$/d' -e '/^-----BEGIN \(PGP\|SSH\|SIGNED\) /q'
|
|
322
|
+
* -e p` when the end names a tag: its message up to the signature (undefined otherwise).
|
|
323
|
+
*/
|
|
324
|
+
private async tagMessage(id: string): Promise<string | undefined> {
|
|
325
|
+
const objects = this._workingCopy.history?.objects;
|
|
326
|
+
const object = await objects?.get(id).catch(() => undefined);
|
|
327
|
+
if (!object) return undefined;
|
|
328
|
+
if (object.type !== "tag") {
|
|
329
|
+
await object.content[Symbol.asyncIterator]().return?.();
|
|
330
|
+
return undefined;
|
|
331
|
+
}
|
|
332
|
+
const chunks: Uint8Array[] = [];
|
|
333
|
+
for await (const c of object.content) chunks.push(c.slice());
|
|
334
|
+
const bytes = new Uint8Array(chunks.reduce((n, c) => n + c.length, 0));
|
|
335
|
+
let at = 0;
|
|
336
|
+
for (const c of chunks) {
|
|
337
|
+
bytes.set(c, at);
|
|
338
|
+
at += c.length;
|
|
339
|
+
}
|
|
340
|
+
const lines = decodeGitPath(bytes).split("\n");
|
|
341
|
+
// a final newline leaves an empty last element, which is no line
|
|
342
|
+
const complete = lines[lines.length - 1] === "";
|
|
343
|
+
if (complete) lines.pop();
|
|
344
|
+
let printed = "";
|
|
345
|
+
// 1,/^$/d: the range's end is looked for from line 2 on
|
|
346
|
+
let i = 1;
|
|
347
|
+
while (i < lines.length && lines[i] !== "") i++;
|
|
348
|
+
for (i++; i < lines.length; i++) {
|
|
349
|
+
const line = lines[i] as string;
|
|
350
|
+
if (/^-----BEGIN (PGP|SSH|SIGNED) /.test(line)) break;
|
|
351
|
+
printed += line;
|
|
352
|
+
if (i < lines.length - 1 || complete) printed += "\n";
|
|
353
|
+
}
|
|
354
|
+
return printed;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `git rerere` (builtin/rerere.c): with no subcommand, rerere's record and replay (what the
|
|
3
|
+
* merge family runs on conflicts and `git commit` after a commit); `clear`, `forget
|
|
4
|
+
* <pathspec>`, `status`, `remaining`, `diff` and `gc`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const { stdout } = await git.rerere().setSubcommand("status").call(); // "f\n"
|
|
9
|
+
* await git.rerere().setSubcommand("forget").addPath("f").call();
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { rerereGc } from "@statewalker/vcs-store-files";
|
|
14
|
+
import { unifiedDiff } from "@statewalker/vcs-utils";
|
|
15
|
+
import { decodeGitPath, encodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
16
|
+
|
|
17
|
+
import { GitCommand } from "../git-command.js";
|
|
18
|
+
import type { PlumbingTextOutput } from "./check-ref-format-command.js";
|
|
19
|
+
import { hostEnvironmentOf } from "./git-ident.js";
|
|
20
|
+
import { matchPathspec, parsePathspec } from "./pathspec.js";
|
|
21
|
+
import {
|
|
22
|
+
RerereError,
|
|
23
|
+
type RerereHost,
|
|
24
|
+
rerereClear,
|
|
25
|
+
rerereDiff,
|
|
26
|
+
rerereForget,
|
|
27
|
+
rerereGcLocation,
|
|
28
|
+
rerereRemaining,
|
|
29
|
+
rerereStatus,
|
|
30
|
+
runRerere,
|
|
31
|
+
} from "./rerere.js";
|
|
32
|
+
|
|
33
|
+
/** The subcommands of `git rerere` (`record` is the bare `git rerere`). */
|
|
34
|
+
export type RerereSubcommand =
|
|
35
|
+
| "record"
|
|
36
|
+
| "clear"
|
|
37
|
+
| "forget"
|
|
38
|
+
| "status"
|
|
39
|
+
| "remaining"
|
|
40
|
+
| "diff"
|
|
41
|
+
| "gc";
|
|
42
|
+
|
|
43
|
+
const USAGE =
|
|
44
|
+
"usage: git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]\n\n" +
|
|
45
|
+
" --[no-]rerere-autoupdate\n" +
|
|
46
|
+
" register clean resolutions in index\n\n";
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* `git rerere [--[no-]rerere-autoupdate] [<subcommand>]`: git's stdout, stderr and exit
|
|
50
|
+
* status.
|
|
51
|
+
*/
|
|
52
|
+
export class RerereCommand extends GitCommand<PlumbingTextOutput> {
|
|
53
|
+
private subcommand = "record";
|
|
54
|
+
private readonly paths: string[] = [];
|
|
55
|
+
private autoUpdate?: boolean;
|
|
56
|
+
|
|
57
|
+
/** The subcommand (default `record`, the bare `git rerere`); an unknown one is git's usage */
|
|
58
|
+
setSubcommand(subcommand: RerereSubcommand | string): this {
|
|
59
|
+
this.checkCallable();
|
|
60
|
+
this.subcommand = subcommand;
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** A pathspec element of `forget` */
|
|
65
|
+
addPath(path: string): this {
|
|
66
|
+
this.checkCallable();
|
|
67
|
+
this.paths.push(path);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** `--rerere-autoupdate` (true) / `--no-rerere-autoupdate` (false) */
|
|
72
|
+
setAutoUpdate(value: boolean): this {
|
|
73
|
+
this.checkCallable();
|
|
74
|
+
this.autoUpdate = value;
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async call(): Promise<PlumbingTextOutput> {
|
|
79
|
+
this.checkCallable();
|
|
80
|
+
this.setCallable(false);
|
|
81
|
+
const stderr = (lines: string[]) => lines.map((l) => `${l}\n`).join("");
|
|
82
|
+
try {
|
|
83
|
+
return await this.run(stderr);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if (error instanceof RerereError) {
|
|
86
|
+
return { exitCode: error.exitCode, stdout: "", stderr: stderr(error.lines) };
|
|
87
|
+
}
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private async run(stderr: (lines: string[]) => string): Promise<PlumbingTextOutput> {
|
|
93
|
+
const host = this.rerereHost();
|
|
94
|
+
const empty = { exitCode: 0, stdout: "", stderr: "" };
|
|
95
|
+
switch (this.subcommand) {
|
|
96
|
+
case "record": {
|
|
97
|
+
if (!host) return empty;
|
|
98
|
+
await this.staging.read();
|
|
99
|
+
const out = await runRerere(
|
|
100
|
+
host,
|
|
101
|
+
this.autoUpdate === undefined ? {} : { autoUpdate: this.autoUpdate },
|
|
102
|
+
);
|
|
103
|
+
return { exitCode: 0, stdout: "", stderr: stderr(out.messages) };
|
|
104
|
+
}
|
|
105
|
+
case "forget": {
|
|
106
|
+
if (!host) return empty;
|
|
107
|
+
await this.staging.read();
|
|
108
|
+
const items = parsePathspec(this.paths.length > 0 ? this.paths : ["."]);
|
|
109
|
+
const out = await rerereForget(host, (path) => matchPathspec(items, path, 0) > 0);
|
|
110
|
+
return { exitCode: 0, stdout: "", stderr: stderr(out.messages) };
|
|
111
|
+
}
|
|
112
|
+
case "clear": {
|
|
113
|
+
if (!host) return empty;
|
|
114
|
+
const out = await rerereClear(host);
|
|
115
|
+
return { exitCode: 0, stdout: "", stderr: stderr(out.messages) };
|
|
116
|
+
}
|
|
117
|
+
case "status": {
|
|
118
|
+
if (!host) return empty;
|
|
119
|
+
const paths = await rerereStatus(host);
|
|
120
|
+
return { exitCode: 0, stdout: paths.map((p) => `${p}\n`).join(""), stderr: "" };
|
|
121
|
+
}
|
|
122
|
+
case "remaining": {
|
|
123
|
+
if (!host) return empty;
|
|
124
|
+
await this.staging.read();
|
|
125
|
+
const paths = await rerereRemaining(host);
|
|
126
|
+
return { exitCode: 0, stdout: paths.map((p) => `${p}\n`).join(""), stderr: "" };
|
|
127
|
+
}
|
|
128
|
+
case "diff": {
|
|
129
|
+
if (!host) return empty;
|
|
130
|
+
const out = await rerereDiff(host, (minus, plus) =>
|
|
131
|
+
unifiedDiff(minus, plus, {
|
|
132
|
+
context: 3,
|
|
133
|
+
algorithm: "myers",
|
|
134
|
+
findFunction: () => undefined,
|
|
135
|
+
}),
|
|
136
|
+
);
|
|
137
|
+
const bytes = out.stdout.reduce((n, b) => n + b.length, 0);
|
|
138
|
+
const all = new Uint8Array(bytes);
|
|
139
|
+
let at = 0;
|
|
140
|
+
for (const b of out.stdout) {
|
|
141
|
+
all.set(b, at);
|
|
142
|
+
at += b.length;
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
exitCode: out.fatal ? 128 : 0,
|
|
146
|
+
stdout: decodeGitPath(all),
|
|
147
|
+
stderr: out.fatal ? `fatal: ${out.fatal}\n` : "",
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
case "gc": {
|
|
151
|
+
const location = await rerereGcLocation(this.workingCopy);
|
|
152
|
+
if (location) {
|
|
153
|
+
const environment = hostEnvironmentOf(this.workingCopy);
|
|
154
|
+
await rerereGc({ ...location, ...(environment ? { environment } : {}) });
|
|
155
|
+
}
|
|
156
|
+
return empty;
|
|
157
|
+
}
|
|
158
|
+
default:
|
|
159
|
+
return { exitCode: 129, stdout: "", stderr: USAGE };
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** The bytes git writes on stdout for `diff` are its paths' bytes. */
|
|
164
|
+
static stdoutBytes(output: PlumbingTextOutput): Uint8Array {
|
|
165
|
+
return encodeGitPath(output.stdout);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
private rerereHost(): RerereHost | undefined {
|
|
169
|
+
const worktree = this.worktreeAccess;
|
|
170
|
+
if (!worktree) return undefined;
|
|
171
|
+
return {
|
|
172
|
+
workingCopy: this.workingCopy,
|
|
173
|
+
staging: this.staging,
|
|
174
|
+
worktree,
|
|
175
|
+
blobs: this.blobs,
|
|
176
|
+
objectFormat: this.objectFormat,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|