@statewalker/vcs-commands 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commands/add-command.d.ts +32 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/add-patch.d.ts +7 -0
- package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts +2 -0
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-modes.d.ts +6 -2
- package/dist/commands/add-patch/patch-modes.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-session.d.ts +4 -0
- package/dist/commands/add-patch/patch-session.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +88 -2
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-command.d.ts +2 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.d.ts +7 -0
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/apply/index.d.ts +1 -1
- package/dist/commands/apply/index.d.ts.map +1 -1
- package/dist/commands/archive/archive-command.d.ts +169 -0
- package/dist/commands/archive/archive-command.d.ts.map +1 -0
- package/dist/commands/archive/archive-entry.d.ts +60 -0
- package/dist/commands/archive/archive-entry.d.ts.map +1 -0
- package/dist/commands/archive/index.d.ts +8 -0
- package/dist/commands/archive/index.d.ts.map +1 -0
- package/dist/commands/archive/remote-archive-command.d.ts +56 -0
- package/dist/commands/archive/remote-archive-command.d.ts.map +1 -0
- package/dist/commands/archive/tar-archive.d.ts +31 -0
- package/dist/commands/archive/tar-archive.d.ts.map +1 -0
- package/dist/commands/archive/tar-commit-id.d.ts +13 -0
- package/dist/commands/archive/tar-commit-id.d.ts.map +1 -0
- package/dist/commands/archive/upload-archive-writer.d.ts +48 -0
- package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -0
- package/dist/commands/archive/zip-archive.d.ts +42 -0
- package/dist/commands/archive/zip-archive.d.ts.map +1 -0
- package/dist/commands/attributes-source.d.ts +10 -0
- package/dist/commands/attributes-source.d.ts.map +1 -1
- package/dist/commands/blame-command.d.ts +345 -8
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/blame-ignore.d.ts +48 -0
- package/dist/commands/blame-ignore.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-create-command.d.ts +67 -0
- package/dist/commands/bundle/bundle-create-command.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-format.d.ts +89 -0
- package/dist/commands/bundle/bundle-format.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-list.d.ts +92 -0
- package/dist/commands/bundle/bundle-list.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts +81 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-support.d.ts +32 -0
- package/dist/commands/bundle/bundle-support.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-transport.d.ts +38 -0
- package/dist/commands/bundle/bundle-transport.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts +43 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri.d.ts +55 -0
- package/dist/commands/bundle/bundle-uri.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-verify.d.ts +63 -0
- package/dist/commands/bundle/bundle-verify.d.ts.map +1 -0
- package/dist/commands/bundle/index.d.ts +14 -0
- package/dist/commands/bundle/index.d.ts.map +1 -0
- package/dist/commands/cat-file/batch-format.d.ts +58 -0
- package/dist/commands/cat-file/batch-format.d.ts.map +1 -0
- package/dist/commands/cat-file/cat-file-command.d.ts +135 -0
- package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -0
- package/dist/commands/cat-file/index.d.ts +3 -0
- package/dist/commands/cat-file/index.d.ts.map +1 -0
- package/dist/commands/check-attr-command.d.ts +66 -0
- package/dist/commands/check-attr-command.d.ts.map +1 -0
- package/dist/commands/check-ignore-command.d.ts +58 -0
- package/dist/commands/check-ignore-command.d.ts.map +1 -0
- package/dist/commands/check-mailmap-command.d.ts +49 -0
- package/dist/commands/check-mailmap-command.d.ts.map +1 -0
- package/dist/commands/check-ref-format-command.d.ts +60 -0
- package/dist/commands/check-ref-format-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +7 -0
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-index-command.d.ts +96 -0
- package/dist/commands/checkout-index-command.d.ts.map +1 -0
- package/dist/commands/checkout-paths.d.ts +4 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-command.d.ts +61 -0
- package/dist/commands/cherry-command.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +33 -1
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +32 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +56 -0
- package/dist/commands/clean-interactive.d.ts.map +1 -0
- package/dist/commands/clone-command.d.ts +135 -2
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +59 -3
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/config-command.d.ts +2 -0
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/daemon-access-hook.d.ts +36 -0
- package/dist/commands/daemon-access-hook.d.ts.map +1 -0
- package/dist/commands/default-branch.d.ts +42 -0
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/describe-command.d.ts +71 -64
- package/dist/commands/describe-command.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +249 -10
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/diff-external.d.ts +43 -0
- package/dist/commands/diff-external.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts +27 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts +129 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/index.d.ts +3 -0
- package/dist/commands/diff-plumbing/index.d.ts.map +1 -0
- package/dist/commands/diff-textconv.d.ts +5 -1
- package/dist/commands/diff-textconv.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-export-command.d.ts +135 -0
- package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-import-command.d.ts +182 -0
- package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts +64 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -0
- package/dist/commands/fast-export/index.d.ts +4 -0
- package/dist/commands/fast-export/index.d.ts.map +1 -0
- package/dist/commands/fetch-command.d.ts +125 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fetch-multiple-command.d.ts +193 -0
- package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
- package/dist/commands/format-patch-command.d.ts +28 -2
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/format-rev-command.d.ts +58 -0
- package/dist/commands/format-rev-command.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-msg-ids.d.ts +18 -3
- package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -1
- package/dist/commands/fsmonitor-refresh.d.ts +69 -0
- package/dist/commands/fsmonitor-refresh.d.ts.map +1 -0
- package/dist/commands/gc-command.d.ts +5 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +77 -4
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +47 -1
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/git-paths.d.ts +26 -0
- package/dist/commands/git-paths.d.ts.map +1 -0
- package/dist/commands/grep/grep-command.d.ts +2 -1
- package/dist/commands/grep/grep-command.d.ts.map +1 -1
- package/dist/commands/history-command.d.ts +156 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/http-config.d.ts +38 -0
- package/dist/commands/http-config.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +12 -1
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index-host.d.ts.map +1 -1
- package/dist/commands/index.d.ts +56 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +6 -3
- package/dist/commands/init-command.d.ts +89 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/last-modified-command.d.ts +102 -0
- package/dist/commands/last-modified-command.d.ts.map +1 -0
- package/dist/commands/lfs/go-url.d.ts +43 -0
- package/dist/commands/lfs/go-url.d.ts.map +1 -0
- package/dist/commands/lfs/index.d.ts +3 -0
- package/dist/commands/lfs/index.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-config.d.ts +174 -0
- package/dist/commands/lfs/lfs-config.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-endpoint-command.d.ts +83 -0
- package/dist/commands/lfs/lfs-endpoint-command.d.ts.map +1 -0
- package/dist/commands/line-log.d.ts +161 -0
- package/dist/commands/line-log.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +261 -6
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +4 -2
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +88 -2
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-files-command.d.ts +153 -0
- package/dist/commands/ls-files-command.d.ts.map +1 -0
- package/dist/commands/ls-remote-command.d.ts +5 -0
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/ls-tree-command.d.ts +105 -0
- package/dist/commands/ls-tree-command.d.ts.map +1 -0
- package/dist/commands/mailmap.d.ts +24 -1
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/maintenance-run-command.d.ts +122 -0
- package/dist/commands/maintenance-run-command.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +58 -1
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-config.d.ts +7 -0
- package/dist/commands/merge-config.d.ts.map +1 -1
- package/dist/commands/merge-drivers.d.ts +69 -5
- package/dist/commands/merge-drivers.d.ts.map +1 -1
- package/dist/commands/merge-strategy-options.d.ts +69 -0
- package/dist/commands/merge-strategy-options.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +16 -0
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/merge-tree-command.d.ts +122 -0
- package/dist/commands/merge-tree-command.d.ts.map +1 -0
- package/dist/commands/message-cleanup.d.ts +2 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -1
- package/dist/commands/mktag-command.d.ts +51 -0
- package/dist/commands/mktag-command.d.ts.map +1 -0
- package/dist/commands/name-rev-command.d.ts +65 -0
- package/dist/commands/name-rev-command.d.ts.map +1 -0
- package/dist/commands/name-rev.d.ts +110 -22
- package/dist/commands/name-rev.d.ts.map +1 -1
- package/dist/commands/object-store/count-objects-command.d.ts +58 -0
- package/dist/commands/object-store/count-objects-command.d.ts.map +1 -0
- package/dist/commands/object-store/index.d.ts +5 -0
- package/dist/commands/object-store/index.d.ts.map +1 -0
- package/dist/commands/object-store/objects-directory.d.ts +12 -0
- package/dist/commands/object-store/objects-directory.d.ts.map +1 -0
- package/dist/commands/object-store/prune-command.d.ts +38 -0
- package/dist/commands/object-store/prune-command.d.ts.map +1 -0
- package/dist/commands/object-store/show-index-command.d.ts +23 -0
- package/dist/commands/object-store/show-index-command.d.ts.map +1 -0
- package/dist/commands/octopus-merge.d.ts +26 -1
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/ort-merge.d.ts +40 -0
- package/dist/commands/ort-merge.d.ts.map +1 -1
- package/dist/commands/ort-recursive.d.ts.map +1 -1
- package/dist/commands/patch-id-command.d.ts +30 -0
- package/dist/commands/patch-id-command.d.ts.map +1 -0
- package/dist/commands/patch-id.d.ts +82 -0
- package/dist/commands/patch-id.d.ts.map +1 -1
- package/dist/commands/plumbing-command.d.ts +66 -0
- package/dist/commands/plumbing-command.d.ts.map +1 -0
- package/dist/commands/plumbing-input.d.ts +38 -0
- package/dist/commands/plumbing-input.d.ts.map +1 -0
- package/dist/commands/promisor-remote-reply.d.ts +35 -0
- package/dist/commands/promisor-remote-reply.d.ts.map +1 -0
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +182 -38
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +82 -2
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/index.d.ts +4 -0
- package/dist/commands/range-diff/index.d.ts.map +1 -0
- package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
- package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff.d.ts +106 -0
- package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
- package/dist/commands/read-tree-command.d.ts +14 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +129 -4
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/refs-command.d.ts +81 -0
- package/dist/commands/refs-command.d.ts.map +1 -0
- package/dist/commands/remerge-diff.d.ts +59 -0
- package/dist/commands/remerge-diff.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +41 -0
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-object-info-command.d.ts +55 -0
- package/dist/commands/remote-object-info-command.d.ts.map +1 -0
- package/dist/commands/remote-show-command.d.ts +204 -0
- package/dist/commands/remote-show-command.d.ts.map +1 -0
- package/dist/commands/remote-transport.d.ts +40 -3
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/repack-command.d.ts +115 -0
- package/dist/commands/repack-command.d.ts.map +1 -0
- package/dist/commands/replace-command.d.ts +143 -0
- package/dist/commands/replace-command.d.ts.map +1 -0
- package/dist/commands/replay-command.d.ts +117 -0
- package/dist/commands/replay-command.d.ts.map +1 -0
- package/dist/commands/repo-command.d.ts +136 -0
- package/dist/commands/repo-command.d.ts.map +1 -0
- package/dist/commands/request-pull-command.d.ts +82 -0
- package/dist/commands/request-pull-command.d.ts.map +1 -0
- package/dist/commands/rerere-command.d.ts +36 -0
- package/dist/commands/rerere-command.d.ts.map +1 -0
- package/dist/commands/rerere.d.ts +102 -0
- package/dist/commands/rerere.d.ts.map +1 -0
- package/dist/commands/reset-command.d.ts +19 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +7 -0
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-filter/commit-grep.d.ts +3 -1
- package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -1
- package/dist/commands/rev-list-command.d.ts +78 -3
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/rev-parse-command.d.ts +9 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +32 -1
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +7 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +12 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +120 -1
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +10 -1
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +23 -1
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/session-id.d.ts +18 -0
- package/dist/commands/session-id.d.ts.map +1 -0
- package/dist/commands/shortlog-command.d.ts +109 -0
- package/dist/commands/shortlog-command.d.ts.map +1 -0
- package/dist/commands/shortlog.d.ts +151 -0
- package/dist/commands/shortlog.d.ts.map +1 -0
- package/dist/commands/show-branch-command.d.ts +59 -0
- package/dist/commands/show-branch-command.d.ts.map +1 -0
- package/dist/commands/show-ref-command.d.ts +112 -0
- package/dist/commands/show-ref-command.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +9 -2
- package/dist/commands/signature-check.d.ts.map +1 -1
- package/dist/commands/signing.d.ts +22 -1
- package/dist/commands/signing.d.ts.map +1 -1
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-export-command.d.ts +115 -0
- package/dist/commands/stash-export-command.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +33 -3
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/stripspace-command.d.ts +44 -0
- package/dist/commands/stripspace-command.d.ts.map +1 -0
- package/dist/commands/submodule-add-command.d.ts +10 -1
- package/dist/commands/submodule-add-command.d.ts.map +1 -1
- package/dist/commands/submodule-auth.d.ts +3 -1
- package/dist/commands/submodule-auth.d.ts.map +1 -1
- package/dist/commands/submodule-commands.d.ts +99 -3
- package/dist/commands/submodule-commands.d.ts.map +1 -1
- package/dist/commands/submodule-fetch.d.ts +149 -0
- package/dist/commands/submodule-fetch.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +8 -0
- package/dist/commands/submodule-model.d.ts.map +1 -1
- package/dist/commands/submodule-unpack.d.ts +120 -0
- package/dist/commands/submodule-unpack.d.ts.map +1 -0
- package/dist/commands/submodule-update-command.d.ts +21 -1
- package/dist/commands/submodule-update-command.d.ts.map +1 -1
- package/dist/commands/subtree-shift.d.ts +27 -0
- package/dist/commands/subtree-shift.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts +3 -0
- package/dist/commands/switch-command.d.ts.map +1 -1
- package/dist/commands/textconv-cache.d.ts +58 -0
- package/dist/commands/textconv-cache.d.ts.map +1 -0
- package/dist/commands/tree-restore.d.ts +5 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/unpack-objects-command.d.ts +47 -0
- package/dist/commands/unpack-objects-command.d.ts.map +1 -0
- package/dist/commands/update-index-command.d.ts +110 -0
- package/dist/commands/update-index-command.d.ts.map +1 -0
- package/dist/commands/uri-protocols.d.ts +13 -0
- package/dist/commands/uri-protocols.d.ts.map +1 -0
- package/dist/commands/url-parse-command.d.ts +30 -0
- package/dist/commands/url-parse-command.d.ts.map +1 -0
- package/dist/commands/var-command.d.ts +42 -0
- package/dist/commands/var-command.d.ts.map +1 -0
- package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/{commands-ISM52N0n.js → commands-Mlo1dxQN.js} +56133 -70269
- package/dist/errors/command-errors.d.ts +58 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +67 -1
- package/dist/fsck-CrhVMNIH.js +5179 -0
- package/dist/git-command.d.ts +89 -3
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +628 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +84 -0
- package/dist/guarded-transport-command.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/maintenance-run-command-Bw21HEkH.js +13539 -0
- package/dist/remote-transport-Bu4PGSMD.js +2605 -0
- package/dist/rename/detect-renames.d.ts +20 -0
- package/dist/rename/detect-renames.d.ts.map +1 -1
- package/dist/rename/diffcore-break.d.ts +51 -0
- package/dist/rename/diffcore-break.d.ts.map +1 -0
- package/dist/rename/index.d.ts +1 -0
- package/dist/rename/index.d.ts.map +1 -1
- package/dist/results/blame-format.d.ts +62 -1
- package/dist/results/blame-format.d.ts.map +1 -1
- package/dist/results/cherry-pick-result.d.ts +6 -0
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +9 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/diff-dirstat.d.ts +36 -0
- package/dist/results/diff-dirstat.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +20 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +67 -3
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/fetch-result.d.ts +24 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +2 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/init-result.d.ts +8 -1
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/line-range-hunks.d.ts +27 -0
- package/dist/results/line-range-hunks.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +13 -1
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +11 -0
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +10 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +7 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +6 -0
- package/dist/results/revert-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +5 -0
- package/dist/results/stash-result.d.ts.map +1 -1
- package/dist/results/status-result.d.ts +1 -1
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-ERo9vELd.js +49673 -0
- package/dist/transport-command.d.ts +93 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/commands/add-command.ts +118 -0
- package/src/commands/add-patch/add-patch.ts +8 -0
- package/src/commands/add-patch/patch-backend.ts +24 -3
- package/src/commands/add-patch/patch-modes.ts +26 -2
- package/src/commands/add-patch/patch-session.ts +6 -0
- package/src/commands/am/am-command.ts +301 -12
- package/src/commands/apply/apply-command.ts +52 -9
- package/src/commands/apply/apply-parse.ts +10 -0
- package/src/commands/apply/index.ts +9 -1
- package/src/commands/archive/archive-command.ts +1148 -0
- package/src/commands/archive/archive-entry.ts +93 -0
- package/src/commands/archive/index.ts +7 -0
- package/src/commands/archive/remote-archive-command.ts +140 -0
- package/src/commands/archive/tar-archive.ts +207 -0
- package/src/commands/archive/tar-commit-id.ts +72 -0
- package/src/commands/archive/upload-archive-writer.ts +213 -0
- package/src/commands/archive/zip-archive.ts +317 -0
- package/src/commands/attributes-source.ts +26 -12
- package/src/commands/blame-command.ts +1551 -53
- package/src/commands/blame-ignore.ts +307 -0
- package/src/commands/bundle/bundle-create-command.ts +405 -0
- package/src/commands/bundle/bundle-format.ts +228 -0
- package/src/commands/bundle/bundle-list.ts +276 -0
- package/src/commands/bundle/bundle-read-commands.ts +157 -0
- package/src/commands/bundle/bundle-support.ts +85 -0
- package/src/commands/bundle/bundle-transport.ts +107 -0
- package/src/commands/bundle/bundle-uri-host.ts +204 -0
- package/src/commands/bundle/bundle-uri.ts +236 -0
- package/src/commands/bundle/bundle-verify.ts +152 -0
- package/src/commands/bundle/index.ts +14 -0
- package/src/commands/cat-file/batch-format.ts +193 -0
- package/src/commands/cat-file/cat-file-command.ts +857 -0
- package/src/commands/cat-file/index.ts +2 -0
- package/src/commands/check-attr-command.ts +333 -0
- package/src/commands/check-ignore-command.ts +261 -0
- package/src/commands/check-mailmap-command.ts +129 -0
- package/src/commands/check-ref-format-command.ts +129 -0
- package/src/commands/checkout-command.ts +131 -28
- package/src/commands/checkout-index-command.ts +568 -0
- package/src/commands/checkout-paths.ts +35 -0
- package/src/commands/cherry-command.ts +187 -0
- package/src/commands/cherry-pick-command.ts +63 -2
- package/src/commands/clean-command.ts +92 -12
- package/src/commands/clean-interactive.ts +522 -0
- package/src/commands/clone-command.ts +803 -50
- package/src/commands/commit-command.ts +202 -51
- package/src/commands/config-command.ts +9 -0
- package/src/commands/daemon-access-hook.ts +78 -0
- package/src/commands/default-branch.ts +99 -1
- package/src/commands/describe-command.ts +341 -254
- package/src/commands/diff-command.ts +1186 -99
- package/src/commands/diff-external.ts +131 -0
- package/src/commands/diff-plumbing/diff-pairs-command.ts +193 -0
- package/src/commands/diff-plumbing/diff-plumbing-command.ts +424 -0
- package/src/commands/diff-plumbing/index.ts +2 -0
- package/src/commands/diff-textconv.ts +5 -1
- package/src/commands/fast-export/fast-export-command.ts +911 -0
- package/src/commands/fast-export/fast-import-command.ts +1553 -0
- package/src/commands/fast-export/fast-stream-support.ts +162 -0
- package/src/commands/fast-export/index.ts +3 -0
- package/src/commands/fetch-command.ts +665 -14
- package/src/commands/fetch-multiple-command.ts +668 -0
- package/src/commands/format-patch-command.ts +189 -77
- package/src/commands/format-rev-command.ts +251 -0
- package/src/commands/fsck/fsck-command.ts +47 -20
- package/src/commands/fsck/fsck-msg-ids.ts +19 -3
- package/src/commands/fsck/fsck-pack.ts +2 -2
- package/src/commands/fsmonitor-refresh.ts +315 -0
- package/src/commands/gc-command.ts +10 -0
- package/src/commands/git-describe.ts +456 -217
- package/src/commands/git-hooks.ts +165 -9
- package/src/commands/git-paths.ts +136 -0
- package/src/commands/grep/grep-command.ts +38 -15
- package/src/commands/history-command.ts +617 -0
- package/src/commands/http-config.ts +139 -0
- package/src/commands/index-adder.ts +37 -3
- package/src/commands/index-host.ts +6 -1
- package/src/commands/index.ts +62 -0
- package/src/commands/init-command.ts +617 -49
- package/src/commands/last-modified-command.ts +804 -0
- package/src/commands/lfs/go-url.ts +370 -0
- package/src/commands/lfs/index.ts +2 -0
- package/src/commands/lfs/lfs-config.ts +738 -0
- package/src/commands/lfs/lfs-endpoint-command.ts +180 -0
- package/src/commands/line-log.ts +931 -0
- package/src/commands/local-transport.ts +252 -4
- package/src/commands/log-command.ts +1518 -182
- package/src/commands/log-graph.ts +6 -3
- package/src/commands/log-output.ts +228 -15
- package/src/commands/ls-files-command.ts +1177 -0
- package/src/commands/ls-remote-command.ts +6 -0
- package/src/commands/ls-tree-command.ts +684 -0
- package/src/commands/mailmap.ts +41 -5
- package/src/commands/maintenance-run-command.ts +949 -0
- package/src/commands/merge-command.ts +351 -47
- package/src/commands/merge-config.ts +23 -1
- package/src/commands/merge-drivers.ts +112 -20
- package/src/commands/merge-strategy-options.ts +224 -0
- package/src/commands/merge-support.ts +130 -26
- package/src/commands/merge-tree-command.ts +786 -0
- package/src/commands/message-cleanup.ts +1 -1
- package/src/commands/mktag-command.ts +149 -0
- package/src/commands/name-rev-command.ts +184 -0
- package/src/commands/name-rev.ts +700 -109
- package/src/commands/object-store/count-objects-command.ts +404 -0
- package/src/commands/object-store/index.ts +4 -0
- package/src/commands/object-store/objects-directory.ts +24 -0
- package/src/commands/object-store/prune-command.ts +129 -0
- package/src/commands/object-store/show-index-command.ts +151 -0
- package/src/commands/octopus-merge.ts +35 -11
- package/src/commands/ort-merge.ts +124 -23
- package/src/commands/ort-recursive.ts +40 -2
- package/src/commands/patch-id-command.ts +65 -0
- package/src/commands/patch-id.ts +327 -0
- package/src/commands/plumbing-command.ts +141 -0
- package/src/commands/plumbing-input.ts +87 -0
- package/src/commands/promisor-remote-reply.ts +276 -0
- package/src/commands/promisor-remote.ts +25 -2
- package/src/commands/pull-command.ts +720 -224
- package/src/commands/push-command.ts +440 -8
- package/src/commands/range-diff/index.ts +3 -0
- package/src/commands/range-diff/linear-assignment.ts +203 -0
- package/src/commands/range-diff/range-diff-command.ts +433 -0
- package/src/commands/range-diff/range-diff.ts +617 -0
- package/src/commands/read-tree-command.ts +74 -3
- package/src/commands/rebase-command.ts +647 -83
- package/src/commands/refs-command.ts +274 -0
- package/src/commands/remerge-diff.ts +241 -0
- package/src/commands/remote-command.ts +98 -10
- package/src/commands/remote-object-info-command.ts +109 -0
- package/src/commands/remote-show-command.ts +836 -0
- package/src/commands/remote-transport.ts +116 -1
- package/src/commands/repack-command.ts +383 -0
- package/src/commands/replace-command.ts +816 -0
- package/src/commands/replay-command.ts +674 -0
- package/src/commands/repo-command.ts +967 -0
- package/src/commands/request-pull-command.ts +356 -0
- package/src/commands/rerere-command.ts +179 -0
- package/src/commands/rerere.ts +925 -0
- package/src/commands/reset-command.ts +78 -3
- package/src/commands/restore-command.ts +15 -0
- package/src/commands/rev-filter/commit-grep.ts +7 -2
- package/src/commands/rev-list-command.ts +196 -11
- package/src/commands/rev-parse-command.ts +62 -4
- package/src/commands/revert-command.ts +62 -2
- package/src/commands/revision-range.ts +10 -3
- package/src/commands/revision-resolver.ts +44 -3
- package/src/commands/sequencer-pick.ts +370 -29
- package/src/commands/sequencer-support.ts +164 -2
- package/src/commands/serve-repository.ts +65 -0
- package/src/commands/session-id.ts +31 -0
- package/src/commands/shortlog-command.ts +354 -0
- package/src/commands/shortlog.ts +361 -0
- package/src/commands/show-branch-command.ts +981 -0
- package/src/commands/show-command.ts +3 -2
- package/src/commands/show-ref-command.ts +439 -0
- package/src/commands/signature-check.ts +37 -5
- package/src/commands/signing.ts +122 -16
- package/src/commands/stash-apply-command.ts +3 -0
- package/src/commands/stash-export-command.ts +397 -0
- package/src/commands/status-command.ts +158 -31
- package/src/commands/status-format.ts +1 -1
- package/src/commands/stripspace-command.ts +118 -0
- package/src/commands/submodule-add-command.ts +22 -1
- package/src/commands/submodule-auth.ts +61 -6
- package/src/commands/submodule-commands.ts +333 -5
- package/src/commands/submodule-fetch.ts +789 -0
- package/src/commands/submodule-model.ts +9 -1
- package/src/commands/submodule-unpack.ts +265 -0
- package/src/commands/submodule-update-command.ts +68 -5
- package/src/commands/subtree-shift.ts +215 -0
- package/src/commands/switch-command.ts +9 -0
- package/src/commands/textconv-cache.ts +143 -0
- package/src/commands/tree-restore.ts +20 -1
- package/src/commands/unpack-objects-command.ts +235 -0
- package/src/commands/update-index-command.ts +1016 -0
- package/src/commands/uri-protocols.ts +13 -0
- package/src/commands/url-parse-command.ts +67 -0
- package/src/commands/var-command.ts +219 -0
- package/src/commands/worktree-overwrite-checks.ts +5 -0
- package/src/errors/command-errors.ts +80 -0
- package/src/git-command.ts +218 -2
- package/src/git.ts +1033 -80
- package/src/guarded-transport-command.ts +176 -0
- package/src/index.ts +1 -0
- package/src/rename/detect-renames.ts +42 -8
- package/src/rename/diffcore-break.ts +166 -0
- package/src/rename/index.ts +1 -0
- package/src/results/blame-format.ts +268 -43
- package/src/results/cherry-pick-result.ts +6 -0
- package/src/results/clone-result.ts +6 -0
- package/src/results/diff-dirstat.ts +117 -0
- package/src/results/diff-entry.ts +24 -0
- package/src/results/diff-formatter.ts +8 -4
- package/src/results/diff-output.ts +239 -8
- package/src/results/diff-pickaxe.ts +1 -1
- package/src/results/fetch-result.ts +24 -1
- package/src/results/index.ts +2 -0
- package/src/results/init-result.ts +10 -1
- package/src/results/line-range-hunks.ts +126 -0
- package/src/results/merge-result.ts +14 -0
- package/src/results/pull-result.ts +7 -0
- package/src/results/push-result.ts +10 -0
- package/src/results/rebase-result.ts +7 -0
- package/src/results/revert-result.ts +6 -0
- package/src/results/stash-result.ts +6 -0
- package/src/results/status-result.ts +2 -2
- package/src/transport-command.ts +216 -4
- package/dist/fsck-DLRpbwTj.js +0 -13405
- package/dist/results-TB2IJ64h.js +0 -4700
|
@@ -0,0 +1,981 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ShowBranchCommand - `git show-branch` (builtin/show-branch.c): the commit-ancestry table of
|
|
3
|
+
* branches, and its other modes: `--list`, `--more=<n>`, `--independent`, `--merge-base`,
|
|
4
|
+
* `--topics`, `--sparse`, `--reflog` (`-g`).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // git show-branch main topic
|
|
9
|
+
* const { stdout } = await git.showBranch().setArguments(["main", "topic"]).call();
|
|
10
|
+
* // ! [main] subject of main
|
|
11
|
+
* // * [topic] subject of topic
|
|
12
|
+
* // --
|
|
13
|
+
* // * [topic] subject of topic
|
|
14
|
+
* // +* [main] subject of main
|
|
15
|
+
*
|
|
16
|
+
* // git show-branch --merge-base main topic: exit status 1 when there is none
|
|
17
|
+
* const { exitCode, stdout: base } = await git.showBranch()
|
|
18
|
+
* .setArguments(["--merge-base", "main", "topic"]).call();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import type { ObjectId } from "@statewalker/vcs-core";
|
|
23
|
+
import { wildmatch } from "@statewalker/vcs-working-tree";
|
|
24
|
+
|
|
25
|
+
import { RevisionError } from "../errors/index.js";
|
|
26
|
+
import { GitCommand } from "../git-command.js";
|
|
27
|
+
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
28
|
+
import type { PlumbingTextOutput } from "./check-ref-format-command.js";
|
|
29
|
+
import { gitConfigColorBool } from "./config-value-types.js";
|
|
30
|
+
import { approxidateCareful, formatRfc2822Date } from "./git-date.js";
|
|
31
|
+
import { GRAPH_COLUMN_COLORS_ANSI } from "./log-graph.js";
|
|
32
|
+
import { relativeDate } from "./pretty-format.js";
|
|
33
|
+
import { commitSubject } from "./shortlog.js";
|
|
34
|
+
|
|
35
|
+
const USAGE = [
|
|
36
|
+
"usage: git show-branch [-a | --all] [-r | --remotes] [--topo-order | --date-order]",
|
|
37
|
+
" [--current] [--color[=<when>] | --no-color] [--sparse]",
|
|
38
|
+
" [--more=<n> | --list | --independent | --merge-base]",
|
|
39
|
+
" [--no-name | --sha1-name] [--topics]",
|
|
40
|
+
" [(<rev> | <glob>)...]",
|
|
41
|
+
" or: git show-branch (-g | --reflog)[=<n>[,<base>]] [--list] [<ref>]",
|
|
42
|
+
].join("\n");
|
|
43
|
+
|
|
44
|
+
/** The commit flag bits git keeps for itself before the revs' bits (UNINTERESTING is 01). */
|
|
45
|
+
const UNINTERESTING = 1;
|
|
46
|
+
const REV_SHIFT = 2;
|
|
47
|
+
const DEFAULT_REFLOG = 4;
|
|
48
|
+
|
|
49
|
+
/** A commit as show-branch sees it: `parents` undefined until git would parse it. */
|
|
50
|
+
interface Node {
|
|
51
|
+
readonly id: ObjectId;
|
|
52
|
+
date: number;
|
|
53
|
+
parents?: Node[];
|
|
54
|
+
subject?: string;
|
|
55
|
+
flags: number;
|
|
56
|
+
/** commit_name: which head's ancestor, how many first parents away */
|
|
57
|
+
name?: { head: string; generation: number };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** A git death: its lines and exit status. */
|
|
61
|
+
class Death extends Error {
|
|
62
|
+
constructor(
|
|
63
|
+
readonly lines: string,
|
|
64
|
+
readonly exitCode: number,
|
|
65
|
+
) {
|
|
66
|
+
super(lines);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** What the options of one run say (show-branch's locals). */
|
|
71
|
+
interface Options {
|
|
72
|
+
allHeads: boolean;
|
|
73
|
+
allRemotes: boolean;
|
|
74
|
+
color?: boolean;
|
|
75
|
+
extra: number;
|
|
76
|
+
noName: boolean;
|
|
77
|
+
current: boolean;
|
|
78
|
+
sha1Name: boolean;
|
|
79
|
+
mergeBase: boolean;
|
|
80
|
+
independent: boolean;
|
|
81
|
+
sortOrder: "topo" | "date";
|
|
82
|
+
topics: boolean;
|
|
83
|
+
sparse: boolean;
|
|
84
|
+
reflog: number;
|
|
85
|
+
reflogBase?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The long options and whether each may be negated (parse-options' `--no-`). */
|
|
89
|
+
const LONG_OPTIONS: { name: string; negatable: boolean; arg?: "optional" }[] = [
|
|
90
|
+
{ name: "all", negatable: true },
|
|
91
|
+
{ name: "remotes", negatable: true },
|
|
92
|
+
{ name: "color", negatable: true, arg: "optional" },
|
|
93
|
+
{ name: "more", negatable: true, arg: "optional" },
|
|
94
|
+
{ name: "list", negatable: true },
|
|
95
|
+
{ name: "no-name", negatable: true },
|
|
96
|
+
{ name: "current", negatable: true },
|
|
97
|
+
{ name: "sha1-name", negatable: true },
|
|
98
|
+
{ name: "merge-base", negatable: true },
|
|
99
|
+
{ name: "independent", negatable: true },
|
|
100
|
+
{ name: "topo-order", negatable: false },
|
|
101
|
+
{ name: "topics", negatable: true },
|
|
102
|
+
{ name: "sparse", negatable: true },
|
|
103
|
+
{ name: "date-order", negatable: false },
|
|
104
|
+
{ name: "reflog", negatable: false, arg: "optional" },
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* `git show-branch` with git's argv (`setArguments`), its output as git's process ends
|
|
109
|
+
* (stdout, stderr, exit status: 129 for git's usage errors, 128 where it dies). With no
|
|
110
|
+
* arguments the `showbranch.default` values are taken as the argv, as git does. Relative
|
|
111
|
+
* reflog dates count from {@link setNow} (git's `GIT_TEST_DATE_NOW`), else the clock.
|
|
112
|
+
*/
|
|
113
|
+
export class ShowBranchCommand extends GitCommand<PlumbingTextOutput> {
|
|
114
|
+
private args: string[] = [];
|
|
115
|
+
private now?: number;
|
|
116
|
+
private maxRevs = 27;
|
|
117
|
+
/** git before 2.45 reads `<ref>@{<n>}` one record early (refs.c's read_ref_at) */
|
|
118
|
+
private legacyReflog = false;
|
|
119
|
+
|
|
120
|
+
/** The arguments after `git show-branch`, as git parses them. */
|
|
121
|
+
setArguments(args: readonly string[]): this {
|
|
122
|
+
this.checkCallable();
|
|
123
|
+
this.args = [...args];
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** The time relative reflog dates are counted from, in seconds (git's `GIT_TEST_DATE_NOW`). */
|
|
128
|
+
setNow(now: number): this {
|
|
129
|
+
this.checkCallable();
|
|
130
|
+
this.now = now;
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The git version followed (`git version 2.43.0`, default the newest): before 2.54 git
|
|
136
|
+
* keeps one flag bit fewer, so it handles 26 refs at once instead of 27; before 2.45 its
|
|
137
|
+
* reflog reads show `<ref>@{<n>}` (n > 0) with the message and date of the newer entry.
|
|
138
|
+
*/
|
|
139
|
+
setVersionString(version: string): this {
|
|
140
|
+
this.checkCallable();
|
|
141
|
+
const m = /(\d+)\.(\d+)/.exec(version);
|
|
142
|
+
const major = Number(m?.[1] ?? 2);
|
|
143
|
+
const minor = Number(m?.[2] ?? 99);
|
|
144
|
+
this.maxRevs = major < 2 || (major === 2 && minor < 54) ? 26 : 27;
|
|
145
|
+
this.legacyReflog = major < 2 || (major === 2 && minor < 45);
|
|
146
|
+
return this;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async call(): Promise<PlumbingTextOutput> {
|
|
150
|
+
this.checkCallable();
|
|
151
|
+
this.setCallable(false);
|
|
152
|
+
const out: string[] = [];
|
|
153
|
+
const err: string[] = [];
|
|
154
|
+
try {
|
|
155
|
+
const exitCode = await this.run(out, err);
|
|
156
|
+
return { exitCode, stdout: out.join(""), stderr: err.join("") };
|
|
157
|
+
} catch (e) {
|
|
158
|
+
if (e instanceof Death) {
|
|
159
|
+
return {
|
|
160
|
+
exitCode: e.exitCode,
|
|
161
|
+
stdout: out.join(""),
|
|
162
|
+
stderr: `${err.join("")}${e.lines}\n`,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
if (e instanceof RevisionError) {
|
|
166
|
+
return { exitCode: 128, stdout: out.join(""), stderr: `${err.join("")}${e.message}\n` };
|
|
167
|
+
}
|
|
168
|
+
throw e;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private async run(out: string[], err: string[]): Promise<number> {
|
|
173
|
+
const config = RemoteConfigStore.from(this.workingCopy);
|
|
174
|
+
let argv = this.args;
|
|
175
|
+
if (argv.length === 0) argv = config.values("showbranch.default");
|
|
176
|
+
const configColor = config.value("color.showbranch") ?? config.value("color.ui");
|
|
177
|
+
const o: Options = {
|
|
178
|
+
allHeads: false,
|
|
179
|
+
allRemotes: false,
|
|
180
|
+
extra: 0,
|
|
181
|
+
noName: false,
|
|
182
|
+
current: false,
|
|
183
|
+
sha1Name: false,
|
|
184
|
+
mergeBase: false,
|
|
185
|
+
independent: false,
|
|
186
|
+
sortOrder: "topo",
|
|
187
|
+
topics: false,
|
|
188
|
+
sparse: false,
|
|
189
|
+
reflog: 0,
|
|
190
|
+
};
|
|
191
|
+
let av = parseArguments(argv, o);
|
|
192
|
+
if (o.allHeads) o.allRemotes = true;
|
|
193
|
+
const useColor =
|
|
194
|
+
o.color ??
|
|
195
|
+
(configColor !== undefined && gitConfigColorBool("color", configColor) === "always");
|
|
196
|
+
|
|
197
|
+
if (o.extra || o.reflog) {
|
|
198
|
+
if (o.independent || o.mergeBase) throw new Death(USAGE, 129);
|
|
199
|
+
if (o.reflog && (o.extra > 0 || o.allHeads || o.allRemotes)) {
|
|
200
|
+
throw new Death(
|
|
201
|
+
"fatal: options '--reflog' and '--all/--remotes/--independent/--merge-base' cannot be used together",
|
|
202
|
+
128,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (o.current && o.reflog) {
|
|
207
|
+
throw new Death("fatal: options '--reflog' and '--current' cannot be used together", 128);
|
|
208
|
+
}
|
|
209
|
+
if (av.length <= (o.topics ? 1 : 0) && !o.allHeads && !o.allRemotes) o.allHeads = true;
|
|
210
|
+
|
|
211
|
+
const resolver = this.revisionResolver();
|
|
212
|
+
const flushWarnings = () => {
|
|
213
|
+
for (const w of resolver.warnings.splice(0)) err.push(`${w}\n`);
|
|
214
|
+
};
|
|
215
|
+
/** repo_get_oid: the object a name gives, undefined where git's lookup fails */
|
|
216
|
+
const getOid = async (name: string): Promise<ObjectId | undefined> => {
|
|
217
|
+
try {
|
|
218
|
+
return await resolver.resolve(name);
|
|
219
|
+
} catch (e) {
|
|
220
|
+
if (e instanceof RevisionError) throw e;
|
|
221
|
+
return undefined;
|
|
222
|
+
} finally {
|
|
223
|
+
flushWarnings();
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
const maxRevs = this.maxRevs;
|
|
227
|
+
const refNames: string[] = [];
|
|
228
|
+
const refCommits: ObjectId[] = [];
|
|
229
|
+
/** append_ref: refs that peel to no commit are skipped silently */
|
|
230
|
+
const appendRef = async (name: string, id: ObjectId, allowDups: boolean) => {
|
|
231
|
+
const peeled = await resolver.peelTags(id).catch(() => undefined);
|
|
232
|
+
if (peeled?.type !== "commit") return;
|
|
233
|
+
if (!allowDups && refNames.includes(name)) return;
|
|
234
|
+
if (refNames.length >= maxRevs) {
|
|
235
|
+
err.push(`warning: ignoring ${name}; cannot handle more than ${maxRevs} refs\n`);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
refNames.push(name);
|
|
239
|
+
refCommits.push(peeled.id);
|
|
240
|
+
};
|
|
241
|
+
const sortRange = (from: number) => {
|
|
242
|
+
const pairs = refNames.slice(from).map((n, i) => [n, refCommits[from + i]] as const);
|
|
243
|
+
pairs.sort((a, b) => versionCmp(a[0], b[0]));
|
|
244
|
+
pairs.forEach(([n, c], i) => {
|
|
245
|
+
refNames[from + i] = n;
|
|
246
|
+
refCommits[from + i] = c as ObjectId;
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
const allRefs = async (): Promise<{ name: string; id: ObjectId }[]> => {
|
|
250
|
+
const refs: { name: string; id: ObjectId }[] = [];
|
|
251
|
+
for await (const ref of this.refsStore.list("refs/")) {
|
|
252
|
+
if (!ref.name.startsWith("refs/")) continue;
|
|
253
|
+
const id =
|
|
254
|
+
"objectId" in ref && ref.objectId && !("target" in ref && ref.target)
|
|
255
|
+
? ref.objectId
|
|
256
|
+
: (await this.refsStore.resolve(ref.name).catch(() => undefined))?.objectId;
|
|
257
|
+
if (id) refs.push({ name: ref.name, id });
|
|
258
|
+
}
|
|
259
|
+
refs.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
260
|
+
return refs;
|
|
261
|
+
};
|
|
262
|
+
/** append_head_ref / append_remote_ref: `heads/foo` when `foo` names something else */
|
|
263
|
+
const appendShortRef = async (name: string, id: ObjectId, prefix: string) => {
|
|
264
|
+
const short = name.slice(prefix.length);
|
|
265
|
+
const ofs = (await getOid(short)) === id ? prefix.length : 5;
|
|
266
|
+
await appendRef(name.slice(ofs), id, false);
|
|
267
|
+
};
|
|
268
|
+
const appendMatchingRef = async (ref: { name: string; id: ObjectId }, pattern: string) => {
|
|
269
|
+
let slash = countSlashes(ref.name);
|
|
270
|
+
const wanted = countSlashes(pattern);
|
|
271
|
+
let tail = 0;
|
|
272
|
+
while (tail < ref.name.length && wanted < slash) {
|
|
273
|
+
if (ref.name[tail++] === "/") slash--;
|
|
274
|
+
}
|
|
275
|
+
if (tail >= ref.name.length) return;
|
|
276
|
+
if (!wildmatch(pattern, ref.name.slice(tail))) return;
|
|
277
|
+
if (ref.name.startsWith("refs/heads/")) await appendShortRef(ref.name, ref.id, "refs/heads/");
|
|
278
|
+
else if (ref.name.startsWith("refs/tags/")) await appendRef(ref.name.slice(5), ref.id, false);
|
|
279
|
+
else await appendRef(ref.name, ref.id, false);
|
|
280
|
+
};
|
|
281
|
+
const appendOneRev = async (name: string) => {
|
|
282
|
+
const id = await getOid(name);
|
|
283
|
+
if (id !== undefined) {
|
|
284
|
+
await appendRef(name, id, false);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (/[*?[]/.test(name)) {
|
|
288
|
+
const saved = refNames.length;
|
|
289
|
+
for (const ref of await allRefs()) await appendMatchingRef(ref, name);
|
|
290
|
+
if (saved === refNames.length && refNames.length < maxRevs) {
|
|
291
|
+
err.push(`error: no matching refs with ${name}\n`);
|
|
292
|
+
}
|
|
293
|
+
sortRange(saved);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
throw new Death(`fatal: bad sha1 reference ${name}`, 128);
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
const head = await this.readHead();
|
|
300
|
+
const reflogMsg: string[] = [];
|
|
301
|
+
if (o.reflog) {
|
|
302
|
+
if (av.length === 0) {
|
|
303
|
+
if (!head) throw new Death("fatal: no branches given, and HEAD is not valid", 128);
|
|
304
|
+
av = [head.name];
|
|
305
|
+
}
|
|
306
|
+
if (av.length !== 1) throw new Death("fatal: --reflog option needs one branch name", 128);
|
|
307
|
+
if (maxRevs < o.reflog) {
|
|
308
|
+
throw new Death(`fatal: only ${maxRevs} entries can be shown at one time.`, 128);
|
|
309
|
+
}
|
|
310
|
+
const name = av[0] as string;
|
|
311
|
+
const found = (await resolver.dwimRef(name).catch(() => []))[0];
|
|
312
|
+
flushWarnings();
|
|
313
|
+
if (!found) throw new Death(`fatal: no such ref ${name}`, 128);
|
|
314
|
+
const log = await this.refsStore.getReflog?.(found.ref);
|
|
315
|
+
const entries = (await log?.getReverseEntries()) ?? [];
|
|
316
|
+
let base = 0;
|
|
317
|
+
if (o.reflogBase !== undefined) {
|
|
318
|
+
const n = parseUnsigned(o.reflogBase);
|
|
319
|
+
if (n.rest.length === 0) base = n.value;
|
|
320
|
+
else {
|
|
321
|
+
// a date: the count of the newest entry at or before it (read_ref_at's cutoff_cnt)
|
|
322
|
+
const at = approxidateCareful(o.reflogBase, this.nowSeconds()).timestamp;
|
|
323
|
+
if (entries.length === 0) throw new Death(`fatal: log for ${found.ref} is empty`, 128);
|
|
324
|
+
const k = entries.findIndex((e) => e.who.timestamp <= at);
|
|
325
|
+
base = k < 0 ? entries.length : k;
|
|
326
|
+
if (k >= 0) this.gapWarning(entries, k, found.ref, found.id, err);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
let oid = found.id;
|
|
330
|
+
for (let i = 0; i < o.reflog; i++) {
|
|
331
|
+
const k = base + i;
|
|
332
|
+
if (entries.length === 0 && k > 0) {
|
|
333
|
+
throw new Death(`fatal: log for ${found.ref} is empty`, 128);
|
|
334
|
+
}
|
|
335
|
+
let at = k;
|
|
336
|
+
if (this.legacyReflog && k > 0) {
|
|
337
|
+
// git before 2.45 stops a record early: the newer entry's message and its old id
|
|
338
|
+
at = k - 1;
|
|
339
|
+
while (at < entries.length && isNullId((entries[at] as (typeof entries)[number]).oldId)) {
|
|
340
|
+
at++;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const entry = entries[at];
|
|
344
|
+
if (!entry) {
|
|
345
|
+
o.reflog = i;
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
if (this.legacyReflog && k > 0) {
|
|
349
|
+
const newer = at > 0 ? entries[at - 1] : undefined;
|
|
350
|
+
if (newer && !isNullId(newer.oldId) && newer.oldId !== entry.newId) {
|
|
351
|
+
err.push(
|
|
352
|
+
`warning: log for ref ${found.ref} has gap after ${formatRfc2822Date(entry.who.timestamp, entry.who.tzOffset)}\n`,
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
oid = entry.oldId;
|
|
356
|
+
} else oid = this.gapWarning(entries, k, found.ref, oid, err);
|
|
357
|
+
const line = entry.comment.split("\n")[0] ?? "";
|
|
358
|
+
const msg = line === "" ? "(none)" : line;
|
|
359
|
+
reflogMsg[i] = `(${relativeDate(entry.who.timestamp, this.nowSeconds())}) ${msg}`;
|
|
360
|
+
await appendRef(`${name}@{${base + i}}`, oid, true);
|
|
361
|
+
}
|
|
362
|
+
} else {
|
|
363
|
+
for (const name of av) await appendOneRev(name);
|
|
364
|
+
if (o.allHeads) {
|
|
365
|
+
const from = refNames.length;
|
|
366
|
+
for (const ref of await allRefs()) {
|
|
367
|
+
if (ref.name.startsWith("refs/heads/")) {
|
|
368
|
+
await appendShortRef(ref.name, ref.id, "refs/heads/");
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
sortRange(from);
|
|
372
|
+
}
|
|
373
|
+
if (o.allRemotes) {
|
|
374
|
+
const from = refNames.length;
|
|
375
|
+
for (const ref of await allRefs()) {
|
|
376
|
+
if (ref.name.startsWith("refs/remotes/")) {
|
|
377
|
+
await appendShortRef(ref.name, ref.id, "refs/remotes/");
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
sortRange(from);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
if (o.current && head) {
|
|
385
|
+
if (!refNames.some((n) => revIsHead(head.name, n))) {
|
|
386
|
+
await appendOneRev(head.name.startsWith("refs/heads/") ? head.name.slice(11) : head.name);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (refNames.length === 0) {
|
|
391
|
+
err.push("No revs to be shown.\n");
|
|
392
|
+
return 0;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const nodes = new Map<ObjectId, Node>();
|
|
396
|
+
const node = (id: ObjectId): Node => {
|
|
397
|
+
let n = nodes.get(id);
|
|
398
|
+
if (!n) {
|
|
399
|
+
n = { id, date: 0, flags: 0 };
|
|
400
|
+
nodes.set(id, n);
|
|
401
|
+
}
|
|
402
|
+
return n;
|
|
403
|
+
};
|
|
404
|
+
const parse = async (n: Node) => {
|
|
405
|
+
if (n.parents) return;
|
|
406
|
+
const commit = await this.walkCommits.load(n.id);
|
|
407
|
+
if (!commit) {
|
|
408
|
+
n.parents = [];
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
n.date = commit.committer.timestamp;
|
|
412
|
+
n.subject = commitSubject(commit.message);
|
|
413
|
+
n.parents = commit.parents.map(node);
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
const numRev = refNames.length;
|
|
417
|
+
// git looks every name up again (repo_get_oid, lookup_commit_reference): `HEAD@{n}`
|
|
418
|
+
// reads HEAD's own reflog, and an ambiguous name warns once more
|
|
419
|
+
for (let i = 0; i < numRev; i++) {
|
|
420
|
+
const name = refNames[i] as string;
|
|
421
|
+
const id = await getOid(name);
|
|
422
|
+
if (id === undefined) throw new Death(`fatal: '${name}' is not a valid ref.`, 128);
|
|
423
|
+
const peeled = await resolver.peelTags(id).catch(() => undefined);
|
|
424
|
+
if (peeled?.type !== "commit") {
|
|
425
|
+
throw new Death(`fatal: cannot find commit ${name} (${id})`, 128);
|
|
426
|
+
}
|
|
427
|
+
refCommits[i] = peeled.id;
|
|
428
|
+
}
|
|
429
|
+
const rev: Node[] = [];
|
|
430
|
+
const seen: Node[] = [];
|
|
431
|
+
/** mark_seen: commit_list_insert, so the list is newest-inserted first */
|
|
432
|
+
const markSeen = (n: Node): boolean => {
|
|
433
|
+
if (n.flags) return false;
|
|
434
|
+
seen.unshift(n);
|
|
435
|
+
return true;
|
|
436
|
+
};
|
|
437
|
+
const queue = new DateQueue<Node>();
|
|
438
|
+
for (let i = 0; i < numRev; i++) {
|
|
439
|
+
const flag = 1 << (i + REV_SHIFT);
|
|
440
|
+
const commit = node(refCommits[i] as ObjectId);
|
|
441
|
+
await parse(commit);
|
|
442
|
+
markSeen(commit);
|
|
443
|
+
commit.flags |= flag;
|
|
444
|
+
if (commit.flags === flag) queue.put(commit, commit.date);
|
|
445
|
+
rev.push(commit);
|
|
446
|
+
}
|
|
447
|
+
const revMask = rev.map((c) => c.flags);
|
|
448
|
+
const allMask = (1 << (REV_SHIFT + numRev)) - 1;
|
|
449
|
+
const allRevs = allMask & ~((1 << REV_SHIFT) - 1);
|
|
450
|
+
|
|
451
|
+
if (o.extra >= 0) {
|
|
452
|
+
// join_revs
|
|
453
|
+
let extra = o.extra;
|
|
454
|
+
for (let commit = queue.peek(); commit; commit = queue.peek()) {
|
|
455
|
+
const stillInteresting = queue.items().some((c) => !(c.flags & UNINTERESTING));
|
|
456
|
+
let flags = commit.flags & allMask;
|
|
457
|
+
if (!stillInteresting && extra <= 0) break;
|
|
458
|
+
queue.get();
|
|
459
|
+
markSeen(commit);
|
|
460
|
+
if ((flags & allRevs) === allRevs) flags |= UNINTERESTING;
|
|
461
|
+
for (const p of commit.parents ?? []) {
|
|
462
|
+
if ((p.flags & flags) === flags) continue;
|
|
463
|
+
await parse(p);
|
|
464
|
+
if (markSeen(p) && !stillInteresting) extra--;
|
|
465
|
+
p.flags |= flags;
|
|
466
|
+
queue.put(p, p.date);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
for (;;) {
|
|
470
|
+
let changed = false;
|
|
471
|
+
for (const c of seen) {
|
|
472
|
+
if ((c.flags & allRevs) !== allRevs && !(c.flags & UNINTERESTING)) continue;
|
|
473
|
+
for (const p of c.parents ?? []) {
|
|
474
|
+
if (!(p.flags & UNINTERESTING)) {
|
|
475
|
+
p.flags |= UNINTERESTING;
|
|
476
|
+
changed = true;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
if (!changed) break;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// commit_list_sort_by_date (stable)
|
|
485
|
+
const indexed = seen.map((n, i) => [n, i] as const);
|
|
486
|
+
indexed.sort((a, b) => b[0].date - a[0].date || a[1] - b[1]);
|
|
487
|
+
let sorted = indexed.map(([n]) => n);
|
|
488
|
+
|
|
489
|
+
if (o.mergeBase) {
|
|
490
|
+
let status = 1;
|
|
491
|
+
for (const c of sorted) {
|
|
492
|
+
const flags = c.flags & allMask;
|
|
493
|
+
if (!(flags & UNINTERESTING) && (flags & allRevs) === allRevs) {
|
|
494
|
+
out.push(`${c.id}\n`);
|
|
495
|
+
status = 0;
|
|
496
|
+
c.flags |= UNINTERESTING;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return status;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (o.independent) {
|
|
503
|
+
for (let i = 0; i < numRev; i++) {
|
|
504
|
+
const c = rev[i] as Node;
|
|
505
|
+
if (c.flags === revMask[i]) out.push(`${c.id}\n`);
|
|
506
|
+
c.flags |= UNINTERESTING;
|
|
507
|
+
}
|
|
508
|
+
return 0;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
const color = (i: number) => (useColor ? (GRAPH_COLUMN_COLORS_ANSI[i % 12] as string) : "");
|
|
512
|
+
const reset = useColor ? "\x1b[m" : "";
|
|
513
|
+
const showOneCommit = async (c: Node, noName: boolean) => {
|
|
514
|
+
const pretty = c.parents && c.subject !== undefined ? c.subject : "(unavailable)";
|
|
515
|
+
const text = pretty.startsWith("[PATCH] ") ? pretty.slice(8) : pretty;
|
|
516
|
+
let prefix = "";
|
|
517
|
+
if (!noName) {
|
|
518
|
+
if (c.name?.head !== undefined) {
|
|
519
|
+
const g = c.name.generation;
|
|
520
|
+
prefix = `[${c.name.head}${g === 0 ? "" : g === 1 ? "^" : `~${g}`}] `;
|
|
521
|
+
} else {
|
|
522
|
+
prefix = `[${await this.abbreviateObjectId(c.id)}] `;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
out.push(`${prefix}${text}\n`);
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
let headAt = -1;
|
|
529
|
+
if (numRev > 1 || o.extra < 0) {
|
|
530
|
+
for (let i = 0; i < numRev; i++) {
|
|
531
|
+
const name = refNames[i] as string;
|
|
532
|
+
const isHead =
|
|
533
|
+
head !== undefined && revIsHead(head.name, name) && head.id === (rev[i] as Node).id;
|
|
534
|
+
if (o.extra < 0) out.push(`${isHead ? "*" : " "} [${name}] `);
|
|
535
|
+
else out.push(`${" ".repeat(i)}${color(i)}${isHead ? "*" : "!"}${reset} [${name}] `);
|
|
536
|
+
if (!o.reflog) await showOneCommit(rev[i] as Node, true);
|
|
537
|
+
else out.push(`${reflogMsg[i]}\n`);
|
|
538
|
+
if (isHead) headAt = i;
|
|
539
|
+
}
|
|
540
|
+
if (o.extra >= 0) out.push(`${"-".repeat(numRev)}\n`);
|
|
541
|
+
}
|
|
542
|
+
if (o.extra < 0) return 0;
|
|
543
|
+
|
|
544
|
+
sorted = sortInTopologicalOrder(sorted, o.sortOrder);
|
|
545
|
+
if (!o.sha1Name && !o.noName) nameCommits(sorted, rev, refNames);
|
|
546
|
+
|
|
547
|
+
let extra = o.extra;
|
|
548
|
+
let shownMergePoint = false;
|
|
549
|
+
for (const c of sorted) {
|
|
550
|
+
const thisFlag = c.flags;
|
|
551
|
+
const isMergePoint = (thisFlag & allRevs) === allRevs;
|
|
552
|
+
shownMergePoint ||= isMergePoint;
|
|
553
|
+
if (numRev > 1) {
|
|
554
|
+
const isMerge = (c.parents?.length ?? 0) > 1;
|
|
555
|
+
if (o.topics && !isMergePoint && thisFlag & (1 << REV_SHIFT)) continue;
|
|
556
|
+
if (!o.sparse && isMerge && omitInDense(c, rev)) continue;
|
|
557
|
+
let marks = "";
|
|
558
|
+
for (let i = 0; i < numRev; i++) {
|
|
559
|
+
if (!(thisFlag & (1 << (i + REV_SHIFT)))) marks += " ";
|
|
560
|
+
else marks += `${color(i)}${isMerge ? "-" : i === headAt ? "*" : "+"}${reset}`;
|
|
561
|
+
}
|
|
562
|
+
out.push(`${marks} `);
|
|
563
|
+
}
|
|
564
|
+
await showOneCommit(c, o.noName);
|
|
565
|
+
if (shownMergePoint && --extra < 0) break;
|
|
566
|
+
}
|
|
567
|
+
return 0;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* read_ref_at's choice of the id of reflog entry `k` (newest first): the entry's new id
|
|
572
|
+
* when a newer entry exists (with git's warning when it does not follow on), else the
|
|
573
|
+
* ref's value `current` (with git's warning when the newest entry differs).
|
|
574
|
+
*/
|
|
575
|
+
private gapWarning(
|
|
576
|
+
entries: { oldId: ObjectId; newId: ObjectId; who: { timestamp: number; tzOffset: string } }[],
|
|
577
|
+
k: number,
|
|
578
|
+
ref: string,
|
|
579
|
+
current: ObjectId | undefined,
|
|
580
|
+
err: string[],
|
|
581
|
+
): ObjectId {
|
|
582
|
+
const entry = entries[k] as (typeof entries)[number];
|
|
583
|
+
const date = () => formatRfc2822Date(entry.who.timestamp, entry.who.tzOffset);
|
|
584
|
+
const newer = k > 0 ? entries[k - 1] : undefined;
|
|
585
|
+
if (newer && !isNullId(newer.oldId)) {
|
|
586
|
+
if (newer.oldId !== entry.newId)
|
|
587
|
+
err.push(`warning: log for ref ${ref} has gap after ${date()}\n`);
|
|
588
|
+
return entry.newId;
|
|
589
|
+
}
|
|
590
|
+
if (current !== undefined && entry.newId !== current) {
|
|
591
|
+
err.push(`warning: log for ref ${ref} unexpectedly ended on ${date()}\n`);
|
|
592
|
+
return current;
|
|
593
|
+
}
|
|
594
|
+
return current ?? entry.newId;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
private nowSeconds(): number {
|
|
598
|
+
return this.now ?? Math.floor(Date.now() / 1000);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/** refs_resolve_refdup("HEAD", RESOLVE_REF_READING): the ref HEAD ends at, and its value. */
|
|
602
|
+
private async readHead(): Promise<{ name: string; id: ObjectId } | undefined> {
|
|
603
|
+
let name = "HEAD";
|
|
604
|
+
for (let depth = 0; depth < 5; depth++) {
|
|
605
|
+
const ref = await this.refsStore.get(name).catch(() => undefined);
|
|
606
|
+
if (!ref) return undefined;
|
|
607
|
+
if ("target" in ref && ref.target) {
|
|
608
|
+
name = ref.target;
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
const id = "objectId" in ref ? ref.objectId : undefined;
|
|
612
|
+
return id ? { name, id } : undefined;
|
|
613
|
+
}
|
|
614
|
+
return undefined;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/** parse-options over show-branch's options (PARSE_OPT_STOP_AT_NON_OPTION): the rest. */
|
|
619
|
+
function parseArguments(argv: readonly string[], o: Options): string[] {
|
|
620
|
+
const usageError = (line: string): never => {
|
|
621
|
+
throw new Death(line, 129);
|
|
622
|
+
};
|
|
623
|
+
const setReflog = (arg: string | undefined) => {
|
|
624
|
+
const n = parseUnsigned(arg ?? "");
|
|
625
|
+
o.reflog = n.value;
|
|
626
|
+
if (n.rest.startsWith(",")) o.reflogBase = n.rest.slice(1);
|
|
627
|
+
else if (n.rest.length > 0) usageError(`error: unrecognized reflog param '${arg}'`);
|
|
628
|
+
else o.reflogBase = undefined;
|
|
629
|
+
if (o.reflog <= 0) o.reflog = DEFAULT_REFLOG;
|
|
630
|
+
};
|
|
631
|
+
let i = 0;
|
|
632
|
+
for (; i < argv.length; i++) {
|
|
633
|
+
const arg = argv[i] as string;
|
|
634
|
+
if (arg === "--") {
|
|
635
|
+
i++;
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
if (arg === "-h") throw new Death(USAGE, 129);
|
|
639
|
+
if (arg.startsWith("--")) {
|
|
640
|
+
const eq = arg.indexOf("=");
|
|
641
|
+
const word = eq < 0 ? arg.slice(2) : arg.slice(2, eq);
|
|
642
|
+
const value = eq < 0 ? undefined : arg.slice(eq + 1);
|
|
643
|
+
const { option, unset } = findLongOption(word, arg, usageError);
|
|
644
|
+
if (value !== undefined && (unset || !option.arg)) {
|
|
645
|
+
usageError(`error: option \`${unset ? `no-${option.name}` : option.name}' takes no value`);
|
|
646
|
+
}
|
|
647
|
+
switch (option.name) {
|
|
648
|
+
case "all":
|
|
649
|
+
o.allHeads = !unset;
|
|
650
|
+
break;
|
|
651
|
+
case "remotes":
|
|
652
|
+
o.allRemotes = !unset;
|
|
653
|
+
break;
|
|
654
|
+
case "color":
|
|
655
|
+
if (unset) o.color = false;
|
|
656
|
+
else if (value === undefined) o.color = true;
|
|
657
|
+
else {
|
|
658
|
+
const v = value.toLowerCase();
|
|
659
|
+
if (["always", "yes", "true", "on", "force"].includes(v)) o.color = true;
|
|
660
|
+
else if (["never", "no", "false", "off", "none"].includes(v)) o.color = false;
|
|
661
|
+
else if (["auto", "tty", "if-tty"].includes(v)) o.color = false;
|
|
662
|
+
else usageError(`error: option \`color' expects "always", "auto", or "never"`);
|
|
663
|
+
}
|
|
664
|
+
break;
|
|
665
|
+
case "more":
|
|
666
|
+
if (unset) o.extra = 0;
|
|
667
|
+
else if (value === undefined) o.extra = 1;
|
|
668
|
+
else {
|
|
669
|
+
if (!/^-?\d+$/.test(value)) {
|
|
670
|
+
usageError(
|
|
671
|
+
`error: option \`more' expects an integer value with an optional k/m/g suffix`,
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
o.extra = Number.parseInt(value, 10);
|
|
675
|
+
}
|
|
676
|
+
break;
|
|
677
|
+
case "list":
|
|
678
|
+
o.extra = unset ? 0 : -1;
|
|
679
|
+
break;
|
|
680
|
+
case "no-name":
|
|
681
|
+
o.noName = !unset;
|
|
682
|
+
break;
|
|
683
|
+
case "current":
|
|
684
|
+
o.current = !unset;
|
|
685
|
+
break;
|
|
686
|
+
case "sha1-name":
|
|
687
|
+
o.sha1Name = !unset;
|
|
688
|
+
break;
|
|
689
|
+
case "merge-base":
|
|
690
|
+
o.mergeBase = !unset;
|
|
691
|
+
break;
|
|
692
|
+
case "independent":
|
|
693
|
+
o.independent = !unset;
|
|
694
|
+
break;
|
|
695
|
+
case "topo-order":
|
|
696
|
+
o.sortOrder = "topo";
|
|
697
|
+
break;
|
|
698
|
+
case "topics":
|
|
699
|
+
o.topics = !unset;
|
|
700
|
+
break;
|
|
701
|
+
case "sparse":
|
|
702
|
+
o.sparse = !unset;
|
|
703
|
+
break;
|
|
704
|
+
case "date-order":
|
|
705
|
+
o.sortOrder = "date";
|
|
706
|
+
break;
|
|
707
|
+
case "reflog":
|
|
708
|
+
setReflog(value);
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
if (arg.startsWith("-") && arg.length > 1) {
|
|
714
|
+
for (let k = 1; k < arg.length; k++) {
|
|
715
|
+
const c = arg[k] as string;
|
|
716
|
+
if (c === "a") o.allHeads = true;
|
|
717
|
+
else if (c === "r") o.allRemotes = true;
|
|
718
|
+
else if (c === "h") throw new Death(USAGE, 129);
|
|
719
|
+
else if (c === "g") {
|
|
720
|
+
const rest = arg.slice(k + 1);
|
|
721
|
+
setReflog(rest.length > 0 ? rest : undefined);
|
|
722
|
+
break;
|
|
723
|
+
} else usageError(`error: unknown switch \`${c}'`);
|
|
724
|
+
}
|
|
725
|
+
continue;
|
|
726
|
+
}
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
729
|
+
return argv.slice(i);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/** parse_long_opt: an exact name, `no-<name>`, `<name>` for a `no-` option, or a unique prefix. */
|
|
733
|
+
function findLongOption(
|
|
734
|
+
word: string,
|
|
735
|
+
arg: string,
|
|
736
|
+
usageError: (line: string) => never,
|
|
737
|
+
): { option: (typeof LONG_OPTIONS)[number]; unset: boolean } {
|
|
738
|
+
const candidates: { option: (typeof LONG_OPTIONS)[number]; unset: boolean }[] = [];
|
|
739
|
+
for (const option of LONG_OPTIONS) {
|
|
740
|
+
const forms: { text: string; unset: boolean }[] = [{ text: option.name, unset: false }];
|
|
741
|
+
if (option.name.startsWith("no-")) forms.push({ text: option.name.slice(3), unset: true });
|
|
742
|
+
else forms.push({ text: `no-${option.name}`, unset: true });
|
|
743
|
+
for (const form of forms) {
|
|
744
|
+
if (form.text === word) {
|
|
745
|
+
if (form.unset && !option.negatable) usageError(`error: unknown option \`${word}'`);
|
|
746
|
+
return { option, unset: form.unset };
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
for (const form of forms) {
|
|
750
|
+
if (word.length > 0 && form.text.startsWith(word) && (option.negatable || !form.unset)) {
|
|
751
|
+
candidates.push({ option, unset: form.unset });
|
|
752
|
+
break;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
if (candidates.length === 1) return candidates[0] as (typeof candidates)[number];
|
|
757
|
+
if (candidates.length > 1) {
|
|
758
|
+
const [a, b] = candidates as [(typeof candidates)[number], (typeof candidates)[number]];
|
|
759
|
+
const label = (c: (typeof candidates)[number]) =>
|
|
760
|
+
c.unset
|
|
761
|
+
? c.option.name.startsWith("no-")
|
|
762
|
+
? c.option.name.slice(3)
|
|
763
|
+
: `no-${c.option.name}`
|
|
764
|
+
: c.option.name;
|
|
765
|
+
usageError(`error: ambiguous option: ${word} (could be --${label(a)} or --${label(b)})`);
|
|
766
|
+
}
|
|
767
|
+
return usageError(`error: unknown option \`${arg.slice(2).split("=")[0]}'`);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/** strtoul's digits: the value and what follows them. */
|
|
771
|
+
function parseUnsigned(text: string): { value: number; rest: string } {
|
|
772
|
+
const m = /^\s*\+?(\d*)/.exec(text) as RegExpExecArray;
|
|
773
|
+
const digits = m[1] ?? "";
|
|
774
|
+
if (digits.length === 0) return { value: 0, rest: text };
|
|
775
|
+
return { value: Number.parseInt(digits, 10), rest: text.slice(m[0].length) };
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/** An all-zero object id (a creation's old id). */
|
|
779
|
+
const isNullId = (id: string) => /^0+$/.test(id);
|
|
780
|
+
|
|
781
|
+
function countSlashes(s: string): number {
|
|
782
|
+
let n = 0;
|
|
783
|
+
for (const c of s) if (c === "/") n++;
|
|
784
|
+
return n;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
/** show-branch.c's version_cmp: runs of digits compared as numbers, the rest by byte. */
|
|
788
|
+
export function versionCmp(a: string, b: string): number {
|
|
789
|
+
let i = 0;
|
|
790
|
+
let j = 0;
|
|
791
|
+
const digitAt = (s: string, k: number) => {
|
|
792
|
+
const c = s.charCodeAt(k);
|
|
793
|
+
return c >= 0x30 && c <= 0x39;
|
|
794
|
+
};
|
|
795
|
+
for (;;) {
|
|
796
|
+
let va = 0;
|
|
797
|
+
let vb = 0;
|
|
798
|
+
while (i < a.length && digitAt(a, i)) va = va * 10 + a.charCodeAt(i++) - 0x30;
|
|
799
|
+
while (j < b.length && digitAt(b, j)) vb = vb * 10 + b.charCodeAt(j++) - 0x30;
|
|
800
|
+
if (va !== vb) return va - vb;
|
|
801
|
+
for (;;) {
|
|
802
|
+
const ca = i < a.length && !digitAt(a, i) ? a.charCodeAt(i) : 0;
|
|
803
|
+
const cb = j < b.length && !digitAt(b, j) ? b.charCodeAt(j) : 0;
|
|
804
|
+
if (ca !== cb) return ca - cb;
|
|
805
|
+
if (!ca) break;
|
|
806
|
+
i++;
|
|
807
|
+
j++;
|
|
808
|
+
}
|
|
809
|
+
if (i >= a.length && j >= b.length) return 0;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/** rev_is_head: whether a rev's name is the branch HEAD is at. */
|
|
814
|
+
function revIsHead(head: string, name: string): boolean {
|
|
815
|
+
const h = head.startsWith("refs/heads/") ? head.slice(11) : head;
|
|
816
|
+
const n = name.startsWith("refs/heads/")
|
|
817
|
+
? name.slice(11)
|
|
818
|
+
: name.startsWith("heads/")
|
|
819
|
+
? name.slice(6)
|
|
820
|
+
: name;
|
|
821
|
+
return h === n;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/** omit_in_dense: a merge (not a tip) reachable from only one tip. */
|
|
825
|
+
function omitInDense(c: Node, rev: Node[]): boolean {
|
|
826
|
+
if (rev.includes(c)) return false;
|
|
827
|
+
let count = 0;
|
|
828
|
+
for (let i = 0; i < rev.length; i++) if (c.flags & (1 << (i + REV_SHIFT))) count++;
|
|
829
|
+
return count === 1;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
/** name_commits: tips, their first-parent chains, then the other parents (`x^2`, `x~3^`). */
|
|
833
|
+
function nameCommits(list: Node[], rev: Node[], refNames: string[]): void {
|
|
834
|
+
const nameParent = (c: Node, p: Node) => {
|
|
835
|
+
if (!c.name) return;
|
|
836
|
+
if (!p.name || c.name.generation + 1 < p.name.generation) {
|
|
837
|
+
p.name = { head: c.name.head, generation: c.name.generation + 1 };
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
const nameFirstParentChain = (start: Node): number => {
|
|
841
|
+
let i = 0;
|
|
842
|
+
let c: Node | undefined = start;
|
|
843
|
+
while (c) {
|
|
844
|
+
if (!c.name) break;
|
|
845
|
+
const p: Node | undefined = c.parents?.[0];
|
|
846
|
+
if (!p) break;
|
|
847
|
+
if (p.name) break;
|
|
848
|
+
nameParent(c, p);
|
|
849
|
+
i++;
|
|
850
|
+
c = p;
|
|
851
|
+
}
|
|
852
|
+
return i;
|
|
853
|
+
};
|
|
854
|
+
for (const c of list) {
|
|
855
|
+
if (c.name) continue;
|
|
856
|
+
const i = rev.indexOf(c);
|
|
857
|
+
if (i >= 0) c.name = { head: refNames[i] as string, generation: 0 };
|
|
858
|
+
}
|
|
859
|
+
let named: number;
|
|
860
|
+
do {
|
|
861
|
+
named = 0;
|
|
862
|
+
for (const c of list) named += nameFirstParentChain(c);
|
|
863
|
+
} while (named);
|
|
864
|
+
do {
|
|
865
|
+
named = 0;
|
|
866
|
+
for (const c of list) {
|
|
867
|
+
const n = c.name;
|
|
868
|
+
if (!n) continue;
|
|
869
|
+
let nth = 0;
|
|
870
|
+
for (const p of c.parents ?? []) {
|
|
871
|
+
nth++;
|
|
872
|
+
if (p.name) continue;
|
|
873
|
+
let name =
|
|
874
|
+
n.generation === 0
|
|
875
|
+
? n.head
|
|
876
|
+
: n.generation === 1
|
|
877
|
+
? `${n.head}^`
|
|
878
|
+
: `${n.head}~${n.generation}`;
|
|
879
|
+
name += nth === 1 ? "^" : `^${nth}`;
|
|
880
|
+
p.name = { head: name, generation: 0 };
|
|
881
|
+
named++;
|
|
882
|
+
nameFirstParentChain(p);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
} while (named);
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
/** commit.c's sort_in_topological_order over parsed parents (graph order or commit date). */
|
|
889
|
+
function sortInTopologicalOrder(list: Node[], order: "topo" | "date"): Node[] {
|
|
890
|
+
if (list.length === 0) return list;
|
|
891
|
+
const indegree = new Map<Node, number>();
|
|
892
|
+
for (const n of list) indegree.set(n, 1);
|
|
893
|
+
for (const n of list) {
|
|
894
|
+
for (const p of n.parents ?? []) {
|
|
895
|
+
const d = indegree.get(p);
|
|
896
|
+
if (d) indegree.set(p, d + 1);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
let put: (n: Node) => void;
|
|
900
|
+
let get: () => Node | undefined;
|
|
901
|
+
if (order === "topo") {
|
|
902
|
+
const stack: Node[] = [];
|
|
903
|
+
for (const n of list) if (indegree.get(n) === 1) stack.push(n);
|
|
904
|
+
stack.reverse();
|
|
905
|
+
put = (n) => stack.push(n);
|
|
906
|
+
get = () => stack.pop();
|
|
907
|
+
} else {
|
|
908
|
+
const queue = new DateQueue<Node>();
|
|
909
|
+
put = (n) => queue.put(n, n.date);
|
|
910
|
+
get = () => queue.get();
|
|
911
|
+
for (const n of list) if (indegree.get(n) === 1) put(n);
|
|
912
|
+
}
|
|
913
|
+
const out: Node[] = [];
|
|
914
|
+
for (let n = get(); n !== undefined; n = get()) {
|
|
915
|
+
for (const p of n.parents ?? []) {
|
|
916
|
+
const d = indegree.get(p);
|
|
917
|
+
if (!d) continue;
|
|
918
|
+
indegree.set(p, d - 1);
|
|
919
|
+
if (d - 1 === 1) put(p);
|
|
920
|
+
}
|
|
921
|
+
indegree.set(n, 0);
|
|
922
|
+
out.push(n);
|
|
923
|
+
}
|
|
924
|
+
return out;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* git's prio_queue with compare_commits_by_commit_date: the newest first, entries of one date
|
|
929
|
+
* in the order they were put. A binary heap, so `items()` is prio_queue_for_each's order.
|
|
930
|
+
*/
|
|
931
|
+
class DateQueue<T> {
|
|
932
|
+
private readonly heap: { item: T; date: number; ctr: number }[] = [];
|
|
933
|
+
private ctr = 0;
|
|
934
|
+
|
|
935
|
+
put(item: T, date: number): void {
|
|
936
|
+
const h = this.heap;
|
|
937
|
+
h.push({ item, date, ctr: this.ctr++ });
|
|
938
|
+
let ix = h.length - 1;
|
|
939
|
+
while (ix > 0) {
|
|
940
|
+
const parent = (ix - 1) >> 1;
|
|
941
|
+
if (this.before(parent, ix)) break;
|
|
942
|
+
[h[parent], h[ix]] = [h[ix] as (typeof h)[number], h[parent] as (typeof h)[number]];
|
|
943
|
+
ix = parent;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
get(): T | undefined {
|
|
948
|
+
const h = this.heap;
|
|
949
|
+
if (h.length === 0) return undefined;
|
|
950
|
+
const top = h[0] as (typeof h)[number];
|
|
951
|
+
const last = h.pop() as (typeof h)[number];
|
|
952
|
+
if (h.length > 0) {
|
|
953
|
+
h[0] = last;
|
|
954
|
+
let ix = 0;
|
|
955
|
+
for (;;) {
|
|
956
|
+
let child = 2 * ix + 1;
|
|
957
|
+
if (child >= h.length) break;
|
|
958
|
+
if (child + 1 < h.length && this.before(child + 1, child)) child++;
|
|
959
|
+
if (this.before(ix, child)) break;
|
|
960
|
+
[h[ix], h[child]] = [h[child] as (typeof h)[number], h[ix] as (typeof h)[number]];
|
|
961
|
+
ix = child;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
return top.item;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
peek(): T | undefined {
|
|
968
|
+
return this.heap[0]?.item;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
items(): T[] {
|
|
972
|
+
return this.heap.map((e) => e.item);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
private before(a: number, b: number): boolean {
|
|
976
|
+
const x = this.heap[a] as (typeof this.heap)[number];
|
|
977
|
+
const y = this.heap[b] as (typeof this.heap)[number];
|
|
978
|
+
if (x.date !== y.date) return x.date > y.date;
|
|
979
|
+
return x.ctr < y.ctr;
|
|
980
|
+
}
|
|
981
|
+
}
|