@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
|
@@ -13,17 +13,17 @@ import { isIndexUnborn, type Worktree } from "@statewalker/vcs-working-tree";
|
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
CommitNotFoundError,
|
|
16
|
+
GitApiError,
|
|
16
17
|
InvalidArgumentError,
|
|
17
18
|
NoHeadError,
|
|
18
19
|
NoRebaseInProgressError,
|
|
19
20
|
RebaseTodoMissingError,
|
|
20
21
|
RefNotFoundError,
|
|
21
|
-
UpstreamRequiredError,
|
|
22
22
|
} from "../errors/index.js";
|
|
23
23
|
import { GitCommand } from "../git-command.js";
|
|
24
24
|
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
25
25
|
import {
|
|
26
|
-
|
|
26
|
+
ContentMergeStrategy,
|
|
27
27
|
FastForwardMode,
|
|
28
28
|
type MergeResult,
|
|
29
29
|
MergeStatus,
|
|
@@ -31,7 +31,9 @@ import {
|
|
|
31
31
|
} from "../results/merge-result.js";
|
|
32
32
|
import type { RebaseResult, RebaseTodoLine } from "../results/rebase-result.js";
|
|
33
33
|
import { RebaseAction, RebaseStatus } from "../results/rebase-result.js";
|
|
34
|
+
import { AmCommand } from "./am/index.js";
|
|
34
35
|
import { coreBool, createIdAbbreviator, worktreeModeTrust } from "./core-config.js";
|
|
36
|
+
import { findForkPoint } from "./fork-point.js";
|
|
35
37
|
import { createDescriber, type DescribeOptions } from "./git-describe.js";
|
|
36
38
|
import {
|
|
37
39
|
type GitCommitHookRun,
|
|
@@ -42,9 +44,11 @@ import {
|
|
|
42
44
|
sequencerPrepareMessage,
|
|
43
45
|
} from "./git-hooks.js";
|
|
44
46
|
import { hostEnvironmentOf, localTimezoneOffset } from "./git-ident.js";
|
|
47
|
+
import { commitsBaseSource, MergeBaseGraph } from "./merge-bases.js";
|
|
45
48
|
import { favorOf, MergeCommand } from "./merge-command.js";
|
|
46
49
|
import { configBool, configValue, conflictStyleOf } from "./merge-config.js";
|
|
47
50
|
import { ortConfigOptions } from "./merge-drivers.js";
|
|
51
|
+
import { quoteStrategyOptions, splitStrategyOptions } from "./merge-strategy-options.js";
|
|
48
52
|
import {
|
|
49
53
|
conflictsComment,
|
|
50
54
|
FlatTreeCache,
|
|
@@ -61,8 +65,8 @@ import {
|
|
|
61
65
|
import { CleanupMode, commentPrefixOf, stripspace } from "./message-cleanup.js";
|
|
62
66
|
import { copyNotesForAmend, copyNotesForRebase } from "./notes-support.js";
|
|
63
67
|
import { ortResultEntries } from "./ort-merge.js";
|
|
64
|
-
import { mergeBaseTree, mergeStoredTrees
|
|
65
|
-
import { type PatchIdTrees
|
|
68
|
+
import { mergeBaseTree, mergeStoredTrees } from "./ort-recursive.js";
|
|
69
|
+
import { PatchIds, type PatchIdTrees } from "./patch-id.js";
|
|
66
70
|
import { formatCommitPretty, loadRefDecorations, type RefDecorations } from "./pretty-format.js";
|
|
67
71
|
import {
|
|
68
72
|
addExecCommands,
|
|
@@ -87,18 +91,29 @@ import {
|
|
|
87
91
|
} from "./rebase-todo.js";
|
|
88
92
|
import { reflogMessages, updateHeadExpecting } from "./reflog-messages.js";
|
|
89
93
|
import { revisionMergeBases } from "./rev-parse-command.js";
|
|
90
|
-
import { expandCommitId } from "./sequencer-pick.js";
|
|
94
|
+
import { expandCommitId, mergePickChange } from "./sequencer-pick.js";
|
|
91
95
|
import {
|
|
96
|
+
AUTOSTASH_SAVED_LINES,
|
|
92
97
|
applyAutostash,
|
|
93
98
|
cleanupMessage,
|
|
94
99
|
createAutostash,
|
|
95
100
|
moveHeadAsReset,
|
|
96
101
|
removeBranchState,
|
|
97
102
|
resetMerge,
|
|
103
|
+
saveAutostash,
|
|
98
104
|
} from "./sequencer-support.js";
|
|
99
|
-
import {
|
|
105
|
+
import { showCommit } from "./show-commit.js";
|
|
106
|
+
import { SigningFailedError, type SignRequest, signRequestOf } from "./signing.js";
|
|
107
|
+
import {
|
|
108
|
+
amendWithTrailers,
|
|
109
|
+
appendSignoff,
|
|
110
|
+
type TrailerCommandRunner,
|
|
111
|
+
type TrailerConfig,
|
|
112
|
+
trailerConfigOf,
|
|
113
|
+
validateTrailerArgs,
|
|
114
|
+
} from "./trailers.js";
|
|
100
115
|
import { worktreeModified } from "./worktree-overwrite-checks.js";
|
|
101
|
-
import { usesBranch } from "./worktree-support.js";
|
|
116
|
+
import { refuseIfCheckedOut, usesBranch } from "./worktree-support.js";
|
|
102
117
|
|
|
103
118
|
/**
|
|
104
119
|
* Rebase operation types.
|
|
@@ -116,6 +131,16 @@ export enum RebaseOperation {
|
|
|
116
131
|
PROCESS_STEPS = "process-steps",
|
|
117
132
|
/** `--edit-todo`: the rest of the todo list edited (the interactive handler's editTodo) */
|
|
118
133
|
EDIT_TODO = "edit-todo",
|
|
134
|
+
/**
|
|
135
|
+
* `--quit`: the rebase forgotten (its state directory removed, its autostash kept on
|
|
136
|
+
* `refs/stash`), HEAD, the index and the worktree left as they are
|
|
137
|
+
*/
|
|
138
|
+
QUIT = "quit",
|
|
139
|
+
/**
|
|
140
|
+
* `--show-current-patch`: `git show REBASE_HEAD` (merge backend) or `git am
|
|
141
|
+
* --show-current-patch` (apply backend), in {@link RebaseResult.currentPatch}
|
|
142
|
+
*/
|
|
143
|
+
SHOW_CURRENT_PATCH = "show-current-patch",
|
|
119
144
|
}
|
|
120
145
|
|
|
121
146
|
/**
|
|
@@ -170,7 +195,11 @@ interface UpdateRefRecord {
|
|
|
170
195
|
|
|
171
196
|
/** What a pick (do_pick_commit) did. */
|
|
172
197
|
type PickOutcome =
|
|
173
|
-
| {
|
|
198
|
+
| {
|
|
199
|
+
kind: "ok";
|
|
200
|
+
/** The message picked (do_pick_commit's ctx->message), when the pick was not fast-forwarded */
|
|
201
|
+
message?: string;
|
|
202
|
+
}
|
|
174
203
|
| { kind: "dropped" }
|
|
175
204
|
| {
|
|
176
205
|
kind: "conflicts";
|
|
@@ -179,6 +208,8 @@ type PickOutcome =
|
|
|
179
208
|
conflicts: string[];
|
|
180
209
|
/** What error_with_patch writes to `rebase-merge/message` */
|
|
181
210
|
message?: string;
|
|
211
|
+
/** error_failed_squash's to_amend (default true): 2.43 stops a failed squash unamended */
|
|
212
|
+
toAmend?: boolean;
|
|
182
213
|
}
|
|
183
214
|
| { kind: "reschedule"; result: RebaseResult & { reschedule?: boolean } };
|
|
184
215
|
|
|
@@ -190,19 +221,49 @@ type StepOutcome =
|
|
|
190
221
|
| (Partial<RebaseResult> & { reschedule?: boolean; checkTodo?: boolean })
|
|
191
222
|
| undefined;
|
|
192
223
|
|
|
193
|
-
/** sequencer.c's staged_changes_advice
|
|
194
|
-
|
|
224
|
+
/** sequencer.c's staged_changes_advice, with the run's quoted `-S<key>` (gpg_sign_opt_quoted). */
|
|
225
|
+
function stagedChangesAdvice(gpgSignOpt: string): string {
|
|
226
|
+
return `error: you have staged changes in your working tree
|
|
195
227
|
If these changes are meant to be squashed into the previous commit, run:
|
|
196
228
|
|
|
197
|
-
git commit --amend
|
|
229
|
+
git commit --amend ${gpgSignOpt}
|
|
198
230
|
|
|
199
231
|
If they are meant to go into a new commit, run:
|
|
200
232
|
|
|
201
|
-
git commit
|
|
233
|
+
git commit ${gpgSignOpt}
|
|
202
234
|
|
|
203
235
|
In both cases, once you're done, continue with:
|
|
204
236
|
|
|
205
237
|
git rebase --continue`;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* commit_staged_changes' git commit dying on its signature (not signed yet): gpg's lines,
|
|
242
|
+
* git commit's death, then the sequencer's error; nothing committed, the stop kept.
|
|
243
|
+
*/
|
|
244
|
+
function commitStagedSigningFailure(error: SigningFailedError): RebaseResult {
|
|
245
|
+
return {
|
|
246
|
+
status: RebaseStatus.FAILED,
|
|
247
|
+
message: [
|
|
248
|
+
error.message,
|
|
249
|
+
"fatal: failed to write commit object",
|
|
250
|
+
"error: could not commit staged changes.",
|
|
251
|
+
].join("\n"),
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* A reword's `git commit --amend -e` dying on its signature: gpg's lines and git commit's
|
|
257
|
+
* death, the rebase stopped with HEAD to amend; undefined for any other failure.
|
|
258
|
+
*/
|
|
259
|
+
function signingFailure(error: unknown): Extract<PickOutcome, { kind: "conflicts" }> | undefined {
|
|
260
|
+
if (!(error instanceof SigningFailedError)) return undefined;
|
|
261
|
+
return {
|
|
262
|
+
kind: "conflicts",
|
|
263
|
+
conflicts: [],
|
|
264
|
+
lines: [error.message, "fatal: failed to write commit object"],
|
|
265
|
+
};
|
|
266
|
+
}
|
|
206
267
|
|
|
207
268
|
/** rebase-interactive.c's edit_todo_list_advice. */
|
|
208
269
|
const EDIT_TODO_ADVICE = [
|
|
@@ -249,9 +310,16 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
249
310
|
private upstreamCommit?: ObjectId;
|
|
250
311
|
private upstreamCommitName?: string;
|
|
251
312
|
private strategy = MergeStrategy.RECURSIVE;
|
|
313
|
+
private strategyGiven = false;
|
|
252
314
|
private contentStrategy?: ContentMergeStrategy;
|
|
315
|
+
/** `-X <option>`s */
|
|
316
|
+
private strategyOptions: string[] = [];
|
|
317
|
+
/** The run's `-s` and `-X` (rebase-merge/strategy, strategy_opts), once read */
|
|
318
|
+
private runStrategyState?: { strategy?: string; xopts: string[] };
|
|
253
319
|
private preserveMerges = false;
|
|
254
320
|
private interactiveHandler?: InteractiveHandler;
|
|
321
|
+
/** Whose messages to give where git 2.43 and 2.5x differ (default: the hooks') */
|
|
322
|
+
private compatibility?: "2.43" | "2.56";
|
|
255
323
|
private committer?: PersonIdent;
|
|
256
324
|
/** `--committer-date-is-author-date` (kept in `rebase-merge/cdate_is_adate`) */
|
|
257
325
|
private committerDateIsAuthorDate = false;
|
|
@@ -259,8 +327,24 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
259
327
|
private ignoreDate = false;
|
|
260
328
|
/** `--signoff` (kept in `rebase-merge/signoff`) */
|
|
261
329
|
private signoff = false;
|
|
330
|
+
/** `--force-rebase` (REBASE_FORCE) */
|
|
331
|
+
private forceRebase = false;
|
|
332
|
+
/** `-S[<keyid>]` / `--no-gpg-sign` (undefined: `commit.gpgSign`; kept in `gpg_sign_opt`) */
|
|
333
|
+
private sign?: boolean | string;
|
|
334
|
+
/** What this run signs with (git's opts->gpg_sign), once known */
|
|
335
|
+
private runSign?: { key: SignRequest };
|
|
262
336
|
private autoStash?: boolean;
|
|
263
|
-
private reapplyCherryPicks
|
|
337
|
+
private reapplyCherryPicks?: boolean;
|
|
338
|
+
/** `--onto <newbase>` as given (`A...B` included) */
|
|
339
|
+
private ontoName?: string;
|
|
340
|
+
/** The `<branch>` argument: switched to before the rebase */
|
|
341
|
+
private branchArg?: string;
|
|
342
|
+
/** `--keep-base` */
|
|
343
|
+
private keepBase = false;
|
|
344
|
+
/** `--[no-]fork-point`; undefined: git's default (on for an implicit upstream) */
|
|
345
|
+
private forkPoint?: boolean;
|
|
346
|
+
/** The onto name of the rebase running (git's `onto_name`), for the reflog */
|
|
347
|
+
private runOntoName?: string;
|
|
264
348
|
/** `--rebase-merges` (undefined: `rebase.rebaseMerges`) */
|
|
265
349
|
private rebaseMerges?: boolean;
|
|
266
350
|
/** `--rebase-merges=rebase-cousins` */
|
|
@@ -292,6 +376,24 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
292
376
|
/** `--root`: every commit of the branch rebased (onto the upstream given, else a new root) */
|
|
293
377
|
private root = false;
|
|
294
378
|
private noVerify = false;
|
|
379
|
+
/** `--trailer` arguments (kept in `rebase-merge/trailer`, one per line) */
|
|
380
|
+
private trailerArgs: string[] = [];
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* `--trailer <token>[(=|:)<value>]` (git 2.46+): each rebased commit's message gets the
|
|
384
|
+
* trailer as `git interpret-trailers --no-divider --trailer` adds it (`trailer.*`
|
|
385
|
+
* configuration applies; a fixup or squash none, a `fixup -C` the message it takes). Like
|
|
386
|
+
* git, it implies `--force-rebase` and is kept in `rebase-merge/trailer` for `--continue`;
|
|
387
|
+
* an empty argument or one without a key is refused before anything is done, and under
|
|
388
|
+
* 2.43 compatibility the option itself (`error: unknown option \`trailer'`, exit 129).
|
|
389
|
+
* git's apply backend refuses it (`--trailer requires the merge backend`); ours has only
|
|
390
|
+
* the merge backend.
|
|
391
|
+
*/
|
|
392
|
+
addTrailer(trailer: string): this {
|
|
393
|
+
this.checkCallable();
|
|
394
|
+
this.trailerArgs.push(trailer);
|
|
395
|
+
return this;
|
|
396
|
+
}
|
|
295
397
|
|
|
296
398
|
/** `--no-verify`: the pre-rebase hook does not run. */
|
|
297
399
|
setNoVerify(noVerify: boolean): this {
|
|
@@ -333,18 +435,66 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
333
435
|
* builtin/rebase.c's `lookup_commit_reference_by_name(options.upstream_name)`: the commit
|
|
334
436
|
* an upstream names, or git's "fatal: invalid upstream '<name>'" (exit 128).
|
|
335
437
|
*/
|
|
336
|
-
private async resolveUpstream(name: string): Promise<ObjectId> {
|
|
337
|
-
const fatal = (
|
|
438
|
+
private async resolveUpstream(name: string, shown = name): Promise<ObjectId> {
|
|
439
|
+
const fatal = () => `fatal: invalid upstream '${shown}'`;
|
|
338
440
|
try {
|
|
339
441
|
return await this.resolveRef(name, fatal);
|
|
340
442
|
} catch (error) {
|
|
341
443
|
if (error instanceof RefNotFoundError) {
|
|
342
|
-
throw new RefNotFoundError(name, fatal(
|
|
444
|
+
throw new RefNotFoundError(name, fatal()).withExitCode(128);
|
|
343
445
|
}
|
|
344
446
|
throw error;
|
|
345
447
|
}
|
|
346
448
|
}
|
|
347
449
|
|
|
450
|
+
/**
|
|
451
|
+
* `--onto <newbase>`: the commits of `<upstream>..HEAD` go onto `newbase` instead of onto
|
|
452
|
+
* the upstream. Any revision, or `A...B` for the one merge base of A and B (either side
|
|
453
|
+
* empty is HEAD): git's `fatal: '<A...B>': need exactly one merge base` when there are
|
|
454
|
+
* none or several, `fatal: Does not point to a valid commit '<newbase>'` when it names no
|
|
455
|
+
* commit. With {@link setRoot} it is `--root --onto <newbase>`.
|
|
456
|
+
*/
|
|
457
|
+
setOnto(newbase: string): this {
|
|
458
|
+
this.checkCallable();
|
|
459
|
+
this.ontoName = newbase;
|
|
460
|
+
return this;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* The `<branch>` argument: `git rebase <upstream> <branch>` switches to it first (a local
|
|
465
|
+
* branch, which then moves; or any commit, rebased on a detached HEAD), as
|
|
466
|
+
* `git switch <branch>` would; a branch another worktree has checked out is refused.
|
|
467
|
+
*/
|
|
468
|
+
setBranch(branch: string): this {
|
|
469
|
+
this.checkCallable();
|
|
470
|
+
this.branchArg = branch;
|
|
471
|
+
return this;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* `--keep-base`: onto the merge base of the upstream and the branch (`<upstream>...<branch>`),
|
|
476
|
+
* so the commits stay where they are while the upstream's are left out. Implies
|
|
477
|
+
* `--no-fork-point` and `--reapply-cherry-picks` unless set; refused with `--onto` and
|
|
478
|
+
* `--root`.
|
|
479
|
+
*/
|
|
480
|
+
setKeepBase(keepBase: boolean): this {
|
|
481
|
+
this.checkCallable();
|
|
482
|
+
this.keepBase = keepBase;
|
|
483
|
+
return this;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* `--fork-point` / `--no-fork-point`: leave out the commits the upstream's reflog shows
|
|
488
|
+
* were once on it (git's get_fork_point: the one merge base of the branch and the values
|
|
489
|
+
* the upstream's reflog records, when it is one of them). Default: on when no upstream is
|
|
490
|
+
* given (the branch's `@{upstream}`), unless `rebase.forkPoint` is false; off otherwise.
|
|
491
|
+
*/
|
|
492
|
+
setForkPoint(forkPoint: boolean): this {
|
|
493
|
+
this.checkCallable();
|
|
494
|
+
this.forkPoint = forkPoint;
|
|
495
|
+
return this;
|
|
496
|
+
}
|
|
497
|
+
|
|
348
498
|
/**
|
|
349
499
|
* Set the upstream name for messages.
|
|
350
500
|
*
|
|
@@ -373,6 +523,17 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
373
523
|
*
|
|
374
524
|
* @param operation Rebase operation
|
|
375
525
|
*/
|
|
526
|
+
/**
|
|
527
|
+
* Whose messages to give where git 2.43 and 2.5x differ (`fatal: No rebase in progress?`
|
|
528
|
+
* in 2.43, `fatal: no rebase in progress` in 2.5x). Default: the hook runner's
|
|
529
|
+
* compatibility, else 2.56.
|
|
530
|
+
*/
|
|
531
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
532
|
+
this.checkCallable();
|
|
533
|
+
this.compatibility = version;
|
|
534
|
+
return this;
|
|
535
|
+
}
|
|
536
|
+
|
|
376
537
|
setOperation(operation: RebaseOperation): this {
|
|
377
538
|
this.checkCallable();
|
|
378
539
|
this.operation = operation;
|
|
@@ -387,16 +548,70 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
387
548
|
}
|
|
388
549
|
|
|
389
550
|
/**
|
|
390
|
-
* Set the merge strategy (
|
|
551
|
+
* Set the merge strategy (`-s`): merge-ort (RECURSIVE, ORT), RESOLVE (git-merge-resolve)
|
|
552
|
+
* or SUBTREE (git merge-subtree) for each pick; kept in `rebase-merge/strategy`.
|
|
391
553
|
*
|
|
392
554
|
* @param strategy Merge strategy
|
|
393
555
|
*/
|
|
394
556
|
setStrategy(strategy: MergeStrategy): this {
|
|
395
557
|
this.checkCallable();
|
|
396
558
|
this.strategy = strategy;
|
|
559
|
+
this.strategyGiven = true;
|
|
397
560
|
return this;
|
|
398
561
|
}
|
|
399
562
|
|
|
563
|
+
/**
|
|
564
|
+
* The `-X <option>`s of each pick (see `MergeCommand.setStrategyOptions`), kept in
|
|
565
|
+
* `rebase-merge/strategy_opts`; with no `-s`, the strategy is `ort` (builtin/rebase.c).
|
|
566
|
+
*/
|
|
567
|
+
setStrategyOptions(options: readonly string[]): this {
|
|
568
|
+
this.checkCallable();
|
|
569
|
+
this.strategyOptions = [...options];
|
|
570
|
+
return this;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** Adds one `-X <option>` (see {@link setStrategyOptions}). */
|
|
574
|
+
addStrategyOption(option: string): this {
|
|
575
|
+
this.checkCallable();
|
|
576
|
+
this.strategyOptions.push(option);
|
|
577
|
+
return this;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/** The `-X` options as given: `-X ours`/`-X theirs` of the content strategy first. */
|
|
581
|
+
private givenStrategyOptions(): string[] {
|
|
582
|
+
const favor =
|
|
583
|
+
this.contentStrategy === ContentMergeStrategy.OURS
|
|
584
|
+
? ["ours"]
|
|
585
|
+
: this.contentStrategy === ContentMergeStrategy.THEIRS
|
|
586
|
+
? ["theirs"]
|
|
587
|
+
: [];
|
|
588
|
+
return [...favor, ...this.strategyOptions];
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/** The run's `-s` (`ort` when only `-X` was given) as builtin/rebase.c settles it. */
|
|
592
|
+
private givenStrategyName(): string | undefined {
|
|
593
|
+
if (this.strategyGiven) return this.strategy;
|
|
594
|
+
return this.givenStrategyOptions().length > 0 ? "ort" : undefined;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/** The run's `-s` and `-X`: read back from `rebase-merge/` (read_strategy_opts), else given. */
|
|
598
|
+
private async runStrategy(
|
|
599
|
+
state: OperationState,
|
|
600
|
+
): Promise<{ strategy: string | undefined; xopts: string[] }> {
|
|
601
|
+
if (!this.runStrategyState) {
|
|
602
|
+
const strategy = (await state.read(`${DIR}/strategy`))?.trim();
|
|
603
|
+
const opts = await state.read(`${DIR}/strategy_opts`);
|
|
604
|
+
this.runStrategyState =
|
|
605
|
+
strategy !== undefined || opts !== undefined
|
|
606
|
+
? {
|
|
607
|
+
...(strategy ? { strategy } : {}),
|
|
608
|
+
xopts: opts !== undefined ? splitStrategyOptions(opts.trim()) : [],
|
|
609
|
+
}
|
|
610
|
+
: { strategy: this.givenStrategyName(), xopts: this.givenStrategyOptions() };
|
|
611
|
+
}
|
|
612
|
+
return { strategy: this.runStrategyState.strategy, xopts: this.runStrategyState.xopts };
|
|
613
|
+
}
|
|
614
|
+
|
|
400
615
|
/**
|
|
401
616
|
* Get the merge strategy.
|
|
402
617
|
*/
|
|
@@ -533,6 +748,84 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
533
748
|
return this;
|
|
534
749
|
}
|
|
535
750
|
|
|
751
|
+
/**
|
|
752
|
+
* `-S` (true) / `--no-gpg-sign` (false): whether to sign the commits the rebase makes;
|
|
753
|
+
* undefined (the default) leaves it to `commit.gpgSign`. Kept in
|
|
754
|
+
* `rebase-merge/gpg_sign_opt` for `--continue`. Every commit the rebase writes is signed
|
|
755
|
+
* through the host's signer (`GitHostEnvironment.signer`) as git's sequencer signs it; when
|
|
756
|
+
* it cannot be signed the step fails as git's does (`error: gpg failed to sign the data:`,
|
|
757
|
+
* `error: failed to write commit object`) and the rebase stops there (2.5x: `Could not
|
|
758
|
+
* apply ...`, the pick to commit; 2.43: the pick rescheduled), the branch untouched.
|
|
759
|
+
* Picks kept as they are (fast-forwarded) sign nothing, as in git.
|
|
760
|
+
*/
|
|
761
|
+
setSign(sign: boolean | undefined): this {
|
|
762
|
+
this.checkCallable();
|
|
763
|
+
this.sign = sign;
|
|
764
|
+
return this;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/** `-S<keyid>`: sign with this key (see {@link setSign}). */
|
|
768
|
+
setSigningKey(keyId: string): this {
|
|
769
|
+
this.checkCallable();
|
|
770
|
+
this.sign = keyId;
|
|
771
|
+
return this;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* The key this run's commits are signed with: the one it started with, else (a
|
|
776
|
+
* `--continue`) `rebase-merge/gpg_sign_opt` over `commit.gpgSign` (read_populate_opts).
|
|
777
|
+
*/
|
|
778
|
+
private async signRequest(state: OperationState): Promise<SignRequest> {
|
|
779
|
+
if (this.runSign) return this.runSign.key;
|
|
780
|
+
const saved = (await state.read(`${DIR}/gpg_sign_opt`))?.replace(/\n$/, "");
|
|
781
|
+
const key =
|
|
782
|
+
saved?.startsWith("-S") === true
|
|
783
|
+
? saved.slice(2)
|
|
784
|
+
: signRequestOf(this.workingCopy, undefined);
|
|
785
|
+
this.runSign = { key };
|
|
786
|
+
return key;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* commit_tree's signing of a commit the rebase makes, with this run's key (git's
|
|
791
|
+
* opts->gpg_sign), the signing program in the worktree top. When it cannot be signed:
|
|
792
|
+
* {@link SigningFailedError} with gpg's lines alone; the step says what follows.
|
|
793
|
+
*/
|
|
794
|
+
private async signedRebaseCommit(state: OperationState, commit: Commit): Promise<Commit> {
|
|
795
|
+
return this.signedCommit(await this.signRequest(state), commit, []);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/** sequencer.c's gpg_sign_opt_quoted: `'-S<key>'` (shell-quoted) when the run signs, else "". */
|
|
799
|
+
private async gpgSignOptQuoted(state: OperationState): Promise<string> {
|
|
800
|
+
const sign = await this.signRequest(state);
|
|
801
|
+
return sign === undefined
|
|
802
|
+
? ""
|
|
803
|
+
: `'-S${sign.replaceAll("'", "'\\''").replaceAll("!", "'\\!'")}'`;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* try_to_commit failing to sign a pick or a fixup: 2.43 reschedules the command (its
|
|
808
|
+
* `error:` lines, the rescheduled advice), 2.5x stops as after a conflict.
|
|
809
|
+
*/
|
|
810
|
+
private signingStop(
|
|
811
|
+
item: TodoItem,
|
|
812
|
+
lines: string[],
|
|
813
|
+
options: { message?: string } = {},
|
|
814
|
+
): PickOutcome {
|
|
815
|
+
if (this.hooks.compatibility === "2.43") {
|
|
816
|
+
return {
|
|
817
|
+
kind: "reschedule",
|
|
818
|
+
result: {
|
|
819
|
+
status: RebaseStatus.FAILED,
|
|
820
|
+
currentCommit: item.id,
|
|
821
|
+
message: lines.join("\n"),
|
|
822
|
+
reschedule: true,
|
|
823
|
+
},
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
return { kind: "conflicts", conflicts: [], lines, ...options };
|
|
827
|
+
}
|
|
828
|
+
|
|
536
829
|
/**
|
|
537
830
|
* `--exec <command>` (`-x`): an `exec <command>` line after each pick (after its fixup and
|
|
538
831
|
* squash chain) and each merge; implies an interactive list (no fast-forward shortcut) and
|
|
@@ -609,6 +902,18 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
609
902
|
return this;
|
|
610
903
|
}
|
|
611
904
|
|
|
905
|
+
/**
|
|
906
|
+
* `--force-rebase` (`-f`, `--no-ff`): every commit is picked again, even one whose parent is
|
|
907
|
+
* already where the rebase puts it (git's REBASE_FORCE: no allow_ff, no up-to-date
|
|
908
|
+
* shortcut, `Current branch <name> is up to date, rebase forced.`). Like git, a `--continue`
|
|
909
|
+
* does not remember it.
|
|
910
|
+
*/
|
|
911
|
+
setForceRebase(value: boolean): this {
|
|
912
|
+
this.checkCallable();
|
|
913
|
+
this.forceRebase = value;
|
|
914
|
+
return this;
|
|
915
|
+
}
|
|
916
|
+
|
|
612
917
|
/**
|
|
613
918
|
* `--root`: all the commits of the branch are rebased, its root commit too. With an
|
|
614
919
|
* upstream set ({@link setUpstream}) that is `--root --onto <upstream>`; without one the
|
|
@@ -649,7 +954,18 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
649
954
|
};
|
|
650
955
|
}
|
|
651
956
|
}
|
|
957
|
+
// parse_options: --trailer is unknown to 2.43; validate_trailer_args, then die(NULL)
|
|
958
|
+
if (this.trailerArgs.length > 0) {
|
|
959
|
+
if ((this.compatibility ?? this.hooks.compatibility) === "2.43") {
|
|
960
|
+
throw new GitApiError("error: unknown option `trailer'", { exitCode: 129 });
|
|
961
|
+
}
|
|
962
|
+
const refused = validateTrailerArgs(this.trailerArgs, this.trailerConfig());
|
|
963
|
+
if (refused !== undefined) throw new GitApiError(refused, { exitCode: 128 });
|
|
964
|
+
}
|
|
652
965
|
switch (this.operation) {
|
|
966
|
+
case RebaseOperation.QUIT:
|
|
967
|
+
case RebaseOperation.SHOW_CURRENT_PATCH:
|
|
968
|
+
return this.quitOrShow(state, worktree, this.operation);
|
|
653
969
|
case RebaseOperation.ABORT:
|
|
654
970
|
return this.abort(state, worktree);
|
|
655
971
|
case RebaseOperation.CONTINUE:
|
|
@@ -683,19 +999,260 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
683
999
|
);
|
|
684
1000
|
}
|
|
685
1001
|
|
|
1002
|
+
/**
|
|
1003
|
+
* cmd_rebase's checks of the options among themselves; the fork-point setting as git
|
|
1004
|
+
* settles it then (1 on, 0 off, -1 the default: on for an implicit upstream).
|
|
1005
|
+
*/
|
|
1006
|
+
private checkBeginOptions(): number {
|
|
1007
|
+
// rebase_config: rebase.forkPoint=false turns the default off, true leaves it
|
|
1008
|
+
const configured = configValue(this.workingCopy, "rebase.forkPoint");
|
|
1009
|
+
let forkPoint = configured !== undefined && parseGitBool(configured) === false ? 0 : -1;
|
|
1010
|
+
if (this.forkPoint !== undefined) forkPoint = this.forkPoint ? 1 : 0;
|
|
1011
|
+
const together = (a: string, b: string) =>
|
|
1012
|
+
new GitApiError(`fatal: options '${a}' and '${b}' cannot be used together`);
|
|
1013
|
+
if (this.keepBase) {
|
|
1014
|
+
if (this.ontoName !== undefined) throw together("--keep-base", "--onto");
|
|
1015
|
+
if (this.root) throw together("--keep-base", "--root");
|
|
1016
|
+
// --keep-base defaults to --no-fork-point to keep the base the same
|
|
1017
|
+
if (forkPoint < 0) forkPoint = 0;
|
|
1018
|
+
}
|
|
1019
|
+
if (this.root && forkPoint > 0) throw together("--root", "--fork-point");
|
|
1020
|
+
return forkPoint;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* cmd_rebase's names and commits: the upstream (given, else the branch's `@{upstream}`),
|
|
1025
|
+
* the branch rebased (the `<branch>` argument, else HEAD's), onto (`--onto`, `A...B`,
|
|
1026
|
+
* `--keep-base`, `--root`'s squash-onto), the fork point and the branch base (the one
|
|
1027
|
+
* merge base of onto and the branch, which can_fast_forward reads).
|
|
1028
|
+
*/
|
|
1029
|
+
private async settleBegin(
|
|
1030
|
+
forkPoint: number,
|
|
1031
|
+
/** What git prints reading the names (`warning: refname 'x' is ambiguous.`) */
|
|
1032
|
+
warnings: string[],
|
|
1033
|
+
): Promise<
|
|
1034
|
+
| RebaseResult
|
|
1035
|
+
| {
|
|
1036
|
+
currentHead: ObjectId;
|
|
1037
|
+
origHead: ObjectId;
|
|
1038
|
+
headName: string;
|
|
1039
|
+
branchName: string;
|
|
1040
|
+
onto: ObjectId;
|
|
1041
|
+
ontoName: string;
|
|
1042
|
+
upstream?: ObjectId;
|
|
1043
|
+
upstreamName?: string;
|
|
1044
|
+
restrict?: ObjectId;
|
|
1045
|
+
branchBase?: ObjectId;
|
|
1046
|
+
squashOnto?: ObjectId;
|
|
1047
|
+
}
|
|
1048
|
+
> {
|
|
1049
|
+
const fatal = (message: string) => new GitApiError(`fatal: ${message}`);
|
|
1050
|
+
let upstreamName: string | undefined;
|
|
1051
|
+
let upstream: ObjectId | undefined;
|
|
1052
|
+
let ontoName = this.ontoName;
|
|
1053
|
+
let onto: ObjectId | undefined;
|
|
1054
|
+
let squashOnto: ObjectId | undefined;
|
|
1055
|
+
if (!this.root) {
|
|
1056
|
+
if (this.upstreamCommit === undefined) {
|
|
1057
|
+
const missing = await this.defaultUpstream();
|
|
1058
|
+
if (typeof missing !== "string") return missing;
|
|
1059
|
+
upstreamName = missing;
|
|
1060
|
+
if (forkPoint < 0) forkPoint = 1;
|
|
1061
|
+
} else {
|
|
1062
|
+
upstreamName = this.upstreamCommitName === "-" ? "@{-1}" : this.upstreamCommitName;
|
|
1063
|
+
}
|
|
1064
|
+
// the upstream as given (setUpstream takes a name too) peeled to the commit it names
|
|
1065
|
+
// before anything is written, so HEAD is never set to a name ("main\n" in .git/HEAD);
|
|
1066
|
+
// an empty name too: "fatal: invalid upstream ''"
|
|
1067
|
+
const given =
|
|
1068
|
+
this.upstreamCommit === undefined || this.upstreamCommit === "-"
|
|
1069
|
+
? (upstreamName as string)
|
|
1070
|
+
: this.upstreamCommit;
|
|
1071
|
+
upstream = await this.resolveUpstream(given, upstreamName as string);
|
|
1072
|
+
warnings.push(...(await this.nameWarnings(given)));
|
|
1073
|
+
} else if (ontoName === undefined) {
|
|
1074
|
+
if (this.upstreamCommit !== undefined) {
|
|
1075
|
+
// setRoot with setUpstream: `--root --onto <upstream>`
|
|
1076
|
+
onto = await this.resolveUpstream(this.upstreamCommit);
|
|
1077
|
+
ontoName = this.upstreamCommitName ?? onto;
|
|
1078
|
+
} else {
|
|
1079
|
+
// --root without --onto: the commits go onto git's squash_onto, a commit of the
|
|
1080
|
+
// empty tree with no parent (their root is then a root again)
|
|
1081
|
+
squashOnto = await this.createSquashOnto();
|
|
1082
|
+
onto = squashOnto;
|
|
1083
|
+
ontoName = squashOnto;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
const headResolved = await this.refsStore.resolve("HEAD");
|
|
1088
|
+
if (!headResolved?.objectId) throw new NoHeadError("HEAD cannot be resolved");
|
|
1089
|
+
const currentHead = headResolved.objectId;
|
|
1090
|
+
let headName: string;
|
|
1091
|
+
let branchName: string;
|
|
1092
|
+
let origHead: ObjectId;
|
|
1093
|
+
if (this.branchArg !== undefined) {
|
|
1094
|
+
// "rebase other branchname" or "rebase other commit"
|
|
1095
|
+
branchName = this.branchArg;
|
|
1096
|
+
const ref = `refs/heads/${branchName}`;
|
|
1097
|
+
const local = (await this.refsStore.resolve(ref).catch(() => undefined))?.objectId;
|
|
1098
|
+
if (local) {
|
|
1099
|
+
const worktrees = this.workingCopy.worktrees;
|
|
1100
|
+
if (worktrees) await refuseIfCheckedOut(worktrees, ref, true);
|
|
1101
|
+
if (!(await this.loadCommit(local))) {
|
|
1102
|
+
throw fatal(`no such branch/commit '${branchName}'`);
|
|
1103
|
+
}
|
|
1104
|
+
headName = ref;
|
|
1105
|
+
origHead = local;
|
|
1106
|
+
} else {
|
|
1107
|
+
const id = await this.revisionResolver()
|
|
1108
|
+
.resolve(branchName, { hint: "committish" })
|
|
1109
|
+
.catch(() => undefined);
|
|
1110
|
+
const commit = id && (await this.revisionResolver().commitReference(id));
|
|
1111
|
+
if (!commit) throw fatal(`no such branch/commit '${branchName}'`);
|
|
1112
|
+
headName = "detached HEAD";
|
|
1113
|
+
origHead = commit;
|
|
1114
|
+
}
|
|
1115
|
+
} else {
|
|
1116
|
+
const headRef = await this.refsStore.get("HEAD");
|
|
1117
|
+
if (headRef && isSymbolicRef(headRef)) {
|
|
1118
|
+
headName = headRef.target;
|
|
1119
|
+
branchName = headName.startsWith("refs/heads/")
|
|
1120
|
+
? headName.slice("refs/heads/".length)
|
|
1121
|
+
: headName;
|
|
1122
|
+
} else {
|
|
1123
|
+
headName = "detached HEAD";
|
|
1124
|
+
branchName = "HEAD";
|
|
1125
|
+
}
|
|
1126
|
+
origHead = currentHead;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
// make sure the branch to rebase onto is valid
|
|
1130
|
+
let branchBase: ObjectId | undefined;
|
|
1131
|
+
if (this.keepBase) ontoName = `${upstreamName}...${branchName}`;
|
|
1132
|
+
else if (ontoName === undefined) ontoName = upstreamName as string;
|
|
1133
|
+
if (onto === undefined && !ontoName.includes("...")) {
|
|
1134
|
+
warnings.push(...(await this.nameWarnings(ontoName)));
|
|
1135
|
+
}
|
|
1136
|
+
if (onto === undefined && ontoName.includes("...")) {
|
|
1137
|
+
onto = await this.mergeBaseOfDots(ontoName);
|
|
1138
|
+
if (onto === undefined) {
|
|
1139
|
+
throw this.keepBase
|
|
1140
|
+
? fatal(`'${upstreamName}': need exactly one merge base with branch`)
|
|
1141
|
+
: fatal(`'${ontoName}': need exactly one merge base`);
|
|
1142
|
+
}
|
|
1143
|
+
branchBase = onto;
|
|
1144
|
+
} else {
|
|
1145
|
+
if (onto === undefined) {
|
|
1146
|
+
const id =
|
|
1147
|
+
ontoName === upstreamName && upstream !== undefined
|
|
1148
|
+
? upstream
|
|
1149
|
+
: await this.resolveRef(
|
|
1150
|
+
ontoName,
|
|
1151
|
+
(n) => `fatal: Does not point to a valid commit '${n}'`,
|
|
1152
|
+
).catch((error: unknown) => {
|
|
1153
|
+
if (error instanceof RefNotFoundError) {
|
|
1154
|
+
throw fatal(`Does not point to a valid commit '${ontoName}'`);
|
|
1155
|
+
}
|
|
1156
|
+
throw error;
|
|
1157
|
+
});
|
|
1158
|
+
onto = id;
|
|
1159
|
+
}
|
|
1160
|
+
// fill_branch_base: the one merge base of onto and the branch, else none
|
|
1161
|
+
const bases = await revisionMergeBases(this.commits, onto, origHead);
|
|
1162
|
+
branchBase = bases.length === 1 ? bases[0] : undefined;
|
|
1163
|
+
}
|
|
1164
|
+
// --keep-base keeps cherry-picks (unless --no-reapply-cherry-picks): the upstream is
|
|
1165
|
+
// onto, so none can be detected
|
|
1166
|
+
if (this.keepBase && (this.reapplyCherryPicks ?? true)) upstream = onto;
|
|
1167
|
+
let restrict: ObjectId | undefined;
|
|
1168
|
+
if (forkPoint > 0 && upstreamName !== undefined) {
|
|
1169
|
+
const graph = new MergeBaseGraph(commitsBaseSource(this.commits, async () => new Map()));
|
|
1170
|
+
restrict = await findForkPoint(this.forkPointSource(graph), upstreamName, origHead);
|
|
1171
|
+
}
|
|
1172
|
+
return {
|
|
1173
|
+
currentHead,
|
|
1174
|
+
origHead,
|
|
1175
|
+
headName,
|
|
1176
|
+
branchName,
|
|
1177
|
+
onto,
|
|
1178
|
+
ontoName,
|
|
1179
|
+
upstream,
|
|
1180
|
+
upstreamName,
|
|
1181
|
+
restrict,
|
|
1182
|
+
branchBase,
|
|
1183
|
+
squashOnto,
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* branch_get_upstream for `git rebase` without an upstream: the current branch's
|
|
1189
|
+
* `@{upstream}`, else error_on_missing_default_upstream's advice (stdout, exit 1).
|
|
1190
|
+
*/
|
|
1191
|
+
private async defaultUpstream(): Promise<string | RebaseResult> {
|
|
1192
|
+
const headRef = await this.refsStore.get("HEAD").catch(() => undefined);
|
|
1193
|
+
const branch =
|
|
1194
|
+
headRef && isSymbolicRef(headRef) && headRef.target.startsWith("refs/heads/")
|
|
1195
|
+
? headRef.target.slice("refs/heads/".length)
|
|
1196
|
+
: undefined;
|
|
1197
|
+
if (branch !== undefined) {
|
|
1198
|
+
try {
|
|
1199
|
+
return await this.revisionResolver().upstreamOf(branch);
|
|
1200
|
+
} catch {
|
|
1201
|
+
// no upstream: the advice below
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
const output = [
|
|
1205
|
+
branch !== undefined
|
|
1206
|
+
? "There is no tracking information for the current branch."
|
|
1207
|
+
: "You are not currently on a branch.",
|
|
1208
|
+
"Please specify which branch you want to rebase against.",
|
|
1209
|
+
"See git-rebase(1) for details.",
|
|
1210
|
+
"",
|
|
1211
|
+
" git rebase '<branch>'",
|
|
1212
|
+
"",
|
|
1213
|
+
];
|
|
1214
|
+
if (branch !== undefined) {
|
|
1215
|
+
const remote =
|
|
1216
|
+
RemoteConfigStore.from(this.workingCopy).value(`branch.${branch}.remote`) ?? "<remote>";
|
|
1217
|
+
output.push(
|
|
1218
|
+
"If you wish to set tracking information for this branch you can do so with:",
|
|
1219
|
+
"",
|
|
1220
|
+
` git branch --set-upstream-to=${remote}/<branch> ${branch}`,
|
|
1221
|
+
"",
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1224
|
+
return { status: RebaseStatus.FAILED, output };
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
/** What git prints while it reads `name` (an ambiguous refname's warning). */
|
|
1228
|
+
private async nameWarnings(name: string): Promise<string[]> {
|
|
1229
|
+
const resolver = this.revisionResolver();
|
|
1230
|
+
await resolver.resolve(name, { hint: "committish" }).catch(() => undefined);
|
|
1231
|
+
return resolver.warnings;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
/** repo_get_oid_mb: the one merge base of `A...B` (either side empty is HEAD). */
|
|
1235
|
+
private async mergeBaseOfDots(name: string): Promise<ObjectId | undefined> {
|
|
1236
|
+
const dots = name.indexOf("...");
|
|
1237
|
+
const resolver = this.revisionResolver();
|
|
1238
|
+
const commitOf = async (rev: string) => {
|
|
1239
|
+
const id = await resolver.resolve(rev, { hint: "committish" }).catch(() => undefined);
|
|
1240
|
+
return id === undefined ? undefined : resolver.commitReference(id);
|
|
1241
|
+
};
|
|
1242
|
+
const one = await commitOf(dots === 0 ? "HEAD" : name.slice(0, dots));
|
|
1243
|
+
if (one === undefined) return undefined;
|
|
1244
|
+
const rest = name.slice(dots + 3);
|
|
1245
|
+
const two = await commitOf(rest === "" ? "HEAD" : rest);
|
|
1246
|
+
if (two === undefined) return undefined;
|
|
1247
|
+
const bases = await revisionMergeBases(this.commits, one, two);
|
|
1248
|
+
return bases.length === 1 ? bases[0] : undefined;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
686
1251
|
private async begin(
|
|
687
1252
|
state: OperationState,
|
|
688
1253
|
worktree: Worktree | undefined,
|
|
689
1254
|
): Promise<RebaseResult> {
|
|
690
|
-
|
|
691
|
-
throw new UpstreamRequiredError("Upstream commit is required for rebase BEGIN operation");
|
|
692
|
-
}
|
|
693
|
-
// the upstream as given (setUpstream takes a name too) peeled to the commit it names
|
|
694
|
-
// before anything is written, so HEAD is never set to a name ("main\n" in .git/HEAD)
|
|
695
|
-
// an empty name too: "fatal: invalid upstream ''"
|
|
696
|
-
if (this.upstreamCommit !== undefined) {
|
|
697
|
-
this.upstreamCommit = await this.resolveUpstream(this.upstreamCommit);
|
|
698
|
-
}
|
|
1255
|
+
const forkPoint = this.checkBeginOptions();
|
|
699
1256
|
if (await this.inProgress(state)) {
|
|
700
1257
|
return {
|
|
701
1258
|
status: RebaseStatus.FAILED,
|
|
@@ -714,23 +1271,35 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
714
1271
|
if (command === "")
|
|
715
1272
|
return { status: RebaseStatus.FAILED, message: "error: empty exec command" };
|
|
716
1273
|
}
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
squashOnto = await this.createSquashOnto();
|
|
727
|
-
this.upstreamCommitName = squashOnto;
|
|
1274
|
+
const nameWarnings: string[] = [];
|
|
1275
|
+
let settled: Awaited<ReturnType<RebaseCommand["settleBegin"]>>;
|
|
1276
|
+
try {
|
|
1277
|
+
settled = await this.settleBegin(forkPoint, nameWarnings);
|
|
1278
|
+
} catch (error) {
|
|
1279
|
+
if (error instanceof GitApiError && nameWarnings.length > 0) {
|
|
1280
|
+
error.message = [...nameWarnings, error.message].join("\n");
|
|
1281
|
+
}
|
|
1282
|
+
throw error;
|
|
728
1283
|
}
|
|
729
|
-
|
|
1284
|
+
if ("status" in settled) return settled;
|
|
1285
|
+
const {
|
|
1286
|
+
currentHead: headId,
|
|
1287
|
+
origHead,
|
|
1288
|
+
headName,
|
|
1289
|
+
branchName,
|
|
1290
|
+
onto,
|
|
1291
|
+
ontoName,
|
|
1292
|
+
upstream,
|
|
1293
|
+
upstreamName,
|
|
1294
|
+
restrict,
|
|
1295
|
+
branchBase,
|
|
1296
|
+
squashOnto,
|
|
1297
|
+
} = settled;
|
|
1298
|
+
this.runOntoName = ontoName;
|
|
730
1299
|
|
|
731
1300
|
// git's require_clean_work_tree: no unstaged, no staged changes, unless they are
|
|
732
1301
|
// stashed away for the rebase (rebase.autoStash) and applied again after it
|
|
733
|
-
const output: string[] = [];
|
|
1302
|
+
const output: string[] = [...nameWarnings];
|
|
734
1303
|
let autostash: ObjectId | undefined;
|
|
735
1304
|
const refusal = await this.uncleanWorktree(headId, worktree);
|
|
736
1305
|
if (refusal) {
|
|
@@ -771,27 +1340,39 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
771
1340
|
// git's can_fast_forward: HEAD already on upstream with a linear history since, nothing
|
|
772
1341
|
// to do (unless forced, as the date options and --signoff do); an interactive rebase,
|
|
773
1342
|
// --exec and --autosquash never take the shortcut (allow_preemptive_ff)
|
|
774
|
-
const forced =
|
|
1343
|
+
const forced =
|
|
1344
|
+
this.forceRebase ||
|
|
1345
|
+
this.committerDateIsAuthorDate ||
|
|
1346
|
+
this.ignoreDate ||
|
|
1347
|
+
this.signoff ||
|
|
1348
|
+
this.trailerArgs.length > 0;
|
|
775
1349
|
const preemptive = !interactive && execs.length === 0 && this.autosquash !== true;
|
|
776
|
-
if (preemptive &&
|
|
777
|
-
const upToDate =
|
|
778
|
-
? `Current branch ${
|
|
779
|
-
: "HEAD is up to date";
|
|
1350
|
+
if (preemptive && (await this.canFastForward(onto, upstream, restrict, origHead, branchBase))) {
|
|
1351
|
+
const upToDate =
|
|
1352
|
+
branchName === "HEAD" ? "HEAD is up to date" : `Current branch ${branchName} is up to date`;
|
|
780
1353
|
if (!forced) {
|
|
1354
|
+
// lazily switch to the target branch if needed (checkout_up_to_date)
|
|
1355
|
+
if (this.branchArg !== undefined) {
|
|
1356
|
+
const refused = await this.checkoutUpToDate(worktree, headId, origHead, headName);
|
|
1357
|
+
if (refused) {
|
|
1358
|
+
await unstash();
|
|
1359
|
+
return { ...refused, output: [...output, ...(refused.output ?? [])] };
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
781
1362
|
output.push(`${upToDate}.`);
|
|
782
1363
|
// finish_rebase: what an earlier rebase left removed
|
|
783
1364
|
await state.removeRef("REBASE_HEAD", "AUTO_MERGE");
|
|
784
1365
|
await unstash();
|
|
785
|
-
return { status: RebaseStatus.UP_TO_DATE, newHead:
|
|
1366
|
+
return { status: RebaseStatus.UP_TO_DATE, newHead: origHead, output };
|
|
786
1367
|
}
|
|
787
1368
|
output.push(`${upToDate}, rebase forced.`);
|
|
788
1369
|
}
|
|
789
1370
|
|
|
790
1371
|
// the pre-rebase hook, told the upstream as given (`--root` with --root), may refuse
|
|
791
1372
|
if (!this.noVerify) {
|
|
792
|
-
const upstreamArg =
|
|
793
|
-
|
|
794
|
-
const pre = await this.hooks.run("pre-rebase", { args
|
|
1373
|
+
const upstreamArg = this.root ? "--root" : (upstreamName as string);
|
|
1374
|
+
const args = this.branchArg !== undefined ? [upstreamArg, this.branchArg] : [upstreamArg];
|
|
1375
|
+
const pre = await this.hooks.run("pre-rebase", { args });
|
|
795
1376
|
if (pre && pre.exitCode !== 0) {
|
|
796
1377
|
await unstash();
|
|
797
1378
|
return {
|
|
@@ -823,15 +1404,20 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
823
1404
|
output,
|
|
824
1405
|
};
|
|
825
1406
|
}
|
|
826
|
-
await state.setRef("ORIG_HEAD",
|
|
1407
|
+
await state.setRef("ORIG_HEAD", origHead);
|
|
827
1408
|
await this.refsStore.set("HEAD", onto, this.startLog());
|
|
828
1409
|
await runPostCheckoutHook(this.hooks, headId, onto, true);
|
|
829
1410
|
await this.finishBranch(headName, onto, onto);
|
|
830
1411
|
await unstash();
|
|
831
1412
|
return { status, newHead: onto, output };
|
|
832
1413
|
};
|
|
833
|
-
// nothing of HEAD's to replay: HEAD moves to upstream
|
|
834
|
-
|
|
1414
|
+
// nothing of HEAD's to replay: HEAD moves to upstream (an interactive rebase still
|
|
1415
|
+
// shows its `noop` list to the editor, which may add commands)
|
|
1416
|
+
// get_revision_ranges' base: the upstream, else (--root) onto
|
|
1417
|
+
const base = upstream ?? onto;
|
|
1418
|
+
if (!interactive && base === onto && !restrict && (await this.isAncestor(origHead, onto))) {
|
|
1419
|
+
return moveToOnto(RebaseStatus.FAST_FORWARD);
|
|
1420
|
+
}
|
|
835
1421
|
|
|
836
1422
|
// `--rebase-merges` (else `rebase.rebaseMerges`, a boolean or a cousins mode)
|
|
837
1423
|
let rebaseMerges = this.rebaseMerges;
|
|
@@ -846,15 +1432,19 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
846
1432
|
}
|
|
847
1433
|
// the commits to pick: HEAD's, not upstream's, merges dropped (kept with
|
|
848
1434
|
// --rebase-merges), oldest first
|
|
849
|
-
|
|
1435
|
+
// (git's `<upstream>...<branch>` right side, `^<fork point>` excluded; with --root
|
|
1436
|
+
// everything below the branch)
|
|
1437
|
+
const excluded = [base, restrict].filter((id): id is ObjectId => id !== undefined);
|
|
1438
|
+
const range = await this.commitsToRebase(origHead, excluded, !!rebaseMerges);
|
|
850
1439
|
// only merges since upstream (dropped without --rebase-merges): git's todo is a `noop`,
|
|
851
|
-
// and the branch still moves to upstream
|
|
852
|
-
if (range.length === 0) return moveToOnto(RebaseStatus.OK);
|
|
1440
|
+
// and the branch still moves to upstream (an interactive rebase shows that `noop`)
|
|
1441
|
+
if (range.length === 0 && !interactive) return moveToOnto(RebaseStatus.OK);
|
|
853
1442
|
// commits whose change upstream has already (`--cherry-mark`): left out, with git's
|
|
854
1443
|
// warnings (`make_script`), unless --reapply-cherry-picks
|
|
855
|
-
const skipped =
|
|
856
|
-
|
|
857
|
-
|
|
1444
|
+
const skipped =
|
|
1445
|
+
(this.reapplyCherryPicks ?? this.keepBase)
|
|
1446
|
+
? new Set<ObjectId>()
|
|
1447
|
+
: await this.appliedUpstream(origHead, base, range, restrict);
|
|
858
1448
|
const ids = range.filter((id) => !skipped.has(id));
|
|
859
1449
|
if (skipped.size > 0) {
|
|
860
1450
|
for (const id of range) {
|
|
@@ -866,7 +1456,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
866
1456
|
if (configBool(this.workingCopy, "advice.skippedCherryPicks", true)) {
|
|
867
1457
|
output.push(
|
|
868
1458
|
"hint: use --reapply-cherry-picks to include skipped commits",
|
|
869
|
-
'
|
|
1459
|
+
// 2.43's advice: `git config <key> false`
|
|
1460
|
+
`hint: Disable this message with "git config${(this.compatibility ?? this.hooks.compatibility) === "2.43" ? "" : " set"} advice.skippedCherryPicks false"`,
|
|
870
1461
|
);
|
|
871
1462
|
}
|
|
872
1463
|
}
|
|
@@ -875,8 +1466,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
875
1466
|
let script = "";
|
|
876
1467
|
if (rebaseMerges) {
|
|
877
1468
|
script = await this.makeScriptWithMerges(
|
|
878
|
-
|
|
879
|
-
|
|
1469
|
+
origHead,
|
|
1470
|
+
base,
|
|
880
1471
|
range,
|
|
881
1472
|
skipped,
|
|
882
1473
|
rebaseCousins,
|
|
@@ -899,12 +1490,26 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
899
1490
|
// init_basic_state / write_basic_state
|
|
900
1491
|
await state.write(`${DIR}/head-name`, `${headName}\n`);
|
|
901
1492
|
await state.write(`${DIR}/onto`, `${onto}\n`);
|
|
902
|
-
await state.write(`${DIR}/orig-head`, `${
|
|
1493
|
+
await state.write(`${DIR}/orig-head`, `${origHead}\n`);
|
|
1494
|
+
// write_basic_state: strategy, strategy_opts
|
|
1495
|
+
const strategyName = this.givenStrategyName();
|
|
1496
|
+
if (strategyName) await state.write(`${DIR}/strategy`, `${strategyName}\n`);
|
|
1497
|
+
const xopts = this.givenStrategyOptions();
|
|
1498
|
+
if (xopts.length > 0) {
|
|
1499
|
+
await state.write(`${DIR}/strategy_opts`, `${quoteStrategyOptions(xopts)}\n`);
|
|
1500
|
+
}
|
|
1501
|
+
// write_basic_state: gpg_sign_opt (`-S<key>`) when the run signs
|
|
1502
|
+
const sign = signRequestOf(this.workingCopy, this.sign);
|
|
1503
|
+
this.runSign = { key: sign };
|
|
1504
|
+
if (sign !== undefined) await state.write(`${DIR}/gpg_sign_opt`, `-S${sign}\n`);
|
|
903
1505
|
if (this.signoff) await state.write(`${DIR}/signoff`, "--signoff\n");
|
|
904
1506
|
if (emptyMode === "drop") await state.write(`${DIR}/drop_redundant_commits`, "");
|
|
905
1507
|
if (emptyMode === "keep") await state.write(`${DIR}/keep_redundant_commits`, "");
|
|
906
1508
|
if (this.committerDateIsAuthorDate) await state.write(`${DIR}/cdate_is_adate`, "");
|
|
907
1509
|
if (this.ignoreDate) await state.write(`${DIR}/ignore_date`, "");
|
|
1510
|
+
if (this.trailerArgs.length > 0) {
|
|
1511
|
+
await state.write(`${DIR}/trailer`, this.trailerArgs.map((t) => `${t}\n`).join(""));
|
|
1512
|
+
}
|
|
908
1513
|
await state.write(
|
|
909
1514
|
`${DIR}/${reschedule ? "reschedule-failed-exec" : "no-reschedule-failed-exec"}`,
|
|
910
1515
|
"",
|
|
@@ -946,8 +1551,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
946
1551
|
comment,
|
|
947
1552
|
{
|
|
948
1553
|
shortRevisions: this.root
|
|
949
|
-
? await this.abbreviateObjectId(
|
|
950
|
-
: `${
|
|
1554
|
+
? await this.abbreviateObjectId(origHead)
|
|
1555
|
+
: `${await this.abbreviateObjectId(base)}..${await this.abbreviateObjectId(origHead)}`,
|
|
951
1556
|
shortOnto,
|
|
952
1557
|
},
|
|
953
1558
|
missingCheck === "error",
|
|
@@ -984,7 +1589,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
984
1589
|
targetTree: ontoTreeId,
|
|
985
1590
|
});
|
|
986
1591
|
if (!refused) {
|
|
987
|
-
await state.setRef("ORIG_HEAD",
|
|
1592
|
+
await state.setRef("ORIG_HEAD", origHead);
|
|
988
1593
|
await this.refsStore.set("HEAD", onto, this.startLog());
|
|
989
1594
|
}
|
|
990
1595
|
return { status: RebaseStatus.FAILED, message: lines.join("\n"), output };
|
|
@@ -1059,7 +1664,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1059
1664
|
start,
|
|
1060
1665
|
this.startLog(),
|
|
1061
1666
|
"rebase: updating ORIG_HEAD",
|
|
1062
|
-
{ detach: true },
|
|
1667
|
+
{ detach: true, origHead },
|
|
1063
1668
|
)),
|
|
1064
1669
|
);
|
|
1065
1670
|
// checkout_onto's post-checkout hook: the HEAD left, the commit the picks start from
|
|
@@ -1248,13 +1853,30 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1248
1853
|
if (!conflicts) {
|
|
1249
1854
|
lines.push(`Stopped at ${await this.abbreviateObjectId(item.id)}... ${rest}`);
|
|
1250
1855
|
}
|
|
1856
|
+
// error_with_patch: 2.5x writes the picked message as it is (have_message), 2.43 and a
|
|
1857
|
+
// fast-forwarded pick leave it to make_patch (the commit's, a line end added)
|
|
1858
|
+
const picked =
|
|
1859
|
+
outcome.kind === "ok" && (this.compatibility ?? this.hooks.compatibility) !== "2.43"
|
|
1860
|
+
? outcome.message
|
|
1861
|
+
: undefined;
|
|
1251
1862
|
lines.push(
|
|
1252
1863
|
...(await this.errorWithPatch(state, item.id, rest, {
|
|
1253
1864
|
exitCode: conflicts ? 1 : 0,
|
|
1254
1865
|
toAmend: outcome.kind === "ok",
|
|
1255
|
-
...(conflicts
|
|
1256
|
-
|
|
1257
|
-
|
|
1866
|
+
...(conflicts
|
|
1867
|
+
? { message: outcome.message }
|
|
1868
|
+
: picked !== undefined
|
|
1869
|
+
? { message: picked }
|
|
1870
|
+
: {}),
|
|
1871
|
+
// the picked message (do_pick_commit's, --signoff's and --trailer's trailers
|
|
1872
|
+
// added); a fast-forwarded pick (possible with --trailer after --continue) has
|
|
1873
|
+
// none, and make_patch writes the commit's own
|
|
1874
|
+
picked:
|
|
1875
|
+
!conflicts &&
|
|
1876
|
+
((await state.exists(`${DIR}/signoff`)) ||
|
|
1877
|
+
(outcome.kind === "ok" &&
|
|
1878
|
+
outcome.message !== undefined &&
|
|
1879
|
+
(await state.exists(`${DIR}/trailer`)))),
|
|
1258
1880
|
})),
|
|
1259
1881
|
);
|
|
1260
1882
|
return {
|
|
@@ -1284,7 +1906,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1284
1906
|
conflicts: outcome.conflicts,
|
|
1285
1907
|
message: [
|
|
1286
1908
|
...outcome.lines,
|
|
1287
|
-
...(await this.errorWithPatch(state, item.id, rest, {
|
|
1909
|
+
...(await this.errorWithPatch(state, item.id, rest, {
|
|
1910
|
+
exitCode: 1,
|
|
1911
|
+
toAmend: outcome.toAmend ?? true,
|
|
1912
|
+
})),
|
|
1288
1913
|
].join("\n"),
|
|
1289
1914
|
};
|
|
1290
1915
|
}
|
|
@@ -1319,7 +1944,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1319
1944
|
state: OperationState,
|
|
1320
1945
|
id: ObjectId,
|
|
1321
1946
|
rest: string,
|
|
1322
|
-
options: { exitCode: number; toAmend: boolean; message?: string;
|
|
1947
|
+
options: { exitCode: number; toAmend: boolean; message?: string; picked?: boolean },
|
|
1323
1948
|
): Promise<string[]> {
|
|
1324
1949
|
if (options.message !== undefined && !(await state.exists(`${DIR}/message`))) {
|
|
1325
1950
|
await state.write(`${DIR}/message`, options.message);
|
|
@@ -1333,9 +1958,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1333
1958
|
const body = messageBody(commit?.message ?? "");
|
|
1334
1959
|
await state.write(
|
|
1335
1960
|
`${DIR}/message`,
|
|
1336
|
-
options.
|
|
1337
|
-
? appendSignoff(body, this.signoffLine(), trailerConfigOf(this.workingCopy))
|
|
1338
|
-
: `${body}\n`,
|
|
1961
|
+
options.picked ? await this.pickedMessageOf(state, body) : `${body}\n`,
|
|
1339
1962
|
);
|
|
1340
1963
|
}
|
|
1341
1964
|
if (options.toAmend) {
|
|
@@ -1343,7 +1966,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1343
1966
|
return [
|
|
1344
1967
|
"You can amend the commit now, with",
|
|
1345
1968
|
"",
|
|
1346
|
-
|
|
1969
|
+
` git commit --amend ${await this.gpgSignOptQuoted(state)}`,
|
|
1347
1970
|
"",
|
|
1348
1971
|
"Once you are satisfied with your changes, run",
|
|
1349
1972
|
"",
|
|
@@ -1399,7 +2022,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1399
2022
|
await this.rewordHead(state);
|
|
1400
2023
|
} catch (error) {
|
|
1401
2024
|
// fast_forward_edit's git commit failed: a stop with HEAD to amend
|
|
1402
|
-
return editorFailure(error);
|
|
2025
|
+
return signingFailure(error) ?? editorFailure(error);
|
|
1403
2026
|
}
|
|
1404
2027
|
}
|
|
1405
2028
|
return { kind: "ok" };
|
|
@@ -1413,12 +2036,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1413
2036
|
const parentTreeId = parentId ? await this.commits.getTree(parentId) : undefined;
|
|
1414
2037
|
const subject = subjectOf(commit.message);
|
|
1415
2038
|
// do_pick_commit: the message from its subject on; --signoff appends the committer's
|
|
1416
|
-
// sign-off (not for a fixup or squash), before the merge
|
|
2039
|
+
// sign-off and --trailer its trailers (not for a fixup or squash), before the merge
|
|
2040
|
+
// (MERGE_MSG has them)
|
|
1417
2041
|
const body = messageBody(commit.message);
|
|
1418
|
-
const pickedMessage =
|
|
1419
|
-
signoff && !fixup
|
|
1420
|
-
? appendSignoff(body, this.signoffLine(), trailerConfigOf(this.workingCopy))
|
|
1421
|
-
: body;
|
|
2042
|
+
const pickedMessage = fixup ? body : await this.pickedMessageOf(state, body);
|
|
1422
2043
|
let messageFile: "squash" | "fixup" | "edit" | undefined;
|
|
1423
2044
|
if (fixup) {
|
|
1424
2045
|
await this.updateSquashMessages(state, item, commit.message);
|
|
@@ -1435,34 +2056,48 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1435
2056
|
const short = await this.abbreviateObjectId(item.id);
|
|
1436
2057
|
const label = `${short} (${subject})`;
|
|
1437
2058
|
const baseLabel = parentId ? `parent of ${label}` : "(empty tree)";
|
|
1438
|
-
// the trees as merge-ort reads them: what all three hold alike is never read
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
headTreeId,
|
|
1443
|
-
commit.tree,
|
|
2059
|
+
// the trees as merge-ort reads them: what all three hold alike is never read; `-s`
|
|
2060
|
+
// and `-X` as the sequencer gives them to the pick
|
|
2061
|
+
const { strategy, xopts } = await this.runStrategy(state);
|
|
2062
|
+
const merge = await mergePickChange(
|
|
1444
2063
|
{
|
|
1445
|
-
|
|
1446
|
-
|
|
2064
|
+
...this.context(worktree),
|
|
2065
|
+
commits: this.commits,
|
|
2066
|
+
flats,
|
|
2067
|
+
abbreviate: (id) => this.abbreviateObjectId(id),
|
|
2068
|
+
},
|
|
2069
|
+
{
|
|
2070
|
+
action: "pick",
|
|
2071
|
+
headId,
|
|
2072
|
+
headTreeId,
|
|
2073
|
+
base: parentTreeId,
|
|
2074
|
+
theirs: commit.tree,
|
|
1447
2075
|
baseLabel,
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
2076
|
+
theirsLabel: label,
|
|
2077
|
+
pickId: item.id,
|
|
2078
|
+
parentId,
|
|
2079
|
+
strategy,
|
|
2080
|
+
xopts,
|
|
2081
|
+
oursLabel: "HEAD",
|
|
2082
|
+
favor: this.contentStrategy === ContentMergeStrategy.UNION ? "union" : undefined,
|
|
2083
|
+
compatibility: this.compatibility ?? this.hooks.compatibility ?? "2.56",
|
|
1452
2084
|
},
|
|
1453
|
-
(id) => flats.get(id),
|
|
1454
2085
|
);
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
2086
|
+
if ("failed" in merge) {
|
|
2087
|
+
output.push(...(merge.output ?? []));
|
|
2088
|
+
return {
|
|
2089
|
+
kind: "reschedule",
|
|
2090
|
+
result: { status: RebaseStatus.FAILED, currentCommit: item.id, message: merge.failed },
|
|
2091
|
+
};
|
|
2092
|
+
}
|
|
2093
|
+
const { treeId, conflicts } = merge;
|
|
1459
2094
|
// only the paths HEAD and the result differ on are switched
|
|
1460
|
-
const delta = await treeDelta(this.trees, headTreeId, treeId);
|
|
2095
|
+
const delta = merge.delta ?? (await treeDelta(this.trees, headTreeId, treeId));
|
|
1461
2096
|
const refused = await switchTrees(this.context(worktree), delta.from, delta.to, {
|
|
1462
2097
|
action: "merge",
|
|
1463
2098
|
operation: "rebase",
|
|
1464
2099
|
conflicts,
|
|
1465
|
-
targetTree: treeId,
|
|
2100
|
+
...(merge.delta ? {} : { targetTree: treeId }),
|
|
1466
2101
|
});
|
|
1467
2102
|
if (refused) {
|
|
1468
2103
|
// nothing written: the pick is rescheduled (git keeps the author and REBASE_HEAD)
|
|
@@ -1477,13 +2112,18 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1477
2112
|
},
|
|
1478
2113
|
};
|
|
1479
2114
|
}
|
|
1480
|
-
// the sequencer shows merge-ort's messages of a rebase only when the pick conflicts
|
|
1481
|
-
|
|
1482
|
-
|
|
2115
|
+
// the sequencer shows merge-ort's messages of a rebase only when the pick conflicts (an
|
|
2116
|
+
// external strategy prints its own)
|
|
2117
|
+
if (merge.external || conflicts.length > 0 || !merge.clean) output.push(...merge.messages);
|
|
2118
|
+
if (merge.autoMerge) await state.setRef("AUTO_MERGE", treeId);
|
|
1483
2119
|
const merged = pickedMessage.endsWith("\n") ? pickedMessage : `${pickedMessage}\n`;
|
|
1484
2120
|
if (conflicts.length > 0 || !merge.clean) {
|
|
1485
2121
|
const paths = [...new Set(conflicts.map((c) => c.stagePath))].sort(compareGitPaths);
|
|
1486
|
-
|
|
2122
|
+
// do_recursive_merge adds the conflicts hint; another strategy's MERGE_MSG has none
|
|
2123
|
+
await state.write(
|
|
2124
|
+
"MERGE_MSG",
|
|
2125
|
+
merge.external ? merged : `${merged}${conflictsComment(paths, true)}`,
|
|
2126
|
+
);
|
|
1487
2127
|
if (!fixup) {
|
|
1488
2128
|
// do_pick_commit writes CHERRY_PICK_HEAD after a conflicted merge too; the rebase
|
|
1489
2129
|
// stopping there deletes it again (REBASE_HEAD names the commit instead)
|
|
@@ -1491,16 +2131,14 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1491
2131
|
}
|
|
1492
2132
|
return {
|
|
1493
2133
|
kind: "conflicts",
|
|
1494
|
-
conflicts: [...new Set(merge.
|
|
1495
|
-
// git 2.43 writes the message and a blank line (2.5x the conflict list after it
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
'hint: To abort and get back to the state before "git rebase", run "git rebase --abort".',
|
|
1503
|
-
],
|
|
2134
|
+
conflicts: [...new Set(merge.conflictPaths)].sort(),
|
|
2135
|
+
// git 2.43 writes the message and a blank line (2.5x the conflict list after it, which
|
|
2136
|
+
// another strategy than merge-ort does not add)
|
|
2137
|
+
message:
|
|
2138
|
+
!merge.external || (this.compatibility ?? this.hooks.compatibility) === "2.43"
|
|
2139
|
+
? `${merged}\n`
|
|
2140
|
+
: merged,
|
|
2141
|
+
lines: [`error: could not apply ${short}... ${subject}`, ...this.mergeConflictAdvice()],
|
|
1504
2142
|
};
|
|
1505
2143
|
}
|
|
1506
2144
|
await state.write("MERGE_MSG", pickedMessage);
|
|
@@ -1563,7 +2201,24 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1563
2201
|
)) ?? "";
|
|
1564
2202
|
if (signoff) message = stripspace(message);
|
|
1565
2203
|
}
|
|
1566
|
-
|
|
2204
|
+
try {
|
|
2205
|
+
await this.amendHead(state, treeId, message, item.action, messageFile === "edit");
|
|
2206
|
+
} catch (error) {
|
|
2207
|
+
if (!(error instanceof SigningFailedError)) throw error;
|
|
2208
|
+
// the end of a chain with a squash is git commit's (it dies), the rest try_to_commit's
|
|
2209
|
+
// (an error); then error_failed_squash, 2.43 rescheduling an in-process amend
|
|
2210
|
+
if (messageFile === "edit") {
|
|
2211
|
+
// git commit died before its cleanup: AUTO_MERGE stays
|
|
2212
|
+
await state.setRef("AUTO_MERGE", treeId);
|
|
2213
|
+
return {
|
|
2214
|
+
kind: "conflicts",
|
|
2215
|
+
conflicts: [],
|
|
2216
|
+
lines: [error.message, "fatal: failed to write commit object"],
|
|
2217
|
+
toAmend: this.hooks.compatibility !== "2.43",
|
|
2218
|
+
};
|
|
2219
|
+
}
|
|
2220
|
+
return this.signingStop(item, [error.message, "error: failed to write commit object"]);
|
|
2221
|
+
}
|
|
1567
2222
|
// try_to_commit removes MERGE_MSG; git commit (the edited end of a chain) SQUASH_MSG too
|
|
1568
2223
|
await state.remove("MERGE_MSG");
|
|
1569
2224
|
if (messageFile === "edit") await state.remove("SQUASH_MSG");
|
|
@@ -1589,22 +2244,40 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1589
2244
|
const message = signoff ? stripspace(pickedMessage) : pickedMessage;
|
|
1590
2245
|
// do_pick_commit writes CHERRY_PICK_HEAD for the commit to come; do_commit deletes it
|
|
1591
2246
|
// once try_to_commit made it
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
2247
|
+
try {
|
|
2248
|
+
await state.withRefDuring("CHERRY_PICK_HEAD", item.id, () =>
|
|
2249
|
+
this.commitOnto(
|
|
2250
|
+
state,
|
|
2251
|
+
unborn ? [] : [headId],
|
|
2252
|
+
treeId,
|
|
2253
|
+
commit.author,
|
|
2254
|
+
message,
|
|
2255
|
+
item.action,
|
|
2256
|
+
),
|
|
2257
|
+
);
|
|
2258
|
+
} catch (error) {
|
|
2259
|
+
if (!(error instanceof SigningFailedError)) throw error;
|
|
2260
|
+
// try_to_commit could not sign: 2.43 reschedules the pick, 2.5x stops as after a
|
|
2261
|
+
// conflict, the merged result staged for `--continue` (CHERRY_PICK_HEAD left)
|
|
2262
|
+
await state.setRef("CHERRY_PICK_HEAD", item.id);
|
|
2263
|
+
return this.signingStop(item, [error.message, "error: failed to write commit object"], {
|
|
2264
|
+
message: pickedMessage,
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
1595
2267
|
// do_commit: the commit made, MERGE_MSG removed
|
|
1596
2268
|
await state.remove("MERGE_MSG");
|
|
1597
2269
|
if (item.action === RebaseAction.REWORD) {
|
|
1598
2270
|
try {
|
|
1599
2271
|
await this.rewordHead(state);
|
|
1600
2272
|
} catch (error) {
|
|
1601
|
-
// git commit --amend -e failed (the editor): the pick stays, the
|
|
1602
|
-
|
|
2273
|
+
// git commit --amend -e failed (the editor, the signing): the pick stays, the
|
|
2274
|
+
// rebase stops
|
|
2275
|
+
return { ...(signingFailure(error) ?? editorFailure(error)), message: pickedMessage };
|
|
1603
2276
|
}
|
|
1604
2277
|
}
|
|
1605
2278
|
}
|
|
1606
2279
|
if (finalFixup) await this.endFixupChain(state);
|
|
1607
|
-
return { kind: "ok" };
|
|
2280
|
+
return fixup ? { kind: "ok" } : { kind: "ok", message: pickedMessage };
|
|
1608
2281
|
}
|
|
1609
2282
|
|
|
1610
2283
|
/** do_pick_commit after a final fixup: the chain's files removed. */
|
|
@@ -1747,10 +2420,12 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1747
2420
|
const fixupOff = buf.length;
|
|
1748
2421
|
buf += body.slice(commented);
|
|
1749
2422
|
if (fixupFlag && !seenSquash) {
|
|
1750
|
-
// the message replaced: --signoff's trailer appended
|
|
2423
|
+
// the message replaced: --signoff's and --trailer's trailers appended
|
|
2424
|
+
// (append_squash_message)
|
|
1751
2425
|
if (await state.exists(`${DIR}/signoff`)) {
|
|
1752
|
-
buf = appendSignoff(buf, this.signoffLine(),
|
|
2426
|
+
buf = appendSignoff(buf, this.signoffLine(), this.trailerConfig());
|
|
1753
2427
|
}
|
|
2428
|
+
buf = await this.withTrailers(state, buf);
|
|
1754
2429
|
if (
|
|
1755
2430
|
item.replaceMessage &&
|
|
1756
2431
|
((await state.exists(`${DIR}/message-fixup`)) ||
|
|
@@ -2147,14 +2822,32 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2147
2822
|
// git commit -n -F MERGE_MSG --cleanup=verbatim (whitespace with --signoff, which the
|
|
2148
2823
|
// merge does not get): the merge committed, its state removed
|
|
2149
2824
|
const committed = (await state.exists(`${DIR}/signoff`)) ? stripspace(message) : message;
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
[headId, head.id],
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2825
|
+
let newId: ObjectId;
|
|
2826
|
+
try {
|
|
2827
|
+
newId = await this.commitOnto(state, [headId, head.id], treeId, author, committed, "merge");
|
|
2828
|
+
} catch (error) {
|
|
2829
|
+
if (!(error instanceof SigningFailedError)) throw error;
|
|
2830
|
+
// do_merge's git commit dies signing: the merge stays staged (MERGE_HEAD, MERGE_MSG)
|
|
2831
|
+
// for --continue, the rebase stops as at a conflicting merge (AUTO_MERGE written)
|
|
2832
|
+
await state.setRef("AUTO_MERGE", treeId);
|
|
2833
|
+
await state.write(`${DIR}/message`, message);
|
|
2834
|
+
if (item.id) {
|
|
2835
|
+
await state.write(`${DIR}/stopped-sha`, `${item.id}\n`);
|
|
2836
|
+
await state.setRef("REBASE_HEAD", item.id);
|
|
2837
|
+
await state.write(`${DIR}/patch`, "");
|
|
2838
|
+
}
|
|
2839
|
+
const short = item.id ? await this.abbreviateObjectId(item.id) : "";
|
|
2840
|
+
return {
|
|
2841
|
+
status: RebaseStatus.STOPPED,
|
|
2842
|
+
...(item.id ? { currentCommit: item.id } : {}),
|
|
2843
|
+
conflicts: [],
|
|
2844
|
+
message: [
|
|
2845
|
+
error.message,
|
|
2846
|
+
"fatal: failed to write commit object",
|
|
2847
|
+
item.id ? `Could not apply ${short}... ${arg}` : `Could not merge ${arg}`,
|
|
2848
|
+
].join("\n"),
|
|
2849
|
+
};
|
|
2850
|
+
}
|
|
2158
2851
|
// (git commit removes SQUASH_MSG too; the octopus' git merge leaves it)
|
|
2159
2852
|
await state.remove("MERGE_MSG", "MERGE_HEAD", "MERGE_MODE", "SQUASH_MSG");
|
|
2160
2853
|
await state.removeRef("AUTO_MERGE");
|
|
@@ -2199,6 +2892,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2199
2892
|
.setCommitter(committer);
|
|
2200
2893
|
// `merge -c`: --edit, the message cleaned up as an edited one
|
|
2201
2894
|
if (item.editMessage) command.setCleanupMode(CleanupMode.STRIP);
|
|
2895
|
+
// do_merge passes the run's -S<key> to git merge, else --no-gpg-sign
|
|
2896
|
+
const sign = await this.signRequest(state);
|
|
2897
|
+
if (sign !== undefined) command.setSigningKey(sign);
|
|
2898
|
+
else command.setSign(false);
|
|
2202
2899
|
// the merge inherits pull's GIT_REFLOG_ACTION, not the rebase's own action
|
|
2203
2900
|
if (this.hasReflogAction()) command.setReflogAction(this.reflogAction("rebase"));
|
|
2204
2901
|
for (const head of heads) command.include(head.id);
|
|
@@ -2255,13 +2952,15 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2255
2952
|
tzOffset: commit.author.tzOffset,
|
|
2256
2953
|
};
|
|
2257
2954
|
}
|
|
2258
|
-
const newId = await this.commits.store(
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2955
|
+
const newId = await this.commits.store(
|
|
2956
|
+
await this.signedRebaseCommit(state, {
|
|
2957
|
+
tree: commit.tree,
|
|
2958
|
+
parents: commit.parents,
|
|
2959
|
+
author: commit.author,
|
|
2960
|
+
committer,
|
|
2961
|
+
message,
|
|
2962
|
+
}),
|
|
2963
|
+
);
|
|
2265
2964
|
const action = reflogMessages.rebaseStep(this.reflogAction("rebase"), "merge");
|
|
2266
2965
|
await this.refsStore.set(
|
|
2267
2966
|
"HEAD",
|
|
@@ -2315,12 +3014,86 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2315
3014
|
* options and --signoff imply (`cdate_is_adate`, `ignore_date`, `signoff` in the state).
|
|
2316
3015
|
*/
|
|
2317
3016
|
private async allowFastForward(state: OperationState): Promise<boolean> {
|
|
3017
|
+
// --trailer forces the run that starts the rebase (REBASE_FORCE) but, as in git, is not
|
|
3018
|
+
// read back as a reason to: a --continue may fast-forward again
|
|
3019
|
+
if (this.operation === RebaseOperation.BEGIN && this.trailerArgs.length > 0) return false;
|
|
3020
|
+
// so does --force-rebase (REBASE_FORCE, never saved in the state)
|
|
3021
|
+
if (this.operation === RebaseOperation.BEGIN && this.forceRebase) return false;
|
|
2318
3022
|
for (const name of ["cdate_is_adate", "ignore_date", "signoff"]) {
|
|
2319
3023
|
if (await state.exists(`${DIR}/${name}`)) return false;
|
|
2320
3024
|
}
|
|
2321
3025
|
return true;
|
|
2322
3026
|
}
|
|
2323
3027
|
|
|
3028
|
+
/** The trailer configuration `--trailer` and `--signoff` apply (`trailer.*`). */
|
|
3029
|
+
private trailerConfig(): TrailerConfig {
|
|
3030
|
+
return {
|
|
3031
|
+
...trailerConfigOf(this.workingCopy),
|
|
3032
|
+
compatibility: this.compatibility ?? this.hooks.compatibility,
|
|
3033
|
+
};
|
|
3034
|
+
}
|
|
3035
|
+
|
|
3036
|
+
/**
|
|
3037
|
+
* do_pick_commit's message of a pick: `--signoff`'s trailer, then the `--trailer`s
|
|
3038
|
+
* (amend_strbuf_with_trailers) kept in `rebase-merge/trailer`.
|
|
3039
|
+
*/
|
|
3040
|
+
private async pickedMessageOf(state: OperationState, body: string): Promise<string> {
|
|
3041
|
+
let message = body;
|
|
3042
|
+
if (await state.exists(`${DIR}/signoff`)) {
|
|
3043
|
+
message = appendSignoff(message, this.signoffLine(), this.trailerConfig());
|
|
3044
|
+
}
|
|
3045
|
+
return this.withTrailers(state, message);
|
|
3046
|
+
}
|
|
3047
|
+
|
|
3048
|
+
/** amend_strbuf_with_trailers with the run's `--trailer`s (read_trailers), if any. */
|
|
3049
|
+
private async withTrailers(state: OperationState, message: string): Promise<string> {
|
|
3050
|
+
const args = await this.runTrailers(state);
|
|
3051
|
+
if (args.length === 0) return message;
|
|
3052
|
+
const hooks = this.hooks;
|
|
3053
|
+
const runCommand: TrailerCommandRunner | undefined = hooks.enabled
|
|
3054
|
+
? (command) => hooks.runShellCommand("trailer", command.command, command.args)
|
|
3055
|
+
: undefined;
|
|
3056
|
+
return (await amendWithTrailers(message, args, this.trailerConfig(), runCommand)).output;
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
/** read_trailers: the lines of `rebase-merge/trailer` (none without the file). */
|
|
3060
|
+
private async runTrailers(state: OperationState): Promise<string[]> {
|
|
3061
|
+
const text = await state.read(`${DIR}/trailer`);
|
|
3062
|
+
if (text === undefined) return [];
|
|
3063
|
+
if (text === "") {
|
|
3064
|
+
throw new GitApiError("error: trailers file is empty", { exitCode: 1 });
|
|
3065
|
+
}
|
|
3066
|
+
const lines = text.split("\n");
|
|
3067
|
+
// a last line without its newline is not read (strchr finds none)
|
|
3068
|
+
lines.pop();
|
|
3069
|
+
if (lines.some((l) => l === "")) {
|
|
3070
|
+
throw new GitApiError("error: trailers file contains empty line", { exitCode: 1 });
|
|
3071
|
+
}
|
|
3072
|
+
return lines;
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
/**
|
|
3076
|
+
* print_advice's hints at a conflicting pick (`advice.mergeConflict`, 2.45+: off drops
|
|
3077
|
+
* them, unset adds how to turn them off; 2.43 always gives them as they are).
|
|
3078
|
+
*/
|
|
3079
|
+
private mergeConflictAdvice(): string[] {
|
|
3080
|
+
const hints = [
|
|
3081
|
+
"hint: Resolve all conflicts manually, mark them as resolved with",
|
|
3082
|
+
'hint: "git add/rm <conflicted_files>", then run "git rebase --continue".',
|
|
3083
|
+
'hint: You can instead skip this commit: run "git rebase --skip".',
|
|
3084
|
+
'hint: To abort and get back to the state before "git rebase", run "git rebase --abort".',
|
|
3085
|
+
];
|
|
3086
|
+
if ((this.compatibility ?? this.hooks.compatibility) === "2.43") return hints;
|
|
3087
|
+
const value = configValue(this.workingCopy, "advice.mergeConflict");
|
|
3088
|
+
if (value === undefined) {
|
|
3089
|
+
return [
|
|
3090
|
+
...hints,
|
|
3091
|
+
'hint: Disable this message with "git config set advice.mergeConflict false"',
|
|
3092
|
+
];
|
|
3093
|
+
}
|
|
3094
|
+
return (parseGitBool(value) ?? true) ? hints : [];
|
|
3095
|
+
}
|
|
3096
|
+
|
|
2324
3097
|
/** append_signoff's `Signed-off-by: <committer name> <email>` line. */
|
|
2325
3098
|
private signoffLine(): string {
|
|
2326
3099
|
const committer = this.committer ?? this.resolveCommitter();
|
|
@@ -2624,7 +3397,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2624
3397
|
const treeId = await this.staging.writeTree(this.trees);
|
|
2625
3398
|
const isClean = headCommit?.tree === treeId;
|
|
2626
3399
|
if (!isClean && !(await state.exists(`${DIR}/message`))) {
|
|
2627
|
-
return {
|
|
3400
|
+
return {
|
|
3401
|
+
status: RebaseStatus.FAILED,
|
|
3402
|
+
message: stagedChangesAdvice(await this.gpgSignOptQuoted(state)),
|
|
3403
|
+
};
|
|
2628
3404
|
}
|
|
2629
3405
|
let amend = false;
|
|
2630
3406
|
let finalFixup = false;
|
|
@@ -2737,6 +3513,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2737
3513
|
}
|
|
2738
3514
|
}
|
|
2739
3515
|
} catch (error) {
|
|
3516
|
+
if (error instanceof SigningFailedError) return commitStagedSigningFailure(error);
|
|
2740
3517
|
// git commit failed on its editor: nothing committed, the stop stays as it is
|
|
2741
3518
|
return {
|
|
2742
3519
|
status: RebaseStatus.FAILED,
|
|
@@ -2747,8 +3524,14 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2747
3524
|
}
|
|
2748
3525
|
if (gitCommit) {
|
|
2749
3526
|
// committed above, with git commit's hooks
|
|
2750
|
-
} else if (amend)
|
|
2751
|
-
|
|
3527
|
+
} else if (amend) {
|
|
3528
|
+
try {
|
|
3529
|
+
await this.amendHead(state, treeId, message, "continue", true);
|
|
3530
|
+
} catch (error) {
|
|
3531
|
+
if (error instanceof SigningFailedError) return commitStagedSigningFailure(error);
|
|
3532
|
+
throw error;
|
|
3533
|
+
}
|
|
3534
|
+
} else {
|
|
2752
3535
|
// a stopped merge: its other parents (git commit reads MERGE_HEAD, one per line: an
|
|
2753
3536
|
// octopus has several)
|
|
2754
3537
|
const mergeHeads = ((await state.read("MERGE_HEAD")) ?? "")
|
|
@@ -2757,7 +3540,12 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2757
3540
|
.filter((line) => /^[0-9a-f]{40,64}$/.test(line));
|
|
2758
3541
|
const author =
|
|
2759
3542
|
parseAuthorScript((await state.read(`${DIR}/author-script`)) ?? "") ?? this.resolveAuthor();
|
|
2760
|
-
|
|
3543
|
+
try {
|
|
3544
|
+
await this.commitOnto(state, [headId, ...mergeHeads], treeId, author, message, "continue");
|
|
3545
|
+
} catch (error) {
|
|
3546
|
+
if (error instanceof SigningFailedError) return commitStagedSigningFailure(error);
|
|
3547
|
+
throw error;
|
|
3548
|
+
}
|
|
2761
3549
|
}
|
|
2762
3550
|
// git commit's cleanup (SQUASH_MSG of a final squash too), then commit_staged_changes'
|
|
2763
3551
|
await state.remove(`${DIR}/amend`, "MERGE_HEAD", "MERGE_MODE", "MERGE_MSG", "SQUASH_MSG");
|
|
@@ -2786,6 +3574,63 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2786
3574
|
return this.resume(state, worktree);
|
|
2787
3575
|
}
|
|
2788
3576
|
|
|
3577
|
+
/**
|
|
3578
|
+
* `git rebase --quit` and `--show-current-patch` (builtin/rebase.c's ACTION_QUIT and
|
|
3579
|
+
* ACTION_SHOW_CURRENT_PATCH): the backend found as cmd_rebase finds it (`rebase-apply/`
|
|
3580
|
+
* first, `rebase-apply/applying` being git am's), refused when no rebase is in progress.
|
|
3581
|
+
*/
|
|
3582
|
+
private async quitOrShow(
|
|
3583
|
+
state: OperationState,
|
|
3584
|
+
worktree: Worktree | undefined,
|
|
3585
|
+
operation: RebaseOperation,
|
|
3586
|
+
): Promise<RebaseResult> {
|
|
3587
|
+
const APPLY_DIR = "rebase-apply";
|
|
3588
|
+
if (await state.exists(`${APPLY_DIR}/applying`)) {
|
|
3589
|
+
return {
|
|
3590
|
+
status: RebaseStatus.FAILED,
|
|
3591
|
+
message: "fatal: It looks like 'git am' is in progress. Cannot rebase.",
|
|
3592
|
+
};
|
|
3593
|
+
}
|
|
3594
|
+
const apply = await state.exists(APPLY_DIR);
|
|
3595
|
+
if (!apply && !(await state.exists(DIR))) {
|
|
3596
|
+
const legacy = (this.compatibility ?? this.hooks.compatibility) === "2.43";
|
|
3597
|
+
return {
|
|
3598
|
+
status: RebaseStatus.FAILED,
|
|
3599
|
+
message: legacy ? "fatal: No rebase in progress?" : "fatal: no rebase in progress",
|
|
3600
|
+
};
|
|
3601
|
+
}
|
|
3602
|
+
const stateDir = apply ? APPLY_DIR : DIR;
|
|
3603
|
+
if (operation === RebaseOperation.SHOW_CURRENT_PATCH) {
|
|
3604
|
+
if (apply) {
|
|
3605
|
+
// run_am: `git am --show-current-patch` (its rebasing session shows the original
|
|
3606
|
+
// commit, `git show <original-commit>`)
|
|
3607
|
+
const am = await new AmCommand(this.workingCopy).setShowCurrentPatch("raw").call();
|
|
3608
|
+
if (am.exitCode !== 0) {
|
|
3609
|
+
return { status: RebaseStatus.FAILED, message: am.errors.replace(/\n$/, "") };
|
|
3610
|
+
}
|
|
3611
|
+
return { status: RebaseStatus.OK, currentPatch: am.output };
|
|
3612
|
+
}
|
|
3613
|
+
// run_sequencer_rebase: `git show REBASE_HEAD --` (its failure is rebase's exit 1)
|
|
3614
|
+
const id = await state.ref("REBASE_HEAD");
|
|
3615
|
+
if (!id) return { status: RebaseStatus.FAILED, message: "fatal: bad revision 'REBASE_HEAD'" };
|
|
3616
|
+
return { status: RebaseStatus.OK, currentPatch: await showCommit(this.workingCopy, id) };
|
|
3617
|
+
}
|
|
3618
|
+
// ACTION_QUIT: save_autostash (kept on refs/stash), then sequencer_remove_state for the
|
|
3619
|
+
// merge backend (refs-to-delete deleted, the directory removed) or the directory alone;
|
|
3620
|
+
// REBASE_HEAD, AUTO_MERGE, ORIG_HEAD, MERGE_MSG and HEAD stay as they are
|
|
3621
|
+
const output: string[] = [];
|
|
3622
|
+
const autostash = (await state.read(`${stateDir}/autostash`))?.trim();
|
|
3623
|
+
if (autostash) {
|
|
3624
|
+
await saveAutostash(this.context(worktree), autostash);
|
|
3625
|
+
await state.remove(`${stateDir}/autostash`);
|
|
3626
|
+
output.push(...AUTOSTASH_SAVED_LINES);
|
|
3627
|
+
}
|
|
3628
|
+
if (!apply) await this.deleteRewrittenRefs(state);
|
|
3629
|
+
await state.remove(stateDir);
|
|
3630
|
+
const head = (await this.refsStore.resolve("HEAD").catch(() => undefined))?.objectId;
|
|
3631
|
+
return { status: RebaseStatus.OK, ...(head ? { newHead: head } : {}), output };
|
|
3632
|
+
}
|
|
3633
|
+
|
|
2789
3634
|
/** `git rebase --abort`: back to the original branch and commit (`reset --hard`). */
|
|
2790
3635
|
private async abort(
|
|
2791
3636
|
state: OperationState,
|
|
@@ -2916,13 +3761,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2916
3761
|
commentPrefixOf(this.workingCopy),
|
|
2917
3762
|
)
|
|
2918
3763
|
: await sequencerPrepareMessage(this.hooks, state, message);
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
parents,
|
|
2922
|
-
|
|
2923
|
-
committer,
|
|
2924
|
-
message: hooked,
|
|
2925
|
-
});
|
|
3764
|
+
// commit_tree signs: when it cannot, git's failure (each step says what follows)
|
|
3765
|
+
const id = await this.commits.store(
|
|
3766
|
+
await this.signedRebaseCommit(state, { tree, parents, author, committer, message: hooked }),
|
|
3767
|
+
);
|
|
2926
3768
|
const action = reflogMessages.rebaseStep(this.reflogAction("rebase"), step);
|
|
2927
3769
|
const log = this.reflogLine(reflogMessages.pick(action, hooked), this.committer);
|
|
2928
3770
|
const refs = this.refsStore;
|
|
@@ -2967,7 +3809,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2967
3809
|
|
|
2968
3810
|
/** HEAD detached at upstream: `rebase (start): checkout <upstream as given>`. */
|
|
2969
3811
|
private startLog(): RefLogOptions {
|
|
2970
|
-
const onto = this.upstreamCommitName ?? this.upstreamCommit ?? "";
|
|
3812
|
+
const onto = this.runOntoName ?? this.upstreamCommitName ?? this.upstreamCommit ?? "";
|
|
2971
3813
|
return this.reflogLine(
|
|
2972
3814
|
reflogMessages.rebaseStart(this.reflogAction("rebase"), onto),
|
|
2973
3815
|
this.committer,
|
|
@@ -3773,11 +4615,11 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3773
4615
|
*/
|
|
3774
4616
|
private async commitsToRebase(
|
|
3775
4617
|
head: ObjectId,
|
|
3776
|
-
|
|
4618
|
+
excluded: ObjectId[],
|
|
3777
4619
|
keepMerges = false,
|
|
3778
4620
|
): Promise<ObjectId[]> {
|
|
3779
4621
|
const upstreamCommits = new Set<ObjectId>();
|
|
3780
|
-
const walk = [
|
|
4622
|
+
const walk = [...excluded];
|
|
3781
4623
|
while (walk.length > 0) {
|
|
3782
4624
|
const id = walk.pop() as ObjectId;
|
|
3783
4625
|
if (upstreamCommits.has(id)) continue;
|
|
@@ -3833,9 +4675,11 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3833
4675
|
head: ObjectId,
|
|
3834
4676
|
upstream: ObjectId,
|
|
3835
4677
|
range: ObjectId[],
|
|
4678
|
+
/** The fork point (`^<fork point>`), which limits upstream's side too */
|
|
4679
|
+
restrict?: ObjectId,
|
|
3836
4680
|
): Promise<Set<ObjectId>> {
|
|
3837
4681
|
const skipped = new Set<ObjectId>();
|
|
3838
|
-
const left = await this.onlyReachableFrom(upstream, head);
|
|
4682
|
+
const left = await this.onlyReachableFrom(upstream, restrict ? [head, restrict] : [head]);
|
|
3839
4683
|
if (left.length === 0 || range.length === 0) return skipped;
|
|
3840
4684
|
// each tree read once: a commit's tree is its child's parent tree
|
|
3841
4685
|
const treeEntries = new Map<ObjectId, TreeEntry[]>();
|
|
@@ -3851,41 +4695,27 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3851
4695
|
},
|
|
3852
4696
|
};
|
|
3853
4697
|
const loadTree = (id: ObjectId) => this.trees.loadTree(id);
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
const
|
|
3872
|
-
for (const id of range) {
|
|
3873
|
-
const header = await patchIdOf(id, true);
|
|
3874
|
-
if (!header) continue;
|
|
3875
|
-
const list = byHeader.get(header) ?? [];
|
|
3876
|
-
list.push(id);
|
|
3877
|
-
byHeader.set(header, list);
|
|
3878
|
-
}
|
|
3879
|
-
if (byHeader.size === 0) return skipped;
|
|
4698
|
+
// HEAD's side added, upstream's looked up (patch-ids.c)
|
|
4699
|
+
const ids = new PatchIds<ObjectId>({
|
|
4700
|
+
trees,
|
|
4701
|
+
blobs: this.blobs,
|
|
4702
|
+
objectFormat: this.objectFormat,
|
|
4703
|
+
change: async (id) => {
|
|
4704
|
+
const commit = await this.loadCommit(id);
|
|
4705
|
+
if (!commit || commit.parents.length > 1) return undefined;
|
|
4706
|
+
const parentTree = commit.parents[0]
|
|
4707
|
+
? (await this.loadCommit(commit.parents[0]))?.tree
|
|
4708
|
+
: undefined;
|
|
4709
|
+
return { ...(parentTree ? { parentTree } : {}), tree: commit.tree };
|
|
4710
|
+
},
|
|
4711
|
+
});
|
|
4712
|
+
let added = 0;
|
|
4713
|
+
for (const id of range) if (await ids.add(id)) added++;
|
|
4714
|
+
if (added === 0) return skipped;
|
|
4715
|
+
const empty = this.objectFormat.nullId;
|
|
3880
4716
|
for (const id of left) {
|
|
3881
|
-
|
|
3882
|
-
const
|
|
3883
|
-
if (!candidates) continue;
|
|
3884
|
-
const mine = await fullOf(id);
|
|
3885
|
-
if (!mine) continue;
|
|
3886
|
-
for (const c of candidates) {
|
|
3887
|
-
if (!skipped.has(c) && (await fullOf(c)) === mine) skipped.add(c);
|
|
3888
|
-
}
|
|
4717
|
+
// make_script never skips a commit empty from the start
|
|
4718
|
+
for (const c of await ids.matches(id)) if ((await ids.fullId(c)) !== empty) skipped.add(c);
|
|
3889
4719
|
}
|
|
3890
4720
|
return skipped;
|
|
3891
4721
|
}
|
|
@@ -3896,7 +4726,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3896
4726
|
* what `other` reaches painted uninteresting, done once every commit still queued is
|
|
3897
4727
|
* uninteresting (and a few more, git's slop against clock skew).
|
|
3898
4728
|
*/
|
|
3899
|
-
private async onlyReachableFrom(tip: ObjectId,
|
|
4729
|
+
private async onlyReachableFrom(tip: ObjectId, others: ObjectId[]): Promise<ObjectId[]> {
|
|
3900
4730
|
interface Node {
|
|
3901
4731
|
id: ObjectId;
|
|
3902
4732
|
time: number;
|
|
@@ -3938,7 +4768,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3938
4768
|
}
|
|
3939
4769
|
}
|
|
3940
4770
|
};
|
|
3941
|
-
await push(other, true);
|
|
4771
|
+
for (const other of others) await push(other, true);
|
|
3942
4772
|
await push(tip, false);
|
|
3943
4773
|
const out: Node[] = [];
|
|
3944
4774
|
let slop = 5;
|
|
@@ -3968,13 +4798,63 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3968
4798
|
}
|
|
3969
4799
|
|
|
3970
4800
|
/**
|
|
3971
|
-
* builtin/rebase.c's
|
|
3972
|
-
*
|
|
3973
|
-
*
|
|
3974
|
-
|
|
4801
|
+
* builtin/rebase.c's checkout_up_to_date: the `<branch>` argument checked out when there
|
|
4802
|
+
* is nothing to rebase (reset_working_tree: the worktree switched from HEAD, the branch
|
|
4803
|
+
* and HEAD logged `rebase: checkout <branch>`, the post-checkout hook run).
|
|
4804
|
+
*/
|
|
4805
|
+
private async checkoutUpToDate(
|
|
4806
|
+
worktree: Worktree | undefined,
|
|
4807
|
+
headId: ObjectId,
|
|
4808
|
+
origHead: ObjectId,
|
|
4809
|
+
headName: string,
|
|
4810
|
+
): Promise<RebaseResult | undefined> {
|
|
4811
|
+
const branch = this.branchArg as string;
|
|
4812
|
+
const headTree = await flatTree(this.trees, await this.commits.getTree(headId));
|
|
4813
|
+
const targetTreeId = await this.commits.getTree(origHead);
|
|
4814
|
+
const targetTree = await flatTree(this.trees, targetTreeId);
|
|
4815
|
+
const refused = await switchTrees(this.context(worktree), headTree, targetTree, {
|
|
4816
|
+
action: "checkout",
|
|
4817
|
+
operation: "rebase",
|
|
4818
|
+
targetTree: targetTreeId,
|
|
4819
|
+
});
|
|
4820
|
+
if (refused) {
|
|
4821
|
+
return {
|
|
4822
|
+
status: RebaseStatus.FAILED,
|
|
4823
|
+
message: `${refused.message}\nerror: could not switch to ${branch}`,
|
|
4824
|
+
};
|
|
4825
|
+
}
|
|
4826
|
+
const log = this.reflogLine(
|
|
4827
|
+
`${this.reflogAction("rebase")}: checkout ${branch}`,
|
|
4828
|
+
this.committer,
|
|
4829
|
+
);
|
|
4830
|
+
if (headName.startsWith("refs/")) {
|
|
4831
|
+
await this.refsStore.set(headName, origHead, log);
|
|
4832
|
+
await this.refsStore.setSymbolic("HEAD", headName, log);
|
|
4833
|
+
} else {
|
|
4834
|
+
await this.refsStore.set("HEAD", origHead, log);
|
|
4835
|
+
}
|
|
4836
|
+
await runPostCheckoutHook(this.hooks, headId, origHead, true);
|
|
4837
|
+
return undefined;
|
|
4838
|
+
}
|
|
4839
|
+
|
|
4840
|
+
/**
|
|
4841
|
+
* builtin/rebase.c's can_fast_forward: the branch's one merge base with onto is onto
|
|
4842
|
+
* (`branchBase`), the fork point (if any) is that base too, the upstream (none with
|
|
4843
|
+
* --root) and the branch have one merge base, onto, and the first-parent line from the
|
|
4844
|
+
* branch down to onto has no merge (is_linear_history).
|
|
3975
4845
|
*/
|
|
3976
|
-
private async canFastForward(
|
|
3977
|
-
|
|
4846
|
+
private async canFastForward(
|
|
4847
|
+
onto: ObjectId,
|
|
4848
|
+
upstream: ObjectId | undefined,
|
|
4849
|
+
restrict: ObjectId | undefined,
|
|
4850
|
+
head: ObjectId,
|
|
4851
|
+
branchBase: ObjectId | undefined,
|
|
4852
|
+
): Promise<boolean> {
|
|
4853
|
+
if (branchBase === undefined || branchBase !== onto) return false;
|
|
4854
|
+
if (restrict !== undefined && restrict !== branchBase) return false;
|
|
4855
|
+
if (upstream === undefined) return false;
|
|
4856
|
+
const bases = await revisionMergeBases(this.commits, upstream, head);
|
|
4857
|
+
if (bases.length !== 1 || bases[0] !== onto) return false;
|
|
3978
4858
|
let id: ObjectId | undefined = head;
|
|
3979
4859
|
while (id !== undefined && id !== onto) {
|
|
3980
4860
|
const parents: ObjectId[] = (await this.loadCommit(id))?.parents ?? [];
|