@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,836 @@
|
|
|
1
|
+
import { isSymbolicRef, isValidRefName } from "@statewalker/vcs-core";
|
|
2
|
+
import {
|
|
3
|
+
expandFromDestination,
|
|
4
|
+
expandFromSource,
|
|
5
|
+
lsRefs,
|
|
6
|
+
type MatchedPushRef,
|
|
7
|
+
matchDestination,
|
|
8
|
+
matchPushRefs,
|
|
9
|
+
matchSource,
|
|
10
|
+
PushRefspecError,
|
|
11
|
+
parseRefSpec,
|
|
12
|
+
type RefSpec,
|
|
13
|
+
type RemoteRef as TransportRemoteRef,
|
|
14
|
+
} from "@statewalker/vcs-transport";
|
|
15
|
+
import { parseGitBool } from "@statewalker/vcs-utils";
|
|
16
|
+
|
|
17
|
+
import { GitApiError, MissingArgumentError } from "../errors/index.js";
|
|
18
|
+
import { GuardedTransportCommand } from "../guarded-transport-command.js";
|
|
19
|
+
import { deleteRefs, RemoteConfigStore } from "../remote-config/index.js";
|
|
20
|
+
import { RemoteListCommand } from "./remote-command.js";
|
|
21
|
+
import { withRemoteUploadPack } from "./remote-transport.js";
|
|
22
|
+
|
|
23
|
+
/** What `git remote show` says of one ref a push would update (builtin/remote.c `push_info`). */
|
|
24
|
+
export interface RemotePushInfo {
|
|
25
|
+
/** The local ref, short (`main`), `(delete)` for a deleting refspec, `(matching)` */
|
|
26
|
+
source: string;
|
|
27
|
+
/** The remote ref, short (`main`), or `(matching)` */
|
|
28
|
+
destination: string;
|
|
29
|
+
/** Whether the refspec forces the update (`+`) */
|
|
30
|
+
forced: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* What the push would do (with the remote queried): `create`, `delete`, `up to date`,
|
|
33
|
+
* `fast-forwardable`, `local out of date`; undefined when the remote was not queried
|
|
34
|
+
*/
|
|
35
|
+
status?: "create" | "delete" | "up to date" | "fast-forwardable" | "local out of date";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** A local branch that `git pull` merges from the remote (builtin/remote.c `branch_info`). */
|
|
39
|
+
export interface RemotePullInfo {
|
|
40
|
+
branch: string;
|
|
41
|
+
/** The remote branches it merges, short names (`branch.<name>.merge`) */
|
|
42
|
+
merges: string[];
|
|
43
|
+
/** `branch.<name>.rebase`: none, `true`, `merges` or `interactive` */
|
|
44
|
+
rebase?: "true" | "merges" | "interactive";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** What `git remote show <name>` knows of a remote (builtin/remote.c `ref_states`). */
|
|
48
|
+
export interface RemoteShowInfo {
|
|
49
|
+
name: string;
|
|
50
|
+
fetchUrl: string;
|
|
51
|
+
pushUrls: string[];
|
|
52
|
+
/** Whether the remote was asked for its refs (no `-n`) */
|
|
53
|
+
queried: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The remote's HEAD branch: one name, several when HEAD's commit is at several branches
|
|
56
|
+
* and the remote names none, empty when unknown; undefined when not queried
|
|
57
|
+
*/
|
|
58
|
+
heads?: string[];
|
|
59
|
+
/** The remote's refs the fetch refspecs take that have no tracking ref yet (short names) */
|
|
60
|
+
newRefs: string[];
|
|
61
|
+
/** The remote's refs the fetch refspecs take whose tracking refs exist (short names) */
|
|
62
|
+
tracked: string[];
|
|
63
|
+
/** The remote's refs a negative refspec excludes */
|
|
64
|
+
skipped: string[];
|
|
65
|
+
/** The tracking refs whose remote ref is gone (outside `refs/heads/`: full names) */
|
|
66
|
+
stale: string[];
|
|
67
|
+
/** The local branches `git pull` merges from this remote */
|
|
68
|
+
pull: RemotePullInfo[];
|
|
69
|
+
/** Whether `remote.<name>.mirror` makes `git push` mirror every ref */
|
|
70
|
+
mirror: boolean;
|
|
71
|
+
/** What `git push` does, sorted as git prints it */
|
|
72
|
+
push: RemotePushInfo[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** One remote of {@link RemotePruneCommand}: what was (or would be) pruned. */
|
|
76
|
+
export interface RemotePruneResult {
|
|
77
|
+
name: string;
|
|
78
|
+
url: string;
|
|
79
|
+
/** The tracking refs pruned, full names, in git's order */
|
|
80
|
+
pruned: string[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The commands that read a remote's refs as builtin/remote.c's `get_remote_ref_states`:
|
|
85
|
+
* `git remote show` and `git remote prune`.
|
|
86
|
+
*/
|
|
87
|
+
abstract class RemoteStatesCommand<T> extends GuardedTransportCommand<T> {
|
|
88
|
+
/** git's command reads no core settings: an unparsable `core.whitespace` does not stop it */
|
|
89
|
+
protected override readsCoreConfig(): boolean {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected messages: string[] = [];
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* What git prints on stderr besides the output: legacy-remote warnings (2.5x), `more than
|
|
97
|
+
* one branch.<name>.remote`, `invalid branch.<name>.merge`. Empty before the call.
|
|
98
|
+
*/
|
|
99
|
+
getMessages(): string[] {
|
|
100
|
+
return [...this.messages];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Reads the legacy remotes of `names` (git's remote_get) and decides who gets the static
|
|
105
|
+
* credentials and headers from the URLs of every remote this call asks (see
|
|
106
|
+
* `GuardedTransportCommand`), before the first connection.
|
|
107
|
+
*/
|
|
108
|
+
protected async prepareRemotes(names: readonly string[]): Promise<void> {
|
|
109
|
+
for (const name of names) this.messages.push(...(await this.loadLegacyRemote(name)));
|
|
110
|
+
const store = RemoteConfigStore.from(this.workingCopy);
|
|
111
|
+
const head = await this.refsStore.get("HEAD");
|
|
112
|
+
const branch =
|
|
113
|
+
head && isSymbolicRef(head) && head.target.startsWith("refs/heads/")
|
|
114
|
+
? head.target.slice("refs/heads/".length)
|
|
115
|
+
: undefined;
|
|
116
|
+
this.resolveAuth(
|
|
117
|
+
names.map((name) => this.urlsOf(store, name).fetch),
|
|
118
|
+
store.urlFor(store.remoteForBranch(branch)),
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** The remote as `remote_get` gives it: its first URL and its push URLs. */
|
|
123
|
+
protected urlsOf(store: RemoteConfigStore, name: string): { fetch: string; push: string[] } {
|
|
124
|
+
const fetch = store.remoteUrlOf(name);
|
|
125
|
+
const push = store.isConfigured(name) ? store.remotePushUrls(name) : [];
|
|
126
|
+
return { fetch, push: push.length > 0 ? push : [store.remoteUrlOf(name, { push: true })] };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Every ref the remote advertises (transport_get_remote_refs without prefixes). */
|
|
130
|
+
protected async remoteRefs(name: string, url: string): Promise<readonly TransportRemoteRef[]> {
|
|
131
|
+
const program = this.remoteProgram(name, "uploadpack");
|
|
132
|
+
return withRemoteUploadPack(
|
|
133
|
+
await this.prepareRemote(url),
|
|
134
|
+
{ ...this.remoteSessionOptions(), ...(program !== undefined ? { program } : {}) },
|
|
135
|
+
async (connection) =>
|
|
136
|
+
connection.version === 2 ? lsRefs(connection, []) : (connection.advertisedRefs ?? []),
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* git's get_ref_states: the remote refs the fetch refspecs map (new, tracked, or skipped
|
|
142
|
+
* by a negative refspec) and the tracking refs whose remote ref is gone (get_stale_heads).
|
|
143
|
+
*/
|
|
144
|
+
protected async refStates(
|
|
145
|
+
specs: RefSpec[],
|
|
146
|
+
remoteRefs: readonly TransportRemoteRef[],
|
|
147
|
+
): Promise<{
|
|
148
|
+
newRefs: string[];
|
|
149
|
+
tracked: string[];
|
|
150
|
+
skipped: string[];
|
|
151
|
+
/** The stale tracking refs: `short` as git shows them, `ref` in full; by `short` */
|
|
152
|
+
stale: { short: string; ref: string }[];
|
|
153
|
+
}> {
|
|
154
|
+
const fetchMap: { name: string; peer?: string }[] = [];
|
|
155
|
+
for (const spec of specs) {
|
|
156
|
+
if (spec.negative) continue;
|
|
157
|
+
if (spec.wildcard) {
|
|
158
|
+
// get_expanded_map: a local symbolic ref is never updated
|
|
159
|
+
for (const ref of remoteRefs) {
|
|
160
|
+
if (ref.name.includes("^") || !spec.source || !matchSource(spec, ref.name)) continue;
|
|
161
|
+
const peer = spec.destination
|
|
162
|
+
? (expandFromSource(spec, ref.name).destination ?? undefined)
|
|
163
|
+
: undefined;
|
|
164
|
+
if (peer !== undefined) {
|
|
165
|
+
const local = await this.refsStore.get(peer);
|
|
166
|
+
if (local && isSymbolicRef(local)) continue;
|
|
167
|
+
}
|
|
168
|
+
if (peer !== undefined && !funnyRef(peer)) fetchMap.push({ name: ref.name, peer });
|
|
169
|
+
else if (peer === undefined) fetchMap.push({ name: ref.name });
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
const wanted = spec.source ? spec.source : "HEAD";
|
|
173
|
+
const ref = findRefByNameAbbrev(remoteRefs, wanted);
|
|
174
|
+
if (!ref) continue;
|
|
175
|
+
const peer = localRefName(spec.destination);
|
|
176
|
+
if (peer !== undefined && funnyRef(peer)) continue;
|
|
177
|
+
fetchMap.push({ name: ref.name, ...(peer !== undefined ? { peer } : {}) });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const negative = specs.filter((s) => s.negative && s.source);
|
|
181
|
+
const newRefs = new Set<string>();
|
|
182
|
+
const tracked = new Set<string>();
|
|
183
|
+
const skipped = new Set<string>();
|
|
184
|
+
for (const ref of fetchMap) {
|
|
185
|
+
if (negative.some((n) => matchSource(n, ref.name))) skipped.add(abbrevBranch(ref.name));
|
|
186
|
+
else if (!ref.peer || !(await this.refExists(ref.peer))) newRefs.add(abbrevBranch(ref.name));
|
|
187
|
+
else tracked.add(abbrevBranch(ref.name));
|
|
188
|
+
}
|
|
189
|
+
const names = new Set(fetchMap.map((r) => r.name));
|
|
190
|
+
const stale: string[] = [];
|
|
191
|
+
for await (const ref of this.refsStore.list("refs/")) {
|
|
192
|
+
const sources = trackingSources(specs, ref.name);
|
|
193
|
+
if (!sources || sources.length === 0 || isSymbolicRef(ref)) continue;
|
|
194
|
+
if (!sources.some((s) => names.has(s))) stale.push(ref.name);
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
newRefs: sortBytes([...newRefs]),
|
|
198
|
+
tracked: sortBytes([...tracked]),
|
|
199
|
+
skipped: sortBytes([...skipped]),
|
|
200
|
+
stale: stale
|
|
201
|
+
.map((ref) => ({ short: abbrevBranch(ref), ref }))
|
|
202
|
+
.sort((a, b) => compareBytes(a.short, b.short)),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** git's refs_ref_exists: the ref resolves to an object. */
|
|
207
|
+
private async refExists(name: string): Promise<boolean> {
|
|
208
|
+
return !!(await this.refsStore.resolve(name))?.objectId;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* The symbolic refs whose target is one of `names` (refs_warn_dangling_symrefs), sorted:
|
|
213
|
+
* `[name, target]`.
|
|
214
|
+
*/
|
|
215
|
+
protected async danglingSymrefs(names: Set<string>): Promise<[string, string][]> {
|
|
216
|
+
const found: [string, string][] = [];
|
|
217
|
+
for await (const ref of this.refsStore.list("refs/")) {
|
|
218
|
+
if (!isSymbolicRef(ref)) continue;
|
|
219
|
+
let target = ref.target;
|
|
220
|
+
for (let i = 0; i < 5; i++) {
|
|
221
|
+
const next = await this.refsStore.get(target);
|
|
222
|
+
if (!next || !isSymbolicRef(next)) break;
|
|
223
|
+
target = next.target;
|
|
224
|
+
}
|
|
225
|
+
if (names.has(target)) found.push([ref.name, target]);
|
|
226
|
+
}
|
|
227
|
+
return found.sort((a, b) => compareBytes(a[0], b[0]));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* What git knows of a remote: `git remote show [-n] <name>...`.
|
|
233
|
+
*
|
|
234
|
+
* As builtin/remote.c `show`: the remote's URLs; unless {@link setNoQuery} (`-n`), the
|
|
235
|
+
* remote is asked for its refs through the command's transports (as `git fetch` reaches it),
|
|
236
|
+
* which gives its HEAD branch (the branch HEAD's symref names, else every branch at HEAD's
|
|
237
|
+
* commit), the state of each branch the fetch refspecs take (`tracked`, `new (next fetch will
|
|
238
|
+
* store in remotes/<name>)`, `skipped` by a negative refspec, and the tracking refs whose
|
|
239
|
+
* branch is gone, `stale`) and what `git push` would do to each remote ref (`create`, `up to
|
|
240
|
+
* date`, `fast-forwardable`, `local out of date`, `delete`); with `-n` nothing is asked and
|
|
241
|
+
* the tracking refs are listed from the refspecs alone. The local branches `git pull` merges
|
|
242
|
+
* from the remote (`branch.<name>.remote`, `.merge`, `.rebase`) are listed either way. Without
|
|
243
|
+
* a remote name it is `git remote` ({@link RemoteListCommand}).
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* const text = await git.remoteShow().setRemoteNames("origin").callText();
|
|
248
|
+
* // "* remote origin\n Fetch URL: ...\n HEAD branch: main\n Remote branches:\n ..."
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
export class RemoteShowCommand extends RemoteStatesCommand<RemoteShowInfo[]> {
|
|
252
|
+
private names: string[] = [];
|
|
253
|
+
private noQuery = false;
|
|
254
|
+
|
|
255
|
+
/** The remotes to show, in order. */
|
|
256
|
+
setRemoteNames(...names: string[]): this {
|
|
257
|
+
this.checkCallable();
|
|
258
|
+
this.names = [...names];
|
|
259
|
+
return this;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** Do not ask the remotes for their refs (`-n`). */
|
|
263
|
+
setNoQuery(noQuery: boolean): this {
|
|
264
|
+
this.checkCallable();
|
|
265
|
+
this.noQuery = noQuery;
|
|
266
|
+
return this;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* @returns what git knows of each remote
|
|
271
|
+
* @throws the transport's error when a remote cannot be reached (git dies, exit 128)
|
|
272
|
+
*/
|
|
273
|
+
async call(): Promise<RemoteShowInfo[]> {
|
|
274
|
+
this.checkCallable();
|
|
275
|
+
this.setCallable(false);
|
|
276
|
+
const infos: RemoteShowInfo[] = [];
|
|
277
|
+
if (!this.noQuery) await this.prepareRemotes(this.names);
|
|
278
|
+
else for (const name of this.names) this.messages.push(...(await this.loadLegacyRemote(name)));
|
|
279
|
+
for (const name of this.names) infos.push(await this.collect(name));
|
|
280
|
+
return infos;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* What `git remote show` prints on stdout: per remote, `* remote <name>`, ` Fetch URL:`,
|
|
285
|
+
* ` Push URL:` lines, ` HEAD branch:`, ` Remote branches:` with each branch's state,
|
|
286
|
+
* ` Local branches configured for 'git pull':` and ` Local refs configured for 'git
|
|
287
|
+
* push':`, columns as wide as git makes them. Without remote names, `git remote`'s list.
|
|
288
|
+
*
|
|
289
|
+
* @throws the transport's error when a remote cannot be reached (git dies, exit 128); the
|
|
290
|
+
* text of the remotes shown before it is on the error as `stdout`
|
|
291
|
+
*/
|
|
292
|
+
async callText(): Promise<string> {
|
|
293
|
+
this.checkCallable();
|
|
294
|
+
if (this.names.length === 0) {
|
|
295
|
+
this.setCallable(false);
|
|
296
|
+
return new RemoteListCommand(this._workingCopy).callText();
|
|
297
|
+
}
|
|
298
|
+
this.setCallable(false);
|
|
299
|
+
if (!this.noQuery) await this.prepareRemotes(this.names);
|
|
300
|
+
else for (const name of this.names) this.messages.push(...(await this.loadLegacyRemote(name)));
|
|
301
|
+
let out = "";
|
|
302
|
+
for (const name of this.names) {
|
|
303
|
+
let info: RemoteShowInfo;
|
|
304
|
+
try {
|
|
305
|
+
info = await this.collect(name);
|
|
306
|
+
} catch (error) {
|
|
307
|
+
if (error instanceof Error) Object.assign(error, { stdout: out });
|
|
308
|
+
throw error;
|
|
309
|
+
}
|
|
310
|
+
out += formatShow(info, this.noQuery);
|
|
311
|
+
}
|
|
312
|
+
return out;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
private async collect(name: string): Promise<RemoteShowInfo> {
|
|
316
|
+
const store = RemoteConfigStore.from(this.workingCopy);
|
|
317
|
+
const specs = store.configuredFetchRefspecs(name).map((s) => parseRefSpec(s));
|
|
318
|
+
const urls = this.urlsOf(store, name);
|
|
319
|
+
const mirror = parseGitBool(store.value(`remote.${name}.mirror`)) === true;
|
|
320
|
+
const pushSpecs = store.pushRefspecs(name);
|
|
321
|
+
const info: RemoteShowInfo = {
|
|
322
|
+
name,
|
|
323
|
+
fetchUrl: urls.fetch,
|
|
324
|
+
pushUrls: urls.push,
|
|
325
|
+
queried: !this.noQuery,
|
|
326
|
+
newRefs: [],
|
|
327
|
+
tracked: [],
|
|
328
|
+
skipped: [],
|
|
329
|
+
stale: [],
|
|
330
|
+
pull: [],
|
|
331
|
+
mirror,
|
|
332
|
+
push: [],
|
|
333
|
+
};
|
|
334
|
+
// read_branches comes before the query
|
|
335
|
+
const branches = readBranches(store, this.messages);
|
|
336
|
+
if (!this.noQuery) {
|
|
337
|
+
const refs = await this.remoteRefs(name, urls.fetch);
|
|
338
|
+
const states = await this.refStates(specs, refs);
|
|
339
|
+
info.newRefs = states.newRefs;
|
|
340
|
+
info.tracked = states.tracked;
|
|
341
|
+
info.skipped = states.skipped;
|
|
342
|
+
info.stale = states.stale.map((s) => s.short);
|
|
343
|
+
info.heads = headNames(refs);
|
|
344
|
+
if (!mirror) info.push = await this.pushStates(pushSpecs, refs);
|
|
345
|
+
} else {
|
|
346
|
+
// append_ref_to_tracked_list: every ref the fetch refspecs map back to a remote ref
|
|
347
|
+
const tracked: string[] = [];
|
|
348
|
+
for await (const ref of this.refsStore.list("refs/")) {
|
|
349
|
+
if (isSymbolicRef(ref)) continue;
|
|
350
|
+
const source = trackingSources(specs, ref.name)?.[0];
|
|
351
|
+
if (source !== undefined) tracked.push(abbrevBranch(source));
|
|
352
|
+
}
|
|
353
|
+
info.tracked = sortBytes(tracked);
|
|
354
|
+
if (!mirror) info.push = pushNoQuery(pushSpecs);
|
|
355
|
+
}
|
|
356
|
+
for (const branch of branches) {
|
|
357
|
+
if (branch.merges.length === 0 || branch.remote !== name) continue;
|
|
358
|
+
info.pull.push({
|
|
359
|
+
branch: branch.name,
|
|
360
|
+
merges: branch.merges,
|
|
361
|
+
...(branch.rebase ? { rebase: branch.rebase } : {}),
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
info.push.sort(
|
|
365
|
+
(a, b) => compareBytes(a.source, b.source) || compareBytes(a.destination, b.destination),
|
|
366
|
+
);
|
|
367
|
+
// show_local_info_item: a rebase onto several branches is refused
|
|
368
|
+
for (const pull of info.pull) {
|
|
369
|
+
if (pull.rebase && pull.merges.length > 1) {
|
|
370
|
+
this.messages.push(
|
|
371
|
+
`error: invalid branch.${pull.branch}.merge; cannot rebase onto > 1 branch`,
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return info;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** get_push_ref_states: match_push_refs over the local refs and the remote's. */
|
|
379
|
+
private async pushStates(
|
|
380
|
+
pushSpecs: string[],
|
|
381
|
+
remoteRefs: readonly TransportRemoteRef[],
|
|
382
|
+
): Promise<RemotePushInfo[]> {
|
|
383
|
+
const local = new Map<string, string>();
|
|
384
|
+
for await (const ref of this.refsStore.list("refs/")) {
|
|
385
|
+
if (!isValidRefName(ref.name)) continue;
|
|
386
|
+
const id = isSymbolicRef(ref)
|
|
387
|
+
? (await this.refsStore.resolve(ref.name))?.objectId
|
|
388
|
+
: ref.objectId;
|
|
389
|
+
if (id) local.set(ref.name, id);
|
|
390
|
+
}
|
|
391
|
+
const head = await this.refsStore.get("HEAD");
|
|
392
|
+
const headId = (await this.refsStore.resolve("HEAD"))?.objectId;
|
|
393
|
+
const localState = {
|
|
394
|
+
refs: local,
|
|
395
|
+
head: {
|
|
396
|
+
...(head && isSymbolicRef(head) ? { target: head.target } : {}),
|
|
397
|
+
...(headId ? { oid: headId } : {}),
|
|
398
|
+
},
|
|
399
|
+
hasObject: async (id: string) => this.objectExists(id),
|
|
400
|
+
};
|
|
401
|
+
const match = (specs: string[]) =>
|
|
402
|
+
matchPushRefs(specs, localState, remoteRefs, { objectFormat: this.objectFormat });
|
|
403
|
+
// match_explicit_refs reports a refspec that matches nothing (or too much) and matches
|
|
404
|
+
// the others: such refspecs are left out here
|
|
405
|
+
const specs = pushSpecs.length > 0 ? pushSpecs : [":"];
|
|
406
|
+
const usable: string[] = [];
|
|
407
|
+
for (const spec of specs) {
|
|
408
|
+
try {
|
|
409
|
+
await match([spec]);
|
|
410
|
+
usable.push(spec);
|
|
411
|
+
} catch (error) {
|
|
412
|
+
if (!(error instanceof PushRefspecError)) throw error;
|
|
413
|
+
this.messages.push(`error: ${error.message}`);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (usable.length === 0) return [];
|
|
417
|
+
let matched: MatchedPushRef[];
|
|
418
|
+
try {
|
|
419
|
+
matched = await match(usable);
|
|
420
|
+
} catch (error) {
|
|
421
|
+
if (error instanceof PushRefspecError) return [];
|
|
422
|
+
throw error;
|
|
423
|
+
}
|
|
424
|
+
const nullId = this.objectFormat.nullId;
|
|
425
|
+
const infos: RemotePushInfo[] = [];
|
|
426
|
+
for (const ref of matched) {
|
|
427
|
+
const deleting = ref.newOid === nullId;
|
|
428
|
+
const source = deleting ? "(delete)" : abbrevBranch(ref.localRef ?? ref.source ?? "");
|
|
429
|
+
let status: RemotePushInfo["status"];
|
|
430
|
+
if (deleting) status = "delete";
|
|
431
|
+
else if (ref.oldOid === ref.newOid) status = "up to date";
|
|
432
|
+
else if (ref.oldOid === nullId) status = "create";
|
|
433
|
+
else if (
|
|
434
|
+
(await this.objectExists(ref.oldOid)) &&
|
|
435
|
+
(await this.isNewer(ref.newOid, ref.oldOid))
|
|
436
|
+
)
|
|
437
|
+
status = "fast-forwardable";
|
|
438
|
+
else status = "local out of date";
|
|
439
|
+
infos.push({ source, destination: abbrevBranch(ref.remoteRef), forced: ref.force, status });
|
|
440
|
+
}
|
|
441
|
+
return infos;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/** odb_has_object; a store without its object kernel asks the typed stores. */
|
|
445
|
+
private async objectExists(id: string): Promise<boolean> {
|
|
446
|
+
const objects = this.workingCopy.history.objects;
|
|
447
|
+
if (objects) return objects.has(id).catch(() => false);
|
|
448
|
+
for (const s of [this.commits, this.trees, this.blobs, this.tagsStore]) {
|
|
449
|
+
if (s && (await s.has(id).catch(() => false))) return true;
|
|
450
|
+
}
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/** git's ref_newer: both peel to commits, and `old` is an ancestor of `next`. */
|
|
455
|
+
private async isNewer(next: string, old: string): Promise<boolean> {
|
|
456
|
+
const a = await this.peelToCommit(next);
|
|
457
|
+
const b = await this.peelToCommit(old);
|
|
458
|
+
if (!a || !b) return false;
|
|
459
|
+
return this.commits.isAncestor(b, a);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
private async peelToCommit(id: string): Promise<string | undefined> {
|
|
463
|
+
const tags = this.tagsStore;
|
|
464
|
+
let current: string | undefined = id;
|
|
465
|
+
for (let i = 0; current && i < 16; i++) {
|
|
466
|
+
if (await this.commits.has(current)) return current;
|
|
467
|
+
if (!tags || !(await tags.has(current))) return undefined;
|
|
468
|
+
current = await tags.getTarget(current);
|
|
469
|
+
}
|
|
470
|
+
return undefined;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Delete the tracking refs whose remote branch is gone: `git remote prune [--dry-run]
|
|
476
|
+
* <name>...`.
|
|
477
|
+
*
|
|
478
|
+
* As builtin/remote.c `prune_remote`: the remote is asked for its refs through the command's
|
|
479
|
+
* transports, and every ref its fetch refspecs map from a remote ref the remote no longer has
|
|
480
|
+
* (git's get_stale_heads: not a symbolic ref, not excluded by a negative refspec) is deleted
|
|
481
|
+
* with its reflog in one batch (`remote: prune`). git's output is {@link getOutput}:
|
|
482
|
+
* `Pruning <name>`, `URL: <url>`, ` * [pruned] <name>/<branch>` (` * [would prune] ...` for
|
|
483
|
+
* a dry run), then the symbolic refs left dangling; nothing for a remote with nothing stale.
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```typescript
|
|
487
|
+
* await git.remotePrune().setRemoteNames("origin").call();
|
|
488
|
+
* const preview = git.remotePrune().setRemoteNames("origin").setDryRun(true);
|
|
489
|
+
* await preview.call();
|
|
490
|
+
* console.log(preview.getOutput());
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
493
|
+
export class RemotePruneCommand extends RemoteStatesCommand<RemotePruneResult[]> {
|
|
494
|
+
private names: string[] = [];
|
|
495
|
+
private dryRun = false;
|
|
496
|
+
private output = "";
|
|
497
|
+
|
|
498
|
+
/** The remotes to prune, in order. */
|
|
499
|
+
setRemoteNames(...names: string[]): this {
|
|
500
|
+
this.checkCallable();
|
|
501
|
+
this.names = [...names];
|
|
502
|
+
return this;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/** Report what would be pruned, delete nothing (`--dry-run`). */
|
|
506
|
+
setDryRun(dryRun: boolean): this {
|
|
507
|
+
this.checkCallable();
|
|
508
|
+
this.dryRun = dryRun;
|
|
509
|
+
return this;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/** What git prints on stdout. Empty before {@link call}. */
|
|
513
|
+
getOutput(): string {
|
|
514
|
+
return this.output;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* @returns each remote's pruned refs (empty for one with nothing stale)
|
|
519
|
+
* @throws MissingArgumentError (git: its usage, exit 129) without a remote
|
|
520
|
+
* @throws the transport's error when a remote cannot be reached (git dies, exit 128); what
|
|
521
|
+
* was printed before it is in {@link getOutput}
|
|
522
|
+
* @throws GitApiError (exit 1) when the ref store refused the deletion
|
|
523
|
+
*/
|
|
524
|
+
async call(): Promise<RemotePruneResult[]> {
|
|
525
|
+
this.checkCallable();
|
|
526
|
+
this.setCallable(false);
|
|
527
|
+
if (this.names.length === 0) {
|
|
528
|
+
throw new MissingArgumentError("remoteNames", "usage: git remote prune [<options>] <name>");
|
|
529
|
+
}
|
|
530
|
+
const results: RemotePruneResult[] = [];
|
|
531
|
+
let failure: string | undefined;
|
|
532
|
+
await this.prepareRemotes(this.names);
|
|
533
|
+
for (const name of this.names) {
|
|
534
|
+
const store = RemoteConfigStore.from(this.workingCopy);
|
|
535
|
+
const specs = store.configuredFetchRefspecs(name).map((s) => parseRefSpec(s));
|
|
536
|
+
const url = this.urlsOf(store, name).fetch;
|
|
537
|
+
const states = await this.refStates(specs, await this.remoteRefs(name, url));
|
|
538
|
+
const stale = states.stale.map((s) => s.ref);
|
|
539
|
+
results.push({ name, url, pruned: stale });
|
|
540
|
+
if (stale.length === 0) continue;
|
|
541
|
+
this.output += `Pruning ${name}\nURL: ${url}\n`;
|
|
542
|
+
const toPrune = sortBytes([...stale]);
|
|
543
|
+
if (!this.dryRun) {
|
|
544
|
+
try {
|
|
545
|
+
await deleteRefs(this.refsStore, toPrune, "remote: prune", {
|
|
546
|
+
legacy: this.hooks.compatibility === "2.43",
|
|
547
|
+
});
|
|
548
|
+
} catch (error) {
|
|
549
|
+
failure = error instanceof Error ? error.message : String(error);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
for (const ref of stale) {
|
|
553
|
+
const short = ref.startsWith("refs/remotes/") ? ref.slice("refs/remotes/".length) : ref;
|
|
554
|
+
this.output += ` * [${this.dryRun ? "would prune" : "pruned"}] ${short}\n`;
|
|
555
|
+
}
|
|
556
|
+
// git 2.43 names the symbolic ref alone
|
|
557
|
+
const legacy = this.hooks.compatibility === "2.43";
|
|
558
|
+
for (const [symref, target] of await this.danglingSymrefs(new Set(toPrune))) {
|
|
559
|
+
if (legacy) {
|
|
560
|
+
this.output += ` ${symref} ${this.dryRun ? "will become" : "has become"} dangling!\n`;
|
|
561
|
+
} else {
|
|
562
|
+
this.output += this.dryRun
|
|
563
|
+
? ` ${symref} will become dangling after ${target} is deleted\n`
|
|
564
|
+
: ` ${symref} has become dangling after ${target} was deleted\n`;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
if (failure !== undefined) throw new GitApiError(failure, { exitCode: 1 });
|
|
569
|
+
return results;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** The text of one remote of `git remote show` (builtin/remote.c `show`). */
|
|
574
|
+
function formatShow(info: RemoteShowInfo, noQuery: boolean): string {
|
|
575
|
+
const lines: string[] = [`* remote ${info.name}`, ` Fetch URL: ${info.fetchUrl}`];
|
|
576
|
+
for (const url of info.pushUrls) lines.push(` Push URL: ${url}`);
|
|
577
|
+
if (info.pushUrls.length === 0) lines.push(" Push URL: (no URL)");
|
|
578
|
+
const heads = info.heads ?? [];
|
|
579
|
+
if (noQuery) lines.push(" HEAD branch: (not queried)");
|
|
580
|
+
else if (heads.length === 0) lines.push(" HEAD branch: (unknown)");
|
|
581
|
+
else if (heads.length === 1) lines.push(` HEAD branch: ${heads[0]}`);
|
|
582
|
+
else {
|
|
583
|
+
lines.push(" HEAD branch (remote HEAD is ambiguous, may be one of the following):");
|
|
584
|
+
for (const head of heads) lines.push(` ${head}`);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// remote branch info: a sorted set of every name
|
|
588
|
+
const all = sortBytes([
|
|
589
|
+
...new Set([...info.newRefs, ...info.skipped, ...info.tracked, ...info.stale]),
|
|
590
|
+
]);
|
|
591
|
+
const width = Math.max(0, ...all.map((n) => n.length));
|
|
592
|
+
if (all.length > 0) {
|
|
593
|
+
lines.push(
|
|
594
|
+
` Remote branch${all.length === 1 ? "" : "es"}:${noQuery ? " (status not queried)" : ""}`,
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
for (const name of all) {
|
|
598
|
+
if (!info.queried) {
|
|
599
|
+
lines.push(` ${name}`);
|
|
600
|
+
continue;
|
|
601
|
+
}
|
|
602
|
+
let state: string;
|
|
603
|
+
if (info.newRefs.includes(name)) state = ` new (next fetch will store in remotes/${info.name})`;
|
|
604
|
+
else if (info.tracked.includes(name)) state = " tracked";
|
|
605
|
+
else if (info.skipped.includes(name)) state = " skipped";
|
|
606
|
+
else if (info.stale.includes(name)) state = " stale (use 'git remote prune' to remove)";
|
|
607
|
+
else state = " ???";
|
|
608
|
+
lines.push(` ${name.padEnd(width)}${state}`);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// git pull info
|
|
612
|
+
const pullWidth = Math.max(0, ...info.pull.map((p) => p.branch.length));
|
|
613
|
+
const anyRebase = info.pull.some((p) => p.rebase);
|
|
614
|
+
if (info.pull.length > 0) {
|
|
615
|
+
lines.push(
|
|
616
|
+
info.pull.length === 1
|
|
617
|
+
? " Local branch configured for 'git pull':"
|
|
618
|
+
: " Local branches configured for 'git pull':",
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
for (const pull of info.pull) {
|
|
622
|
+
if (pull.rebase && pull.merges.length > 1) continue;
|
|
623
|
+
const head = ` ${pull.branch.padEnd(pullWidth)} `;
|
|
624
|
+
let width = pullWidth + 4;
|
|
625
|
+
if (pull.rebase) {
|
|
626
|
+
const what =
|
|
627
|
+
pull.rebase === "interactive"
|
|
628
|
+
? "rebases interactively onto remote"
|
|
629
|
+
: pull.rebase === "merges"
|
|
630
|
+
? "rebases interactively (with merges) onto remote"
|
|
631
|
+
: "rebases onto remote";
|
|
632
|
+
lines.push(`${head}${what} ${pull.merges[0]}`);
|
|
633
|
+
continue;
|
|
634
|
+
}
|
|
635
|
+
if (anyRebase) {
|
|
636
|
+
lines.push(`${head} merges with remote ${pull.merges[0]}`);
|
|
637
|
+
width++;
|
|
638
|
+
} else lines.push(`${head}merges with remote ${pull.merges[0]}`);
|
|
639
|
+
for (const merge of pull.merges.slice(1)) {
|
|
640
|
+
lines.push(`${"".padEnd(width)} and with remote ${merge}`);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// git push info
|
|
645
|
+
if (info.mirror) lines.push(" Local refs will be mirrored by 'git push'");
|
|
646
|
+
const width1 = Math.max(0, ...info.push.map((p) => p.source.length));
|
|
647
|
+
const width2 = Math.max(0, ...info.push.map((p) => p.destination.length));
|
|
648
|
+
if (info.push.length > 0) {
|
|
649
|
+
lines.push(
|
|
650
|
+
` Local ref${info.push.length === 1 ? "" : "s"} configured for 'git push'${noQuery ? " (status not queried)" : ""}:`,
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
for (const push of info.push) {
|
|
654
|
+
const verb = push.forced ? "forces to" : "pushes to";
|
|
655
|
+
const source = push.status === "delete" ? "(none)" : push.source;
|
|
656
|
+
if (push.status) {
|
|
657
|
+
lines.push(
|
|
658
|
+
` ${source.padEnd(width1)} ${verb} ${push.destination.padEnd(width2)} (${push.status})`,
|
|
659
|
+
);
|
|
660
|
+
} else lines.push(` ${source.padEnd(width1)} ${verb} ${push.destination}`);
|
|
661
|
+
}
|
|
662
|
+
return `${lines.join("\n")}\n`;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/** get_push_ref_states_noquery: the push refspecs as written. */
|
|
666
|
+
function pushNoQuery(pushSpecs: string[]): RemotePushInfo[] {
|
|
667
|
+
if (pushSpecs.length === 0) {
|
|
668
|
+
return [{ source: "(matching)", destination: "(matching)", forced: false }];
|
|
669
|
+
}
|
|
670
|
+
return pushSpecs.map((raw) => {
|
|
671
|
+
let spec = raw;
|
|
672
|
+
const forced = spec.startsWith("+");
|
|
673
|
+
if (forced) spec = spec.slice(1);
|
|
674
|
+
const negative = spec.startsWith("^");
|
|
675
|
+
if (negative) spec = spec.slice(1);
|
|
676
|
+
const colon = spec.indexOf(":");
|
|
677
|
+
const src = colon < 0 ? spec : spec.slice(0, colon);
|
|
678
|
+
const dst = colon < 0 ? undefined : spec.slice(colon + 1);
|
|
679
|
+
// ":" (and "+:") is the matching refspec
|
|
680
|
+
const source = spec === ":" ? "(matching)" : src.length > 0 ? src : "(delete)";
|
|
681
|
+
return { source, destination: dst ? dst : source, forced };
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/** The branch settings `git remote show` reads (read_branches), sorted by branch name. */
|
|
686
|
+
function readBranches(
|
|
687
|
+
store: RemoteConfigStore,
|
|
688
|
+
messages: string[],
|
|
689
|
+
): { name: string; remote?: string; merges: string[]; rebase?: RemotePullInfo["rebase"] }[] {
|
|
690
|
+
const byName = new Map<
|
|
691
|
+
string,
|
|
692
|
+
{
|
|
693
|
+
name: string;
|
|
694
|
+
remote?: string;
|
|
695
|
+
merges: string[];
|
|
696
|
+
rebase?: RemotePullInfo["rebase"];
|
|
697
|
+
pushRemote?: string;
|
|
698
|
+
}
|
|
699
|
+
>();
|
|
700
|
+
const entries =
|
|
701
|
+
store.entriesWithPrefix("branch.") ??
|
|
702
|
+
store
|
|
703
|
+
.subsections("branch")
|
|
704
|
+
.flatMap((branch) =>
|
|
705
|
+
["remote", "merge", "rebase", "pushremote"].flatMap((v) =>
|
|
706
|
+
store
|
|
707
|
+
.values(`branch.${branch}.${v}`)
|
|
708
|
+
.map((value) => ({ key: `branch.${branch}.${v}`, value })),
|
|
709
|
+
),
|
|
710
|
+
);
|
|
711
|
+
for (const { key, value } of entries) {
|
|
712
|
+
const rest = key.slice("branch.".length);
|
|
713
|
+
const dot = rest.lastIndexOf(".");
|
|
714
|
+
if (dot < 0) continue;
|
|
715
|
+
const name = rest.slice(0, dot);
|
|
716
|
+
const variable = rest.slice(dot + 1).toLowerCase();
|
|
717
|
+
if (!["remote", "merge", "rebase", "pushremote"].includes(variable)) continue;
|
|
718
|
+
let info = byName.get(name);
|
|
719
|
+
if (!info) {
|
|
720
|
+
info = { name, merges: [] };
|
|
721
|
+
byName.set(name, info);
|
|
722
|
+
}
|
|
723
|
+
if (value === undefined) continue;
|
|
724
|
+
if (variable === "remote") {
|
|
725
|
+
if (info.remote !== undefined) messages.push(`warning: more than one ${key}`);
|
|
726
|
+
info.remote = value;
|
|
727
|
+
} else if (variable === "pushremote") {
|
|
728
|
+
if (info.pushRemote !== undefined) messages.push(`warning: more than one ${key}`);
|
|
729
|
+
info.pushRemote = value;
|
|
730
|
+
} else if (variable === "merge") {
|
|
731
|
+
// several branches on one line, separated by spaces
|
|
732
|
+
for (const part of value.split(" ")) info.merges.push(abbrevBranch(part));
|
|
733
|
+
} else {
|
|
734
|
+
const bool = parseGitBool(value);
|
|
735
|
+
if (bool === true) info.rebase = "true";
|
|
736
|
+
else if (bool === false) info.rebase = undefined;
|
|
737
|
+
else if (value === "merges" || value === "m") info.rebase = "merges";
|
|
738
|
+
else if (value === "interactive" || value === "i") info.rebase = "interactive";
|
|
739
|
+
else {
|
|
740
|
+
if (value === "preserve" || value === "p") {
|
|
741
|
+
messages.push(`error: ${value}: 'preserve' superseded by 'merges'`);
|
|
742
|
+
}
|
|
743
|
+
messages.push(`warning: unhandled branch.${name}.rebase=${value}; assuming 'true'`);
|
|
744
|
+
info.rebase = undefined;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
return [...byName.values()].sort((a, b) => compareBytes(a.name, b.name));
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* get_head_names: the branch HEAD's symref names, else every branch at HEAD's commit
|
|
753
|
+
* (guess_remote_head with REMOTE_GUESS_HEAD_ALL), short names.
|
|
754
|
+
*/
|
|
755
|
+
function headNames(refs: readonly TransportRemoteRef[]): string[] {
|
|
756
|
+
const head = refs.find((r) => r.name === "HEAD");
|
|
757
|
+
if (!head) return [];
|
|
758
|
+
const branches = refs.filter((r) => r.name.startsWith("refs/heads/") && !r.name.includes("^"));
|
|
759
|
+
const matches = head.symref
|
|
760
|
+
? branches.filter((r) => r.name === head.symref)
|
|
761
|
+
: branches.filter((r) => r.oid !== undefined && r.oid === head.oid);
|
|
762
|
+
return matches.map((r) => abbrevBranch(r.name));
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* The remote refs a local ref is the tracking ref of (remote_find_tracking /
|
|
767
|
+
* refspec_find_all_matches over the fetch refspecs); undefined when a negative refspec
|
|
768
|
+
* excludes one of them.
|
|
769
|
+
*/
|
|
770
|
+
export function trackingSources(specs: RefSpec[], refName: string): string[] | undefined {
|
|
771
|
+
const sources: string[] = [];
|
|
772
|
+
for (const spec of specs) {
|
|
773
|
+
if (spec.negative || !spec.source || !spec.destination) continue;
|
|
774
|
+
if (spec.wildcard) {
|
|
775
|
+
if (!matchDestination(spec, refName)) continue;
|
|
776
|
+
const source = expandFromDestination(spec, refName).source;
|
|
777
|
+
if (source) sources.push(source);
|
|
778
|
+
} else if (spec.destination === refName) sources.push(spec.source);
|
|
779
|
+
}
|
|
780
|
+
const negative = specs.filter((s) => s.negative && s.source);
|
|
781
|
+
if (sources.some((src) => negative.some((n) => matchSource(n, src)))) return undefined;
|
|
782
|
+
return sources;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/** git's find_ref_by_name_abbrev: the ref `name` names by refname_match's rules, best first. */
|
|
786
|
+
function findRefByNameAbbrev(
|
|
787
|
+
refs: readonly TransportRemoteRef[],
|
|
788
|
+
name: string,
|
|
789
|
+
): TransportRemoteRef | undefined {
|
|
790
|
+
const rules = [
|
|
791
|
+
name,
|
|
792
|
+
`refs/${name}`,
|
|
793
|
+
`refs/tags/${name}`,
|
|
794
|
+
`refs/heads/${name}`,
|
|
795
|
+
`refs/remotes/${name}`,
|
|
796
|
+
`refs/remotes/${name}/HEAD`,
|
|
797
|
+
];
|
|
798
|
+
let best: TransportRemoteRef | undefined;
|
|
799
|
+
let bestRule = rules.length;
|
|
800
|
+
for (const ref of refs) {
|
|
801
|
+
const rule = rules.indexOf(ref.name);
|
|
802
|
+
if (rule >= 0 && rule < bestRule) {
|
|
803
|
+
best = ref;
|
|
804
|
+
bestRule = rule;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
return best;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/** git's get_local_ref: the local ref a refspec's destination names. */
|
|
811
|
+
function localRefName(dst: string | null): string | undefined {
|
|
812
|
+
if (!dst) return undefined;
|
|
813
|
+
if (dst.startsWith("refs/")) return dst;
|
|
814
|
+
if (dst.startsWith("heads/") || dst.startsWith("tags/") || dst.startsWith("remotes/")) {
|
|
815
|
+
return `refs/${dst}`;
|
|
816
|
+
}
|
|
817
|
+
return `refs/heads/${dst}`;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
/** get_fetch_map's "funny ref": a local ref outside `refs/` or of an invalid name. */
|
|
821
|
+
function funnyRef(name: string): boolean {
|
|
822
|
+
return !name.startsWith("refs/") || !isValidRefName(name);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
/** git's abbrev_branch: `refs/heads/` dropped. */
|
|
826
|
+
function abbrevBranch(name: string): string {
|
|
827
|
+
return name.startsWith("refs/heads/") ? name.slice("refs/heads/".length) : name;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
function compareBytes(a: string, b: string): number {
|
|
831
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
function sortBytes(names: string[]): string[] {
|
|
835
|
+
return names.sort(compareBytes);
|
|
836
|
+
}
|