@statewalker/vcs-commands 0.7.0 → 0.8.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 +38 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +55 -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.map +1 -1
- package/dist/commands/apply/apply-engine.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.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/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/checkout-command.d.ts +19 -3
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/cherry-pick-command.d.ts +59 -0
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +12 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +191 -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/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 +252 -5
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +20 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- 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 +41 -1
- 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 +4 -0
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +35 -0
- 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 +26 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -3
- package/dist/commands/interpret-trailers-command.d.ts +90 -0
- package/dist/commands/interpret-trailers-command.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 +296 -11
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +26 -1
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +133 -5
- 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 +30 -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 +96 -9
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-support.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.d.ts +48 -0
- package/dist/commands/name-rev.d.ts.map +1 -0
- package/dist/commands/notes-command.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 +10 -0
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +160 -9
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/read-tree-command.d.ts +6 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +168 -6
- 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/remote-command.d.ts +138 -29
- package/dist/commands/remote-command.d.ts.map +1 -1
- 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 +2 -3
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +2 -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 +154 -2
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +32 -0
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +32 -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 +84 -4
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +2 -0
- 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/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.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 +375 -0
- package/dist/commands/submodule-commands.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +288 -0
- package/dist/commands/submodule-model.d.ts.map +1 -0
- package/dist/commands/submodule-update-command.d.ts +198 -0
- package/dist/commands/submodule-update-command.d.ts.map +1 -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-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-ISM52N0n.js} +70736 -54492
- 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.map +1 -1
- package/dist/errors/index.js +57 -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/{git-command-BGiOJ8Zk.js → fsck-DLRpbwTj.js} +6230 -71
- package/dist/git-command.d.ts +27 -1
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +267 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/index.js +5 -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/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-output.d.ts +85 -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/index.d.ts +4 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/push-result.d.ts +7 -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-WVlBhVb1.js → results-TB2IJ64h.js} +2168 -403
- 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 +178 -17
- package/src/commands/am/am-command.ts +262 -42
- package/src/commands/am/index.ts +1 -0
- package/src/commands/am/mailsplit.ts +326 -0
- package/src/commands/apply/apply-command.ts +6 -6
- package/src/commands/apply/apply-engine.ts +1 -1
- package/src/commands/apply/apply-parse.ts +7 -8
- package/src/commands/bisect/bisect-command.ts +18 -5
- 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/checkout-command.ts +69 -43
- package/src/commands/cherry-pick-command.ts +143 -0
- package/src/commands/clean-command.ts +34 -3
- package/src/commands/clone-command.ts +2 -1
- package/src/commands/commit-command.ts +782 -64
- 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/diff-color-config.ts +274 -0
- package/src/commands/diff-command.ts +1009 -49
- package/src/commands/fetch-command.ts +142 -8
- 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 +314 -46
- package/src/commands/fsck/fetch-fsck.ts +172 -18
- package/src/commands/gc-command.ts +31 -1
- package/src/commands/git-describe.ts +31 -11
- package/src/commands/git-hooks.ts +81 -0
- 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 +26 -0
- package/src/commands/interpret-trailers-command.ts +256 -0
- package/src/commands/local-transport.ts +109 -10
- package/src/commands/log-command.ts +1246 -210
- package/src/commands/log-graph.ts +123 -26
- package/src/commands/log-output.ts +280 -21
- package/src/commands/ls-remote-command.ts +5 -0
- package/src/commands/mailmap.ts +119 -0
- package/src/commands/merge-base-command.ts +170 -0
- package/src/commands/merge-bases.ts +63 -8
- package/src/commands/merge-command.ts +330 -82
- package/src/commands/merge-support.ts +14 -1
- package/src/commands/mv-command.ts +6 -3
- package/src/commands/name-rev.ts +171 -0
- package/src/commands/notes-command.ts +11 -1
- 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 +26 -7
- package/src/commands/push-command.ts +682 -65
- package/src/commands/read-tree-command.ts +28 -1
- package/src/commands/rebase-command.ts +933 -129
- 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/remote-command.ts +449 -69
- package/src/commands/remote-transport.ts +9 -1
- package/src/commands/reset-command.ts +36 -31
- package/src/commands/restore-command.ts +12 -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 +402 -15
- package/src/commands/revert-command.ts +82 -0
- package/src/commands/revision-range.ts +204 -4
- package/src/commands/revision-resolver.ts +23 -8
- package/src/commands/rm-command.ts +282 -21
- package/src/commands/sequencer-pick.ts +498 -85
- package/src/commands/sequencer-support.ts +20 -2
- package/src/commands/serve-repository.ts +18 -3
- package/src/commands/show-command.ts +490 -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 +5 -2
- 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 +1517 -0
- package/src/commands/submodule-model.ts +930 -0
- package/src/commands/submodule-update-command.ts +1092 -0
- package/src/commands/switch-command.ts +3 -1
- package/src/commands/tag-command.ts +876 -64
- package/src/commands/trailers.ts +837 -100
- package/src/commands/tree-restore.ts +38 -10
- package/src/commands/verify-command.ts +235 -0
- package/src/commands/worktree-add-command.ts +268 -24
- 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 +2 -1
- package/src/errors/ref-errors.ts +23 -0
- package/src/errors/worktree-errors.ts +8 -1
- package/src/git-command.ts +66 -1
- package/src/git.ts +404 -1
- package/src/remote-config/index.ts +2 -0
- package/src/remote-config/remote-config-store.ts +101 -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-output.ts +195 -30
- package/src/results/diff-pickaxe.ts +304 -0
- package/src/results/diff-words.ts +395 -0
- package/src/results/index.ts +4 -0
- package/src/results/push-result.ts +7 -0
- package/src/results/rebase-result.ts +3 -0
- package/src/results/stash-result.ts +7 -0
- 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
|
@@ -13,12 +13,12 @@ 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";
|
|
@@ -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,6 +44,7 @@ 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";
|
|
@@ -89,16 +92,27 @@ import { reflogMessages, updateHeadExpecting } from "./reflog-messages.js";
|
|
|
89
92
|
import { revisionMergeBases } from "./rev-parse-command.js";
|
|
90
93
|
import { expandCommitId } from "./sequencer-pick.js";
|
|
91
94
|
import {
|
|
95
|
+
AUTOSTASH_SAVED_LINES,
|
|
92
96
|
applyAutostash,
|
|
93
97
|
cleanupMessage,
|
|
94
98
|
createAutostash,
|
|
95
99
|
moveHeadAsReset,
|
|
96
100
|
removeBranchState,
|
|
97
101
|
resetMerge,
|
|
102
|
+
saveAutostash,
|
|
98
103
|
} from "./sequencer-support.js";
|
|
99
|
-
import {
|
|
104
|
+
import { showCommit } from "./show-commit.js";
|
|
105
|
+
import { SigningFailedError, type SignRequest, signRequestOf } from "./signing.js";
|
|
106
|
+
import {
|
|
107
|
+
amendWithTrailers,
|
|
108
|
+
appendSignoff,
|
|
109
|
+
type TrailerCommandRunner,
|
|
110
|
+
type TrailerConfig,
|
|
111
|
+
trailerConfigOf,
|
|
112
|
+
validateTrailerArgs,
|
|
113
|
+
} from "./trailers.js";
|
|
100
114
|
import { worktreeModified } from "./worktree-overwrite-checks.js";
|
|
101
|
-
import { usesBranch } from "./worktree-support.js";
|
|
115
|
+
import { refuseIfCheckedOut, usesBranch } from "./worktree-support.js";
|
|
102
116
|
|
|
103
117
|
/**
|
|
104
118
|
* Rebase operation types.
|
|
@@ -116,6 +130,16 @@ export enum RebaseOperation {
|
|
|
116
130
|
PROCESS_STEPS = "process-steps",
|
|
117
131
|
/** `--edit-todo`: the rest of the todo list edited (the interactive handler's editTodo) */
|
|
118
132
|
EDIT_TODO = "edit-todo",
|
|
133
|
+
/**
|
|
134
|
+
* `--quit`: the rebase forgotten (its state directory removed, its autostash kept on
|
|
135
|
+
* `refs/stash`), HEAD, the index and the worktree left as they are
|
|
136
|
+
*/
|
|
137
|
+
QUIT = "quit",
|
|
138
|
+
/**
|
|
139
|
+
* `--show-current-patch`: `git show REBASE_HEAD` (merge backend) or `git am
|
|
140
|
+
* --show-current-patch` (apply backend), in {@link RebaseResult.currentPatch}
|
|
141
|
+
*/
|
|
142
|
+
SHOW_CURRENT_PATCH = "show-current-patch",
|
|
119
143
|
}
|
|
120
144
|
|
|
121
145
|
/**
|
|
@@ -170,7 +194,11 @@ interface UpdateRefRecord {
|
|
|
170
194
|
|
|
171
195
|
/** What a pick (do_pick_commit) did. */
|
|
172
196
|
type PickOutcome =
|
|
173
|
-
| {
|
|
197
|
+
| {
|
|
198
|
+
kind: "ok";
|
|
199
|
+
/** The message picked (do_pick_commit's ctx->message), when the pick was not fast-forwarded */
|
|
200
|
+
message?: string;
|
|
201
|
+
}
|
|
174
202
|
| { kind: "dropped" }
|
|
175
203
|
| {
|
|
176
204
|
kind: "conflicts";
|
|
@@ -179,6 +207,8 @@ type PickOutcome =
|
|
|
179
207
|
conflicts: string[];
|
|
180
208
|
/** What error_with_patch writes to `rebase-merge/message` */
|
|
181
209
|
message?: string;
|
|
210
|
+
/** error_failed_squash's to_amend (default true): 2.43 stops a failed squash unamended */
|
|
211
|
+
toAmend?: boolean;
|
|
182
212
|
}
|
|
183
213
|
| { kind: "reschedule"; result: RebaseResult & { reschedule?: boolean } };
|
|
184
214
|
|
|
@@ -190,19 +220,49 @@ type StepOutcome =
|
|
|
190
220
|
| (Partial<RebaseResult> & { reschedule?: boolean; checkTodo?: boolean })
|
|
191
221
|
| undefined;
|
|
192
222
|
|
|
193
|
-
/** sequencer.c's staged_changes_advice
|
|
194
|
-
|
|
223
|
+
/** sequencer.c's staged_changes_advice, with the run's quoted `-S<key>` (gpg_sign_opt_quoted). */
|
|
224
|
+
function stagedChangesAdvice(gpgSignOpt: string): string {
|
|
225
|
+
return `error: you have staged changes in your working tree
|
|
195
226
|
If these changes are meant to be squashed into the previous commit, run:
|
|
196
227
|
|
|
197
|
-
git commit --amend
|
|
228
|
+
git commit --amend ${gpgSignOpt}
|
|
198
229
|
|
|
199
230
|
If they are meant to go into a new commit, run:
|
|
200
231
|
|
|
201
|
-
git commit
|
|
232
|
+
git commit ${gpgSignOpt}
|
|
202
233
|
|
|
203
234
|
In both cases, once you're done, continue with:
|
|
204
235
|
|
|
205
236
|
git rebase --continue`;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* commit_staged_changes' git commit dying on its signature (not signed yet): gpg's lines,
|
|
241
|
+
* git commit's death, then the sequencer's error; nothing committed, the stop kept.
|
|
242
|
+
*/
|
|
243
|
+
function commitStagedSigningFailure(error: SigningFailedError): RebaseResult {
|
|
244
|
+
return {
|
|
245
|
+
status: RebaseStatus.FAILED,
|
|
246
|
+
message: [
|
|
247
|
+
error.message,
|
|
248
|
+
"fatal: failed to write commit object",
|
|
249
|
+
"error: could not commit staged changes.",
|
|
250
|
+
].join("\n"),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* A reword's `git commit --amend -e` dying on its signature: gpg's lines and git commit's
|
|
256
|
+
* death, the rebase stopped with HEAD to amend; undefined for any other failure.
|
|
257
|
+
*/
|
|
258
|
+
function signingFailure(error: unknown): Extract<PickOutcome, { kind: "conflicts" }> | undefined {
|
|
259
|
+
if (!(error instanceof SigningFailedError)) return undefined;
|
|
260
|
+
return {
|
|
261
|
+
kind: "conflicts",
|
|
262
|
+
conflicts: [],
|
|
263
|
+
lines: [error.message, "fatal: failed to write commit object"],
|
|
264
|
+
};
|
|
265
|
+
}
|
|
206
266
|
|
|
207
267
|
/** rebase-interactive.c's edit_todo_list_advice. */
|
|
208
268
|
const EDIT_TODO_ADVICE = [
|
|
@@ -252,6 +312,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
252
312
|
private contentStrategy?: ContentMergeStrategy;
|
|
253
313
|
private preserveMerges = false;
|
|
254
314
|
private interactiveHandler?: InteractiveHandler;
|
|
315
|
+
/** Whose messages to give where git 2.43 and 2.5x differ (default: the hooks') */
|
|
316
|
+
private compatibility?: "2.43" | "2.56";
|
|
255
317
|
private committer?: PersonIdent;
|
|
256
318
|
/** `--committer-date-is-author-date` (kept in `rebase-merge/cdate_is_adate`) */
|
|
257
319
|
private committerDateIsAuthorDate = false;
|
|
@@ -259,8 +321,24 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
259
321
|
private ignoreDate = false;
|
|
260
322
|
/** `--signoff` (kept in `rebase-merge/signoff`) */
|
|
261
323
|
private signoff = false;
|
|
324
|
+
/** `--force-rebase` (REBASE_FORCE) */
|
|
325
|
+
private forceRebase = false;
|
|
326
|
+
/** `-S[<keyid>]` / `--no-gpg-sign` (undefined: `commit.gpgSign`; kept in `gpg_sign_opt`) */
|
|
327
|
+
private sign?: boolean | string;
|
|
328
|
+
/** What this run signs with (git's opts->gpg_sign), once known */
|
|
329
|
+
private runSign?: { key: SignRequest };
|
|
262
330
|
private autoStash?: boolean;
|
|
263
|
-
private reapplyCherryPicks
|
|
331
|
+
private reapplyCherryPicks?: boolean;
|
|
332
|
+
/** `--onto <newbase>` as given (`A...B` included) */
|
|
333
|
+
private ontoName?: string;
|
|
334
|
+
/** The `<branch>` argument: switched to before the rebase */
|
|
335
|
+
private branchArg?: string;
|
|
336
|
+
/** `--keep-base` */
|
|
337
|
+
private keepBase = false;
|
|
338
|
+
/** `--[no-]fork-point`; undefined: git's default (on for an implicit upstream) */
|
|
339
|
+
private forkPoint?: boolean;
|
|
340
|
+
/** The onto name of the rebase running (git's `onto_name`), for the reflog */
|
|
341
|
+
private runOntoName?: string;
|
|
264
342
|
/** `--rebase-merges` (undefined: `rebase.rebaseMerges`) */
|
|
265
343
|
private rebaseMerges?: boolean;
|
|
266
344
|
/** `--rebase-merges=rebase-cousins` */
|
|
@@ -292,6 +370,24 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
292
370
|
/** `--root`: every commit of the branch rebased (onto the upstream given, else a new root) */
|
|
293
371
|
private root = false;
|
|
294
372
|
private noVerify = false;
|
|
373
|
+
/** `--trailer` arguments (kept in `rebase-merge/trailer`, one per line) */
|
|
374
|
+
private trailerArgs: string[] = [];
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* `--trailer <token>[(=|:)<value>]` (git 2.46+): each rebased commit's message gets the
|
|
378
|
+
* trailer as `git interpret-trailers --no-divider --trailer` adds it (`trailer.*`
|
|
379
|
+
* configuration applies; a fixup or squash none, a `fixup -C` the message it takes). Like
|
|
380
|
+
* git, it implies `--force-rebase` and is kept in `rebase-merge/trailer` for `--continue`;
|
|
381
|
+
* an empty argument or one without a key is refused before anything is done, and under
|
|
382
|
+
* 2.43 compatibility the option itself (`error: unknown option \`trailer'`, exit 129).
|
|
383
|
+
* git's apply backend refuses it (`--trailer requires the merge backend`); ours has only
|
|
384
|
+
* the merge backend.
|
|
385
|
+
*/
|
|
386
|
+
addTrailer(trailer: string): this {
|
|
387
|
+
this.checkCallable();
|
|
388
|
+
this.trailerArgs.push(trailer);
|
|
389
|
+
return this;
|
|
390
|
+
}
|
|
295
391
|
|
|
296
392
|
/** `--no-verify`: the pre-rebase hook does not run. */
|
|
297
393
|
setNoVerify(noVerify: boolean): this {
|
|
@@ -333,18 +429,66 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
333
429
|
* builtin/rebase.c's `lookup_commit_reference_by_name(options.upstream_name)`: the commit
|
|
334
430
|
* an upstream names, or git's "fatal: invalid upstream '<name>'" (exit 128).
|
|
335
431
|
*/
|
|
336
|
-
private async resolveUpstream(name: string): Promise<ObjectId> {
|
|
337
|
-
const fatal = (
|
|
432
|
+
private async resolveUpstream(name: string, shown = name): Promise<ObjectId> {
|
|
433
|
+
const fatal = () => `fatal: invalid upstream '${shown}'`;
|
|
338
434
|
try {
|
|
339
435
|
return await this.resolveRef(name, fatal);
|
|
340
436
|
} catch (error) {
|
|
341
437
|
if (error instanceof RefNotFoundError) {
|
|
342
|
-
throw new RefNotFoundError(name, fatal(
|
|
438
|
+
throw new RefNotFoundError(name, fatal()).withExitCode(128);
|
|
343
439
|
}
|
|
344
440
|
throw error;
|
|
345
441
|
}
|
|
346
442
|
}
|
|
347
443
|
|
|
444
|
+
/**
|
|
445
|
+
* `--onto <newbase>`: the commits of `<upstream>..HEAD` go onto `newbase` instead of onto
|
|
446
|
+
* the upstream. Any revision, or `A...B` for the one merge base of A and B (either side
|
|
447
|
+
* empty is HEAD): git's `fatal: '<A...B>': need exactly one merge base` when there are
|
|
448
|
+
* none or several, `fatal: Does not point to a valid commit '<newbase>'` when it names no
|
|
449
|
+
* commit. With {@link setRoot} it is `--root --onto <newbase>`.
|
|
450
|
+
*/
|
|
451
|
+
setOnto(newbase: string): this {
|
|
452
|
+
this.checkCallable();
|
|
453
|
+
this.ontoName = newbase;
|
|
454
|
+
return this;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* The `<branch>` argument: `git rebase <upstream> <branch>` switches to it first (a local
|
|
459
|
+
* branch, which then moves; or any commit, rebased on a detached HEAD), as
|
|
460
|
+
* `git switch <branch>` would; a branch another worktree has checked out is refused.
|
|
461
|
+
*/
|
|
462
|
+
setBranch(branch: string): this {
|
|
463
|
+
this.checkCallable();
|
|
464
|
+
this.branchArg = branch;
|
|
465
|
+
return this;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* `--keep-base`: onto the merge base of the upstream and the branch (`<upstream>...<branch>`),
|
|
470
|
+
* so the commits stay where they are while the upstream's are left out. Implies
|
|
471
|
+
* `--no-fork-point` and `--reapply-cherry-picks` unless set; refused with `--onto` and
|
|
472
|
+
* `--root`.
|
|
473
|
+
*/
|
|
474
|
+
setKeepBase(keepBase: boolean): this {
|
|
475
|
+
this.checkCallable();
|
|
476
|
+
this.keepBase = keepBase;
|
|
477
|
+
return this;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* `--fork-point` / `--no-fork-point`: leave out the commits the upstream's reflog shows
|
|
482
|
+
* were once on it (git's get_fork_point: the one merge base of the branch and the values
|
|
483
|
+
* the upstream's reflog records, when it is one of them). Default: on when no upstream is
|
|
484
|
+
* given (the branch's `@{upstream}`), unless `rebase.forkPoint` is false; off otherwise.
|
|
485
|
+
*/
|
|
486
|
+
setForkPoint(forkPoint: boolean): this {
|
|
487
|
+
this.checkCallable();
|
|
488
|
+
this.forkPoint = forkPoint;
|
|
489
|
+
return this;
|
|
490
|
+
}
|
|
491
|
+
|
|
348
492
|
/**
|
|
349
493
|
* Set the upstream name for messages.
|
|
350
494
|
*
|
|
@@ -373,6 +517,17 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
373
517
|
*
|
|
374
518
|
* @param operation Rebase operation
|
|
375
519
|
*/
|
|
520
|
+
/**
|
|
521
|
+
* Whose messages to give where git 2.43 and 2.5x differ (`fatal: No rebase in progress?`
|
|
522
|
+
* in 2.43, `fatal: no rebase in progress` in 2.5x). Default: the hook runner's
|
|
523
|
+
* compatibility, else 2.56.
|
|
524
|
+
*/
|
|
525
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
526
|
+
this.checkCallable();
|
|
527
|
+
this.compatibility = version;
|
|
528
|
+
return this;
|
|
529
|
+
}
|
|
530
|
+
|
|
376
531
|
setOperation(operation: RebaseOperation): this {
|
|
377
532
|
this.checkCallable();
|
|
378
533
|
this.operation = operation;
|
|
@@ -533,6 +688,84 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
533
688
|
return this;
|
|
534
689
|
}
|
|
535
690
|
|
|
691
|
+
/**
|
|
692
|
+
* `-S` (true) / `--no-gpg-sign` (false): whether to sign the commits the rebase makes;
|
|
693
|
+
* undefined (the default) leaves it to `commit.gpgSign`. Kept in
|
|
694
|
+
* `rebase-merge/gpg_sign_opt` for `--continue`. Every commit the rebase writes is signed
|
|
695
|
+
* through the host's signer (`GitHostEnvironment.signer`) as git's sequencer signs it; when
|
|
696
|
+
* it cannot be signed the step fails as git's does (`error: gpg failed to sign the data:`,
|
|
697
|
+
* `error: failed to write commit object`) and the rebase stops there (2.5x: `Could not
|
|
698
|
+
* apply ...`, the pick to commit; 2.43: the pick rescheduled), the branch untouched.
|
|
699
|
+
* Picks kept as they are (fast-forwarded) sign nothing, as in git.
|
|
700
|
+
*/
|
|
701
|
+
setSign(sign: boolean | undefined): this {
|
|
702
|
+
this.checkCallable();
|
|
703
|
+
this.sign = sign;
|
|
704
|
+
return this;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/** `-S<keyid>`: sign with this key (see {@link setSign}). */
|
|
708
|
+
setSigningKey(keyId: string): this {
|
|
709
|
+
this.checkCallable();
|
|
710
|
+
this.sign = keyId;
|
|
711
|
+
return this;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* The key this run's commits are signed with: the one it started with, else (a
|
|
716
|
+
* `--continue`) `rebase-merge/gpg_sign_opt` over `commit.gpgSign` (read_populate_opts).
|
|
717
|
+
*/
|
|
718
|
+
private async signRequest(state: OperationState): Promise<SignRequest> {
|
|
719
|
+
if (this.runSign) return this.runSign.key;
|
|
720
|
+
const saved = (await state.read(`${DIR}/gpg_sign_opt`))?.replace(/\n$/, "");
|
|
721
|
+
const key =
|
|
722
|
+
saved?.startsWith("-S") === true
|
|
723
|
+
? saved.slice(2)
|
|
724
|
+
: signRequestOf(this.workingCopy, undefined);
|
|
725
|
+
this.runSign = { key };
|
|
726
|
+
return key;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* commit_tree's signing of a commit the rebase makes, with this run's key (git's
|
|
731
|
+
* opts->gpg_sign), the signing program in the worktree top. When it cannot be signed:
|
|
732
|
+
* {@link SigningFailedError} with gpg's lines alone; the step says what follows.
|
|
733
|
+
*/
|
|
734
|
+
private async signedRebaseCommit(state: OperationState, commit: Commit): Promise<Commit> {
|
|
735
|
+
return this.signedCommit(await this.signRequest(state), commit, []);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/** sequencer.c's gpg_sign_opt_quoted: `'-S<key>'` (shell-quoted) when the run signs, else "". */
|
|
739
|
+
private async gpgSignOptQuoted(state: OperationState): Promise<string> {
|
|
740
|
+
const sign = await this.signRequest(state);
|
|
741
|
+
return sign === undefined
|
|
742
|
+
? ""
|
|
743
|
+
: `'-S${sign.replaceAll("'", "'\\''").replaceAll("!", "'\\!'")}'`;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* try_to_commit failing to sign a pick or a fixup: 2.43 reschedules the command (its
|
|
748
|
+
* `error:` lines, the rescheduled advice), 2.5x stops as after a conflict.
|
|
749
|
+
*/
|
|
750
|
+
private signingStop(
|
|
751
|
+
item: TodoItem,
|
|
752
|
+
lines: string[],
|
|
753
|
+
options: { message?: string } = {},
|
|
754
|
+
): PickOutcome {
|
|
755
|
+
if (this.hooks.compatibility === "2.43") {
|
|
756
|
+
return {
|
|
757
|
+
kind: "reschedule",
|
|
758
|
+
result: {
|
|
759
|
+
status: RebaseStatus.FAILED,
|
|
760
|
+
currentCommit: item.id,
|
|
761
|
+
message: lines.join("\n"),
|
|
762
|
+
reschedule: true,
|
|
763
|
+
},
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
return { kind: "conflicts", conflicts: [], lines, ...options };
|
|
767
|
+
}
|
|
768
|
+
|
|
536
769
|
/**
|
|
537
770
|
* `--exec <command>` (`-x`): an `exec <command>` line after each pick (after its fixup and
|
|
538
771
|
* squash chain) and each merge; implies an interactive list (no fast-forward shortcut) and
|
|
@@ -609,6 +842,18 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
609
842
|
return this;
|
|
610
843
|
}
|
|
611
844
|
|
|
845
|
+
/**
|
|
846
|
+
* `--force-rebase` (`-f`, `--no-ff`): every commit is picked again, even one whose parent is
|
|
847
|
+
* already where the rebase puts it (git's REBASE_FORCE: no allow_ff, no up-to-date
|
|
848
|
+
* shortcut, `Current branch <name> is up to date, rebase forced.`). Like git, a `--continue`
|
|
849
|
+
* does not remember it.
|
|
850
|
+
*/
|
|
851
|
+
setForceRebase(value: boolean): this {
|
|
852
|
+
this.checkCallable();
|
|
853
|
+
this.forceRebase = value;
|
|
854
|
+
return this;
|
|
855
|
+
}
|
|
856
|
+
|
|
612
857
|
/**
|
|
613
858
|
* `--root`: all the commits of the branch are rebased, its root commit too. With an
|
|
614
859
|
* upstream set ({@link setUpstream}) that is `--root --onto <upstream>`; without one the
|
|
@@ -649,7 +894,18 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
649
894
|
};
|
|
650
895
|
}
|
|
651
896
|
}
|
|
897
|
+
// parse_options: --trailer is unknown to 2.43; validate_trailer_args, then die(NULL)
|
|
898
|
+
if (this.trailerArgs.length > 0) {
|
|
899
|
+
if ((this.compatibility ?? this.hooks.compatibility) === "2.43") {
|
|
900
|
+
throw new GitApiError("error: unknown option `trailer'", { exitCode: 129 });
|
|
901
|
+
}
|
|
902
|
+
const refused = validateTrailerArgs(this.trailerArgs, this.trailerConfig());
|
|
903
|
+
if (refused !== undefined) throw new GitApiError(refused, { exitCode: 128 });
|
|
904
|
+
}
|
|
652
905
|
switch (this.operation) {
|
|
906
|
+
case RebaseOperation.QUIT:
|
|
907
|
+
case RebaseOperation.SHOW_CURRENT_PATCH:
|
|
908
|
+
return this.quitOrShow(state, worktree, this.operation);
|
|
653
909
|
case RebaseOperation.ABORT:
|
|
654
910
|
return this.abort(state, worktree);
|
|
655
911
|
case RebaseOperation.CONTINUE:
|
|
@@ -683,19 +939,260 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
683
939
|
);
|
|
684
940
|
}
|
|
685
941
|
|
|
942
|
+
/**
|
|
943
|
+
* cmd_rebase's checks of the options among themselves; the fork-point setting as git
|
|
944
|
+
* settles it then (1 on, 0 off, -1 the default: on for an implicit upstream).
|
|
945
|
+
*/
|
|
946
|
+
private checkBeginOptions(): number {
|
|
947
|
+
// rebase_config: rebase.forkPoint=false turns the default off, true leaves it
|
|
948
|
+
const configured = configValue(this.workingCopy, "rebase.forkPoint");
|
|
949
|
+
let forkPoint = configured !== undefined && parseGitBool(configured) === false ? 0 : -1;
|
|
950
|
+
if (this.forkPoint !== undefined) forkPoint = this.forkPoint ? 1 : 0;
|
|
951
|
+
const together = (a: string, b: string) =>
|
|
952
|
+
new GitApiError(`fatal: options '${a}' and '${b}' cannot be used together`);
|
|
953
|
+
if (this.keepBase) {
|
|
954
|
+
if (this.ontoName !== undefined) throw together("--keep-base", "--onto");
|
|
955
|
+
if (this.root) throw together("--keep-base", "--root");
|
|
956
|
+
// --keep-base defaults to --no-fork-point to keep the base the same
|
|
957
|
+
if (forkPoint < 0) forkPoint = 0;
|
|
958
|
+
}
|
|
959
|
+
if (this.root && forkPoint > 0) throw together("--root", "--fork-point");
|
|
960
|
+
return forkPoint;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* cmd_rebase's names and commits: the upstream (given, else the branch's `@{upstream}`),
|
|
965
|
+
* the branch rebased (the `<branch>` argument, else HEAD's), onto (`--onto`, `A...B`,
|
|
966
|
+
* `--keep-base`, `--root`'s squash-onto), the fork point and the branch base (the one
|
|
967
|
+
* merge base of onto and the branch, which can_fast_forward reads).
|
|
968
|
+
*/
|
|
969
|
+
private async settleBegin(
|
|
970
|
+
forkPoint: number,
|
|
971
|
+
/** What git prints reading the names (`warning: refname 'x' is ambiguous.`) */
|
|
972
|
+
warnings: string[],
|
|
973
|
+
): Promise<
|
|
974
|
+
| RebaseResult
|
|
975
|
+
| {
|
|
976
|
+
currentHead: ObjectId;
|
|
977
|
+
origHead: ObjectId;
|
|
978
|
+
headName: string;
|
|
979
|
+
branchName: string;
|
|
980
|
+
onto: ObjectId;
|
|
981
|
+
ontoName: string;
|
|
982
|
+
upstream?: ObjectId;
|
|
983
|
+
upstreamName?: string;
|
|
984
|
+
restrict?: ObjectId;
|
|
985
|
+
branchBase?: ObjectId;
|
|
986
|
+
squashOnto?: ObjectId;
|
|
987
|
+
}
|
|
988
|
+
> {
|
|
989
|
+
const fatal = (message: string) => new GitApiError(`fatal: ${message}`);
|
|
990
|
+
let upstreamName: string | undefined;
|
|
991
|
+
let upstream: ObjectId | undefined;
|
|
992
|
+
let ontoName = this.ontoName;
|
|
993
|
+
let onto: ObjectId | undefined;
|
|
994
|
+
let squashOnto: ObjectId | undefined;
|
|
995
|
+
if (!this.root) {
|
|
996
|
+
if (this.upstreamCommit === undefined) {
|
|
997
|
+
const missing = await this.defaultUpstream();
|
|
998
|
+
if (typeof missing !== "string") return missing;
|
|
999
|
+
upstreamName = missing;
|
|
1000
|
+
if (forkPoint < 0) forkPoint = 1;
|
|
1001
|
+
} else {
|
|
1002
|
+
upstreamName = this.upstreamCommitName === "-" ? "@{-1}" : this.upstreamCommitName;
|
|
1003
|
+
}
|
|
1004
|
+
// the upstream as given (setUpstream takes a name too) peeled to the commit it names
|
|
1005
|
+
// before anything is written, so HEAD is never set to a name ("main\n" in .git/HEAD);
|
|
1006
|
+
// an empty name too: "fatal: invalid upstream ''"
|
|
1007
|
+
const given =
|
|
1008
|
+
this.upstreamCommit === undefined || this.upstreamCommit === "-"
|
|
1009
|
+
? (upstreamName as string)
|
|
1010
|
+
: this.upstreamCommit;
|
|
1011
|
+
upstream = await this.resolveUpstream(given, upstreamName as string);
|
|
1012
|
+
warnings.push(...(await this.nameWarnings(given)));
|
|
1013
|
+
} else if (ontoName === undefined) {
|
|
1014
|
+
if (this.upstreamCommit !== undefined) {
|
|
1015
|
+
// setRoot with setUpstream: `--root --onto <upstream>`
|
|
1016
|
+
onto = await this.resolveUpstream(this.upstreamCommit);
|
|
1017
|
+
ontoName = this.upstreamCommitName ?? onto;
|
|
1018
|
+
} else {
|
|
1019
|
+
// --root without --onto: the commits go onto git's squash_onto, a commit of the
|
|
1020
|
+
// empty tree with no parent (their root is then a root again)
|
|
1021
|
+
squashOnto = await this.createSquashOnto();
|
|
1022
|
+
onto = squashOnto;
|
|
1023
|
+
ontoName = squashOnto;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
const headResolved = await this.refsStore.resolve("HEAD");
|
|
1028
|
+
if (!headResolved?.objectId) throw new NoHeadError("HEAD cannot be resolved");
|
|
1029
|
+
const currentHead = headResolved.objectId;
|
|
1030
|
+
let headName: string;
|
|
1031
|
+
let branchName: string;
|
|
1032
|
+
let origHead: ObjectId;
|
|
1033
|
+
if (this.branchArg !== undefined) {
|
|
1034
|
+
// "rebase other branchname" or "rebase other commit"
|
|
1035
|
+
branchName = this.branchArg;
|
|
1036
|
+
const ref = `refs/heads/${branchName}`;
|
|
1037
|
+
const local = (await this.refsStore.resolve(ref).catch(() => undefined))?.objectId;
|
|
1038
|
+
if (local) {
|
|
1039
|
+
const worktrees = this.workingCopy.worktrees;
|
|
1040
|
+
if (worktrees) await refuseIfCheckedOut(worktrees, ref, true);
|
|
1041
|
+
if (!(await this.loadCommit(local))) {
|
|
1042
|
+
throw fatal(`no such branch/commit '${branchName}'`);
|
|
1043
|
+
}
|
|
1044
|
+
headName = ref;
|
|
1045
|
+
origHead = local;
|
|
1046
|
+
} else {
|
|
1047
|
+
const id = await this.revisionResolver()
|
|
1048
|
+
.resolve(branchName, { hint: "committish" })
|
|
1049
|
+
.catch(() => undefined);
|
|
1050
|
+
const commit = id && (await this.revisionResolver().commitReference(id));
|
|
1051
|
+
if (!commit) throw fatal(`no such branch/commit '${branchName}'`);
|
|
1052
|
+
headName = "detached HEAD";
|
|
1053
|
+
origHead = commit;
|
|
1054
|
+
}
|
|
1055
|
+
} else {
|
|
1056
|
+
const headRef = await this.refsStore.get("HEAD");
|
|
1057
|
+
if (headRef && isSymbolicRef(headRef)) {
|
|
1058
|
+
headName = headRef.target;
|
|
1059
|
+
branchName = headName.startsWith("refs/heads/")
|
|
1060
|
+
? headName.slice("refs/heads/".length)
|
|
1061
|
+
: headName;
|
|
1062
|
+
} else {
|
|
1063
|
+
headName = "detached HEAD";
|
|
1064
|
+
branchName = "HEAD";
|
|
1065
|
+
}
|
|
1066
|
+
origHead = currentHead;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
// make sure the branch to rebase onto is valid
|
|
1070
|
+
let branchBase: ObjectId | undefined;
|
|
1071
|
+
if (this.keepBase) ontoName = `${upstreamName}...${branchName}`;
|
|
1072
|
+
else if (ontoName === undefined) ontoName = upstreamName as string;
|
|
1073
|
+
if (onto === undefined && !ontoName.includes("...")) {
|
|
1074
|
+
warnings.push(...(await this.nameWarnings(ontoName)));
|
|
1075
|
+
}
|
|
1076
|
+
if (onto === undefined && ontoName.includes("...")) {
|
|
1077
|
+
onto = await this.mergeBaseOfDots(ontoName);
|
|
1078
|
+
if (onto === undefined) {
|
|
1079
|
+
throw this.keepBase
|
|
1080
|
+
? fatal(`'${upstreamName}': need exactly one merge base with branch`)
|
|
1081
|
+
: fatal(`'${ontoName}': need exactly one merge base`);
|
|
1082
|
+
}
|
|
1083
|
+
branchBase = onto;
|
|
1084
|
+
} else {
|
|
1085
|
+
if (onto === undefined) {
|
|
1086
|
+
const id =
|
|
1087
|
+
ontoName === upstreamName && upstream !== undefined
|
|
1088
|
+
? upstream
|
|
1089
|
+
: await this.resolveRef(
|
|
1090
|
+
ontoName,
|
|
1091
|
+
(n) => `fatal: Does not point to a valid commit '${n}'`,
|
|
1092
|
+
).catch((error: unknown) => {
|
|
1093
|
+
if (error instanceof RefNotFoundError) {
|
|
1094
|
+
throw fatal(`Does not point to a valid commit '${ontoName}'`);
|
|
1095
|
+
}
|
|
1096
|
+
throw error;
|
|
1097
|
+
});
|
|
1098
|
+
onto = id;
|
|
1099
|
+
}
|
|
1100
|
+
// fill_branch_base: the one merge base of onto and the branch, else none
|
|
1101
|
+
const bases = await revisionMergeBases(this.commits, onto, origHead);
|
|
1102
|
+
branchBase = bases.length === 1 ? bases[0] : undefined;
|
|
1103
|
+
}
|
|
1104
|
+
// --keep-base keeps cherry-picks (unless --no-reapply-cherry-picks): the upstream is
|
|
1105
|
+
// onto, so none can be detected
|
|
1106
|
+
if (this.keepBase && (this.reapplyCherryPicks ?? true)) upstream = onto;
|
|
1107
|
+
let restrict: ObjectId | undefined;
|
|
1108
|
+
if (forkPoint > 0 && upstreamName !== undefined) {
|
|
1109
|
+
const graph = new MergeBaseGraph(commitsBaseSource(this.commits, async () => new Map()));
|
|
1110
|
+
restrict = await findForkPoint(this.forkPointSource(graph), upstreamName, origHead);
|
|
1111
|
+
}
|
|
1112
|
+
return {
|
|
1113
|
+
currentHead,
|
|
1114
|
+
origHead,
|
|
1115
|
+
headName,
|
|
1116
|
+
branchName,
|
|
1117
|
+
onto,
|
|
1118
|
+
ontoName,
|
|
1119
|
+
upstream,
|
|
1120
|
+
upstreamName,
|
|
1121
|
+
restrict,
|
|
1122
|
+
branchBase,
|
|
1123
|
+
squashOnto,
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
* branch_get_upstream for `git rebase` without an upstream: the current branch's
|
|
1129
|
+
* `@{upstream}`, else error_on_missing_default_upstream's advice (stdout, exit 1).
|
|
1130
|
+
*/
|
|
1131
|
+
private async defaultUpstream(): Promise<string | RebaseResult> {
|
|
1132
|
+
const headRef = await this.refsStore.get("HEAD").catch(() => undefined);
|
|
1133
|
+
const branch =
|
|
1134
|
+
headRef && isSymbolicRef(headRef) && headRef.target.startsWith("refs/heads/")
|
|
1135
|
+
? headRef.target.slice("refs/heads/".length)
|
|
1136
|
+
: undefined;
|
|
1137
|
+
if (branch !== undefined) {
|
|
1138
|
+
try {
|
|
1139
|
+
return await this.revisionResolver().upstreamOf(branch);
|
|
1140
|
+
} catch {
|
|
1141
|
+
// no upstream: the advice below
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
const output = [
|
|
1145
|
+
branch !== undefined
|
|
1146
|
+
? "There is no tracking information for the current branch."
|
|
1147
|
+
: "You are not currently on a branch.",
|
|
1148
|
+
"Please specify which branch you want to rebase against.",
|
|
1149
|
+
"See git-rebase(1) for details.",
|
|
1150
|
+
"",
|
|
1151
|
+
" git rebase '<branch>'",
|
|
1152
|
+
"",
|
|
1153
|
+
];
|
|
1154
|
+
if (branch !== undefined) {
|
|
1155
|
+
const remote =
|
|
1156
|
+
RemoteConfigStore.from(this.workingCopy).value(`branch.${branch}.remote`) ?? "<remote>";
|
|
1157
|
+
output.push(
|
|
1158
|
+
"If you wish to set tracking information for this branch you can do so with:",
|
|
1159
|
+
"",
|
|
1160
|
+
` git branch --set-upstream-to=${remote}/<branch> ${branch}`,
|
|
1161
|
+
"",
|
|
1162
|
+
);
|
|
1163
|
+
}
|
|
1164
|
+
return { status: RebaseStatus.FAILED, output };
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
/** What git prints while it reads `name` (an ambiguous refname's warning). */
|
|
1168
|
+
private async nameWarnings(name: string): Promise<string[]> {
|
|
1169
|
+
const resolver = this.revisionResolver();
|
|
1170
|
+
await resolver.resolve(name, { hint: "committish" }).catch(() => undefined);
|
|
1171
|
+
return resolver.warnings;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
/** repo_get_oid_mb: the one merge base of `A...B` (either side empty is HEAD). */
|
|
1175
|
+
private async mergeBaseOfDots(name: string): Promise<ObjectId | undefined> {
|
|
1176
|
+
const dots = name.indexOf("...");
|
|
1177
|
+
const resolver = this.revisionResolver();
|
|
1178
|
+
const commitOf = async (rev: string) => {
|
|
1179
|
+
const id = await resolver.resolve(rev, { hint: "committish" }).catch(() => undefined);
|
|
1180
|
+
return id === undefined ? undefined : resolver.commitReference(id);
|
|
1181
|
+
};
|
|
1182
|
+
const one = await commitOf(dots === 0 ? "HEAD" : name.slice(0, dots));
|
|
1183
|
+
if (one === undefined) return undefined;
|
|
1184
|
+
const rest = name.slice(dots + 3);
|
|
1185
|
+
const two = await commitOf(rest === "" ? "HEAD" : rest);
|
|
1186
|
+
if (two === undefined) return undefined;
|
|
1187
|
+
const bases = await revisionMergeBases(this.commits, one, two);
|
|
1188
|
+
return bases.length === 1 ? bases[0] : undefined;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
686
1191
|
private async begin(
|
|
687
1192
|
state: OperationState,
|
|
688
1193
|
worktree: Worktree | undefined,
|
|
689
1194
|
): 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
|
-
}
|
|
1195
|
+
const forkPoint = this.checkBeginOptions();
|
|
699
1196
|
if (await this.inProgress(state)) {
|
|
700
1197
|
return {
|
|
701
1198
|
status: RebaseStatus.FAILED,
|
|
@@ -714,23 +1211,35 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
714
1211
|
if (command === "")
|
|
715
1212
|
return { status: RebaseStatus.FAILED, message: "error: empty exec command" };
|
|
716
1213
|
}
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
squashOnto = await this.createSquashOnto();
|
|
727
|
-
this.upstreamCommitName = squashOnto;
|
|
1214
|
+
const nameWarnings: string[] = [];
|
|
1215
|
+
let settled: Awaited<ReturnType<RebaseCommand["settleBegin"]>>;
|
|
1216
|
+
try {
|
|
1217
|
+
settled = await this.settleBegin(forkPoint, nameWarnings);
|
|
1218
|
+
} catch (error) {
|
|
1219
|
+
if (error instanceof GitApiError && nameWarnings.length > 0) {
|
|
1220
|
+
error.message = [...nameWarnings, error.message].join("\n");
|
|
1221
|
+
}
|
|
1222
|
+
throw error;
|
|
728
1223
|
}
|
|
729
|
-
|
|
1224
|
+
if ("status" in settled) return settled;
|
|
1225
|
+
const {
|
|
1226
|
+
currentHead: headId,
|
|
1227
|
+
origHead,
|
|
1228
|
+
headName,
|
|
1229
|
+
branchName,
|
|
1230
|
+
onto,
|
|
1231
|
+
ontoName,
|
|
1232
|
+
upstream,
|
|
1233
|
+
upstreamName,
|
|
1234
|
+
restrict,
|
|
1235
|
+
branchBase,
|
|
1236
|
+
squashOnto,
|
|
1237
|
+
} = settled;
|
|
1238
|
+
this.runOntoName = ontoName;
|
|
730
1239
|
|
|
731
1240
|
// git's require_clean_work_tree: no unstaged, no staged changes, unless they are
|
|
732
1241
|
// stashed away for the rebase (rebase.autoStash) and applied again after it
|
|
733
|
-
const output: string[] = [];
|
|
1242
|
+
const output: string[] = [...nameWarnings];
|
|
734
1243
|
let autostash: ObjectId | undefined;
|
|
735
1244
|
const refusal = await this.uncleanWorktree(headId, worktree);
|
|
736
1245
|
if (refusal) {
|
|
@@ -771,27 +1280,39 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
771
1280
|
// git's can_fast_forward: HEAD already on upstream with a linear history since, nothing
|
|
772
1281
|
// to do (unless forced, as the date options and --signoff do); an interactive rebase,
|
|
773
1282
|
// --exec and --autosquash never take the shortcut (allow_preemptive_ff)
|
|
774
|
-
const forced =
|
|
1283
|
+
const forced =
|
|
1284
|
+
this.forceRebase ||
|
|
1285
|
+
this.committerDateIsAuthorDate ||
|
|
1286
|
+
this.ignoreDate ||
|
|
1287
|
+
this.signoff ||
|
|
1288
|
+
this.trailerArgs.length > 0;
|
|
775
1289
|
const preemptive = !interactive && execs.length === 0 && this.autosquash !== true;
|
|
776
|
-
if (preemptive &&
|
|
777
|
-
const upToDate =
|
|
778
|
-
? `Current branch ${
|
|
779
|
-
: "HEAD is up to date";
|
|
1290
|
+
if (preemptive && (await this.canFastForward(onto, upstream, restrict, origHead, branchBase))) {
|
|
1291
|
+
const upToDate =
|
|
1292
|
+
branchName === "HEAD" ? "HEAD is up to date" : `Current branch ${branchName} is up to date`;
|
|
780
1293
|
if (!forced) {
|
|
1294
|
+
// lazily switch to the target branch if needed (checkout_up_to_date)
|
|
1295
|
+
if (this.branchArg !== undefined) {
|
|
1296
|
+
const refused = await this.checkoutUpToDate(worktree, headId, origHead, headName);
|
|
1297
|
+
if (refused) {
|
|
1298
|
+
await unstash();
|
|
1299
|
+
return { ...refused, output: [...output, ...(refused.output ?? [])] };
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
781
1302
|
output.push(`${upToDate}.`);
|
|
782
1303
|
// finish_rebase: what an earlier rebase left removed
|
|
783
1304
|
await state.removeRef("REBASE_HEAD", "AUTO_MERGE");
|
|
784
1305
|
await unstash();
|
|
785
|
-
return { status: RebaseStatus.UP_TO_DATE, newHead:
|
|
1306
|
+
return { status: RebaseStatus.UP_TO_DATE, newHead: origHead, output };
|
|
786
1307
|
}
|
|
787
1308
|
output.push(`${upToDate}, rebase forced.`);
|
|
788
1309
|
}
|
|
789
1310
|
|
|
790
1311
|
// the pre-rebase hook, told the upstream as given (`--root` with --root), may refuse
|
|
791
1312
|
if (!this.noVerify) {
|
|
792
|
-
const upstreamArg =
|
|
793
|
-
|
|
794
|
-
const pre = await this.hooks.run("pre-rebase", { args
|
|
1313
|
+
const upstreamArg = this.root ? "--root" : (upstreamName as string);
|
|
1314
|
+
const args = this.branchArg !== undefined ? [upstreamArg, this.branchArg] : [upstreamArg];
|
|
1315
|
+
const pre = await this.hooks.run("pre-rebase", { args });
|
|
795
1316
|
if (pre && pre.exitCode !== 0) {
|
|
796
1317
|
await unstash();
|
|
797
1318
|
return {
|
|
@@ -823,15 +1344,20 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
823
1344
|
output,
|
|
824
1345
|
};
|
|
825
1346
|
}
|
|
826
|
-
await state.setRef("ORIG_HEAD",
|
|
1347
|
+
await state.setRef("ORIG_HEAD", origHead);
|
|
827
1348
|
await this.refsStore.set("HEAD", onto, this.startLog());
|
|
828
1349
|
await runPostCheckoutHook(this.hooks, headId, onto, true);
|
|
829
1350
|
await this.finishBranch(headName, onto, onto);
|
|
830
1351
|
await unstash();
|
|
831
1352
|
return { status, newHead: onto, output };
|
|
832
1353
|
};
|
|
833
|
-
// nothing of HEAD's to replay: HEAD moves to upstream
|
|
834
|
-
|
|
1354
|
+
// nothing of HEAD's to replay: HEAD moves to upstream (an interactive rebase still
|
|
1355
|
+
// shows its `noop` list to the editor, which may add commands)
|
|
1356
|
+
// get_revision_ranges' base: the upstream, else (--root) onto
|
|
1357
|
+
const base = upstream ?? onto;
|
|
1358
|
+
if (!interactive && base === onto && !restrict && (await this.isAncestor(origHead, onto))) {
|
|
1359
|
+
return moveToOnto(RebaseStatus.FAST_FORWARD);
|
|
1360
|
+
}
|
|
835
1361
|
|
|
836
1362
|
// `--rebase-merges` (else `rebase.rebaseMerges`, a boolean or a cousins mode)
|
|
837
1363
|
let rebaseMerges = this.rebaseMerges;
|
|
@@ -846,15 +1372,19 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
846
1372
|
}
|
|
847
1373
|
// the commits to pick: HEAD's, not upstream's, merges dropped (kept with
|
|
848
1374
|
// --rebase-merges), oldest first
|
|
849
|
-
|
|
1375
|
+
// (git's `<upstream>...<branch>` right side, `^<fork point>` excluded; with --root
|
|
1376
|
+
// everything below the branch)
|
|
1377
|
+
const excluded = [base, restrict].filter((id): id is ObjectId => id !== undefined);
|
|
1378
|
+
const range = await this.commitsToRebase(origHead, excluded, !!rebaseMerges);
|
|
850
1379
|
// 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);
|
|
1380
|
+
// and the branch still moves to upstream (an interactive rebase shows that `noop`)
|
|
1381
|
+
if (range.length === 0 && !interactive) return moveToOnto(RebaseStatus.OK);
|
|
853
1382
|
// commits whose change upstream has already (`--cherry-mark`): left out, with git's
|
|
854
1383
|
// warnings (`make_script`), unless --reapply-cherry-picks
|
|
855
|
-
const skipped =
|
|
856
|
-
|
|
857
|
-
|
|
1384
|
+
const skipped =
|
|
1385
|
+
(this.reapplyCherryPicks ?? this.keepBase)
|
|
1386
|
+
? new Set<ObjectId>()
|
|
1387
|
+
: await this.appliedUpstream(origHead, base, range, restrict);
|
|
858
1388
|
const ids = range.filter((id) => !skipped.has(id));
|
|
859
1389
|
if (skipped.size > 0) {
|
|
860
1390
|
for (const id of range) {
|
|
@@ -866,7 +1396,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
866
1396
|
if (configBool(this.workingCopy, "advice.skippedCherryPicks", true)) {
|
|
867
1397
|
output.push(
|
|
868
1398
|
"hint: use --reapply-cherry-picks to include skipped commits",
|
|
869
|
-
'
|
|
1399
|
+
// 2.43's advice: `git config <key> false`
|
|
1400
|
+
`hint: Disable this message with "git config${(this.compatibility ?? this.hooks.compatibility) === "2.43" ? "" : " set"} advice.skippedCherryPicks false"`,
|
|
870
1401
|
);
|
|
871
1402
|
}
|
|
872
1403
|
}
|
|
@@ -875,8 +1406,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
875
1406
|
let script = "";
|
|
876
1407
|
if (rebaseMerges) {
|
|
877
1408
|
script = await this.makeScriptWithMerges(
|
|
878
|
-
|
|
879
|
-
|
|
1409
|
+
origHead,
|
|
1410
|
+
base,
|
|
880
1411
|
range,
|
|
881
1412
|
skipped,
|
|
882
1413
|
rebaseCousins,
|
|
@@ -899,12 +1430,19 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
899
1430
|
// init_basic_state / write_basic_state
|
|
900
1431
|
await state.write(`${DIR}/head-name`, `${headName}\n`);
|
|
901
1432
|
await state.write(`${DIR}/onto`, `${onto}\n`);
|
|
902
|
-
await state.write(`${DIR}/orig-head`, `${
|
|
1433
|
+
await state.write(`${DIR}/orig-head`, `${origHead}\n`);
|
|
1434
|
+
// write_basic_state: gpg_sign_opt (`-S<key>`) when the run signs
|
|
1435
|
+
const sign = signRequestOf(this.workingCopy, this.sign);
|
|
1436
|
+
this.runSign = { key: sign };
|
|
1437
|
+
if (sign !== undefined) await state.write(`${DIR}/gpg_sign_opt`, `-S${sign}\n`);
|
|
903
1438
|
if (this.signoff) await state.write(`${DIR}/signoff`, "--signoff\n");
|
|
904
1439
|
if (emptyMode === "drop") await state.write(`${DIR}/drop_redundant_commits`, "");
|
|
905
1440
|
if (emptyMode === "keep") await state.write(`${DIR}/keep_redundant_commits`, "");
|
|
906
1441
|
if (this.committerDateIsAuthorDate) await state.write(`${DIR}/cdate_is_adate`, "");
|
|
907
1442
|
if (this.ignoreDate) await state.write(`${DIR}/ignore_date`, "");
|
|
1443
|
+
if (this.trailerArgs.length > 0) {
|
|
1444
|
+
await state.write(`${DIR}/trailer`, this.trailerArgs.map((t) => `${t}\n`).join(""));
|
|
1445
|
+
}
|
|
908
1446
|
await state.write(
|
|
909
1447
|
`${DIR}/${reschedule ? "reschedule-failed-exec" : "no-reschedule-failed-exec"}`,
|
|
910
1448
|
"",
|
|
@@ -946,8 +1484,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
946
1484
|
comment,
|
|
947
1485
|
{
|
|
948
1486
|
shortRevisions: this.root
|
|
949
|
-
? await this.abbreviateObjectId(
|
|
950
|
-
: `${
|
|
1487
|
+
? await this.abbreviateObjectId(origHead)
|
|
1488
|
+
: `${await this.abbreviateObjectId(base)}..${await this.abbreviateObjectId(origHead)}`,
|
|
951
1489
|
shortOnto,
|
|
952
1490
|
},
|
|
953
1491
|
missingCheck === "error",
|
|
@@ -984,7 +1522,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
984
1522
|
targetTree: ontoTreeId,
|
|
985
1523
|
});
|
|
986
1524
|
if (!refused) {
|
|
987
|
-
await state.setRef("ORIG_HEAD",
|
|
1525
|
+
await state.setRef("ORIG_HEAD", origHead);
|
|
988
1526
|
await this.refsStore.set("HEAD", onto, this.startLog());
|
|
989
1527
|
}
|
|
990
1528
|
return { status: RebaseStatus.FAILED, message: lines.join("\n"), output };
|
|
@@ -1059,7 +1597,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1059
1597
|
start,
|
|
1060
1598
|
this.startLog(),
|
|
1061
1599
|
"rebase: updating ORIG_HEAD",
|
|
1062
|
-
{ detach: true },
|
|
1600
|
+
{ detach: true, origHead },
|
|
1063
1601
|
)),
|
|
1064
1602
|
);
|
|
1065
1603
|
// checkout_onto's post-checkout hook: the HEAD left, the commit the picks start from
|
|
@@ -1248,13 +1786,30 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1248
1786
|
if (!conflicts) {
|
|
1249
1787
|
lines.push(`Stopped at ${await this.abbreviateObjectId(item.id)}... ${rest}`);
|
|
1250
1788
|
}
|
|
1789
|
+
// error_with_patch: 2.5x writes the picked message as it is (have_message), 2.43 and a
|
|
1790
|
+
// fast-forwarded pick leave it to make_patch (the commit's, a line end added)
|
|
1791
|
+
const picked =
|
|
1792
|
+
outcome.kind === "ok" && (this.compatibility ?? this.hooks.compatibility) !== "2.43"
|
|
1793
|
+
? outcome.message
|
|
1794
|
+
: undefined;
|
|
1251
1795
|
lines.push(
|
|
1252
1796
|
...(await this.errorWithPatch(state, item.id, rest, {
|
|
1253
1797
|
exitCode: conflicts ? 1 : 0,
|
|
1254
1798
|
toAmend: outcome.kind === "ok",
|
|
1255
|
-
...(conflicts
|
|
1256
|
-
|
|
1257
|
-
|
|
1799
|
+
...(conflicts
|
|
1800
|
+
? { message: outcome.message }
|
|
1801
|
+
: picked !== undefined
|
|
1802
|
+
? { message: picked }
|
|
1803
|
+
: {}),
|
|
1804
|
+
// the picked message (do_pick_commit's, --signoff's and --trailer's trailers
|
|
1805
|
+
// added); a fast-forwarded pick (possible with --trailer after --continue) has
|
|
1806
|
+
// none, and make_patch writes the commit's own
|
|
1807
|
+
picked:
|
|
1808
|
+
!conflicts &&
|
|
1809
|
+
((await state.exists(`${DIR}/signoff`)) ||
|
|
1810
|
+
(outcome.kind === "ok" &&
|
|
1811
|
+
outcome.message !== undefined &&
|
|
1812
|
+
(await state.exists(`${DIR}/trailer`)))),
|
|
1258
1813
|
})),
|
|
1259
1814
|
);
|
|
1260
1815
|
return {
|
|
@@ -1284,7 +1839,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1284
1839
|
conflicts: outcome.conflicts,
|
|
1285
1840
|
message: [
|
|
1286
1841
|
...outcome.lines,
|
|
1287
|
-
...(await this.errorWithPatch(state, item.id, rest, {
|
|
1842
|
+
...(await this.errorWithPatch(state, item.id, rest, {
|
|
1843
|
+
exitCode: 1,
|
|
1844
|
+
toAmend: outcome.toAmend ?? true,
|
|
1845
|
+
})),
|
|
1288
1846
|
].join("\n"),
|
|
1289
1847
|
};
|
|
1290
1848
|
}
|
|
@@ -1319,7 +1877,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1319
1877
|
state: OperationState,
|
|
1320
1878
|
id: ObjectId,
|
|
1321
1879
|
rest: string,
|
|
1322
|
-
options: { exitCode: number; toAmend: boolean; message?: string;
|
|
1880
|
+
options: { exitCode: number; toAmend: boolean; message?: string; picked?: boolean },
|
|
1323
1881
|
): Promise<string[]> {
|
|
1324
1882
|
if (options.message !== undefined && !(await state.exists(`${DIR}/message`))) {
|
|
1325
1883
|
await state.write(`${DIR}/message`, options.message);
|
|
@@ -1333,9 +1891,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1333
1891
|
const body = messageBody(commit?.message ?? "");
|
|
1334
1892
|
await state.write(
|
|
1335
1893
|
`${DIR}/message`,
|
|
1336
|
-
options.
|
|
1337
|
-
? appendSignoff(body, this.signoffLine(), trailerConfigOf(this.workingCopy))
|
|
1338
|
-
: `${body}\n`,
|
|
1894
|
+
options.picked ? await this.pickedMessageOf(state, body) : `${body}\n`,
|
|
1339
1895
|
);
|
|
1340
1896
|
}
|
|
1341
1897
|
if (options.toAmend) {
|
|
@@ -1343,7 +1899,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1343
1899
|
return [
|
|
1344
1900
|
"You can amend the commit now, with",
|
|
1345
1901
|
"",
|
|
1346
|
-
|
|
1902
|
+
` git commit --amend ${await this.gpgSignOptQuoted(state)}`,
|
|
1347
1903
|
"",
|
|
1348
1904
|
"Once you are satisfied with your changes, run",
|
|
1349
1905
|
"",
|
|
@@ -1399,7 +1955,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1399
1955
|
await this.rewordHead(state);
|
|
1400
1956
|
} catch (error) {
|
|
1401
1957
|
// fast_forward_edit's git commit failed: a stop with HEAD to amend
|
|
1402
|
-
return editorFailure(error);
|
|
1958
|
+
return signingFailure(error) ?? editorFailure(error);
|
|
1403
1959
|
}
|
|
1404
1960
|
}
|
|
1405
1961
|
return { kind: "ok" };
|
|
@@ -1413,12 +1969,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1413
1969
|
const parentTreeId = parentId ? await this.commits.getTree(parentId) : undefined;
|
|
1414
1970
|
const subject = subjectOf(commit.message);
|
|
1415
1971
|
// 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
|
|
1972
|
+
// sign-off and --trailer its trailers (not for a fixup or squash), before the merge
|
|
1973
|
+
// (MERGE_MSG has them)
|
|
1417
1974
|
const body = messageBody(commit.message);
|
|
1418
|
-
const pickedMessage =
|
|
1419
|
-
signoff && !fixup
|
|
1420
|
-
? appendSignoff(body, this.signoffLine(), trailerConfigOf(this.workingCopy))
|
|
1421
|
-
: body;
|
|
1975
|
+
const pickedMessage = fixup ? body : await this.pickedMessageOf(state, body);
|
|
1422
1976
|
let messageFile: "squash" | "fixup" | "edit" | undefined;
|
|
1423
1977
|
if (fixup) {
|
|
1424
1978
|
await this.updateSquashMessages(state, item, commit.message);
|
|
@@ -1494,13 +2048,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1494
2048
|
conflicts: [...new Set(merge.conflicts.keys())].sort(),
|
|
1495
2049
|
// git 2.43 writes the message and a blank line (2.5x the conflict list after it)
|
|
1496
2050
|
message: `${merged}\n`,
|
|
1497
|
-
lines: [
|
|
1498
|
-
`error: could not apply ${short}... ${subject}`,
|
|
1499
|
-
"hint: Resolve all conflicts manually, mark them as resolved with",
|
|
1500
|
-
'hint: "git add/rm <conflicted_files>", then run "git rebase --continue".',
|
|
1501
|
-
'hint: You can instead skip this commit: run "git rebase --skip".',
|
|
1502
|
-
'hint: To abort and get back to the state before "git rebase", run "git rebase --abort".',
|
|
1503
|
-
],
|
|
2051
|
+
lines: [`error: could not apply ${short}... ${subject}`, ...this.mergeConflictAdvice()],
|
|
1504
2052
|
};
|
|
1505
2053
|
}
|
|
1506
2054
|
await state.write("MERGE_MSG", pickedMessage);
|
|
@@ -1563,7 +2111,24 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1563
2111
|
)) ?? "";
|
|
1564
2112
|
if (signoff) message = stripspace(message);
|
|
1565
2113
|
}
|
|
1566
|
-
|
|
2114
|
+
try {
|
|
2115
|
+
await this.amendHead(state, treeId, message, item.action, messageFile === "edit");
|
|
2116
|
+
} catch (error) {
|
|
2117
|
+
if (!(error instanceof SigningFailedError)) throw error;
|
|
2118
|
+
// the end of a chain with a squash is git commit's (it dies), the rest try_to_commit's
|
|
2119
|
+
// (an error); then error_failed_squash, 2.43 rescheduling an in-process amend
|
|
2120
|
+
if (messageFile === "edit") {
|
|
2121
|
+
// git commit died before its cleanup: AUTO_MERGE stays
|
|
2122
|
+
await state.setRef("AUTO_MERGE", treeId);
|
|
2123
|
+
return {
|
|
2124
|
+
kind: "conflicts",
|
|
2125
|
+
conflicts: [],
|
|
2126
|
+
lines: [error.message, "fatal: failed to write commit object"],
|
|
2127
|
+
toAmend: this.hooks.compatibility !== "2.43",
|
|
2128
|
+
};
|
|
2129
|
+
}
|
|
2130
|
+
return this.signingStop(item, [error.message, "error: failed to write commit object"]);
|
|
2131
|
+
}
|
|
1567
2132
|
// try_to_commit removes MERGE_MSG; git commit (the edited end of a chain) SQUASH_MSG too
|
|
1568
2133
|
await state.remove("MERGE_MSG");
|
|
1569
2134
|
if (messageFile === "edit") await state.remove("SQUASH_MSG");
|
|
@@ -1589,22 +2154,40 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1589
2154
|
const message = signoff ? stripspace(pickedMessage) : pickedMessage;
|
|
1590
2155
|
// do_pick_commit writes CHERRY_PICK_HEAD for the commit to come; do_commit deletes it
|
|
1591
2156
|
// once try_to_commit made it
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
2157
|
+
try {
|
|
2158
|
+
await state.withRefDuring("CHERRY_PICK_HEAD", item.id, () =>
|
|
2159
|
+
this.commitOnto(
|
|
2160
|
+
state,
|
|
2161
|
+
unborn ? [] : [headId],
|
|
2162
|
+
treeId,
|
|
2163
|
+
commit.author,
|
|
2164
|
+
message,
|
|
2165
|
+
item.action,
|
|
2166
|
+
),
|
|
2167
|
+
);
|
|
2168
|
+
} catch (error) {
|
|
2169
|
+
if (!(error instanceof SigningFailedError)) throw error;
|
|
2170
|
+
// try_to_commit could not sign: 2.43 reschedules the pick, 2.5x stops as after a
|
|
2171
|
+
// conflict, the merged result staged for `--continue` (CHERRY_PICK_HEAD left)
|
|
2172
|
+
await state.setRef("CHERRY_PICK_HEAD", item.id);
|
|
2173
|
+
return this.signingStop(item, [error.message, "error: failed to write commit object"], {
|
|
2174
|
+
message: pickedMessage,
|
|
2175
|
+
});
|
|
2176
|
+
}
|
|
1595
2177
|
// do_commit: the commit made, MERGE_MSG removed
|
|
1596
2178
|
await state.remove("MERGE_MSG");
|
|
1597
2179
|
if (item.action === RebaseAction.REWORD) {
|
|
1598
2180
|
try {
|
|
1599
2181
|
await this.rewordHead(state);
|
|
1600
2182
|
} catch (error) {
|
|
1601
|
-
// git commit --amend -e failed (the editor): the pick stays, the
|
|
1602
|
-
|
|
2183
|
+
// git commit --amend -e failed (the editor, the signing): the pick stays, the
|
|
2184
|
+
// rebase stops
|
|
2185
|
+
return { ...(signingFailure(error) ?? editorFailure(error)), message: pickedMessage };
|
|
1603
2186
|
}
|
|
1604
2187
|
}
|
|
1605
2188
|
}
|
|
1606
2189
|
if (finalFixup) await this.endFixupChain(state);
|
|
1607
|
-
return { kind: "ok" };
|
|
2190
|
+
return fixup ? { kind: "ok" } : { kind: "ok", message: pickedMessage };
|
|
1608
2191
|
}
|
|
1609
2192
|
|
|
1610
2193
|
/** do_pick_commit after a final fixup: the chain's files removed. */
|
|
@@ -1747,10 +2330,12 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1747
2330
|
const fixupOff = buf.length;
|
|
1748
2331
|
buf += body.slice(commented);
|
|
1749
2332
|
if (fixupFlag && !seenSquash) {
|
|
1750
|
-
// the message replaced: --signoff's trailer appended
|
|
2333
|
+
// the message replaced: --signoff's and --trailer's trailers appended
|
|
2334
|
+
// (append_squash_message)
|
|
1751
2335
|
if (await state.exists(`${DIR}/signoff`)) {
|
|
1752
|
-
buf = appendSignoff(buf, this.signoffLine(),
|
|
2336
|
+
buf = appendSignoff(buf, this.signoffLine(), this.trailerConfig());
|
|
1753
2337
|
}
|
|
2338
|
+
buf = await this.withTrailers(state, buf);
|
|
1754
2339
|
if (
|
|
1755
2340
|
item.replaceMessage &&
|
|
1756
2341
|
((await state.exists(`${DIR}/message-fixup`)) ||
|
|
@@ -2147,14 +2732,32 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2147
2732
|
// git commit -n -F MERGE_MSG --cleanup=verbatim (whitespace with --signoff, which the
|
|
2148
2733
|
// merge does not get): the merge committed, its state removed
|
|
2149
2734
|
const committed = (await state.exists(`${DIR}/signoff`)) ? stripspace(message) : message;
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
[headId, head.id],
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2735
|
+
let newId: ObjectId;
|
|
2736
|
+
try {
|
|
2737
|
+
newId = await this.commitOnto(state, [headId, head.id], treeId, author, committed, "merge");
|
|
2738
|
+
} catch (error) {
|
|
2739
|
+
if (!(error instanceof SigningFailedError)) throw error;
|
|
2740
|
+
// do_merge's git commit dies signing: the merge stays staged (MERGE_HEAD, MERGE_MSG)
|
|
2741
|
+
// for --continue, the rebase stops as at a conflicting merge (AUTO_MERGE written)
|
|
2742
|
+
await state.setRef("AUTO_MERGE", treeId);
|
|
2743
|
+
await state.write(`${DIR}/message`, message);
|
|
2744
|
+
if (item.id) {
|
|
2745
|
+
await state.write(`${DIR}/stopped-sha`, `${item.id}\n`);
|
|
2746
|
+
await state.setRef("REBASE_HEAD", item.id);
|
|
2747
|
+
await state.write(`${DIR}/patch`, "");
|
|
2748
|
+
}
|
|
2749
|
+
const short = item.id ? await this.abbreviateObjectId(item.id) : "";
|
|
2750
|
+
return {
|
|
2751
|
+
status: RebaseStatus.STOPPED,
|
|
2752
|
+
...(item.id ? { currentCommit: item.id } : {}),
|
|
2753
|
+
conflicts: [],
|
|
2754
|
+
message: [
|
|
2755
|
+
error.message,
|
|
2756
|
+
"fatal: failed to write commit object",
|
|
2757
|
+
item.id ? `Could not apply ${short}... ${arg}` : `Could not merge ${arg}`,
|
|
2758
|
+
].join("\n"),
|
|
2759
|
+
};
|
|
2760
|
+
}
|
|
2158
2761
|
// (git commit removes SQUASH_MSG too; the octopus' git merge leaves it)
|
|
2159
2762
|
await state.remove("MERGE_MSG", "MERGE_HEAD", "MERGE_MODE", "SQUASH_MSG");
|
|
2160
2763
|
await state.removeRef("AUTO_MERGE");
|
|
@@ -2199,6 +2802,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2199
2802
|
.setCommitter(committer);
|
|
2200
2803
|
// `merge -c`: --edit, the message cleaned up as an edited one
|
|
2201
2804
|
if (item.editMessage) command.setCleanupMode(CleanupMode.STRIP);
|
|
2805
|
+
// do_merge passes the run's -S<key> to git merge, else --no-gpg-sign
|
|
2806
|
+
const sign = await this.signRequest(state);
|
|
2807
|
+
if (sign !== undefined) command.setSigningKey(sign);
|
|
2808
|
+
else command.setSign(false);
|
|
2202
2809
|
// the merge inherits pull's GIT_REFLOG_ACTION, not the rebase's own action
|
|
2203
2810
|
if (this.hasReflogAction()) command.setReflogAction(this.reflogAction("rebase"));
|
|
2204
2811
|
for (const head of heads) command.include(head.id);
|
|
@@ -2255,13 +2862,15 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2255
2862
|
tzOffset: commit.author.tzOffset,
|
|
2256
2863
|
};
|
|
2257
2864
|
}
|
|
2258
|
-
const newId = await this.commits.store(
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2865
|
+
const newId = await this.commits.store(
|
|
2866
|
+
await this.signedRebaseCommit(state, {
|
|
2867
|
+
tree: commit.tree,
|
|
2868
|
+
parents: commit.parents,
|
|
2869
|
+
author: commit.author,
|
|
2870
|
+
committer,
|
|
2871
|
+
message,
|
|
2872
|
+
}),
|
|
2873
|
+
);
|
|
2265
2874
|
const action = reflogMessages.rebaseStep(this.reflogAction("rebase"), "merge");
|
|
2266
2875
|
await this.refsStore.set(
|
|
2267
2876
|
"HEAD",
|
|
@@ -2315,12 +2924,86 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2315
2924
|
* options and --signoff imply (`cdate_is_adate`, `ignore_date`, `signoff` in the state).
|
|
2316
2925
|
*/
|
|
2317
2926
|
private async allowFastForward(state: OperationState): Promise<boolean> {
|
|
2927
|
+
// --trailer forces the run that starts the rebase (REBASE_FORCE) but, as in git, is not
|
|
2928
|
+
// read back as a reason to: a --continue may fast-forward again
|
|
2929
|
+
if (this.operation === RebaseOperation.BEGIN && this.trailerArgs.length > 0) return false;
|
|
2930
|
+
// so does --force-rebase (REBASE_FORCE, never saved in the state)
|
|
2931
|
+
if (this.operation === RebaseOperation.BEGIN && this.forceRebase) return false;
|
|
2318
2932
|
for (const name of ["cdate_is_adate", "ignore_date", "signoff"]) {
|
|
2319
2933
|
if (await state.exists(`${DIR}/${name}`)) return false;
|
|
2320
2934
|
}
|
|
2321
2935
|
return true;
|
|
2322
2936
|
}
|
|
2323
2937
|
|
|
2938
|
+
/** The trailer configuration `--trailer` and `--signoff` apply (`trailer.*`). */
|
|
2939
|
+
private trailerConfig(): TrailerConfig {
|
|
2940
|
+
return {
|
|
2941
|
+
...trailerConfigOf(this.workingCopy),
|
|
2942
|
+
compatibility: this.compatibility ?? this.hooks.compatibility,
|
|
2943
|
+
};
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
/**
|
|
2947
|
+
* do_pick_commit's message of a pick: `--signoff`'s trailer, then the `--trailer`s
|
|
2948
|
+
* (amend_strbuf_with_trailers) kept in `rebase-merge/trailer`.
|
|
2949
|
+
*/
|
|
2950
|
+
private async pickedMessageOf(state: OperationState, body: string): Promise<string> {
|
|
2951
|
+
let message = body;
|
|
2952
|
+
if (await state.exists(`${DIR}/signoff`)) {
|
|
2953
|
+
message = appendSignoff(message, this.signoffLine(), this.trailerConfig());
|
|
2954
|
+
}
|
|
2955
|
+
return this.withTrailers(state, message);
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
/** amend_strbuf_with_trailers with the run's `--trailer`s (read_trailers), if any. */
|
|
2959
|
+
private async withTrailers(state: OperationState, message: string): Promise<string> {
|
|
2960
|
+
const args = await this.runTrailers(state);
|
|
2961
|
+
if (args.length === 0) return message;
|
|
2962
|
+
const hooks = this.hooks;
|
|
2963
|
+
const runCommand: TrailerCommandRunner | undefined = hooks.enabled
|
|
2964
|
+
? (command) => hooks.runShellCommand("trailer", command.command, command.args)
|
|
2965
|
+
: undefined;
|
|
2966
|
+
return (await amendWithTrailers(message, args, this.trailerConfig(), runCommand)).output;
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2969
|
+
/** read_trailers: the lines of `rebase-merge/trailer` (none without the file). */
|
|
2970
|
+
private async runTrailers(state: OperationState): Promise<string[]> {
|
|
2971
|
+
const text = await state.read(`${DIR}/trailer`);
|
|
2972
|
+
if (text === undefined) return [];
|
|
2973
|
+
if (text === "") {
|
|
2974
|
+
throw new GitApiError("error: trailers file is empty", { exitCode: 1 });
|
|
2975
|
+
}
|
|
2976
|
+
const lines = text.split("\n");
|
|
2977
|
+
// a last line without its newline is not read (strchr finds none)
|
|
2978
|
+
lines.pop();
|
|
2979
|
+
if (lines.some((l) => l === "")) {
|
|
2980
|
+
throw new GitApiError("error: trailers file contains empty line", { exitCode: 1 });
|
|
2981
|
+
}
|
|
2982
|
+
return lines;
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
/**
|
|
2986
|
+
* print_advice's hints at a conflicting pick (`advice.mergeConflict`, 2.45+: off drops
|
|
2987
|
+
* them, unset adds how to turn them off; 2.43 always gives them as they are).
|
|
2988
|
+
*/
|
|
2989
|
+
private mergeConflictAdvice(): string[] {
|
|
2990
|
+
const hints = [
|
|
2991
|
+
"hint: Resolve all conflicts manually, mark them as resolved with",
|
|
2992
|
+
'hint: "git add/rm <conflicted_files>", then run "git rebase --continue".',
|
|
2993
|
+
'hint: You can instead skip this commit: run "git rebase --skip".',
|
|
2994
|
+
'hint: To abort and get back to the state before "git rebase", run "git rebase --abort".',
|
|
2995
|
+
];
|
|
2996
|
+
if ((this.compatibility ?? this.hooks.compatibility) === "2.43") return hints;
|
|
2997
|
+
const value = configValue(this.workingCopy, "advice.mergeConflict");
|
|
2998
|
+
if (value === undefined) {
|
|
2999
|
+
return [
|
|
3000
|
+
...hints,
|
|
3001
|
+
'hint: Disable this message with "git config set advice.mergeConflict false"',
|
|
3002
|
+
];
|
|
3003
|
+
}
|
|
3004
|
+
return (parseGitBool(value) ?? true) ? hints : [];
|
|
3005
|
+
}
|
|
3006
|
+
|
|
2324
3007
|
/** append_signoff's `Signed-off-by: <committer name> <email>` line. */
|
|
2325
3008
|
private signoffLine(): string {
|
|
2326
3009
|
const committer = this.committer ?? this.resolveCommitter();
|
|
@@ -2624,7 +3307,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2624
3307
|
const treeId = await this.staging.writeTree(this.trees);
|
|
2625
3308
|
const isClean = headCommit?.tree === treeId;
|
|
2626
3309
|
if (!isClean && !(await state.exists(`${DIR}/message`))) {
|
|
2627
|
-
return {
|
|
3310
|
+
return {
|
|
3311
|
+
status: RebaseStatus.FAILED,
|
|
3312
|
+
message: stagedChangesAdvice(await this.gpgSignOptQuoted(state)),
|
|
3313
|
+
};
|
|
2628
3314
|
}
|
|
2629
3315
|
let amend = false;
|
|
2630
3316
|
let finalFixup = false;
|
|
@@ -2737,6 +3423,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2737
3423
|
}
|
|
2738
3424
|
}
|
|
2739
3425
|
} catch (error) {
|
|
3426
|
+
if (error instanceof SigningFailedError) return commitStagedSigningFailure(error);
|
|
2740
3427
|
// git commit failed on its editor: nothing committed, the stop stays as it is
|
|
2741
3428
|
return {
|
|
2742
3429
|
status: RebaseStatus.FAILED,
|
|
@@ -2747,8 +3434,14 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2747
3434
|
}
|
|
2748
3435
|
if (gitCommit) {
|
|
2749
3436
|
// committed above, with git commit's hooks
|
|
2750
|
-
} else if (amend)
|
|
2751
|
-
|
|
3437
|
+
} else if (amend) {
|
|
3438
|
+
try {
|
|
3439
|
+
await this.amendHead(state, treeId, message, "continue", true);
|
|
3440
|
+
} catch (error) {
|
|
3441
|
+
if (error instanceof SigningFailedError) return commitStagedSigningFailure(error);
|
|
3442
|
+
throw error;
|
|
3443
|
+
}
|
|
3444
|
+
} else {
|
|
2752
3445
|
// a stopped merge: its other parents (git commit reads MERGE_HEAD, one per line: an
|
|
2753
3446
|
// octopus has several)
|
|
2754
3447
|
const mergeHeads = ((await state.read("MERGE_HEAD")) ?? "")
|
|
@@ -2757,7 +3450,12 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2757
3450
|
.filter((line) => /^[0-9a-f]{40,64}$/.test(line));
|
|
2758
3451
|
const author =
|
|
2759
3452
|
parseAuthorScript((await state.read(`${DIR}/author-script`)) ?? "") ?? this.resolveAuthor();
|
|
2760
|
-
|
|
3453
|
+
try {
|
|
3454
|
+
await this.commitOnto(state, [headId, ...mergeHeads], treeId, author, message, "continue");
|
|
3455
|
+
} catch (error) {
|
|
3456
|
+
if (error instanceof SigningFailedError) return commitStagedSigningFailure(error);
|
|
3457
|
+
throw error;
|
|
3458
|
+
}
|
|
2761
3459
|
}
|
|
2762
3460
|
// git commit's cleanup (SQUASH_MSG of a final squash too), then commit_staged_changes'
|
|
2763
3461
|
await state.remove(`${DIR}/amend`, "MERGE_HEAD", "MERGE_MODE", "MERGE_MSG", "SQUASH_MSG");
|
|
@@ -2786,6 +3484,63 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2786
3484
|
return this.resume(state, worktree);
|
|
2787
3485
|
}
|
|
2788
3486
|
|
|
3487
|
+
/**
|
|
3488
|
+
* `git rebase --quit` and `--show-current-patch` (builtin/rebase.c's ACTION_QUIT and
|
|
3489
|
+
* ACTION_SHOW_CURRENT_PATCH): the backend found as cmd_rebase finds it (`rebase-apply/`
|
|
3490
|
+
* first, `rebase-apply/applying` being git am's), refused when no rebase is in progress.
|
|
3491
|
+
*/
|
|
3492
|
+
private async quitOrShow(
|
|
3493
|
+
state: OperationState,
|
|
3494
|
+
worktree: Worktree | undefined,
|
|
3495
|
+
operation: RebaseOperation,
|
|
3496
|
+
): Promise<RebaseResult> {
|
|
3497
|
+
const APPLY_DIR = "rebase-apply";
|
|
3498
|
+
if (await state.exists(`${APPLY_DIR}/applying`)) {
|
|
3499
|
+
return {
|
|
3500
|
+
status: RebaseStatus.FAILED,
|
|
3501
|
+
message: "fatal: It looks like 'git am' is in progress. Cannot rebase.",
|
|
3502
|
+
};
|
|
3503
|
+
}
|
|
3504
|
+
const apply = await state.exists(APPLY_DIR);
|
|
3505
|
+
if (!apply && !(await state.exists(DIR))) {
|
|
3506
|
+
const legacy = (this.compatibility ?? this.hooks.compatibility) === "2.43";
|
|
3507
|
+
return {
|
|
3508
|
+
status: RebaseStatus.FAILED,
|
|
3509
|
+
message: legacy ? "fatal: No rebase in progress?" : "fatal: no rebase in progress",
|
|
3510
|
+
};
|
|
3511
|
+
}
|
|
3512
|
+
const stateDir = apply ? APPLY_DIR : DIR;
|
|
3513
|
+
if (operation === RebaseOperation.SHOW_CURRENT_PATCH) {
|
|
3514
|
+
if (apply) {
|
|
3515
|
+
// run_am: `git am --show-current-patch` (its rebasing session shows the original
|
|
3516
|
+
// commit, `git show <original-commit>`)
|
|
3517
|
+
const am = await new AmCommand(this.workingCopy).setShowCurrentPatch("raw").call();
|
|
3518
|
+
if (am.exitCode !== 0) {
|
|
3519
|
+
return { status: RebaseStatus.FAILED, message: am.errors.replace(/\n$/, "") };
|
|
3520
|
+
}
|
|
3521
|
+
return { status: RebaseStatus.OK, currentPatch: am.output };
|
|
3522
|
+
}
|
|
3523
|
+
// run_sequencer_rebase: `git show REBASE_HEAD --` (its failure is rebase's exit 1)
|
|
3524
|
+
const id = await state.ref("REBASE_HEAD");
|
|
3525
|
+
if (!id) return { status: RebaseStatus.FAILED, message: "fatal: bad revision 'REBASE_HEAD'" };
|
|
3526
|
+
return { status: RebaseStatus.OK, currentPatch: await showCommit(this.workingCopy, id) };
|
|
3527
|
+
}
|
|
3528
|
+
// ACTION_QUIT: save_autostash (kept on refs/stash), then sequencer_remove_state for the
|
|
3529
|
+
// merge backend (refs-to-delete deleted, the directory removed) or the directory alone;
|
|
3530
|
+
// REBASE_HEAD, AUTO_MERGE, ORIG_HEAD, MERGE_MSG and HEAD stay as they are
|
|
3531
|
+
const output: string[] = [];
|
|
3532
|
+
const autostash = (await state.read(`${stateDir}/autostash`))?.trim();
|
|
3533
|
+
if (autostash) {
|
|
3534
|
+
await saveAutostash(this.context(worktree), autostash);
|
|
3535
|
+
await state.remove(`${stateDir}/autostash`);
|
|
3536
|
+
output.push(...AUTOSTASH_SAVED_LINES);
|
|
3537
|
+
}
|
|
3538
|
+
if (!apply) await this.deleteRewrittenRefs(state);
|
|
3539
|
+
await state.remove(stateDir);
|
|
3540
|
+
const head = (await this.refsStore.resolve("HEAD").catch(() => undefined))?.objectId;
|
|
3541
|
+
return { status: RebaseStatus.OK, ...(head ? { newHead: head } : {}), output };
|
|
3542
|
+
}
|
|
3543
|
+
|
|
2789
3544
|
/** `git rebase --abort`: back to the original branch and commit (`reset --hard`). */
|
|
2790
3545
|
private async abort(
|
|
2791
3546
|
state: OperationState,
|
|
@@ -2916,13 +3671,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2916
3671
|
commentPrefixOf(this.workingCopy),
|
|
2917
3672
|
)
|
|
2918
3673
|
: await sequencerPrepareMessage(this.hooks, state, message);
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
parents,
|
|
2922
|
-
|
|
2923
|
-
committer,
|
|
2924
|
-
message: hooked,
|
|
2925
|
-
});
|
|
3674
|
+
// commit_tree signs: when it cannot, git's failure (each step says what follows)
|
|
3675
|
+
const id = await this.commits.store(
|
|
3676
|
+
await this.signedRebaseCommit(state, { tree, parents, author, committer, message: hooked }),
|
|
3677
|
+
);
|
|
2926
3678
|
const action = reflogMessages.rebaseStep(this.reflogAction("rebase"), step);
|
|
2927
3679
|
const log = this.reflogLine(reflogMessages.pick(action, hooked), this.committer);
|
|
2928
3680
|
const refs = this.refsStore;
|
|
@@ -2967,7 +3719,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2967
3719
|
|
|
2968
3720
|
/** HEAD detached at upstream: `rebase (start): checkout <upstream as given>`. */
|
|
2969
3721
|
private startLog(): RefLogOptions {
|
|
2970
|
-
const onto = this.upstreamCommitName ?? this.upstreamCommit ?? "";
|
|
3722
|
+
const onto = this.runOntoName ?? this.upstreamCommitName ?? this.upstreamCommit ?? "";
|
|
2971
3723
|
return this.reflogLine(
|
|
2972
3724
|
reflogMessages.rebaseStart(this.reflogAction("rebase"), onto),
|
|
2973
3725
|
this.committer,
|
|
@@ -3773,11 +4525,11 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3773
4525
|
*/
|
|
3774
4526
|
private async commitsToRebase(
|
|
3775
4527
|
head: ObjectId,
|
|
3776
|
-
|
|
4528
|
+
excluded: ObjectId[],
|
|
3777
4529
|
keepMerges = false,
|
|
3778
4530
|
): Promise<ObjectId[]> {
|
|
3779
4531
|
const upstreamCommits = new Set<ObjectId>();
|
|
3780
|
-
const walk = [
|
|
4532
|
+
const walk = [...excluded];
|
|
3781
4533
|
while (walk.length > 0) {
|
|
3782
4534
|
const id = walk.pop() as ObjectId;
|
|
3783
4535
|
if (upstreamCommits.has(id)) continue;
|
|
@@ -3833,9 +4585,11 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3833
4585
|
head: ObjectId,
|
|
3834
4586
|
upstream: ObjectId,
|
|
3835
4587
|
range: ObjectId[],
|
|
4588
|
+
/** The fork point (`^<fork point>`), which limits upstream's side too */
|
|
4589
|
+
restrict?: ObjectId,
|
|
3836
4590
|
): Promise<Set<ObjectId>> {
|
|
3837
4591
|
const skipped = new Set<ObjectId>();
|
|
3838
|
-
const left = await this.onlyReachableFrom(upstream, head);
|
|
4592
|
+
const left = await this.onlyReachableFrom(upstream, restrict ? [head, restrict] : [head]);
|
|
3839
4593
|
if (left.length === 0 || range.length === 0) return skipped;
|
|
3840
4594
|
// each tree read once: a commit's tree is its child's parent tree
|
|
3841
4595
|
const treeEntries = new Map<ObjectId, TreeEntry[]>();
|
|
@@ -3896,7 +4650,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3896
4650
|
* what `other` reaches painted uninteresting, done once every commit still queued is
|
|
3897
4651
|
* uninteresting (and a few more, git's slop against clock skew).
|
|
3898
4652
|
*/
|
|
3899
|
-
private async onlyReachableFrom(tip: ObjectId,
|
|
4653
|
+
private async onlyReachableFrom(tip: ObjectId, others: ObjectId[]): Promise<ObjectId[]> {
|
|
3900
4654
|
interface Node {
|
|
3901
4655
|
id: ObjectId;
|
|
3902
4656
|
time: number;
|
|
@@ -3938,7 +4692,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3938
4692
|
}
|
|
3939
4693
|
}
|
|
3940
4694
|
};
|
|
3941
|
-
await push(other, true);
|
|
4695
|
+
for (const other of others) await push(other, true);
|
|
3942
4696
|
await push(tip, false);
|
|
3943
4697
|
const out: Node[] = [];
|
|
3944
4698
|
let slop = 5;
|
|
@@ -3968,13 +4722,63 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3968
4722
|
}
|
|
3969
4723
|
|
|
3970
4724
|
/**
|
|
3971
|
-
* builtin/rebase.c's
|
|
3972
|
-
*
|
|
3973
|
-
*
|
|
3974
|
-
|
|
4725
|
+
* builtin/rebase.c's checkout_up_to_date: the `<branch>` argument checked out when there
|
|
4726
|
+
* is nothing to rebase (reset_working_tree: the worktree switched from HEAD, the branch
|
|
4727
|
+
* and HEAD logged `rebase: checkout <branch>`, the post-checkout hook run).
|
|
4728
|
+
*/
|
|
4729
|
+
private async checkoutUpToDate(
|
|
4730
|
+
worktree: Worktree | undefined,
|
|
4731
|
+
headId: ObjectId,
|
|
4732
|
+
origHead: ObjectId,
|
|
4733
|
+
headName: string,
|
|
4734
|
+
): Promise<RebaseResult | undefined> {
|
|
4735
|
+
const branch = this.branchArg as string;
|
|
4736
|
+
const headTree = await flatTree(this.trees, await this.commits.getTree(headId));
|
|
4737
|
+
const targetTreeId = await this.commits.getTree(origHead);
|
|
4738
|
+
const targetTree = await flatTree(this.trees, targetTreeId);
|
|
4739
|
+
const refused = await switchTrees(this.context(worktree), headTree, targetTree, {
|
|
4740
|
+
action: "checkout",
|
|
4741
|
+
operation: "rebase",
|
|
4742
|
+
targetTree: targetTreeId,
|
|
4743
|
+
});
|
|
4744
|
+
if (refused) {
|
|
4745
|
+
return {
|
|
4746
|
+
status: RebaseStatus.FAILED,
|
|
4747
|
+
message: `${refused.message}\nerror: could not switch to ${branch}`,
|
|
4748
|
+
};
|
|
4749
|
+
}
|
|
4750
|
+
const log = this.reflogLine(
|
|
4751
|
+
`${this.reflogAction("rebase")}: checkout ${branch}`,
|
|
4752
|
+
this.committer,
|
|
4753
|
+
);
|
|
4754
|
+
if (headName.startsWith("refs/")) {
|
|
4755
|
+
await this.refsStore.set(headName, origHead, log);
|
|
4756
|
+
await this.refsStore.setSymbolic("HEAD", headName, log);
|
|
4757
|
+
} else {
|
|
4758
|
+
await this.refsStore.set("HEAD", origHead, log);
|
|
4759
|
+
}
|
|
4760
|
+
await runPostCheckoutHook(this.hooks, headId, origHead, true);
|
|
4761
|
+
return undefined;
|
|
4762
|
+
}
|
|
4763
|
+
|
|
4764
|
+
/**
|
|
4765
|
+
* builtin/rebase.c's can_fast_forward: the branch's one merge base with onto is onto
|
|
4766
|
+
* (`branchBase`), the fork point (if any) is that base too, the upstream (none with
|
|
4767
|
+
* --root) and the branch have one merge base, onto, and the first-parent line from the
|
|
4768
|
+
* branch down to onto has no merge (is_linear_history).
|
|
3975
4769
|
*/
|
|
3976
|
-
private async canFastForward(
|
|
3977
|
-
|
|
4770
|
+
private async canFastForward(
|
|
4771
|
+
onto: ObjectId,
|
|
4772
|
+
upstream: ObjectId | undefined,
|
|
4773
|
+
restrict: ObjectId | undefined,
|
|
4774
|
+
head: ObjectId,
|
|
4775
|
+
branchBase: ObjectId | undefined,
|
|
4776
|
+
): Promise<boolean> {
|
|
4777
|
+
if (branchBase === undefined || branchBase !== onto) return false;
|
|
4778
|
+
if (restrict !== undefined && restrict !== branchBase) return false;
|
|
4779
|
+
if (upstream === undefined) return false;
|
|
4780
|
+
const bases = await revisionMergeBases(this.commits, upstream, head);
|
|
4781
|
+
if (bases.length !== 1 || bases[0] !== onto) return false;
|
|
3978
4782
|
let id: ObjectId | undefined = head;
|
|
3979
4783
|
while (id !== undefined && id !== onto) {
|
|
3980
4784
|
const parents: ObjectId[] = (await this.loadCommit(id))?.parents ?? [];
|