@statewalker/vcs-commands 0.5.0 → 0.6.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 +123 -8
- package/dist/commands/add-command.d.ts +265 -34
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/add-interactive.d.ts +46 -0
- package/dist/commands/add-patch/add-interactive.d.ts.map +1 -0
- package/dist/commands/add-patch/add-patch.d.ts +139 -0
- package/dist/commands/add-patch/add-patch.d.ts.map +1 -0
- package/dist/commands/add-patch/index.d.ts +6 -0
- package/dist/commands/add-patch/index.d.ts.map +1 -0
- package/dist/commands/add-patch/patch-backend.d.ts +80 -0
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -0
- package/dist/commands/add-patch/patch-modes.d.ts +71 -0
- package/dist/commands/add-patch/patch-modes.d.ts.map +1 -0
- package/dist/commands/add-patch/patch-session.d.ts +49 -0
- package/dist/commands/add-patch/patch-session.d.ts.map +1 -0
- package/dist/commands/am/am-command.d.ts +175 -0
- package/dist/commands/am/am-command.d.ts.map +1 -0
- package/dist/commands/am/index.d.ts +3 -0
- package/dist/commands/am/index.d.ts.map +1 -0
- package/dist/commands/am/mailinfo.d.ts +58 -0
- package/dist/commands/am/mailinfo.d.ts.map +1 -0
- package/dist/commands/am/patch-format.d.ts +24 -0
- package/dist/commands/am/patch-format.d.ts.map +1 -0
- package/dist/commands/apply/apply-command.d.ts +153 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -0
- package/dist/commands/apply/apply-engine.d.ts +195 -0
- package/dist/commands/apply/apply-engine.d.ts.map +1 -0
- package/dist/commands/apply/apply-parse.d.ts +86 -0
- package/dist/commands/apply/apply-parse.d.ts.map +1 -0
- package/dist/commands/apply/apply-types.d.ts +70 -0
- package/dist/commands/apply/apply-types.d.ts.map +1 -0
- package/dist/commands/apply/index.d.ts +6 -0
- package/dist/commands/apply/index.d.ts.map +1 -0
- package/dist/commands/apply/latin1.d.ts +32 -0
- package/dist/commands/apply/latin1.d.ts.map +1 -0
- package/dist/commands/apply/whitespace.d.ts +58 -0
- package/dist/commands/apply/whitespace.d.ts.map +1 -0
- package/dist/commands/attributes-source.d.ts +26 -0
- package/dist/commands/attributes-source.d.ts.map +1 -0
- package/dist/commands/backfill-command.d.ts +110 -0
- package/dist/commands/backfill-command.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-checkout.d.ts +64 -0
- package/dist/commands/bisect/bisect-checkout.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-command.d.ts +201 -0
- package/dist/commands/bisect/bisect-command.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-engine.d.ts +219 -0
- package/dist/commands/bisect/bisect-engine.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-graph.d.ts +127 -0
- package/dist/commands/bisect/bisect-graph.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-quote.d.ts +27 -0
- package/dist/commands/bisect/bisect-quote.d.ts.map +1 -0
- package/dist/commands/bisect/index.d.ts +5 -0
- package/dist/commands/bisect/index.d.ts.map +1 -0
- package/dist/commands/blame-command.d.ts +122 -131
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/branch-command.d.ts +52 -2
- package/dist/commands/branch-command.d.ts.map +1 -1
- package/dist/commands/branch-tracking.d.ts +98 -0
- package/dist/commands/branch-tracking.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +300 -18
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-paths.d.ts +124 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +50 -42
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +49 -16
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +117 -0
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +311 -17
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/core-config.d.ts +78 -1
- package/dist/commands/core-config.d.ts.map +1 -1
- package/dist/commands/date-format.d.ts +58 -0
- package/dist/commands/date-format.d.ts.map +1 -0
- package/dist/commands/describe-command.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +377 -30
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/diff-textconv.d.ts +40 -0
- package/dist/commands/diff-textconv.d.ts.map +1 -0
- package/dist/commands/fetch-command.d.ts +149 -10
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/format-patch-command.d.ts +164 -0
- package/dist/commands/format-patch-command.d.ts.map +1 -0
- package/dist/commands/fsck/fetch-fsck.d.ts +60 -0
- package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-command.d.ts +225 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-loose.d.ts +68 -0
- package/dist/commands/fsck/fsck-loose.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-msg-ids.d.ts +122 -0
- package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-object-checks.d.ts +148 -0
- package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-object-table.d.ts +132 -0
- package/dist/commands/fsck/fsck-object-table.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-pack.d.ts +115 -0
- package/dist/commands/fsck/fsck-pack.d.ts.map +1 -0
- package/dist/commands/fsck/index.d.ts +6 -0
- package/dist/commands/fsck/index.d.ts.map +1 -0
- package/dist/commands/fsck/verify-pack-command.d.ts +81 -0
- package/dist/commands/fsck/verify-pack-command.d.ts.map +1 -0
- package/dist/commands/gc-command.d.ts +43 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-date.d.ts +66 -0
- package/dist/commands/git-date.d.ts.map +1 -0
- package/dist/commands/git-describe.d.ts +67 -0
- package/dist/commands/git-describe.d.ts.map +1 -0
- package/dist/commands/git-hooks.d.ts +416 -0
- package/dist/commands/git-hooks.d.ts.map +1 -0
- package/dist/commands/git-ident.d.ts +128 -0
- package/dist/commands/git-ident.d.ts.map +1 -0
- package/dist/commands/hook-command.d.ts +96 -0
- package/dist/commands/hook-command.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +231 -0
- package/dist/commands/index-adder.d.ts.map +1 -0
- package/dist/commands/index-host.d.ts +86 -0
- package/dist/commands/index-host.d.ts.map +1 -0
- package/dist/commands/index.d.ts +54 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -2
- package/dist/commands/init-command.d.ts +12 -1
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/local-clone.d.ts +60 -0
- package/dist/commands/local-clone.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts +117 -0
- package/dist/commands/local-transport.d.ts.map +1 -0
- package/dist/commands/log-command.d.ts +216 -24
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +120 -0
- package/dist/commands/log-graph.d.ts.map +1 -0
- package/dist/commands/log-output.d.ts +323 -0
- package/dist/commands/log-output.d.ts.map +1 -0
- package/dist/commands/ls-remote-command.d.ts +23 -7
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/mailmap.d.ts +31 -0
- package/dist/commands/mailmap.d.ts.map +1 -0
- package/dist/commands/merge-bases.d.ts +85 -0
- package/dist/commands/merge-bases.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +209 -74
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-config.d.ts +13 -0
- package/dist/commands/merge-config.d.ts.map +1 -0
- package/dist/commands/merge-drivers.d.ts +130 -0
- package/dist/commands/merge-drivers.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +252 -0
- package/dist/commands/merge-support.d.ts.map +1 -0
- package/dist/commands/message-cleanup.d.ts +86 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -0
- package/dist/commands/mv-command.d.ts +94 -0
- package/dist/commands/mv-command.d.ts.map +1 -0
- package/dist/commands/notes-command.d.ts +256 -0
- package/dist/commands/notes-command.d.ts.map +1 -0
- package/dist/commands/notes-commands.d.ts +41 -0
- package/dist/commands/notes-commands.d.ts.map +1 -0
- package/dist/commands/notes-merge-command.d.ts +105 -0
- package/dist/commands/notes-merge-command.d.ts.map +1 -0
- package/dist/commands/notes-support.d.ts +125 -0
- package/dist/commands/notes-support.d.ts.map +1 -0
- package/dist/commands/notes-tree.d.ts +106 -0
- package/dist/commands/notes-tree.d.ts.map +1 -0
- package/dist/commands/object-id-input.d.ts +20 -0
- package/dist/commands/object-id-input.d.ts.map +1 -0
- package/dist/commands/octopus-merge.d.ts +59 -0
- package/dist/commands/octopus-merge.d.ts.map +1 -0
- package/dist/commands/ort-merge.d.ts +126 -0
- package/dist/commands/ort-merge.d.ts.map +1 -0
- package/dist/commands/ort-recursive.d.ts +53 -0
- package/dist/commands/ort-recursive.d.ts.map +1 -0
- package/dist/commands/pack-refs-command.d.ts +20 -0
- package/dist/commands/pack-refs-command.d.ts.map +1 -1
- package/dist/commands/patch-id.d.ts +41 -0
- package/dist/commands/patch-id.d.ts.map +1 -0
- package/dist/commands/pathspec-attributes.d.ts +64 -0
- package/dist/commands/pathspec-attributes.d.ts.map +1 -0
- package/dist/commands/pathspec.d.ts +324 -0
- package/dist/commands/pathspec.d.ts.map +1 -0
- package/dist/commands/post-index-change.d.ts +33 -0
- package/dist/commands/post-index-change.d.ts.map +1 -0
- package/dist/commands/pretty-format.d.ts +222 -0
- package/dist/commands/pretty-format.d.ts.map +1 -0
- package/dist/commands/promisor-remote.d.ts +80 -0
- package/dist/commands/promisor-remote.d.ts.map +1 -0
- package/dist/commands/pull-command.d.ts +41 -8
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +24 -8
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/read-tree-command.d.ts +112 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -0
- package/dist/commands/rebase-command.d.ts +507 -75
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/rebase-todo.d.ts +130 -0
- package/dist/commands/rebase-todo.d.ts.map +1 -0
- package/dist/commands/ref-decoration-filter.d.ts +53 -0
- package/dist/commands/ref-decoration-filter.d.ts.map +1 -0
- package/dist/commands/reflog-messages.d.ts +98 -0
- package/dist/commands/reflog-messages.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +31 -0
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-transport.d.ts +120 -0
- package/dist/commands/remote-transport.d.ts.map +1 -0
- package/dist/commands/reset-command.d.ts +161 -7
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +103 -0
- package/dist/commands/restore-command.d.ts.map +1 -0
- package/dist/commands/rev-list-command.d.ts +78 -0
- package/dist/commands/rev-list-command.d.ts.map +1 -0
- package/dist/commands/rev-parse-command.d.ts +80 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -0
- package/dist/commands/revert-command.d.ts +46 -38
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-filenames.d.ts +95 -0
- package/dist/commands/revision-filenames.d.ts.map +1 -0
- package/dist/commands/revision-range.d.ts +67 -0
- package/dist/commands/revision-range.d.ts.map +1 -0
- package/dist/commands/revision-resolver.d.ts +321 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -0
- package/dist/commands/rm-command.d.ts +69 -7
- package/dist/commands/rm-command.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +191 -0
- package/dist/commands/sequencer-pick.d.ts.map +1 -0
- package/dist/commands/sequencer-support.d.ts +125 -0
- package/dist/commands/sequencer-support.d.ts.map +1 -0
- package/dist/commands/serve-repository.d.ts +52 -0
- package/dist/commands/serve-repository.d.ts.map +1 -0
- package/dist/commands/sparse-checkout-command.d.ts +190 -0
- package/dist/commands/sparse-checkout-command.d.ts.map +1 -0
- package/dist/commands/sparse-checkout-support.d.ts +268 -0
- package/dist/commands/sparse-checkout-support.d.ts.map +1 -0
- package/dist/commands/stash-apply-command.d.ts +42 -8
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-create-command.d.ts +155 -1
- package/dist/commands/stash-create-command.d.ts.map +1 -1
- package/dist/commands/stash-drop-command.d.ts +2 -0
- package/dist/commands/stash-drop-command.d.ts.map +1 -1
- package/dist/commands/stash-working-tree.d.ts +23 -0
- package/dist/commands/stash-working-tree.d.ts.map +1 -1
- package/dist/commands/status-command.d.ts +300 -15
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/status-format.d.ts +155 -0
- package/dist/commands/status-format.d.ts.map +1 -0
- package/dist/commands/status-header.d.ts +64 -0
- package/dist/commands/status-header.d.ts.map +1 -0
- package/dist/commands/strerror.d.ts +7 -0
- package/dist/commands/strerror.d.ts.map +1 -0
- package/dist/commands/submodule-config.d.ts +38 -0
- package/dist/commands/submodule-config.d.ts.map +1 -0
- package/dist/commands/submodule-summary-command.d.ts +80 -0
- package/dist/commands/submodule-summary-command.d.ts.map +1 -0
- package/dist/commands/submodule-summary.d.ts +150 -0
- package/dist/commands/submodule-summary.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts +132 -0
- package/dist/commands/switch-command.d.ts.map +1 -0
- package/dist/commands/tag-command.d.ts +23 -2
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/tracking-info.d.ts +64 -0
- package/dist/commands/tracking-info.d.ts.map +1 -0
- package/dist/commands/trailers.d.ts +73 -0
- package/dist/commands/trailers.d.ts.map +1 -0
- package/dist/commands/tree-restore.d.ts +85 -1
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/untracked-cache-support.d.ts +53 -0
- package/dist/commands/untracked-cache-support.d.ts.map +1 -0
- package/dist/commands/worktree-add-command.d.ts +108 -0
- package/dist/commands/worktree-add-command.d.ts.map +1 -0
- package/dist/commands/worktree-list-command.d.ts +69 -0
- package/dist/commands/worktree-list-command.d.ts.map +1 -0
- package/dist/commands/worktree-lock-command.d.ts +44 -0
- package/dist/commands/worktree-lock-command.d.ts.map +1 -0
- package/dist/commands/worktree-overwrite-checks.d.ts +146 -6
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/commands/worktree-prune-command.d.ts +48 -0
- package/dist/commands/worktree-prune-command.d.ts.map +1 -0
- package/dist/commands/worktree-remove-command.d.ts +59 -0
- package/dist/commands/worktree-remove-command.d.ts.map +1 -0
- package/dist/commands/worktree-repair-command.d.ts +35 -0
- package/dist/commands/worktree-repair-command.d.ts.map +1 -0
- package/dist/commands/worktree-support.d.ts +64 -0
- package/dist/commands/worktree-support.d.ts.map +1 -0
- package/dist/commands-DnmlfwGV.js +61620 -0
- package/dist/core-commands/add.command.impl.d.ts.map +1 -1
- package/dist/errors/add-errors.d.ts +55 -0
- package/dist/errors/add-errors.d.ts.map +1 -1
- package/dist/errors/checkout-errors.d.ts +16 -0
- package/dist/errors/checkout-errors.d.ts.map +1 -1
- package/dist/errors/command-errors.d.ts +77 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/commit-errors.d.ts +9 -0
- package/dist/errors/commit-errors.d.ts.map +1 -1
- package/dist/errors/git-api-error.d.ts +59 -2
- package/dist/errors/git-api-error.d.ts.map +1 -1
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +354 -19
- package/dist/errors/rebase-errors.d.ts +9 -0
- package/dist/errors/rebase-errors.d.ts.map +1 -1
- package/dist/errors/ref-errors.d.ts +32 -0
- package/dist/errors/ref-errors.d.ts.map +1 -1
- package/dist/errors/transport-errors.d.ts +12 -2
- package/dist/errors/transport-errors.d.ts.map +1 -1
- package/dist/errors/worktree-errors.d.ts +35 -0
- package/dist/errors/worktree-errors.d.ts.map +1 -0
- package/dist/git-command-DxvwPrPB.js +7612 -0
- package/dist/git-command.d.ts +413 -32
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +306 -3
- package/dist/git.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/remote-config/remote-config-store.d.ts +105 -3
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/remote-config/remote-refs.d.ts +7 -3
- package/dist/remote-config/remote-refs.d.ts.map +1 -1
- package/dist/rename/detect-renames.d.ts +148 -0
- package/dist/rename/detect-renames.d.ts.map +1 -0
- package/dist/rename/git-similarity.d.ts +44 -0
- package/dist/rename/git-similarity.d.ts.map +1 -0
- package/dist/rename/index.d.ts +2 -0
- package/dist/rename/index.d.ts.map +1 -1
- package/dist/results/binary-patch.d.ts +11 -0
- package/dist/results/binary-patch.d.ts.map +1 -0
- package/dist/results/blame-format.d.ts +55 -0
- package/dist/results/blame-format.d.ts.map +1 -0
- package/dist/results/cherry-pick-result.d.ts +10 -0
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +10 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/combined-diff.d.ts +77 -0
- package/dist/results/combined-diff.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +32 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts +34 -60
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-order.d.ts +25 -0
- package/dist/results/diff-order.d.ts.map +1 -0
- package/dist/results/diff-output.d.ts +249 -0
- package/dist/results/diff-output.d.ts.map +1 -0
- package/dist/results/fetch-result.d.ts +15 -0
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +5 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -252
- package/dist/results/merge-result.d.ts +15 -1
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +12 -3
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +42 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/quote-path.d.ts +27 -0
- package/dist/results/quote-path.d.ts.map +1 -0
- package/dist/results/rebase-result.d.ts +28 -1
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +10 -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 +60 -6
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-BZGa2Z3I.js +2934 -0
- package/dist/transport-command.d.ts +44 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +15 -11
- package/src/commands/add-command.ts +1291 -226
- package/src/commands/add-patch/add-interactive.ts +941 -0
- package/src/commands/add-patch/add-patch.ts +1169 -0
- package/src/commands/add-patch/index.ts +5 -0
- package/src/commands/add-patch/patch-backend.ts +239 -0
- package/src/commands/add-patch/patch-modes.ts +249 -0
- package/src/commands/add-patch/patch-session.ts +159 -0
- package/src/commands/am/am-command.ts +1111 -0
- package/src/commands/am/index.ts +2 -0
- package/src/commands/am/mailinfo.ts +1015 -0
- package/src/commands/am/patch-format.ts +121 -0
- package/src/commands/apply/apply-command.ts +832 -0
- package/src/commands/apply/apply-engine.ts +1603 -0
- package/src/commands/apply/apply-parse.ts +1209 -0
- package/src/commands/apply/apply-types.ts +112 -0
- package/src/commands/apply/index.ts +5 -0
- package/src/commands/apply/latin1.ts +171 -0
- package/src/commands/apply/whitespace.ts +260 -0
- package/src/commands/attributes-source.ts +96 -0
- package/src/commands/backfill-command.ts +694 -0
- package/src/commands/bisect/bisect-checkout.ts +217 -0
- package/src/commands/bisect/bisect-command.ts +788 -0
- package/src/commands/bisect/bisect-engine.ts +1079 -0
- package/src/commands/bisect/bisect-graph.ts +595 -0
- package/src/commands/bisect/bisect-quote.ts +92 -0
- package/src/commands/bisect/index.ts +4 -0
- package/src/commands/blame-command.ts +711 -986
- package/src/commands/branch-command.ts +354 -32
- package/src/commands/branch-tracking.ts +331 -0
- package/src/commands/checkout-command.ts +1290 -243
- package/src/commands/checkout-paths.ts +784 -0
- package/src/commands/cherry-pick-command.ts +156 -396
- package/src/commands/clean-command.ts +504 -156
- package/src/commands/clone-command.ts +634 -67
- package/src/commands/commit-command.ts +1781 -166
- package/src/commands/core-config.ts +161 -6
- package/src/commands/date-format.ts +668 -0
- package/src/commands/describe-command.ts +2 -0
- package/src/commands/diff-command.ts +1898 -110
- package/src/commands/diff-textconv.ts +50 -0
- package/src/commands/fetch-command.ts +606 -66
- package/src/commands/format-patch-command.ts +969 -0
- package/src/commands/fsck/fetch-fsck.ts +229 -0
- package/src/commands/fsck/fsck-command.ts +3347 -0
- package/src/commands/fsck/fsck-loose.ts +287 -0
- package/src/commands/fsck/fsck-msg-ids.ts +176 -0
- package/src/commands/fsck/fsck-object-checks.ts +1044 -0
- package/src/commands/fsck/fsck-object-table.ts +363 -0
- package/src/commands/fsck/fsck-pack.ts +604 -0
- package/src/commands/fsck/index.ts +5 -0
- package/src/commands/fsck/verify-pack-command.ts +249 -0
- package/src/commands/gc-command.ts +147 -1
- package/src/commands/git-date.ts +895 -0
- package/src/commands/git-describe.ts +316 -0
- package/src/commands/git-hooks.ts +1472 -0
- package/src/commands/git-ident.ts +344 -0
- package/src/commands/hook-command.ts +247 -0
- package/src/commands/index-adder.ts +706 -0
- package/src/commands/index-host.ts +291 -0
- package/src/commands/index.ts +82 -0
- package/src/commands/init-command.ts +28 -4
- package/src/commands/local-clone.ts +183 -0
- package/src/commands/local-transport.ts +762 -0
- package/src/commands/log-command.ts +1915 -170
- package/src/commands/log-graph.ts +671 -0
- package/src/commands/log-output.ts +1359 -0
- package/src/commands/ls-remote-command.ts +101 -58
- package/src/commands/mailmap.ts +129 -0
- package/src/commands/merge-bases.ts +296 -0
- package/src/commands/merge-command.ts +1386 -491
- package/src/commands/merge-config.ts +25 -0
- package/src/commands/merge-drivers.ts +306 -0
- package/src/commands/merge-support.ts +1198 -0
- package/src/commands/message-cleanup.ts +275 -0
- package/src/commands/mv-command.ts +976 -0
- package/src/commands/notes-command.ts +890 -0
- package/src/commands/notes-commands.ts +87 -0
- package/src/commands/notes-merge-command.ts +768 -0
- package/src/commands/notes-support.ts +402 -0
- package/src/commands/notes-tree.ts +602 -0
- package/src/commands/object-id-input.ts +27 -0
- package/src/commands/octopus-merge.ts +377 -0
- package/src/commands/ort-merge.ts +1660 -0
- package/src/commands/ort-recursive.ts +160 -0
- package/src/commands/pack-refs-command.ts +39 -22
- package/src/commands/patch-id.ts +196 -0
- package/src/commands/pathspec-attributes.ts +162 -0
- package/src/commands/pathspec.ts +1199 -0
- package/src/commands/post-index-change.ts +62 -0
- package/src/commands/pretty-format.ts +1431 -0
- package/src/commands/promisor-remote.ts +298 -0
- package/src/commands/pull-command.ts +207 -22
- package/src/commands/push-command.ts +236 -23
- package/src/commands/read-tree-command.ts +857 -0
- package/src/commands/rebase-command.ts +3808 -371
- package/src/commands/rebase-todo.ts +584 -0
- package/src/commands/ref-decoration-filter.ts +118 -0
- package/src/commands/reflog-messages.ts +177 -0
- package/src/commands/remote-command.ts +93 -22
- package/src/commands/remote-transport.ts +383 -0
- package/src/commands/reset-command.ts +827 -103
- package/src/commands/restore-command.ts +350 -0
- package/src/commands/rev-list-command.ts +167 -0
- package/src/commands/rev-parse-command.ts +277 -0
- package/src/commands/revert-command.ts +152 -399
- package/src/commands/revision-filenames.ts +254 -0
- package/src/commands/revision-range.ts +222 -0
- package/src/commands/revision-resolver.ts +1379 -0
- package/src/commands/rm-command.ts +613 -67
- package/src/commands/sequencer-pick.ts +869 -0
- package/src/commands/sequencer-support.ts +869 -0
- package/src/commands/serve-repository.ts +125 -0
- package/src/commands/sparse-checkout-command.ts +1389 -0
- package/src/commands/sparse-checkout-support.ts +793 -0
- package/src/commands/stash-apply-command.ts +376 -343
- package/src/commands/stash-create-command.ts +625 -42
- package/src/commands/stash-drop-command.ts +15 -2
- package/src/commands/stash-working-tree.ts +168 -24
- package/src/commands/status-command.ts +1328 -105
- package/src/commands/status-format.ts +775 -0
- package/src/commands/status-header.ts +330 -0
- package/src/commands/strerror.ts +29 -0
- package/src/commands/submodule-config.ts +94 -0
- package/src/commands/submodule-summary-command.ts +334 -0
- package/src/commands/submodule-summary.ts +446 -0
- package/src/commands/switch-command.ts +402 -0
- package/src/commands/tag-command.ts +129 -41
- package/src/commands/tracking-info.ts +201 -0
- package/src/commands/trailers.ts +417 -0
- package/src/commands/tree-restore.ts +204 -4
- package/src/commands/untracked-cache-support.ts +194 -0
- package/src/commands/worktree-add-command.ts +458 -0
- package/src/commands/worktree-list-command.ts +208 -0
- package/src/commands/worktree-lock-command.ts +96 -0
- package/src/commands/worktree-overwrite-checks.ts +452 -26
- package/src/commands/worktree-prune-command.ts +99 -0
- package/src/commands/worktree-remove-command.ts +186 -0
- package/src/commands/worktree-repair-command.ts +59 -0
- package/src/commands/worktree-support.ts +214 -0
- package/src/core-commands/add.command.impl.ts +7 -1
- package/src/errors/add-errors.ts +45 -0
- package/src/errors/checkout-errors.ts +26 -2
- package/src/errors/command-errors.ts +101 -1
- package/src/errors/commit-errors.ts +18 -2
- package/src/errors/git-api-error.ts +82 -2
- package/src/errors/index.ts +1 -0
- package/src/errors/merge-errors.ts +2 -2
- package/src/errors/rebase-errors.ts +12 -0
- package/src/errors/ref-errors.ts +56 -2
- package/src/errors/remote-errors.ts +2 -2
- package/src/errors/stash-errors.ts +1 -1
- package/src/errors/transport-errors.ts +20 -4
- package/src/errors/worktree-errors.ts +49 -0
- package/src/git-command.ts +1177 -118
- package/src/git.ts +523 -10
- package/src/index.ts +1 -1
- package/src/remote-config/remote-config-store.ts +242 -8
- package/src/remote-config/remote-refs.ts +22 -6
- package/src/rename/detect-renames.ts +711 -0
- package/src/rename/git-similarity.ts +116 -0
- package/src/rename/index.ts +2 -0
- package/src/results/binary-patch.ts +401 -0
- package/src/results/blame-format.ts +239 -0
- package/src/results/cherry-pick-result.ts +10 -0
- package/src/results/clone-result.ts +12 -0
- package/src/results/combined-diff.ts +585 -0
- package/src/results/diff-entry.ts +35 -0
- package/src/results/diff-formatter.ts +152 -288
- package/src/results/diff-order.ts +64 -0
- package/src/results/diff-output.ts +1051 -0
- package/src/results/fetch-result.ts +15 -0
- package/src/results/index.ts +5 -0
- package/src/results/merge-result.ts +15 -1
- package/src/results/pull-result.ts +12 -3
- package/src/results/push-result.ts +43 -0
- package/src/results/quote-path.ts +103 -0
- package/src/results/rebase-result.ts +37 -0
- package/src/results/revert-result.ts +10 -0
- package/src/results/stash-result.ts +6 -0
- package/src/results/status-result.ts +123 -45
- package/src/transport-command.ts +121 -2
- package/dist/commands-CsLNyvZ1.js +0 -12587
- package/dist/status-result-BpyUK1Sg.js +0 -519
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
1
|
+
import { isSymbolicRef, type ObjectId } from "@statewalker/vcs-core";
|
|
2
|
+
import { lsRefs, type UploadPackConnection } from "@statewalker/vcs-transport";
|
|
3
3
|
|
|
4
4
|
import { InvalidRemoteError } from "../errors/index.js";
|
|
5
5
|
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
6
6
|
import { TransportCommand } from "../transport-command.js";
|
|
7
|
+
import { withRemoteUploadPack } from "./remote-transport.js";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* A remote ref entry.
|
|
@@ -66,8 +67,9 @@ export class LsRemoteCommand extends TransportCommand<LsRemoteResult> {
|
|
|
66
67
|
private remote?: string;
|
|
67
68
|
private heads = false;
|
|
68
69
|
private tags = false;
|
|
69
|
-
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: API placeholder for transport layer
|
|
70
70
|
private uploadPack?: string;
|
|
71
|
+
/** The remote (name or URL) {@link remoteUrl} resolved */
|
|
72
|
+
private remoteName?: string;
|
|
71
73
|
|
|
72
74
|
/**
|
|
73
75
|
* Set the remote to query.
|
|
@@ -126,7 +128,9 @@ export class LsRemoteCommand extends TransportCommand<LsRemoteResult> {
|
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
/**
|
|
129
|
-
* Set
|
|
131
|
+
* Set the program the remote runs for upload-pack (git's `--upload-pack`, over the
|
|
132
|
+
* `remote.<name>.uploadpack` of the remote listed, given or default): what an ssh connector runs, and
|
|
133
|
+
* what git:// names in its request line.
|
|
130
134
|
*
|
|
131
135
|
* @param uploadPack Path to git-upload-pack on remote
|
|
132
136
|
*/
|
|
@@ -140,63 +144,69 @@ export class LsRemoteCommand extends TransportCommand<LsRemoteResult> {
|
|
|
140
144
|
* Execute the ls-remote operation.
|
|
141
145
|
*
|
|
142
146
|
* @returns Refs from the remote repository
|
|
143
|
-
* @throws InvalidRemoteError
|
|
147
|
+
* @throws InvalidRemoteError git's "No remote configured to list refs from." when no remote
|
|
148
|
+
* is given and git's default one has no URL
|
|
144
149
|
*/
|
|
145
150
|
async call(): Promise<LsRemoteResult> {
|
|
146
151
|
this.checkCallable();
|
|
147
152
|
this.setCallable(false);
|
|
148
153
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Resolve remote URL
|
|
154
|
-
const remoteUrl = await this.resolveRemoteUrl(this.remote);
|
|
155
|
-
if (!remoteUrl) {
|
|
156
|
-
throw new InvalidRemoteError(this.remote);
|
|
157
|
-
}
|
|
154
|
+
// remote_get: the remote given, or git's default one (see callGetUrl)
|
|
155
|
+
const remoteUrl = await this.remoteUrl();
|
|
158
156
|
|
|
159
|
-
//
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
157
|
+
// transport_get: git's local transport (upload-pack of the repository at the path, in
|
|
158
|
+
// process), or the connector the transport registry names (smart HTTP or a native
|
|
159
|
+
// session); either lists with ls-refs over v2, else reads the v0/v1 advertisement, as
|
|
160
|
+
// protocol.version asks; anything else fails in git's words
|
|
161
|
+
const remote = await this.prepareRemote(remoteUrl);
|
|
162
|
+
// --upload-pack, else remote.<name>.uploadpack (transport_get reads it for a named remote)
|
|
163
|
+
const uploadPack =
|
|
164
|
+
this.uploadPack ??
|
|
165
|
+
(this.remoteName !== undefined
|
|
166
|
+
? this.remoteProgram(this.remoteName, "uploadpack")
|
|
167
|
+
: undefined);
|
|
168
|
+
const options = {
|
|
169
|
+
...this.remoteSessionOptions(),
|
|
170
|
+
...(uploadPack !== undefined ? { program: uploadPack } : {}),
|
|
171
|
+
};
|
|
172
|
+
// builtin/ls-remote.c: --tags and --heads become v2 ref-prefixes (v0 lists everything,
|
|
173
|
+
// filtered here). `ref-prefix HEAD` too, which git does not send: HEAD's symref gives
|
|
174
|
+
// `defaultBranch` (HEAD itself is never in the refs returned)
|
|
175
|
+
const prefixes = [...(this.tags ? ["refs/tags/"] : []), ...(this.heads ? ["refs/heads/"] : [])];
|
|
176
|
+
if (prefixes.length > 0) prefixes.push("HEAD");
|
|
177
|
+
const listRefs = async (connection: UploadPackConnection) =>
|
|
178
|
+
connection.version === 2
|
|
179
|
+
? await lsRefs(connection, prefixes)
|
|
180
|
+
: [...(connection.advertisedRefs ?? [])];
|
|
181
|
+
const listed = await withRemoteUploadPack(remote, options, listRefs);
|
|
165
182
|
|
|
166
|
-
// Filter refs based on heads/tags settings
|
|
167
183
|
const filteredRefs: RemoteRef[] = [];
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (this.heads && !refName.startsWith("refs/heads/")) {
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
if (this.tags && !refName.startsWith("refs/tags/")) {
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
+
for (const ref of listed) {
|
|
185
|
+
// HEAD only names the default branch; an unborn ref has no object
|
|
186
|
+
if (ref.name === "HEAD" || !ref.oid) continue;
|
|
187
|
+
// --heads and --tags: refs of either kind (git's REF_BRANCHES | REF_TAGS)
|
|
188
|
+
const wanted =
|
|
189
|
+
(!this.heads && !this.tags) ||
|
|
190
|
+
(this.heads && ref.name.startsWith("refs/heads/")) ||
|
|
191
|
+
(this.tags && ref.name.startsWith("refs/tags/"));
|
|
192
|
+
if (!wanted) continue;
|
|
184
193
|
filteredRefs.push({
|
|
185
|
-
name:
|
|
186
|
-
objectId:
|
|
194
|
+
name: ref.name,
|
|
195
|
+
objectId: ref.oid,
|
|
196
|
+
...(ref.peeled ? { peeledObjectId: ref.peeled } : {}),
|
|
197
|
+
...(ref.symref ? { symbolic: true, target: ref.symref } : {}),
|
|
187
198
|
});
|
|
188
199
|
}
|
|
189
200
|
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
201
|
+
// The default branch: HEAD's symref (v2 `symref-target`, v0's `symref=HEAD:` capability),
|
|
202
|
+
// else the first branch at HEAD's commit (a server that names no symref)
|
|
203
|
+
let defaultBranch: string | undefined;
|
|
204
|
+
const head = listed.find((r) => r.name === "HEAD");
|
|
205
|
+
if (head?.symref?.startsWith("refs/heads/")) {
|
|
206
|
+
defaultBranch = head.symref.slice("refs/heads/".length);
|
|
207
|
+
} else if (head?.oid) {
|
|
208
|
+
const match = listed.find((r) => r.name.startsWith("refs/heads/") && r.oid === head.oid);
|
|
209
|
+
if (match) defaultBranch = match.name.slice("refs/heads/".length);
|
|
200
210
|
}
|
|
201
211
|
|
|
202
212
|
return {
|
|
@@ -221,17 +231,50 @@ export class LsRemoteCommand extends TransportCommand<LsRemoteResult> {
|
|
|
221
231
|
}
|
|
222
232
|
|
|
223
233
|
/**
|
|
224
|
-
*
|
|
234
|
+
* The URL a remote resolves to, without contacting it: `git ls-remote --get-url
|
|
235
|
+
* [<remote>]` (the remote's first URL, or the URL given, with `insteadOf` applied). Without
|
|
236
|
+
* a remote, git's `remote_get(NULL)`: the current branch's `branch.<name>.remote` (read as a
|
|
237
|
+
* URL when no such remote has one), else the only configured remote, else `origin`; when
|
|
238
|
+
* that names no remote with a URL, git's "No remote configured to list refs from.".
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* // [url "https://example.com/"] insteadOf = ex:
|
|
243
|
+
* await git.lsRemote().setRemote("ex:repo.git").callGetUrl(); // "https://example.com/repo.git"
|
|
244
|
+
* ```
|
|
225
245
|
*
|
|
226
|
-
*
|
|
227
|
-
* configuration; an unconfigured name is passed through unchanged.
|
|
246
|
+
* @throws InvalidRemoteError "fatal: No remote configured to list refs from." (exit 128)
|
|
228
247
|
*/
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
248
|
+
async callGetUrl(): Promise<string> {
|
|
249
|
+
this.checkCallable();
|
|
250
|
+
this.setCallable(false);
|
|
251
|
+
return this.remoteUrl();
|
|
252
|
+
}
|
|
234
253
|
|
|
235
|
-
|
|
254
|
+
/** The URL of the remote given, or of git's default remote (see {@link callGetUrl}). */
|
|
255
|
+
private async remoteUrl(): Promise<string> {
|
|
256
|
+
const store = RemoteConfigStore.from(this.workingCopy);
|
|
257
|
+
if (this.remote !== undefined) {
|
|
258
|
+
this.remoteName = this.remote;
|
|
259
|
+
return store.remoteUrlOf(this.remote);
|
|
260
|
+
}
|
|
261
|
+
// remotes_remote_for_branch: an explicit branch remote is "given" (add_url_alias)
|
|
262
|
+
const head = await this.refsStore.get("HEAD");
|
|
263
|
+
if (head && isSymbolicRef(head) && head.target.startsWith("refs/heads/")) {
|
|
264
|
+
const branch = head.target.slice("refs/heads/".length);
|
|
265
|
+
const explicit = store.value(`branch.${branch}.remote`);
|
|
266
|
+
if (explicit !== undefined) {
|
|
267
|
+
this.remoteName = explicit;
|
|
268
|
+
return store.remoteUrlOf(explicit);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const names = store.configuredNames();
|
|
272
|
+
const name = names.length === 1 ? (names[0] ?? "origin") : "origin";
|
|
273
|
+
const url = store.urlFor(name);
|
|
274
|
+
if (url === undefined) {
|
|
275
|
+
throw new InvalidRemoteError(name, "fatal: No remote configured to list refs from.");
|
|
276
|
+
}
|
|
277
|
+
this.remoteName = name;
|
|
278
|
+
return url;
|
|
236
279
|
}
|
|
237
280
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git's mailmap (mailmap.c): `.mailmap`, `mailmap.blob` and `mailmap.file`, mapping the
|
|
3
|
+
* names and emails of commits to canonical ones (`%aN`, `%aE`, and `git log`'s headers when
|
|
4
|
+
* `log.mailmap` is on, its default).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const map = new Mailmap();
|
|
9
|
+
* map.read("Jane Doe <jane@example.com> <jane@old.example>\n");
|
|
10
|
+
* map.map("jane", "JANE@old.example"); // { name: "Jane Doe", email: "jane@example.com" }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
interface MailmapInfo {
|
|
17
|
+
name?: string;
|
|
18
|
+
email?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface MailmapEntry extends MailmapInfo {
|
|
22
|
+
/** The entries that also match the old name, by lower-cased name */
|
|
23
|
+
names: Map<string, MailmapInfo>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** strcasecmp's folding: ASCII letters only */
|
|
27
|
+
const fold = (s: string) => s.replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
28
|
+
|
|
29
|
+
/** git's isspace: space, tab, LF, CR */
|
|
30
|
+
const isSpace = (c: string | undefined) => c === " " || c === "\t" || c === "\n" || c === "\r";
|
|
31
|
+
|
|
32
|
+
/** mailmap.c's parse_name_and_email: the name, the email and what follows the `>`. */
|
|
33
|
+
function parseNameAndEmail(
|
|
34
|
+
buffer: string,
|
|
35
|
+
allowEmptyEmail: boolean,
|
|
36
|
+
): { name?: string; email?: string; rest?: string } {
|
|
37
|
+
const left = buffer.indexOf("<");
|
|
38
|
+
if (left < 0) return {};
|
|
39
|
+
const right = buffer.indexOf(">", left + 1);
|
|
40
|
+
if (right < 0) return {};
|
|
41
|
+
if (!allowEmptyEmail && left + 1 === right) return {};
|
|
42
|
+
let start = 0;
|
|
43
|
+
while (start < left && isSpace(buffer[start])) start++;
|
|
44
|
+
let end = left - 1;
|
|
45
|
+
while (end > start && isSpace(buffer[end])) end--;
|
|
46
|
+
const name = start <= end ? buffer.slice(start, end + 1) : undefined;
|
|
47
|
+
const email = buffer.slice(left + 1, right);
|
|
48
|
+
const rest = buffer.slice(right + 1);
|
|
49
|
+
return {
|
|
50
|
+
...(name !== undefined ? { name } : {}),
|
|
51
|
+
email,
|
|
52
|
+
...(rest !== "" ? { rest } : {}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** A mailmap: entries keyed by email, case-insensitively, as git's string list keeps them. */
|
|
57
|
+
export class Mailmap {
|
|
58
|
+
private readonly entries = new Map<string, MailmapEntry>();
|
|
59
|
+
|
|
60
|
+
/** Whether it has no entries (git maps nothing then). */
|
|
61
|
+
get empty(): boolean {
|
|
62
|
+
return this.entries.size === 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The lines of a mailmap file (read_mailmap_string / read_mailmap_file) added. */
|
|
66
|
+
read(text: string): this {
|
|
67
|
+
for (const raw of text.split("\n")) {
|
|
68
|
+
// fgets reads 1023 bytes at most; longer lines are rare enough to keep whole
|
|
69
|
+
this.readLine(raw);
|
|
70
|
+
}
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private readLine(buffer: string): void {
|
|
75
|
+
if (buffer.startsWith("#")) return;
|
|
76
|
+
const first = parseNameAndEmail(buffer, false);
|
|
77
|
+
if (first.email === undefined) return;
|
|
78
|
+
let name2: string | undefined;
|
|
79
|
+
let email2: string | undefined;
|
|
80
|
+
if (first.rest !== undefined) {
|
|
81
|
+
const second = parseNameAndEmail(first.rest, true);
|
|
82
|
+
name2 = second.name;
|
|
83
|
+
email2 = second.email;
|
|
84
|
+
}
|
|
85
|
+
this.add(first.name, first.email, name2, email2);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** mailmap.c's add_mapping. */
|
|
89
|
+
private add(
|
|
90
|
+
newName: string | undefined,
|
|
91
|
+
newEmail: string | undefined,
|
|
92
|
+
oldName: string | undefined,
|
|
93
|
+
oldEmail: string | undefined,
|
|
94
|
+
): void {
|
|
95
|
+
let key = oldEmail;
|
|
96
|
+
let email = newEmail;
|
|
97
|
+
if (key === undefined) {
|
|
98
|
+
key = newEmail as string;
|
|
99
|
+
email = undefined;
|
|
100
|
+
}
|
|
101
|
+
const lower = fold(key);
|
|
102
|
+
let entry = this.entries.get(lower);
|
|
103
|
+
if (!entry) {
|
|
104
|
+
entry = { names: new Map() };
|
|
105
|
+
this.entries.set(lower, entry);
|
|
106
|
+
}
|
|
107
|
+
if (oldName === undefined) {
|
|
108
|
+
if (newName !== undefined) entry.name = newName;
|
|
109
|
+
if (email !== undefined) entry.email = email;
|
|
110
|
+
} else {
|
|
111
|
+
entry.names.set(fold(oldName), {
|
|
112
|
+
...(newName !== undefined ? { name: newName } : {}),
|
|
113
|
+
...(email !== undefined ? { email } : {}),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** mailmap.c's map_user: the canonical name and email of an identity. */
|
|
119
|
+
map(name: string, email: string): { name: string; email: string } {
|
|
120
|
+
const entry = this.entries.get(fold(email));
|
|
121
|
+
if (!entry) return { name, email };
|
|
122
|
+
let info: MailmapInfo = entry;
|
|
123
|
+
if (entry.names.size > 0) {
|
|
124
|
+
const sub = entry.names.get(fold(name));
|
|
125
|
+
if (sub) info = sub;
|
|
126
|
+
}
|
|
127
|
+
return { name: info.name ?? name, email: info.email ?? email };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git's merge bases in git's order (`repo_get_merge_bases`), over real commits and the
|
|
3
|
+
* virtual commits merge-ort makes of merged merge bases (in memory, never stored).
|
|
4
|
+
*
|
|
5
|
+
* The order matters to merge-ort: with several bases it merges them pairwise, the oldest
|
|
6
|
+
* first, and which base is "Temporary merge branch 1" decides the virtual base's markers.
|
|
7
|
+
* git paints both sides down a queue ordered by committer date (ties in insertion order),
|
|
8
|
+
* collects the commits reached from both in the order they come out, drops the ones reachable
|
|
9
|
+
* from another, and sorts the rest by date (stable).
|
|
10
|
+
*
|
|
11
|
+
* With a commit-graph that has corrected commit dates the queue is ordered by generation
|
|
12
|
+
* first, as git's `compare_commits_by_gen_then_commit_date` (commits outside the graph and
|
|
13
|
+
* virtual ones have generation Infinity), and the redundancy check skips commits whose
|
|
14
|
+
* generation shows they cannot reach the base checked. A graph whose generations cannot be
|
|
15
|
+
* trusted (`CommitGraph.generationsTrusted`: zero levels, a corrupt record, generations not
|
|
16
|
+
* above the parents') gives every commit generation Infinity, as git reads a zero generation.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { CommitHeaderReader, Commits, ObjectId } from "@statewalker/vcs-core";
|
|
20
|
+
|
|
21
|
+
import type { CheckedEntry } from "./worktree-overwrite-checks.js";
|
|
22
|
+
|
|
23
|
+
/** A commit as the merge-base walk sees it: real (by id) or virtual (merge-ort's). */
|
|
24
|
+
export interface BaseNode {
|
|
25
|
+
/** The id of a real commit; undefined for a virtual one */
|
|
26
|
+
id?: ObjectId;
|
|
27
|
+
/** A key unique among the nodes (the id, or `virtual:<n>`) */
|
|
28
|
+
key: string;
|
|
29
|
+
/** Committer date (git's `commit->date`; 0 for a virtual commit) */
|
|
30
|
+
date: number;
|
|
31
|
+
/** The commit-graph generation (Infinity outside the graph and for a virtual commit) */
|
|
32
|
+
generation: number;
|
|
33
|
+
/** The parents, loaded on demand for a real commit */
|
|
34
|
+
parents(): Promise<BaseNode[]>;
|
|
35
|
+
/** The commit's tree as a flat map */
|
|
36
|
+
tree(): Promise<Map<string, CheckedEntry>>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** What {@link MergeBaseGraph} reads of real commits. */
|
|
40
|
+
export interface MergeBaseSource {
|
|
41
|
+
/**
|
|
42
|
+
* The commit's parents and committer timestamp (and commit-graph generation, Infinity when
|
|
43
|
+
* absent), undefined when missing
|
|
44
|
+
*/
|
|
45
|
+
load(
|
|
46
|
+
id: ObjectId,
|
|
47
|
+
): Promise<{ parents: ObjectId[]; date: number; generation?: number } | undefined>;
|
|
48
|
+
/** The flat tree of a commit */
|
|
49
|
+
tree(id: ObjectId): Promise<Map<string, CheckedEntry>>;
|
|
50
|
+
/** Whether generations are corrected commit dates (the queue is then ordered by them) */
|
|
51
|
+
generationOrder?(): Promise<boolean>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A source over a commit store: headers from the commit-graph where it has the commit (no
|
|
56
|
+
* commit is read), the queue ordered as git orders it with that graph. The source reads one
|
|
57
|
+
* graph for its whole life (the one loaded at its first read): a graph written while a merge
|
|
58
|
+
* base is computed does not mix its generations with the old one's.
|
|
59
|
+
*/
|
|
60
|
+
export function commitsBaseSource(
|
|
61
|
+
commits: Commits,
|
|
62
|
+
tree: (id: ObjectId) => Promise<Map<string, CheckedEntry>>,
|
|
63
|
+
): MergeBaseSource {
|
|
64
|
+
let reader: Promise<CommitHeaderReader | undefined> | undefined;
|
|
65
|
+
const pinned = () => {
|
|
66
|
+
reader ??= commits.headerReader?.().catch(() => undefined) ?? Promise.resolve(undefined);
|
|
67
|
+
return reader;
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
load: async (id) => {
|
|
71
|
+
const r = await pinned();
|
|
72
|
+
if (r) {
|
|
73
|
+
const h = await r.getHeader(id).catch(() => undefined);
|
|
74
|
+
return h ? { parents: h.parents, date: h.commitTime, generation: h.generation } : undefined;
|
|
75
|
+
}
|
|
76
|
+
const commit = await commits.load(id).catch(() => undefined);
|
|
77
|
+
return commit ? { parents: commit.parents, date: commit.committer.timestamp } : undefined;
|
|
78
|
+
},
|
|
79
|
+
tree,
|
|
80
|
+
// generations the graph does not trust are Infinity: the queue is then by date
|
|
81
|
+
generationOrder: async () => (await pinned())?.correctedDates ?? false,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const PARENT1 = 1;
|
|
86
|
+
const PARENT2 = 2;
|
|
87
|
+
const STALE = 4;
|
|
88
|
+
const RESULT = 8;
|
|
89
|
+
|
|
90
|
+
/** Real and virtual commits, and git's merge-base computation over them. */
|
|
91
|
+
export class MergeBaseGraph {
|
|
92
|
+
private readonly nodes = new Map<string, BaseNode>();
|
|
93
|
+
private virtuals = 0;
|
|
94
|
+
private byGeneration?: boolean;
|
|
95
|
+
|
|
96
|
+
constructor(private readonly source: MergeBaseSource) {}
|
|
97
|
+
|
|
98
|
+
/** The node of a real commit. */
|
|
99
|
+
commit(id: ObjectId): BaseNode {
|
|
100
|
+
const known = this.nodes.get(id);
|
|
101
|
+
if (known) return known;
|
|
102
|
+
let loaded:
|
|
103
|
+
| Promise<{ parents: ObjectId[]; date: number; generation?: number } | undefined>
|
|
104
|
+
| undefined;
|
|
105
|
+
const load = () => {
|
|
106
|
+
loaded ??= this.source.load(id);
|
|
107
|
+
return loaded;
|
|
108
|
+
};
|
|
109
|
+
let date = 0;
|
|
110
|
+
let generation = Number.POSITIVE_INFINITY;
|
|
111
|
+
const node: BaseNode = {
|
|
112
|
+
id,
|
|
113
|
+
key: id,
|
|
114
|
+
get date() {
|
|
115
|
+
return date;
|
|
116
|
+
},
|
|
117
|
+
get generation() {
|
|
118
|
+
return generation;
|
|
119
|
+
},
|
|
120
|
+
parents: async () => ((await load())?.parents ?? []).map((p) => this.commit(p)),
|
|
121
|
+
tree: () => this.source.tree(id),
|
|
122
|
+
};
|
|
123
|
+
// the date is needed synchronously by the queue: read before the node is queued
|
|
124
|
+
(node as { ready?: Promise<void> }).ready = load().then((c) => {
|
|
125
|
+
date = c?.date ?? 0;
|
|
126
|
+
generation = c?.generation ?? Number.POSITIVE_INFINITY;
|
|
127
|
+
});
|
|
128
|
+
this.nodes.set(id, node);
|
|
129
|
+
return node;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** A virtual commit (merge-ort's `make_virtual_commit`): date 0, the given parents. */
|
|
133
|
+
virtual(tree: Map<string, CheckedEntry>, parents: BaseNode[]): BaseNode {
|
|
134
|
+
const node: BaseNode = {
|
|
135
|
+
key: `virtual:${this.virtuals++}`,
|
|
136
|
+
date: 0,
|
|
137
|
+
generation: Number.POSITIVE_INFINITY,
|
|
138
|
+
parents: async () => parents,
|
|
139
|
+
tree: async () => tree,
|
|
140
|
+
};
|
|
141
|
+
this.nodes.set(node.key, node);
|
|
142
|
+
return node;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private async ready(node: BaseNode): Promise<void> {
|
|
146
|
+
await (node as { ready?: Promise<void> }).ready;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* git's paint_down_to_common: the commits reached from both `one` and `twos`, in the
|
|
151
|
+
* order the date queue yields them (`flags` is left as the walk painted it).
|
|
152
|
+
*/
|
|
153
|
+
private async paintDownToCommon(
|
|
154
|
+
one: BaseNode,
|
|
155
|
+
twos: BaseNode[],
|
|
156
|
+
flags: Map<string, number>,
|
|
157
|
+
): Promise<BaseNode[]> {
|
|
158
|
+
const result: BaseNode[] = [];
|
|
159
|
+
const flag = (n: BaseNode) => flags.get(n.key) ?? 0;
|
|
160
|
+
// a priority queue by date (newest first), ties in insertion order (git's prio_queue)
|
|
161
|
+
type Item = { node: BaseNode; ctr: number };
|
|
162
|
+
const heap: Item[] = [];
|
|
163
|
+
const byGeneration = this.byGeneration === true;
|
|
164
|
+
const before = (a: Item, b: Item) => {
|
|
165
|
+
if (byGeneration && a.node.generation !== b.node.generation) {
|
|
166
|
+
return a.node.generation > b.node.generation;
|
|
167
|
+
}
|
|
168
|
+
return a.node.date > b.node.date || (a.node.date === b.node.date && a.ctr < b.ctr);
|
|
169
|
+
};
|
|
170
|
+
// how many queued entries each commit has, and how many entries are not stale
|
|
171
|
+
const queued = new Map<string, number>();
|
|
172
|
+
let nonStale = 0;
|
|
173
|
+
let ctr = 0;
|
|
174
|
+
const put = async (node: BaseNode) => {
|
|
175
|
+
await this.ready(node);
|
|
176
|
+
const item = { node, ctr: ctr++ };
|
|
177
|
+
heap.push(item);
|
|
178
|
+
for (let i = heap.length - 1; i > 0; ) {
|
|
179
|
+
const p = (i - 1) >> 1;
|
|
180
|
+
if (!before(heap[i], heap[p])) break;
|
|
181
|
+
[heap[i], heap[p]] = [heap[p], heap[i]];
|
|
182
|
+
i = p;
|
|
183
|
+
}
|
|
184
|
+
queued.set(node.key, (queued.get(node.key) ?? 0) + 1);
|
|
185
|
+
if (!(flag(node) & STALE)) nonStale++;
|
|
186
|
+
};
|
|
187
|
+
const get = (): BaseNode => {
|
|
188
|
+
const top = heap[0];
|
|
189
|
+
const last = heap.pop() as Item;
|
|
190
|
+
if (heap.length > 0) {
|
|
191
|
+
heap[0] = last;
|
|
192
|
+
for (let i = 0; ; ) {
|
|
193
|
+
const l = 2 * i + 1;
|
|
194
|
+
const r = l + 1;
|
|
195
|
+
let m = i;
|
|
196
|
+
if (l < heap.length && before(heap[l], heap[m])) m = l;
|
|
197
|
+
if (r < heap.length && before(heap[r], heap[m])) m = r;
|
|
198
|
+
if (m === i) break;
|
|
199
|
+
[heap[i], heap[m]] = [heap[m], heap[i]];
|
|
200
|
+
i = m;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
queued.set(top.node.key, (queued.get(top.node.key) ?? 1) - 1);
|
|
204
|
+
if (!(flag(top.node) & STALE)) nonStale--;
|
|
205
|
+
return top.node;
|
|
206
|
+
};
|
|
207
|
+
const paint = (node: BaseNode, add: number) => {
|
|
208
|
+
const was = flag(node);
|
|
209
|
+
flags.set(node.key, was | add);
|
|
210
|
+
// a commit turning stale: its queued entries are stale now
|
|
211
|
+
if (!(was & STALE) && add & STALE) nonStale -= queued.get(node.key) ?? 0;
|
|
212
|
+
};
|
|
213
|
+
paint(one, PARENT1);
|
|
214
|
+
if (twos.length === 0) return [one];
|
|
215
|
+
await put(one);
|
|
216
|
+
for (const two of twos) {
|
|
217
|
+
paint(two, PARENT2);
|
|
218
|
+
await put(two);
|
|
219
|
+
}
|
|
220
|
+
while (nonStale > 0) {
|
|
221
|
+
const commit = get();
|
|
222
|
+
let f = flag(commit) & (PARENT1 | PARENT2 | STALE);
|
|
223
|
+
if (f === (PARENT1 | PARENT2)) {
|
|
224
|
+
if (!(flag(commit) & RESULT)) {
|
|
225
|
+
paint(commit, RESULT);
|
|
226
|
+
result.push(commit);
|
|
227
|
+
}
|
|
228
|
+
// the parents of a found merge base are stale
|
|
229
|
+
f |= STALE;
|
|
230
|
+
}
|
|
231
|
+
for (const parent of await commit.parents()) {
|
|
232
|
+
if ((flag(parent) & f) === f) continue;
|
|
233
|
+
paint(parent, f);
|
|
234
|
+
await put(parent);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return result;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Whether `node` is reachable from one of `from` (git's redundancy check). A commit whose
|
|
242
|
+
* generation is below `node`'s (or equal and finite) cannot reach it and is not walked.
|
|
243
|
+
*/
|
|
244
|
+
private async reachable(node: BaseNode, from: BaseNode[]): Promise<boolean> {
|
|
245
|
+
await this.ready(node);
|
|
246
|
+
const target = node.generation;
|
|
247
|
+
const cannotReach = (n: BaseNode) =>
|
|
248
|
+
n.generation < target || (n.generation === target && Number.isFinite(target));
|
|
249
|
+
const seen = new Set<string>();
|
|
250
|
+
const stack = [...from];
|
|
251
|
+
while (stack.length > 0) {
|
|
252
|
+
const n = stack.pop() as BaseNode;
|
|
253
|
+
if (seen.has(n.key)) continue;
|
|
254
|
+
seen.add(n.key);
|
|
255
|
+
if (n !== node && n.key === node.key) return true;
|
|
256
|
+
for (const p of await n.parents()) {
|
|
257
|
+
if (p.key === node.key) return true;
|
|
258
|
+
await this.ready(p);
|
|
259
|
+
if (!seen.has(p.key) && !cannotReach(p)) stack.push(p);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** git's repo_get_merge_bases(one, two), in git's order (newest first). */
|
|
266
|
+
async mergeBases(one: BaseNode, two: BaseNode): Promise<BaseNode[]> {
|
|
267
|
+
return this.mergeBasesMany(one, [two]);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** git's repo_get_merge_bases_many(one, twos) (`git merge-base --all one twos...`). */
|
|
271
|
+
async mergeBasesMany(one: BaseNode, twos: BaseNode[]): Promise<BaseNode[]> {
|
|
272
|
+
if (twos.some((two) => two.key === one.key)) return [one];
|
|
273
|
+
this.byGeneration ??= (await this.source.generationOrder?.()) ?? false;
|
|
274
|
+
const flags = new Map<string, number>();
|
|
275
|
+
const list = await this.paintDownToCommon(one, twos, flags);
|
|
276
|
+
const byDate = (nodes: BaseNode[]) => nodes.map((n, i) => ({ n, i }));
|
|
277
|
+
const sortByDate = (nodes: BaseNode[]) =>
|
|
278
|
+
byDate(nodes)
|
|
279
|
+
.sort((a, b) => b.n.date - a.n.date || a.i - b.i)
|
|
280
|
+
.map((x) => x.n);
|
|
281
|
+
const result = sortByDate(list.filter((n) => !((flags.get(n.key) ?? 0) & STALE)));
|
|
282
|
+
if (result.length <= 1) return result;
|
|
283
|
+
// remove_redundant: a base reachable from another is dropped (the array's order kept)
|
|
284
|
+
const redundant = new Array(result.length).fill(false);
|
|
285
|
+
for (let i = 0; i < result.length; i++) {
|
|
286
|
+
if (redundant[i]) continue;
|
|
287
|
+
const others = result.filter((_, j) => j !== i && !redundant[j]);
|
|
288
|
+
if (await this.reachable(result[i], others)) redundant[i] = true;
|
|
289
|
+
for (let j = 0; j < result.length; j++) {
|
|
290
|
+
if (j === i || redundant[j]) continue;
|
|
291
|
+
if (await this.reachable(result[j], [result[i]])) redundant[j] = true;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return sortByDate(result.filter((_, i) => !redundant[i]));
|
|
295
|
+
}
|
|
296
|
+
}
|