@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,738 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git LFS configuration as git-lfs reads it (v3, `config/git_fetcher.go`,
|
|
3
|
+
* `git/config.go` `Sources`, `lfsapi/endpoint_finder.go`, `lfshttp/endpoint.go`): the
|
|
4
|
+
* repository's `.lfsconfig` (the worktree's file, else the index's stage-0 blob, else
|
|
5
|
+
* HEAD's; HEAD's alone in a bare repository) read first, then the whole git configuration,
|
|
6
|
+
* the last value of a key winning. `.lfsconfig` is repository content: only git-lfs's safe
|
|
7
|
+
* keys are taken from it (`lfs.url`, `lfs.pushurl`, `remote.<name>.lfsurl`, ...), the others
|
|
8
|
+
* are ignored with git-lfs's warning.
|
|
9
|
+
*
|
|
10
|
+
* The LFS endpoint of an operation (`download`, `upload`) and remote follows git-lfs's order:
|
|
11
|
+
* `lfs.pushurl` (upload), `lfs.url`, then the remote's `lfspushurl` (upload), `lfsurl`, then
|
|
12
|
+
* its `pushurl` (upload) or `url` with `.git/info/lfs` appended (`/info/lfs` after a `.git`
|
|
13
|
+
* path), the remote named `origin` when the asked remote gives none. URLs go through
|
|
14
|
+
* `url.<base>.insteadOf` (`pushInsteadOf` for uploads) and Go's URL reading, so an ssh remote
|
|
15
|
+
* gives `https://<host><path>` and its ssh metadata, a `git://` one `lfs.gitprotocol`
|
|
16
|
+
* (default `https`).
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const lfs = await LfsConfig.load(workingCopy);
|
|
21
|
+
* const ep = await lfs.endpoint("download", lfs.remote());
|
|
22
|
+
* ep.url; // "https://example.com/foo/bar.git/info/lfs"
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { FileMode, type ObjectId } from "@statewalker/vcs-core";
|
|
27
|
+
import { ConfigParseError, GitWorkingCopyConfig } from "@statewalker/vcs-store-files";
|
|
28
|
+
import { collectChunks, type WorkingCopy } from "@statewalker/vcs-working-tree";
|
|
29
|
+
|
|
30
|
+
import { GitCommand } from "../../git-command.js";
|
|
31
|
+
import { RemoteConfigStore } from "../../remote-config/index.js";
|
|
32
|
+
import { gitFileOf } from "../git-hooks.js";
|
|
33
|
+
import { hostEnvironmentOf } from "../git-ident.js";
|
|
34
|
+
import { worktreeHostPath } from "../submodule-model.js";
|
|
35
|
+
import { type GoUrl, goEscapedPath, goUrlParse, goUrlString } from "./go-url.js";
|
|
36
|
+
|
|
37
|
+
/** The LFS operation an endpoint is for. */
|
|
38
|
+
export type LfsEndpointOperation = "download" | "upload";
|
|
39
|
+
|
|
40
|
+
/** git-lfs's `UrlUnknown`: an ssh URL whose host cannot be read. */
|
|
41
|
+
export const LFS_URL_UNKNOWN = "<unknown>";
|
|
42
|
+
|
|
43
|
+
/** How git-lfs reaches an endpoint over ssh (`git-lfs-authenticate`, `git-lfs-transfer`). */
|
|
44
|
+
export interface LfsSshMetadata {
|
|
45
|
+
/** `user@host`, or `host` */
|
|
46
|
+
userAndHost: string;
|
|
47
|
+
/** The port, `""` for ssh's default */
|
|
48
|
+
port: string;
|
|
49
|
+
path: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Which setting gave an endpoint. */
|
|
53
|
+
export type LfsEndpointSource =
|
|
54
|
+
| "lfs.pushurl"
|
|
55
|
+
| "lfs.url"
|
|
56
|
+
| "remote.lfspushurl"
|
|
57
|
+
| "remote.lfsurl"
|
|
58
|
+
| "remote.pushurl"
|
|
59
|
+
| "remote.url"
|
|
60
|
+
/** The remote's name read as a URL (a remote without URL, or a URL given as the remote) */
|
|
61
|
+
| "remote.name"
|
|
62
|
+
/** git-lfs 3.5+: the URL `FETCH_HEAD`'s first line names (`origin` without any URL) */
|
|
63
|
+
| "fetch-head";
|
|
64
|
+
|
|
65
|
+
/** An LFS endpoint, as git-lfs's `lfshttp.Endpoint`. */
|
|
66
|
+
export interface LfsEndpoint {
|
|
67
|
+
/**
|
|
68
|
+
* The endpoint's URL: `""` when nothing names one, {@link LFS_URL_UNKNOWN} for an ssh URL
|
|
69
|
+
* whose host cannot be read; a `file://` URL for a local repository
|
|
70
|
+
*/
|
|
71
|
+
url: string;
|
|
72
|
+
operation: LfsEndpointOperation;
|
|
73
|
+
/** The remote whose settings gave the endpoint (`origin` after a fallback) */
|
|
74
|
+
remote: string;
|
|
75
|
+
/** Present for an ssh URL */
|
|
76
|
+
ssh?: LfsSshMetadata;
|
|
77
|
+
/** The setting that gave it; absent when nothing did */
|
|
78
|
+
source?: LfsEndpointSource;
|
|
79
|
+
/**
|
|
80
|
+
* The setting's value came from `.lfsconfig` (repository content), not the git
|
|
81
|
+
* configuration; {@link LfsEndpointCommand} also sets it when `.lfsconfig` chose the remote
|
|
82
|
+
*/
|
|
83
|
+
fromLfsconfig: boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Where `.lfsconfig` was read from. */
|
|
87
|
+
export type LfsconfigSource =
|
|
88
|
+
| { kind: "worktree" }
|
|
89
|
+
| { kind: "index"; id: ObjectId }
|
|
90
|
+
| { kind: "head"; id: ObjectId }
|
|
91
|
+
| { kind: "none" };
|
|
92
|
+
|
|
93
|
+
/** git-lfs's `safeKeys`: what `.lfsconfig` may set. */
|
|
94
|
+
const SAFE_KEYS = new Set([
|
|
95
|
+
"lfs.allowincompletepush",
|
|
96
|
+
"lfs.fetchexclude",
|
|
97
|
+
"lfs.fetchinclude",
|
|
98
|
+
"lfs.gitprotocol",
|
|
99
|
+
"lfs.locksverify",
|
|
100
|
+
"lfs.pushurl",
|
|
101
|
+
"lfs.skipdownloaderrors",
|
|
102
|
+
"lfs.url",
|
|
103
|
+
]);
|
|
104
|
+
|
|
105
|
+
interface LfsValue {
|
|
106
|
+
value: string;
|
|
107
|
+
lfsconfig: boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** A host path's kind, links followed (Go's `os.Stat`). */
|
|
111
|
+
type HostStat = (path: string) => Promise<"file" | "directory" | "other" | undefined>;
|
|
112
|
+
|
|
113
|
+
/** What {@link LfsConfig.load} reads besides the configuration. */
|
|
114
|
+
export interface LfsConfigLoadOptions {
|
|
115
|
+
/** Leave `.lfsconfig` out (the user's own configuration alone) */
|
|
116
|
+
withoutLfsconfig?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* The git-lfs version to follow (default {@link LFS_DEFAULT_COMPATIBILITY}): 3.5 added the
|
|
119
|
+
* `FETCH_HEAD` fallback; 3.8.1 takes from `.lfsconfig` only `remote.<name>.lfsurl` of the
|
|
120
|
+
* `remote.*` keys and only `lfs.*.access` of the access keys, and escapes the path of an ssh
|
|
121
|
+
* remote's HTTPS fallback
|
|
122
|
+
*/
|
|
123
|
+
compatibility?: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** The git-lfs version followed by default. */
|
|
127
|
+
export const LFS_DEFAULT_COMPATIBILITY = "3.8.1";
|
|
128
|
+
|
|
129
|
+
/** `version` is at least `min` (dotted numbers). */
|
|
130
|
+
function atLeast(version: string, min: string): boolean {
|
|
131
|
+
const a = version
|
|
132
|
+
.replace(/^v/, "")
|
|
133
|
+
.split(".")
|
|
134
|
+
.map((n) => Number.parseInt(n, 10) || 0);
|
|
135
|
+
const b = min.split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
136
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
137
|
+
const d = (a[i] ?? 0) - (b[i] ?? 0);
|
|
138
|
+
if (d !== 0) return d > 0;
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** What a git-lfs version does (see {@link LfsConfigLoadOptions.compatibility}). */
|
|
144
|
+
interface LfsFeatures {
|
|
145
|
+
fetchHead: boolean;
|
|
146
|
+
strictLfsconfig: boolean;
|
|
147
|
+
escapedSshPath: boolean;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function featuresOf(version: string): LfsFeatures {
|
|
151
|
+
return {
|
|
152
|
+
fetchHead: atLeast(version, "3.5.0"),
|
|
153
|
+
strictLfsconfig: atLeast(version, "3.8.1"),
|
|
154
|
+
escapedSshPath: atLeast(version, "3.8.1"),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Reads `.lfsconfig` as git-lfs's `Sources` does. */
|
|
159
|
+
class LfsconfigReader extends GitCommand<{ bytes?: Uint8Array; source: LfsconfigSource }> {
|
|
160
|
+
async call(): Promise<{ bytes?: Uint8Array; source: LfsconfigSource }> {
|
|
161
|
+
const blob = async (id: ObjectId) => collectChunks((await this.blobs.load(id)) ?? []);
|
|
162
|
+
const head = async (): Promise<{ bytes?: Uint8Array; source: LfsconfigSource }> => {
|
|
163
|
+
const id = await this.resolveRevision("HEAD:.lfsconfig").catch(() => undefined);
|
|
164
|
+
if (id === undefined) return { source: { kind: "none" } };
|
|
165
|
+
return { bytes: await blob(id), source: { kind: "head", id } };
|
|
166
|
+
};
|
|
167
|
+
const worktree = this.worktreeAccess;
|
|
168
|
+
if (!worktree) return head();
|
|
169
|
+
const file = await worktree.getEntry(".lfsconfig").catch(() => undefined);
|
|
170
|
+
if (file) {
|
|
171
|
+
// git-lfs stats and reads the file through its links; ours never follows a link out
|
|
172
|
+
// of the worktree (repository content), so a linked `.lfsconfig` gives nothing
|
|
173
|
+
if (file.isDirectory || file.mode === FileMode.SYMLINK) return { source: { kind: "none" } };
|
|
174
|
+
return {
|
|
175
|
+
bytes: await collectChunks(worktree.readContent(".lfsconfig")),
|
|
176
|
+
source: { kind: "worktree" },
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
// `git config --blob :.lfsconfig`: the stage-0 entry only
|
|
180
|
+
let staged: ObjectId | undefined;
|
|
181
|
+
for await (const entry of this.staging.entries()) {
|
|
182
|
+
if (entry.path !== ".lfsconfig") continue;
|
|
183
|
+
if (entry.stage === 0) staged = entry.objectId;
|
|
184
|
+
}
|
|
185
|
+
if (staged !== undefined) {
|
|
186
|
+
return { bytes: await blob(staged), source: { kind: "index", id: staged } };
|
|
187
|
+
}
|
|
188
|
+
return head();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Every `key=value` of a config text, keys canonical, in file order (`git config -l`). */
|
|
193
|
+
async function configLines(bytes: Uint8Array, name: string): Promise<[string, string][]> {
|
|
194
|
+
const config = new GitWorkingCopyConfig(
|
|
195
|
+
{ read: async () => bytes, write: async () => {} },
|
|
196
|
+
name,
|
|
197
|
+
// git-lfs passes `--includes`; ours never follows an include of repository content
|
|
198
|
+
{ includes: false },
|
|
199
|
+
);
|
|
200
|
+
await config.load();
|
|
201
|
+
const lines: [string, string][] = [];
|
|
202
|
+
for (const entry of config.listWithOrigin()) {
|
|
203
|
+
// `git config -l` prints a variable without `=` as its key alone: git-lfs skips it
|
|
204
|
+
if (entry.text !== undefined) lines.push([entry.key, entry.text]);
|
|
205
|
+
}
|
|
206
|
+
return lines;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** git-lfs's `caseFoldKey`: section and name in lower case, the middle kept. */
|
|
210
|
+
function caseFoldKey(key: string): string {
|
|
211
|
+
const parts = key.split(".");
|
|
212
|
+
if (parts.length < 3) return key.toLowerCase();
|
|
213
|
+
const last = parts.length - 1;
|
|
214
|
+
return [
|
|
215
|
+
(parts[0] as string).toLowerCase(),
|
|
216
|
+
parts.slice(1, last).join("."),
|
|
217
|
+
(parts[last] as string).toLowerCase(),
|
|
218
|
+
].join(".");
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** POSIX `filepath.Clean`. */
|
|
222
|
+
function cleanPath(path: string): string {
|
|
223
|
+
const absolute = path.startsWith("/");
|
|
224
|
+
const out: string[] = [];
|
|
225
|
+
for (const part of path.split("/")) {
|
|
226
|
+
if (part === "" || part === ".") continue;
|
|
227
|
+
if (part === "..") {
|
|
228
|
+
if (out.length > 0 && out[out.length - 1] !== "..") out.pop();
|
|
229
|
+
else if (!absolute) out.push("..");
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
out.push(part);
|
|
233
|
+
}
|
|
234
|
+
const joined = out.join("/");
|
|
235
|
+
if (absolute) return `/${joined}`;
|
|
236
|
+
return joined === "" ? "." : joined;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** `path.Ext`: the suffix from the last `.` of the last element. */
|
|
240
|
+
function pathExt(path: string): string {
|
|
241
|
+
for (let i = path.length - 1; i >= 0 && path[i] !== "/"; i--) {
|
|
242
|
+
if (path[i] === ".") return path.slice(i);
|
|
243
|
+
}
|
|
244
|
+
return "";
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* The LFS configuration of a working copy (see the module notes): `.lfsconfig` and the git
|
|
249
|
+
* configuration merged as git-lfs merges them, and git-lfs's endpoint finder over them.
|
|
250
|
+
*/
|
|
251
|
+
export class LfsConfig {
|
|
252
|
+
private readonly aliases = new Map<string, string>();
|
|
253
|
+
private readonly pushAliases = new Map<string, string>();
|
|
254
|
+
private readonly gitProtocol: string;
|
|
255
|
+
|
|
256
|
+
private constructor(
|
|
257
|
+
private readonly values: Map<string, LfsValue[]>,
|
|
258
|
+
/** git-lfs's `Remotes()`: every remote any `remote.*` key names, in the order first seen */
|
|
259
|
+
readonly remotes: readonly string[],
|
|
260
|
+
/** `git remote`: the remotes of the git configuration */
|
|
261
|
+
private readonly gitRemotes: readonly string[],
|
|
262
|
+
/** What git-lfs prints on stderr reading the configuration (ignored `.lfsconfig` keys) */
|
|
263
|
+
readonly warnings: readonly string[],
|
|
264
|
+
/**
|
|
265
|
+
* Why the configuration was not read (a worktree `.lfsconfig` git cannot parse: git-lfs
|
|
266
|
+
* then reads no configuration at all)
|
|
267
|
+
*/
|
|
268
|
+
readonly errors: readonly string[],
|
|
269
|
+
/** Where `.lfsconfig` was read from */
|
|
270
|
+
readonly lfsconfigSource: LfsconfigSource,
|
|
271
|
+
private readonly currentBranch: string | undefined,
|
|
272
|
+
private readonly stat: HostStat,
|
|
273
|
+
private readonly cwd: string | undefined,
|
|
274
|
+
private readonly features: LfsFeatures,
|
|
275
|
+
/** The first line of the worktree's `FETCH_HEAD`, when there is one */
|
|
276
|
+
private readonly fetchHeadLine: string | undefined,
|
|
277
|
+
) {
|
|
278
|
+
this.gitProtocol = this.get("lfs.gitprotocol") ?? "https";
|
|
279
|
+
// initAliases: every `url.<base>.insteadof` / `.pushinsteadof` value names an alias
|
|
280
|
+
for (const [key, entries] of values) {
|
|
281
|
+
if (!key.startsWith("url.")) continue;
|
|
282
|
+
for (const [suffix, map] of [
|
|
283
|
+
[".insteadof", this.aliases],
|
|
284
|
+
[".pushinsteadof", this.pushAliases],
|
|
285
|
+
] as const) {
|
|
286
|
+
if (!key.endsWith(suffix)) continue;
|
|
287
|
+
const base = key.slice(4, key.length - suffix.length);
|
|
288
|
+
for (const { value } of entries) {
|
|
289
|
+
const known = map.get(value);
|
|
290
|
+
if (known !== undefined && known !== base) {
|
|
291
|
+
(this.warnings as string[]).push(
|
|
292
|
+
`warning: Multiple 'url.*.${suffix}' keys with the same alias: "${value}"`,
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
map.set(value, base);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Reads `.lfsconfig` (see the module notes) and the working copy's configuration.
|
|
303
|
+
*
|
|
304
|
+
* A `.lfsconfig` git cannot parse makes git-lfs drop its whole configuration (git's too:
|
|
305
|
+
* `Error reading \`git config\``) when it is the worktree's file; a blob git cannot parse is
|
|
306
|
+
* passed over for the next source.
|
|
307
|
+
*/
|
|
308
|
+
static async load(
|
|
309
|
+
workingCopy: WorkingCopy,
|
|
310
|
+
options: LfsConfigLoadOptions = {},
|
|
311
|
+
): Promise<LfsConfig> {
|
|
312
|
+
const features = featuresOf(options.compatibility ?? LFS_DEFAULT_COMPATIBILITY);
|
|
313
|
+
const warnings: string[] = [];
|
|
314
|
+
const errors: string[] = [];
|
|
315
|
+
const sources: { lines: [string, string][]; onlySafeKeys: boolean }[] = [];
|
|
316
|
+
let lfsconfigSource: LfsconfigSource = { kind: "none" };
|
|
317
|
+
let broken = false;
|
|
318
|
+
if (!options.withoutLfsconfig) {
|
|
319
|
+
const reader = new LfsconfigReader(workingCopy);
|
|
320
|
+
const read = await reader.call();
|
|
321
|
+
lfsconfigSource = read.source;
|
|
322
|
+
if (read.bytes) {
|
|
323
|
+
try {
|
|
324
|
+
sources.push({
|
|
325
|
+
lines: await configLines(read.bytes, ".lfsconfig"),
|
|
326
|
+
onlySafeKeys: true,
|
|
327
|
+
});
|
|
328
|
+
} catch (error) {
|
|
329
|
+
if (!(error instanceof ConfigParseError)) throw error;
|
|
330
|
+
if (read.source.kind === "worktree") {
|
|
331
|
+
broken = true;
|
|
332
|
+
errors.push(
|
|
333
|
+
`Error reading \`git config\`: fatal: bad config line ${error.line} in file .lfsconfig`,
|
|
334
|
+
);
|
|
335
|
+
} else {
|
|
336
|
+
lfsconfigSource = { kind: "none" };
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const store = RemoteConfigStore.from(workingCopy);
|
|
342
|
+
if (!broken) {
|
|
343
|
+
const listed = (
|
|
344
|
+
workingCopy.config as { listWithOrigin?: () => { key: string; text?: string }[] }
|
|
345
|
+
)?.listWithOrigin;
|
|
346
|
+
const entries = listed ? listed.call(workingCopy.config) : [];
|
|
347
|
+
const lines: [string, string][] = [];
|
|
348
|
+
for (const e of entries) if (e.text !== undefined) lines.push([e.key, e.text]);
|
|
349
|
+
sources.push({ lines, onlySafeKeys: false });
|
|
350
|
+
}
|
|
351
|
+
// readGitConfig
|
|
352
|
+
const values = new Map<string, LfsValue[]>();
|
|
353
|
+
const remotes: string[] = [];
|
|
354
|
+
const ignored: string[] = [];
|
|
355
|
+
for (const source of sources) {
|
|
356
|
+
for (const [key, value] of source.lines) {
|
|
357
|
+
let allowed = !source.onlySafeKeys;
|
|
358
|
+
const parts = key.split(".");
|
|
359
|
+
if (parts.length === 4 && parts[0] === "lfs" && parts[1] === "extension") {
|
|
360
|
+
if ((parts[3] === "clean" || parts[3] === "smudge") && source.onlySafeKeys) {
|
|
361
|
+
ignored.push(key);
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (parts[3] === "priority") allowed = true;
|
|
365
|
+
} else if (parts.length > 1 && parts[0] === "remote") {
|
|
366
|
+
const unsafe = features.strictLfsconfig
|
|
367
|
+
? parts.length < 3 || parts[parts.length - 1] !== "lfsurl"
|
|
368
|
+
: parts.length === 3 && parts[2] !== "lfsurl";
|
|
369
|
+
if (source.onlySafeKeys && unsafe) {
|
|
370
|
+
ignored.push(key);
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
allowed = true;
|
|
374
|
+
const remote = parts.slice(1, parts.length - 1).join(".");
|
|
375
|
+
if (!remotes.includes(remote)) remotes.push(remote);
|
|
376
|
+
} else if (
|
|
377
|
+
parts.length > 2 &&
|
|
378
|
+
(!features.strictLfsconfig || parts[0] === "lfs") &&
|
|
379
|
+
parts[parts.length - 1] === "access"
|
|
380
|
+
) {
|
|
381
|
+
allowed = true;
|
|
382
|
+
}
|
|
383
|
+
if (!allowed && !SAFE_KEYS.has(key)) {
|
|
384
|
+
ignored.push(key);
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
const list = values.get(key) ?? [];
|
|
388
|
+
values.set(key, list);
|
|
389
|
+
list.push({ value, lfsconfig: source.onlySafeKeys });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (ignored.length > 0) {
|
|
393
|
+
warnings.push("warning: These unsafe '.lfsconfig' keys were ignored:", "");
|
|
394
|
+
for (const key of ignored) warnings.push(` ${key}`);
|
|
395
|
+
}
|
|
396
|
+
const environment = hostEnvironmentOf(workingCopy);
|
|
397
|
+
const stat: HostStat = async (path) => {
|
|
398
|
+
const stats = await environment?.statFile?.(path).catch(() => undefined);
|
|
399
|
+
if (!stats) return undefined;
|
|
400
|
+
return stats.kind === "directory" ? "directory" : stats.kind === "file" ? "file" : "other";
|
|
401
|
+
};
|
|
402
|
+
return new LfsConfig(
|
|
403
|
+
values,
|
|
404
|
+
remotes,
|
|
405
|
+
store.configuredNames(),
|
|
406
|
+
warnings,
|
|
407
|
+
errors,
|
|
408
|
+
lfsconfigSource,
|
|
409
|
+
await currentBranchOf(workingCopy),
|
|
410
|
+
stat,
|
|
411
|
+
await worktreeHostPath(workingCopy).catch(() => undefined),
|
|
412
|
+
features,
|
|
413
|
+
features.fetchHead ? await fetchHeadLineOf(workingCopy) : undefined,
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/** The last value of `key` (git-lfs's `Get`), undefined when unset. */
|
|
418
|
+
get(key: string): string | undefined {
|
|
419
|
+
return this.entry(key)?.value;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** Every value of `key`, `.lfsconfig`'s first. */
|
|
423
|
+
getAll(key: string): string[] {
|
|
424
|
+
return (this.values.get(caseFoldKey(key)) ?? []).map((v) => v.value);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
private entry(key: string): LfsValue | undefined {
|
|
428
|
+
const list = this.values.get(caseFoldKey(key));
|
|
429
|
+
return list?.[list.length - 1];
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* git-lfs's `Remote()`: the current branch's `branch.<name>.remote`, else
|
|
434
|
+
* `remote.lfsdefault`, else the only remote, else `origin`.
|
|
435
|
+
*/
|
|
436
|
+
remote(): string {
|
|
437
|
+
return this.remoteChoice("download").name;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* git-lfs's `PushRemote()`: `branch.<name>.pushRemote`, `remote.lfspushdefault`,
|
|
442
|
+
* `remote.pushDefault`, else {@link remote}.
|
|
443
|
+
*/
|
|
444
|
+
pushRemote(): string {
|
|
445
|
+
return this.remoteChoice("upload").name;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* {@link remote} (download) or {@link pushRemote} (upload), and whether `.lfsconfig` chose
|
|
450
|
+
* it: git-lfs takes `remote.lfsdefault`, `remote.lfspushdefault` and `remote.pushDefault`
|
|
451
|
+
* from `.lfsconfig` (and a remote with a URL-like name is read as that URL), so a remote it
|
|
452
|
+
* picks is repository content too.
|
|
453
|
+
*/
|
|
454
|
+
remoteChoice(operation: LfsEndpointOperation): { name: string; fromLfsconfig: boolean } {
|
|
455
|
+
const pick = (key: string) => {
|
|
456
|
+
const e = this.entry(key);
|
|
457
|
+
return e ? { name: e.value, fromLfsconfig: e.lfsconfig } : undefined;
|
|
458
|
+
};
|
|
459
|
+
const branch = (name: string) =>
|
|
460
|
+
this.currentBranch !== undefined ? pick(`branch.${this.currentBranch}.${name}`) : undefined;
|
|
461
|
+
const download = () =>
|
|
462
|
+
branch("remote") ??
|
|
463
|
+
pick("remote.lfsdefault") ??
|
|
464
|
+
(this.remotes.length === 1
|
|
465
|
+
? {
|
|
466
|
+
name: this.remotes[0] as string,
|
|
467
|
+
fromLfsconfig: !this.gitRemotes.includes(this.remotes[0] as string),
|
|
468
|
+
}
|
|
469
|
+
: { name: "origin", fromLfsconfig: false });
|
|
470
|
+
if (operation === "download") return download();
|
|
471
|
+
return (
|
|
472
|
+
branch("pushremote") ??
|
|
473
|
+
pick("remote.lfspushdefault") ??
|
|
474
|
+
pick("remote.pushdefault") ??
|
|
475
|
+
download()
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* git-lfs's `Endpoint(operation, remote)`: `lfs.pushurl` (upload), `lfs.url`, the remote's
|
|
481
|
+
* own endpoint, else `origin`'s.
|
|
482
|
+
*/
|
|
483
|
+
async endpoint(operation: LfsEndpointOperation, remote?: string): Promise<LfsEndpoint> {
|
|
484
|
+
if (operation === "upload") {
|
|
485
|
+
const push = this.entry("lfs.pushurl");
|
|
486
|
+
if (push) return this.newEndpoint(operation, push, "lfs.pushurl", "origin", remote);
|
|
487
|
+
}
|
|
488
|
+
const url = this.entry("lfs.url");
|
|
489
|
+
if (url) return this.newEndpoint(operation, url, "lfs.url", "origin", remote);
|
|
490
|
+
if (remote !== undefined && remote !== "" && remote !== "origin") {
|
|
491
|
+
const own = await this.remoteEndpoint(operation, remote);
|
|
492
|
+
if (own.url !== "") return own;
|
|
493
|
+
}
|
|
494
|
+
return this.remoteEndpoint(operation, "origin");
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/** git-lfs's `RemoteEndpoint`: the remote's own settings alone. */
|
|
498
|
+
async remoteEndpoint(operation: LfsEndpointOperation, remote: string): Promise<LfsEndpoint> {
|
|
499
|
+
const name = remote === "" ? "origin" : remote;
|
|
500
|
+
if (operation === "upload") {
|
|
501
|
+
const push = this.entry(`remote.${name}.lfspushurl`);
|
|
502
|
+
if (push) return this.newEndpoint(operation, push, "remote.lfspushurl", name);
|
|
503
|
+
}
|
|
504
|
+
const lfsurl = this.entry(`remote.${name}.lfsurl`);
|
|
505
|
+
if (lfsurl) return this.newEndpoint(operation, lfsurl, "remote.lfsurl", name);
|
|
506
|
+
const git = this.gitRemoteUrl(name, operation === "upload");
|
|
507
|
+
if (git) return this.cloneUrlEndpoint(operation, operation, git.entry, git.source, name);
|
|
508
|
+
// git-lfs 3.5+: the URL of FETCH_HEAD's first line, for `origin` only, read as a download
|
|
509
|
+
if (name === "origin" && this.fetchHeadLine !== undefined) {
|
|
510
|
+
const url = fetchHeadUrl(this.fetchHeadLine);
|
|
511
|
+
if (url !== undefined) {
|
|
512
|
+
return this.cloneUrlEndpoint(
|
|
513
|
+
operation,
|
|
514
|
+
"download",
|
|
515
|
+
{ value: url, lfsconfig: false },
|
|
516
|
+
"fetch-head",
|
|
517
|
+
name,
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return { url: "", operation, remote: name, fromLfsconfig: false };
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/** git-lfs's `NewEndpointFromCloneURL`: the URL with `.git/info/lfs` appended. */
|
|
525
|
+
private async cloneUrlEndpoint(
|
|
526
|
+
operation: LfsEndpointOperation,
|
|
527
|
+
aliasOperation: LfsEndpointOperation,
|
|
528
|
+
entry: LfsValue,
|
|
529
|
+
source: LfsEndpointSource,
|
|
530
|
+
name: string,
|
|
531
|
+
): Promise<LfsEndpoint> {
|
|
532
|
+
const ep = await this.newEndpoint(aliasOperation, entry, source, name);
|
|
533
|
+
ep.operation = operation;
|
|
534
|
+
if (ep.url === LFS_URL_UNKNOWN) return ep;
|
|
535
|
+
if (ep.url.endsWith("/")) ep.url = ep.url.slice(0, -1);
|
|
536
|
+
if (ep.url.startsWith("file://")) return ep;
|
|
537
|
+
ep.url += pathExt(ep.url) === ".git" ? "/info/lfs" : ".git/info/lfs";
|
|
538
|
+
return ep;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/** git-lfs's `GitRemoteURL`: `pushurl` (push), `url`, else the name if it is a remote or a URL. */
|
|
542
|
+
private gitRemoteUrl(
|
|
543
|
+
remote: string,
|
|
544
|
+
forPush: boolean,
|
|
545
|
+
): { entry: LfsValue; source: LfsEndpointSource } | undefined {
|
|
546
|
+
if (forPush) {
|
|
547
|
+
const push = this.entry(`remote.${remote}.pushurl`);
|
|
548
|
+
if (push) return { entry: push, source: "remote.pushurl" };
|
|
549
|
+
}
|
|
550
|
+
const url = this.entry(`remote.${remote}.url`);
|
|
551
|
+
if (url) return { entry: url, source: "remote.url" };
|
|
552
|
+
if (this.gitRemotes.includes(remote) || isRemoteUrl(remote)) {
|
|
553
|
+
return { entry: { value: remote, lfsconfig: false }, source: "remote.name" };
|
|
554
|
+
}
|
|
555
|
+
return undefined;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
private async newEndpoint(
|
|
559
|
+
operation: LfsEndpointOperation,
|
|
560
|
+
entry: LfsValue,
|
|
561
|
+
source: LfsEndpointSource,
|
|
562
|
+
remote: string,
|
|
563
|
+
asked?: string,
|
|
564
|
+
): Promise<LfsEndpoint> {
|
|
565
|
+
const fields = await this.readEndpointUrl(operation, entry.value);
|
|
566
|
+
return {
|
|
567
|
+
...fields,
|
|
568
|
+
operation,
|
|
569
|
+
remote: source.startsWith("lfs.") && asked ? asked : remote,
|
|
570
|
+
source,
|
|
571
|
+
fromLfsconfig: entry.lfsconfig,
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/** git-lfs's `NewEndpoint`: the URL as the endpoint gives it. */
|
|
576
|
+
private async readEndpointUrl(
|
|
577
|
+
operation: LfsEndpointOperation,
|
|
578
|
+
raw: string,
|
|
579
|
+
): Promise<{ url: string; ssh?: LfsSshMetadata }> {
|
|
580
|
+
const rawurl = this.replaceUrlAlias(operation, raw);
|
|
581
|
+
if (rawurl.startsWith("/")) return { url: await this.localPathUrl(rawurl) };
|
|
582
|
+
let u: GoUrl;
|
|
583
|
+
try {
|
|
584
|
+
u = goUrlParse(rawurl);
|
|
585
|
+
} catch {
|
|
586
|
+
return endpointFromBareSshUrl(rawurl, this.features.escapedSshPath);
|
|
587
|
+
}
|
|
588
|
+
switch (u.scheme) {
|
|
589
|
+
case "ssh":
|
|
590
|
+
case "git+ssh":
|
|
591
|
+
case "ssh+git":
|
|
592
|
+
return endpointFromSshUrl(u, this.features.escapedSshPath);
|
|
593
|
+
case "http":
|
|
594
|
+
case "https":
|
|
595
|
+
case "file":
|
|
596
|
+
return { url: goUrlString(u) };
|
|
597
|
+
case "git":
|
|
598
|
+
return { url: goUrlString({ ...u, scheme: this.gitProtocol }) };
|
|
599
|
+
case "":
|
|
600
|
+
if ((await this.stat(this.hostPath(rawurl))) !== undefined) {
|
|
601
|
+
return { url: await this.localPathUrl(rawurl) };
|
|
602
|
+
}
|
|
603
|
+
return endpointFromBareSshUrl(goUrlString(u), this.features.escapedSshPath);
|
|
604
|
+
default:
|
|
605
|
+
if (rawurl.startsWith(`${u.scheme}::`)) return { url: rawurl };
|
|
606
|
+
if ((await this.stat(this.hostPath(rawurl))) !== undefined) {
|
|
607
|
+
return { url: await this.localPathUrl(rawurl) };
|
|
608
|
+
}
|
|
609
|
+
return endpointFromBareSshUrl(goUrlString(u), this.features.escapedSshPath);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/** A path as the process sees it: relative ones from the worktree top. */
|
|
614
|
+
private hostPath(path: string): string {
|
|
615
|
+
if (path.startsWith("/")) return path;
|
|
616
|
+
return this.cwd !== undefined ? `${this.cwd}/${path}` : path;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/** git's `RewriteLocalPathAsURL` (git-lfs). */
|
|
620
|
+
private async localPathUrl(raw: string): Promise<string> {
|
|
621
|
+
let path = cleanPath(this.hostPath(raw));
|
|
622
|
+
let gitPath: string;
|
|
623
|
+
const base = path.slice(path.lastIndexOf("/") + 1);
|
|
624
|
+
if (base === ".git") {
|
|
625
|
+
gitPath = path;
|
|
626
|
+
path = cleanPath(path.slice(0, path.lastIndexOf("/")) || "/");
|
|
627
|
+
} else {
|
|
628
|
+
gitPath = path === "/" ? "/.git" : `${path}/.git`;
|
|
629
|
+
}
|
|
630
|
+
if ((await this.stat(gitPath)) !== undefined) path = gitPath;
|
|
631
|
+
else if ((await this.stat(path)) === undefined) return path;
|
|
632
|
+
return `file://${path}`;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/** git-lfs's `ReplaceUrlAlias`: the longest `insteadOf` (`pushInsteadOf` first for uploads). */
|
|
636
|
+
replaceUrlAlias(operation: LfsEndpointOperation, rawurl: string): string {
|
|
637
|
+
if (operation === "upload") {
|
|
638
|
+
const pushed = replaceAlias(this.pushAliases, rawurl);
|
|
639
|
+
if (pushed !== undefined) return pushed;
|
|
640
|
+
}
|
|
641
|
+
return replaceAlias(this.aliases, rawurl) ?? rawurl;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
function replaceAlias(aliases: Map<string, string>, rawurl: string): string | undefined {
|
|
646
|
+
let longest = "";
|
|
647
|
+
for (const alias of aliases.keys()) {
|
|
648
|
+
if (!rawurl.startsWith(alias)) continue;
|
|
649
|
+
if (longest < alias) longest = alias;
|
|
650
|
+
}
|
|
651
|
+
if (longest.length === 0) return undefined;
|
|
652
|
+
return (aliases.get(longest) as string) + rawurl.slice(longest.length);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/** git-lfs's `ValidateRemoteURL`. */
|
|
656
|
+
function isRemoteUrl(remote: string): boolean {
|
|
657
|
+
let u: GoUrl | undefined;
|
|
658
|
+
try {
|
|
659
|
+
u = goUrlParse(remote);
|
|
660
|
+
} catch {
|
|
661
|
+
u = undefined;
|
|
662
|
+
}
|
|
663
|
+
if (u === undefined || u.scheme === "") return remote.includes(":");
|
|
664
|
+
return ["ssh", "http", "https", "git", "file"].includes(u.scheme);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/** git-lfs's `EndpointFromSshUrl`. */
|
|
668
|
+
function endpointFromSshUrl(u: GoUrl, escaped: boolean): { url: string; ssh?: LfsSshMetadata } {
|
|
669
|
+
const match = /^([^:]+)(?::(\d+))?$/.exec(u.host);
|
|
670
|
+
if (!match) return { url: LFS_URL_UNKNOWN };
|
|
671
|
+
const host = match[1] as string;
|
|
672
|
+
const userAndHost =
|
|
673
|
+
u.user !== undefined && u.user.username !== "" ? `${u.user.username}@${host}` : host;
|
|
674
|
+
return {
|
|
675
|
+
url: `https://${host}${escaped ? goEscapedPath(u.path) : u.path}`,
|
|
676
|
+
ssh: { userAndHost, port: match[2] ?? "", path: u.path },
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/** git-lfs's `EndpointFromBareSshUrl`: `user@host:path`, `[user@host:port]:path`. */
|
|
681
|
+
function endpointFromBareSshUrl(
|
|
682
|
+
rawurl: string,
|
|
683
|
+
escaped: boolean,
|
|
684
|
+
): { url: string; ssh?: LfsSshMetadata } {
|
|
685
|
+
const parts = rawurl.split(":");
|
|
686
|
+
if (parts.length < 2) return { url: rawurl };
|
|
687
|
+
let newPath: string;
|
|
688
|
+
if (parts.length > 2) {
|
|
689
|
+
parts[0] = (parts[0] as string).replace(/^\[/, "");
|
|
690
|
+
parts[1] = (parts[1] as string).replace(/\]$/, "");
|
|
691
|
+
newPath = `${parts[0]}:${parts.slice(1).join("/")}`;
|
|
692
|
+
} else {
|
|
693
|
+
newPath = parts.join("/");
|
|
694
|
+
}
|
|
695
|
+
let u: GoUrl;
|
|
696
|
+
try {
|
|
697
|
+
u = goUrlParse(`ssh://${newPath}`);
|
|
698
|
+
} catch {
|
|
699
|
+
return { url: LFS_URL_UNKNOWN };
|
|
700
|
+
}
|
|
701
|
+
const endpoint = endpointFromSshUrl(u, escaped);
|
|
702
|
+
if (endpoint.ssh?.path.startsWith("/")) endpoint.ssh.path = endpoint.ssh.path.slice(1);
|
|
703
|
+
return endpoint;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/** The branch HEAD names, when it names one that has a commit (git-lfs's `CurrentRef`). */
|
|
707
|
+
async function currentBranchOf(workingCopy: WorkingCopy): Promise<string | undefined> {
|
|
708
|
+
const reader = new HeadBranchReader(workingCopy);
|
|
709
|
+
return reader.call();
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
class HeadBranchReader extends GitCommand<string | undefined> {
|
|
713
|
+
async call(): Promise<string | undefined> {
|
|
714
|
+
const ref = await this.getCurrentBranch().catch(() => undefined);
|
|
715
|
+
if (ref === undefined || !ref.startsWith("refs/heads/")) return undefined;
|
|
716
|
+
// an unborn branch: git-lfs's `git rev-parse` of HEAD fails, no branch is looked at
|
|
717
|
+
if ((await this.resolveRevision("HEAD").catch(() => undefined)) === undefined) return undefined;
|
|
718
|
+
return ref.slice("refs/heads/".length);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/** git-lfs's `ExtractRemoteUrl`: the URL of a FETCH_HEAD line, if it matches. */
|
|
723
|
+
function fetchHeadUrl(line: string): string | undefined {
|
|
724
|
+
const match =
|
|
725
|
+
/^[a-f0-9]{40,64}\t(not-for-merge)?\t(tag |branch |)'.*' of ([/.\-:_a-zA-Z0-9]+)$/.exec(line);
|
|
726
|
+
return match ? (match[3] as string).trim() : undefined;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/** The first line of the worktree's `FETCH_HEAD` (git-lfs's `parseFetchHead`). */
|
|
730
|
+
async function fetchHeadLineOf(workingCopy: WorkingCopy): Promise<string | undefined> {
|
|
731
|
+
const file = await gitFileOf(workingCopy, "FETCH_HEAD").catch(() => undefined);
|
|
732
|
+
if (!file) return undefined;
|
|
733
|
+
const bytes = await collectChunks(file.files.read(file.path)).catch(() => undefined);
|
|
734
|
+
if (!bytes || bytes.length === 0) return undefined;
|
|
735
|
+
const text = new TextDecoder().decode(bytes);
|
|
736
|
+
const end = text.indexOf("\n");
|
|
737
|
+
return end < 0 ? text : text.slice(0, end);
|
|
738
|
+
}
|