@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
|
@@ -102,6 +102,11 @@ export interface GitmodulesParseOptions {
|
|
|
102
102
|
export class Gitmodules {
|
|
103
103
|
/** git's `warning:` lines, in order */
|
|
104
104
|
readonly warnings: string[] = [];
|
|
105
|
+
/**
|
|
106
|
+
* The variables that name no submodule (`fetch.recurseSubmodules`, `submodule.fetchJobs`),
|
|
107
|
+
* in the file's order, as `fetch_config_from_gitmodules` reads them
|
|
108
|
+
*/
|
|
109
|
+
readonly settings: { key: string; value: string | undefined }[] = [];
|
|
105
110
|
private readonly names = new Map<string, SubmoduleSettings>();
|
|
106
111
|
private readonly paths = new Map<string, SubmoduleSettings>();
|
|
107
112
|
|
|
@@ -164,7 +169,10 @@ export class Gitmodules {
|
|
|
164
169
|
);
|
|
165
170
|
for (const entry of config.listWithOrigin()) {
|
|
166
171
|
const parts = entry.key.split(".");
|
|
167
|
-
if (parts.length < 3 || parts[0] !== "submodule")
|
|
172
|
+
if (parts.length < 3 || parts[0] !== "submodule") {
|
|
173
|
+
out.settings.push({ key: entry.key, value: entry.text });
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
168
176
|
const name = parts.slice(1, -1).join(".");
|
|
169
177
|
const item = parts[parts.length - 1] as string;
|
|
170
178
|
const key = `submodule.${name}.${item}`;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* unpack-trees' submodule support (`--recurse-submodules`, `submodule.recurse`): the checks
|
|
3
|
+
* `check_submodule_move_head` makes in `verify_uptodate_1`, `verify_absent_1` and
|
|
4
|
+
* `merged_entry`, and the moves entry.c's `checkout_entry` and `unlink_entry` make in
|
|
5
|
+
* `check_updates`, for the commands that switch a superproject's index and worktree
|
|
6
|
+
* (checkout, switch, reset, read-tree, restore).
|
|
7
|
+
*/
|
|
8
|
+
import { FileMode, type ObjectId } from "@statewalker/vcs-core";
|
|
9
|
+
import { parseGitBool } from "@statewalker/vcs-utils";
|
|
10
|
+
import type { WorkingCopy, Worktree } from "@statewalker/vcs-working-tree";
|
|
11
|
+
|
|
12
|
+
import { GitApiError } from "../errors/index.js";
|
|
13
|
+
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
14
|
+
import type { SubmoduleHeadMover } from "./submodule-commands.js";
|
|
15
|
+
|
|
16
|
+
/** An index or tree entry as the checks see it. */
|
|
17
|
+
interface Entry {
|
|
18
|
+
objectId: ObjectId;
|
|
19
|
+
mode: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Whether a command recurses into submodules: `--[no-]recurse-submodules` when given, else
|
|
24
|
+
* `submodule.recurse` (git's `config_update_recurse_submodules`).
|
|
25
|
+
*/
|
|
26
|
+
export function recursesIntoSubmodules(
|
|
27
|
+
workingCopy: WorkingCopy,
|
|
28
|
+
given: boolean | undefined,
|
|
29
|
+
): boolean {
|
|
30
|
+
if (given !== undefined) return given;
|
|
31
|
+
const value = RemoteConfigStore.from(workingCopy).value("submodule.recurse");
|
|
32
|
+
return value === undefined ? false : parseGitBool(value) === true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* One unpack-trees run's submodule handling. The checks run before anything is written and
|
|
37
|
+
* record what they refuse ({@link rejected}, git's `ERROR_WOULD_LOSE_SUBMODULE`) with the
|
|
38
|
+
* lines the submodules' own read-tree printed ({@link lines}); the moves run with the
|
|
39
|
+
* worktree update, removals first, then (`.gitmodules` read again) the checkouts.
|
|
40
|
+
*/
|
|
41
|
+
export class SubmoduleUnpack {
|
|
42
|
+
/** The lines printed while checking or moving (the child read-trees' errors, git's `error:`) */
|
|
43
|
+
readonly lines: string[] = [];
|
|
44
|
+
/** The paths refused as `Cannot update submodule` (ERROR_WOULD_LOSE_SUBMODULE) */
|
|
45
|
+
readonly rejected: string[] = [];
|
|
46
|
+
|
|
47
|
+
private moverLoad?: Promise<SubmoduleHeadMover>;
|
|
48
|
+
private loadedMover?: SubmoduleHeadMover;
|
|
49
|
+
/** submodule-commands.ts, loaded when first needed (it imports the commands this serves) */
|
|
50
|
+
private commands?: typeof import("./submodule-commands.js");
|
|
51
|
+
|
|
52
|
+
private constructor(
|
|
53
|
+
private readonly workingCopy: WorkingCopy,
|
|
54
|
+
/** unpack-trees' `o->reset`: the checks pass `SUBMODULE_MOVE_HEAD_FORCE` */
|
|
55
|
+
readonly reset: boolean,
|
|
56
|
+
/** git's `--super-prefix` of the run (its plain messages name paths with it) */
|
|
57
|
+
readonly superPrefix: string,
|
|
58
|
+
) {}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The run's submodule handling, or undefined when the command does not recurse. The
|
|
62
|
+
* `.gitmodules` the run starts with is read here, before anything changes it (git reads it
|
|
63
|
+
* before its removals: `load_gitmodules_file`).
|
|
64
|
+
*/
|
|
65
|
+
static async start(
|
|
66
|
+
workingCopy: WorkingCopy,
|
|
67
|
+
options: { recurse: boolean; reset: boolean; superPrefix?: string },
|
|
68
|
+
): Promise<SubmoduleUnpack | undefined> {
|
|
69
|
+
if (!options.recurse || !workingCopy.worktree) return undefined;
|
|
70
|
+
const unpack = new SubmoduleUnpack(workingCopy, options.reset, options.superPrefix ?? "");
|
|
71
|
+
await (await unpack.m()).isSubmodule("");
|
|
72
|
+
return unpack;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private async m(): Promise<SubmoduleHeadMover> {
|
|
76
|
+
if (this.loadedMover) return this.loadedMover;
|
|
77
|
+
this.moverLoad ??= import("./submodule-commands.js").then((commands) => {
|
|
78
|
+
this.commands = commands;
|
|
79
|
+
this.loadedMover = new commands.SubmoduleHeadMover(this.workingCopy, this.superPrefix);
|
|
80
|
+
return this.loadedMover;
|
|
81
|
+
});
|
|
82
|
+
return this.moverLoad;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** `submodule_from_ce`: a gitlink `.gitmodules` (as read now) names. */
|
|
86
|
+
async isSubmodule(path: string, entry: Entry | undefined): Promise<boolean> {
|
|
87
|
+
if (!entry || entry.mode !== FileMode.GITLINK) return false;
|
|
88
|
+
return (await this.m()).isSubmodule(path);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** `file_exists`. */
|
|
92
|
+
async exists(path: string): Promise<boolean> {
|
|
93
|
+
return (await this.m()).exists(path);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Whether the submodule at `path` keeps its repository in its worktree (`.git` directory). */
|
|
97
|
+
async hasGitDirectory(path: string): Promise<boolean> {
|
|
98
|
+
return (await this.m()).hasGitDirectory(path);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* `check_submodule_move_head` (a dry run): whether the submodule at `path` could move from
|
|
103
|
+
* `oldHead` to `newHead`; a refusal is recorded. True when refused.
|
|
104
|
+
*/
|
|
105
|
+
async refuses(path: string, oldHead: string | null, newHead: string | null): Promise<boolean> {
|
|
106
|
+
const ok = await this.run(async () =>
|
|
107
|
+
(await this.m()).moveHead(path, oldHead, newHead, { dryRun: true, force: this.reset }),
|
|
108
|
+
);
|
|
109
|
+
if (ok) return false;
|
|
110
|
+
if (!this.rejected.includes(path)) this.rejected.push(path);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* `verify_uptodate_1` of the index entry `entry` at `path`: undefined when it is not a
|
|
116
|
+
* submodule there (the file checks apply), else whether it is refused (its HEAD cannot move
|
|
117
|
+
* to the recorded commit: local changes, a dirty index).
|
|
118
|
+
*/
|
|
119
|
+
async notUptodate(path: string, entry: Entry): Promise<boolean | undefined> {
|
|
120
|
+
if (this.reset) return false;
|
|
121
|
+
if (!(await this.isSubmodule(path, entry)) || !(await this.exists(path))) return undefined;
|
|
122
|
+
return this.refuses(path, "HEAD", entry.objectId);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* `merged_entry`'s check of the entry `next` replacing `old` (none for a new path): the
|
|
127
|
+
* submodule there must be able to move. True when refused.
|
|
128
|
+
*/
|
|
129
|
+
async mergedRefuses(path: string, old: Entry | undefined, next: Entry): Promise<boolean> {
|
|
130
|
+
if (!(await this.isSubmodule(path, next)) || !(await this.exists(path))) return false;
|
|
131
|
+
return this.refuses(path, old?.objectId ?? null, next.objectId);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* `verify_absent_1` of a new entry `next` at `path` (with an update, without
|
|
136
|
+
* `UNPACK_RESET_OVERWRITE_UNTRACKED`): undefined when not a submodule (the untracked-file
|
|
137
|
+
* checks apply), else whether it is refused.
|
|
138
|
+
*/
|
|
139
|
+
async absentRefuses(path: string, next: Entry): Promise<boolean | undefined> {
|
|
140
|
+
if (!(await this.isSubmodule(path, next)) || !(await this.exists(path))) return undefined;
|
|
141
|
+
return this.refuses(path, next.objectId, null);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** `load_gitmodules_file` after `.gitmodules` was checked out. */
|
|
145
|
+
reload(): void {
|
|
146
|
+
this.loadedMover?.reload();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* `unlink_entry` of a gitlink `entry` leaving the index: the submodule moved to nothing
|
|
151
|
+
* (forced), then its directory removed when empty.
|
|
152
|
+
*/
|
|
153
|
+
async unlink(worktree: Worktree, path: string, entry: Entry): Promise<void> {
|
|
154
|
+
if (await this.isSubmodule(path, entry)) {
|
|
155
|
+
await this.run(async () => (await this.m()).moveHead(path, "HEAD", null, { force: true }));
|
|
156
|
+
}
|
|
157
|
+
await worktree.removeEmptyDirectory?.(path);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** `unlink_entry`'s move of a submodule leaving the index (forced), without the rmdir. */
|
|
161
|
+
async moveAway(path: string, entry: Entry): Promise<void> {
|
|
162
|
+
if (!(await this.isSubmodule(path, entry))) return;
|
|
163
|
+
await this.run(async () => (await this.m()).moveHead(path, "HEAD", null, { force: true }));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* `checkout_entry` of the gitlink `entry` (check_updates' `state.force`): an existing
|
|
168
|
+
* submodule moved to its commit (forced), a missing or unpopulated one checked out there.
|
|
169
|
+
* False when the move failed.
|
|
170
|
+
*/
|
|
171
|
+
async checkout(worktree: Worktree, path: string, entry: Entry): Promise<boolean> {
|
|
172
|
+
const kind = await (await this.m()).kind(path);
|
|
173
|
+
if (!(await this.isSubmodule(path, entry))) {
|
|
174
|
+
if (kind === undefined) await worktree.mkdir(path);
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
if (kind === "symlink") {
|
|
178
|
+
// a link git's stat follows into a repository: validate_submodule_path dies
|
|
179
|
+
await this.run(async () => (await this.m()).validateLinked(path).then(() => true));
|
|
180
|
+
}
|
|
181
|
+
if (kind === undefined) {
|
|
182
|
+
await worktree.mkdir(path);
|
|
183
|
+
return this.run(async () =>
|
|
184
|
+
(await this.m()).moveHead(path, null, entry.objectId, { force: true }),
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
if (!(await (await this.m()).populated(path))) {
|
|
188
|
+
if (kind !== "directory") await worktree.remove(path);
|
|
189
|
+
return this.run(async () => (await this.m()).moveHead(path, null, entry.objectId, {}));
|
|
190
|
+
}
|
|
191
|
+
return this.run(async () =>
|
|
192
|
+
(await this.m()).moveHead(path, "HEAD", entry.objectId, { force: true }),
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The refusal git prints for the recorded submodules, in porcelain form (`Cannot update
|
|
198
|
+
* submodule:` and the list) or plain (`Submodule '<path>' cannot checkout new HEAD.`).
|
|
199
|
+
*/
|
|
200
|
+
refusalLines(plain: boolean): string[] {
|
|
201
|
+
if (this.rejected.length === 0) return [];
|
|
202
|
+
if (plain) {
|
|
203
|
+
return this.rejected.map(
|
|
204
|
+
(p) => `error: Submodule '${this.superPrefix}${p}' cannot checkout new HEAD.`,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
return [
|
|
208
|
+
["error: Cannot update submodule:", ...this.rejected.map((p) => `\t${p}`), ""].join("\n"),
|
|
209
|
+
];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** The lines printed so far, as one text (each line ended). */
|
|
213
|
+
printed(): string {
|
|
214
|
+
return this.lines.join("");
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* A plain (read-tree, reset) refusal of `path`: what the submodules printed, then
|
|
219
|
+
* unpack-trees' own lines (`not uptodate` too when `verify_uptodate` refused it).
|
|
220
|
+
*/
|
|
221
|
+
plainRefusal(path: string, notUptodate: boolean): string {
|
|
222
|
+
const lines = [...this.refusalLines(true)];
|
|
223
|
+
if (notUptodate) {
|
|
224
|
+
lines.push(`error: Entry '${this.superPrefix}${path}' not uptodate. Cannot merge.`);
|
|
225
|
+
}
|
|
226
|
+
return `${this.printed()}${lines.join("\n")}`;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* A worktree file or link replacing the submodule at `path`: refused where its repository
|
|
231
|
+
* is a `.git` directory in it (a deliberate divergence: git's `checkout_entry` removes the
|
|
232
|
+
* whole directory, the submodule's only copy of its history included); else the directory
|
|
233
|
+
* goes, untracked files and all, as git's `remove_subtree`. True when refused.
|
|
234
|
+
*/
|
|
235
|
+
async fileReplacesRefuses(path: string, old: Entry): Promise<boolean> {
|
|
236
|
+
if (!(await this.isSubmodule(path, old))) return false;
|
|
237
|
+
if (!(await this.hasGitDirectory(path))) return false;
|
|
238
|
+
if (!this.rejected.includes(path)) this.rejected.push(path);
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** git's `remove_subtree` of a submodule's directory a file replaces. */
|
|
243
|
+
async removeForFile(worktree: Worktree, path: string, old: Entry): Promise<void> {
|
|
244
|
+
if (!(await this.isSubmodule(path, old))) return;
|
|
245
|
+
if ((await (await this.m()).kind(path)) !== "directory") return;
|
|
246
|
+
if (await this.hasGitDirectory(path)) return;
|
|
247
|
+
await worktree.remove(path, { recursive: true, nonRepositoryGitDirs: true });
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Runs a move, its printed lines kept; git's deaths propagate. */
|
|
251
|
+
private async run(move: () => Promise<boolean>): Promise<boolean> {
|
|
252
|
+
try {
|
|
253
|
+
return await move();
|
|
254
|
+
} catch (error) {
|
|
255
|
+
if (this.commands && error instanceof this.commands.SubmoduleCommandError) {
|
|
256
|
+
const text = `${(await this.m()).takeStderr()}${error.result.stderr}`;
|
|
257
|
+
throw new GitApiError(`${text}${error.message}`);
|
|
258
|
+
}
|
|
259
|
+
throw error;
|
|
260
|
+
} finally {
|
|
261
|
+
const text = (await this.m()).takeStderr();
|
|
262
|
+
if (text) this.lines.push(text);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -10,9 +10,10 @@ import {
|
|
|
10
10
|
type Credentials,
|
|
11
11
|
createDefaultTransports,
|
|
12
12
|
type GitTransportRegistry,
|
|
13
|
+
type HttpCredentialHelper,
|
|
13
14
|
} from "@statewalker/vcs-transport";
|
|
14
15
|
import type { PosixFilesApi } from "@statewalker/vcs-utils/files";
|
|
15
|
-
import type
|
|
16
|
+
import { type WorkingCopy, wildmatch } from "@statewalker/vcs-working-tree";
|
|
16
17
|
|
|
17
18
|
import { GitApiError } from "../errors/index.js";
|
|
18
19
|
import { GitCommand } from "../git-command.js";
|
|
@@ -25,7 +26,7 @@ import { createDescriber } from "./git-describe.js";
|
|
|
25
26
|
import { gitFileOf, hookRunnerOf } from "./git-hooks.js";
|
|
26
27
|
import { hostEnvironmentOf } from "./git-ident.js";
|
|
27
28
|
import { MergeCommand } from "./merge-command.js";
|
|
28
|
-
import { nameRevByTags } from "./name-rev.js";
|
|
29
|
+
import { commitLoaderOf, nameRevByTags, withShallowParents } from "./name-rev.js";
|
|
29
30
|
import { RebaseCommand } from "./rebase-command.js";
|
|
30
31
|
import {
|
|
31
32
|
type CredentialsForUrl,
|
|
@@ -128,7 +129,7 @@ class SubmoduleRepository extends GitCommand<never> {
|
|
|
128
129
|
const source = {
|
|
129
130
|
refs: this.refsStore,
|
|
130
131
|
...(tags ? { tags } : {}),
|
|
131
|
-
commits: this.commits,
|
|
132
|
+
commits: withShallowParents(this.commits, () => this.shallowCommits()),
|
|
132
133
|
};
|
|
133
134
|
const describe = createDescriber({
|
|
134
135
|
...source,
|
|
@@ -142,7 +143,19 @@ class SubmoduleRepository extends GitCommand<never> {
|
|
|
142
143
|
if (plain) return plain;
|
|
143
144
|
const lightweight = await describe(id, { tags: true }).catch(() => "");
|
|
144
145
|
if (lightweight) return lightweight;
|
|
145
|
-
const
|
|
146
|
+
const resolver = this.revisionResolver();
|
|
147
|
+
const contains = await nameRevByTags(
|
|
148
|
+
{
|
|
149
|
+
refs: this.refsStore,
|
|
150
|
+
objectType: (oid) => resolver.objectType(oid),
|
|
151
|
+
loadTag: async (oid) => tags?.load(oid),
|
|
152
|
+
loadCommit: commitLoaderOf(this.walkCommits, () => this.shallowCommits()),
|
|
153
|
+
refExists: (name) => this.refsStore.has(name).catch(() => false),
|
|
154
|
+
abbreviate: (oid) => this.abbreviateObjectId(oid),
|
|
155
|
+
wildmatch: (pattern, text) => wildmatch(pattern, text),
|
|
156
|
+
},
|
|
157
|
+
id,
|
|
158
|
+
).catch(() => undefined);
|
|
146
159
|
if (contains) return contains;
|
|
147
160
|
return (await describe(id, { all: true, always: true }).catch(() => "")) || undefined;
|
|
148
161
|
}
|
|
@@ -229,6 +242,10 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
|
|
|
229
242
|
private recommendShallow?: boolean;
|
|
230
243
|
private references: string[] = [];
|
|
231
244
|
private requireInit = false;
|
|
245
|
+
/** `--filter=<spec>` of the clones */
|
|
246
|
+
private filter?: string;
|
|
247
|
+
/** `--[no-]single-branch` of the clones */
|
|
248
|
+
private singleBranch?: boolean;
|
|
232
249
|
private transports?: GitTransportRegistry;
|
|
233
250
|
private credentials?: Credentials;
|
|
234
251
|
private headers?: Record<string, string>;
|
|
@@ -238,6 +255,8 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
|
|
|
238
255
|
/** Set once at the top superproject, handed to nested updates unchanged */
|
|
239
256
|
private authPolicy?: SubmoduleAuthFor;
|
|
240
257
|
private timeout?: number;
|
|
258
|
+
private credentialHelper?: HttpCredentialHelper;
|
|
259
|
+
private warningCallback?: (line: string) => void;
|
|
241
260
|
|
|
242
261
|
/** A path (pathspec element) limiting the submodules; uninitialized ones are then reported. */
|
|
243
262
|
addPath(path: string): this {
|
|
@@ -312,6 +331,20 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
|
|
|
312
331
|
return this;
|
|
313
332
|
}
|
|
314
333
|
|
|
334
|
+
/** `--filter=<spec>`: partial clones of the submodules (`CloneCommand.setFilter`). */
|
|
335
|
+
setFilter(spec: string | undefined): this {
|
|
336
|
+
this.checkCallable();
|
|
337
|
+
this.filter = spec;
|
|
338
|
+
return this;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** `--[no-]single-branch`: how the submodules are cloned (`CloneCommand.setSingleBranch`). */
|
|
342
|
+
setSingleBranch(singleBranch: boolean | undefined): this {
|
|
343
|
+
this.checkCallable();
|
|
344
|
+
this.singleBranch = singleBranch;
|
|
345
|
+
return this;
|
|
346
|
+
}
|
|
347
|
+
|
|
315
348
|
/** `--reference <repository>`: borrow objects in clones. */
|
|
316
349
|
addReference(reference: string): this {
|
|
317
350
|
this.checkCallable();
|
|
@@ -423,6 +456,26 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
|
|
|
423
456
|
return this.authPolicy;
|
|
424
457
|
}
|
|
425
458
|
|
|
459
|
+
/**
|
|
460
|
+
* A credential helper, as git's `credential.helper` read by its child clones and fetches:
|
|
461
|
+
* asked with each submodule's own URL when its server answers 401 (so it decides per host,
|
|
462
|
+
* at any depth), told when the credentials worked or were refused. Unlike
|
|
463
|
+
* {@link setCredentials}, its answer for one host never goes to another: the client asks
|
|
464
|
+
* it per URL, and the guarded transports drop it on a redirect to another origin.
|
|
465
|
+
*/
|
|
466
|
+
setCredentialHelper(helper: HttpCredentialHelper): this {
|
|
467
|
+
this.checkCallable();
|
|
468
|
+
this.credentialHelper = helper;
|
|
469
|
+
return this;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/** Receives the `warning:` lines of the clones' and fetches' HTTP clients. */
|
|
473
|
+
setWarningCallback(callback: (line: string) => void): this {
|
|
474
|
+
this.checkCallable();
|
|
475
|
+
this.warningCallback = callback;
|
|
476
|
+
return this;
|
|
477
|
+
}
|
|
478
|
+
|
|
426
479
|
/** The timeout of clones and fetches, in milliseconds. */
|
|
427
480
|
setTimeout(timeout: number): this {
|
|
428
481
|
this.checkCallable();
|
|
@@ -609,8 +662,12 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
|
|
|
609
662
|
...(depth !== undefined ? { depth } : {}),
|
|
610
663
|
references: this.references,
|
|
611
664
|
requireInit: this.requireInit,
|
|
665
|
+
...(this.filter !== undefined ? { filter: this.filter } : {}),
|
|
666
|
+
...(this.singleBranch !== undefined ? { singleBranch: this.singleBranch } : {}),
|
|
612
667
|
transports: await this.guardedTransports(),
|
|
613
668
|
...(this.timeout !== undefined ? { timeout: this.timeout } : {}),
|
|
669
|
+
...(this.credentialHelper ? { credentialHelper: this.credentialHelper } : {}),
|
|
670
|
+
...(this.warningCallback ? { warningCallback: this.warningCallback } : {}),
|
|
614
671
|
});
|
|
615
672
|
return true;
|
|
616
673
|
} catch (error) {
|
|
@@ -744,6 +801,8 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
|
|
|
744
801
|
const fetch = new FetchCommand(inner);
|
|
745
802
|
fetch.setTransports(await this.guardedTransports());
|
|
746
803
|
if (this.timeout !== undefined) fetch.setTimeout(this.timeout);
|
|
804
|
+
if (this.credentialHelper) fetch.setCredentialHelper(this.credentialHelper);
|
|
805
|
+
if (this.warningCallback) fetch.setWarningCallback(this.warningCallback);
|
|
747
806
|
if (this.depth) fetch.setDepth(this.depth);
|
|
748
807
|
// the remote named, so its URL is known: `git fetch` alone fetches the default remote
|
|
749
808
|
const remote = target?.remote ?? (await defaultRemoteOf(inner));
|
|
@@ -962,13 +1021,17 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
|
|
|
962
1021
|
.setNoFetch(this.noFetch)
|
|
963
1022
|
.setForce(this.force)
|
|
964
1023
|
.setMode(this.mode)
|
|
965
|
-
.setDepth(this.depth)
|
|
1024
|
+
.setDepth(this.depth)
|
|
1025
|
+
.setFilter(this.filter)
|
|
1026
|
+
.setSingleBranch(this.singleBranch);
|
|
966
1027
|
if (this.recommendShallow !== undefined) child.setRecommendShallow(this.recommendShallow);
|
|
967
1028
|
for (const reference of this.references) child.addReference(reference);
|
|
968
1029
|
if (this.transports) child.setTransports(this.transports);
|
|
969
1030
|
// the top superproject's policy: a nested superproject's remote is no trusted origin
|
|
970
1031
|
child.setAuthPolicy(await this.auth());
|
|
971
1032
|
if (this.timeout !== undefined) child.setTimeout(this.timeout);
|
|
1033
|
+
if (this.credentialHelper) child.setCredentialHelper(this.credentialHelper);
|
|
1034
|
+
if (this.warningCallback) child.setWarningCallback(this.warningCallback);
|
|
972
1035
|
let code: number;
|
|
973
1036
|
try {
|
|
974
1037
|
const result = await child.call();
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git's subtree shift (match-trees.c), which `-s subtree` and `-X subtree[=<path>]` apply to
|
|
3
|
+
* a merge's other side and its base before merge-ort reads them: a tree that matches a
|
|
4
|
+
* subdirectory of ours is shifted down into it (ours' tree with that directory replaced),
|
|
5
|
+
* a tree whose subdirectory matches ours is shifted up to it.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const shifted = await shiftTree(trees, oursTree, theirsTree); // -s subtree
|
|
9
|
+
* const byPath = await shiftTreeBy(trees, oursTree, theirsTree, "git-gui"); // -X subtree=git-gui
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Trees are given by id, `undefined` for the empty tree; a shift down stores the spliced
|
|
13
|
+
* trees, as git writes them.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { ObjectId, TreeEntry } from "@statewalker/vcs-core";
|
|
17
|
+
|
|
18
|
+
import type { CommandTrees } from "../git-command.js";
|
|
19
|
+
|
|
20
|
+
const S_IFMT = 0o170000;
|
|
21
|
+
const isDir = (mode: number) => (mode & S_IFMT) === 0o040000;
|
|
22
|
+
const isLink = (mode: number) => (mode & S_IFMT) === 0o120000;
|
|
23
|
+
|
|
24
|
+
function scoreMissing(mode: number): number {
|
|
25
|
+
if (isDir(mode)) return -1000;
|
|
26
|
+
if (isLink(mode)) return -500;
|
|
27
|
+
return -50;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function scoreDiffers(m1: number, m2: number): number {
|
|
31
|
+
if (isDir(m1) !== isDir(m2)) return -100;
|
|
32
|
+
if (isLink(m1) !== isLink(m2)) return -50;
|
|
33
|
+
return -5;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function scoreMatches(m1: number, m2: number): number {
|
|
37
|
+
if (isDir(m1) !== isDir(m2)) return -100;
|
|
38
|
+
if (isLink(m1) !== isLink(m2)) return -50;
|
|
39
|
+
if (isDir(m1)) return 1000;
|
|
40
|
+
if (isLink(m1)) return 500;
|
|
41
|
+
return 250;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const encoder = new TextEncoder();
|
|
45
|
+
|
|
46
|
+
/** git's base_name_compare: names compared as bytes, a directory's as if `/` followed it. */
|
|
47
|
+
function baseNameCompare(a: TreeEntry, b: TreeEntry): number {
|
|
48
|
+
const x = encoder.encode(a.name);
|
|
49
|
+
const y = encoder.encode(b.name);
|
|
50
|
+
const len = Math.min(x.length, y.length);
|
|
51
|
+
for (let i = 0; i < len; i++) if (x[i] !== y[i]) return x[i] - y[i];
|
|
52
|
+
const c1 = x.length > len ? x[len] : isDir(a.mode) ? 0x2f : 0;
|
|
53
|
+
const c2 = y.length > len ? y[len] : isDir(b.mode) ? 0x2f : 0;
|
|
54
|
+
return c1 - c2;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function entries(trees: CommandTrees, id: ObjectId | undefined): Promise<TreeEntry[]> {
|
|
58
|
+
if (id === undefined) return [];
|
|
59
|
+
const out: TreeEntry[] = [];
|
|
60
|
+
for await (const entry of trees.loadTree(id)) out.push(entry);
|
|
61
|
+
return out.sort(baseNameCompare);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** match-trees.c's score_trees: how alike two trees are. */
|
|
65
|
+
async function scoreTrees(
|
|
66
|
+
trees: CommandTrees,
|
|
67
|
+
one: ObjectId | undefined,
|
|
68
|
+
two: ObjectId | undefined,
|
|
69
|
+
): Promise<number> {
|
|
70
|
+
const a = await entries(trees, one);
|
|
71
|
+
const b = await entries(trees, two);
|
|
72
|
+
let score = 0;
|
|
73
|
+
let i = 0;
|
|
74
|
+
let j = 0;
|
|
75
|
+
while (i < a.length || j < b.length) {
|
|
76
|
+
const cmp = i < a.length && j < b.length ? baseNameCompare(a[i], b[j]) : i < a.length ? -1 : 1;
|
|
77
|
+
if (cmp < 0) score += scoreMissing(a[i++].mode);
|
|
78
|
+
else if (cmp > 0) score += scoreMissing(b[j++].mode);
|
|
79
|
+
else {
|
|
80
|
+
score +=
|
|
81
|
+
a[i].id !== b[j].id
|
|
82
|
+
? scoreDiffers(a[i].mode, b[j].mode)
|
|
83
|
+
: scoreMatches(a[i].mode, b[j].mode);
|
|
84
|
+
i++;
|
|
85
|
+
j++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return score;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** match-trees.c's match_trees: the subtree of `one` (recursing) that best matches `two`. */
|
|
92
|
+
async function matchTrees(
|
|
93
|
+
trees: CommandTrees,
|
|
94
|
+
one: ObjectId | undefined,
|
|
95
|
+
two: ObjectId | undefined,
|
|
96
|
+
best: { score: number; match: string },
|
|
97
|
+
base: string,
|
|
98
|
+
recurseLimit: number,
|
|
99
|
+
): Promise<void> {
|
|
100
|
+
for (const entry of await entries(trees, one)) {
|
|
101
|
+
if (!isDir(entry.mode)) continue;
|
|
102
|
+
const score = await scoreTrees(trees, entry.id, two);
|
|
103
|
+
if (best.score < score) {
|
|
104
|
+
best.match = `${base}${entry.name}`;
|
|
105
|
+
best.score = score;
|
|
106
|
+
}
|
|
107
|
+
if (recurseLimit) {
|
|
108
|
+
await matchTrees(trees, entry.id, two, best, `${base}${entry.name}/`, recurseLimit - 1);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** get_tree_entry: the entry at `path` in tree `id`, undefined when a component is missing. */
|
|
114
|
+
async function treeEntryAt(
|
|
115
|
+
trees: CommandTrees,
|
|
116
|
+
id: ObjectId | undefined,
|
|
117
|
+
path: string,
|
|
118
|
+
): Promise<{ id: ObjectId; mode: number } | undefined> {
|
|
119
|
+
const parts = path.split("/").filter((p) => p.length > 0);
|
|
120
|
+
if (parts.length === 0) return undefined;
|
|
121
|
+
let current: { id: ObjectId; mode: number } | undefined;
|
|
122
|
+
let tree = id;
|
|
123
|
+
for (const [k, name] of parts.entries()) {
|
|
124
|
+
const entry = (await entries(trees, tree)).find((e) => e.name === name);
|
|
125
|
+
if (!entry) return undefined;
|
|
126
|
+
current = { id: entry.id, mode: entry.mode };
|
|
127
|
+
if (k < parts.length - 1) {
|
|
128
|
+
if (!isDir(entry.mode)) return undefined;
|
|
129
|
+
tree = entry.id;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return current;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** match-trees.c's splice_tree: tree `one` with its directory at `prefix` replaced by `two`. */
|
|
136
|
+
async function spliceTree(
|
|
137
|
+
trees: CommandTrees,
|
|
138
|
+
one: ObjectId | undefined,
|
|
139
|
+
prefix: string,
|
|
140
|
+
two: ObjectId | undefined,
|
|
141
|
+
emptyTree: () => Promise<ObjectId>,
|
|
142
|
+
): Promise<ObjectId> {
|
|
143
|
+
const slash = prefix.indexOf("/");
|
|
144
|
+
const top = slash < 0 ? prefix : prefix.slice(0, slash);
|
|
145
|
+
const sub = slash < 0 ? "" : prefix.slice(slash + 1);
|
|
146
|
+
const list = await entries(trees, one);
|
|
147
|
+
const at = list.findIndex((e) => e.name === top);
|
|
148
|
+
if (at < 0) throw new Error(`entry ${top} not found in tree ${one ?? ""}`);
|
|
149
|
+
const found = list[at];
|
|
150
|
+
if (!isDir(found.mode)) throw new Error(`entry ${top} in tree ${one ?? ""} is not a tree`);
|
|
151
|
+
const replacement = sub
|
|
152
|
+
? await spliceTree(trees, found.id, sub, two, emptyTree)
|
|
153
|
+
: (two ?? (await emptyTree()));
|
|
154
|
+
list[at] = { ...found, id: replacement };
|
|
155
|
+
return trees.storeTree(list);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* match-trees.c's shift_tree: `two` shifted to match the shape of `one` (`-s subtree`,
|
|
160
|
+
* `-X subtree`), as the id of the tree merge-ort then reads.
|
|
161
|
+
*/
|
|
162
|
+
export async function shiftTree(
|
|
163
|
+
trees: CommandTrees,
|
|
164
|
+
one: ObjectId | undefined,
|
|
165
|
+
two: ObjectId | undefined,
|
|
166
|
+
emptyTree: () => Promise<ObjectId>,
|
|
167
|
+
depthLimit = 2,
|
|
168
|
+
): Promise<ObjectId | undefined> {
|
|
169
|
+
const initial = await scoreTrees(trees, one, two);
|
|
170
|
+
const add = { score: initial, match: "" };
|
|
171
|
+
const del = { score: initial, match: "" };
|
|
172
|
+
await matchTrees(trees, one, two, add, "", depthLimit);
|
|
173
|
+
await matchTrees(trees, two, one, del, "", depthLimit);
|
|
174
|
+
if (add.score < del.score) {
|
|
175
|
+
// a subtree of two
|
|
176
|
+
if (!del.match) return two;
|
|
177
|
+
const entry = await treeEntryAt(trees, two, del.match);
|
|
178
|
+
if (!entry) throw new Error(`cannot find path ${del.match} in tree ${two ?? ""}`);
|
|
179
|
+
return entry.id;
|
|
180
|
+
}
|
|
181
|
+
if (!add.match) return two;
|
|
182
|
+
return spliceTree(trees, one, add.match, two, emptyTree);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* match-trees.c's shift_tree_by: `two` shifted by `prefix` (`-X subtree=<path>`), down when
|
|
187
|
+
* `one` holds a directory there (and that matches better), up when `two` does.
|
|
188
|
+
*/
|
|
189
|
+
export async function shiftTreeBy(
|
|
190
|
+
trees: CommandTrees,
|
|
191
|
+
one: ObjectId | undefined,
|
|
192
|
+
two: ObjectId | undefined,
|
|
193
|
+
prefix: string,
|
|
194
|
+
emptyTree: () => Promise<ObjectId>,
|
|
195
|
+
): Promise<ObjectId | undefined> {
|
|
196
|
+
const sub1 = await treeEntryAt(trees, one, prefix);
|
|
197
|
+
const sub2 = await treeEntryAt(trees, two, prefix);
|
|
198
|
+
let candidate = 0;
|
|
199
|
+
if (sub1 && isDir(sub1.mode)) candidate |= 1;
|
|
200
|
+
if (sub2 && isDir(sub2.mode)) candidate |= 2;
|
|
201
|
+
if (candidate === 3) {
|
|
202
|
+
let best = await scoreTrees(trees, one, two);
|
|
203
|
+
candidate = 0;
|
|
204
|
+
let score = await scoreTrees(trees, sub1?.id, two);
|
|
205
|
+
if (score > best) {
|
|
206
|
+
candidate = 1;
|
|
207
|
+
best = score;
|
|
208
|
+
}
|
|
209
|
+
score = await scoreTrees(trees, sub2?.id, one);
|
|
210
|
+
if (score > best) candidate = 2;
|
|
211
|
+
}
|
|
212
|
+
if (!candidate) return two;
|
|
213
|
+
if (candidate === 1) return spliceTree(trees, one, prefix, two, emptyTree);
|
|
214
|
+
return sub2?.id;
|
|
215
|
+
}
|
|
@@ -63,6 +63,7 @@ export class SwitchCommand extends GitCommand<CheckoutResult> {
|
|
|
63
63
|
private ignoreOtherWorktrees = false;
|
|
64
64
|
private merge = false;
|
|
65
65
|
private compatibility: "2.43" | "2.56" = "2.56";
|
|
66
|
+
private recurseSubmodules?: boolean;
|
|
66
67
|
|
|
67
68
|
/**
|
|
68
69
|
* The branch to switch to; with `-c`/`-C` the start point, with `--detach` the commit.
|
|
@@ -186,6 +187,13 @@ export class SwitchCommand extends GitCommand<CheckoutResult> {
|
|
|
186
187
|
return this;
|
|
187
188
|
}
|
|
188
189
|
|
|
190
|
+
/** `--[no-]recurse-submodules` (default `submodule.recurse`): see `CheckoutCommand`. */
|
|
191
|
+
setRecurseSubmodules(recurse: boolean): this {
|
|
192
|
+
this.checkCallable();
|
|
193
|
+
this.recurseSubmodules = recurse;
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
|
|
189
197
|
/** `--ignore-other-worktrees`: switch to a branch another worktree has checked out. */
|
|
190
198
|
setIgnoreOtherWorktrees(ignore: boolean): this {
|
|
191
199
|
this.checkCallable();
|
|
@@ -286,6 +294,7 @@ export class SwitchCommand extends GitCommand<CheckoutResult> {
|
|
|
286
294
|
.setAdviceCommand("switch")
|
|
287
295
|
.setOnlyMergeOnSwitchingBranches(true);
|
|
288
296
|
if (this.guess !== undefined) checkout.setGuess(this.guess);
|
|
297
|
+
if (this.recurseSubmodules !== undefined) checkout.setRecurseSubmodules(this.recurseSubmodules);
|
|
289
298
|
if (this.hasReflogAction()) checkout.setReflogAction(this.reflogAction("checkout"));
|
|
290
299
|
if (this.orphan !== undefined) {
|
|
291
300
|
checkout.setOrphan(true).setOrphanFromEmptyTree(true).setName(this.orphan);
|