@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,674 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `git replay` (builtin/replay.c, replay.c): replays a range of commits onto a new base with
|
|
3
|
+
* merge-ort in memory, writing only objects, then updates the refs the range named (or prints
|
|
4
|
+
* `update-ref --stdin` lines). The worktree and the index are never touched, so it runs in
|
|
5
|
+
* bare repositories too.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // git replay --ref-action=print --onto main topic1..topic2
|
|
10
|
+
* const { stdout, exitCode } = await git
|
|
11
|
+
* .replay()
|
|
12
|
+
* .setOnto("main")
|
|
13
|
+
* .setRefAction("print")
|
|
14
|
+
* .addRevision("topic1..topic2")
|
|
15
|
+
* .callOutput();
|
|
16
|
+
* // stdout: "update refs/heads/topic2 <new> <old>\n"; exitCode: 0 clean, 1 conflicted
|
|
17
|
+
*
|
|
18
|
+
* // git replay --advance main topic1..topic2 (cherry-picks onto main and moves main)
|
|
19
|
+
* await git.replay().setAdvance("main").addRevision("topic1..topic2").call();
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* The modes: `--onto <newbase>` replays onto a commit and moves the branches the positive
|
|
23
|
+
* revisions name (`--contained`: every local branch at a replayed commit, and a detached HEAD
|
|
24
|
+
* there); `--advance <branch>` replays onto the branch and moves it; `--revert <branch>`
|
|
25
|
+
* reverts the range newest first on the branch (git's `Revert "<subject>"` messages, the
|
|
26
|
+
* current user as author); `--ref <ref>` moves that ref instead. `--linearize` drops merge
|
|
27
|
+
* commits (without it a merge in the range dies). Commits that become empty are dropped.
|
|
28
|
+
* Each replayed commit keeps the original's author, message and extra headers (not its
|
|
29
|
+
* signature) with the current committer. The refs move in one transaction with reflog
|
|
30
|
+
* `replay --onto <id>` / `replay --advance <branch>` / `replay --revert <branch>`, unless
|
|
31
|
+
* `--ref-action=print` (or `replay.refAction=print`) prints `update <ref> <new> <old>` lines.
|
|
32
|
+
* A conflict exits 1 with no output.
|
|
33
|
+
*
|
|
34
|
+
* Version differences (`setCompatibility`): `git replay` is 2.44+. Up to 2.52 it always
|
|
35
|
+
* prints (no `--ref-action`), stops at a root commit, keeps commits that become empty,
|
|
36
|
+
* updates no detached HEAD, prints the lines of the commits replayed before a conflict, and
|
|
37
|
+
* words some refusals otherwise (`option --onto or --advance is mandatory`, `cannot advance
|
|
38
|
+
* target with multiple sources ...`); 2.53 adds `--ref-action` and ref updates. 2.54 adds
|
|
39
|
+
* `--revert`, `--ref`, root commits and dropped empty commits; 2.56 `--linearize`.
|
|
40
|
+
*
|
|
41
|
+
* The message is read as git's `repo_logmsg_reencode` reads it: a commit with an `encoding`
|
|
42
|
+
* header has its message re-encoded to UTF-8 (the header dropped, as every replayed commit's
|
|
43
|
+
* `encoding` is `i18n.commitEncoding`'s, written only when that is not UTF-8). Divergences: an
|
|
44
|
+
* `i18n.logOutputEncoding` other than UTF-8 keeps the message as stored (Web encoders write
|
|
45
|
+
* UTF-8 only); a detached HEAD updated with branches moves after them in
|
|
46
|
+
* a transaction of its own (a batch of HEAD with other refs is not atomic in our stores).
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import {
|
|
50
|
+
type Blobs,
|
|
51
|
+
formatPersonIdent,
|
|
52
|
+
isValidRefName,
|
|
53
|
+
type ObjectId,
|
|
54
|
+
overlayMethods,
|
|
55
|
+
} from "@statewalker/vcs-core";
|
|
56
|
+
|
|
57
|
+
import type { CommandTrees } from "../git-command.js";
|
|
58
|
+
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
59
|
+
import { coreBool } from "./core-config.js";
|
|
60
|
+
import { authorIdentOf, committerIdentOf } from "./git-ident.js";
|
|
61
|
+
import { conflictStyleOf } from "./merge-config.js";
|
|
62
|
+
import { ortConfigOptions } from "./merge-drivers.js";
|
|
63
|
+
import { flatTree, storeFlatTreeOver } from "./merge-support.js";
|
|
64
|
+
import { ortResultEntries } from "./ort-merge.js";
|
|
65
|
+
import { mergeStoredTrees, storedBase } from "./ort-recursive.js";
|
|
66
|
+
import { PlumbingCommand, PlumbingError } from "./plumbing-command.js";
|
|
67
|
+
import { RevListCommand } from "./rev-list-command.js";
|
|
68
|
+
|
|
69
|
+
/** The git versions whose `git replay` ours follows (see the module documentation). */
|
|
70
|
+
export type ReplayCompatibility = "2.52" | "2.53" | "2.56";
|
|
71
|
+
|
|
72
|
+
/** `--ref-action`: update the refs (one transaction) or print `update-ref --stdin` lines. */
|
|
73
|
+
export type ReplayRefAction = "update" | "print";
|
|
74
|
+
|
|
75
|
+
/** One ref the replay moves (replay_ref_update). */
|
|
76
|
+
interface RefUpdate {
|
|
77
|
+
name: string;
|
|
78
|
+
old: ObjectId;
|
|
79
|
+
new: ObjectId;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** A tree the merge needed and the store lacks (merge-ort's `Could not read`). */
|
|
83
|
+
class MissingTree extends Error {
|
|
84
|
+
constructor(readonly id: ObjectId) {
|
|
85
|
+
super(`missing tree ${id}`);
|
|
86
|
+
this.name = "MissingTree";
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const usage = (line: string) => new PlumbingError(line, 129);
|
|
91
|
+
const die = (line: string) => new PlumbingError(`fatal: ${line}`);
|
|
92
|
+
const error = (line: string) => new PlumbingError(`error: ${line}`);
|
|
93
|
+
|
|
94
|
+
/** `git replay`: see the module documentation. */
|
|
95
|
+
export class ReplayCommand extends PlumbingCommand {
|
|
96
|
+
private onto?: string;
|
|
97
|
+
private advance?: string;
|
|
98
|
+
private revert?: string;
|
|
99
|
+
private ref?: string;
|
|
100
|
+
private refAction?: string;
|
|
101
|
+
private contained = false;
|
|
102
|
+
private linearize = false;
|
|
103
|
+
private readonly revisions: string[] = [];
|
|
104
|
+
private readonly walkSteps: ((walk: RevListCommand) => void)[] = [];
|
|
105
|
+
private compatibility: ReplayCompatibility = "2.56";
|
|
106
|
+
|
|
107
|
+
/** `--onto <newbase>`: replay onto this commit-ish, moving the branches of the range. */
|
|
108
|
+
setOnto(revision: string): this {
|
|
109
|
+
this.checkCallable();
|
|
110
|
+
this.onto = revision;
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** `--advance <branch>`: replay onto the branch and move it to the result. */
|
|
115
|
+
setAdvance(branch: string): this {
|
|
116
|
+
this.checkCallable();
|
|
117
|
+
this.advance = branch;
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** `--revert <branch>` (2.54+): revert the range, newest first, on the branch. */
|
|
122
|
+
setRevert(branch: string): this {
|
|
123
|
+
this.checkCallable();
|
|
124
|
+
this.revert = branch;
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** `--ref <ref>` (2.54+): the fully qualified ref to move instead. */
|
|
129
|
+
setRef(ref: string): this {
|
|
130
|
+
this.checkCallable();
|
|
131
|
+
this.ref = ref;
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** `--ref-action <mode>` (2.53+): `update` (the default) or `print`; others die. */
|
|
136
|
+
setRefAction(mode: ReplayRefAction | string): this {
|
|
137
|
+
this.checkCallable();
|
|
138
|
+
this.refAction = mode;
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** `--contained`: move every branch at a replayed commit (with `--onto` only). */
|
|
143
|
+
setContained(contained: boolean): this {
|
|
144
|
+
this.checkCallable();
|
|
145
|
+
this.contained = contained;
|
|
146
|
+
return this;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** `--linearize` (2.56+): drop merge commits, replaying the rest as one line. */
|
|
150
|
+
setLinearize(linearize: boolean): this {
|
|
151
|
+
this.checkCallable();
|
|
152
|
+
this.linearize = linearize;
|
|
153
|
+
return this;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* A revision argument (`a..b`, `^a`, `a^!`, `--branches`, `--not`...), as
|
|
158
|
+
* `git rev-list` reads it.
|
|
159
|
+
*/
|
|
160
|
+
addRevision(revision: string): this {
|
|
161
|
+
this.checkCallable();
|
|
162
|
+
this.revisions.push(revision);
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Other rev-list options of the walk (`--ancestry-path=<commit>`: `addAncestryPath`). */
|
|
167
|
+
configureWalk(step: (walk: RevListCommand) => void): this {
|
|
168
|
+
this.checkCallable();
|
|
169
|
+
this.walkSteps.push(step);
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** The git version to follow (default 2.56; see the module documentation). */
|
|
174
|
+
setCompatibility(version: ReplayCompatibility): this {
|
|
175
|
+
this.checkCallable();
|
|
176
|
+
this.compatibility = version;
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
protected async run(): Promise<number> {
|
|
181
|
+
const v = this.compatibility;
|
|
182
|
+
const modern = v === "2.56";
|
|
183
|
+
// parse_options: options a version lacks are left for setup_revisions, which refuses them
|
|
184
|
+
if (!modern) {
|
|
185
|
+
const unknown =
|
|
186
|
+
this.revert !== undefined
|
|
187
|
+
? `--revert=${this.revert}`
|
|
188
|
+
: this.ref !== undefined
|
|
189
|
+
? `--ref=${this.ref}`
|
|
190
|
+
: this.linearize
|
|
191
|
+
? "--linearize"
|
|
192
|
+
: v === "2.52" && this.refAction !== undefined
|
|
193
|
+
? `--ref-action=${this.refAction}`
|
|
194
|
+
: undefined;
|
|
195
|
+
if (this.onto === undefined && this.advance === undefined) {
|
|
196
|
+
throw usage("error: option --onto or --advance is mandatory");
|
|
197
|
+
}
|
|
198
|
+
if (this.advance !== undefined && this.contained) {
|
|
199
|
+
throw die("options '--advance' and '--contained' cannot be used together");
|
|
200
|
+
}
|
|
201
|
+
if (unknown !== undefined) throw error(`unrecognized argument: ${unknown}`);
|
|
202
|
+
} else {
|
|
203
|
+
if (this.onto === undefined && this.advance === undefined && this.revert === undefined) {
|
|
204
|
+
throw usage("error: exactly one of --onto, --advance, or --revert is required");
|
|
205
|
+
}
|
|
206
|
+
incompatible([
|
|
207
|
+
[this.onto !== undefined, "--onto"],
|
|
208
|
+
[this.advance !== undefined, "--advance"],
|
|
209
|
+
[this.revert !== undefined, "--revert"],
|
|
210
|
+
]);
|
|
211
|
+
incompatible([
|
|
212
|
+
[this.advance !== undefined, "--advance"],
|
|
213
|
+
[this.contained, "--contained"],
|
|
214
|
+
]);
|
|
215
|
+
incompatible([
|
|
216
|
+
[this.revert !== undefined, "--revert"],
|
|
217
|
+
[this.contained, "--contained"],
|
|
218
|
+
]);
|
|
219
|
+
incompatible([
|
|
220
|
+
[this.ref !== undefined, "--ref"],
|
|
221
|
+
[this.contained, "--contained"],
|
|
222
|
+
]);
|
|
223
|
+
incompatible([
|
|
224
|
+
[this.linearize, "--linearize"],
|
|
225
|
+
[this.contained, "--contained"],
|
|
226
|
+
]);
|
|
227
|
+
}
|
|
228
|
+
const print = v === "2.52" || this.refActionMode() === "print";
|
|
229
|
+
|
|
230
|
+
// setup_revisions, then the replay's mode from the command line's revisions
|
|
231
|
+
const walk = new RevListCommand(this._workingCopy);
|
|
232
|
+
for (const step of this.walkSteps) step(walk);
|
|
233
|
+
for (const revision of this.revisions) walk.addRevision(revision);
|
|
234
|
+
const reverting = modern && this.revert !== undefined;
|
|
235
|
+
walk.setOrder("topo").setReverse(!reverting).setFullHistory(true);
|
|
236
|
+
const { entries } = await walk.resolve();
|
|
237
|
+
|
|
238
|
+
const resolver = this.revisionResolver();
|
|
239
|
+
const positiveRefs = new Set<string>();
|
|
240
|
+
let positive = 0;
|
|
241
|
+
for (const entry of entries) {
|
|
242
|
+
if (entry.exclude) continue;
|
|
243
|
+
positive++;
|
|
244
|
+
const name = entry.name ?? entry.id;
|
|
245
|
+
const found = await resolver.dwimRef(name).catch(() => []);
|
|
246
|
+
if (found.length === 1) positiveRefs.add((found[0] as { ref: string }).ref);
|
|
247
|
+
}
|
|
248
|
+
const head = await this.refsStore.get("HEAD").catch(() => undefined);
|
|
249
|
+
const detachedHead = !(head !== undefined && "target" in head);
|
|
250
|
+
if (positive === 0) throw die("need some commits to replay");
|
|
251
|
+
|
|
252
|
+
let onto: ObjectId | undefined;
|
|
253
|
+
let branch: string | undefined;
|
|
254
|
+
let updateRefs: Set<string> | undefined;
|
|
255
|
+
if (!modern && this.onto !== undefined && this.advance !== undefined) {
|
|
256
|
+
throw die("options '--onto' and '--advance' cannot be used together");
|
|
257
|
+
}
|
|
258
|
+
if (this.onto !== undefined) {
|
|
259
|
+
onto = await this.peelCommittish(this.onto, "--onto");
|
|
260
|
+
updateRefs = positiveRefs;
|
|
261
|
+
} else {
|
|
262
|
+
const option = this.advance !== undefined ? "--advance" : "--revert";
|
|
263
|
+
const name = (this.advance ?? this.revert) as string;
|
|
264
|
+
const found = await resolver.dwimRef(name).catch(() => []);
|
|
265
|
+
if (v === "2.52") onto = await this.peelCommittish(name, option);
|
|
266
|
+
if (found.length !== 1) throw die(`argument to ${option} must be a reference`);
|
|
267
|
+
branch = (found[0] as { ref: string }).ref;
|
|
268
|
+
if (v !== "2.52") onto = await this.peelCommittish(branch, option);
|
|
269
|
+
if (positive > 1) {
|
|
270
|
+
throw die(
|
|
271
|
+
modern
|
|
272
|
+
? `'${option}' cannot be used with multiple revision ranges because the ordering would be ill-defined`
|
|
273
|
+
: "cannot advance target with multiple sources because ordering would be ill-defined",
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (onto === undefined) throw die("Replaying down to root commit is not supported yet!");
|
|
278
|
+
|
|
279
|
+
let ref: string | undefined = branch;
|
|
280
|
+
let refOld: ObjectId = onto;
|
|
281
|
+
if (modern) {
|
|
282
|
+
if (this.linearize && updateRefs && updateRefs.size > 1) {
|
|
283
|
+
throw error("'--linearize' cannot be used with multiple branches");
|
|
284
|
+
}
|
|
285
|
+
if (this.ref !== undefined) {
|
|
286
|
+
if (updateRefs && updateRefs.size > 1) {
|
|
287
|
+
throw error("'--ref' cannot be used with multiple revision ranges");
|
|
288
|
+
}
|
|
289
|
+
if (!isValidRefName(this.ref) || !this.ref.startsWith("refs/")) {
|
|
290
|
+
throw error(`'${this.ref}' is not a valid refname`);
|
|
291
|
+
}
|
|
292
|
+
ref = this.ref;
|
|
293
|
+
const current = await this.refsStore.resolve(this.ref).catch(() => undefined);
|
|
294
|
+
refOld = current?.objectId ?? this.objectFormat.nullId;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// the walk
|
|
299
|
+
const decorations = await this.localDecorations(modern && detachedHead);
|
|
300
|
+
const replayed = new Map<ObjectId, ObjectId>();
|
|
301
|
+
const updates: RefUpdate[] = [];
|
|
302
|
+
let last: ObjectId | undefined = onto;
|
|
303
|
+
let clean = true;
|
|
304
|
+
const stores = this.mergeStores();
|
|
305
|
+
const log = await walk.call();
|
|
306
|
+
for await (const commit of log) {
|
|
307
|
+
const parents = commit.parents;
|
|
308
|
+
if (!modern && parents.length === 0) {
|
|
309
|
+
throw die(
|
|
310
|
+
v === "2.52"
|
|
311
|
+
? "replaying down to root commit is not supported yet!"
|
|
312
|
+
: "replaying down from root commit is not supported yet!",
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
if (parents.length > 1) {
|
|
316
|
+
if (!this.linearize) throw die("replaying merge commits is not supported yet!");
|
|
317
|
+
} else {
|
|
318
|
+
const parent = parents[0];
|
|
319
|
+
let base = (parent !== undefined ? replayed.get(parent) : undefined) ?? onto;
|
|
320
|
+
if (this.linearize || reverting) base = last as ObjectId;
|
|
321
|
+
last = await this.pick(stores, commit.id, parent, base, reverting);
|
|
322
|
+
}
|
|
323
|
+
if (last === undefined) {
|
|
324
|
+
clean = false;
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
replayed.set(commit.id, last);
|
|
328
|
+
if (ref !== undefined) continue;
|
|
329
|
+
for (const name of decorations.get(commit.id) ?? []) {
|
|
330
|
+
if (!this.contained && !updateRefs?.has(name)) continue;
|
|
331
|
+
const update = { name, old: commit.id, new: last };
|
|
332
|
+
// git 2.52 prints as it goes, 2.53 in its print mode too
|
|
333
|
+
if (!modern && print) await this.write(updateLine(update));
|
|
334
|
+
else updates.push(update);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (!clean) return 1;
|
|
338
|
+
if (ref !== undefined) {
|
|
339
|
+
const update = { name: ref, old: refOld, new: last as ObjectId };
|
|
340
|
+
if (!modern && print) await this.write(updateLine(update));
|
|
341
|
+
else updates.push(update);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (print) {
|
|
345
|
+
for (const update of updates) await this.write(updateLine(update));
|
|
346
|
+
return 0;
|
|
347
|
+
}
|
|
348
|
+
let message: string;
|
|
349
|
+
if (reverting) message = `replay --revert ${this.revert}`;
|
|
350
|
+
else if (this.advance !== undefined) message = `replay --advance ${this.advance}`;
|
|
351
|
+
else message = `replay --onto ${onto}`;
|
|
352
|
+
await this.applyUpdates(updates, message);
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** get_ref_action_mode: the option, else `replay.refAction`, else `update`. */
|
|
357
|
+
private refActionMode(): ReplayRefAction {
|
|
358
|
+
const parse = (value: string, source: string): ReplayRefAction => {
|
|
359
|
+
if (value === "update" || value === "print") return value;
|
|
360
|
+
throw die(`invalid ${source} value: '${value}'`);
|
|
361
|
+
};
|
|
362
|
+
if (this.refAction !== undefined) return parse(this.refAction, "--ref-action");
|
|
363
|
+
const value = RemoteConfigStore.from(this._workingCopy).value("replay.refAction");
|
|
364
|
+
if (value !== undefined) return parse(value, "replay.refAction");
|
|
365
|
+
return "update";
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** peel_committish: the commit a commit-ish names, or git's death for the option. */
|
|
369
|
+
private async peelCommittish(name: string, option: string): Promise<ObjectId | undefined> {
|
|
370
|
+
const resolver = this.revisionResolver();
|
|
371
|
+
const id = await resolver.resolve(name).catch(() => undefined);
|
|
372
|
+
if (id === undefined) {
|
|
373
|
+
// git 2.52 left onto unset (its later death: no root commits)
|
|
374
|
+
if (this.compatibility === "2.52") return undefined;
|
|
375
|
+
throw die(`'${name}' is not a valid commit-ish for ${option}`);
|
|
376
|
+
}
|
|
377
|
+
const commit = await resolver.commitReference(id).catch(() => undefined);
|
|
378
|
+
if (commit === undefined) {
|
|
379
|
+
if (this.compatibility === "2.52") return undefined;
|
|
380
|
+
throw die(`'${name}' does not point to a commit for ${option}`);
|
|
381
|
+
}
|
|
382
|
+
return commit;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* get_name_decoration for each commit, the local branches and (`withHead`, a detached HEAD)
|
|
387
|
+
* HEAD: load_ref_decorations adds refs in name order, then HEAD, each in front of the
|
|
388
|
+
* commit's list.
|
|
389
|
+
*/
|
|
390
|
+
private async localDecorations(withHead: boolean): Promise<Map<ObjectId, string[]>> {
|
|
391
|
+
const out = new Map<ObjectId, string[]>();
|
|
392
|
+
const add = (id: ObjectId, name: string) => {
|
|
393
|
+
const list = out.get(id);
|
|
394
|
+
if (list) list.unshift(name);
|
|
395
|
+
else out.set(id, [name]);
|
|
396
|
+
};
|
|
397
|
+
const names: string[] = [];
|
|
398
|
+
for await (const ref of this.refsStore.list("refs/heads/")) names.push(ref.name);
|
|
399
|
+
names.sort(compareBytes);
|
|
400
|
+
for (const name of names) {
|
|
401
|
+
const resolved = await this.refsStore.resolve(name).catch(() => undefined);
|
|
402
|
+
const id = resolved?.objectId;
|
|
403
|
+
if (id === undefined) continue;
|
|
404
|
+
const commit = await this.revisionResolver()
|
|
405
|
+
.commitReference(id)
|
|
406
|
+
.catch(() => undefined);
|
|
407
|
+
if (commit === id) add(id, name);
|
|
408
|
+
}
|
|
409
|
+
if (withHead) {
|
|
410
|
+
const id = (await this.refsStore.resolve("HEAD").catch(() => undefined))?.objectId;
|
|
411
|
+
if (id !== undefined) add(id, "HEAD");
|
|
412
|
+
}
|
|
413
|
+
return out;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* pick_regular_commit: merges the commit's change onto `base` (reverted: its inverse) and
|
|
418
|
+
* writes the result commit; undefined on a conflict, `base` itself when the change is
|
|
419
|
+
* already there (2.54+).
|
|
420
|
+
*/
|
|
421
|
+
private async pick(
|
|
422
|
+
stores: { trees: CommandTrees; blobs: Blobs },
|
|
423
|
+
id: ObjectId,
|
|
424
|
+
parent: ObjectId | undefined,
|
|
425
|
+
base: ObjectId,
|
|
426
|
+
reverting: boolean,
|
|
427
|
+
): Promise<ObjectId | undefined> {
|
|
428
|
+
const { trees, blobs } = stores;
|
|
429
|
+
const pickTree = await this.commits.getTree(id);
|
|
430
|
+
const parentTree =
|
|
431
|
+
parent !== undefined ? await this.commits.getTree(parent) : this.objectFormat.emptyTreeId;
|
|
432
|
+
const baseTree = await this.commits.getTree(base);
|
|
433
|
+
const pickName = await this.abbreviateObjectId(id);
|
|
434
|
+
const baseName = await this.abbreviateObjectId(base);
|
|
435
|
+
const worktree = this.worktreeOrNone();
|
|
436
|
+
const common = {
|
|
437
|
+
style: conflictStyleOf(this.workingCopy),
|
|
438
|
+
ignoreCase: coreBool(this.workingCopy, "ignorecase", false),
|
|
439
|
+
...ortConfigOptions(this.workingCopy, worktree),
|
|
440
|
+
};
|
|
441
|
+
const [ancestorTree, theirsTree, ancestorLabel, theirsLabel] = reverting
|
|
442
|
+
? [pickTree, parentTree, pickName, `parent of ${pickName}`]
|
|
443
|
+
: [
|
|
444
|
+
parentTree,
|
|
445
|
+
pickTree,
|
|
446
|
+
parent !== undefined ? `parent of ${pickName}` : "empty tree",
|
|
447
|
+
pickName,
|
|
448
|
+
];
|
|
449
|
+
let merge: Awaited<ReturnType<typeof mergeStoredTrees>>;
|
|
450
|
+
try {
|
|
451
|
+
merge = await mergeStoredTrees(
|
|
452
|
+
{ trees, blobs },
|
|
453
|
+
storedBase(ancestorTree, ancestorLabel, () => flatTree(trees, ancestorTree)),
|
|
454
|
+
baseTree,
|
|
455
|
+
theirsTree,
|
|
456
|
+
{ ...common, oursLabel: baseName, theirsLabel, baseLabel: ancestorLabel },
|
|
457
|
+
);
|
|
458
|
+
} catch (e) {
|
|
459
|
+
if (e instanceof MissingTree) {
|
|
460
|
+
throw new PlumbingError(
|
|
461
|
+
[
|
|
462
|
+
`error: Could not read ${e.id}`,
|
|
463
|
+
`error: collecting merge info failed for trees ${ancestorTree}, ${baseTree}, ${theirsTree}`,
|
|
464
|
+
`error: merge of ${id} onto ${base} failed`,
|
|
465
|
+
].join("\n"),
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
throw e;
|
|
469
|
+
}
|
|
470
|
+
// merge-ort writes its result tree (and conflicted blobs) whether clean or not
|
|
471
|
+
const target = await ortResultEntries(blobs, merge);
|
|
472
|
+
const resultTree = await storeFlatTreeOver(trees, baseTree, merge.ours, target);
|
|
473
|
+
if (!merge.clean) return undefined;
|
|
474
|
+
if (this.compatibility === "2.56" && resultTree === baseTree && pickTree !== parentTree) {
|
|
475
|
+
return base;
|
|
476
|
+
}
|
|
477
|
+
return this.createCommit(id, resultTree, base, reverting);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/** create_commit: the original's author, message and extra headers on the new tree. */
|
|
481
|
+
private async createCommit(
|
|
482
|
+
id: ObjectId,
|
|
483
|
+
tree: ObjectId,
|
|
484
|
+
parent: ObjectId,
|
|
485
|
+
reverting: boolean,
|
|
486
|
+
): Promise<ObjectId> {
|
|
487
|
+
const objects = this._workingCopy.history?.objects;
|
|
488
|
+
if (!objects) throw new Error("WorkingCopy.history.objects is required for git replay");
|
|
489
|
+
const raw = latin1(await this.readObject(id));
|
|
490
|
+
const split = raw.indexOf("\n\n");
|
|
491
|
+
const headerText = split >= 0 ? raw.slice(0, split) : raw;
|
|
492
|
+
const lines = headerText.split("\n");
|
|
493
|
+
// standard_header_field (encoding among them) and the signatures
|
|
494
|
+
const excluded = new Set(["tree", "parent", "author", "committer", "encoding", "gpgsig"]);
|
|
495
|
+
if (this.compatibility !== "2.52") excluded.add("gpgsig-sha256");
|
|
496
|
+
let author: string | undefined;
|
|
497
|
+
let extra = "";
|
|
498
|
+
let keep = false;
|
|
499
|
+
let encoding: string | undefined;
|
|
500
|
+
for (const line of lines) {
|
|
501
|
+
if (line.startsWith(" ")) {
|
|
502
|
+
if (keep) extra += `${line}\n`;
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
const space = line.indexOf(" ");
|
|
506
|
+
const key = space >= 0 ? line.slice(0, space) : line;
|
|
507
|
+
if (key === "author" && author === undefined) author = line.slice(space + 1);
|
|
508
|
+
if (key === "encoding" && encoding === undefined) encoding = line.slice(space + 1);
|
|
509
|
+
keep = !excluded.has(key);
|
|
510
|
+
if (keep) extra += `${line}\n`;
|
|
511
|
+
}
|
|
512
|
+
const now = Math.floor(Date.now() / 1000);
|
|
513
|
+
let message: string;
|
|
514
|
+
const config = RemoteConfigStore.from(this._workingCopy);
|
|
515
|
+
const commitEncoding = config.value("i18n.commitEncoding");
|
|
516
|
+
const outputEncoding = config.value("i18n.logOutputEncoding") ?? commitEncoding;
|
|
517
|
+
let stored = split >= 0 ? raw.slice(split + 2) : "";
|
|
518
|
+
// repo_logmsg_reencode: from the commit's encoding to the output one (UTF-8 here)
|
|
519
|
+
if (encoding !== undefined && !isUtf8(encoding) && isUtf8(outputEncoding)) {
|
|
520
|
+
try {
|
|
521
|
+
const decoded = new TextDecoder(encoding, { fatal: true }).decode(latin1Bytes(stored));
|
|
522
|
+
stored = latin1(utf8(decoded));
|
|
523
|
+
} catch {
|
|
524
|
+
// an encoding the decoder does not know (or bytes it refuses): git keeps the message
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
const body = skipBlankLines(stored, 0);
|
|
528
|
+
if (reverting) {
|
|
529
|
+
const subject = body.slice(0, body.indexOf("\n") >= 0 ? body.indexOf("\n") : body.length);
|
|
530
|
+
let text: string;
|
|
531
|
+
if (subject.startsWith('Revert "') && !subject.slice(8).startsWith('Revert "')) {
|
|
532
|
+
text = `Reapply "${subject.slice(8)}\n`;
|
|
533
|
+
} else {
|
|
534
|
+
text = `Revert "${subject}"\n`;
|
|
535
|
+
}
|
|
536
|
+
message = `${text}\nThis reverts commit ${id}.\n`;
|
|
537
|
+
author = latin1(utf8(formatPersonIdent(authorIdentOf(this._workingCopy, { now }))));
|
|
538
|
+
} else {
|
|
539
|
+
message = body;
|
|
540
|
+
}
|
|
541
|
+
const committer = latin1(utf8(formatPersonIdent(committerIdentOf(this._workingCopy, { now }))));
|
|
542
|
+
const text =
|
|
543
|
+
`tree ${tree}\nparent ${parent}\nauthor ${author ?? ""}\ncommitter ${committer}\n` +
|
|
544
|
+
(isUtf8(commitEncoding) ? "" : `encoding ${commitEncoding}\n`) +
|
|
545
|
+
`${extra}\n${message}`;
|
|
546
|
+
const bytes = latin1Bytes(text);
|
|
547
|
+
return objects.put("commit", bytes.length, [bytes]);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/** The object's content as stored. */
|
|
551
|
+
private async readObject(id: ObjectId): Promise<Uint8Array> {
|
|
552
|
+
const objects = this._workingCopy.history?.objects;
|
|
553
|
+
const object = await objects?.get(id);
|
|
554
|
+
if (!object) throw die(`unable to read ${id}`);
|
|
555
|
+
if (object.bytes) return object.bytes;
|
|
556
|
+
const chunks: Uint8Array[] = [];
|
|
557
|
+
let size = 0;
|
|
558
|
+
for await (const c of object.content) {
|
|
559
|
+
chunks.push(c);
|
|
560
|
+
size += c.length;
|
|
561
|
+
}
|
|
562
|
+
const out = new Uint8Array(size);
|
|
563
|
+
let at = 0;
|
|
564
|
+
for (const c of chunks) {
|
|
565
|
+
out.set(c, at);
|
|
566
|
+
at += c.length;
|
|
567
|
+
}
|
|
568
|
+
return out;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/** The refs moved in one transaction (a detached HEAD in a second one: see the module). */
|
|
572
|
+
private async applyUpdates(updates: RefUpdate[], message: string): Promise<void> {
|
|
573
|
+
if (updates.length === 0) return;
|
|
574
|
+
const nullId = this.objectFormat.nullId;
|
|
575
|
+
const command = (u: RefUpdate) => ({
|
|
576
|
+
name: u.name,
|
|
577
|
+
old: u.old === nullId ? null : u.old,
|
|
578
|
+
new: u.new,
|
|
579
|
+
...(u.name === "HEAD" ? { noDeref: true } : {}),
|
|
580
|
+
});
|
|
581
|
+
const refsFirst = updates.filter((u) => u.name.startsWith("refs/"));
|
|
582
|
+
const others = updates.filter((u) => !u.name.startsWith("refs/"));
|
|
583
|
+
const batches = refsFirst.length > 0 && others.length > 0 ? [refsFirst, others] : [updates];
|
|
584
|
+
for (const batch of batches) {
|
|
585
|
+
const result = await this.refsStore.batch(batch.map(command), this.reflogLine(message));
|
|
586
|
+
if (!result.ok) {
|
|
587
|
+
const rejected = result.rejected[0];
|
|
588
|
+
const name = rejected?.name ?? (batch[0] as RefUpdate).name;
|
|
589
|
+
const update = batch.find((u) => u.name === name);
|
|
590
|
+
let reason = `cannot lock ref '${name}'`;
|
|
591
|
+
if (rejected?.reason === "mismatch" && update) {
|
|
592
|
+
const current = await this.refsStore.resolve(name).catch(() => undefined);
|
|
593
|
+
reason += current?.objectId
|
|
594
|
+
? `: is at ${current.objectId} but expected ${update.old}`
|
|
595
|
+
: `: unable to resolve reference '${name}'`;
|
|
596
|
+
}
|
|
597
|
+
throw error(`failed to commit ref transaction: ${reason}`);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/** The stores the merge reads: a missing tree is merge-ort's `Could not read`. */
|
|
603
|
+
private mergeStores(): { trees: CommandTrees; blobs: Blobs } {
|
|
604
|
+
const trees = this.trees;
|
|
605
|
+
const wrapped = overlayMethods(trees, {
|
|
606
|
+
loadTree: async function* (id: ObjectId) {
|
|
607
|
+
if (!(await trees.has(id))) throw new MissingTree(id);
|
|
608
|
+
yield* trees.loadTree(id);
|
|
609
|
+
},
|
|
610
|
+
});
|
|
611
|
+
return { trees: wrapped, blobs: this.blobs };
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/** The worktree, none in a bare repository (its attributes are read from it). */
|
|
615
|
+
private worktreeOrNone() {
|
|
616
|
+
try {
|
|
617
|
+
return this.worktreeAccess;
|
|
618
|
+
} catch {
|
|
619
|
+
return undefined;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/** die_for_incompatible_opt4's message for the options set. */
|
|
625
|
+
function incompatible(options: [boolean, string][]): void {
|
|
626
|
+
const set = options.filter(([on]) => on).map(([, name]) => `'${name}'`);
|
|
627
|
+
if (set.length < 2) return;
|
|
628
|
+
if (set.length === 2) throw die(`options ${set[0]} and ${set[1]} cannot be used together`);
|
|
629
|
+
throw die(
|
|
630
|
+
`options ${set.slice(0, -1).join(", ")}, and ${set[set.length - 1]} cannot be used together`,
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/** utf8.c's is_encoding_utf8: unset, `UTF-8` or `utf8` in any case. */
|
|
635
|
+
function isUtf8(name: string | undefined): boolean {
|
|
636
|
+
return name === undefined || /^utf-?8$/i.test(name);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const updateLine = (u: RefUpdate) => `update ${u.name} ${u.new} ${u.old}\n`;
|
|
640
|
+
|
|
641
|
+
/** commit.c's skip_blank_lines from `at`: lines of whitespace alone are dropped. */
|
|
642
|
+
function skipBlankLines(text: string, at: number): string {
|
|
643
|
+
let p = at;
|
|
644
|
+
for (;;) {
|
|
645
|
+
let q = p;
|
|
646
|
+
while (q < text.length && text[q] !== "\n" && /\s/.test(text[q] as string)) q++;
|
|
647
|
+
if (q < text.length && text[q] === "\n") p = q + 1;
|
|
648
|
+
else break;
|
|
649
|
+
}
|
|
650
|
+
return text.slice(p);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
function compareBytes(a: string, b: string): number {
|
|
654
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/** Bytes as a string of one character per byte. */
|
|
658
|
+
function latin1(bytes: Uint8Array): string {
|
|
659
|
+
let out = "";
|
|
660
|
+
for (let i = 0; i < bytes.length; i += 8192) {
|
|
661
|
+
out += String.fromCharCode(...bytes.subarray(i, i + 8192));
|
|
662
|
+
}
|
|
663
|
+
return out;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
function latin1Bytes(text: string): Uint8Array {
|
|
667
|
+
const out = new Uint8Array(text.length);
|
|
668
|
+
for (let i = 0; i < text.length; i++) out[i] = text.charCodeAt(i) & 0xff;
|
|
669
|
+
return out;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function utf8(text: string): Uint8Array {
|
|
673
|
+
return new TextEncoder().encode(text);
|
|
674
|
+
}
|