@statewalker/vcs-commands 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commands/add-command.d.ts +32 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/add-patch.d.ts +7 -0
- package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts +2 -0
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-modes.d.ts +6 -2
- package/dist/commands/add-patch/patch-modes.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-session.d.ts +4 -0
- package/dist/commands/add-patch/patch-session.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +88 -2
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-command.d.ts +2 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.d.ts +7 -0
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/apply/index.d.ts +1 -1
- package/dist/commands/apply/index.d.ts.map +1 -1
- package/dist/commands/archive/archive-command.d.ts +169 -0
- package/dist/commands/archive/archive-command.d.ts.map +1 -0
- package/dist/commands/archive/archive-entry.d.ts +60 -0
- package/dist/commands/archive/archive-entry.d.ts.map +1 -0
- package/dist/commands/archive/index.d.ts +8 -0
- package/dist/commands/archive/index.d.ts.map +1 -0
- package/dist/commands/archive/remote-archive-command.d.ts +56 -0
- package/dist/commands/archive/remote-archive-command.d.ts.map +1 -0
- package/dist/commands/archive/tar-archive.d.ts +31 -0
- package/dist/commands/archive/tar-archive.d.ts.map +1 -0
- package/dist/commands/archive/tar-commit-id.d.ts +13 -0
- package/dist/commands/archive/tar-commit-id.d.ts.map +1 -0
- package/dist/commands/archive/upload-archive-writer.d.ts +48 -0
- package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -0
- package/dist/commands/archive/zip-archive.d.ts +42 -0
- package/dist/commands/archive/zip-archive.d.ts.map +1 -0
- package/dist/commands/attributes-source.d.ts +10 -0
- package/dist/commands/attributes-source.d.ts.map +1 -1
- package/dist/commands/blame-command.d.ts +345 -8
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/blame-ignore.d.ts +48 -0
- package/dist/commands/blame-ignore.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-create-command.d.ts +67 -0
- package/dist/commands/bundle/bundle-create-command.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-format.d.ts +89 -0
- package/dist/commands/bundle/bundle-format.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-list.d.ts +92 -0
- package/dist/commands/bundle/bundle-list.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts +81 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-support.d.ts +32 -0
- package/dist/commands/bundle/bundle-support.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-transport.d.ts +38 -0
- package/dist/commands/bundle/bundle-transport.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts +43 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri.d.ts +55 -0
- package/dist/commands/bundle/bundle-uri.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-verify.d.ts +63 -0
- package/dist/commands/bundle/bundle-verify.d.ts.map +1 -0
- package/dist/commands/bundle/index.d.ts +14 -0
- package/dist/commands/bundle/index.d.ts.map +1 -0
- package/dist/commands/cat-file/batch-format.d.ts +58 -0
- package/dist/commands/cat-file/batch-format.d.ts.map +1 -0
- package/dist/commands/cat-file/cat-file-command.d.ts +135 -0
- package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -0
- package/dist/commands/cat-file/index.d.ts +3 -0
- package/dist/commands/cat-file/index.d.ts.map +1 -0
- package/dist/commands/check-attr-command.d.ts +66 -0
- package/dist/commands/check-attr-command.d.ts.map +1 -0
- package/dist/commands/check-ignore-command.d.ts +58 -0
- package/dist/commands/check-ignore-command.d.ts.map +1 -0
- package/dist/commands/check-mailmap-command.d.ts +49 -0
- package/dist/commands/check-mailmap-command.d.ts.map +1 -0
- package/dist/commands/check-ref-format-command.d.ts +60 -0
- package/dist/commands/check-ref-format-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +7 -0
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-index-command.d.ts +96 -0
- package/dist/commands/checkout-index-command.d.ts.map +1 -0
- package/dist/commands/checkout-paths.d.ts +4 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-command.d.ts +61 -0
- package/dist/commands/cherry-command.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +33 -1
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +32 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +56 -0
- package/dist/commands/clean-interactive.d.ts.map +1 -0
- package/dist/commands/clone-command.d.ts +135 -2
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +59 -3
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/config-command.d.ts +2 -0
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/daemon-access-hook.d.ts +36 -0
- package/dist/commands/daemon-access-hook.d.ts.map +1 -0
- package/dist/commands/default-branch.d.ts +42 -0
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/describe-command.d.ts +71 -64
- package/dist/commands/describe-command.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +249 -10
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/diff-external.d.ts +43 -0
- package/dist/commands/diff-external.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts +27 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts +129 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/index.d.ts +3 -0
- package/dist/commands/diff-plumbing/index.d.ts.map +1 -0
- package/dist/commands/diff-textconv.d.ts +5 -1
- package/dist/commands/diff-textconv.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-export-command.d.ts +135 -0
- package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-import-command.d.ts +182 -0
- package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts +64 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -0
- package/dist/commands/fast-export/index.d.ts +4 -0
- package/dist/commands/fast-export/index.d.ts.map +1 -0
- package/dist/commands/fetch-command.d.ts +125 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fetch-multiple-command.d.ts +193 -0
- package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
- package/dist/commands/format-patch-command.d.ts +28 -2
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/format-rev-command.d.ts +58 -0
- package/dist/commands/format-rev-command.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-msg-ids.d.ts +18 -3
- package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -1
- package/dist/commands/fsmonitor-refresh.d.ts +69 -0
- package/dist/commands/fsmonitor-refresh.d.ts.map +1 -0
- package/dist/commands/gc-command.d.ts +5 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +77 -4
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +47 -1
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/git-paths.d.ts +26 -0
- package/dist/commands/git-paths.d.ts.map +1 -0
- package/dist/commands/grep/grep-command.d.ts +2 -1
- package/dist/commands/grep/grep-command.d.ts.map +1 -1
- package/dist/commands/history-command.d.ts +156 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/http-config.d.ts +38 -0
- package/dist/commands/http-config.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +12 -1
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index-host.d.ts.map +1 -1
- package/dist/commands/index.d.ts +56 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +6 -3
- package/dist/commands/init-command.d.ts +89 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/last-modified-command.d.ts +102 -0
- package/dist/commands/last-modified-command.d.ts.map +1 -0
- package/dist/commands/lfs/go-url.d.ts +43 -0
- package/dist/commands/lfs/go-url.d.ts.map +1 -0
- package/dist/commands/lfs/index.d.ts +3 -0
- package/dist/commands/lfs/index.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-config.d.ts +174 -0
- package/dist/commands/lfs/lfs-config.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-endpoint-command.d.ts +83 -0
- package/dist/commands/lfs/lfs-endpoint-command.d.ts.map +1 -0
- package/dist/commands/line-log.d.ts +161 -0
- package/dist/commands/line-log.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +261 -6
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +4 -2
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +88 -2
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-files-command.d.ts +153 -0
- package/dist/commands/ls-files-command.d.ts.map +1 -0
- package/dist/commands/ls-remote-command.d.ts +5 -0
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/ls-tree-command.d.ts +105 -0
- package/dist/commands/ls-tree-command.d.ts.map +1 -0
- package/dist/commands/mailmap.d.ts +24 -1
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/maintenance-run-command.d.ts +122 -0
- package/dist/commands/maintenance-run-command.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +58 -1
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-config.d.ts +7 -0
- package/dist/commands/merge-config.d.ts.map +1 -1
- package/dist/commands/merge-drivers.d.ts +69 -5
- package/dist/commands/merge-drivers.d.ts.map +1 -1
- package/dist/commands/merge-strategy-options.d.ts +69 -0
- package/dist/commands/merge-strategy-options.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +16 -0
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/merge-tree-command.d.ts +122 -0
- package/dist/commands/merge-tree-command.d.ts.map +1 -0
- package/dist/commands/message-cleanup.d.ts +2 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -1
- package/dist/commands/mktag-command.d.ts +51 -0
- package/dist/commands/mktag-command.d.ts.map +1 -0
- package/dist/commands/name-rev-command.d.ts +65 -0
- package/dist/commands/name-rev-command.d.ts.map +1 -0
- package/dist/commands/name-rev.d.ts +110 -22
- package/dist/commands/name-rev.d.ts.map +1 -1
- package/dist/commands/object-store/count-objects-command.d.ts +58 -0
- package/dist/commands/object-store/count-objects-command.d.ts.map +1 -0
- package/dist/commands/object-store/index.d.ts +5 -0
- package/dist/commands/object-store/index.d.ts.map +1 -0
- package/dist/commands/object-store/objects-directory.d.ts +12 -0
- package/dist/commands/object-store/objects-directory.d.ts.map +1 -0
- package/dist/commands/object-store/prune-command.d.ts +38 -0
- package/dist/commands/object-store/prune-command.d.ts.map +1 -0
- package/dist/commands/object-store/show-index-command.d.ts +23 -0
- package/dist/commands/object-store/show-index-command.d.ts.map +1 -0
- package/dist/commands/octopus-merge.d.ts +26 -1
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/ort-merge.d.ts +40 -0
- package/dist/commands/ort-merge.d.ts.map +1 -1
- package/dist/commands/ort-recursive.d.ts.map +1 -1
- package/dist/commands/patch-id-command.d.ts +30 -0
- package/dist/commands/patch-id-command.d.ts.map +1 -0
- package/dist/commands/patch-id.d.ts +82 -0
- package/dist/commands/patch-id.d.ts.map +1 -1
- package/dist/commands/plumbing-command.d.ts +66 -0
- package/dist/commands/plumbing-command.d.ts.map +1 -0
- package/dist/commands/plumbing-input.d.ts +38 -0
- package/dist/commands/plumbing-input.d.ts.map +1 -0
- package/dist/commands/promisor-remote-reply.d.ts +35 -0
- package/dist/commands/promisor-remote-reply.d.ts.map +1 -0
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +182 -38
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +82 -2
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/index.d.ts +4 -0
- package/dist/commands/range-diff/index.d.ts.map +1 -0
- package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
- package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff.d.ts +106 -0
- package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
- package/dist/commands/read-tree-command.d.ts +14 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +129 -4
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/refs-command.d.ts +81 -0
- package/dist/commands/refs-command.d.ts.map +1 -0
- package/dist/commands/remerge-diff.d.ts +59 -0
- package/dist/commands/remerge-diff.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +41 -0
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-object-info-command.d.ts +55 -0
- package/dist/commands/remote-object-info-command.d.ts.map +1 -0
- package/dist/commands/remote-show-command.d.ts +204 -0
- package/dist/commands/remote-show-command.d.ts.map +1 -0
- package/dist/commands/remote-transport.d.ts +40 -3
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/repack-command.d.ts +115 -0
- package/dist/commands/repack-command.d.ts.map +1 -0
- package/dist/commands/replace-command.d.ts +143 -0
- package/dist/commands/replace-command.d.ts.map +1 -0
- package/dist/commands/replay-command.d.ts +117 -0
- package/dist/commands/replay-command.d.ts.map +1 -0
- package/dist/commands/repo-command.d.ts +136 -0
- package/dist/commands/repo-command.d.ts.map +1 -0
- package/dist/commands/request-pull-command.d.ts +82 -0
- package/dist/commands/request-pull-command.d.ts.map +1 -0
- package/dist/commands/rerere-command.d.ts +36 -0
- package/dist/commands/rerere-command.d.ts.map +1 -0
- package/dist/commands/rerere.d.ts +102 -0
- package/dist/commands/rerere.d.ts.map +1 -0
- package/dist/commands/reset-command.d.ts +19 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +7 -0
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-filter/commit-grep.d.ts +3 -1
- package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -1
- package/dist/commands/rev-list-command.d.ts +78 -3
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/rev-parse-command.d.ts +9 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +32 -1
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +7 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +12 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +120 -1
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +10 -1
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +23 -1
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/session-id.d.ts +18 -0
- package/dist/commands/session-id.d.ts.map +1 -0
- package/dist/commands/shortlog-command.d.ts +109 -0
- package/dist/commands/shortlog-command.d.ts.map +1 -0
- package/dist/commands/shortlog.d.ts +151 -0
- package/dist/commands/shortlog.d.ts.map +1 -0
- package/dist/commands/show-branch-command.d.ts +59 -0
- package/dist/commands/show-branch-command.d.ts.map +1 -0
- package/dist/commands/show-ref-command.d.ts +112 -0
- package/dist/commands/show-ref-command.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +9 -2
- package/dist/commands/signature-check.d.ts.map +1 -1
- package/dist/commands/signing.d.ts +22 -1
- package/dist/commands/signing.d.ts.map +1 -1
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-export-command.d.ts +115 -0
- package/dist/commands/stash-export-command.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +33 -3
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/stripspace-command.d.ts +44 -0
- package/dist/commands/stripspace-command.d.ts.map +1 -0
- package/dist/commands/submodule-add-command.d.ts +10 -1
- package/dist/commands/submodule-add-command.d.ts.map +1 -1
- package/dist/commands/submodule-auth.d.ts +3 -1
- package/dist/commands/submodule-auth.d.ts.map +1 -1
- package/dist/commands/submodule-commands.d.ts +99 -3
- package/dist/commands/submodule-commands.d.ts.map +1 -1
- package/dist/commands/submodule-fetch.d.ts +149 -0
- package/dist/commands/submodule-fetch.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +8 -0
- package/dist/commands/submodule-model.d.ts.map +1 -1
- package/dist/commands/submodule-unpack.d.ts +120 -0
- package/dist/commands/submodule-unpack.d.ts.map +1 -0
- package/dist/commands/submodule-update-command.d.ts +21 -1
- package/dist/commands/submodule-update-command.d.ts.map +1 -1
- package/dist/commands/subtree-shift.d.ts +27 -0
- package/dist/commands/subtree-shift.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts +3 -0
- package/dist/commands/switch-command.d.ts.map +1 -1
- package/dist/commands/textconv-cache.d.ts +58 -0
- package/dist/commands/textconv-cache.d.ts.map +1 -0
- package/dist/commands/tree-restore.d.ts +5 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/unpack-objects-command.d.ts +47 -0
- package/dist/commands/unpack-objects-command.d.ts.map +1 -0
- package/dist/commands/update-index-command.d.ts +110 -0
- package/dist/commands/update-index-command.d.ts.map +1 -0
- package/dist/commands/uri-protocols.d.ts +13 -0
- package/dist/commands/uri-protocols.d.ts.map +1 -0
- package/dist/commands/url-parse-command.d.ts +30 -0
- package/dist/commands/url-parse-command.d.ts.map +1 -0
- package/dist/commands/var-command.d.ts +42 -0
- package/dist/commands/var-command.d.ts.map +1 -0
- package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/{commands-ISM52N0n.js → commands-Mlo1dxQN.js} +56133 -70269
- package/dist/errors/command-errors.d.ts +58 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +67 -1
- package/dist/fsck-CrhVMNIH.js +5179 -0
- package/dist/git-command.d.ts +89 -3
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +628 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +84 -0
- package/dist/guarded-transport-command.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/maintenance-run-command-Bw21HEkH.js +13539 -0
- package/dist/remote-transport-Bu4PGSMD.js +2605 -0
- package/dist/rename/detect-renames.d.ts +20 -0
- package/dist/rename/detect-renames.d.ts.map +1 -1
- package/dist/rename/diffcore-break.d.ts +51 -0
- package/dist/rename/diffcore-break.d.ts.map +1 -0
- package/dist/rename/index.d.ts +1 -0
- package/dist/rename/index.d.ts.map +1 -1
- package/dist/results/blame-format.d.ts +62 -1
- package/dist/results/blame-format.d.ts.map +1 -1
- package/dist/results/cherry-pick-result.d.ts +6 -0
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +9 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/diff-dirstat.d.ts +36 -0
- package/dist/results/diff-dirstat.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +20 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +67 -3
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/fetch-result.d.ts +24 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +2 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/init-result.d.ts +8 -1
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/line-range-hunks.d.ts +27 -0
- package/dist/results/line-range-hunks.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +13 -1
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +11 -0
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +10 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +7 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +6 -0
- package/dist/results/revert-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +5 -0
- package/dist/results/stash-result.d.ts.map +1 -1
- package/dist/results/status-result.d.ts +1 -1
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-ERo9vELd.js +49673 -0
- package/dist/transport-command.d.ts +93 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/commands/add-command.ts +118 -0
- package/src/commands/add-patch/add-patch.ts +8 -0
- package/src/commands/add-patch/patch-backend.ts +24 -3
- package/src/commands/add-patch/patch-modes.ts +26 -2
- package/src/commands/add-patch/patch-session.ts +6 -0
- package/src/commands/am/am-command.ts +301 -12
- package/src/commands/apply/apply-command.ts +52 -9
- package/src/commands/apply/apply-parse.ts +10 -0
- package/src/commands/apply/index.ts +9 -1
- package/src/commands/archive/archive-command.ts +1148 -0
- package/src/commands/archive/archive-entry.ts +93 -0
- package/src/commands/archive/index.ts +7 -0
- package/src/commands/archive/remote-archive-command.ts +140 -0
- package/src/commands/archive/tar-archive.ts +207 -0
- package/src/commands/archive/tar-commit-id.ts +72 -0
- package/src/commands/archive/upload-archive-writer.ts +213 -0
- package/src/commands/archive/zip-archive.ts +317 -0
- package/src/commands/attributes-source.ts +26 -12
- package/src/commands/blame-command.ts +1551 -53
- package/src/commands/blame-ignore.ts +307 -0
- package/src/commands/bundle/bundle-create-command.ts +405 -0
- package/src/commands/bundle/bundle-format.ts +228 -0
- package/src/commands/bundle/bundle-list.ts +276 -0
- package/src/commands/bundle/bundle-read-commands.ts +157 -0
- package/src/commands/bundle/bundle-support.ts +85 -0
- package/src/commands/bundle/bundle-transport.ts +107 -0
- package/src/commands/bundle/bundle-uri-host.ts +204 -0
- package/src/commands/bundle/bundle-uri.ts +236 -0
- package/src/commands/bundle/bundle-verify.ts +152 -0
- package/src/commands/bundle/index.ts +14 -0
- package/src/commands/cat-file/batch-format.ts +193 -0
- package/src/commands/cat-file/cat-file-command.ts +857 -0
- package/src/commands/cat-file/index.ts +2 -0
- package/src/commands/check-attr-command.ts +333 -0
- package/src/commands/check-ignore-command.ts +261 -0
- package/src/commands/check-mailmap-command.ts +129 -0
- package/src/commands/check-ref-format-command.ts +129 -0
- package/src/commands/checkout-command.ts +131 -28
- package/src/commands/checkout-index-command.ts +568 -0
- package/src/commands/checkout-paths.ts +35 -0
- package/src/commands/cherry-command.ts +187 -0
- package/src/commands/cherry-pick-command.ts +63 -2
- package/src/commands/clean-command.ts +92 -12
- package/src/commands/clean-interactive.ts +522 -0
- package/src/commands/clone-command.ts +803 -50
- package/src/commands/commit-command.ts +202 -51
- package/src/commands/config-command.ts +9 -0
- package/src/commands/daemon-access-hook.ts +78 -0
- package/src/commands/default-branch.ts +99 -1
- package/src/commands/describe-command.ts +341 -254
- package/src/commands/diff-command.ts +1186 -99
- package/src/commands/diff-external.ts +131 -0
- package/src/commands/diff-plumbing/diff-pairs-command.ts +193 -0
- package/src/commands/diff-plumbing/diff-plumbing-command.ts +424 -0
- package/src/commands/diff-plumbing/index.ts +2 -0
- package/src/commands/diff-textconv.ts +5 -1
- package/src/commands/fast-export/fast-export-command.ts +911 -0
- package/src/commands/fast-export/fast-import-command.ts +1553 -0
- package/src/commands/fast-export/fast-stream-support.ts +162 -0
- package/src/commands/fast-export/index.ts +3 -0
- package/src/commands/fetch-command.ts +665 -14
- package/src/commands/fetch-multiple-command.ts +668 -0
- package/src/commands/format-patch-command.ts +189 -77
- package/src/commands/format-rev-command.ts +251 -0
- package/src/commands/fsck/fsck-command.ts +47 -20
- package/src/commands/fsck/fsck-msg-ids.ts +19 -3
- package/src/commands/fsck/fsck-pack.ts +2 -2
- package/src/commands/fsmonitor-refresh.ts +315 -0
- package/src/commands/gc-command.ts +10 -0
- package/src/commands/git-describe.ts +456 -217
- package/src/commands/git-hooks.ts +165 -9
- package/src/commands/git-paths.ts +136 -0
- package/src/commands/grep/grep-command.ts +38 -15
- package/src/commands/history-command.ts +617 -0
- package/src/commands/http-config.ts +139 -0
- package/src/commands/index-adder.ts +37 -3
- package/src/commands/index-host.ts +6 -1
- package/src/commands/index.ts +62 -0
- package/src/commands/init-command.ts +617 -49
- package/src/commands/last-modified-command.ts +804 -0
- package/src/commands/lfs/go-url.ts +370 -0
- package/src/commands/lfs/index.ts +2 -0
- package/src/commands/lfs/lfs-config.ts +738 -0
- package/src/commands/lfs/lfs-endpoint-command.ts +180 -0
- package/src/commands/line-log.ts +931 -0
- package/src/commands/local-transport.ts +252 -4
- package/src/commands/log-command.ts +1518 -182
- package/src/commands/log-graph.ts +6 -3
- package/src/commands/log-output.ts +228 -15
- package/src/commands/ls-files-command.ts +1177 -0
- package/src/commands/ls-remote-command.ts +6 -0
- package/src/commands/ls-tree-command.ts +684 -0
- package/src/commands/mailmap.ts +41 -5
- package/src/commands/maintenance-run-command.ts +949 -0
- package/src/commands/merge-command.ts +351 -47
- package/src/commands/merge-config.ts +23 -1
- package/src/commands/merge-drivers.ts +112 -20
- package/src/commands/merge-strategy-options.ts +224 -0
- package/src/commands/merge-support.ts +130 -26
- package/src/commands/merge-tree-command.ts +786 -0
- package/src/commands/message-cleanup.ts +1 -1
- package/src/commands/mktag-command.ts +149 -0
- package/src/commands/name-rev-command.ts +184 -0
- package/src/commands/name-rev.ts +700 -109
- package/src/commands/object-store/count-objects-command.ts +404 -0
- package/src/commands/object-store/index.ts +4 -0
- package/src/commands/object-store/objects-directory.ts +24 -0
- package/src/commands/object-store/prune-command.ts +129 -0
- package/src/commands/object-store/show-index-command.ts +151 -0
- package/src/commands/octopus-merge.ts +35 -11
- package/src/commands/ort-merge.ts +124 -23
- package/src/commands/ort-recursive.ts +40 -2
- package/src/commands/patch-id-command.ts +65 -0
- package/src/commands/patch-id.ts +327 -0
- package/src/commands/plumbing-command.ts +141 -0
- package/src/commands/plumbing-input.ts +87 -0
- package/src/commands/promisor-remote-reply.ts +276 -0
- package/src/commands/promisor-remote.ts +25 -2
- package/src/commands/pull-command.ts +720 -224
- package/src/commands/push-command.ts +440 -8
- package/src/commands/range-diff/index.ts +3 -0
- package/src/commands/range-diff/linear-assignment.ts +203 -0
- package/src/commands/range-diff/range-diff-command.ts +433 -0
- package/src/commands/range-diff/range-diff.ts +617 -0
- package/src/commands/read-tree-command.ts +74 -3
- package/src/commands/rebase-command.ts +647 -83
- package/src/commands/refs-command.ts +274 -0
- package/src/commands/remerge-diff.ts +241 -0
- package/src/commands/remote-command.ts +98 -10
- package/src/commands/remote-object-info-command.ts +109 -0
- package/src/commands/remote-show-command.ts +836 -0
- package/src/commands/remote-transport.ts +116 -1
- package/src/commands/repack-command.ts +383 -0
- package/src/commands/replace-command.ts +816 -0
- package/src/commands/replay-command.ts +674 -0
- package/src/commands/repo-command.ts +967 -0
- package/src/commands/request-pull-command.ts +356 -0
- package/src/commands/rerere-command.ts +179 -0
- package/src/commands/rerere.ts +925 -0
- package/src/commands/reset-command.ts +78 -3
- package/src/commands/restore-command.ts +15 -0
- package/src/commands/rev-filter/commit-grep.ts +7 -2
- package/src/commands/rev-list-command.ts +196 -11
- package/src/commands/rev-parse-command.ts +62 -4
- package/src/commands/revert-command.ts +62 -2
- package/src/commands/revision-range.ts +10 -3
- package/src/commands/revision-resolver.ts +44 -3
- package/src/commands/sequencer-pick.ts +370 -29
- package/src/commands/sequencer-support.ts +164 -2
- package/src/commands/serve-repository.ts +65 -0
- package/src/commands/session-id.ts +31 -0
- package/src/commands/shortlog-command.ts +354 -0
- package/src/commands/shortlog.ts +361 -0
- package/src/commands/show-branch-command.ts +981 -0
- package/src/commands/show-command.ts +3 -2
- package/src/commands/show-ref-command.ts +439 -0
- package/src/commands/signature-check.ts +37 -5
- package/src/commands/signing.ts +122 -16
- package/src/commands/stash-apply-command.ts +3 -0
- package/src/commands/stash-export-command.ts +397 -0
- package/src/commands/status-command.ts +158 -31
- package/src/commands/status-format.ts +1 -1
- package/src/commands/stripspace-command.ts +118 -0
- package/src/commands/submodule-add-command.ts +22 -1
- package/src/commands/submodule-auth.ts +61 -6
- package/src/commands/submodule-commands.ts +333 -5
- package/src/commands/submodule-fetch.ts +789 -0
- package/src/commands/submodule-model.ts +9 -1
- package/src/commands/submodule-unpack.ts +265 -0
- package/src/commands/submodule-update-command.ts +68 -5
- package/src/commands/subtree-shift.ts +215 -0
- package/src/commands/switch-command.ts +9 -0
- package/src/commands/textconv-cache.ts +143 -0
- package/src/commands/tree-restore.ts +20 -1
- package/src/commands/unpack-objects-command.ts +235 -0
- package/src/commands/update-index-command.ts +1016 -0
- package/src/commands/uri-protocols.ts +13 -0
- package/src/commands/url-parse-command.ts +67 -0
- package/src/commands/var-command.ts +219 -0
- package/src/commands/worktree-overwrite-checks.ts +5 -0
- package/src/errors/command-errors.ts +80 -0
- package/src/git-command.ts +218 -2
- package/src/git.ts +1033 -80
- package/src/guarded-transport-command.ts +176 -0
- package/src/index.ts +1 -0
- package/src/rename/detect-renames.ts +42 -8
- package/src/rename/diffcore-break.ts +166 -0
- package/src/rename/index.ts +1 -0
- package/src/results/blame-format.ts +268 -43
- package/src/results/cherry-pick-result.ts +6 -0
- package/src/results/clone-result.ts +6 -0
- package/src/results/diff-dirstat.ts +117 -0
- package/src/results/diff-entry.ts +24 -0
- package/src/results/diff-formatter.ts +8 -4
- package/src/results/diff-output.ts +239 -8
- package/src/results/diff-pickaxe.ts +1 -1
- package/src/results/fetch-result.ts +24 -1
- package/src/results/index.ts +2 -0
- package/src/results/init-result.ts +10 -1
- package/src/results/line-range-hunks.ts +126 -0
- package/src/results/merge-result.ts +14 -0
- package/src/results/pull-result.ts +7 -0
- package/src/results/push-result.ts +10 -0
- package/src/results/rebase-result.ts +7 -0
- package/src/results/revert-result.ts +6 -0
- package/src/results/stash-result.ts +6 -0
- package/src/results/status-result.ts +2 -2
- package/src/transport-command.ts +216 -4
- package/dist/fsck-DLRpbwTj.js +0 -13405
- package/dist/results-TB2IJ64h.js +0 -4700
package/src/commands/name-rev.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* git name-rev (builtin/name-rev.c): every commit named after the ref it is reached from,
|
|
3
|
+
* nearest first, as `<ref>~<n>` or `<ref>~<n>^<p>~<m>`, a tagged commit itself as
|
|
4
|
+
* `<tag>^0`. `git describe --contains` runs it as `name-rev --peel-tag --name-only
|
|
5
|
+
* --no-undefined --tags`.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
|
-
* const
|
|
9
|
+
* const run = await runNameRev(source, { tags: true, nameOnly: true }, { revs });
|
|
10
|
+
* run.stdout; // "v2.0~3\n"
|
|
10
11
|
* ```
|
|
11
12
|
*
|
|
12
13
|
* @module
|
|
@@ -14,158 +15,748 @@
|
|
|
14
15
|
|
|
15
16
|
import type { ObjectId, PersonIdent } from "@statewalker/vcs-core";
|
|
16
17
|
|
|
17
|
-
/**
|
|
18
|
+
/** An object's type as git's `parse_object` finds it. */
|
|
19
|
+
export type NameRevObjectType = "commit" | "tree" | "blob" | "tag";
|
|
20
|
+
|
|
21
|
+
/** A commit as name-rev reads it (from the commit-graph where it has it). */
|
|
22
|
+
export interface NameRevCommit {
|
|
23
|
+
parents: ObjectId[];
|
|
24
|
+
/** Committer date */
|
|
25
|
+
date: number;
|
|
26
|
+
/** The commit-graph's generation; Infinity outside the graph */
|
|
27
|
+
generation: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** What {@link runNameRev} reads. */
|
|
18
31
|
export interface NameRevSource {
|
|
19
32
|
refs: {
|
|
20
33
|
list(prefix?: string): AsyncIterable<{ name: string; objectId?: ObjectId; target?: string }>;
|
|
21
34
|
resolve(name: string): Promise<{ objectId?: ObjectId } | undefined>;
|
|
22
35
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
/** The type of an object, undefined when the repository lacks it */
|
|
37
|
+
objectType(id: ObjectId): Promise<NameRevObjectType | undefined>;
|
|
38
|
+
/** An annotated tag's target and tagger */
|
|
39
|
+
loadTag(id: ObjectId): Promise<{ object: ObjectId; tagger?: PersonIdent } | undefined>;
|
|
40
|
+
/** A commit's parents, date and generation, undefined when it cannot be read */
|
|
41
|
+
loadCommit(id: ObjectId): Promise<NameRevCommit | undefined>;
|
|
42
|
+
/** Whether a full ref name (or `HEAD`) exists, for `refs_shorten_unambiguous_ref` */
|
|
43
|
+
refExists(name: string): Promise<boolean>;
|
|
44
|
+
/** `id` abbreviated as `find_unique_abbrev(oid, DEFAULT_ABBREV)` */
|
|
45
|
+
abbreviate(id: ObjectId): Promise<string>;
|
|
46
|
+
/** git's wildmatch without flags (default: a simple glob) */
|
|
47
|
+
wildmatch?: (pattern: string, text: string) => boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** name-rev's options. */
|
|
51
|
+
export interface NameRevOptions {
|
|
52
|
+
/** `--name-only`: no object names before the names */
|
|
53
|
+
nameOnly?: boolean;
|
|
54
|
+
/** `--tags`: only tags name commits */
|
|
55
|
+
tags?: boolean;
|
|
56
|
+
/** `--refs=<pattern>`: only refs matching one of these (or a subpath of them) */
|
|
57
|
+
refs?: readonly string[];
|
|
58
|
+
/** `--exclude=<pattern>`: no refs matching one of these */
|
|
59
|
+
exclude?: readonly string[];
|
|
60
|
+
/** `--no-undefined` (false): die instead of printing `undefined` (default true) */
|
|
61
|
+
allowUndefined?: boolean;
|
|
62
|
+
/** `--always`: the abbreviated id of an object no ref names */
|
|
63
|
+
always?: boolean;
|
|
64
|
+
/** `--peel-tag` (internal): a tag given is named by the commit it peels to */
|
|
65
|
+
peelTag?: boolean;
|
|
66
|
+
/** The length of the repository's hex ids `--annotate-stdin` looks for (default 40) */
|
|
67
|
+
hexLength?: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** What name-rev names: revisions given, every commit (`--all`) or stdin's text. */
|
|
71
|
+
export type NameRevInput =
|
|
72
|
+
| {
|
|
73
|
+
/** The revisions as given and the object each names (undefined: none) */
|
|
74
|
+
revs: readonly { name: string; id: ObjectId | undefined }[];
|
|
75
|
+
}
|
|
76
|
+
| { all: true }
|
|
77
|
+
| { annotate: string };
|
|
78
|
+
|
|
79
|
+
/** name-rev's outcome: stdout, stderr lines and, where git dies, its message. */
|
|
80
|
+
export interface NameRevRun {
|
|
81
|
+
stdout: string;
|
|
82
|
+
stderr: string[];
|
|
83
|
+
/** The `fatal:` line git dies with (after printing {@link stdout}) */
|
|
84
|
+
fatal?: string;
|
|
30
85
|
}
|
|
31
86
|
|
|
32
87
|
/** name-rev.c's CUTOFF_DATE_SLOP: one day. */
|
|
33
88
|
const CUTOFF_DATE_SLOP = 86400;
|
|
34
89
|
/** name-rev.c's MERGE_TRAVERSAL_WEIGHT. */
|
|
35
90
|
const MERGE_TRAVERSAL_WEIGHT = 65535;
|
|
91
|
+
const TIME_MAX = Number.MAX_SAFE_INTEGER;
|
|
92
|
+
const INFINITY = Number.POSITIVE_INFINITY;
|
|
36
93
|
|
|
37
94
|
interface RevName {
|
|
38
95
|
tipName: string;
|
|
39
96
|
taggerdate: number;
|
|
40
97
|
generation: number;
|
|
41
98
|
distance: number;
|
|
99
|
+
fromTag: boolean;
|
|
42
100
|
}
|
|
43
101
|
|
|
44
102
|
interface Tip {
|
|
45
|
-
|
|
46
|
-
|
|
103
|
+
oid: ObjectId;
|
|
104
|
+
refname: string;
|
|
105
|
+
commit: ObjectId | undefined;
|
|
47
106
|
taggerdate: number;
|
|
107
|
+
fromTag: boolean;
|
|
48
108
|
deref: boolean;
|
|
49
109
|
}
|
|
50
110
|
|
|
51
111
|
const effectiveDistance = (distance: number, generation: number) =>
|
|
52
112
|
distance + (generation > 0 ? MERGE_TRAVERSAL_WEIGHT : 0);
|
|
53
113
|
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
114
|
+
/** name-rev.c's is_better_name. */
|
|
115
|
+
function isBetterName(
|
|
116
|
+
name: RevName,
|
|
117
|
+
taggerdate: number,
|
|
118
|
+
generation: number,
|
|
119
|
+
distance: number,
|
|
120
|
+
fromTag: boolean,
|
|
121
|
+
): boolean {
|
|
122
|
+
const nameDistance = effectiveDistance(name.distance, name.generation);
|
|
123
|
+
const newDistance = effectiveDistance(distance, generation);
|
|
124
|
+
// both tags: the nearer
|
|
125
|
+
if (fromTag && name.fromTag) return nameDistance > newDistance;
|
|
126
|
+
// a tag over a non-tag
|
|
127
|
+
if (name.fromTag !== fromTag) return fromTag;
|
|
128
|
+
// two non-tags: shorter hops, then the older date
|
|
129
|
+
if (nameDistance !== newDistance) return nameDistance > newDistance;
|
|
130
|
+
if (name.taggerdate !== taggerdate) return name.taggerdate > taggerdate;
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** A simple wildmatch: `*` (any run, `/` too), `?`, `[...]` classes. */
|
|
135
|
+
function globMatch(pattern: string, text: string): boolean {
|
|
136
|
+
let re = "";
|
|
137
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
138
|
+
const c = pattern[i] as string;
|
|
139
|
+
if (c === "*") re += ".*";
|
|
140
|
+
else if (c === "?") re += ".";
|
|
141
|
+
else if (c === "[") {
|
|
142
|
+
const end = pattern.indexOf("]", i + 2);
|
|
143
|
+
if (end < 0) re += "\\[";
|
|
144
|
+
else {
|
|
145
|
+
let cls = pattern.slice(i + 1, end);
|
|
146
|
+
if (cls.startsWith("!")) cls = `^${cls.slice(1)}`;
|
|
147
|
+
re += `[${cls.replace(/\\/g, "\\\\")}]`;
|
|
148
|
+
i = end;
|
|
149
|
+
}
|
|
150
|
+
} else re += c.replace(/[.+^${}()|\\/]/g, "\\$&");
|
|
151
|
+
}
|
|
152
|
+
return new RegExp(`^${re}$`, "s").test(text);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** The ref name rules `refs_shorten_unambiguous_ref` walks (ref_rev_parse_rules). */
|
|
156
|
+
const RULES = [
|
|
157
|
+
"%s",
|
|
158
|
+
"refs/%s",
|
|
159
|
+
"refs/tags/%s",
|
|
160
|
+
"refs/heads/%s",
|
|
161
|
+
"refs/remotes/%s",
|
|
162
|
+
"refs/remotes/%s/HEAD",
|
|
163
|
+
];
|
|
164
|
+
|
|
165
|
+
/** refs.c's `refs_shorten_unambiguous_ref(ref, strict = 0)`. */
|
|
166
|
+
async function shortenUnambiguous(
|
|
167
|
+
ref: string,
|
|
168
|
+
exists: (name: string) => Promise<boolean>,
|
|
169
|
+
): Promise<string> {
|
|
170
|
+
for (let i = RULES.length - 1; i > 0; i--) {
|
|
171
|
+
const [prefix, suffix] = (RULES[i] as string).split("%s") as [string, string];
|
|
172
|
+
if (ref.length <= prefix.length + suffix.length) continue;
|
|
173
|
+
if (!ref.startsWith(prefix) || !ref.endsWith(suffix)) continue;
|
|
174
|
+
const short = ref.slice(prefix.length, ref.length - suffix.length);
|
|
175
|
+
let ambiguous = false;
|
|
176
|
+
for (let j = 0; j < i && !ambiguous; j++) {
|
|
177
|
+
if (await exists((RULES[j] as string).replace("%s", short))) ambiguous = true;
|
|
178
|
+
}
|
|
179
|
+
if (!ambiguous) return short;
|
|
180
|
+
}
|
|
181
|
+
return ref;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const take2 = (hex: string, ofs: number) => Number.parseInt(hex.slice(ofs * 2, ofs * 2 + 4), 16);
|
|
185
|
+
|
|
186
|
+
/** hash-lookup.c's `oid_pos` over ids sorted in byte order: an index of `id`, else -1. */
|
|
187
|
+
function oidPos(id: ObjectId, table: readonly ObjectId[]): number {
|
|
188
|
+
const nr = table.length;
|
|
189
|
+
if (nr === 0) return -1;
|
|
190
|
+
let lo = 0;
|
|
191
|
+
let hi = nr;
|
|
192
|
+
let mi = 0;
|
|
193
|
+
if (nr !== 1) {
|
|
194
|
+
const rawsz = id.length / 2;
|
|
195
|
+
for (let ofs = 0; ofs < rawsz - 2; ofs += 2) {
|
|
196
|
+
const lov = take2(table[0] as string, ofs);
|
|
197
|
+
const hiv = take2(table[nr - 1] as string, ofs);
|
|
198
|
+
const miv = take2(id, ofs);
|
|
199
|
+
if (miv < lov) return -1;
|
|
200
|
+
if (hiv < miv) return -1;
|
|
201
|
+
if (lov !== hiv) {
|
|
202
|
+
mi = Math.floor(((nr - 1) * (miv - lov)) / (hiv - lov));
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
do {
|
|
208
|
+
const other = table[mi] as string;
|
|
209
|
+
if (other === id) return mi;
|
|
210
|
+
if (other > id) hi = mi;
|
|
211
|
+
else lo = mi + 1;
|
|
212
|
+
mi = lo + Math.floor((hi - lo) / 2);
|
|
213
|
+
} while (lo < hi);
|
|
214
|
+
return -1;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** The parse state of objects, as git's object hash table holds them (for `--all`). */
|
|
218
|
+
class ObjectTable {
|
|
219
|
+
readonly types = new Map<ObjectId, NameRevObjectType | undefined>();
|
|
220
|
+
private slots: (ObjectId | undefined)[] = [];
|
|
221
|
+
|
|
222
|
+
add(id: ObjectId, type: NameRevObjectType | undefined): void {
|
|
223
|
+
if (this.types.has(id)) {
|
|
224
|
+
if (type && !this.types.get(id)) this.types.set(id, type);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
// object.c's create_object: grow (rehashing in slot order), then probe linearly
|
|
228
|
+
if (this.slots.length - 1 <= this.types.size * 2) {
|
|
229
|
+
const old = this.slots;
|
|
230
|
+
this.slots = new Array(old.length < 32 ? 32 : old.length * 2);
|
|
231
|
+
for (const o of old) if (o !== undefined) this.insert(o);
|
|
232
|
+
}
|
|
233
|
+
this.insert(id);
|
|
234
|
+
this.types.set(id, type);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
private insert(id: ObjectId): void {
|
|
238
|
+
const hash =
|
|
239
|
+
(Number.parseInt(id.slice(0, 2), 16) |
|
|
240
|
+
(Number.parseInt(id.slice(2, 4), 16) << 8) |
|
|
241
|
+
(Number.parseInt(id.slice(4, 6), 16) << 16) |
|
|
242
|
+
(Number.parseInt(id.slice(6, 8), 16) << 24)) >>>
|
|
243
|
+
0;
|
|
244
|
+
const size = this.slots.length;
|
|
245
|
+
let j = hash & (size - 1);
|
|
246
|
+
while (this.slots[j] !== undefined) {
|
|
247
|
+
j++;
|
|
248
|
+
if (j >= size) j = 0;
|
|
249
|
+
}
|
|
250
|
+
this.slots[j] = id;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** The objects in table order (`get_indexed_object`). */
|
|
254
|
+
ordered(): ObjectId[] {
|
|
255
|
+
return this.slots.filter((s): s is ObjectId => s !== undefined);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** One name-rev run: the tips, the names they spread, and the output. */
|
|
260
|
+
class NameRevEngine {
|
|
261
|
+
private readonly match: (pattern: string, text: string) => boolean;
|
|
262
|
+
private readonly commits = new Map<ObjectId, NameRevCommit | null>();
|
|
263
|
+
private readonly parsed = new Set<ObjectId>();
|
|
264
|
+
private readonly names = new Map<ObjectId, RevName>();
|
|
265
|
+
private readonly tips: Tip[] = [];
|
|
266
|
+
private sortedTips?: Tip[];
|
|
267
|
+
readonly objects = new ObjectTable();
|
|
268
|
+
cutoff = TIME_MAX;
|
|
269
|
+
generationCutoff = INFINITY;
|
|
270
|
+
|
|
271
|
+
constructor(
|
|
272
|
+
private readonly source: NameRevSource,
|
|
273
|
+
private readonly options: NameRevOptions,
|
|
274
|
+
) {
|
|
275
|
+
this.match = source.wildmatch ?? globMatch;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async commit(id: ObjectId): Promise<NameRevCommit | undefined> {
|
|
279
|
+
let c = this.commits.get(id);
|
|
67
280
|
if (c === undefined) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
281
|
+
c = (await this.source.loadCommit(id).catch(() => undefined)) ?? null;
|
|
282
|
+
this.commits.set(id, c);
|
|
283
|
+
}
|
|
284
|
+
return c ?? undefined;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** `parse_object`: the object's type, recording it (and a commit's parents) as created. */
|
|
288
|
+
async parseObject(id: ObjectId): Promise<NameRevObjectType | undefined> {
|
|
289
|
+
const known = this.objects.types.get(id);
|
|
290
|
+
const type = known ?? (await this.source.objectType(id).catch(() => undefined));
|
|
291
|
+
if (type === undefined) return undefined;
|
|
292
|
+
this.objects.add(id, type);
|
|
293
|
+
if (type === "commit") await this.parseCommit(id);
|
|
294
|
+
return type;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** `repo_parse_commit`: the parents become (unparsed) commit objects. */
|
|
298
|
+
async parseCommit(id: ObjectId): Promise<NameRevCommit | undefined> {
|
|
299
|
+
const c = await this.commit(id);
|
|
300
|
+
if (!this.parsed.has(id)) {
|
|
301
|
+
this.parsed.add(id);
|
|
302
|
+
this.objects.add(id, "commit");
|
|
303
|
+
for (const p of c?.parents ?? []) this.objects.add(p, "commit");
|
|
71
304
|
}
|
|
72
305
|
return c;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** set_commit_cutoff. */
|
|
309
|
+
async setCommitCutoff(id: ObjectId): Promise<void> {
|
|
310
|
+
const c = await this.commit(id);
|
|
311
|
+
if (!c) return;
|
|
312
|
+
if (this.cutoff > c.date) this.cutoff = c.date;
|
|
313
|
+
if (this.generationCutoff && this.generationCutoff > c.generation) {
|
|
314
|
+
this.generationCutoff = c.generation;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
disableCutoff(): void {
|
|
319
|
+
this.generationCutoff = 0;
|
|
320
|
+
this.cutoff = 0;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
adjustCutoffForSlop(): void {
|
|
324
|
+
if (this.cutoff) {
|
|
325
|
+
this.cutoff = this.cutoff > CUTOFF_DATE_SLOP ? this.cutoff - CUTOFF_DATE_SLOP : 0;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
private beforeCutoff(c: NameRevCommit): boolean {
|
|
330
|
+
if (this.generationCutoff < INFINITY) {
|
|
331
|
+
return !!this.generationCutoff && c.generation < this.generationCutoff;
|
|
332
|
+
}
|
|
333
|
+
return c.date < this.cutoff;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** name_ref over every ref (refs_for_each_ref order), then name_tips. */
|
|
337
|
+
async nameRefs(): Promise<void> {
|
|
338
|
+
const refs: { name: string; objectId?: ObjectId; target?: string }[] = [];
|
|
339
|
+
for await (const ref of this.source.refs.list("refs/")) {
|
|
340
|
+
if (ref.name.startsWith("refs/")) refs.push(ref);
|
|
341
|
+
}
|
|
342
|
+
refs.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
343
|
+
for (const ref of refs) {
|
|
344
|
+
const oid =
|
|
345
|
+
ref.objectId && ref.target === undefined
|
|
346
|
+
? ref.objectId
|
|
347
|
+
: (await this.source.refs.resolve(ref.name).catch(() => undefined))?.objectId;
|
|
348
|
+
if (!oid) continue;
|
|
349
|
+
await this.nameRef(ref.name, oid);
|
|
350
|
+
}
|
|
351
|
+
await this.nameTips();
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
private subpathMatches(path: string, filter: string): number {
|
|
355
|
+
let subpath: number | undefined = 0;
|
|
356
|
+
while (subpath !== undefined) {
|
|
357
|
+
if (this.match(filter, path.slice(subpath))) return subpath;
|
|
358
|
+
const slash = path.indexOf("/", subpath);
|
|
359
|
+
subpath = slash < 0 ? undefined : slash + 1;
|
|
360
|
+
}
|
|
361
|
+
return -1;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
private async nameRef(refname: string, oid: ObjectId): Promise<void> {
|
|
365
|
+
let type = await this.parseObject(oid);
|
|
366
|
+
const { options } = this;
|
|
367
|
+
let canAbbreviate = !!options.tags && !!options.nameOnly;
|
|
368
|
+
if (options.tags && !refname.startsWith("refs/tags/")) return;
|
|
369
|
+
for (const filter of options.exclude ?? []) {
|
|
370
|
+
if (this.subpathMatches(refname, filter) >= 0) return;
|
|
371
|
+
}
|
|
372
|
+
if (options.refs?.length) {
|
|
373
|
+
let matched = false;
|
|
374
|
+
for (const filter of options.refs) {
|
|
375
|
+
const at = this.subpathMatches(refname, filter);
|
|
376
|
+
if (at === 0) matched = true;
|
|
377
|
+
else if (at > 0) {
|
|
378
|
+
matched = true;
|
|
379
|
+
canAbbreviate = true;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (!matched) return;
|
|
383
|
+
}
|
|
384
|
+
let o: ObjectId | undefined = oid;
|
|
90
385
|
let deref = false;
|
|
91
|
-
let taggerdate
|
|
92
|
-
for (let depth = 0;
|
|
93
|
-
const tag = await source
|
|
386
|
+
let taggerdate = TIME_MAX;
|
|
387
|
+
for (let depth = 0; type === "tag" && depth < 64; depth++) {
|
|
388
|
+
const tag: { object: ObjectId; tagger?: PersonIdent } | undefined = await this.source
|
|
389
|
+
.loadTag(o as ObjectId)
|
|
390
|
+
.catch(() => undefined);
|
|
94
391
|
if (!tag) break;
|
|
95
|
-
oid = tag.object;
|
|
96
392
|
deref = true;
|
|
97
393
|
taggerdate = tag.tagger?.timestamp ?? 0;
|
|
394
|
+
const next: ObjectId = tag.object;
|
|
395
|
+
o = next;
|
|
396
|
+
type = await this.parseObject(next);
|
|
397
|
+
if (type === undefined) o = undefined;
|
|
398
|
+
}
|
|
399
|
+
let commit: ObjectId | undefined;
|
|
400
|
+
let fromTag = false;
|
|
401
|
+
if (o !== undefined && type === "commit") {
|
|
402
|
+
commit = o;
|
|
403
|
+
fromTag = refname.startsWith("refs/tags/");
|
|
404
|
+
if (taggerdate === TIME_MAX) taggerdate = (await this.commit(o))?.date ?? 0;
|
|
405
|
+
}
|
|
406
|
+
let short: string;
|
|
407
|
+
if (canAbbreviate) short = await shortenUnambiguous(refname, this.source.refExists);
|
|
408
|
+
else if (refname.startsWith("refs/heads/")) short = refname.slice("refs/heads/".length);
|
|
409
|
+
else short = refname.slice("refs/".length);
|
|
410
|
+
this.tips.push({ oid, refname: short, commit, taggerdate, fromTag, deref });
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/** name_tips: better tips first (tags, then older), so worse names spread less. */
|
|
414
|
+
private async nameTips(): Promise<void> {
|
|
415
|
+
// QSORT (glibc's stable merge sort): ties keep the refs' order
|
|
416
|
+
const order = this.tips
|
|
417
|
+
.map((t, i) => ({ t, i }))
|
|
418
|
+
.sort((a, b) => {
|
|
419
|
+
const byTag = (b.t.fromTag ? 1 : 0) - (a.t.fromTag ? 1 : 0);
|
|
420
|
+
if (byTag) return byTag;
|
|
421
|
+
if (a.t.taggerdate !== b.t.taggerdate) return a.t.taggerdate < b.t.taggerdate ? -1 : 1;
|
|
422
|
+
return a.i - b.i;
|
|
423
|
+
})
|
|
424
|
+
.map((e) => e.t);
|
|
425
|
+
this.tips.splice(0, this.tips.length, ...order);
|
|
426
|
+
for (const tip of this.tips) {
|
|
427
|
+
if (tip.commit) await this.nameRev(tip.commit, tip.refname, tip.taggerdate, tip);
|
|
98
428
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
commit: oid,
|
|
104
|
-
taggerdate: taggerdate ?? commit.date,
|
|
105
|
-
deref,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
// cmp_by_tag_and_age: older first (every tip is a tag)
|
|
109
|
-
tips.sort((a, b) => a.taggerdate - b.taggerdate);
|
|
110
|
-
|
|
111
|
-
const names = new Map<ObjectId, RevName>();
|
|
112
|
-
const createOrUpdate = (
|
|
113
|
-
oid: ObjectId,
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
private createOrUpdate(
|
|
432
|
+
id: ObjectId,
|
|
114
433
|
taggerdate: number,
|
|
115
434
|
generation: number,
|
|
116
435
|
distance: number,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (
|
|
121
|
-
known &&
|
|
122
|
-
!(
|
|
123
|
-
effectiveDistance(known.distance, known.generation) >
|
|
124
|
-
effectiveDistance(distance, generation)
|
|
125
|
-
)
|
|
126
|
-
) {
|
|
436
|
+
fromTag: boolean,
|
|
437
|
+
): RevName | undefined {
|
|
438
|
+
const known = this.names.get(id);
|
|
439
|
+
if (known && !isBetterName(known, taggerdate, generation, distance, fromTag)) {
|
|
127
440
|
return undefined;
|
|
128
441
|
}
|
|
129
|
-
const name: RevName =
|
|
130
|
-
|
|
442
|
+
const name: RevName = known ?? {
|
|
443
|
+
tipName: "",
|
|
444
|
+
taggerdate,
|
|
445
|
+
generation,
|
|
446
|
+
distance,
|
|
447
|
+
fromTag,
|
|
448
|
+
};
|
|
449
|
+
name.taggerdate = taggerdate;
|
|
450
|
+
name.generation = generation;
|
|
451
|
+
name.distance = distance;
|
|
452
|
+
name.fromTag = fromTag;
|
|
453
|
+
this.names.set(id, name);
|
|
131
454
|
return name;
|
|
132
|
-
}
|
|
455
|
+
}
|
|
133
456
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
457
|
+
/** name_rev: a depth-first walk from one tip, first parents first. */
|
|
458
|
+
private async nameRev(
|
|
459
|
+
start: ObjectId,
|
|
460
|
+
tipName: string,
|
|
461
|
+
taggerdate: number,
|
|
462
|
+
tip: { fromTag: boolean; deref: boolean },
|
|
463
|
+
): Promise<void> {
|
|
464
|
+
const startCommit = await this.parseCommit(start);
|
|
465
|
+
if (!startCommit || this.beforeCutoff(startCommit)) return;
|
|
466
|
+
const startName = this.createOrUpdate(start, taggerdate, 0, 0, tip.fromTag);
|
|
467
|
+
if (!startName) return;
|
|
468
|
+
startName.tipName = tip.deref ? `${tipName}^0` : tipName;
|
|
469
|
+
const stack: ObjectId[] = [start];
|
|
141
470
|
for (let oid = stack.pop(); oid !== undefined; oid = stack.pop()) {
|
|
142
|
-
const name = names.get(oid) as RevName;
|
|
143
|
-
const commit = await
|
|
471
|
+
const name = this.names.get(oid) as RevName;
|
|
472
|
+
const commit = await this.parseCommit(oid);
|
|
144
473
|
const toQueue: ObjectId[] = [];
|
|
145
|
-
let parentNumber =
|
|
474
|
+
let parentNumber = 0;
|
|
146
475
|
for (const parentId of commit?.parents ?? []) {
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
if (!parent || parent
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
476
|
+
parentNumber++;
|
|
477
|
+
const parent = await this.parseCommit(parentId);
|
|
478
|
+
if (!parent || this.beforeCutoff(parent)) continue;
|
|
479
|
+
let generation: number;
|
|
480
|
+
let distance: number;
|
|
481
|
+
if (parentNumber > 1) {
|
|
482
|
+
generation = 0;
|
|
483
|
+
distance = name.distance + MERGE_TRAVERSAL_WEIGHT;
|
|
484
|
+
} else {
|
|
485
|
+
generation = name.generation + 1;
|
|
486
|
+
distance = name.distance + 1;
|
|
487
|
+
}
|
|
488
|
+
// the parent's name may be this commit's own record: read the tip name first
|
|
489
|
+
const parentTip =
|
|
490
|
+
parentNumber > 1 ? parentName(name, parentNumber) : (name.tipName as string);
|
|
491
|
+
const updated = this.createOrUpdate(
|
|
492
|
+
parentId,
|
|
493
|
+
taggerdate,
|
|
494
|
+
generation,
|
|
495
|
+
distance,
|
|
496
|
+
tip.fromTag,
|
|
497
|
+
);
|
|
498
|
+
if (updated) {
|
|
499
|
+
updated.tipName = parentTip;
|
|
500
|
+
toQueue.push(parentId);
|
|
501
|
+
}
|
|
160
502
|
}
|
|
161
|
-
// the first parent comes out of the stack first
|
|
162
503
|
for (let i = toQueue.length - 1; i >= 0; i--) stack.push(toQueue[i] as ObjectId);
|
|
163
504
|
}
|
|
164
505
|
}
|
|
165
506
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
507
|
+
/** get_exact_ref_match: the tip whose ref value is `id` (oid_pos over sorted tips). */
|
|
508
|
+
private exactRefMatch(id: ObjectId): string | undefined {
|
|
509
|
+
if (this.tips.length === 0) return undefined;
|
|
510
|
+
if (!this.sortedTips) {
|
|
511
|
+
this.sortedTips = this.tips
|
|
512
|
+
.map((t, i) => ({ t, i }))
|
|
513
|
+
.sort((a, b) => (a.t.oid < b.t.oid ? -1 : a.t.oid > b.t.oid ? 1 : a.i - b.i))
|
|
514
|
+
.map((e) => e.t);
|
|
515
|
+
}
|
|
516
|
+
const found = oidPos(
|
|
517
|
+
id,
|
|
518
|
+
this.sortedTips.map((t) => t.oid),
|
|
519
|
+
);
|
|
520
|
+
return found >= 0 ? this.sortedTips[found]?.refname : undefined;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/** get_rev_name. */
|
|
524
|
+
revName(id: ObjectId, type: NameRevObjectType | undefined): string | undefined {
|
|
525
|
+
if (type !== "commit") return this.exactRefMatch(id);
|
|
526
|
+
const n = this.names.get(id);
|
|
527
|
+
if (!n) return undefined;
|
|
528
|
+
if (!n.generation) return n.tipName;
|
|
529
|
+
const base = n.tipName.endsWith("^0") ? n.tipName.slice(0, -2) : n.tipName;
|
|
530
|
+
return `${base}~${n.generation}`;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/** get_parent_name. */
|
|
535
|
+
function parentName(name: RevName, parentNumber: number): string {
|
|
536
|
+
const base = name.tipName.endsWith("^0") ? name.tipName.slice(0, -2) : name.tipName;
|
|
537
|
+
return name.generation > 0
|
|
538
|
+
? `${base}~${name.generation}^${parentNumber}`
|
|
539
|
+
: `${base}^${parentNumber}`;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
const isHex = (c: string | undefined) =>
|
|
543
|
+
c !== undefined && ((c >= "0" && c <= "9") || (c >= "a" && c <= "f"));
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* `git name-rev [<options>] (<rev>... | --all | --annotate-stdin)`: what git prints, and the
|
|
547
|
+
* line it dies with (`cannot describe '<id>'` under `--no-undefined`).
|
|
548
|
+
*/
|
|
549
|
+
export async function runNameRev(
|
|
550
|
+
source: NameRevSource,
|
|
551
|
+
options: NameRevOptions,
|
|
552
|
+
input: NameRevInput,
|
|
553
|
+
): Promise<NameRevRun> {
|
|
554
|
+
const engine = new NameRevEngine(source, options);
|
|
555
|
+
const stderr: string[] = [];
|
|
556
|
+
const shown: { name: string | undefined; id: ObjectId; type: NameRevObjectType }[] = [];
|
|
557
|
+
if ("revs" in input) {
|
|
558
|
+
for (const rev of input.revs) {
|
|
559
|
+
if (rev.id === undefined) {
|
|
560
|
+
stderr.push(`Could not get sha1 for ${rev.name}. Skipping.`);
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
let type = await engine.parseObject(rev.id);
|
|
564
|
+
if (type === undefined) {
|
|
565
|
+
stderr.push(`Could not get object for ${rev.name}. Skipping.`);
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
568
|
+
// deref_tag
|
|
569
|
+
let peeled: ObjectId | undefined = rev.id;
|
|
570
|
+
for (let depth = 0; type === "tag" && peeled !== undefined && depth < 64; depth++) {
|
|
571
|
+
const tag: { object: ObjectId } | undefined = await source
|
|
572
|
+
.loadTag(peeled)
|
|
573
|
+
.catch(() => undefined);
|
|
574
|
+
peeled = tag?.object;
|
|
575
|
+
type = peeled === undefined ? undefined : await engine.parseObject(peeled);
|
|
576
|
+
}
|
|
577
|
+
const commit = type === "commit" ? peeled : undefined;
|
|
578
|
+
if (commit) await engine.setCommitCutoff(commit);
|
|
579
|
+
if (options.peelTag) {
|
|
580
|
+
if (!commit) {
|
|
581
|
+
stderr.push(`Could not get commit for ${rev.name}. Skipping.`);
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
shown.push({ name: rev.name, id: commit, type: "commit" });
|
|
585
|
+
} else {
|
|
586
|
+
const own = engine.objects.types.get(rev.id) as NameRevObjectType;
|
|
587
|
+
shown.push({ name: rev.name, id: rev.id, type: own });
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
} else engine.disableCutoff();
|
|
591
|
+
engine.adjustCutoffForSlop();
|
|
592
|
+
await engine.nameRefs();
|
|
593
|
+
|
|
594
|
+
let stdout = "";
|
|
595
|
+
if ("annotate" in input) {
|
|
596
|
+
const lines = input.annotate.split("\n");
|
|
597
|
+
if (lines[lines.length - 1] === "") lines.pop();
|
|
598
|
+
for (const raw of lines) {
|
|
599
|
+
const line = `${raw.endsWith("\r") ? raw.slice(0, -1) : raw}\n`;
|
|
600
|
+
stdout += annotateLine(engine, line, options, options.hexLength ?? 40);
|
|
601
|
+
}
|
|
602
|
+
return { stdout, stderr };
|
|
603
|
+
}
|
|
604
|
+
const allowUndefined = options.allowUndefined ?? true;
|
|
605
|
+
const show = async (id: ObjectId, type: NameRevObjectType, caller?: string) => {
|
|
606
|
+
if (!options.nameOnly) stdout += `${caller ?? id} `;
|
|
607
|
+
const name = engine.revName(id, type);
|
|
608
|
+
if (name !== undefined) stdout += `${name}\n`;
|
|
609
|
+
else if (allowUndefined) stdout += "undefined\n";
|
|
610
|
+
else if (options.always) stdout += `${await source.abbreviate(id)}\n`;
|
|
611
|
+
else return `fatal: cannot describe '${id}'`;
|
|
612
|
+
return undefined;
|
|
613
|
+
};
|
|
614
|
+
if ("all" in input) {
|
|
615
|
+
for (const id of engine.objects.ordered()) {
|
|
616
|
+
if (engine.objects.types.get(id) !== "commit") continue;
|
|
617
|
+
const fatal = await show(id, "commit");
|
|
618
|
+
if (fatal) return { stdout, stderr, fatal };
|
|
619
|
+
}
|
|
620
|
+
return { stdout, stderr };
|
|
621
|
+
}
|
|
622
|
+
for (const s of shown) {
|
|
623
|
+
const fatal = await show(s.id, s.type, s.name);
|
|
624
|
+
if (fatal) return { stdout, stderr, fatal };
|
|
625
|
+
}
|
|
626
|
+
return { stdout, stderr };
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/** name_rev_line: each full-length hex id in `line` followed by its name. */
|
|
630
|
+
function annotateLine(
|
|
631
|
+
engine: NameRevEngine,
|
|
632
|
+
line: string,
|
|
633
|
+
options: NameRevOptions,
|
|
634
|
+
hexsz: number,
|
|
635
|
+
): string {
|
|
636
|
+
let out = "";
|
|
637
|
+
let counter = 0;
|
|
638
|
+
let start = 0;
|
|
639
|
+
for (let p = 0; p < line.length; p++) {
|
|
640
|
+
const c = line[p];
|
|
641
|
+
if (!isHex(c)) {
|
|
642
|
+
counter = 0;
|
|
643
|
+
} else if (++counter === hexsz && !isHex(line[p + 1])) {
|
|
644
|
+
counter = 0;
|
|
645
|
+
const id = line.slice(p - (hexsz - 1), p + 1);
|
|
646
|
+
const type = engine.objects.types.get(id);
|
|
647
|
+
const name = type ? engine.revName(id, type) : undefined;
|
|
648
|
+
if (name === undefined) continue;
|
|
649
|
+
if (options.nameOnly) out += line.slice(start, p + 1 - hexsz) + name;
|
|
650
|
+
else out += `${line.slice(start, p + 1)} (${name})`;
|
|
651
|
+
start = p + 1;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
return out + line.slice(start);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/** What {@link nameRevByTags} reads. */
|
|
658
|
+
export type DescribeContainsSource = NameRevSource;
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* `git describe --contains <id>` with default options (`name-rev --peel-tag --name-only
|
|
662
|
+
* --no-undefined --tags`): the name, undefined when no tag contains the commit.
|
|
663
|
+
*/
|
|
664
|
+
export async function nameRevByTags(
|
|
665
|
+
source: NameRevSource,
|
|
666
|
+
id: ObjectId,
|
|
667
|
+
): Promise<string | undefined> {
|
|
668
|
+
const run = await runNameRev(
|
|
669
|
+
source,
|
|
670
|
+
{ peelTag: true, nameOnly: true, allowUndefined: false, tags: true },
|
|
671
|
+
{ revs: [{ name: id, id }] },
|
|
672
|
+
);
|
|
673
|
+
if (run.fatal || run.stdout === "") return undefined;
|
|
674
|
+
return run.stdout.replace(/\n$/, "");
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/** The commit stores {@link commitLoaderOf} reads. */
|
|
678
|
+
export interface NameRevCommitStore {
|
|
679
|
+
load(id: ObjectId): Promise<{ parents: ObjectId[]; committer: PersonIdent } | undefined>;
|
|
680
|
+
headerReader?(): Promise<{
|
|
681
|
+
getHeader(
|
|
682
|
+
id: ObjectId,
|
|
683
|
+
): Promise<{ parents: ObjectId[]; commitTime: number; generation: number } | undefined>;
|
|
684
|
+
}>;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* `loadCommit` over a commit store: from the commit-graph loaded at the first read where it
|
|
689
|
+
* has the commit (its generation), else from the object (generation Infinity). In a shallow
|
|
690
|
+
* repository (`shallow`: its `.git/shallow` commits, given or read on first use) a shallow
|
|
691
|
+
* commit has no parents and no commit-graph is read (git's `commit_graph_compatible`).
|
|
692
|
+
*/
|
|
693
|
+
export function commitLoaderOf(
|
|
694
|
+
commits: NameRevCommitStore,
|
|
695
|
+
shallow?: () => Promise<readonly ObjectId[] | undefined>,
|
|
696
|
+
): (id: ObjectId) => Promise<NameRevCommit | undefined> {
|
|
697
|
+
let cut: Promise<Set<ObjectId>> | undefined;
|
|
698
|
+
const plain = graphLoaderOf(commits);
|
|
699
|
+
const fromObjects = async (id: ObjectId) => {
|
|
700
|
+
const c = await commits.load(id).catch(() => undefined);
|
|
701
|
+
return c
|
|
702
|
+
? { parents: c.parents, date: c.committer.timestamp, generation: INFINITY }
|
|
703
|
+
: undefined;
|
|
704
|
+
};
|
|
705
|
+
return async (id) => {
|
|
706
|
+
cut ??= (shallow?.().catch(() => undefined) ?? Promise.resolve(undefined)).then(
|
|
707
|
+
(ids) => new Set(ids ?? []),
|
|
708
|
+
);
|
|
709
|
+
const boundary = await cut;
|
|
710
|
+
if (boundary.size === 0) return plain(id);
|
|
711
|
+
const c = await fromObjects(id);
|
|
712
|
+
return c && boundary.has(id) ? { ...c, parents: [] } : c;
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/** {@link commitLoaderOf} without shallow commits. */
|
|
717
|
+
function graphLoaderOf(
|
|
718
|
+
commits: NameRevCommitStore,
|
|
719
|
+
): (id: ObjectId) => Promise<NameRevCommit | undefined> {
|
|
720
|
+
let reader:
|
|
721
|
+
| Promise<
|
|
722
|
+
| {
|
|
723
|
+
getHeader(
|
|
724
|
+
id: ObjectId,
|
|
725
|
+
): Promise<{ parents: ObjectId[]; commitTime: number; generation: number } | undefined>;
|
|
726
|
+
}
|
|
727
|
+
| undefined
|
|
728
|
+
>
|
|
729
|
+
| undefined;
|
|
730
|
+
return async (id) => {
|
|
731
|
+
reader ??= commits.headerReader?.().catch(() => undefined) ?? Promise.resolve(undefined);
|
|
732
|
+
const r = await reader;
|
|
733
|
+
if (r) {
|
|
734
|
+
const h = await r.getHeader(id).catch(() => undefined);
|
|
735
|
+
return h ? { parents: h.parents, date: h.commitTime, generation: h.generation } : undefined;
|
|
736
|
+
}
|
|
737
|
+
const c = await commits.load(id).catch(() => undefined);
|
|
738
|
+
return c
|
|
739
|
+
? { parents: c.parents, date: c.committer.timestamp, generation: INFINITY }
|
|
740
|
+
: undefined;
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* A commit store's `load` as a shallow repository's walks read it: the commits of
|
|
746
|
+
* `.git/shallow` without parents (git's shallow grafts), others as stored.
|
|
747
|
+
*/
|
|
748
|
+
export function withShallowParents<C extends { parents: ObjectId[] }>(
|
|
749
|
+
commits: { load(id: ObjectId): Promise<C | undefined> },
|
|
750
|
+
shallow: () => Promise<readonly ObjectId[] | undefined>,
|
|
751
|
+
): { load(id: ObjectId): Promise<C | undefined> } {
|
|
752
|
+
let cut: Promise<Set<ObjectId>> | undefined;
|
|
753
|
+
return {
|
|
754
|
+
load: async (id) => {
|
|
755
|
+
cut ??= shallow()
|
|
756
|
+
.catch(() => undefined)
|
|
757
|
+
.then((ids) => new Set(ids ?? []));
|
|
758
|
+
const c = await commits.load(id);
|
|
759
|
+
return c && (await cut).has(id) ? { ...c, parents: [] } : c;
|
|
760
|
+
},
|
|
761
|
+
};
|
|
171
762
|
}
|