@statewalker/vcs-commands 0.7.0 → 0.9.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/dist/commands/add-command.d.ts +70 -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.map +1 -1
- package/dist/commands/am/am-command.d.ts +102 -1
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/am/index.d.ts +1 -0
- package/dist/commands/am/index.d.ts.map +1 -1
- package/dist/commands/am/mailsplit.d.ts +88 -0
- package/dist/commands/am/mailsplit.d.ts.map +1 -0
- 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-engine.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/bisect/bisect-command.d.ts +2 -0
- package/dist/commands/bisect/bisect-command.d.ts.map +1 -1
- package/dist/commands/blame-command.d.ts +303 -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/branch-command.d.ts +148 -18
- package/dist/commands/branch-command.d.ts.map +1 -1
- package/dist/commands/branch-info-command.d.ts +55 -0
- package/dist/commands/branch-info-command.d.ts.map +1 -0
- package/dist/commands/branch-tracking.d.ts +106 -17
- package/dist/commands/branch-tracking.d.ts.map +1 -1
- package/dist/commands/branch-upstream-command.d.ts +83 -0
- package/dist/commands/branch-upstream-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/checkout-command.d.ts +26 -3
- package/dist/commands/checkout-command.d.ts.map +1 -1
- 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 +82 -1
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +44 -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 +116 -2
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +239 -5
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/commit-reuse.d.ts +33 -0
- package/dist/commands/commit-reuse.d.ts.map +1 -0
- package/dist/commands/config-command.d.ts +236 -0
- package/dist/commands/config-command.d.ts.map +1 -0
- package/dist/commands/config-value-types.d.ts +91 -0
- package/dist/commands/config-value-types.d.ts.map +1 -0
- package/dist/commands/core-config.d.ts +20 -0
- package/dist/commands/core-config.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-color-config.d.ts +73 -0
- package/dist/commands/diff-color-config.d.ts.map +1 -0
- package/dist/commands/diff-command.d.ts +369 -10
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +80 -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/fmt-merge-msg-command.d.ts +124 -0
- package/dist/commands/fmt-merge-msg-command.d.ts.map +1 -0
- package/dist/commands/fork-point.d.ts +38 -0
- package/dist/commands/fork-point.d.ts.map +1 -0
- package/dist/commands/format-patch-command.d.ts +69 -3
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/fsck/fetch-fsck.d.ts +51 -0
- package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -1
- package/dist/commands/gc-command.d.ts +8 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +81 -4
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +50 -1
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/grep/grep-command.d.ts +210 -0
- package/dist/commands/grep/grep-command.d.ts.map +1 -0
- package/dist/commands/grep/grep-engine.d.ts +218 -0
- package/dist/commands/grep/grep-engine.d.ts.map +1 -0
- package/dist/commands/grep/index.d.ts +3 -0
- package/dist/commands/grep/index.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +13 -2
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index.d.ts +38 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +5 -3
- package/dist/commands/init-command.d.ts +89 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/interpret-trailers-command.d.ts +90 -0
- package/dist/commands/interpret-trailers-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 +36 -5
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +527 -13
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +30 -3
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +199 -6
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-remote-command.d.ts +2 -0
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/mailmap.d.ts +53 -0
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/merge-base-command.d.ts +60 -0
- package/dist/commands/merge-base-command.d.ts.map +1 -0
- package/dist/commands/merge-bases.d.ts +23 -0
- package/dist/commands/merge-bases.d.ts.map +1 -1
- package/dist/commands/merge-command.d.ts +147 -10
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-drivers.d.ts +2 -0
- 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 +10 -0
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/message-cleanup.d.ts +2 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -1
- package/dist/commands/mv-command.d.ts +4 -0
- package/dist/commands/mv-command.d.ts.map +1 -1
- 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 +136 -0
- package/dist/commands/name-rev.d.ts.map +1 -0
- package/dist/commands/notes-command.d.ts.map +1 -1
- 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 +16 -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.d.ts +58 -0
- package/dist/commands/patch-id.d.ts.map +1 -1
- package/dist/commands/pathspec-file.d.ts +39 -0
- package/dist/commands/pathspec-file.d.ts.map +1 -0
- package/dist/commands/pathspec.d.ts +3 -0
- package/dist/commands/pathspec.d.ts.map +1 -1
- package/dist/commands/pretty-format.d.ts +43 -3
- package/dist/commands/pretty-format.d.ts.map +1 -1
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +186 -32
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +225 -9
- 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 +20 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +189 -8
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/for-each-ref-command.d.ts +121 -0
- package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -0
- package/dist/commands/ref-filter/index.d.ts +8 -0
- package/dist/commands/ref-filter/index.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-atoms.d.ts +88 -0
- package/dist/commands/ref-filter/ref-atoms.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-filter.d.ts +178 -0
- package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-format.d.ts +222 -0
- package/dist/commands/ref-filter/ref-format.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts +56 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-quote.d.ts +20 -0
- package/dist/commands/ref-filter/ref-quote.d.ts.map +1 -0
- package/dist/commands/ref-filter/version-compare.d.ts +20 -0
- package/dist/commands/ref-filter/version-compare.d.ts.map +1 -0
- package/dist/commands/reflog-command.d.ts +120 -0
- package/dist/commands/reflog-command.d.ts.map +1 -1
- package/dist/commands/reflog-walk.d.ts +72 -0
- package/dist/commands/reflog-walk.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 +179 -29
- package/dist/commands/remote-command.d.ts.map +1 -1
- 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 +7 -1
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/reset-command.d.ts +21 -4
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +9 -3
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-filter/commit-filter.d.ts +95 -0
- package/dist/commands/rev-filter/commit-filter.d.ts.map +1 -0
- package/dist/commands/rev-filter/commit-grep.d.ts +91 -0
- package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -0
- package/dist/commands/rev-filter/index.d.ts +3 -0
- package/dist/commands/rev-filter/index.d.ts.map +1 -0
- package/dist/commands/rev-list-command.d.ts +226 -2
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +54 -1
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +34 -1
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +15 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/rm-command.d.ts +70 -2
- package/dist/commands/rm-command.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +186 -5
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +12 -1
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +7 -0
- package/dist/commands/serve-repository.d.ts.map +1 -1
- 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-command.d.ts +130 -0
- package/dist/commands/show-command.d.ts.map +1 -0
- package/dist/commands/show-commit.d.ts +11 -0
- package/dist/commands/show-commit.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +164 -0
- package/dist/commands/signature-check.d.ts.map +1 -0
- package/dist/commands/signing.d.ts +160 -0
- package/dist/commands/signing.d.ts.map +1 -0
- package/dist/commands/sparse-checkout-command.d.ts.map +1 -1
- package/dist/commands/sparse-index-view.d.ts +45 -0
- package/dist/commands/sparse-index-view.d.ts.map +1 -0
- package/dist/commands/ssh-signer.d.ts +29 -0
- package/dist/commands/ssh-signer.d.ts.map +1 -0
- package/dist/commands/ssh-verifier.d.ts +42 -0
- package/dist/commands/ssh-verifier.d.ts.map +1 -0
- package/dist/commands/stash-apply-command.d.ts +5 -0
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-branch-command.d.ts +34 -0
- package/dist/commands/stash-branch-command.d.ts.map +1 -0
- package/dist/commands/stash-create-command.d.ts +17 -0
- package/dist/commands/stash-create-command.d.ts.map +1 -1
- package/dist/commands/stash-info.d.ts +93 -0
- package/dist/commands/stash-info.d.ts.map +1 -0
- package/dist/commands/stash-list-command.d.ts +16 -0
- package/dist/commands/stash-list-command.d.ts.map +1 -1
- package/dist/commands/stash-pop-command.d.ts +39 -0
- package/dist/commands/stash-pop-command.d.ts.map +1 -0
- package/dist/commands/stash-show-command.d.ts +48 -0
- package/dist/commands/stash-show-command.d.ts.map +1 -0
- package/dist/commands/stash-store-command.d.ts +29 -0
- package/dist/commands/stash-store-command.d.ts.map +1 -0
- package/dist/commands/stash-working-tree.d.ts.map +1 -1
- package/dist/commands/status-command.d.ts +31 -2
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/status-header.d.ts +5 -0
- package/dist/commands/status-header.d.ts.map +1 -1
- package/dist/commands/submodule-add-command.d.ts +89 -0
- package/dist/commands/submodule-add-command.d.ts.map +1 -0
- package/dist/commands/submodule-auth.d.ts +90 -0
- package/dist/commands/submodule-auth.d.ts.map +1 -0
- package/dist/commands/submodule-commands.d.ts +463 -0
- package/dist/commands/submodule-commands.d.ts.map +1 -0
- 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 +296 -0
- package/dist/commands/submodule-model.d.ts.map +1 -0
- 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 +206 -0
- package/dist/commands/submodule-update-command.d.ts.map +1 -0
- 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/tag-command.d.ts +259 -10
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/trailers.d.ts +218 -17
- package/dist/commands/trailers.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts +7 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/verify-command.d.ts +92 -0
- package/dist/commands/verify-command.d.ts.map +1 -0
- package/dist/commands/worktree-add-command.d.ts +79 -7
- package/dist/commands/worktree-add-command.d.ts.map +1 -1
- package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/commands/worktree-path-rules.d.ts +66 -0
- package/dist/commands/worktree-path-rules.d.ts.map +1 -0
- package/dist/commands/worktree-remove-command.d.ts +10 -3
- package/dist/commands/worktree-remove-command.d.ts.map +1 -1
- package/dist/commands/worktree-repair-command.d.ts +15 -2
- package/dist/commands/worktree-repair-command.d.ts.map +1 -1
- package/dist/commands/worktree-support.d.ts +5 -0
- package/dist/commands/worktree-support.d.ts.map +1 -1
- package/dist/{commands-DIJ91NnD.js → commands-CNvli5bl.js} +49442 -54941
- package/dist/errors/checkout-errors.d.ts +19 -0
- package/dist/errors/checkout-errors.d.ts.map +1 -1
- package/dist/errors/command-errors.d.ts +25 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +85 -3
- package/dist/errors/ref-errors.d.ts +19 -0
- package/dist/errors/ref-errors.d.ts.map +1 -1
- package/dist/errors/worktree-errors.d.ts +6 -1
- package/dist/errors/worktree-errors.d.ts.map +1 -1
- package/dist/fsck-CPeDh9fh.js +5138 -0
- package/dist/git-command.d.ts +58 -2
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +363 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +82 -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 +6 -5
- package/dist/remote-config/index.d.ts +1 -1
- package/dist/remote-config/index.d.ts.map +1 -1
- package/dist/remote-config/remote-config-store.d.ts +55 -0
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/remote-transport-CCmBadm-.js +1606 -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/clone-result.d.ts +9 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/combined-diff.d.ts +3 -0
- package/dist/results/combined-diff.d.ts.map +1 -1
- package/dist/results/diff-check.d.ts +38 -0
- package/dist/results/diff-check.d.ts.map +1 -0
- package/dist/results/diff-color.d.ts +135 -0
- package/dist/results/diff-color.d.ts.map +1 -0
- 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 +10 -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 +103 -1
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/diff-pickaxe.d.ts +67 -0
- package/dist/results/diff-pickaxe.d.ts.map +1 -0
- package/dist/results/diff-words.d.ts +55 -0
- package/dist/results/diff-words.d.ts.map +1 -0
- package/dist/results/fetch-result.d.ts +12 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +6 -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 +8 -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 +12 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +2 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +6 -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-BDuEgdLU.js +46847 -0
- package/dist/transport-command.d.ts +14 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/dist/whitespace/index.d.ts +2 -0
- package/dist/whitespace/index.d.ts.map +1 -0
- package/dist/whitespace/whitespace-rule.d.ts +94 -0
- package/dist/whitespace/whitespace-rule.d.ts.map +1 -0
- package/package.json +12 -12
- package/src/commands/add-command.ts +293 -17
- package/src/commands/add-patch/add-patch.ts +8 -0
- package/src/commands/add-patch/patch-backend.ts +20 -2
- package/src/commands/am/am-command.ts +400 -46
- package/src/commands/am/index.ts +1 -0
- package/src/commands/am/mailsplit.ts +326 -0
- package/src/commands/apply/apply-command.ts +58 -15
- package/src/commands/apply/apply-engine.ts +1 -1
- package/src/commands/apply/apply-parse.ts +17 -8
- package/src/commands/apply/index.ts +8 -1
- package/src/commands/bisect/bisect-command.ts +18 -5
- package/src/commands/blame-command.ts +1450 -51
- package/src/commands/blame-ignore.ts +307 -0
- package/src/commands/branch-command.ts +528 -53
- package/src/commands/branch-info-command.ts +150 -0
- package/src/commands/branch-tracking.ts +335 -60
- package/src/commands/branch-upstream-command.ts +218 -0
- package/src/commands/check-mailmap-command.ts +129 -0
- package/src/commands/checkout-command.ts +166 -55
- package/src/commands/checkout-paths.ts +28 -0
- package/src/commands/cherry-command.ts +187 -0
- package/src/commands/cherry-pick-command.ts +185 -1
- package/src/commands/clean-command.ts +126 -15
- package/src/commands/clean-interactive.ts +522 -0
- package/src/commands/clone-command.ts +598 -45
- package/src/commands/commit-command.ts +925 -74
- package/src/commands/commit-reuse.ts +94 -0
- package/src/commands/config-command.ts +1256 -0
- package/src/commands/config-value-types.ts +358 -0
- package/src/commands/core-config.ts +40 -0
- package/src/commands/describe-command.ts +341 -254
- package/src/commands/diff-color-config.ts +274 -0
- package/src/commands/diff-command.ts +1619 -99
- package/src/commands/fetch-command.ts +495 -14
- package/src/commands/fetch-multiple-command.ts +665 -0
- package/src/commands/fmt-merge-msg-command.ts +715 -0
- package/src/commands/fork-point.ts +63 -0
- package/src/commands/format-patch-command.ts +496 -116
- package/src/commands/fsck/fetch-fsck.ts +172 -18
- package/src/commands/gc-command.ts +31 -1
- package/src/commands/git-describe.ts +460 -201
- package/src/commands/git-hooks.ts +123 -3
- package/src/commands/grep/grep-command.ts +1077 -0
- package/src/commands/grep/grep-engine.ts +1024 -0
- package/src/commands/grep/index.ts +2 -0
- package/src/commands/index-adder.ts +46 -7
- package/src/commands/index.ts +43 -0
- package/src/commands/init-command.ts +603 -49
- package/src/commands/interpret-trailers-command.ts +256 -0
- package/src/commands/line-log.ts +931 -0
- package/src/commands/local-transport.ts +109 -10
- package/src/commands/log-command.ts +2599 -326
- package/src/commands/log-graph.ts +129 -29
- package/src/commands/log-output.ts +449 -27
- package/src/commands/ls-remote-command.ts +5 -0
- package/src/commands/mailmap.ts +155 -0
- package/src/commands/merge-base-command.ts +170 -0
- package/src/commands/merge-bases.ts +63 -8
- package/src/commands/merge-command.ts +601 -95
- package/src/commands/merge-drivers.ts +3 -0
- package/src/commands/merge-strategy-options.ts +224 -0
- package/src/commands/merge-support.ts +115 -22
- package/src/commands/message-cleanup.ts +1 -1
- package/src/commands/mv-command.ts +6 -3
- package/src/commands/name-rev-command.ts +184 -0
- package/src/commands/name-rev.ts +762 -0
- package/src/commands/notes-command.ts +11 -1
- package/src/commands/octopus-merge.ts +35 -11
- package/src/commands/ort-merge.ts +41 -7
- package/src/commands/ort-recursive.ts +40 -2
- package/src/commands/patch-id.ts +109 -0
- package/src/commands/pathspec-file.ts +72 -0
- package/src/commands/pathspec.ts +14 -2
- package/src/commands/pretty-format.ts +103 -19
- package/src/commands/promisor-remote.ts +10 -1
- package/src/commands/pull-command.ts +734 -221
- package/src/commands/push-command.ts +1035 -68
- 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 +102 -4
- package/src/commands/rebase-command.ts +1074 -194
- package/src/commands/ref-filter/for-each-ref-command.ts +298 -0
- package/src/commands/ref-filter/index.ts +7 -0
- package/src/commands/ref-filter/ref-atoms.ts +581 -0
- package/src/commands/ref-filter/ref-filter.ts +651 -0
- package/src/commands/ref-filter/ref-format.ts +1070 -0
- package/src/commands/ref-filter/ref-listing-command.ts +421 -0
- package/src/commands/ref-filter/ref-quote.ts +69 -0
- package/src/commands/ref-filter/version-compare.ts +177 -0
- package/src/commands/reflog-command.ts +492 -2
- package/src/commands/reflog-walk.ts +234 -0
- package/src/commands/remerge-diff.ts +241 -0
- package/src/commands/remote-command.ts +537 -69
- package/src/commands/remote-show-command.ts +836 -0
- package/src/commands/remote-transport.ts +9 -1
- package/src/commands/reset-command.ts +114 -34
- package/src/commands/restore-command.ts +27 -41
- package/src/commands/rev-filter/commit-filter.ts +159 -0
- package/src/commands/rev-filter/commit-grep.ts +444 -0
- package/src/commands/rev-filter/index.ts +2 -0
- package/src/commands/rev-list-command.ts +578 -15
- package/src/commands/revert-command.ts +123 -1
- package/src/commands/revision-range.ts +207 -5
- package/src/commands/revision-resolver.ts +23 -8
- package/src/commands/rm-command.ts +282 -21
- package/src/commands/sequencer-pick.ts +818 -111
- package/src/commands/sequencer-support.ts +184 -4
- package/src/commands/serve-repository.ts +18 -3
- package/src/commands/shortlog-command.ts +354 -0
- package/src/commands/shortlog.ts +361 -0
- package/src/commands/show-command.ts +491 -0
- package/src/commands/show-commit.ts +24 -0
- package/src/commands/signature-check.ts +657 -0
- package/src/commands/signing.ts +385 -0
- package/src/commands/sparse-checkout-command.ts +2 -9
- package/src/commands/sparse-checkout-support.ts +2 -2
- package/src/commands/sparse-index-view.ts +135 -0
- package/src/commands/ssh-signer.ts +199 -0
- package/src/commands/ssh-verifier.ts +523 -0
- package/src/commands/stash-apply-command.ts +16 -4
- package/src/commands/stash-branch-command.ts +88 -0
- package/src/commands/stash-create-command.ts +28 -0
- package/src/commands/stash-info.ts +243 -0
- package/src/commands/stash-list-command.ts +33 -0
- package/src/commands/stash-pop-command.ts +83 -0
- package/src/commands/stash-show-command.ts +141 -0
- package/src/commands/stash-store-command.ts +82 -0
- package/src/commands/stash-working-tree.ts +2 -2
- package/src/commands/status-command.ts +120 -27
- package/src/commands/status-format.ts +1 -1
- package/src/commands/status-header.ts +41 -7
- package/src/commands/submodule-add-command.ts +509 -0
- package/src/commands/submodule-auth.ts +276 -0
- package/src/commands/submodule-commands.ts +1835 -0
- package/src/commands/submodule-fetch.ts +789 -0
- package/src/commands/submodule-model.ts +938 -0
- package/src/commands/submodule-unpack.ts +265 -0
- package/src/commands/submodule-update-command.ts +1126 -0
- package/src/commands/subtree-shift.ts +215 -0
- package/src/commands/switch-command.ts +12 -1
- package/src/commands/tag-command.ts +876 -64
- package/src/commands/trailers.ts +837 -100
- package/src/commands/tree-restore.ts +44 -11
- package/src/commands/verify-command.ts +235 -0
- package/src/commands/worktree-add-command.ts +268 -24
- package/src/commands/worktree-overwrite-checks.ts +5 -0
- package/src/commands/worktree-path-rules.ts +183 -0
- package/src/commands/worktree-remove-command.ts +39 -5
- package/src/commands/worktree-repair-command.ts +52 -5
- package/src/commands/worktree-support.ts +22 -1
- package/src/errors/checkout-errors.ts +29 -0
- package/src/errors/command-errors.ts +37 -1
- package/src/errors/ref-errors.ts +23 -0
- package/src/errors/worktree-errors.ts +8 -1
- package/src/git-command.ts +153 -2
- package/src/git.ts +550 -1
- package/src/guarded-transport-command.ts +171 -0
- package/src/index.ts +1 -0
- package/src/remote-config/index.ts +2 -0
- package/src/remote-config/remote-config-store.ts +101 -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/clone-result.ts +6 -0
- package/src/results/combined-diff.ts +38 -18
- package/src/results/diff-check.ts +185 -0
- package/src/results/diff-color.ts +868 -0
- package/src/results/diff-dirstat.ts +117 -0
- package/src/results/diff-entry.ts +12 -0
- package/src/results/diff-formatter.ts +1 -0
- package/src/results/diff-output.ts +322 -32
- package/src/results/diff-pickaxe.ts +304 -0
- package/src/results/diff-words.ts +395 -0
- package/src/results/fetch-result.ts +12 -1
- package/src/results/index.ts +6 -0
- package/src/results/init-result.ts +10 -1
- package/src/results/line-range-hunks.ts +126 -0
- package/src/results/merge-result.ts +9 -0
- package/src/results/pull-result.ts +7 -0
- package/src/results/push-result.ts +12 -0
- package/src/results/rebase-result.ts +3 -0
- package/src/results/stash-result.ts +7 -0
- package/src/results/status-result.ts +2 -2
- package/src/transport-command.ts +34 -3
- package/src/whitespace/index.ts +1 -0
- package/src/{commands/apply/whitespace.ts → whitespace/whitespace-rule.ts} +173 -23
- package/dist/commands/apply/whitespace.d.ts +0 -58
- package/dist/commands/apply/whitespace.d.ts.map +0 -1
- package/dist/git-command-BGiOJ8Zk.js +0 -7246
- package/dist/results-WVlBhVb1.js +0 -2935
|
@@ -21,19 +21,24 @@ import {
|
|
|
21
21
|
} from "../errors/merge-errors.js";
|
|
22
22
|
import { NotACommitError, RefNotFoundError } from "../errors/ref-errors.js";
|
|
23
23
|
import type { CommandCommits, CommandRefs, CommandTrees } from "../git-command.js";
|
|
24
|
+
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
24
25
|
import { coreBool, createIdAbbreviator, type IdAbbreviator } from "./core-config.js";
|
|
25
26
|
import { type HookSession, sequencerPostCommit, sequencerPrepareMessage } from "./git-hooks.js";
|
|
26
27
|
import { authorIdentOf, committerIdentOf } from "./git-ident.js";
|
|
27
28
|
import { UNMERGED_FILES_MESSAGE } from "./merge-command.js";
|
|
28
29
|
import { conflictStyleOf } from "./merge-config.js";
|
|
29
30
|
import { ortConfigOptions } from "./merge-drivers.js";
|
|
31
|
+
import { parseStrategyOptions, strategyOrtOptions } from "./merge-strategy-options.js";
|
|
30
32
|
import {
|
|
31
33
|
conflictsComment,
|
|
32
34
|
FlatTreeCache,
|
|
35
|
+
flatTree,
|
|
36
|
+
indexChanges,
|
|
33
37
|
indexChangesFromTree,
|
|
34
38
|
type MergeWriteContext,
|
|
35
39
|
type OperationState,
|
|
36
40
|
readIndex,
|
|
41
|
+
storeFlatTree,
|
|
37
42
|
storeFlatTreeOver,
|
|
38
43
|
subjectOf,
|
|
39
44
|
switchTrees,
|
|
@@ -41,7 +46,8 @@ import {
|
|
|
41
46
|
writeIndexAsTree,
|
|
42
47
|
} from "./merge-support.js";
|
|
43
48
|
import { stripspace } from "./message-cleanup.js";
|
|
44
|
-
import {
|
|
49
|
+
import { octopusMerge } from "./octopus-merge.js";
|
|
50
|
+
import { type OrtConflict, ortResultEntries } from "./ort-merge.js";
|
|
45
51
|
import { mergeStoredTrees, storedBase } from "./ort-recursive.js";
|
|
46
52
|
import { reflogLine, reflogMessages, updateHead } from "./reflog-messages.js";
|
|
47
53
|
import {
|
|
@@ -50,6 +56,9 @@ import {
|
|
|
50
56
|
removeBranchState,
|
|
51
57
|
resetMerge,
|
|
52
58
|
} from "./sequencer-support.js";
|
|
59
|
+
import { SigningFailedError, type SignRequest, signCommit, signRequestOf } from "./signing.js";
|
|
60
|
+
import { appendSignoff, signoffLine, trailerConfigOf, trailerLinesOf } from "./trailers.js";
|
|
61
|
+
import type { CheckedEntry } from "./worktree-overwrite-checks.js";
|
|
53
62
|
|
|
54
63
|
/** What the sequencer does with each commit. */
|
|
55
64
|
export type PickAction = "pick" | "revert";
|
|
@@ -105,7 +114,7 @@ export interface SequencerDeps extends MergeWriteContext {
|
|
|
105
114
|
|
|
106
115
|
/** The `git commit` the sequencer runs (see {@link SequencerDeps.gitCommit}). */
|
|
107
116
|
export type PickCommitMode =
|
|
108
|
-
| { kind: "pick"; reflogAction: string }
|
|
117
|
+
| { kind: "pick"; reflogAction: string; allowEmpty?: boolean }
|
|
109
118
|
| { kind: "continue"; edit: boolean };
|
|
110
119
|
|
|
111
120
|
/** Options of one sequencer run. */
|
|
@@ -114,6 +123,16 @@ export interface PickOptions {
|
|
|
114
123
|
noCommit?: boolean;
|
|
115
124
|
mainline?: number;
|
|
116
125
|
favor?: "ours" | "theirs" | "union";
|
|
126
|
+
/**
|
|
127
|
+
* `-s <strategy>` (git's opts->strategy): `ort`/`recursive` (merge-ort, as without one),
|
|
128
|
+
* `resolve` (git-merge-resolve) or `subtree` (git merge-subtree); a revert always runs
|
|
129
|
+
* merge-ort. Saved in `sequencer/opts` (`options.strategy`).
|
|
130
|
+
*/
|
|
131
|
+
strategy?: string;
|
|
132
|
+
/** `-X <option>`s (saved in `sequencer/opts` as `options.strategy-option`) */
|
|
133
|
+
strategyOptions?: string[];
|
|
134
|
+
/** The git version to follow where they differ (default: the hook runner's) */
|
|
135
|
+
compatibility?: "2.43" | "2.56";
|
|
117
136
|
/** The label of HEAD in conflict markers (default `HEAD`) */
|
|
118
137
|
oursLabel?: string;
|
|
119
138
|
/**
|
|
@@ -131,6 +150,121 @@ export interface PickOptions {
|
|
|
131
150
|
* (git's `options.edit`), left out when neither was given.
|
|
132
151
|
*/
|
|
133
152
|
edit?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* `-S[<keyid>]` (true or the key) / `--no-gpg-sign` (false); undefined: `commit.gpgSign`.
|
|
155
|
+
* Saved in `sequencer/opts` (`options.gpg-sign`) for a run of several commits.
|
|
156
|
+
*/
|
|
157
|
+
sign?: boolean | string;
|
|
158
|
+
/** `-x`: `(cherry picked from commit <id>)` appended to a pick's message (record_origin) */
|
|
159
|
+
recordOrigin?: boolean;
|
|
160
|
+
/** `-s` / `--signoff`: the committer's `Signed-off-by:` appended (append_signoff) */
|
|
161
|
+
signoff?: boolean;
|
|
162
|
+
/** `--allow-empty`: a commit empty in itself (its tree its first parent's) is committed */
|
|
163
|
+
allowEmpty?: boolean;
|
|
164
|
+
/** `--allow-empty-message` (saved in `sequencer/opts`; the sequencer commits any message) */
|
|
165
|
+
allowEmptyMessage?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* `--keep-redundant-commits` / `--empty=keep`: a commit that becomes empty is committed
|
|
168
|
+
* (implies {@link allowEmpty})
|
|
169
|
+
*/
|
|
170
|
+
keepRedundant?: boolean;
|
|
171
|
+
/** `--empty=drop`: a commit that becomes empty is dropped, git's `dropping ...` line printed */
|
|
172
|
+
dropRedundant?: boolean;
|
|
173
|
+
/** `--ff`: a commit whose parent is HEAD is fast-forwarded to, not picked */
|
|
174
|
+
allowFf?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* `revert --reference` (or `revert.reference`): the reverted commit named as
|
|
177
|
+
* `<abbrev> (<subject>, <date>)` under a `*** SAY WHY ...` comment for the title
|
|
178
|
+
*/
|
|
179
|
+
reference?: boolean;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** The flags of a run, read back from `sequencer/opts` (git's replay_opts). */
|
|
183
|
+
interface PickFlags {
|
|
184
|
+
noCommit: boolean;
|
|
185
|
+
mainline?: number;
|
|
186
|
+
recordOrigin: boolean;
|
|
187
|
+
signoff: boolean;
|
|
188
|
+
allowEmpty: boolean;
|
|
189
|
+
allowEmptyMessage: boolean;
|
|
190
|
+
keepRedundant: boolean;
|
|
191
|
+
dropRedundant: boolean;
|
|
192
|
+
allowFf: boolean;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** commit.cleanup as the sequencer reads it (git_sequencer_config). */
|
|
196
|
+
type SequencerCleanup = "whitespace" | "verbatim" | "scissors" | "strip";
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* builtin/revert.c's verify_opt_compatible: the `fatal:` line refusing an option that cannot
|
|
200
|
+
* go with `--continue`/`--skip`/`--abort`/`--quit` or with `--ff`, as git checks them; undefined
|
|
201
|
+
* when the options go together.
|
|
202
|
+
*/
|
|
203
|
+
export function pickOptionsConflict(
|
|
204
|
+
action: PickAction,
|
|
205
|
+
operation: SequencerOperation,
|
|
206
|
+
options: PickOptions & { emptyGiven?: boolean },
|
|
207
|
+
/** git 2.43 lets `--keep-redundant-commits` and `--empty` go with the operations */
|
|
208
|
+
compatibility?: "2.43" | "2.56",
|
|
209
|
+
): string | undefined {
|
|
210
|
+
const me = ACTION_NAME[action];
|
|
211
|
+
const keep = !!options.keepRedundant;
|
|
212
|
+
if (operation !== SequencerOperation.START) {
|
|
213
|
+
const op = `--${operation}`;
|
|
214
|
+
const given: [string, boolean][] = [
|
|
215
|
+
["--no-commit", !!options.noCommit],
|
|
216
|
+
["--signoff", !!options.signoff],
|
|
217
|
+
["--mainline", !!options.mainline],
|
|
218
|
+
["-x", !!options.recordOrigin],
|
|
219
|
+
["--ff", !!options.allowFf],
|
|
220
|
+
["--keep-redundant-commits", keep && compatibility !== "2.43"],
|
|
221
|
+
["--empty", !!options.emptyGiven && compatibility !== "2.43"],
|
|
222
|
+
];
|
|
223
|
+
const first = given.find(([, on]) => on);
|
|
224
|
+
if (first) return `fatal: ${me}: ${first[0]} cannot be used with ${op}`;
|
|
225
|
+
}
|
|
226
|
+
if (options.allowFf) {
|
|
227
|
+
const given: [string, boolean][] = [
|
|
228
|
+
["--signoff", !!options.signoff],
|
|
229
|
+
["--no-commit", !!options.noCommit],
|
|
230
|
+
["-x", !!options.recordOrigin],
|
|
231
|
+
["--edit", options.edit === true],
|
|
232
|
+
];
|
|
233
|
+
const first = given.find(([, on]) => on);
|
|
234
|
+
if (first) return `fatal: ${me}: ${first[0]} cannot be used with --ff`;
|
|
235
|
+
}
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** The boolean options of `sequencer/opts` (populate_opts_cb). */
|
|
240
|
+
const SAVED_FLAGS: Record<string, keyof Omit<PickFlags, "mainline"> | undefined> = {
|
|
241
|
+
"no-commit": "noCommit",
|
|
242
|
+
"allow-empty": "allowEmpty",
|
|
243
|
+
"allow-empty-message": "allowEmptyMessage",
|
|
244
|
+
"drop-redundant-commits": "dropRedundant",
|
|
245
|
+
"keep-redundant-commits": "keepRedundant",
|
|
246
|
+
signoff: "signoff",
|
|
247
|
+
"record-origin": "recordOrigin",
|
|
248
|
+
"allow-ff": "allowFf",
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
/** git_sequencer_config's commit.cleanup (get_cleanup_mode for a saved one). */
|
|
252
|
+
function cleanupOf(value: string | undefined): SequencerCleanup | undefined {
|
|
253
|
+
switch (value) {
|
|
254
|
+
case "verbatim":
|
|
255
|
+
case "whitespace":
|
|
256
|
+
case "strip":
|
|
257
|
+
case "scissors":
|
|
258
|
+
return value;
|
|
259
|
+
default:
|
|
260
|
+
return undefined;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function configuredCleanup(
|
|
265
|
+
workingCopy: SequencerDeps["workingCopy"],
|
|
266
|
+
): SequencerCleanup | undefined {
|
|
267
|
+
return cleanupOf(RemoteConfigStore.from(workingCopy).value("commit.cleanup"));
|
|
134
268
|
}
|
|
135
269
|
|
|
136
270
|
const ACTION_NAME = { pick: "cherry-pick", revert: "revert" } as const;
|
|
@@ -152,6 +286,16 @@ export class PickSequencer {
|
|
|
152
286
|
private readonly abbreviator: IdAbbreviator;
|
|
153
287
|
/** `--edit` / `--no-edit` (git's opts->edit, unset: undefined), read back from the opts */
|
|
154
288
|
private edit: boolean | undefined;
|
|
289
|
+
/** What the commits are signed with (git's opts->gpg_sign), read back from the opts */
|
|
290
|
+
private sign: SignRequest;
|
|
291
|
+
/** The flags of the run (given, or read back from `sequencer/opts`) */
|
|
292
|
+
private readonly flags: PickFlags;
|
|
293
|
+
/** commit.cleanup (git's default_msg_cleanup with explicit_cleanup), or saved in the opts */
|
|
294
|
+
private cleanup: SequencerCleanup | undefined;
|
|
295
|
+
/** `-s` (git's opts->strategy), or saved in the opts */
|
|
296
|
+
private strategy: string | undefined;
|
|
297
|
+
/** `-X` options (git's opts->xopts), or saved in the opts */
|
|
298
|
+
private xopts: string[];
|
|
155
299
|
|
|
156
300
|
constructor(
|
|
157
301
|
private readonly deps: SequencerDeps,
|
|
@@ -160,6 +304,32 @@ export class PickSequencer {
|
|
|
160
304
|
this.flats = new FlatTreeCache(deps.trees);
|
|
161
305
|
this.abbreviator = createIdAbbreviator(deps.workingCopy);
|
|
162
306
|
this.edit = options.edit;
|
|
307
|
+
this.sign = signRequestOf(deps.workingCopy, options.sign);
|
|
308
|
+
const keepRedundant = !!options.keepRedundant;
|
|
309
|
+
this.flags = {
|
|
310
|
+
noCommit: !!options.noCommit,
|
|
311
|
+
mainline: options.mainline,
|
|
312
|
+
recordOrigin: !!options.recordOrigin,
|
|
313
|
+
signoff: !!options.signoff,
|
|
314
|
+
// --keep-redundant-commits implies --allow-empty (run_sequencer)
|
|
315
|
+
allowEmpty: !!options.allowEmpty || keepRedundant,
|
|
316
|
+
allowEmptyMessage: !!options.allowEmptyMessage,
|
|
317
|
+
keepRedundant,
|
|
318
|
+
dropRedundant: !!options.dropRedundant,
|
|
319
|
+
allowFf: !!options.allowFf,
|
|
320
|
+
};
|
|
321
|
+
this.cleanup = configuredCleanup(deps.workingCopy);
|
|
322
|
+
this.strategy = options.strategy;
|
|
323
|
+
this.xopts = [...(options.strategyOptions ?? [])];
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** The git version to follow where they differ */
|
|
327
|
+
private get compatibility(): "2.43" | "2.56" {
|
|
328
|
+
return this.options.compatibility ?? this.deps.hooks?.compatibility ?? "2.56";
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
private config(key: string): string | undefined {
|
|
332
|
+
return RemoteConfigStore.from(this.deps.workingCopy).value(key);
|
|
163
333
|
}
|
|
164
334
|
|
|
165
335
|
private get name(): string {
|
|
@@ -174,6 +344,10 @@ export class PickSequencer {
|
|
|
174
344
|
async start(names: string[]): Promise<PickOutcome> {
|
|
175
345
|
const { state } = this.deps;
|
|
176
346
|
const { unmerged } = await readIndex(this.deps.staging);
|
|
347
|
+
if (unmerged.length > 0 && this.flags.noCommit) {
|
|
348
|
+
// do_pick_commit's write_index_as_tree fails first
|
|
349
|
+
return this.fail(`error: your index file is unmerged.\nfatal: ${this.name} failed`);
|
|
350
|
+
}
|
|
177
351
|
if (unmerged.length > 0) {
|
|
178
352
|
return this.fail(
|
|
179
353
|
[
|
|
@@ -190,17 +364,46 @@ export class PickSequencer {
|
|
|
190
364
|
);
|
|
191
365
|
}
|
|
192
366
|
const ids: ObjectId[] = [];
|
|
193
|
-
|
|
367
|
+
let lastNamed = "";
|
|
368
|
+
for (const name of names) {
|
|
369
|
+
const id = await this.resolvePick(name);
|
|
370
|
+
lastNamed = id;
|
|
371
|
+
// the revision walk lists each commit once (its SEEN flag), first naming first
|
|
372
|
+
if (!ids.includes(id)) ids.push(id);
|
|
373
|
+
}
|
|
194
374
|
const todo = ids.map((id) => ({ action: this.options.action, id }));
|
|
195
|
-
const headId = await this.headId();
|
|
196
375
|
if (todo.length > 1) {
|
|
197
|
-
|
|
376
|
+
// sequencer_pick_revisions on an unborn HEAD refuses only a revert; a pick saves as
|
|
377
|
+
// sequencer/head what its failed repo_get_oid("HEAD") left in `oid`, which in git 2.43
|
|
378
|
+
// and 2.56 builds alike is the id of the last commit named (the loop over the pending
|
|
379
|
+
// revisions shares its stack slot), and an empty abort-safety
|
|
380
|
+
const headId = await this.headIfBorn();
|
|
381
|
+
if (!headId && this.options.action === "revert") {
|
|
382
|
+
return this.fail(`error: can't revert as initial commit\nfatal: ${this.name} failed`);
|
|
383
|
+
}
|
|
384
|
+
await state.write("sequencer/head", `${headId ?? lastNamed}\n`);
|
|
198
385
|
await this.writeTodo(todo);
|
|
199
|
-
await state.write("sequencer/abort-safety", `${headId}\n`);
|
|
200
|
-
// save_opts
|
|
386
|
+
await state.write("sequencer/abort-safety", `${headId ?? ""}\n`);
|
|
387
|
+
// save_opts, in its order (git config's format)
|
|
388
|
+
const f = this.flags;
|
|
201
389
|
const opts: string[] = [];
|
|
202
|
-
|
|
390
|
+
const flag = (name: string, on: boolean) => on && opts.push(`\t${name} = true\n`);
|
|
391
|
+
flag("no-commit", f.noCommit);
|
|
203
392
|
if (this.edit !== undefined) opts.push(`\tedit = ${this.edit}\n`);
|
|
393
|
+
flag("allow-empty", f.allowEmpty);
|
|
394
|
+
flag("allow-empty-message", f.allowEmptyMessage);
|
|
395
|
+
flag("drop-redundant-commits", f.dropRedundant);
|
|
396
|
+
flag("keep-redundant-commits", f.keepRedundant);
|
|
397
|
+
flag("signoff", f.signoff);
|
|
398
|
+
flag("record-origin", f.recordOrigin);
|
|
399
|
+
flag("allow-ff", f.allowFf);
|
|
400
|
+
if (f.mainline) opts.push(`\tmainline = ${f.mainline}\n`);
|
|
401
|
+
if (this.strategy) opts.push(`\tstrategy = ${configValueText(this.strategy)}\n`);
|
|
402
|
+
if (this.sign !== undefined) {
|
|
403
|
+
opts.push(`\tgpg-sign = ${configValueText(String(this.sign))}\n`);
|
|
404
|
+
}
|
|
405
|
+
for (const x of this.xopts) opts.push(`\tstrategy-option = ${configValueText(x)}\n`);
|
|
406
|
+
if (this.cleanup) opts.push(`\tdefault-msg-cleanup = ${this.cleanup}\n`);
|
|
204
407
|
if (opts.length > 0) await state.write("sequencer/opts", `[options]\n${opts.join("")}`);
|
|
205
408
|
}
|
|
206
409
|
return this.run(todo, todo.length > 1);
|
|
@@ -226,14 +429,17 @@ export class PickSequencer {
|
|
|
226
429
|
private async run(todo: TodoItem[], sequenced: boolean): Promise<PickOutcome> {
|
|
227
430
|
const output: string[] = [];
|
|
228
431
|
const picked: ObjectId[] = [];
|
|
229
|
-
let newHead = await this.
|
|
432
|
+
let newHead = await this.headIfBorn();
|
|
230
433
|
for (let k = 0; k < todo.length; k++) {
|
|
231
434
|
const item = todo[k];
|
|
232
435
|
const outcome = await this.pickOne(item, output);
|
|
233
436
|
if (outcome.status !== "ok") {
|
|
234
437
|
if (sequenced) {
|
|
235
438
|
await this.writeTodo(todo.slice(k));
|
|
236
|
-
await this.deps.state.write(
|
|
439
|
+
await this.deps.state.write(
|
|
440
|
+
"sequencer/abort-safety",
|
|
441
|
+
`${(await this.headIfBorn()) ?? ""}\n`,
|
|
442
|
+
);
|
|
237
443
|
}
|
|
238
444
|
return { ...outcome, picked, output };
|
|
239
445
|
}
|
|
@@ -241,53 +447,82 @@ export class PickSequencer {
|
|
|
241
447
|
newHead = outcome.newHead ?? newHead;
|
|
242
448
|
if (sequenced) {
|
|
243
449
|
await this.writeTodo(todo.slice(k + 1));
|
|
244
|
-
await this.deps.state.write("sequencer/abort-safety", `${newHead}\n`);
|
|
450
|
+
await this.deps.state.write("sequencer/abort-safety", `${newHead ?? ""}\n`);
|
|
245
451
|
}
|
|
246
452
|
}
|
|
247
453
|
if (sequenced) await this.deps.state.remove("sequencer");
|
|
248
454
|
return { status: "ok", newHead, picked, output };
|
|
249
455
|
}
|
|
250
456
|
|
|
457
|
+
/** The merge of a pick: {@link mergePickChange} with this run's strategy and options. */
|
|
458
|
+
private mergePick(p: Omit<PickMergeArgs, "strategy" | "xopts" | "oursLabel" | "favor">) {
|
|
459
|
+
return mergePickChange(
|
|
460
|
+
{ ...this.deps, flats: this.flats, abbreviate: (id) => this.abbreviator.abbreviate(id) },
|
|
461
|
+
{
|
|
462
|
+
...p,
|
|
463
|
+
strategy: this.strategy,
|
|
464
|
+
xopts: this.xopts,
|
|
465
|
+
oursLabel: this.options.oursLabel ?? "HEAD",
|
|
466
|
+
favor: this.options.favor,
|
|
467
|
+
compatibility: this.compatibility,
|
|
468
|
+
},
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
|
|
251
472
|
/** One commit's change merged into HEAD (do_pick_commit). */
|
|
252
473
|
private async pickOne(item: TodoItem, output: string[]): Promise<PickOutcome> {
|
|
253
|
-
const { deps } = this;
|
|
474
|
+
const { deps, flags } = this;
|
|
254
475
|
const action = item.action;
|
|
476
|
+
const name = ACTION_NAME[action];
|
|
477
|
+
const format = objectFormatOf(deps.workingCopy.history);
|
|
255
478
|
const commit = await deps.commits.load(item.id);
|
|
256
479
|
if (!commit) throw new RefNotFoundError(item.id, `Cannot find commit: ${item.id}`);
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
|
|
480
|
+
// an unborn HEAD picks onto the empty tree (repo_get_oid fails: `unborn`)
|
|
481
|
+
const headId = await this.headIfBorn();
|
|
482
|
+
const headCommit = headId ? await deps.commits.load(headId) : undefined;
|
|
483
|
+
if (headId && !headCommit) throw new RefNotFoundError(headId, "HEAD commit not found");
|
|
484
|
+
const headTree = headCommit?.tree ?? format.emptyTreeId;
|
|
260
485
|
// with --no-commit the change is merged into the index as it is (git's
|
|
261
486
|
// write_index_as_tree): each commit's change on top of the previous one's
|
|
262
|
-
const headTreeId =
|
|
263
|
-
? await writeIndexAsTree(deps.staging, deps.trees,
|
|
264
|
-
:
|
|
487
|
+
const headTreeId = flags.noCommit
|
|
488
|
+
? await writeIndexAsTree(deps.staging, deps.trees, format)
|
|
489
|
+
: headTree;
|
|
265
490
|
// a commit is never made on top of staged changes (error_dirty_index)
|
|
266
491
|
const { index } = await readIndex(deps.staging);
|
|
267
|
-
if (
|
|
268
|
-
!this.options.noCommit &&
|
|
269
|
-
(await indexChangesFromTree(index, deps.trees, headTreeId)).length > 0
|
|
270
|
-
) {
|
|
492
|
+
if (!flags.noCommit && (await indexChangesFromTree(index, deps.trees, headTreeId)).length > 0) {
|
|
271
493
|
return this.fail(
|
|
272
|
-
`error: your local changes would be overwritten by ${
|
|
494
|
+
`error: your local changes would be overwritten by ${name}.\nhint: commit your changes or stash them to proceed.\nfatal: ${name} failed`,
|
|
273
495
|
);
|
|
274
496
|
}
|
|
275
497
|
|
|
276
|
-
// the parent the change is taken against
|
|
498
|
+
// the parent the change is taken against (`-m`: a merge's parent, at most 1 otherwise)
|
|
277
499
|
let parentId: ObjectId | undefined;
|
|
500
|
+
const mainline = flags.mainline;
|
|
501
|
+
const noParent = (n: number) =>
|
|
502
|
+
new InvalidMainlineParentError(
|
|
503
|
+
n,
|
|
504
|
+
commit.parents.length,
|
|
505
|
+
`error: commit ${item.id} does not have parent ${n}\nfatal: ${name} failed`,
|
|
506
|
+
);
|
|
278
507
|
if (commit.parents.length > 1) {
|
|
279
|
-
if (
|
|
508
|
+
if (!mainline) {
|
|
280
509
|
throw new MultipleParentsNotAllowedError(
|
|
281
|
-
`error: commit ${item.id} is a merge but no -m option was given.\nfatal: ${
|
|
510
|
+
`error: commit ${item.id} is a merge but no -m option was given.\nfatal: ${name} failed`,
|
|
282
511
|
);
|
|
283
512
|
}
|
|
284
|
-
if (
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
513
|
+
if (mainline > commit.parents.length) throw noParent(mainline);
|
|
514
|
+
parentId = commit.parents[mainline - 1];
|
|
515
|
+
} else if (mainline !== undefined && mainline > 1) {
|
|
516
|
+
throw noParent(mainline);
|
|
288
517
|
} else {
|
|
289
518
|
parentId = commit.parents[0];
|
|
290
519
|
}
|
|
520
|
+
|
|
521
|
+
// --ff: a commit on HEAD (a root commit on an unborn branch) is fast-forwarded to
|
|
522
|
+
if (flags.allowFf && ((parentId && parentId === headId) || (!parentId && !headId))) {
|
|
523
|
+
return this.fastForward(item.id, headId, headTree, commit.tree, output);
|
|
524
|
+
}
|
|
525
|
+
|
|
291
526
|
const parentTreeId = parentId ? await deps.commits.getTree(parentId) : undefined;
|
|
292
527
|
const subject = subjectOf(commit.message);
|
|
293
528
|
// get_message: short_commit_name, repo_find_unique_abbrev with DEFAULT_ABBREV
|
|
@@ -298,50 +533,61 @@ export class PickSequencer {
|
|
|
298
533
|
action === "pick"
|
|
299
534
|
? [parentTreeId, commit.tree, parentLabel, label]
|
|
300
535
|
: [commit.tree, parentTreeId, label, parentLabel];
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
storedBase(base, baseLabel, () => flats.get(base)),
|
|
536
|
+
const merged = await this.mergePick({
|
|
537
|
+
action,
|
|
538
|
+
headId,
|
|
305
539
|
headTreeId,
|
|
540
|
+
base,
|
|
306
541
|
theirs,
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
542
|
+
baseLabel,
|
|
543
|
+
theirsLabel,
|
|
544
|
+
pickId: item.id,
|
|
545
|
+
parentId,
|
|
546
|
+
});
|
|
547
|
+
if ("failed" in merged) {
|
|
548
|
+
if (!merged.strategyFailed) return this.fail(merged.failed, merged.output ?? []);
|
|
549
|
+
// do_pick_commit wrote MERGE_MSG before running the strategy; no CHERRY_PICK_HEAD
|
|
550
|
+
await deps.state.write("MERGE_MSG", await this.messageFor(action, item.id, commit, parentId));
|
|
551
|
+
const short = await this.abbreviator.abbreviate(item.id);
|
|
552
|
+
const verb = action === "pick" ? "apply" : "revert";
|
|
553
|
+
const lines = [
|
|
554
|
+
...(merged.failed ? [merged.failed] : []),
|
|
555
|
+
`error: could not ${verb} ${short}... ${subjectOf(commit.message)}`,
|
|
556
|
+
// git 2.43's sequencer returns the error without dying
|
|
557
|
+
...(this.compatibility === "2.43" ? [] : [`fatal: ${name} failed`]),
|
|
558
|
+
];
|
|
559
|
+
return this.fail(lines.join("\n"), merged.output ?? []);
|
|
560
|
+
}
|
|
561
|
+
const { treeId, conflicts, clean } = merged;
|
|
322
562
|
// only the paths HEAD and the result differ on are switched
|
|
323
|
-
const delta = await treeDelta(deps.trees, headTreeId, treeId);
|
|
563
|
+
const delta = merged.delta ?? (await treeDelta(deps.trees, headTreeId, treeId));
|
|
324
564
|
const refused = await switchTrees(deps, delta.from, delta.to, {
|
|
325
565
|
action: "merge",
|
|
326
|
-
operation:
|
|
566
|
+
operation: name,
|
|
327
567
|
conflicts,
|
|
328
|
-
targetTree: treeId,
|
|
568
|
+
...(merged.delta ? {} : { targetTree: treeId }),
|
|
329
569
|
});
|
|
330
570
|
if (refused) {
|
|
331
|
-
return this.fail(`${refused.message}\nfatal: ${
|
|
571
|
+
return this.fail(`${refused.message}\nfatal: ${name} failed`, merged.refusedOutput ?? []);
|
|
332
572
|
}
|
|
333
|
-
output.push(...
|
|
334
|
-
|
|
335
|
-
|
|
573
|
+
output.push(...merged.messages);
|
|
574
|
+
// merge-ort records its result tree (git-merge-resolve does not)
|
|
575
|
+
if (merged.autoMerge) await deps.state.setRef("AUTO_MERGE", treeId);
|
|
576
|
+
const ort = !merged.external;
|
|
577
|
+
const message = await this.messageFor(action, item.id, commit, parentId);
|
|
336
578
|
|
|
337
|
-
if (conflicts.length > 0 || !
|
|
579
|
+
if (conflicts.length > 0 || !clean) {
|
|
338
580
|
const paths = [...new Set(conflicts.map((c) => c.stagePath))].sort(compareGitPaths);
|
|
339
581
|
// git records REVERT_HEAD for a revert -n too (do_pick_commit), never CHERRY_PICK_HEAD
|
|
340
|
-
if (!
|
|
582
|
+
if (!flags.noCommit || action === "revert") {
|
|
341
583
|
await deps.state.setRef(HEAD_REF[action], item.id);
|
|
342
584
|
}
|
|
343
|
-
|
|
344
|
-
|
|
585
|
+
// do_recursive_merge adds the conflicts hint; another strategy's MERGE_MSG has none
|
|
586
|
+
await deps.state.write(
|
|
587
|
+
"MERGE_MSG",
|
|
588
|
+
ort ? `${message}${conflictsComment(paths, true)}` : message,
|
|
589
|
+
);
|
|
590
|
+
const advice = flags.noCommit
|
|
345
591
|
? [
|
|
346
592
|
"hint: after resolving the conflicts, mark the corrected paths",
|
|
347
593
|
"hint: with 'git add <paths>' or 'git rm <paths>'",
|
|
@@ -349,10 +595,10 @@ export class PickSequencer {
|
|
|
349
595
|
: [
|
|
350
596
|
"hint: After resolving the conflicts, mark them with",
|
|
351
597
|
'hint: "git add/rm <pathspec>", then run',
|
|
352
|
-
`hint: "git ${
|
|
353
|
-
`hint: You can instead skip this commit with "git ${
|
|
354
|
-
`hint: To abort and get back to the state before "git ${
|
|
355
|
-
`hint: run "git ${
|
|
598
|
+
`hint: "git ${name} --continue".`,
|
|
599
|
+
`hint: You can instead skip this commit with "git ${name} --skip".`,
|
|
600
|
+
`hint: To abort and get back to the state before "git ${name}",`,
|
|
601
|
+
`hint: run "git ${name} --abort".`,
|
|
356
602
|
];
|
|
357
603
|
return {
|
|
358
604
|
status: "conflicting",
|
|
@@ -360,33 +606,62 @@ export class PickSequencer {
|
|
|
360
606
|
picked: [],
|
|
361
607
|
output,
|
|
362
608
|
message: [
|
|
609
|
+
// git-merge-one-file's stderr (`ERROR: content conflict in f`, ...)
|
|
610
|
+
...(merged.errors ?? []),
|
|
363
611
|
`error: could not ${action === "pick" ? "apply" : "revert"} ${short}... ${subject}`,
|
|
364
612
|
...advice,
|
|
365
613
|
].join("\n"),
|
|
366
614
|
};
|
|
367
615
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
616
|
+
// a clean merge: CHERRY_PICK_HEAD (not with --no-commit), MERGE_MSG, REVERT_HEAD for a
|
|
617
|
+
// revert -n, before allow_empty and do_commit (a commit that fails leaves them)
|
|
618
|
+
if (action === "pick" && !flags.noCommit) await deps.state.setRef(HEAD_REF[action], item.id);
|
|
619
|
+
await deps.state.write("MERGE_MSG", message);
|
|
620
|
+
if (action === "revert" && flags.noCommit) await deps.state.setRef(HEAD_REF[action], item.id);
|
|
621
|
+
|
|
622
|
+
// allow_empty: a result equal to HEAD's tree is committed (1), dropped (2) or stops (0)
|
|
623
|
+
let allow: 0 | 1 | 2 = 0;
|
|
624
|
+
if (treeId === headTree) {
|
|
625
|
+
const firstParentTree = commit.parents[0]
|
|
626
|
+
? await deps.commits.getTree(commit.parents[0])
|
|
627
|
+
: format.emptyTreeId;
|
|
628
|
+
const originallyEmpty = firstParentTree === commit.tree;
|
|
629
|
+
allow = originallyEmpty
|
|
630
|
+
? flags.allowEmpty
|
|
631
|
+
? 1
|
|
632
|
+
: 0
|
|
633
|
+
: flags.keepRedundant
|
|
634
|
+
? 1
|
|
635
|
+
: flags.dropRedundant
|
|
636
|
+
? 2
|
|
637
|
+
: 0;
|
|
638
|
+
}
|
|
639
|
+
if (allow === 2) {
|
|
640
|
+
await deps.state.deleteRef("CHERRY_PICK_HEAD");
|
|
641
|
+
await deps.state.remove("MERGE_MSG");
|
|
642
|
+
await deps.state.deleteRef("AUTO_MERGE");
|
|
643
|
+
output.push(`dropping ${item.id} ${subject} -- patch contents already upstream`);
|
|
644
|
+
return { status: "ok", newHead: headId, picked: [item.id], output };
|
|
645
|
+
}
|
|
646
|
+
if (flags.noCommit) {
|
|
371
647
|
return { status: "ok", newHead: headId, picked: [item.id], output };
|
|
372
648
|
}
|
|
373
|
-
if (treeId ===
|
|
374
|
-
// nothing to commit: git stops, the pick in
|
|
375
|
-
//
|
|
376
|
-
|
|
377
|
-
await deps.state.write("MERGE_MSG", message);
|
|
649
|
+
if (treeId === headTree && allow === 0) {
|
|
650
|
+
// nothing to commit: try_to_commit leaves it to `git commit`, which stops, the pick in
|
|
651
|
+
// progress, for `git commit --allow-empty` or --skip (CHERRY_PICK_HEAD only: git
|
|
652
|
+
// records REVERT_HEAD for a revert that conflicts)
|
|
378
653
|
return {
|
|
379
654
|
status: "conflicting",
|
|
380
655
|
conflicts: [],
|
|
381
656
|
picked: [],
|
|
382
657
|
output,
|
|
383
658
|
message: [
|
|
384
|
-
`The previous ${
|
|
659
|
+
`The previous ${name} is now empty, possibly due to conflict resolution.`,
|
|
385
660
|
"If you wish to commit it anyway, use:",
|
|
386
661
|
"",
|
|
387
662
|
" git commit --allow-empty",
|
|
388
663
|
"",
|
|
389
|
-
`Otherwise, please use 'git ${
|
|
664
|
+
`Otherwise, please use 'git ${name} --skip'`,
|
|
390
665
|
].join("\n"),
|
|
391
666
|
};
|
|
392
667
|
}
|
|
@@ -394,13 +669,12 @@ export class PickSequencer {
|
|
|
394
669
|
// do_pick_commit with EDIT_MSG: the message in MERGE_MSG, CHERRY_PICK_HEAD for a pick
|
|
395
670
|
// (git commit then takes its author and says it concludes a cherry-pick), then
|
|
396
671
|
// run_git_commit; git commit cleans up after itself (CHERRY_PICK_HEAD, MERGE_MSG)
|
|
397
|
-
if (action === "pick") await deps.state.setRef(HEAD_REF[action], item.id);
|
|
398
|
-
await deps.state.write("MERGE_MSG", message);
|
|
399
672
|
let newHead: ObjectId;
|
|
400
673
|
try {
|
|
401
674
|
newHead = await deps.gitCommit({
|
|
402
675
|
kind: "pick",
|
|
403
|
-
reflogAction: this.options.reflogAction ??
|
|
676
|
+
reflogAction: this.options.reflogAction ?? name,
|
|
677
|
+
allowEmpty: allow === 1,
|
|
404
678
|
});
|
|
405
679
|
} catch (error) {
|
|
406
680
|
if (!(error instanceof GitApiError)) throw error;
|
|
@@ -409,20 +683,15 @@ export class PickSequencer {
|
|
|
409
683
|
}
|
|
410
684
|
return { status: "ok", newHead, picked: [item.id], output };
|
|
411
685
|
}
|
|
412
|
-
// do_pick_commit records CHERRY_PICK_HEAD for a clean pick too, and writes MERGE_MSG,
|
|
413
|
-
// before do_commit: a commit that fails (HEAD's lock held) leaves both
|
|
414
|
-
if (action === "pick") await deps.state.setRef(HEAD_REF[action], item.id);
|
|
415
|
-
await deps.state.write("MERGE_MSG", message);
|
|
416
686
|
const committer = this.committer();
|
|
417
|
-
const commitMessage = action === "pick" ? commit.message : message;
|
|
418
687
|
const newHead = await this.commit(
|
|
419
688
|
treeId,
|
|
420
|
-
[headId],
|
|
689
|
+
headId ? [headId] : [],
|
|
421
690
|
action === "pick" ? commit.author : this.revertAuthor(committer),
|
|
422
691
|
committer,
|
|
423
|
-
|
|
692
|
+
message,
|
|
424
693
|
// the sequencer's update_head_with_reflog: "cherry-pick: <subject>", "revert: ..."
|
|
425
|
-
reflogMessages.pick(this.options.reflogAction ??
|
|
694
|
+
(text) => reflogMessages.pick(this.options.reflogAction ?? name, text),
|
|
426
695
|
);
|
|
427
696
|
// do_commit after try_to_commit: CHERRY_PICK_HEAD (deleted whether there or not) and
|
|
428
697
|
// MERGE_MSG go, a stopped empty pick's left over included (REVERT_HEAD and AUTO_MERGE stay)
|
|
@@ -431,6 +700,29 @@ export class PickSequencer {
|
|
|
431
700
|
return { status: "ok", newHead, picked: [item.id], output };
|
|
432
701
|
}
|
|
433
702
|
|
|
703
|
+
/**
|
|
704
|
+
* fast_forward_to: the index and worktree switched from HEAD's tree to the commit's
|
|
705
|
+
* (checkout_fast_forward, a two-way switch refusing over local changes), then HEAD moved
|
|
706
|
+
* there with the reflog line `<action>: fast-forward`.
|
|
707
|
+
*/
|
|
708
|
+
private async fastForward(
|
|
709
|
+
id: ObjectId,
|
|
710
|
+
headId: ObjectId | undefined,
|
|
711
|
+
headTree: ObjectId,
|
|
712
|
+
targetTree: ObjectId,
|
|
713
|
+
output: string[],
|
|
714
|
+
): Promise<PickOutcome> {
|
|
715
|
+
const delta = await treeDelta(this.deps.trees, headTree, targetTree);
|
|
716
|
+
const refused = await switchTrees(this.deps, delta.from, delta.to, {
|
|
717
|
+
action: "merge",
|
|
718
|
+
operation: this.name,
|
|
719
|
+
targetTree,
|
|
720
|
+
});
|
|
721
|
+
if (refused) return this.fail(`${refused.message}\nfatal: ${this.name} failed`);
|
|
722
|
+
await this.moveHead(id, `${this.name}: fast-forward`, headId ?? null);
|
|
723
|
+
return { status: "ok", newHead: id, picked: [id], output };
|
|
724
|
+
}
|
|
725
|
+
|
|
434
726
|
/** `--continue`: the resolved conflict committed, then the rest picked. */
|
|
435
727
|
async continue(): Promise<PickOutcome> {
|
|
436
728
|
const { state } = this.deps;
|
|
@@ -452,7 +744,7 @@ export class PickSequencer {
|
|
|
452
744
|
if (!commit) throw new RefNotFoundError(stopped, "Commit being picked not found");
|
|
453
745
|
const treeId = await this.deps.staging.writeTree(this.deps.trees);
|
|
454
746
|
const headCommit = await this.deps.commits.load(newHead);
|
|
455
|
-
const fallback = this.messageFor(action, stopped, commit, commit.parents[0]);
|
|
747
|
+
const fallback = await this.messageFor(action, stopped, commit, commit.parents[0]);
|
|
456
748
|
const prepared = (await state.read("MERGE_MSG")) ?? fallback;
|
|
457
749
|
// continue_single_pick runs `git commit --no-edit --cleanup=strip` (plain `git commit`
|
|
458
750
|
// under --edit): without the editor its prepare_to_commit writes MERGE_MSG with its
|
|
@@ -490,7 +782,8 @@ export class PickSequencer {
|
|
|
490
782
|
message,
|
|
491
783
|
// `--continue` commits as `git commit` does: "commit (cherry-pick): <subject>" (a
|
|
492
784
|
// revert is no whence of git commit: "commit: <subject>")
|
|
493
|
-
reflogMessages.commit(action === "pick" ? "cherry-pick" : undefined,
|
|
785
|
+
(text) => reflogMessages.commit(action === "pick" ? "cherry-pick" : undefined, text),
|
|
786
|
+
"verbatim",
|
|
494
787
|
);
|
|
495
788
|
// the commit ends the stopped pick (git commit's remove_merge_branch_state)
|
|
496
789
|
await state.removeRef("CHERRY_PICK_HEAD", "REVERT_HEAD", "AUTO_MERGE");
|
|
@@ -509,7 +802,8 @@ export class PickSequencer {
|
|
|
509
802
|
const { state } = this.deps;
|
|
510
803
|
const stopped = (await state.ref("CHERRY_PICK_HEAD")) ?? (await state.ref("REVERT_HEAD"));
|
|
511
804
|
if (!stopped) {
|
|
512
|
-
|
|
805
|
+
// sequencer_skip: neither this action's head nor a sequence of it to go on with
|
|
806
|
+
return this.fail(`error: no ${this.name} in progress\nfatal: ${this.name} failed`);
|
|
513
807
|
}
|
|
514
808
|
await this.readSavedOptions();
|
|
515
809
|
const headId = await this.headId();
|
|
@@ -548,6 +842,12 @@ export class PickSequencer {
|
|
|
548
842
|
await state.remove("sequencer");
|
|
549
843
|
return this.fail(`error: could not read 'sequencer/head'\nfatal: ${this.name} failed`);
|
|
550
844
|
}
|
|
845
|
+
if (/^0+$/.test(origHead)) {
|
|
846
|
+
// sequencer_rollback: a run started on an unborn branch is not rewound (state kept)
|
|
847
|
+
return this.fail(
|
|
848
|
+
`error: cannot abort from a branch yet to be born\nfatal: ${this.name} failed`,
|
|
849
|
+
);
|
|
850
|
+
}
|
|
551
851
|
if (safety && safety !== headId) {
|
|
552
852
|
await state.remove("sequencer");
|
|
553
853
|
return this.fail(
|
|
@@ -562,11 +862,18 @@ export class PickSequencer {
|
|
|
562
862
|
return { status: "ok", newHead: origHead, picked: [], output: errors };
|
|
563
863
|
}
|
|
564
864
|
|
|
565
|
-
/**
|
|
865
|
+
/**
|
|
866
|
+
* `--quit` (builtin/revert.c): sequencer_remove_state (`sequencer/` removed), then
|
|
867
|
+
* remove_branch_state (CHERRY_PICK_HEAD, REVERT_HEAD, AUTO_MERGE, SQUASH_MSG, MERGE_MSG,
|
|
868
|
+
* MERGE_HEAD, MERGE_MODE, MERGE_RR go, a MERGE_AUTOSTASH is kept on `refs/stash`); the
|
|
869
|
+
* index, the worktree, HEAD and ORIG_HEAD are kept. Nothing in progress is no error.
|
|
870
|
+
*/
|
|
566
871
|
async quit(): Promise<PickOutcome> {
|
|
567
872
|
await this.deps.state.remove("sequencer");
|
|
568
|
-
await this.deps.state
|
|
569
|
-
|
|
873
|
+
const output = await removeBranchState(this.deps, this.deps.state);
|
|
874
|
+
// an unborn HEAD is no error here
|
|
875
|
+
const head = (await this.deps.refs.resolve("HEAD").catch(() => undefined))?.objectId;
|
|
876
|
+
return { status: "ok", ...(head ? { newHead: head } : {}), picked: [], output };
|
|
570
877
|
}
|
|
571
878
|
|
|
572
879
|
/**
|
|
@@ -589,13 +896,15 @@ export class PickSequencer {
|
|
|
589
896
|
}
|
|
590
897
|
|
|
591
898
|
/**
|
|
592
|
-
* read_populate_opts: `options.edit` of `sequencer/opts` (git
|
|
593
|
-
* value wins), the `--edit` / `--no-edit` the run
|
|
899
|
+
* read_populate_opts: `options.edit` and `options.gpg-sign` of `sequencer/opts` (git
|
|
900
|
+
* config's syntax, the last value wins), the `--edit` / `--no-edit` and `-S` the run
|
|
901
|
+
* started with.
|
|
594
902
|
*/
|
|
595
903
|
private async readSavedOptions(): Promise<void> {
|
|
596
904
|
const text = await this.deps.state.read("sequencer/opts");
|
|
597
905
|
if (text === undefined) return;
|
|
598
906
|
let section = "";
|
|
907
|
+
let xoptsRead = false;
|
|
599
908
|
for (const raw of text.split("\n")) {
|
|
600
909
|
const line = raw.trim();
|
|
601
910
|
const header = /^\[\s*([^\]\s]+)\s*\]/.exec(line);
|
|
@@ -604,9 +913,38 @@ export class PickSequencer {
|
|
|
604
913
|
continue;
|
|
605
914
|
}
|
|
606
915
|
const entry = /^([A-Za-z][A-Za-z0-9-]*)\s*=\s*(.*)$/.exec(line);
|
|
607
|
-
if (section !== "options" || !entry
|
|
608
|
-
const
|
|
609
|
-
|
|
916
|
+
if (section !== "options" || !entry) continue;
|
|
917
|
+
const name = entry[1].toLowerCase();
|
|
918
|
+
const text = parseConfigValueText(entry[2]);
|
|
919
|
+
if (text === undefined) continue;
|
|
920
|
+
if (name === "gpg-sign") {
|
|
921
|
+
this.sign = text;
|
|
922
|
+
continue;
|
|
923
|
+
}
|
|
924
|
+
if (name === "mainline") {
|
|
925
|
+
const value = Number.parseInt(text, 10);
|
|
926
|
+
if (Number.isFinite(value)) this.flags.mainline = value;
|
|
927
|
+
continue;
|
|
928
|
+
}
|
|
929
|
+
if (name === "default-msg-cleanup") {
|
|
930
|
+
this.cleanup = cleanupOf(text) ?? this.cleanup;
|
|
931
|
+
continue;
|
|
932
|
+
}
|
|
933
|
+
if (name === "strategy") {
|
|
934
|
+
this.strategy = text;
|
|
935
|
+
continue;
|
|
936
|
+
}
|
|
937
|
+
if (name === "strategy-option") {
|
|
938
|
+
if (!xoptsRead) this.xopts = [];
|
|
939
|
+
xoptsRead = true;
|
|
940
|
+
this.xopts.push(text);
|
|
941
|
+
continue;
|
|
942
|
+
}
|
|
943
|
+
const value = parseGitBool(text);
|
|
944
|
+
if (value === undefined) continue;
|
|
945
|
+
if (name === "edit") this.edit = value;
|
|
946
|
+
const key = SAVED_FLAGS[name];
|
|
947
|
+
if (key) this.flags[key] = value;
|
|
610
948
|
}
|
|
611
949
|
}
|
|
612
950
|
|
|
@@ -615,22 +953,74 @@ export class PickSequencer {
|
|
|
615
953
|
await this.deps.state.remove("MERGE_MSG", "sequencer");
|
|
616
954
|
}
|
|
617
955
|
|
|
618
|
-
/**
|
|
619
|
-
|
|
956
|
+
/**
|
|
957
|
+
* git's message for the commit a pick or revert makes (do_pick_commit's ctx->message): a
|
|
958
|
+
* pick's message from its subject on, with `-x`'s `(cherry picked from commit <id>)` (after a
|
|
959
|
+
* blank line unless the message ends with a trailer block); a revert's `Revert "<subject>"`
|
|
960
|
+
* (`Reapply "..."` for a revert of a revert, `--reference`'s comment and `<abbrev> (<subject>,
|
|
961
|
+
* <date>)`); then `-s`'s sign-off (append_signoff).
|
|
962
|
+
*/
|
|
963
|
+
private async messageFor(
|
|
620
964
|
action: PickAction,
|
|
621
965
|
id: ObjectId,
|
|
622
966
|
commit: Commit,
|
|
623
967
|
parentId: ObjectId | undefined,
|
|
624
|
-
): string {
|
|
968
|
+
): Promise<string> {
|
|
969
|
+
let message: string;
|
|
625
970
|
if (action === "pick") {
|
|
626
|
-
|
|
971
|
+
// find_commit_subject: the message from its first non-blank line
|
|
972
|
+
message = commit.message.replace(/^(?:[ \t]*\n)+/, "");
|
|
973
|
+
if (this.flags.recordOrigin) {
|
|
974
|
+
if (message.length > 0 && !message.endsWith("\n")) message += "\n";
|
|
975
|
+
if (trailerLinesOf(message, trailerConfigOf(this.deps.workingCopy)).length === 0) {
|
|
976
|
+
message += "\n";
|
|
977
|
+
}
|
|
978
|
+
message += `(cherry picked from commit ${id})\n`;
|
|
979
|
+
}
|
|
980
|
+
} else {
|
|
981
|
+
message = await this.revertMessage(id, commit, parentId);
|
|
982
|
+
}
|
|
983
|
+
if (this.flags.signoff) {
|
|
984
|
+
const committer = this.options.committer ?? committerIdentOf(this.deps.workingCopy);
|
|
985
|
+
message = appendSignoff(
|
|
986
|
+
message,
|
|
987
|
+
signoffLine(committer),
|
|
988
|
+
trailerConfigOf(this.deps.workingCopy),
|
|
989
|
+
);
|
|
627
990
|
}
|
|
991
|
+
return message;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
/** sequencer_format_revert_message. */
|
|
995
|
+
private async revertMessage(
|
|
996
|
+
id: ObjectId,
|
|
997
|
+
commit: Commit,
|
|
998
|
+
parentId: ObjectId | undefined,
|
|
999
|
+
): Promise<string> {
|
|
628
1000
|
const subject = subjectOf(commit.message);
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
1001
|
+
const reference = this.options.reference ?? revertReferenceOf(this.deps.workingCopy);
|
|
1002
|
+
let out: string;
|
|
1003
|
+
if (reference) {
|
|
1004
|
+
// git 2.43 wrote `#` whatever core.commentChar said (2.45 follows it)
|
|
1005
|
+
const comment =
|
|
1006
|
+
this.deps.hooks?.compatibility === "2.43" ? "#" : commentStringOf(this.deps.workingCopy);
|
|
1007
|
+
out = `${comment} *** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***\n`;
|
|
1008
|
+
} else if (subject.startsWith('Revert "') && !subject.slice(8).startsWith('Revert "')) {
|
|
1009
|
+
out = `Reapply "${subject.slice(8)}\n`;
|
|
1010
|
+
} else {
|
|
1011
|
+
out = `Revert "${subject}"\n`;
|
|
1012
|
+
}
|
|
1013
|
+
const refer = async (target: ObjectId) => {
|
|
1014
|
+
if (!reference) return target;
|
|
1015
|
+
const referred = await this.deps.commits.load(target);
|
|
1016
|
+
const short = await this.abbreviator.abbreviate(target);
|
|
1017
|
+
return `${short} (${subjectOf(referred?.message ?? "")}, ${shortDate(referred?.author)})`;
|
|
1018
|
+
};
|
|
1019
|
+
out += `\nThis reverts commit ${await refer(id)}`;
|
|
1020
|
+
if (commit.parents.length > 1 && parentId) {
|
|
1021
|
+
out += `, reversing\nchanges made to ${await refer(parentId)}`;
|
|
1022
|
+
}
|
|
1023
|
+
return `${out}.\n`;
|
|
634
1024
|
}
|
|
635
1025
|
|
|
636
1026
|
/**
|
|
@@ -658,24 +1048,88 @@ export class PickSequencer {
|
|
|
658
1048
|
author: PersonIdent,
|
|
659
1049
|
committer: PersonIdent,
|
|
660
1050
|
message: string,
|
|
661
|
-
reflogMessage: string,
|
|
1051
|
+
reflogMessage: (text: string) => string,
|
|
1052
|
+
/** a cleanup of the message after the hook (default: the sequencer's, see cleanupMode) */
|
|
1053
|
+
cleanup: SequencerCleanup = this.commitCleanup(),
|
|
662
1054
|
): Promise<ObjectId> {
|
|
663
1055
|
// try_to_commit: prepare-commit-msg may rewrite the message; post-commit after
|
|
664
1056
|
const hooks = this.deps.hooks;
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
1057
|
+
let text = hooks ? await sequencerPrepareMessage(hooks, this.deps.state, message) : message;
|
|
1058
|
+
if (cleanup !== "verbatim") {
|
|
1059
|
+
text = stripspace(
|
|
1060
|
+
text,
|
|
1061
|
+
cleanup === "strip" ? commentStringOf(this.deps.workingCopy) : undefined,
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
const id = await this.deps.commits.store(
|
|
1065
|
+
await this.signed({ tree, parents, author, committer, message: text }),
|
|
1066
|
+
);
|
|
1067
|
+
await this.moveHead(id, reflogMessage(text));
|
|
668
1068
|
if (hooks) await sequencerPostCommit(hooks);
|
|
669
1069
|
return id;
|
|
670
1070
|
}
|
|
671
1071
|
|
|
1072
|
+
/**
|
|
1073
|
+
* try_to_commit's cleanup: whitespace for `-s`/`-x` unless commit.cleanup is set, else
|
|
1074
|
+
* commit.cleanup's (`scissors` is whitespace without an editor), else none.
|
|
1075
|
+
*/
|
|
1076
|
+
private commitCleanup(): SequencerCleanup {
|
|
1077
|
+
if ((this.flags.signoff || this.flags.recordOrigin) && !this.cleanup) return "whitespace";
|
|
1078
|
+
if (this.cleanup === "scissors") return "whitespace";
|
|
1079
|
+
return this.cleanup ?? "verbatim";
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* try_to_commit's commit_tree signing `commit` for the run's key (git's opts->gpg_sign),
|
|
1084
|
+
* the signing program in the worktree top. When it cannot be signed: gpg's error and
|
|
1085
|
+
* `error: failed to write commit object`, then in git 2.43 `fatal: <action> failed` (exit
|
|
1086
|
+
* 128); 2.5x returns after the error (exit 1). The pick stays in progress
|
|
1087
|
+
* (CHERRY_PICK_HEAD, MERGE_MSG), as git leaves it.
|
|
1088
|
+
*/
|
|
1089
|
+
private async signed(commit: Commit): Promise<Commit> {
|
|
1090
|
+
const sign = this.sign;
|
|
1091
|
+
if (sign === undefined) return commit;
|
|
1092
|
+
const legacy = this.deps.hooks?.compatibility === "2.43";
|
|
1093
|
+
const cwd = await this.deps.hooks?.hostWorkingDirectory().catch(() => undefined);
|
|
1094
|
+
try {
|
|
1095
|
+
return await signCommit(this.deps.workingCopy, sign, commit, {
|
|
1096
|
+
tail: [],
|
|
1097
|
+
...(cwd !== undefined ? { cwd } : {}),
|
|
1098
|
+
});
|
|
1099
|
+
} catch (error) {
|
|
1100
|
+
if (!(error instanceof SigningFailedError)) throw error;
|
|
1101
|
+
// the signing died itself (ssh without a key): git dies there
|
|
1102
|
+
if (/(^|\n)fatal: [^\n]*$/.test(error.message)) throw error;
|
|
1103
|
+
throw new SigningFailedError(
|
|
1104
|
+
[
|
|
1105
|
+
error.message,
|
|
1106
|
+
"error: failed to write commit object",
|
|
1107
|
+
...(legacy ? [`fatal: ${this.name} failed`] : []),
|
|
1108
|
+
].join("\n"),
|
|
1109
|
+
sign,
|
|
1110
|
+
legacy ? 128 : 1,
|
|
1111
|
+
{
|
|
1112
|
+
...(error.signerMessages ? { signerMessages: error.signerMessages } : {}),
|
|
1113
|
+
...(error.programExitCode !== undefined
|
|
1114
|
+
? { programExitCode: error.programExitCode }
|
|
1115
|
+
: {}),
|
|
1116
|
+
},
|
|
1117
|
+
);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
|
|
672
1121
|
/** HEAD (its branch, when attached) moved to `id`, with `message` in the reflogs. */
|
|
673
|
-
private async moveHead(
|
|
1122
|
+
private async moveHead(
|
|
1123
|
+
id: ObjectId,
|
|
1124
|
+
message: string,
|
|
1125
|
+
/** the old value the transaction expects (default HEAD's, null for an unborn HEAD) */
|
|
1126
|
+
expected?: ObjectId | null,
|
|
1127
|
+
): Promise<void> {
|
|
674
1128
|
this.clock ??= Math.floor(Date.now() / 1000);
|
|
675
1129
|
const log = reflogLine(this.deps.workingCopy, message, this.options.committer, this.clock);
|
|
676
1130
|
// update_head_with_reflog: one transaction on HEAD expecting the commit's parent, as the
|
|
677
1131
|
// reference-transaction hook sees it
|
|
678
|
-
const current =
|
|
1132
|
+
const current = expected !== undefined ? expected : await this.headIfBorn();
|
|
679
1133
|
const result = await this.deps.refs.batch(
|
|
680
1134
|
[{ name: "HEAD", old: current ?? null, new: id }],
|
|
681
1135
|
log,
|
|
@@ -731,6 +1185,12 @@ export class PickSequencer {
|
|
|
731
1185
|
);
|
|
732
1186
|
}
|
|
733
1187
|
|
|
1188
|
+
/** HEAD's commit, undefined while HEAD's branch is unborn. */
|
|
1189
|
+
private async headIfBorn(): Promise<ObjectId | undefined> {
|
|
1190
|
+
const resolved = await this.deps.refs.resolve("HEAD").catch(() => undefined);
|
|
1191
|
+
return resolved?.objectId || undefined;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
734
1194
|
private async headId(): Promise<ObjectId> {
|
|
735
1195
|
const resolved = await this.deps.refs.resolve("HEAD");
|
|
736
1196
|
if (!resolved?.objectId) throw new RefNotFoundError("HEAD", "HEAD cannot be resolved");
|
|
@@ -872,3 +1332,250 @@ export async function expandCommitIds(
|
|
|
872
1332
|
return found;
|
|
873
1333
|
});
|
|
874
1334
|
}
|
|
1335
|
+
|
|
1336
|
+
/** `revert.reference` (git_sequencer_config, revert only). */
|
|
1337
|
+
function revertReferenceOf(workingCopy: SequencerDeps["workingCopy"]): boolean {
|
|
1338
|
+
const value = RemoteConfigStore.from(workingCopy).value("revert.reference");
|
|
1339
|
+
return value === undefined ? false : (parseGitBool(value) ?? false);
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
/** comment_line_str: `core.commentString`, else `core.commentChar` (`auto`: `#`). */
|
|
1343
|
+
function commentStringOf(workingCopy: SequencerDeps["workingCopy"]): string {
|
|
1344
|
+
const config = RemoteConfigStore.from(workingCopy);
|
|
1345
|
+
const value = config.value("core.commentString") ?? config.value("core.commentChar");
|
|
1346
|
+
return value && value !== "auto" ? value : "#";
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
/** DATE_SHORT of an ident: `YYYY-MM-DD` in its own zone. */
|
|
1350
|
+
function shortDate(ident: PersonIdent | undefined): string {
|
|
1351
|
+
if (!ident) return "";
|
|
1352
|
+
const tz = ident.tzOffset || "+0000";
|
|
1353
|
+
const sign = tz.startsWith("-") ? -1 : 1;
|
|
1354
|
+
const minutes = sign * (Number(tz.slice(1, 3)) * 60 + Number(tz.slice(3, 5)));
|
|
1355
|
+
const d = new Date((ident.timestamp + minutes * 60) * 1000);
|
|
1356
|
+
const pad = (n: number) => String(n).padStart(2, "0");
|
|
1357
|
+
return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())}`;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
/** What {@link mergePickChange} reads and writes with. */
|
|
1361
|
+
export interface PickMergeContext {
|
|
1362
|
+
workingCopy: SequencerDeps["workingCopy"];
|
|
1363
|
+
worktree?: Worktree;
|
|
1364
|
+
staging: SequencerDeps["staging"];
|
|
1365
|
+
blobs: SequencerDeps["blobs"];
|
|
1366
|
+
trees: CommandTrees;
|
|
1367
|
+
commits: CommandCommits;
|
|
1368
|
+
flats: FlatTreeCache;
|
|
1369
|
+
abbreviate: (id: ObjectId) => Promise<string>;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
/** The pick {@link mergePickChange} merges. */
|
|
1373
|
+
export interface PickMergeArgs {
|
|
1374
|
+
action: PickAction;
|
|
1375
|
+
headId: ObjectId | undefined;
|
|
1376
|
+
/** HEAD's tree (undefined: the empty tree of an unborn branch) */
|
|
1377
|
+
headTreeId: ObjectId | undefined;
|
|
1378
|
+
base: ObjectId | undefined;
|
|
1379
|
+
theirs: ObjectId | undefined;
|
|
1380
|
+
baseLabel: string;
|
|
1381
|
+
theirsLabel: string;
|
|
1382
|
+
pickId: ObjectId;
|
|
1383
|
+
parentId: ObjectId | undefined;
|
|
1384
|
+
/** `-s` (undefined: merge-ort) */
|
|
1385
|
+
strategy: string | undefined;
|
|
1386
|
+
/** `-X` options */
|
|
1387
|
+
xopts: readonly string[];
|
|
1388
|
+
/** HEAD's label in merge-ort's markers */
|
|
1389
|
+
oursLabel: string;
|
|
1390
|
+
/** `-X ours` / `-X theirs` / union given apart from the options */
|
|
1391
|
+
favor?: "ours" | "theirs" | "union";
|
|
1392
|
+
/** The git version whose behaviour to follow where they differ (default 2.56) */
|
|
1393
|
+
compatibility?: "2.43" | "2.56";
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
/** What {@link mergePickChange} found: the result to switch to, or git's failure. */
|
|
1397
|
+
export type PickMergeResult =
|
|
1398
|
+
| {
|
|
1399
|
+
treeId: ObjectId;
|
|
1400
|
+
conflicts: OrtConflict[];
|
|
1401
|
+
/** The paths the conflicts are about (merge-ort's keys; a file moved aside's own path) */
|
|
1402
|
+
conflictPaths: string[];
|
|
1403
|
+
clean: boolean;
|
|
1404
|
+
/** What the strategy printed (merge-ort's messages, git-merge-resolve's stdout) */
|
|
1405
|
+
messages: string[];
|
|
1406
|
+
/** Whether to record AUTO_MERGE (merge-ort's result tree) */
|
|
1407
|
+
autoMerge: boolean;
|
|
1408
|
+
/** Whether the strategy ran as git's child command (resolve, subtree) */
|
|
1409
|
+
external: boolean;
|
|
1410
|
+
/** What git-merge-one-file printed on stderr */
|
|
1411
|
+
errors?: string[];
|
|
1412
|
+
/** The switch to make, when it is not HEAD's tree to `treeId` */
|
|
1413
|
+
delta?: { from: Map<string, CheckedEntry>; to: Map<string, CheckedEntry> };
|
|
1414
|
+
/** What was printed before a refused switch */
|
|
1415
|
+
refusedOutput?: string[];
|
|
1416
|
+
}
|
|
1417
|
+
| {
|
|
1418
|
+
failed: string;
|
|
1419
|
+
/** The strategy gave up (exit 2): the pick fails as do_pick_commit's res -1 */
|
|
1420
|
+
strategyFailed?: boolean;
|
|
1421
|
+
output?: string[];
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
/**
|
|
1425
|
+
* The merge of a pick (do_pick_commit): merge-ort (do_recursive_merge, with the `-X`
|
|
1426
|
+
* options) unless `-s` names another strategy; `subtree` is git merge-subtree (merge-ort
|
|
1427
|
+
* with the shift, the commits' full ids as labels), `resolve` git-merge-resolve
|
|
1428
|
+
* (`read-tree -m --aggressive` and git-merge-one-file). Nothing is written but blobs and
|
|
1429
|
+
* trees: the caller switches to the result.
|
|
1430
|
+
*/
|
|
1431
|
+
export async function mergePickChange(
|
|
1432
|
+
ctx: PickMergeContext,
|
|
1433
|
+
p: PickMergeArgs,
|
|
1434
|
+
): Promise<PickMergeResult> {
|
|
1435
|
+
const strategy = p.strategy;
|
|
1436
|
+
const ort =
|
|
1437
|
+
strategy === undefined ||
|
|
1438
|
+
strategy === "recursive" ||
|
|
1439
|
+
strategy === "ort" ||
|
|
1440
|
+
p.action === "revert";
|
|
1441
|
+
if (!ort && strategy === "resolve" && p.headId) {
|
|
1442
|
+
// git-merge-resolve refuses an index that differs from HEAD's commit (`git diff-index
|
|
1443
|
+
// --cached HEAD`), whatever tree the sequencer merges onto (`--no-commit`: the index's)
|
|
1444
|
+
const headFlat = await flatTree(ctx.trees, p.headTreeId);
|
|
1445
|
+
const headCommitFlat = await flatTree(ctx.trees, await ctx.commits.getTree(p.headId));
|
|
1446
|
+
const { index } = await readIndex(ctx.staging);
|
|
1447
|
+
const outcome = await octopusMerge(
|
|
1448
|
+
{
|
|
1449
|
+
commits: ctx.commits,
|
|
1450
|
+
trees: ctx.trees,
|
|
1451
|
+
blobs: ctx.blobs,
|
|
1452
|
+
style: conflictStyleOf(ctx.workingCopy),
|
|
1453
|
+
},
|
|
1454
|
+
p.headId,
|
|
1455
|
+
[{ id: p.pickId, name: p.pickId }],
|
|
1456
|
+
indexChanges(index, headCommitFlat),
|
|
1457
|
+
{ resolve: true, bases: p.parentId ? [p.parentId] : [] },
|
|
1458
|
+
);
|
|
1459
|
+
if (outcome.status === 2) {
|
|
1460
|
+
// the strategy did not handle the merge: do_pick_commit's "could not apply" (no hints)
|
|
1461
|
+
return { failed: outcome.errors.join("\n"), strategyFailed: true, output: outcome.output };
|
|
1462
|
+
}
|
|
1463
|
+
const target = new Map(outcome.index);
|
|
1464
|
+
for (const [path, entry] of outcome.worktree) target.set(path, entry);
|
|
1465
|
+
const treeId = await storeFlatTree(ctx.trees, outcome.index);
|
|
1466
|
+
return {
|
|
1467
|
+
treeId,
|
|
1468
|
+
conflicts: outcome.conflicts,
|
|
1469
|
+
conflictPaths: outcome.conflicts.map((c) => c.stagePath),
|
|
1470
|
+
clean: outcome.status === 0,
|
|
1471
|
+
messages: outcome.output,
|
|
1472
|
+
errors: outcome.errors,
|
|
1473
|
+
autoMerge: false,
|
|
1474
|
+
external: true,
|
|
1475
|
+
delta: { from: headFlat, to: target },
|
|
1476
|
+
refusedOutput: outcome.output.slice(0, outcome.steps[0]?.output ?? 0),
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1479
|
+
if (!ort && strategy !== "subtree") {
|
|
1480
|
+
return { failed: `fatal: merge strategy '${strategy}' is not supported here` };
|
|
1481
|
+
}
|
|
1482
|
+
// do_recursive_merge reads the options without checking them (merge-subtree dies on an
|
|
1483
|
+
// unknown one, before merging)
|
|
1484
|
+
const xopts = parseStrategyOptions(p.xopts, ort);
|
|
1485
|
+
const subtree = !ort;
|
|
1486
|
+
const flats = ctx.flats;
|
|
1487
|
+
const labels = subtree
|
|
1488
|
+
? {
|
|
1489
|
+
oursLabel: p.headId ?? "HEAD",
|
|
1490
|
+
theirsLabel: p.pickId,
|
|
1491
|
+
baseLabel: p.parentId ? await ctx.abbreviate(p.parentId) : "empty tree",
|
|
1492
|
+
}
|
|
1493
|
+
: {
|
|
1494
|
+
oursLabel: p.oursLabel,
|
|
1495
|
+
theirsLabel: p.theirsLabel,
|
|
1496
|
+
baseLabel: p.baseLabel,
|
|
1497
|
+
};
|
|
1498
|
+
const subtreeShift = xopts.subtreeShift ?? (subtree ? "" : undefined);
|
|
1499
|
+
const merge = await mergeStoredTrees(
|
|
1500
|
+
ctx,
|
|
1501
|
+
storedBase(p.base, labels.baseLabel, () => flats.get(p.base)),
|
|
1502
|
+
p.headTreeId,
|
|
1503
|
+
p.theirs,
|
|
1504
|
+
{
|
|
1505
|
+
...labels,
|
|
1506
|
+
style: conflictStyleOf(ctx.workingCopy),
|
|
1507
|
+
favor: p.favor ?? xopts.favor,
|
|
1508
|
+
ignoreCase: coreBool(ctx.workingCopy, "ignorecase", false),
|
|
1509
|
+
...ortConfigOptions(ctx.workingCopy, ctx.worktree, {
|
|
1510
|
+
...(xopts.renormalize !== undefined ? { renormalize: xopts.renormalize } : {}),
|
|
1511
|
+
}),
|
|
1512
|
+
// merge-subtree runs with init_basic_merge_options (no diff.algorithm)
|
|
1513
|
+
...strategyOrtOptions(subtree ? undefined : ctx.workingCopy, xopts),
|
|
1514
|
+
...(subtreeShift !== undefined ? { subtreeShift } : {}),
|
|
1515
|
+
},
|
|
1516
|
+
(id) => flats.get(id),
|
|
1517
|
+
);
|
|
1518
|
+
const target = await ortResultEntries(ctx.blobs, merge);
|
|
1519
|
+
// only the directories the pick changes are stored again
|
|
1520
|
+
const treeId = await storeFlatTreeOver(ctx.trees, p.headTreeId, merge.ours, target);
|
|
1521
|
+
return {
|
|
1522
|
+
treeId,
|
|
1523
|
+
conflicts: [...merge.conflicts.values()],
|
|
1524
|
+
conflictPaths: [...merge.conflicts.keys()],
|
|
1525
|
+
clean: merge.clean,
|
|
1526
|
+
messages: merge.messages,
|
|
1527
|
+
// merge-subtree runs as a child: git 2.5x's (merge-ort's merge_switch_to_result) records
|
|
1528
|
+
// AUTO_MERGE, 2.43's (merge-recursive) never
|
|
1529
|
+
autoMerge: ort || p.compatibility !== "2.43",
|
|
1530
|
+
external: !ort,
|
|
1531
|
+
};
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
/**
|
|
1535
|
+
* config.c's write_pair: a value as `git config` writes it (quoted when it starts or ends
|
|
1536
|
+
* with a space or holds `;`, `#` or CR; `\n`, `\t`, `"` and `\` escaped).
|
|
1537
|
+
*/
|
|
1538
|
+
export function configValueText(value: string): string {
|
|
1539
|
+
const quote = value.startsWith(" ") || value.endsWith(" ") || /[;#\r]/.test(value) ? '"' : "";
|
|
1540
|
+
const body = value.replace(/[\n\t"\\]/g, (c) =>
|
|
1541
|
+
c === "\n" ? "\\n" : c === "\t" ? "\\t" : `\\${c}`,
|
|
1542
|
+
);
|
|
1543
|
+
return `${quote}${body}${quote}`;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
/**
|
|
1547
|
+
* config.c's parse_value of the text after a variable's `=` on one line: blanks around it
|
|
1548
|
+
* dropped, `"..."` keeping them, escapes undone, an unquoted `;` or `#` starting a comment;
|
|
1549
|
+
* undefined where git refuses the line.
|
|
1550
|
+
*/
|
|
1551
|
+
export function parseConfigValueText(text: string): string | undefined {
|
|
1552
|
+
let quote = false;
|
|
1553
|
+
let value = "";
|
|
1554
|
+
let trimLength = 0;
|
|
1555
|
+
for (let i = 0; i < text.length; i++) {
|
|
1556
|
+
let c = text[i];
|
|
1557
|
+
if ((c === " " || c === "\t") && !quote) {
|
|
1558
|
+
if (!trimLength) trimLength = value.length;
|
|
1559
|
+
if (value.length) value += c;
|
|
1560
|
+
continue;
|
|
1561
|
+
}
|
|
1562
|
+
if (!quote && (c === ";" || c === "#")) break;
|
|
1563
|
+
trimLength = 0;
|
|
1564
|
+
if (c === "\\") {
|
|
1565
|
+
c = text[++i] ?? "";
|
|
1566
|
+
if (c === "t") c = "\t";
|
|
1567
|
+
else if (c === "b") c = "\b";
|
|
1568
|
+
else if (c === "n") c = "\n";
|
|
1569
|
+
else if (c !== "\\" && c !== '"') return undefined;
|
|
1570
|
+
value += c;
|
|
1571
|
+
continue;
|
|
1572
|
+
}
|
|
1573
|
+
if (c === '"') {
|
|
1574
|
+
quote = !quote;
|
|
1575
|
+
continue;
|
|
1576
|
+
}
|
|
1577
|
+
value += c;
|
|
1578
|
+
}
|
|
1579
|
+
if (quote) return undefined;
|
|
1580
|
+
return trimLength ? value.slice(0, trimLength) : value;
|
|
1581
|
+
}
|