@statewalker/vcs-commands 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commands/add-command.d.ts +32 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/add-patch.d.ts +7 -0
- package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts +2 -0
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-modes.d.ts +6 -2
- package/dist/commands/add-patch/patch-modes.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-session.d.ts +4 -0
- package/dist/commands/add-patch/patch-session.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +88 -2
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-command.d.ts +2 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.d.ts +7 -0
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/apply/index.d.ts +1 -1
- package/dist/commands/apply/index.d.ts.map +1 -1
- package/dist/commands/archive/archive-command.d.ts +169 -0
- package/dist/commands/archive/archive-command.d.ts.map +1 -0
- package/dist/commands/archive/archive-entry.d.ts +60 -0
- package/dist/commands/archive/archive-entry.d.ts.map +1 -0
- package/dist/commands/archive/index.d.ts +8 -0
- package/dist/commands/archive/index.d.ts.map +1 -0
- package/dist/commands/archive/remote-archive-command.d.ts +56 -0
- package/dist/commands/archive/remote-archive-command.d.ts.map +1 -0
- package/dist/commands/archive/tar-archive.d.ts +31 -0
- package/dist/commands/archive/tar-archive.d.ts.map +1 -0
- package/dist/commands/archive/tar-commit-id.d.ts +13 -0
- package/dist/commands/archive/tar-commit-id.d.ts.map +1 -0
- package/dist/commands/archive/upload-archive-writer.d.ts +48 -0
- package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -0
- package/dist/commands/archive/zip-archive.d.ts +42 -0
- package/dist/commands/archive/zip-archive.d.ts.map +1 -0
- package/dist/commands/attributes-source.d.ts +10 -0
- package/dist/commands/attributes-source.d.ts.map +1 -1
- package/dist/commands/blame-command.d.ts +345 -8
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/blame-ignore.d.ts +48 -0
- package/dist/commands/blame-ignore.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-create-command.d.ts +67 -0
- package/dist/commands/bundle/bundle-create-command.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-format.d.ts +89 -0
- package/dist/commands/bundle/bundle-format.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-list.d.ts +92 -0
- package/dist/commands/bundle/bundle-list.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts +81 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-support.d.ts +32 -0
- package/dist/commands/bundle/bundle-support.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-transport.d.ts +38 -0
- package/dist/commands/bundle/bundle-transport.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts +43 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri.d.ts +55 -0
- package/dist/commands/bundle/bundle-uri.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-verify.d.ts +63 -0
- package/dist/commands/bundle/bundle-verify.d.ts.map +1 -0
- package/dist/commands/bundle/index.d.ts +14 -0
- package/dist/commands/bundle/index.d.ts.map +1 -0
- package/dist/commands/cat-file/batch-format.d.ts +58 -0
- package/dist/commands/cat-file/batch-format.d.ts.map +1 -0
- package/dist/commands/cat-file/cat-file-command.d.ts +135 -0
- package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -0
- package/dist/commands/cat-file/index.d.ts +3 -0
- package/dist/commands/cat-file/index.d.ts.map +1 -0
- package/dist/commands/check-attr-command.d.ts +66 -0
- package/dist/commands/check-attr-command.d.ts.map +1 -0
- package/dist/commands/check-ignore-command.d.ts +58 -0
- package/dist/commands/check-ignore-command.d.ts.map +1 -0
- package/dist/commands/check-mailmap-command.d.ts +49 -0
- package/dist/commands/check-mailmap-command.d.ts.map +1 -0
- package/dist/commands/check-ref-format-command.d.ts +60 -0
- package/dist/commands/check-ref-format-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +7 -0
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-index-command.d.ts +96 -0
- package/dist/commands/checkout-index-command.d.ts.map +1 -0
- package/dist/commands/checkout-paths.d.ts +4 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-command.d.ts +61 -0
- package/dist/commands/cherry-command.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +33 -1
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +32 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +56 -0
- package/dist/commands/clean-interactive.d.ts.map +1 -0
- package/dist/commands/clone-command.d.ts +135 -2
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +59 -3
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/config-command.d.ts +2 -0
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/daemon-access-hook.d.ts +36 -0
- package/dist/commands/daemon-access-hook.d.ts.map +1 -0
- package/dist/commands/default-branch.d.ts +42 -0
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/describe-command.d.ts +71 -64
- package/dist/commands/describe-command.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +249 -10
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/diff-external.d.ts +43 -0
- package/dist/commands/diff-external.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts +27 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts +129 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/index.d.ts +3 -0
- package/dist/commands/diff-plumbing/index.d.ts.map +1 -0
- package/dist/commands/diff-textconv.d.ts +5 -1
- package/dist/commands/diff-textconv.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-export-command.d.ts +135 -0
- package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-import-command.d.ts +182 -0
- package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts +64 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -0
- package/dist/commands/fast-export/index.d.ts +4 -0
- package/dist/commands/fast-export/index.d.ts.map +1 -0
- package/dist/commands/fetch-command.d.ts +125 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fetch-multiple-command.d.ts +193 -0
- package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
- package/dist/commands/format-patch-command.d.ts +28 -2
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/format-rev-command.d.ts +58 -0
- package/dist/commands/format-rev-command.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-msg-ids.d.ts +18 -3
- package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -1
- package/dist/commands/fsmonitor-refresh.d.ts +69 -0
- package/dist/commands/fsmonitor-refresh.d.ts.map +1 -0
- package/dist/commands/gc-command.d.ts +5 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +77 -4
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +47 -1
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/git-paths.d.ts +26 -0
- package/dist/commands/git-paths.d.ts.map +1 -0
- package/dist/commands/grep/grep-command.d.ts +2 -1
- package/dist/commands/grep/grep-command.d.ts.map +1 -1
- package/dist/commands/history-command.d.ts +156 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/http-config.d.ts +38 -0
- package/dist/commands/http-config.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +12 -1
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index-host.d.ts.map +1 -1
- package/dist/commands/index.d.ts +56 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +6 -3
- package/dist/commands/init-command.d.ts +89 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/last-modified-command.d.ts +102 -0
- package/dist/commands/last-modified-command.d.ts.map +1 -0
- package/dist/commands/lfs/go-url.d.ts +43 -0
- package/dist/commands/lfs/go-url.d.ts.map +1 -0
- package/dist/commands/lfs/index.d.ts +3 -0
- package/dist/commands/lfs/index.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-config.d.ts +174 -0
- package/dist/commands/lfs/lfs-config.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-endpoint-command.d.ts +83 -0
- package/dist/commands/lfs/lfs-endpoint-command.d.ts.map +1 -0
- package/dist/commands/line-log.d.ts +161 -0
- package/dist/commands/line-log.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +261 -6
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +4 -2
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +88 -2
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-files-command.d.ts +153 -0
- package/dist/commands/ls-files-command.d.ts.map +1 -0
- package/dist/commands/ls-remote-command.d.ts +5 -0
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/ls-tree-command.d.ts +105 -0
- package/dist/commands/ls-tree-command.d.ts.map +1 -0
- package/dist/commands/mailmap.d.ts +24 -1
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/maintenance-run-command.d.ts +122 -0
- package/dist/commands/maintenance-run-command.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +58 -1
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-config.d.ts +7 -0
- package/dist/commands/merge-config.d.ts.map +1 -1
- package/dist/commands/merge-drivers.d.ts +69 -5
- package/dist/commands/merge-drivers.d.ts.map +1 -1
- package/dist/commands/merge-strategy-options.d.ts +69 -0
- package/dist/commands/merge-strategy-options.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +16 -0
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/merge-tree-command.d.ts +122 -0
- package/dist/commands/merge-tree-command.d.ts.map +1 -0
- package/dist/commands/message-cleanup.d.ts +2 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -1
- package/dist/commands/mktag-command.d.ts +51 -0
- package/dist/commands/mktag-command.d.ts.map +1 -0
- package/dist/commands/name-rev-command.d.ts +65 -0
- package/dist/commands/name-rev-command.d.ts.map +1 -0
- package/dist/commands/name-rev.d.ts +110 -22
- package/dist/commands/name-rev.d.ts.map +1 -1
- package/dist/commands/object-store/count-objects-command.d.ts +58 -0
- package/dist/commands/object-store/count-objects-command.d.ts.map +1 -0
- package/dist/commands/object-store/index.d.ts +5 -0
- package/dist/commands/object-store/index.d.ts.map +1 -0
- package/dist/commands/object-store/objects-directory.d.ts +12 -0
- package/dist/commands/object-store/objects-directory.d.ts.map +1 -0
- package/dist/commands/object-store/prune-command.d.ts +38 -0
- package/dist/commands/object-store/prune-command.d.ts.map +1 -0
- package/dist/commands/object-store/show-index-command.d.ts +23 -0
- package/dist/commands/object-store/show-index-command.d.ts.map +1 -0
- package/dist/commands/octopus-merge.d.ts +26 -1
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/ort-merge.d.ts +40 -0
- package/dist/commands/ort-merge.d.ts.map +1 -1
- package/dist/commands/ort-recursive.d.ts.map +1 -1
- package/dist/commands/patch-id-command.d.ts +30 -0
- package/dist/commands/patch-id-command.d.ts.map +1 -0
- package/dist/commands/patch-id.d.ts +82 -0
- package/dist/commands/patch-id.d.ts.map +1 -1
- package/dist/commands/plumbing-command.d.ts +66 -0
- package/dist/commands/plumbing-command.d.ts.map +1 -0
- package/dist/commands/plumbing-input.d.ts +38 -0
- package/dist/commands/plumbing-input.d.ts.map +1 -0
- package/dist/commands/promisor-remote-reply.d.ts +35 -0
- package/dist/commands/promisor-remote-reply.d.ts.map +1 -0
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +182 -38
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +82 -2
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/index.d.ts +4 -0
- package/dist/commands/range-diff/index.d.ts.map +1 -0
- package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
- package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff.d.ts +106 -0
- package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
- package/dist/commands/read-tree-command.d.ts +14 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +129 -4
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/refs-command.d.ts +81 -0
- package/dist/commands/refs-command.d.ts.map +1 -0
- package/dist/commands/remerge-diff.d.ts +59 -0
- package/dist/commands/remerge-diff.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +41 -0
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-object-info-command.d.ts +55 -0
- package/dist/commands/remote-object-info-command.d.ts.map +1 -0
- package/dist/commands/remote-show-command.d.ts +204 -0
- package/dist/commands/remote-show-command.d.ts.map +1 -0
- package/dist/commands/remote-transport.d.ts +40 -3
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/repack-command.d.ts +115 -0
- package/dist/commands/repack-command.d.ts.map +1 -0
- package/dist/commands/replace-command.d.ts +143 -0
- package/dist/commands/replace-command.d.ts.map +1 -0
- package/dist/commands/replay-command.d.ts +117 -0
- package/dist/commands/replay-command.d.ts.map +1 -0
- package/dist/commands/repo-command.d.ts +136 -0
- package/dist/commands/repo-command.d.ts.map +1 -0
- package/dist/commands/request-pull-command.d.ts +82 -0
- package/dist/commands/request-pull-command.d.ts.map +1 -0
- package/dist/commands/rerere-command.d.ts +36 -0
- package/dist/commands/rerere-command.d.ts.map +1 -0
- package/dist/commands/rerere.d.ts +102 -0
- package/dist/commands/rerere.d.ts.map +1 -0
- package/dist/commands/reset-command.d.ts +19 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +7 -0
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-filter/commit-grep.d.ts +3 -1
- package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -1
- package/dist/commands/rev-list-command.d.ts +78 -3
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/rev-parse-command.d.ts +9 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +32 -1
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +7 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +12 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +120 -1
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +10 -1
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +23 -1
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/session-id.d.ts +18 -0
- package/dist/commands/session-id.d.ts.map +1 -0
- package/dist/commands/shortlog-command.d.ts +109 -0
- package/dist/commands/shortlog-command.d.ts.map +1 -0
- package/dist/commands/shortlog.d.ts +151 -0
- package/dist/commands/shortlog.d.ts.map +1 -0
- package/dist/commands/show-branch-command.d.ts +59 -0
- package/dist/commands/show-branch-command.d.ts.map +1 -0
- package/dist/commands/show-ref-command.d.ts +112 -0
- package/dist/commands/show-ref-command.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +9 -2
- package/dist/commands/signature-check.d.ts.map +1 -1
- package/dist/commands/signing.d.ts +22 -1
- package/dist/commands/signing.d.ts.map +1 -1
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-export-command.d.ts +115 -0
- package/dist/commands/stash-export-command.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +33 -3
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/stripspace-command.d.ts +44 -0
- package/dist/commands/stripspace-command.d.ts.map +1 -0
- package/dist/commands/submodule-add-command.d.ts +10 -1
- package/dist/commands/submodule-add-command.d.ts.map +1 -1
- package/dist/commands/submodule-auth.d.ts +3 -1
- package/dist/commands/submodule-auth.d.ts.map +1 -1
- package/dist/commands/submodule-commands.d.ts +99 -3
- package/dist/commands/submodule-commands.d.ts.map +1 -1
- package/dist/commands/submodule-fetch.d.ts +149 -0
- package/dist/commands/submodule-fetch.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +8 -0
- package/dist/commands/submodule-model.d.ts.map +1 -1
- package/dist/commands/submodule-unpack.d.ts +120 -0
- package/dist/commands/submodule-unpack.d.ts.map +1 -0
- package/dist/commands/submodule-update-command.d.ts +21 -1
- package/dist/commands/submodule-update-command.d.ts.map +1 -1
- package/dist/commands/subtree-shift.d.ts +27 -0
- package/dist/commands/subtree-shift.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts +3 -0
- package/dist/commands/switch-command.d.ts.map +1 -1
- package/dist/commands/textconv-cache.d.ts +58 -0
- package/dist/commands/textconv-cache.d.ts.map +1 -0
- package/dist/commands/tree-restore.d.ts +5 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/unpack-objects-command.d.ts +47 -0
- package/dist/commands/unpack-objects-command.d.ts.map +1 -0
- package/dist/commands/update-index-command.d.ts +110 -0
- package/dist/commands/update-index-command.d.ts.map +1 -0
- package/dist/commands/uri-protocols.d.ts +13 -0
- package/dist/commands/uri-protocols.d.ts.map +1 -0
- package/dist/commands/url-parse-command.d.ts +30 -0
- package/dist/commands/url-parse-command.d.ts.map +1 -0
- package/dist/commands/var-command.d.ts +42 -0
- package/dist/commands/var-command.d.ts.map +1 -0
- package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/{commands-ISM52N0n.js → commands-Mlo1dxQN.js} +56133 -70269
- package/dist/errors/command-errors.d.ts +58 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +67 -1
- package/dist/fsck-CrhVMNIH.js +5179 -0
- package/dist/git-command.d.ts +89 -3
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +628 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +84 -0
- package/dist/guarded-transport-command.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/maintenance-run-command-Bw21HEkH.js +13539 -0
- package/dist/remote-transport-Bu4PGSMD.js +2605 -0
- package/dist/rename/detect-renames.d.ts +20 -0
- package/dist/rename/detect-renames.d.ts.map +1 -1
- package/dist/rename/diffcore-break.d.ts +51 -0
- package/dist/rename/diffcore-break.d.ts.map +1 -0
- package/dist/rename/index.d.ts +1 -0
- package/dist/rename/index.d.ts.map +1 -1
- package/dist/results/blame-format.d.ts +62 -1
- package/dist/results/blame-format.d.ts.map +1 -1
- package/dist/results/cherry-pick-result.d.ts +6 -0
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +9 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/diff-dirstat.d.ts +36 -0
- package/dist/results/diff-dirstat.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +20 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +67 -3
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/fetch-result.d.ts +24 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +2 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/init-result.d.ts +8 -1
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/line-range-hunks.d.ts +27 -0
- package/dist/results/line-range-hunks.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +13 -1
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +11 -0
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +10 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +7 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +6 -0
- package/dist/results/revert-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +5 -0
- package/dist/results/stash-result.d.ts.map +1 -1
- package/dist/results/status-result.d.ts +1 -1
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-ERo9vELd.js +49673 -0
- package/dist/transport-command.d.ts +93 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/commands/add-command.ts +118 -0
- package/src/commands/add-patch/add-patch.ts +8 -0
- package/src/commands/add-patch/patch-backend.ts +24 -3
- package/src/commands/add-patch/patch-modes.ts +26 -2
- package/src/commands/add-patch/patch-session.ts +6 -0
- package/src/commands/am/am-command.ts +301 -12
- package/src/commands/apply/apply-command.ts +52 -9
- package/src/commands/apply/apply-parse.ts +10 -0
- package/src/commands/apply/index.ts +9 -1
- package/src/commands/archive/archive-command.ts +1148 -0
- package/src/commands/archive/archive-entry.ts +93 -0
- package/src/commands/archive/index.ts +7 -0
- package/src/commands/archive/remote-archive-command.ts +140 -0
- package/src/commands/archive/tar-archive.ts +207 -0
- package/src/commands/archive/tar-commit-id.ts +72 -0
- package/src/commands/archive/upload-archive-writer.ts +213 -0
- package/src/commands/archive/zip-archive.ts +317 -0
- package/src/commands/attributes-source.ts +26 -12
- package/src/commands/blame-command.ts +1551 -53
- package/src/commands/blame-ignore.ts +307 -0
- package/src/commands/bundle/bundle-create-command.ts +405 -0
- package/src/commands/bundle/bundle-format.ts +228 -0
- package/src/commands/bundle/bundle-list.ts +276 -0
- package/src/commands/bundle/bundle-read-commands.ts +157 -0
- package/src/commands/bundle/bundle-support.ts +85 -0
- package/src/commands/bundle/bundle-transport.ts +107 -0
- package/src/commands/bundle/bundle-uri-host.ts +204 -0
- package/src/commands/bundle/bundle-uri.ts +236 -0
- package/src/commands/bundle/bundle-verify.ts +152 -0
- package/src/commands/bundle/index.ts +14 -0
- package/src/commands/cat-file/batch-format.ts +193 -0
- package/src/commands/cat-file/cat-file-command.ts +857 -0
- package/src/commands/cat-file/index.ts +2 -0
- package/src/commands/check-attr-command.ts +333 -0
- package/src/commands/check-ignore-command.ts +261 -0
- package/src/commands/check-mailmap-command.ts +129 -0
- package/src/commands/check-ref-format-command.ts +129 -0
- package/src/commands/checkout-command.ts +131 -28
- package/src/commands/checkout-index-command.ts +568 -0
- package/src/commands/checkout-paths.ts +35 -0
- package/src/commands/cherry-command.ts +187 -0
- package/src/commands/cherry-pick-command.ts +63 -2
- package/src/commands/clean-command.ts +92 -12
- package/src/commands/clean-interactive.ts +522 -0
- package/src/commands/clone-command.ts +803 -50
- package/src/commands/commit-command.ts +202 -51
- package/src/commands/config-command.ts +9 -0
- package/src/commands/daemon-access-hook.ts +78 -0
- package/src/commands/default-branch.ts +99 -1
- package/src/commands/describe-command.ts +341 -254
- package/src/commands/diff-command.ts +1186 -99
- package/src/commands/diff-external.ts +131 -0
- package/src/commands/diff-plumbing/diff-pairs-command.ts +193 -0
- package/src/commands/diff-plumbing/diff-plumbing-command.ts +424 -0
- package/src/commands/diff-plumbing/index.ts +2 -0
- package/src/commands/diff-textconv.ts +5 -1
- package/src/commands/fast-export/fast-export-command.ts +911 -0
- package/src/commands/fast-export/fast-import-command.ts +1553 -0
- package/src/commands/fast-export/fast-stream-support.ts +162 -0
- package/src/commands/fast-export/index.ts +3 -0
- package/src/commands/fetch-command.ts +665 -14
- package/src/commands/fetch-multiple-command.ts +668 -0
- package/src/commands/format-patch-command.ts +189 -77
- package/src/commands/format-rev-command.ts +251 -0
- package/src/commands/fsck/fsck-command.ts +47 -20
- package/src/commands/fsck/fsck-msg-ids.ts +19 -3
- package/src/commands/fsck/fsck-pack.ts +2 -2
- package/src/commands/fsmonitor-refresh.ts +315 -0
- package/src/commands/gc-command.ts +10 -0
- package/src/commands/git-describe.ts +456 -217
- package/src/commands/git-hooks.ts +165 -9
- package/src/commands/git-paths.ts +136 -0
- package/src/commands/grep/grep-command.ts +38 -15
- package/src/commands/history-command.ts +617 -0
- package/src/commands/http-config.ts +139 -0
- package/src/commands/index-adder.ts +37 -3
- package/src/commands/index-host.ts +6 -1
- package/src/commands/index.ts +62 -0
- package/src/commands/init-command.ts +617 -49
- package/src/commands/last-modified-command.ts +804 -0
- package/src/commands/lfs/go-url.ts +370 -0
- package/src/commands/lfs/index.ts +2 -0
- package/src/commands/lfs/lfs-config.ts +738 -0
- package/src/commands/lfs/lfs-endpoint-command.ts +180 -0
- package/src/commands/line-log.ts +931 -0
- package/src/commands/local-transport.ts +252 -4
- package/src/commands/log-command.ts +1518 -182
- package/src/commands/log-graph.ts +6 -3
- package/src/commands/log-output.ts +228 -15
- package/src/commands/ls-files-command.ts +1177 -0
- package/src/commands/ls-remote-command.ts +6 -0
- package/src/commands/ls-tree-command.ts +684 -0
- package/src/commands/mailmap.ts +41 -5
- package/src/commands/maintenance-run-command.ts +949 -0
- package/src/commands/merge-command.ts +351 -47
- package/src/commands/merge-config.ts +23 -1
- package/src/commands/merge-drivers.ts +112 -20
- package/src/commands/merge-strategy-options.ts +224 -0
- package/src/commands/merge-support.ts +130 -26
- package/src/commands/merge-tree-command.ts +786 -0
- package/src/commands/message-cleanup.ts +1 -1
- package/src/commands/mktag-command.ts +149 -0
- package/src/commands/name-rev-command.ts +184 -0
- package/src/commands/name-rev.ts +700 -109
- package/src/commands/object-store/count-objects-command.ts +404 -0
- package/src/commands/object-store/index.ts +4 -0
- package/src/commands/object-store/objects-directory.ts +24 -0
- package/src/commands/object-store/prune-command.ts +129 -0
- package/src/commands/object-store/show-index-command.ts +151 -0
- package/src/commands/octopus-merge.ts +35 -11
- package/src/commands/ort-merge.ts +124 -23
- package/src/commands/ort-recursive.ts +40 -2
- package/src/commands/patch-id-command.ts +65 -0
- package/src/commands/patch-id.ts +327 -0
- package/src/commands/plumbing-command.ts +141 -0
- package/src/commands/plumbing-input.ts +87 -0
- package/src/commands/promisor-remote-reply.ts +276 -0
- package/src/commands/promisor-remote.ts +25 -2
- package/src/commands/pull-command.ts +720 -224
- package/src/commands/push-command.ts +440 -8
- package/src/commands/range-diff/index.ts +3 -0
- package/src/commands/range-diff/linear-assignment.ts +203 -0
- package/src/commands/range-diff/range-diff-command.ts +433 -0
- package/src/commands/range-diff/range-diff.ts +617 -0
- package/src/commands/read-tree-command.ts +74 -3
- package/src/commands/rebase-command.ts +647 -83
- package/src/commands/refs-command.ts +274 -0
- package/src/commands/remerge-diff.ts +241 -0
- package/src/commands/remote-command.ts +98 -10
- package/src/commands/remote-object-info-command.ts +109 -0
- package/src/commands/remote-show-command.ts +836 -0
- package/src/commands/remote-transport.ts +116 -1
- package/src/commands/repack-command.ts +383 -0
- package/src/commands/replace-command.ts +816 -0
- package/src/commands/replay-command.ts +674 -0
- package/src/commands/repo-command.ts +967 -0
- package/src/commands/request-pull-command.ts +356 -0
- package/src/commands/rerere-command.ts +179 -0
- package/src/commands/rerere.ts +925 -0
- package/src/commands/reset-command.ts +78 -3
- package/src/commands/restore-command.ts +15 -0
- package/src/commands/rev-filter/commit-grep.ts +7 -2
- package/src/commands/rev-list-command.ts +196 -11
- package/src/commands/rev-parse-command.ts +62 -4
- package/src/commands/revert-command.ts +62 -2
- package/src/commands/revision-range.ts +10 -3
- package/src/commands/revision-resolver.ts +44 -3
- package/src/commands/sequencer-pick.ts +370 -29
- package/src/commands/sequencer-support.ts +164 -2
- package/src/commands/serve-repository.ts +65 -0
- package/src/commands/session-id.ts +31 -0
- package/src/commands/shortlog-command.ts +354 -0
- package/src/commands/shortlog.ts +361 -0
- package/src/commands/show-branch-command.ts +981 -0
- package/src/commands/show-command.ts +3 -2
- package/src/commands/show-ref-command.ts +439 -0
- package/src/commands/signature-check.ts +37 -5
- package/src/commands/signing.ts +122 -16
- package/src/commands/stash-apply-command.ts +3 -0
- package/src/commands/stash-export-command.ts +397 -0
- package/src/commands/status-command.ts +158 -31
- package/src/commands/status-format.ts +1 -1
- package/src/commands/stripspace-command.ts +118 -0
- package/src/commands/submodule-add-command.ts +22 -1
- package/src/commands/submodule-auth.ts +61 -6
- package/src/commands/submodule-commands.ts +333 -5
- package/src/commands/submodule-fetch.ts +789 -0
- package/src/commands/submodule-model.ts +9 -1
- package/src/commands/submodule-unpack.ts +265 -0
- package/src/commands/submodule-update-command.ts +68 -5
- package/src/commands/subtree-shift.ts +215 -0
- package/src/commands/switch-command.ts +9 -0
- package/src/commands/textconv-cache.ts +143 -0
- package/src/commands/tree-restore.ts +20 -1
- package/src/commands/unpack-objects-command.ts +235 -0
- package/src/commands/update-index-command.ts +1016 -0
- package/src/commands/uri-protocols.ts +13 -0
- package/src/commands/url-parse-command.ts +67 -0
- package/src/commands/var-command.ts +219 -0
- package/src/commands/worktree-overwrite-checks.ts +5 -0
- package/src/errors/command-errors.ts +80 -0
- package/src/git-command.ts +218 -2
- package/src/git.ts +1033 -80
- package/src/guarded-transport-command.ts +176 -0
- package/src/index.ts +1 -0
- package/src/rename/detect-renames.ts +42 -8
- package/src/rename/diffcore-break.ts +166 -0
- package/src/rename/index.ts +1 -0
- package/src/results/blame-format.ts +268 -43
- package/src/results/cherry-pick-result.ts +6 -0
- package/src/results/clone-result.ts +6 -0
- package/src/results/diff-dirstat.ts +117 -0
- package/src/results/diff-entry.ts +24 -0
- package/src/results/diff-formatter.ts +8 -4
- package/src/results/diff-output.ts +239 -8
- package/src/results/diff-pickaxe.ts +1 -1
- package/src/results/fetch-result.ts +24 -1
- package/src/results/index.ts +2 -0
- package/src/results/init-result.ts +10 -1
- package/src/results/line-range-hunks.ts +126 -0
- package/src/results/merge-result.ts +14 -0
- package/src/results/pull-result.ts +7 -0
- package/src/results/push-result.ts +10 -0
- package/src/results/rebase-result.ts +7 -0
- package/src/results/revert-result.ts +6 -0
- package/src/results/stash-result.ts +6 -0
- package/src/results/status-result.ts +2 -2
- package/src/transport-command.ts +216 -4
- package/dist/fsck-DLRpbwTj.js +0 -13405
- package/dist/results-TB2IJ64h.js +0 -4700
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import { GitCommand } from "../git-command.js";
|
|
24
24
|
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
25
25
|
import {
|
|
26
|
-
|
|
26
|
+
ContentMergeStrategy,
|
|
27
27
|
FastForwardMode,
|
|
28
28
|
type MergeResult,
|
|
29
29
|
MergeStatus,
|
|
@@ -48,6 +48,7 @@ import { commitsBaseSource, MergeBaseGraph } from "./merge-bases.js";
|
|
|
48
48
|
import { favorOf, MergeCommand } from "./merge-command.js";
|
|
49
49
|
import { configBool, configValue, conflictStyleOf } from "./merge-config.js";
|
|
50
50
|
import { ortConfigOptions } from "./merge-drivers.js";
|
|
51
|
+
import { quoteStrategyOptions, splitStrategyOptions } from "./merge-strategy-options.js";
|
|
51
52
|
import {
|
|
52
53
|
conflictsComment,
|
|
53
54
|
FlatTreeCache,
|
|
@@ -64,8 +65,8 @@ import {
|
|
|
64
65
|
import { CleanupMode, commentPrefixOf, stripspace } from "./message-cleanup.js";
|
|
65
66
|
import { copyNotesForAmend, copyNotesForRebase } from "./notes-support.js";
|
|
66
67
|
import { ortResultEntries } from "./ort-merge.js";
|
|
67
|
-
import { mergeBaseTree, mergeStoredTrees
|
|
68
|
-
import { type PatchIdTrees
|
|
68
|
+
import { mergeBaseTree, mergeStoredTrees } from "./ort-recursive.js";
|
|
69
|
+
import { PatchIds, type PatchIdTrees } from "./patch-id.js";
|
|
69
70
|
import { formatCommitPretty, loadRefDecorations, type RefDecorations } from "./pretty-format.js";
|
|
70
71
|
import {
|
|
71
72
|
addExecCommands,
|
|
@@ -90,7 +91,7 @@ import {
|
|
|
90
91
|
} from "./rebase-todo.js";
|
|
91
92
|
import { reflogMessages, updateHeadExpecting } from "./reflog-messages.js";
|
|
92
93
|
import { revisionMergeBases } from "./rev-parse-command.js";
|
|
93
|
-
import { expandCommitId } from "./sequencer-pick.js";
|
|
94
|
+
import { expandCommitId, mergePickChange } from "./sequencer-pick.js";
|
|
94
95
|
import {
|
|
95
96
|
AUTOSTASH_SAVED_LINES,
|
|
96
97
|
applyAutostash,
|
|
@@ -276,6 +277,17 @@ const WORKTREE_CHECK_BATCH = 32;
|
|
|
276
277
|
/** The state directory of git's merge backend. */
|
|
277
278
|
const DIR = "rebase-merge";
|
|
278
279
|
|
|
280
|
+
/** The state directory of git's apply backend (`git am --rebasing`'s). */
|
|
281
|
+
const APPLY_DIR = "rebase-apply";
|
|
282
|
+
|
|
283
|
+
/** sequencer.c's rebase_resolvemsg: the advice `git am --rebasing` gives where it stops. */
|
|
284
|
+
const REBASE_RESOLVEMSG = [
|
|
285
|
+
"Resolve all conflicts manually, mark them as resolved with",
|
|
286
|
+
'"git add/rm <conflicted_files>", then run "git rebase --continue".',
|
|
287
|
+
'You can instead skip this commit: run "git rebase --skip".',
|
|
288
|
+
'To abort and get back to the state before "git rebase", run "git rebase --abort".',
|
|
289
|
+
].join("\n");
|
|
290
|
+
|
|
279
291
|
/** sequencer.c's GIT_MAX_LABEL_LENGTH (NAME_MAX - ".lock" - 16) */
|
|
280
292
|
const MAX_LABEL_LENGTH = 255 - 5 - 16;
|
|
281
293
|
|
|
@@ -292,6 +304,8 @@ const sq = (value: string) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
|
292
304
|
* git's state (`.git/rebase-merge/`, `REBASE_HEAD`, `MERGE_MSG`, `AUTO_MERGE`), so native
|
|
293
305
|
* `git rebase --continue / --skip / --abort` resumes what we started, and we resume what
|
|
294
306
|
* native git started. A rebase is refused on unstaged or staged changes, as git refuses it.
|
|
307
|
+
* {@link RebaseCommand.setBackend}`("apply")` (`--apply`, also chosen by `--whitespace`/`-C`
|
|
308
|
+
* or `rebase.backend=apply`) runs git's am-based backend instead (`rebase-apply/`).
|
|
295
309
|
* With {@link RebaseCommand.setRebaseMerges} (`--rebase-merges`) the merges are kept: git's
|
|
296
310
|
* todo list of `label`, `reset` and `merge -C` commands, run as git's sequencer runs them.
|
|
297
311
|
*
|
|
@@ -309,7 +323,12 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
309
323
|
private upstreamCommit?: ObjectId;
|
|
310
324
|
private upstreamCommitName?: string;
|
|
311
325
|
private strategy = MergeStrategy.RECURSIVE;
|
|
326
|
+
private strategyGiven = false;
|
|
312
327
|
private contentStrategy?: ContentMergeStrategy;
|
|
328
|
+
/** `-X <option>`s */
|
|
329
|
+
private strategyOptions: string[] = [];
|
|
330
|
+
/** The run's `-s` and `-X` (rebase-merge/strategy, strategy_opts), once read */
|
|
331
|
+
private runStrategyState?: { strategy?: string; xopts: string[] };
|
|
313
332
|
private preserveMerges = false;
|
|
314
333
|
private interactiveHandler?: InteractiveHandler;
|
|
315
334
|
/** Whose messages to give where git 2.43 and 2.5x differ (default: the hooks') */
|
|
@@ -321,6 +340,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
321
340
|
private ignoreDate = false;
|
|
322
341
|
/** `--signoff` (kept in `rebase-merge/signoff`) */
|
|
323
342
|
private signoff = false;
|
|
343
|
+
/** `--[no-]rerere-autoupdate` (undefined: `rerere.autoUpdate`) */
|
|
344
|
+
private rerereAutoUpdate?: boolean;
|
|
345
|
+
/** What rerere printed on stderr during this run */
|
|
346
|
+
private readonly rerereLines: string[] = [];
|
|
324
347
|
/** `--force-rebase` (REBASE_FORCE) */
|
|
325
348
|
private forceRebase = false;
|
|
326
349
|
/** `-S[<keyid>]` / `--no-gpg-sign` (undefined: `commit.gpgSign`; kept in `gpg_sign_opt`) */
|
|
@@ -372,6 +395,65 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
372
395
|
private noVerify = false;
|
|
373
396
|
/** `--trailer` arguments (kept in `rebase-merge/trailer`, one per line) */
|
|
374
397
|
private trailerArgs: string[] = [];
|
|
398
|
+
/** `--apply` / `--merge` as given (undefined: implied by the options, else `rebase.backend`) */
|
|
399
|
+
private backend?: "apply" | "merge";
|
|
400
|
+
/** The death of `--apply` and `--merge` given together (in git's order of parsing) */
|
|
401
|
+
private backendConflict?: string;
|
|
402
|
+
/** `--whitespace=<action>`, passed to `git am` (apply backend) */
|
|
403
|
+
private whitespace?: string;
|
|
404
|
+
/** `-C<n>`, passed to `git am` (apply backend) */
|
|
405
|
+
private contextLines?: string;
|
|
406
|
+
/** `--ignore-whitespace`: am's `--ignore-whitespace`, or `-Xignore-space-change` */
|
|
407
|
+
private ignoreWhitespace = false;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* `--apply` / `--merge` (`-m`): the backend. `apply` is git's am-based one (`git
|
|
411
|
+
* format-patch | git am --rebasing`, its state in `rebase-apply/`): each commit's diff
|
|
412
|
+
* is applied as a patch, with the three-way fallback, so `--whitespace`, `-C` and
|
|
413
|
+
* `--ignore-whitespace` act as on `git am`; commits empty from the start and commits
|
|
414
|
+
* upstream already has are dropped, merges are flattened away. Options only the merge
|
|
415
|
+
* backend has (`-i`, `--exec`, `--empty`, `-s`/`-X`, `--rebase-merges`, `--update-refs`,
|
|
416
|
+
* `--autosquash`, `--root` without `--onto`, `--trailer`, `--[no-]reapply-cherry-picks`
|
|
417
|
+
* without `--keep-base`) are refused with it (`<option> requires the merge backend`).
|
|
418
|
+
* Without either, `--whitespace`/`-C` choose `apply`, the merge-only options `merge`,
|
|
419
|
+
* else `rebase.backend` (default `merge`).
|
|
420
|
+
*/
|
|
421
|
+
setBackend(backend: "apply" | "merge"): this {
|
|
422
|
+
this.checkCallable();
|
|
423
|
+
if (this.backend !== undefined && this.backend !== backend && !this.backendConflict) {
|
|
424
|
+
this.backendConflict = "fatal: apply options and merge options cannot be used together";
|
|
425
|
+
}
|
|
426
|
+
this.backend = backend;
|
|
427
|
+
return this;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* `--whitespace=<action>` (`nowarn`, `warn`, `fix`, `strip`, `error`, `error-all`): passed
|
|
432
|
+
* to `git am` and so `git apply`; it implies the apply backend. `fix` and `strip` rewrite
|
|
433
|
+
* every commit (no fast-forward when already up to date).
|
|
434
|
+
*/
|
|
435
|
+
setWhitespace(action: string): this {
|
|
436
|
+
this.checkCallable();
|
|
437
|
+
this.whitespace = action;
|
|
438
|
+
return this;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/** `-C<n>`: the context lines that must match, passed to `git am`; implies the apply backend. */
|
|
442
|
+
setContext(lines: number | string): this {
|
|
443
|
+
this.checkCallable();
|
|
444
|
+
this.contextLines = String(lines);
|
|
445
|
+
return this;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* `--ignore-whitespace`: with `--apply`, `git am --ignore-whitespace` (context lines
|
|
450
|
+
* compared ignoring whitespace); otherwise the merge backend's `-X ignore-space-change`.
|
|
451
|
+
*/
|
|
452
|
+
setIgnoreWhitespace(value: boolean): this {
|
|
453
|
+
this.checkCallable();
|
|
454
|
+
this.ignoreWhitespace = value;
|
|
455
|
+
return this;
|
|
456
|
+
}
|
|
375
457
|
|
|
376
458
|
/**
|
|
377
459
|
* `--trailer <token>[(=|:)<value>]` (git 2.46+): each rebased commit's message gets the
|
|
@@ -380,8 +462,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
380
462
|
* git, it implies `--force-rebase` and is kept in `rebase-merge/trailer` for `--continue`;
|
|
381
463
|
* an empty argument or one without a key is refused before anything is done, and under
|
|
382
464
|
* 2.43 compatibility the option itself (`error: unknown option \`trailer'`, exit 129).
|
|
383
|
-
*
|
|
384
|
-
* the merge backend.
|
|
465
|
+
* The apply backend refuses it (`--trailer requires the merge backend`).
|
|
385
466
|
*/
|
|
386
467
|
addTrailer(trailer: string): this {
|
|
387
468
|
this.checkCallable();
|
|
@@ -542,16 +623,71 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
542
623
|
}
|
|
543
624
|
|
|
544
625
|
/**
|
|
545
|
-
* Set the merge strategy (
|
|
626
|
+
* Set the merge strategy (`-s`): merge-ort (RECURSIVE, ORT), RESOLVE (git-merge-resolve)
|
|
627
|
+
* or SUBTREE (git merge-subtree) for each pick; kept in `rebase-merge/strategy`.
|
|
546
628
|
*
|
|
547
629
|
* @param strategy Merge strategy
|
|
548
630
|
*/
|
|
549
631
|
setStrategy(strategy: MergeStrategy): this {
|
|
550
632
|
this.checkCallable();
|
|
551
633
|
this.strategy = strategy;
|
|
634
|
+
this.strategyGiven = true;
|
|
635
|
+
return this;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* The `-X <option>`s of each pick (see `MergeCommand.setStrategyOptions`), kept in
|
|
640
|
+
* `rebase-merge/strategy_opts`; with no `-s`, the strategy is `ort` (builtin/rebase.c).
|
|
641
|
+
*/
|
|
642
|
+
setStrategyOptions(options: readonly string[]): this {
|
|
643
|
+
this.checkCallable();
|
|
644
|
+
this.strategyOptions = [...options];
|
|
645
|
+
return this;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/** Adds one `-X <option>` (see {@link setStrategyOptions}). */
|
|
649
|
+
addStrategyOption(option: string): this {
|
|
650
|
+
this.checkCallable();
|
|
651
|
+
this.strategyOptions.push(option);
|
|
552
652
|
return this;
|
|
553
653
|
}
|
|
554
654
|
|
|
655
|
+
/** The `-X` options as given: `-X ours`/`-X theirs` of the content strategy first. */
|
|
656
|
+
private givenStrategyOptions(): string[] {
|
|
657
|
+
const favor =
|
|
658
|
+
this.contentStrategy === ContentMergeStrategy.OURS
|
|
659
|
+
? ["ours"]
|
|
660
|
+
: this.contentStrategy === ContentMergeStrategy.THEIRS
|
|
661
|
+
? ["theirs"]
|
|
662
|
+
: [];
|
|
663
|
+
const space = this.ignoreWhitespace && this.backend !== "apply" ? ["ignore-space-change"] : [];
|
|
664
|
+
return [...favor, ...this.strategyOptions, ...space];
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/** The run's `-s` (`ort` when only `-X` was given) as builtin/rebase.c settles it. */
|
|
668
|
+
private givenStrategyName(): string | undefined {
|
|
669
|
+
if (this.strategyGiven) return this.strategy;
|
|
670
|
+
return this.givenStrategyOptions().length > 0 ? "ort" : undefined;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/** The run's `-s` and `-X`: read back from `rebase-merge/` (read_strategy_opts), else given. */
|
|
674
|
+
private async runStrategy(
|
|
675
|
+
state: OperationState,
|
|
676
|
+
): Promise<{ strategy: string | undefined; xopts: string[] }> {
|
|
677
|
+
if (!this.runStrategyState) {
|
|
678
|
+
const strategy = (await state.read(`${DIR}/strategy`))?.trim();
|
|
679
|
+
const opts = await state.read(`${DIR}/strategy_opts`);
|
|
680
|
+
this.runStrategyState =
|
|
681
|
+
strategy !== undefined || opts !== undefined
|
|
682
|
+
? {
|
|
683
|
+
...(strategy ? { strategy } : {}),
|
|
684
|
+
xopts: opts !== undefined ? splitStrategyOptions(opts.trim()) : [],
|
|
685
|
+
}
|
|
686
|
+
: { strategy: this.givenStrategyName(), xopts: this.givenStrategyOptions() };
|
|
687
|
+
}
|
|
688
|
+
return { strategy: this.runStrategyState.strategy, xopts: this.runStrategyState.xopts };
|
|
689
|
+
}
|
|
690
|
+
|
|
555
691
|
/**
|
|
556
692
|
* Get the merge strategy.
|
|
557
693
|
*/
|
|
@@ -688,6 +824,17 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
688
824
|
return this;
|
|
689
825
|
}
|
|
690
826
|
|
|
827
|
+
/**
|
|
828
|
+
* `--rerere-autoupdate` (true) / `--no-rerere-autoupdate` (false): whether resolutions
|
|
829
|
+
* rerere replays at a stopped pick are staged (default `rerere.autoUpdate`); kept in
|
|
830
|
+
* `rebase-merge/allow_rerere_autoupdate` for `--continue`.
|
|
831
|
+
*/
|
|
832
|
+
setRerereAutoUpdate(value: boolean): this {
|
|
833
|
+
this.checkCallable();
|
|
834
|
+
this.rerereAutoUpdate = value;
|
|
835
|
+
return this;
|
|
836
|
+
}
|
|
837
|
+
|
|
691
838
|
/**
|
|
692
839
|
* `-S` (true) / `--no-gpg-sign` (false): whether to sign the commits the rebase makes;
|
|
693
840
|
* undefined (the default) leaves it to `commit.gpgSign`. Kept in
|
|
@@ -875,7 +1022,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
875
1022
|
await this.readCurrentIndex();
|
|
876
1023
|
const worktree = this.worktreeAccess;
|
|
877
1024
|
const run = () => this.run(worktree);
|
|
878
|
-
|
|
1025
|
+
const result = await (worktree?.batch ? worktree.batch(run) : run());
|
|
1026
|
+
return this.rerereLines.length > 0
|
|
1027
|
+
? { ...result, rerereOutput: [...this.rerereLines] }
|
|
1028
|
+
: result;
|
|
879
1029
|
}
|
|
880
1030
|
|
|
881
1031
|
private async run(worktree: Worktree | undefined): Promise<RebaseResult> {
|
|
@@ -919,6 +1069,24 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
919
1069
|
}
|
|
920
1070
|
}
|
|
921
1071
|
|
|
1072
|
+
/**
|
|
1073
|
+
* The sequencer's `repo_rerere(r, opts->allow_rerere_auto)` at a stopped pick or merge:
|
|
1074
|
+
* `rebase-merge/allow_rerere_autoupdate` (`--[no-]rerere-autoupdate`), else
|
|
1075
|
+
* `rerere.autoUpdate`. Returns rerere's lines (kept for the result's `rerereOutput` too).
|
|
1076
|
+
*/
|
|
1077
|
+
private async pickRerere(state: OperationState): Promise<string[]> {
|
|
1078
|
+
const saved = (await state.read(`${DIR}/allow_rerere_autoupdate`))?.trim();
|
|
1079
|
+
const autoUpdate =
|
|
1080
|
+
saved === "--rerere-autoupdate"
|
|
1081
|
+
? true
|
|
1082
|
+
: saved === "--no-rerere-autoupdate"
|
|
1083
|
+
? false
|
|
1084
|
+
: undefined;
|
|
1085
|
+
const lines = await this.rerere(autoUpdate === undefined ? {} : { autoUpdate });
|
|
1086
|
+
this.rerereLines.push(...lines);
|
|
1087
|
+
return lines;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
922
1090
|
private context(worktree: Worktree | undefined) {
|
|
923
1091
|
return {
|
|
924
1092
|
workingCopy: this.workingCopy,
|
|
@@ -1193,13 +1361,22 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1193
1361
|
worktree: Worktree | undefined,
|
|
1194
1362
|
): Promise<RebaseResult> {
|
|
1195
1363
|
const forkPoint = this.checkBeginOptions();
|
|
1196
|
-
if (
|
|
1364
|
+
if (this.backendConflict) throw new GitApiError(this.backendConflict);
|
|
1365
|
+
const applyRunning = await this.applyInProgress(state);
|
|
1366
|
+
if (applyRunning === "am") {
|
|
1197
1367
|
return {
|
|
1198
1368
|
status: RebaseStatus.FAILED,
|
|
1199
|
-
message:
|
|
1200
|
-
|
|
1369
|
+
message: "fatal: It looks like 'git am' is in progress. Cannot rebase.",
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
if (applyRunning || (await this.inProgress(state))) {
|
|
1373
|
+
const dir = applyRunning ? APPLY_DIR : DIR;
|
|
1374
|
+
return {
|
|
1375
|
+
status: RebaseStatus.FAILED,
|
|
1376
|
+
message: `fatal: It seems that there is already a ${dir} directory, and\nI wonder if you are in the middle of another rebase. If that is the\ncase, please try\n\tgit rebase (--continue | --abort | --skip)\nIf that is not the case, please\n\trm -fr ".git/${dir}"\nand run me again. I am stopping in case you still have something\nvaluable there.`,
|
|
1201
1377
|
};
|
|
1202
1378
|
}
|
|
1379
|
+
const backend = this.settleBackend();
|
|
1203
1380
|
// check_exec_cmd
|
|
1204
1381
|
for (const command of this.execCommands) {
|
|
1205
1382
|
if (command.includes("\n")) {
|
|
@@ -1286,7 +1463,12 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1286
1463
|
this.ignoreDate ||
|
|
1287
1464
|
this.signoff ||
|
|
1288
1465
|
this.trailerArgs.length > 0;
|
|
1289
|
-
const preemptive =
|
|
1466
|
+
const preemptive =
|
|
1467
|
+
!interactive &&
|
|
1468
|
+
execs.length === 0 &&
|
|
1469
|
+
this.autosquash !== true &&
|
|
1470
|
+
this.whitespace !== "fix" &&
|
|
1471
|
+
this.whitespace !== "strip";
|
|
1290
1472
|
if (preemptive && (await this.canFastForward(onto, upstream, restrict, origHead, branchBase))) {
|
|
1291
1473
|
const upToDate =
|
|
1292
1474
|
branchName === "HEAD" ? "HEAD is up to date" : `Current branch ${branchName} is up to date`;
|
|
@@ -1324,6 +1506,22 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1324
1506
|
}
|
|
1325
1507
|
}
|
|
1326
1508
|
|
|
1509
|
+
if (backend === "apply") {
|
|
1510
|
+
return this.beginApply(state, worktree, {
|
|
1511
|
+
headId,
|
|
1512
|
+
origHead,
|
|
1513
|
+
headName,
|
|
1514
|
+
branchName,
|
|
1515
|
+
onto,
|
|
1516
|
+
ontoName,
|
|
1517
|
+
base: upstream ?? onto,
|
|
1518
|
+
restrict,
|
|
1519
|
+
branchBase,
|
|
1520
|
+
autostash,
|
|
1521
|
+
output,
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1327
1525
|
const headTree = await flatTree(this.trees, await this.commits.getTree(headId));
|
|
1328
1526
|
const ontoTreeId = await this.commits.getTree(onto);
|
|
1329
1527
|
const ontoTree = await flatTree(this.trees, ontoTreeId);
|
|
@@ -1431,11 +1629,24 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1431
1629
|
await state.write(`${DIR}/head-name`, `${headName}\n`);
|
|
1432
1630
|
await state.write(`${DIR}/onto`, `${onto}\n`);
|
|
1433
1631
|
await state.write(`${DIR}/orig-head`, `${origHead}\n`);
|
|
1632
|
+
// write_basic_state: strategy, strategy_opts
|
|
1633
|
+
const strategyName = this.givenStrategyName();
|
|
1634
|
+
if (strategyName) await state.write(`${DIR}/strategy`, `${strategyName}\n`);
|
|
1635
|
+
const xopts = this.givenStrategyOptions();
|
|
1636
|
+
if (xopts.length > 0) {
|
|
1637
|
+
await state.write(`${DIR}/strategy_opts`, `${quoteStrategyOptions(xopts)}\n`);
|
|
1638
|
+
}
|
|
1434
1639
|
// write_basic_state: gpg_sign_opt (`-S<key>`) when the run signs
|
|
1435
1640
|
const sign = signRequestOf(this.workingCopy, this.sign);
|
|
1436
1641
|
this.runSign = { key: sign };
|
|
1437
1642
|
if (sign !== undefined) await state.write(`${DIR}/gpg_sign_opt`, `-S${sign}\n`);
|
|
1438
1643
|
if (this.signoff) await state.write(`${DIR}/signoff`, "--signoff\n");
|
|
1644
|
+
if (this.rerereAutoUpdate !== undefined) {
|
|
1645
|
+
await state.write(
|
|
1646
|
+
`${DIR}/allow_rerere_autoupdate`,
|
|
1647
|
+
`--${this.rerereAutoUpdate ? "" : "no-"}rerere-autoupdate\n`,
|
|
1648
|
+
);
|
|
1649
|
+
}
|
|
1439
1650
|
if (emptyMode === "drop") await state.write(`${DIR}/drop_redundant_commits`, "");
|
|
1440
1651
|
if (emptyMode === "keep") await state.write(`${DIR}/keep_redundant_commits`, "");
|
|
1441
1652
|
if (this.committerDateIsAuthorDate) await state.write(`${DIR}/cdate_is_adate`, "");
|
|
@@ -1989,34 +2200,48 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1989
2200
|
const short = await this.abbreviateObjectId(item.id);
|
|
1990
2201
|
const label = `${short} (${subject})`;
|
|
1991
2202
|
const baseLabel = parentId ? `parent of ${label}` : "(empty tree)";
|
|
1992
|
-
// the trees as merge-ort reads them: what all three hold alike is never read
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
headTreeId,
|
|
1997
|
-
commit.tree,
|
|
2203
|
+
// the trees as merge-ort reads them: what all three hold alike is never read; `-s`
|
|
2204
|
+
// and `-X` as the sequencer gives them to the pick
|
|
2205
|
+
const { strategy, xopts } = await this.runStrategy(state);
|
|
2206
|
+
const merge = await mergePickChange(
|
|
1998
2207
|
{
|
|
1999
|
-
|
|
2000
|
-
|
|
2208
|
+
...this.context(worktree),
|
|
2209
|
+
commits: this.commits,
|
|
2210
|
+
flats,
|
|
2211
|
+
abbreviate: (id) => this.abbreviateObjectId(id),
|
|
2212
|
+
},
|
|
2213
|
+
{
|
|
2214
|
+
action: "pick",
|
|
2215
|
+
headId,
|
|
2216
|
+
headTreeId,
|
|
2217
|
+
base: parentTreeId,
|
|
2218
|
+
theirs: commit.tree,
|
|
2001
2219
|
baseLabel,
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2220
|
+
theirsLabel: label,
|
|
2221
|
+
pickId: item.id,
|
|
2222
|
+
parentId,
|
|
2223
|
+
strategy,
|
|
2224
|
+
xopts,
|
|
2225
|
+
oursLabel: "HEAD",
|
|
2226
|
+
favor: this.contentStrategy === ContentMergeStrategy.UNION ? "union" : undefined,
|
|
2227
|
+
compatibility: this.compatibility ?? this.hooks.compatibility ?? "2.56",
|
|
2006
2228
|
},
|
|
2007
|
-
(id) => flats.get(id),
|
|
2008
2229
|
);
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2230
|
+
if ("failed" in merge) {
|
|
2231
|
+
output.push(...(merge.output ?? []));
|
|
2232
|
+
return {
|
|
2233
|
+
kind: "reschedule",
|
|
2234
|
+
result: { status: RebaseStatus.FAILED, currentCommit: item.id, message: merge.failed },
|
|
2235
|
+
};
|
|
2236
|
+
}
|
|
2237
|
+
const { treeId, conflicts } = merge;
|
|
2013
2238
|
// only the paths HEAD and the result differ on are switched
|
|
2014
|
-
const delta = await treeDelta(this.trees, headTreeId, treeId);
|
|
2239
|
+
const delta = merge.delta ?? (await treeDelta(this.trees, headTreeId, treeId));
|
|
2015
2240
|
const refused = await switchTrees(this.context(worktree), delta.from, delta.to, {
|
|
2016
2241
|
action: "merge",
|
|
2017
2242
|
operation: "rebase",
|
|
2018
2243
|
conflicts,
|
|
2019
|
-
targetTree: treeId,
|
|
2244
|
+
...(merge.delta ? {} : { targetTree: treeId }),
|
|
2020
2245
|
});
|
|
2021
2246
|
if (refused) {
|
|
2022
2247
|
// nothing written: the pick is rescheduled (git keeps the author and REBASE_HEAD)
|
|
@@ -2031,13 +2256,18 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2031
2256
|
},
|
|
2032
2257
|
};
|
|
2033
2258
|
}
|
|
2034
|
-
// the sequencer shows merge-ort's messages of a rebase only when the pick conflicts
|
|
2035
|
-
|
|
2036
|
-
|
|
2259
|
+
// the sequencer shows merge-ort's messages of a rebase only when the pick conflicts (an
|
|
2260
|
+
// external strategy prints its own)
|
|
2261
|
+
if (merge.external || conflicts.length > 0 || !merge.clean) output.push(...merge.messages);
|
|
2262
|
+
if (merge.autoMerge) await state.setRef("AUTO_MERGE", treeId);
|
|
2037
2263
|
const merged = pickedMessage.endsWith("\n") ? pickedMessage : `${pickedMessage}\n`;
|
|
2038
2264
|
if (conflicts.length > 0 || !merge.clean) {
|
|
2039
2265
|
const paths = [...new Set(conflicts.map((c) => c.stagePath))].sort(compareGitPaths);
|
|
2040
|
-
|
|
2266
|
+
// do_recursive_merge adds the conflicts hint; another strategy's MERGE_MSG has none
|
|
2267
|
+
await state.write(
|
|
2268
|
+
"MERGE_MSG",
|
|
2269
|
+
merge.external ? merged : `${merged}${conflictsComment(paths, true)}`,
|
|
2270
|
+
);
|
|
2041
2271
|
if (!fixup) {
|
|
2042
2272
|
// do_pick_commit writes CHERRY_PICK_HEAD after a conflicted merge too; the rebase
|
|
2043
2273
|
// stopping there deletes it again (REBASE_HEAD names the commit instead)
|
|
@@ -2045,10 +2275,19 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2045
2275
|
}
|
|
2046
2276
|
return {
|
|
2047
2277
|
kind: "conflicts",
|
|
2048
|
-
conflicts: [...new Set(merge.
|
|
2049
|
-
// git 2.43 writes the message and a blank line (2.5x the conflict list after it
|
|
2050
|
-
|
|
2051
|
-
|
|
2278
|
+
conflicts: [...new Set(merge.conflictPaths)].sort(),
|
|
2279
|
+
// git 2.43 writes the message and a blank line (2.5x the conflict list after it, which
|
|
2280
|
+
// another strategy than merge-ort does not add)
|
|
2281
|
+
message:
|
|
2282
|
+
!merge.external || (this.compatibility ?? this.hooks.compatibility) === "2.43"
|
|
2283
|
+
? `${merged}\n`
|
|
2284
|
+
: merged,
|
|
2285
|
+
lines: [
|
|
2286
|
+
`error: could not apply ${short}... ${subject}`,
|
|
2287
|
+
...this.mergeConflictAdvice(),
|
|
2288
|
+
// do_pick_commit's repo_rerere, after the advice
|
|
2289
|
+
...(await this.pickRerere(state)),
|
|
2290
|
+
],
|
|
2052
2291
|
};
|
|
2053
2292
|
}
|
|
2054
2293
|
await state.write("MERGE_MSG", pickedMessage);
|
|
@@ -2722,11 +2961,16 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2722
2961
|
await state.write(`${DIR}/patch`, "");
|
|
2723
2962
|
}
|
|
2724
2963
|
const short = item.id ? await this.abbreviateObjectId(item.id) : "";
|
|
2964
|
+
// do_merge's repo_rerere, before the stop is reported
|
|
2965
|
+
const rerere = await this.pickRerere(state);
|
|
2725
2966
|
return {
|
|
2726
2967
|
status: RebaseStatus.STOPPED,
|
|
2727
2968
|
...(item.id ? { currentCommit: item.id } : {}),
|
|
2728
2969
|
conflicts: [...new Set(merge.conflicts.keys())].sort(),
|
|
2729
|
-
message:
|
|
2970
|
+
message: [
|
|
2971
|
+
...rerere,
|
|
2972
|
+
item.id ? `Could not apply ${short}... ${arg}` : `Could not merge ${arg}`,
|
|
2973
|
+
].join("\n"),
|
|
2730
2974
|
};
|
|
2731
2975
|
}
|
|
2732
2976
|
// git commit -n -F MERGE_MSG --cleanup=verbatim (whitespace with --signoff, which the
|
|
@@ -2820,6 +3064,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2820
3064
|
};
|
|
2821
3065
|
}
|
|
2822
3066
|
output.push(...(result.output ?? []));
|
|
3067
|
+
// git merge's suggest_conflicts runs rerere (no --rerere-autoupdate passed to it)
|
|
3068
|
+
if (result.status === MergeStatus.CONFLICTING) this.rerereLines.push(...(await this.rerere()));
|
|
2823
3069
|
if (result.status === MergeStatus.MERGED || result.status === MergeStatus.ALREADY_UP_TO_DATE) {
|
|
2824
3070
|
// remove_merge_branch_state
|
|
2825
3071
|
await state.remove("MERGE_MSG", "MERGE_HEAD", "MERGE_MODE");
|
|
@@ -3214,7 +3460,10 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3214
3460
|
state: OperationState,
|
|
3215
3461
|
worktree: Worktree | undefined,
|
|
3216
3462
|
): Promise<RebaseResult> {
|
|
3217
|
-
|
|
3463
|
+
const apply = await this.applyInProgress(state);
|
|
3464
|
+
if (apply === "am")
|
|
3465
|
+
throw new GitApiError("fatal: It looks like 'git am' is in progress. Cannot rebase.");
|
|
3466
|
+
if (!apply && !(await this.inProgress(state))) throw new NoRebaseInProgressError();
|
|
3218
3467
|
const { unmerged } = await readIndex(this.staging);
|
|
3219
3468
|
if (unmerged.length > 0) {
|
|
3220
3469
|
// builtin/rebase.c: refresh_index's `<path>: needs merge`, then has_unstaged_changes
|
|
@@ -3245,6 +3494,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3245
3494
|
};
|
|
3246
3495
|
}
|
|
3247
3496
|
}
|
|
3497
|
+
if (apply) return this.resumeApply(state, worktree, "continue");
|
|
3248
3498
|
return this.resume(state, worktree);
|
|
3249
3499
|
}
|
|
3250
3500
|
|
|
@@ -3459,6 +3709,8 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3459
3709
|
}
|
|
3460
3710
|
// git commit's cleanup (SQUASH_MSG of a final squash too), then commit_staged_changes'
|
|
3461
3711
|
await state.remove(`${DIR}/amend`, "MERGE_HEAD", "MERGE_MODE", "MERGE_MSG", "SQUASH_MSG");
|
|
3712
|
+
// git commit's repo_rerere: the resolutions recorded
|
|
3713
|
+
this.rerereLines.push(...(await this.rerere()));
|
|
3462
3714
|
await state.removeRef("CHERRY_PICK_HEAD");
|
|
3463
3715
|
// commit_staged_changes deletes AUTO_MERGE once git commit is done, whether it exists
|
|
3464
3716
|
await state.deleteRef("AUTO_MERGE");
|
|
@@ -3469,7 +3721,11 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3469
3721
|
|
|
3470
3722
|
/** `git rebase --skip`: the stopped pick dropped (`reset --hard`), then as `--continue`. */
|
|
3471
3723
|
private async skip(state: OperationState, worktree: Worktree | undefined): Promise<RebaseResult> {
|
|
3472
|
-
|
|
3724
|
+
const apply = await this.applyInProgress(state);
|
|
3725
|
+
if (apply === "am")
|
|
3726
|
+
throw new GitApiError("fatal: It looks like 'git am' is in progress. Cannot rebase.");
|
|
3727
|
+
if (!apply && !(await this.inProgress(state))) throw new NoRebaseInProgressError();
|
|
3728
|
+
await this.rerereClear();
|
|
3473
3729
|
const headId = await this.resolveHead();
|
|
3474
3730
|
const refused = await resetMerge(this.context(worktree), headId, "HEAD", { hard: true });
|
|
3475
3731
|
if (refused) {
|
|
@@ -3481,9 +3737,279 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3481
3737
|
// remove_branch_state (REBASE_HEAD stays: the next command removes it, so a skip of the
|
|
3482
3738
|
// last one leaves it, as git does); AUTO_MERGE deleted twice, as git's hook hears it
|
|
3483
3739
|
await removeBranchState(this.context(worktree), state);
|
|
3740
|
+
if (apply) return this.resumeApply(state, worktree, "skip");
|
|
3484
3741
|
return this.resume(state, worktree);
|
|
3485
3742
|
}
|
|
3486
3743
|
|
|
3744
|
+
/**
|
|
3745
|
+
* The apply backend's session found as cmd_rebase finds it: `rebase-apply/` (a rebase),
|
|
3746
|
+
* `am` when it holds `applying` (git am's), else false.
|
|
3747
|
+
*/
|
|
3748
|
+
private async applyInProgress(state: OperationState): Promise<false | "rebase" | "am"> {
|
|
3749
|
+
if (!(await state.exists(APPLY_DIR))) return false;
|
|
3750
|
+
return (await state.exists(`${APPLY_DIR}/applying`)) ? "am" : "rebase";
|
|
3751
|
+
}
|
|
3752
|
+
|
|
3753
|
+
/**
|
|
3754
|
+
* cmd_rebase's choice of backend: `--apply`/`--merge` as given, the options only one
|
|
3755
|
+
* backend has (imply_merge dies on an explicit `--apply`), the am options (`--whitespace`,
|
|
3756
|
+
* `-C`) choosing `apply`, then `rebase.backend`.
|
|
3757
|
+
*/
|
|
3758
|
+
private settleBackend(): "apply" | "merge" {
|
|
3759
|
+
const die = (message: string) => new GitApiError(`fatal: ${message}`);
|
|
3760
|
+
let type = this.backend ?? (this.interactiveHandler ? "merge" : undefined);
|
|
3761
|
+
if (this.backend === "apply" && this.interactiveHandler) {
|
|
3762
|
+
throw die("apply options and merge options cannot be used together");
|
|
3763
|
+
}
|
|
3764
|
+
if (this.contextLines !== undefined && !/^\d*$/.test(this.contextLines)) {
|
|
3765
|
+
throw die("switch `C' expects a numerical value");
|
|
3766
|
+
}
|
|
3767
|
+
const ws = this.whitespace;
|
|
3768
|
+
if (
|
|
3769
|
+
ws !== undefined &&
|
|
3770
|
+
!["", "fix", "strip", "warn", "nowarn", "error", "error-all"].includes(ws)
|
|
3771
|
+
) {
|
|
3772
|
+
throw die(`Invalid whitespace option: '${ws}'`);
|
|
3773
|
+
}
|
|
3774
|
+
const implyMerge = (option: string) => {
|
|
3775
|
+
if (type === "apply") throw die(`${option} requires the merge backend`);
|
|
3776
|
+
type = "merge";
|
|
3777
|
+
};
|
|
3778
|
+
if (this.emptyMode !== undefined) implyMerge("--empty");
|
|
3779
|
+
if (this.reapplyCherryPicks !== undefined && !this.keepBase) {
|
|
3780
|
+
implyMerge(this.reapplyCherryPicks ? "--reapply-cherry-picks" : "--no-reapply-cherry-picks");
|
|
3781
|
+
}
|
|
3782
|
+
if (this.execCommands.length > 0) implyMerge("--exec");
|
|
3783
|
+
if (this.givenStrategyName() !== undefined) implyMerge("--strategy");
|
|
3784
|
+
if (this.root && this.ontoName === undefined && this.upstreamCommit === undefined) {
|
|
3785
|
+
implyMerge("--root without --onto");
|
|
3786
|
+
}
|
|
3787
|
+
if (this.trailerArgs.length > 0) implyMerge("--trailer");
|
|
3788
|
+
const amOptions = this.whitespace !== undefined || this.contextLines !== undefined;
|
|
3789
|
+
if (amOptions || type === "apply") {
|
|
3790
|
+
if (type === "merge") throw die("apply options and merge options cannot be used together");
|
|
3791
|
+
if (
|
|
3792
|
+
this.rebaseMerges === undefined &&
|
|
3793
|
+
configBool(this.workingCopy, "rebase.rebaseMerges", false)
|
|
3794
|
+
) {
|
|
3795
|
+
throw die(
|
|
3796
|
+
"apply options are incompatible with rebase.rebaseMerges. Consider adding --no-rebase-merges",
|
|
3797
|
+
);
|
|
3798
|
+
}
|
|
3799
|
+
if (
|
|
3800
|
+
this.updateRefs === undefined &&
|
|
3801
|
+
configBool(this.workingCopy, "rebase.updateRefs", false)
|
|
3802
|
+
) {
|
|
3803
|
+
throw die(
|
|
3804
|
+
"apply options are incompatible with rebase.updateRefs. Consider adding --no-update-refs",
|
|
3805
|
+
);
|
|
3806
|
+
}
|
|
3807
|
+
type = "apply";
|
|
3808
|
+
}
|
|
3809
|
+
if (this.updateRefs === true) implyMerge("--update-refs");
|
|
3810
|
+
if (this.rebaseMerges === true) implyMerge("--rebase-merges");
|
|
3811
|
+
if (this.autosquash === true) implyMerge("--autosquash");
|
|
3812
|
+
if (type === undefined) {
|
|
3813
|
+
const configured = configValue(this.workingCopy, "rebase.backend") ?? "merge";
|
|
3814
|
+
if (configured === "merge") type = "merge";
|
|
3815
|
+
else if (configured === "apply") type = "apply";
|
|
3816
|
+
else throw die(`Unknown rebase backend: ${configured}`);
|
|
3817
|
+
}
|
|
3818
|
+
if (this.rescheduleFailedExec === true && type !== "merge") {
|
|
3819
|
+
throw die("--reschedule-failed-exec requires --exec or --interactive");
|
|
3820
|
+
}
|
|
3821
|
+
this.backend = type;
|
|
3822
|
+
return type;
|
|
3823
|
+
}
|
|
3824
|
+
|
|
3825
|
+
/**
|
|
3826
|
+
* The apply backend from HEAD's start on (cmd_rebase after the pre-rebase hook, then
|
|
3827
|
+
* run_am): HEAD detached at onto (`rebase (start): checkout <onto>`, ORIG_HEAD the branch,
|
|
3828
|
+
* post-checkout told), the commits upstream lacks (merges, commits empty from the start
|
|
3829
|
+
* and those upstream has a copy of left out, as `format-patch --cherry-pick
|
|
3830
|
+
* --right-only` lists them) applied by `git am --rebasing`, then the branch moved back
|
|
3831
|
+
* (`move_to_original_branch`) and the state removed; a stop keeps `rebase-apply/` with
|
|
3832
|
+
* the rebase's own files (`rebase_write_basic_state`).
|
|
3833
|
+
*/
|
|
3834
|
+
private async beginApply(
|
|
3835
|
+
state: OperationState,
|
|
3836
|
+
worktree: Worktree | undefined,
|
|
3837
|
+
run: {
|
|
3838
|
+
headId: ObjectId;
|
|
3839
|
+
origHead: ObjectId;
|
|
3840
|
+
headName: string;
|
|
3841
|
+
branchName: string;
|
|
3842
|
+
onto: ObjectId;
|
|
3843
|
+
ontoName: string;
|
|
3844
|
+
base: ObjectId;
|
|
3845
|
+
restrict?: ObjectId;
|
|
3846
|
+
branchBase?: ObjectId;
|
|
3847
|
+
autostash?: ObjectId;
|
|
3848
|
+
output: string[];
|
|
3849
|
+
},
|
|
3850
|
+
): Promise<RebaseResult> {
|
|
3851
|
+
const { headId, origHead, headName, onto, output } = run;
|
|
3852
|
+
const unstash = async () => {
|
|
3853
|
+
if (run.autostash) {
|
|
3854
|
+
output.push(...(await applyAutostash(this.context(worktree), run.autostash)));
|
|
3855
|
+
}
|
|
3856
|
+
};
|
|
3857
|
+
output.push("First, rewinding head to replay your work on top of it...");
|
|
3858
|
+
const headTree = await flatTree(this.trees, await this.commits.getTree(headId));
|
|
3859
|
+
const ontoTreeId = await this.commits.getTree(onto);
|
|
3860
|
+
const ontoTree = await flatTree(this.trees, ontoTreeId);
|
|
3861
|
+
const refused = await switchTrees(this.context(worktree), headTree, ontoTree, {
|
|
3862
|
+
action: "checkout",
|
|
3863
|
+
operation: "rebase",
|
|
3864
|
+
targetTree: ontoTreeId,
|
|
3865
|
+
});
|
|
3866
|
+
if (refused) {
|
|
3867
|
+
await unstash();
|
|
3868
|
+
return {
|
|
3869
|
+
status: RebaseStatus.FAILED,
|
|
3870
|
+
message: `${refused.message}\nerror: Could not detach HEAD`,
|
|
3871
|
+
output,
|
|
3872
|
+
};
|
|
3873
|
+
}
|
|
3874
|
+
await state.setRef("ORIG_HEAD", origHead);
|
|
3875
|
+
await this.refsStore.set("HEAD", onto, this.startLog());
|
|
3876
|
+
await runPostCheckoutHook(this.hooks, headId, onto, true);
|
|
3877
|
+
if (run.autostash) await state.write(`${APPLY_DIR}/autostash`, `${run.autostash}\n`);
|
|
3878
|
+
const basic = { headName, onto, origHead };
|
|
3879
|
+
// onto a proper descendant of the branch: it was a fast-forward
|
|
3880
|
+
if (run.branchBase === origHead) {
|
|
3881
|
+
output.push(`Fast-forwarded ${run.branchName} to ${run.ontoName}.`);
|
|
3882
|
+
return this.finishApply(state, worktree, basic, output);
|
|
3883
|
+
}
|
|
3884
|
+
// format-patch's list: no merges, no commits empty from the start, none upstream has
|
|
3885
|
+
const excluded = [run.base, run.restrict].filter((id): id is ObjectId => id !== undefined);
|
|
3886
|
+
const range = await this.commitsToRebase(origHead, excluded, false);
|
|
3887
|
+
const skipped = await this.appliedUpstream(origHead, run.base, range, run.restrict);
|
|
3888
|
+
const ids: ObjectId[] = [];
|
|
3889
|
+
for (const id of range) {
|
|
3890
|
+
if (!skipped.has(id) && !(await this.originallyEmpty(id))) ids.push(id);
|
|
3891
|
+
}
|
|
3892
|
+
// `git am --rebasing` reads nothing of a mail but its `From <id>` line (the commit gives
|
|
3893
|
+
// the author, the message and the diff), so the mails carry only that
|
|
3894
|
+
const mbox = ids.map((id) => `From ${id} Mon Sep 17 00:00:00 2001\n\n`).join("");
|
|
3895
|
+
const am = this.amForRebase()
|
|
3896
|
+
.addMbox(mbox)
|
|
3897
|
+
.setPatchFormat("mboxrd")
|
|
3898
|
+
.setApplyOptions({
|
|
3899
|
+
...(this.contextLines !== undefined ? { context: Number(this.contextLines || "0") } : {}),
|
|
3900
|
+
...(this.whitespace !== undefined ? { whitespace: this.whitespace } : {}),
|
|
3901
|
+
...(this.ignoreWhitespace ? { ignoreWhitespace: true } : {}),
|
|
3902
|
+
})
|
|
3903
|
+
.setIgnoreDate(this.ignoreDate)
|
|
3904
|
+
.setCommitterDateIsAuthorDate(this.committerDateIsAuthorDate)
|
|
3905
|
+
.setSignoff(this.signoff);
|
|
3906
|
+
if (this.rerereAutoUpdate !== undefined) am.setRerereAutoUpdate(this.rerereAutoUpdate);
|
|
3907
|
+
return this.runAmForRebase(state, worktree, am, basic, output, true);
|
|
3908
|
+
}
|
|
3909
|
+
|
|
3910
|
+
/** `git am --rebasing`'s command as run_am starts it (`GIT_REFLOG_ACTION=rebase (pick)`). */
|
|
3911
|
+
private amForRebase(): AmCommand {
|
|
3912
|
+
const am = new AmCommand(this.workingCopy)
|
|
3913
|
+
.shareHooksOf(this)
|
|
3914
|
+
.setRebasing(true)
|
|
3915
|
+
.setResolveMessage(REBASE_RESOLVEMSG)
|
|
3916
|
+
.setReflogAction(`${this.reflogAction("rebase")} (pick)`)
|
|
3917
|
+
.setLegacyMessages((this.compatibility ?? this.hooks.compatibility) === "2.43");
|
|
3918
|
+
if (typeof this.sign === "string") am.setSigningKey(this.sign);
|
|
3919
|
+
else am.setSign(this.sign);
|
|
3920
|
+
if (this.committer) am.setCommitter(this.committer);
|
|
3921
|
+
return am;
|
|
3922
|
+
}
|
|
3923
|
+
|
|
3924
|
+
/**
|
|
3925
|
+
* run_am's end: am's lines given on, the branch moved back and the state removed when it
|
|
3926
|
+
* applied everything, else (a new run) the rebase's state written beside am's.
|
|
3927
|
+
*/
|
|
3928
|
+
private async runAmForRebase(
|
|
3929
|
+
state: OperationState,
|
|
3930
|
+
worktree: Worktree | undefined,
|
|
3931
|
+
am: AmCommand,
|
|
3932
|
+
basic: { headName: string; onto: ObjectId; origHead: ObjectId },
|
|
3933
|
+
output: string[],
|
|
3934
|
+
writeBasicState: boolean,
|
|
3935
|
+
): Promise<RebaseResult> {
|
|
3936
|
+
const result = await am.call();
|
|
3937
|
+
const lines = (text: string) => text.split("\n").filter((l) => l !== "");
|
|
3938
|
+
output.push(...lines(result.output), ...lines(result.errors));
|
|
3939
|
+
if (result.exitCode === 0) return this.finishApply(state, worktree, basic, output);
|
|
3940
|
+
if (writeBasicState && (await state.exists(APPLY_DIR))) {
|
|
3941
|
+
// rebase_write_basic_state
|
|
3942
|
+
await state.write(`${APPLY_DIR}/head-name`, `${basic.headName}\n`);
|
|
3943
|
+
await state.write(`${APPLY_DIR}/onto`, `${basic.onto}\n`);
|
|
3944
|
+
await state.write(`${APPLY_DIR}/orig-head`, `${basic.origHead}\n`);
|
|
3945
|
+
if (this.rerereAutoUpdate !== undefined) {
|
|
3946
|
+
await state.write(
|
|
3947
|
+
`${APPLY_DIR}/allow_rerere_autoupdate`,
|
|
3948
|
+
`--${this.rerereAutoUpdate ? "" : "no-"}rerere-autoupdate\n`,
|
|
3949
|
+
);
|
|
3950
|
+
}
|
|
3951
|
+
const sign = signRequestOf(this.workingCopy, this.sign);
|
|
3952
|
+
if (sign !== undefined) await state.write(`${APPLY_DIR}/gpg_sign_opt`, `-S${sign}\n`);
|
|
3953
|
+
if (this.signoff) await state.write(`${APPLY_DIR}/signoff`, "--signoff\n");
|
|
3954
|
+
}
|
|
3955
|
+
const { unmerged } = await readIndex(this.staging);
|
|
3956
|
+
return {
|
|
3957
|
+
status: RebaseStatus.STOPPED,
|
|
3958
|
+
...(unmerged.length > 0 ? { conflicts: [...new Set(unmerged)] } : {}),
|
|
3959
|
+
output,
|
|
3960
|
+
};
|
|
3961
|
+
}
|
|
3962
|
+
|
|
3963
|
+
/**
|
|
3964
|
+
* `--continue` (`git am --resolved`) and `--skip` (`git am --skip`) of the apply backend,
|
|
3965
|
+
* the state read back as read_basic_state reads it.
|
|
3966
|
+
*/
|
|
3967
|
+
private async resumeApply(
|
|
3968
|
+
state: OperationState,
|
|
3969
|
+
worktree: Worktree | undefined,
|
|
3970
|
+
mode: "continue" | "skip",
|
|
3971
|
+
): Promise<RebaseResult> {
|
|
3972
|
+
const headName = (await state.read(`${APPLY_DIR}/head-name`))?.trim();
|
|
3973
|
+
const onto = (await state.read(`${APPLY_DIR}/onto`))?.trim();
|
|
3974
|
+
const origHead =
|
|
3975
|
+
(await state.read(`${APPLY_DIR}/orig-head`))?.trim() ??
|
|
3976
|
+
(await state.read(`${APPLY_DIR}/head`))?.trim();
|
|
3977
|
+
if (headName === undefined || !onto || !origHead) {
|
|
3978
|
+
return { status: RebaseStatus.FAILED, message: "error: could not read rebase-apply state" };
|
|
3979
|
+
}
|
|
3980
|
+
const saved = (await state.read(`${APPLY_DIR}/allow_rerere_autoupdate`))?.trim();
|
|
3981
|
+
if (saved === "--rerere-autoupdate") this.rerereAutoUpdate = true;
|
|
3982
|
+
else if (saved === "--no-rerere-autoupdate") this.rerereAutoUpdate = false;
|
|
3983
|
+
// run_am: `--resolved` gets the run's gpg_sign_opt (read_basic_state), `--skip` none
|
|
3984
|
+
if (mode === "continue" && this.sign === undefined) {
|
|
3985
|
+
const saved = (await state.read(`${APPLY_DIR}/gpg_sign_opt`))?.trim();
|
|
3986
|
+
if (saved?.startsWith("-S")) this.sign = saved.length > 2 ? saved.slice(2) : true;
|
|
3987
|
+
}
|
|
3988
|
+
const am = this.amForRebase().setResume(mode === "continue" ? "resolved" : "skip");
|
|
3989
|
+
if (mode === "skip") am.setSign(undefined);
|
|
3990
|
+
return this.runAmForRebase(state, worktree, am, { headName, onto, origHead }, [], false);
|
|
3991
|
+
}
|
|
3992
|
+
|
|
3993
|
+
/**
|
|
3994
|
+
* move_to_original_branch and finish_rebase: the branch at HEAD and HEAD on it again,
|
|
3995
|
+
* REBASE_HEAD and AUTO_MERGE deleted, the autostash applied, `rebase-apply/` removed.
|
|
3996
|
+
*/
|
|
3997
|
+
private async finishApply(
|
|
3998
|
+
state: OperationState,
|
|
3999
|
+
worktree: Worktree | undefined,
|
|
4000
|
+
basic: { headName: string; onto: ObjectId },
|
|
4001
|
+
output: string[],
|
|
4002
|
+
): Promise<RebaseResult> {
|
|
4003
|
+
const head = await this.resolveHead();
|
|
4004
|
+
if (basic.headName.startsWith("refs/"))
|
|
4005
|
+
await this.finishBranch(basic.headName, head, basic.onto);
|
|
4006
|
+
await state.deleteRef("REBASE_HEAD", "AUTO_MERGE");
|
|
4007
|
+
const autostash = (await state.read(`${APPLY_DIR}/autostash`))?.trim();
|
|
4008
|
+
if (autostash) output.push(...(await applyAutostash(this.context(worktree), autostash)));
|
|
4009
|
+
await state.remove(APPLY_DIR);
|
|
4010
|
+
return { status: RebaseStatus.OK, newHead: head, output };
|
|
4011
|
+
}
|
|
4012
|
+
|
|
3487
4013
|
/**
|
|
3488
4014
|
* `git rebase --quit` and `--show-current-patch` (builtin/rebase.c's ACTION_QUIT and
|
|
3489
4015
|
* ACTION_SHOW_CURRENT_PATCH): the backend found as cmd_rebase finds it (`rebase-apply/`
|
|
@@ -3494,7 +4020,6 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3494
4020
|
worktree: Worktree | undefined,
|
|
3495
4021
|
operation: RebaseOperation,
|
|
3496
4022
|
): Promise<RebaseResult> {
|
|
3497
|
-
const APPLY_DIR = "rebase-apply";
|
|
3498
4023
|
if (await state.exists(`${APPLY_DIR}/applying`)) {
|
|
3499
4024
|
return {
|
|
3500
4025
|
status: RebaseStatus.FAILED,
|
|
@@ -3546,9 +4071,14 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3546
4071
|
state: OperationState,
|
|
3547
4072
|
worktree: Worktree | undefined,
|
|
3548
4073
|
): Promise<RebaseResult> {
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
4074
|
+
const apply = await this.applyInProgress(state);
|
|
4075
|
+
if (apply === "am")
|
|
4076
|
+
throw new GitApiError("fatal: It looks like 'git am' is in progress. Cannot rebase.");
|
|
4077
|
+
if (!apply && !(await this.inProgress(state))) return { status: RebaseStatus.ABORTED };
|
|
4078
|
+
const stateDir = apply ? APPLY_DIR : DIR;
|
|
4079
|
+
await this.rerereClear();
|
|
4080
|
+
const origHead = (await state.read(`${stateDir}/orig-head`))?.trim();
|
|
4081
|
+
const headName = (await state.read(`${stateDir}/head-name`))?.trim() ?? "detached HEAD";
|
|
3552
4082
|
if (!origHead)
|
|
3553
4083
|
return { status: RebaseStatus.FAILED, message: "fatal: could not read orig-head" };
|
|
3554
4084
|
const refused = await resetMerge(this.context(worktree), origHead, origHead, { hard: true });
|
|
@@ -3559,13 +4089,13 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
3559
4089
|
};
|
|
3560
4090
|
}
|
|
3561
4091
|
await this.finishBranch(headName, origHead, undefined, true);
|
|
3562
|
-
const autostash = (await state.read(`${
|
|
4092
|
+
const autostash = (await state.read(`${stateDir}/autostash`))?.trim();
|
|
3563
4093
|
// remove_branch_state, then finish_rebase's unconditional deletions of REBASE_HEAD and
|
|
3564
4094
|
// AUTO_MERGE (git 2.5x's reference-transaction hook hears each)
|
|
3565
4095
|
await removeBranchState(this.context(worktree), state);
|
|
3566
4096
|
await state.deleteRef("REBASE_HEAD", "AUTO_MERGE");
|
|
3567
|
-
await this.deleteRewrittenRefs(state);
|
|
3568
|
-
await state.remove("MERGE_HEAD", "MERGE_MODE", "MERGE_MSG", "SQUASH_MSG",
|
|
4097
|
+
if (!apply) await this.deleteRewrittenRefs(state);
|
|
4098
|
+
await state.remove("MERGE_HEAD", "MERGE_MODE", "MERGE_MSG", "SQUASH_MSG", stateDir);
|
|
3569
4099
|
const output = autostash ? await applyAutostash(this.context(worktree), autostash) : [];
|
|
3570
4100
|
return { status: RebaseStatus.ABORTED, newHead: origHead, output };
|
|
3571
4101
|
}
|
|
@@ -4131,6 +4661,49 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
4131
4661
|
return new Map(ids.map((id) => [id, id.slice(0, lengths.get(id) ?? 7)]));
|
|
4132
4662
|
}
|
|
4133
4663
|
|
|
4664
|
+
/**
|
|
4665
|
+
* The sequence editor program git would launch (`git_sequence_editor`):
|
|
4666
|
+
* `$GIT_SEQUENCE_EDITOR`, `sequence.editor`, then git's editor (`$GIT_EDITOR`,
|
|
4667
|
+
* `core.editor`, `$VISUAL` unless the terminal is dumb, `$EDITOR`); undefined where only the
|
|
4668
|
+
* build's default editor is left (a library never starts an interactive `vi` on its own).
|
|
4669
|
+
*/
|
|
4670
|
+
private sequenceEditorProgram(): string | undefined {
|
|
4671
|
+
const programs = hostEnvironmentOf(this.workingCopy)?.programVariables ?? {};
|
|
4672
|
+
const config = RemoteConfigStore.from(this.workingCopy);
|
|
4673
|
+
const sequence = programs.GIT_SEQUENCE_EDITOR ?? config.value("sequence.editor");
|
|
4674
|
+
if (sequence !== undefined) return sequence;
|
|
4675
|
+
const dumb = programs.TERM === undefined || programs.TERM === "dumb";
|
|
4676
|
+
let editor = programs.GIT_EDITOR ?? config.value("core.editor");
|
|
4677
|
+
if (editor === undefined && !dumb) editor = programs.VISUAL;
|
|
4678
|
+
return editor ?? programs.EDITOR;
|
|
4679
|
+
}
|
|
4680
|
+
|
|
4681
|
+
/**
|
|
4682
|
+
* launch_sequence_editor without an interactive handler's `editTodo`: the program of
|
|
4683
|
+
* {@link sequenceEditorProgram} edits `rebase-merge/git-rebase-todo` (already holding
|
|
4684
|
+
* `text`) through the host's hook runner, as git's `launch_specified_editor` runs it (`:`
|
|
4685
|
+
* edits nothing); the file's new content, or undefined when no program runs (no program,
|
|
4686
|
+
* no runner). A failing program throws git's "there was a problem with the editor".
|
|
4687
|
+
*/
|
|
4688
|
+
private async runSequenceEditorProgram(text: string): Promise<string | undefined> {
|
|
4689
|
+
const program = this.sequenceEditorProgram();
|
|
4690
|
+
if (program === undefined || program === ":") return undefined;
|
|
4691
|
+
const todo = `${DIR}/git-rebase-todo`;
|
|
4692
|
+
const state = new OperationState(this.workingCopy.checkout, this.refsStore);
|
|
4693
|
+
await state.write(todo, text);
|
|
4694
|
+
const path = await this.hooks.gitPath(todo);
|
|
4695
|
+
const run = await this.hooks.runShellCommand("sequence-editor", program, [path]);
|
|
4696
|
+
if (!run) return undefined;
|
|
4697
|
+
// launch_specified_editor's error (2.43's wording, capitalised with a period)
|
|
4698
|
+
if (run.exitCode !== 0)
|
|
4699
|
+
throw new EditorProgramFailure(
|
|
4700
|
+
(this.compatibility ?? this.hooks.compatibility) === "2.43"
|
|
4701
|
+
? `error: There was a problem with the editor '${program}'.`
|
|
4702
|
+
: `error: there was a problem with the editor '${program}'`,
|
|
4703
|
+
);
|
|
4704
|
+
return (await state.read(todo)) ?? "";
|
|
4705
|
+
}
|
|
4706
|
+
|
|
4134
4707
|
/**
|
|
4135
4708
|
* launch_sequence_editor: the interactive handler edits the list (editTodo, then the
|
|
4136
4709
|
* steps of prepareSteps); without one the list is kept.
|
|
@@ -4143,6 +4716,7 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
4143
4716
|
const handler = this.interactiveHandler;
|
|
4144
4717
|
let out = text;
|
|
4145
4718
|
if (handler?.editTodo) out = await handler.editTodo(out);
|
|
4719
|
+
else out = (await this.runSequenceEditorProgram(out)) ?? out;
|
|
4146
4720
|
if (handler?.prepareSteps) {
|
|
4147
4721
|
const comment = commentPrefixOf(this.workingCopy);
|
|
4148
4722
|
const items = parseTodo(stripspace(out, comment), comment).items.filter(
|
|
@@ -4605,41 +5179,27 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
4605
5179
|
},
|
|
4606
5180
|
};
|
|
4607
5181
|
const loadTree = (id: ObjectId) => this.trees.loadTree(id);
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
const
|
|
4626
|
-
for (const id of range) {
|
|
4627
|
-
const header = await patchIdOf(id, true);
|
|
4628
|
-
if (!header) continue;
|
|
4629
|
-
const list = byHeader.get(header) ?? [];
|
|
4630
|
-
list.push(id);
|
|
4631
|
-
byHeader.set(header, list);
|
|
4632
|
-
}
|
|
4633
|
-
if (byHeader.size === 0) return skipped;
|
|
5182
|
+
// HEAD's side added, upstream's looked up (patch-ids.c)
|
|
5183
|
+
const ids = new PatchIds<ObjectId>({
|
|
5184
|
+
trees,
|
|
5185
|
+
blobs: this.blobs,
|
|
5186
|
+
objectFormat: this.objectFormat,
|
|
5187
|
+
change: async (id) => {
|
|
5188
|
+
const commit = await this.loadCommit(id);
|
|
5189
|
+
if (!commit || commit.parents.length > 1) return undefined;
|
|
5190
|
+
const parentTree = commit.parents[0]
|
|
5191
|
+
? (await this.loadCommit(commit.parents[0]))?.tree
|
|
5192
|
+
: undefined;
|
|
5193
|
+
return { ...(parentTree ? { parentTree } : {}), tree: commit.tree };
|
|
5194
|
+
},
|
|
5195
|
+
});
|
|
5196
|
+
let added = 0;
|
|
5197
|
+
for (const id of range) if (await ids.add(id)) added++;
|
|
5198
|
+
if (added === 0) return skipped;
|
|
5199
|
+
const empty = this.objectFormat.nullId;
|
|
4634
5200
|
for (const id of left) {
|
|
4635
|
-
|
|
4636
|
-
const
|
|
4637
|
-
if (!candidates) continue;
|
|
4638
|
-
const mine = await fullOf(id);
|
|
4639
|
-
if (!mine) continue;
|
|
4640
|
-
for (const c of candidates) {
|
|
4641
|
-
if (!skipped.has(c) && (await fullOf(c)) === mine) skipped.add(c);
|
|
4642
|
-
}
|
|
5201
|
+
// make_script never skips a commit empty from the start
|
|
5202
|
+
for (const c of await ids.matches(id)) if ((await ids.fullId(c)) !== empty) skipped.add(c);
|
|
4643
5203
|
}
|
|
4644
5204
|
return skipped;
|
|
4645
5205
|
}
|
|
@@ -4881,6 +5441,7 @@ function editorFailure(error: unknown): Extract<PickOutcome, { kind: "conflicts"
|
|
|
4881
5441
|
|
|
4882
5442
|
/** launch_sequence_editor failing (the interactive handler's editTodo or prepareSteps threw). */
|
|
4883
5443
|
function sequenceEditorFailure(error: unknown): string {
|
|
5444
|
+
if (error instanceof EditorProgramFailure) return error.message;
|
|
4884
5445
|
return error instanceof HandlerFailure
|
|
4885
5446
|
? editorProblem(error.editor, error.reason)
|
|
4886
5447
|
: editorProblem("editTodo", error);
|
|
@@ -4895,6 +5456,9 @@ function editorProblem(editor: string, error: unknown): string {
|
|
|
4895
5456
|
return `error: there was a problem with the editor '${editor}': ${reason}`;
|
|
4896
5457
|
}
|
|
4897
5458
|
|
|
5459
|
+
/** The sequence editor program failed: git's line as its message. */
|
|
5460
|
+
class EditorProgramFailure extends Error {}
|
|
5461
|
+
|
|
4898
5462
|
/** An interactive handler's method that threw, named. */
|
|
4899
5463
|
class HandlerFailure extends Error {
|
|
4900
5464
|
constructor(
|