@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
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
} from "../errors/merge-errors.js";
|
|
22
22
|
import { NotACommitError, RefNotFoundError } from "../errors/ref-errors.js";
|
|
23
23
|
import type { CommandCommits, CommandRefs, CommandTrees } from "../git-command.js";
|
|
24
|
+
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
24
25
|
import { coreBool, createIdAbbreviator, type IdAbbreviator } from "./core-config.js";
|
|
25
26
|
import { type HookSession, sequencerPostCommit, sequencerPrepareMessage } from "./git-hooks.js";
|
|
26
27
|
import { authorIdentOf, committerIdentOf } from "./git-ident.js";
|
|
@@ -50,6 +51,8 @@ import {
|
|
|
50
51
|
removeBranchState,
|
|
51
52
|
resetMerge,
|
|
52
53
|
} from "./sequencer-support.js";
|
|
54
|
+
import { SigningFailedError, type SignRequest, signCommit, signRequestOf } from "./signing.js";
|
|
55
|
+
import { appendSignoff, signoffLine, trailerConfigOf, trailerLinesOf } from "./trailers.js";
|
|
53
56
|
|
|
54
57
|
/** What the sequencer does with each commit. */
|
|
55
58
|
export type PickAction = "pick" | "revert";
|
|
@@ -105,7 +108,7 @@ export interface SequencerDeps extends MergeWriteContext {
|
|
|
105
108
|
|
|
106
109
|
/** The `git commit` the sequencer runs (see {@link SequencerDeps.gitCommit}). */
|
|
107
110
|
export type PickCommitMode =
|
|
108
|
-
| { kind: "pick"; reflogAction: string }
|
|
111
|
+
| { kind: "pick"; reflogAction: string; allowEmpty?: boolean }
|
|
109
112
|
| { kind: "continue"; edit: boolean };
|
|
110
113
|
|
|
111
114
|
/** Options of one sequencer run. */
|
|
@@ -131,6 +134,121 @@ export interface PickOptions {
|
|
|
131
134
|
* (git's `options.edit`), left out when neither was given.
|
|
132
135
|
*/
|
|
133
136
|
edit?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* `-S[<keyid>]` (true or the key) / `--no-gpg-sign` (false); undefined: `commit.gpgSign`.
|
|
139
|
+
* Saved in `sequencer/opts` (`options.gpg-sign`) for a run of several commits.
|
|
140
|
+
*/
|
|
141
|
+
sign?: boolean | string;
|
|
142
|
+
/** `-x`: `(cherry picked from commit <id>)` appended to a pick's message (record_origin) */
|
|
143
|
+
recordOrigin?: boolean;
|
|
144
|
+
/** `-s` / `--signoff`: the committer's `Signed-off-by:` appended (append_signoff) */
|
|
145
|
+
signoff?: boolean;
|
|
146
|
+
/** `--allow-empty`: a commit empty in itself (its tree its first parent's) is committed */
|
|
147
|
+
allowEmpty?: boolean;
|
|
148
|
+
/** `--allow-empty-message` (saved in `sequencer/opts`; the sequencer commits any message) */
|
|
149
|
+
allowEmptyMessage?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* `--keep-redundant-commits` / `--empty=keep`: a commit that becomes empty is committed
|
|
152
|
+
* (implies {@link allowEmpty})
|
|
153
|
+
*/
|
|
154
|
+
keepRedundant?: boolean;
|
|
155
|
+
/** `--empty=drop`: a commit that becomes empty is dropped, git's `dropping ...` line printed */
|
|
156
|
+
dropRedundant?: boolean;
|
|
157
|
+
/** `--ff`: a commit whose parent is HEAD is fast-forwarded to, not picked */
|
|
158
|
+
allowFf?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* `revert --reference` (or `revert.reference`): the reverted commit named as
|
|
161
|
+
* `<abbrev> (<subject>, <date>)` under a `*** SAY WHY ...` comment for the title
|
|
162
|
+
*/
|
|
163
|
+
reference?: boolean;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The flags of a run, read back from `sequencer/opts` (git's replay_opts). */
|
|
167
|
+
interface PickFlags {
|
|
168
|
+
noCommit: boolean;
|
|
169
|
+
mainline?: number;
|
|
170
|
+
recordOrigin: boolean;
|
|
171
|
+
signoff: boolean;
|
|
172
|
+
allowEmpty: boolean;
|
|
173
|
+
allowEmptyMessage: boolean;
|
|
174
|
+
keepRedundant: boolean;
|
|
175
|
+
dropRedundant: boolean;
|
|
176
|
+
allowFf: boolean;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** commit.cleanup as the sequencer reads it (git_sequencer_config). */
|
|
180
|
+
type SequencerCleanup = "whitespace" | "verbatim" | "scissors" | "strip";
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* builtin/revert.c's verify_opt_compatible: the `fatal:` line refusing an option that cannot
|
|
184
|
+
* go with `--continue`/`--skip`/`--abort`/`--quit` or with `--ff`, as git checks them; undefined
|
|
185
|
+
* when the options go together.
|
|
186
|
+
*/
|
|
187
|
+
export function pickOptionsConflict(
|
|
188
|
+
action: PickAction,
|
|
189
|
+
operation: SequencerOperation,
|
|
190
|
+
options: PickOptions & { emptyGiven?: boolean },
|
|
191
|
+
/** git 2.43 lets `--keep-redundant-commits` and `--empty` go with the operations */
|
|
192
|
+
compatibility?: "2.43" | "2.56",
|
|
193
|
+
): string | undefined {
|
|
194
|
+
const me = ACTION_NAME[action];
|
|
195
|
+
const keep = !!options.keepRedundant;
|
|
196
|
+
if (operation !== SequencerOperation.START) {
|
|
197
|
+
const op = `--${operation}`;
|
|
198
|
+
const given: [string, boolean][] = [
|
|
199
|
+
["--no-commit", !!options.noCommit],
|
|
200
|
+
["--signoff", !!options.signoff],
|
|
201
|
+
["--mainline", !!options.mainline],
|
|
202
|
+
["-x", !!options.recordOrigin],
|
|
203
|
+
["--ff", !!options.allowFf],
|
|
204
|
+
["--keep-redundant-commits", keep && compatibility !== "2.43"],
|
|
205
|
+
["--empty", !!options.emptyGiven && compatibility !== "2.43"],
|
|
206
|
+
];
|
|
207
|
+
const first = given.find(([, on]) => on);
|
|
208
|
+
if (first) return `fatal: ${me}: ${first[0]} cannot be used with ${op}`;
|
|
209
|
+
}
|
|
210
|
+
if (options.allowFf) {
|
|
211
|
+
const given: [string, boolean][] = [
|
|
212
|
+
["--signoff", !!options.signoff],
|
|
213
|
+
["--no-commit", !!options.noCommit],
|
|
214
|
+
["-x", !!options.recordOrigin],
|
|
215
|
+
["--edit", options.edit === true],
|
|
216
|
+
];
|
|
217
|
+
const first = given.find(([, on]) => on);
|
|
218
|
+
if (first) return `fatal: ${me}: ${first[0]} cannot be used with --ff`;
|
|
219
|
+
}
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** The boolean options of `sequencer/opts` (populate_opts_cb). */
|
|
224
|
+
const SAVED_FLAGS: Record<string, keyof Omit<PickFlags, "mainline"> | undefined> = {
|
|
225
|
+
"no-commit": "noCommit",
|
|
226
|
+
"allow-empty": "allowEmpty",
|
|
227
|
+
"allow-empty-message": "allowEmptyMessage",
|
|
228
|
+
"drop-redundant-commits": "dropRedundant",
|
|
229
|
+
"keep-redundant-commits": "keepRedundant",
|
|
230
|
+
signoff: "signoff",
|
|
231
|
+
"record-origin": "recordOrigin",
|
|
232
|
+
"allow-ff": "allowFf",
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
/** git_sequencer_config's commit.cleanup (get_cleanup_mode for a saved one). */
|
|
236
|
+
function cleanupOf(value: string | undefined): SequencerCleanup | undefined {
|
|
237
|
+
switch (value) {
|
|
238
|
+
case "verbatim":
|
|
239
|
+
case "whitespace":
|
|
240
|
+
case "strip":
|
|
241
|
+
case "scissors":
|
|
242
|
+
return value;
|
|
243
|
+
default:
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function configuredCleanup(
|
|
249
|
+
workingCopy: SequencerDeps["workingCopy"],
|
|
250
|
+
): SequencerCleanup | undefined {
|
|
251
|
+
return cleanupOf(RemoteConfigStore.from(workingCopy).value("commit.cleanup"));
|
|
134
252
|
}
|
|
135
253
|
|
|
136
254
|
const ACTION_NAME = { pick: "cherry-pick", revert: "revert" } as const;
|
|
@@ -152,6 +270,12 @@ export class PickSequencer {
|
|
|
152
270
|
private readonly abbreviator: IdAbbreviator;
|
|
153
271
|
/** `--edit` / `--no-edit` (git's opts->edit, unset: undefined), read back from the opts */
|
|
154
272
|
private edit: boolean | undefined;
|
|
273
|
+
/** What the commits are signed with (git's opts->gpg_sign), read back from the opts */
|
|
274
|
+
private sign: SignRequest;
|
|
275
|
+
/** The flags of the run (given, or read back from `sequencer/opts`) */
|
|
276
|
+
private readonly flags: PickFlags;
|
|
277
|
+
/** commit.cleanup (git's default_msg_cleanup with explicit_cleanup), or saved in the opts */
|
|
278
|
+
private cleanup: SequencerCleanup | undefined;
|
|
155
279
|
|
|
156
280
|
constructor(
|
|
157
281
|
private readonly deps: SequencerDeps,
|
|
@@ -160,6 +284,25 @@ export class PickSequencer {
|
|
|
160
284
|
this.flats = new FlatTreeCache(deps.trees);
|
|
161
285
|
this.abbreviator = createIdAbbreviator(deps.workingCopy);
|
|
162
286
|
this.edit = options.edit;
|
|
287
|
+
this.sign = signRequestOf(deps.workingCopy, options.sign);
|
|
288
|
+
const keepRedundant = !!options.keepRedundant;
|
|
289
|
+
this.flags = {
|
|
290
|
+
noCommit: !!options.noCommit,
|
|
291
|
+
mainline: options.mainline,
|
|
292
|
+
recordOrigin: !!options.recordOrigin,
|
|
293
|
+
signoff: !!options.signoff,
|
|
294
|
+
// --keep-redundant-commits implies --allow-empty (run_sequencer)
|
|
295
|
+
allowEmpty: !!options.allowEmpty || keepRedundant,
|
|
296
|
+
allowEmptyMessage: !!options.allowEmptyMessage,
|
|
297
|
+
keepRedundant,
|
|
298
|
+
dropRedundant: !!options.dropRedundant,
|
|
299
|
+
allowFf: !!options.allowFf,
|
|
300
|
+
};
|
|
301
|
+
this.cleanup = configuredCleanup(deps.workingCopy);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
private config(key: string): string | undefined {
|
|
305
|
+
return RemoteConfigStore.from(this.deps.workingCopy).value(key);
|
|
163
306
|
}
|
|
164
307
|
|
|
165
308
|
private get name(): string {
|
|
@@ -174,6 +317,10 @@ export class PickSequencer {
|
|
|
174
317
|
async start(names: string[]): Promise<PickOutcome> {
|
|
175
318
|
const { state } = this.deps;
|
|
176
319
|
const { unmerged } = await readIndex(this.deps.staging);
|
|
320
|
+
if (unmerged.length > 0 && this.flags.noCommit) {
|
|
321
|
+
// do_pick_commit's write_index_as_tree fails first
|
|
322
|
+
return this.fail(`error: your index file is unmerged.\nfatal: ${this.name} failed`);
|
|
323
|
+
}
|
|
177
324
|
if (unmerged.length > 0) {
|
|
178
325
|
return this.fail(
|
|
179
326
|
[
|
|
@@ -190,17 +337,42 @@ export class PickSequencer {
|
|
|
190
337
|
);
|
|
191
338
|
}
|
|
192
339
|
const ids: ObjectId[] = [];
|
|
193
|
-
|
|
340
|
+
let lastNamed = "";
|
|
341
|
+
for (const name of names) {
|
|
342
|
+
const id = await this.resolvePick(name);
|
|
343
|
+
lastNamed = id;
|
|
344
|
+
// the revision walk lists each commit once (its SEEN flag), first naming first
|
|
345
|
+
if (!ids.includes(id)) ids.push(id);
|
|
346
|
+
}
|
|
194
347
|
const todo = ids.map((id) => ({ action: this.options.action, id }));
|
|
195
|
-
const headId = await this.headId();
|
|
196
348
|
if (todo.length > 1) {
|
|
197
|
-
|
|
349
|
+
// sequencer_pick_revisions on an unborn HEAD refuses only a revert; a pick saves as
|
|
350
|
+
// sequencer/head what its failed repo_get_oid("HEAD") left in `oid`, which in git 2.43
|
|
351
|
+
// and 2.56 builds alike is the id of the last commit named (the loop over the pending
|
|
352
|
+
// revisions shares its stack slot), and an empty abort-safety
|
|
353
|
+
const headId = await this.headIfBorn();
|
|
354
|
+
if (!headId && this.options.action === "revert") {
|
|
355
|
+
return this.fail(`error: can't revert as initial commit\nfatal: ${this.name} failed`);
|
|
356
|
+
}
|
|
357
|
+
await state.write("sequencer/head", `${headId ?? lastNamed}\n`);
|
|
198
358
|
await this.writeTodo(todo);
|
|
199
|
-
await state.write("sequencer/abort-safety", `${headId}\n`);
|
|
200
|
-
// save_opts
|
|
359
|
+
await state.write("sequencer/abort-safety", `${headId ?? ""}\n`);
|
|
360
|
+
// save_opts, in its order (git config's format)
|
|
361
|
+
const f = this.flags;
|
|
201
362
|
const opts: string[] = [];
|
|
202
|
-
|
|
363
|
+
const flag = (name: string, on: boolean) => on && opts.push(`\t${name} = true\n`);
|
|
364
|
+
flag("no-commit", f.noCommit);
|
|
203
365
|
if (this.edit !== undefined) opts.push(`\tedit = ${this.edit}\n`);
|
|
366
|
+
flag("allow-empty", f.allowEmpty);
|
|
367
|
+
flag("allow-empty-message", f.allowEmptyMessage);
|
|
368
|
+
flag("drop-redundant-commits", f.dropRedundant);
|
|
369
|
+
flag("keep-redundant-commits", f.keepRedundant);
|
|
370
|
+
flag("signoff", f.signoff);
|
|
371
|
+
flag("record-origin", f.recordOrigin);
|
|
372
|
+
flag("allow-ff", f.allowFf);
|
|
373
|
+
if (f.mainline) opts.push(`\tmainline = ${f.mainline}\n`);
|
|
374
|
+
if (this.sign !== undefined) opts.push(`\tgpg-sign = ${this.sign}\n`);
|
|
375
|
+
if (this.cleanup) opts.push(`\tdefault-msg-cleanup = ${this.cleanup}\n`);
|
|
204
376
|
if (opts.length > 0) await state.write("sequencer/opts", `[options]\n${opts.join("")}`);
|
|
205
377
|
}
|
|
206
378
|
return this.run(todo, todo.length > 1);
|
|
@@ -226,14 +398,17 @@ export class PickSequencer {
|
|
|
226
398
|
private async run(todo: TodoItem[], sequenced: boolean): Promise<PickOutcome> {
|
|
227
399
|
const output: string[] = [];
|
|
228
400
|
const picked: ObjectId[] = [];
|
|
229
|
-
let newHead = await this.
|
|
401
|
+
let newHead = await this.headIfBorn();
|
|
230
402
|
for (let k = 0; k < todo.length; k++) {
|
|
231
403
|
const item = todo[k];
|
|
232
404
|
const outcome = await this.pickOne(item, output);
|
|
233
405
|
if (outcome.status !== "ok") {
|
|
234
406
|
if (sequenced) {
|
|
235
407
|
await this.writeTodo(todo.slice(k));
|
|
236
|
-
await this.deps.state.write(
|
|
408
|
+
await this.deps.state.write(
|
|
409
|
+
"sequencer/abort-safety",
|
|
410
|
+
`${(await this.headIfBorn()) ?? ""}\n`,
|
|
411
|
+
);
|
|
237
412
|
}
|
|
238
413
|
return { ...outcome, picked, output };
|
|
239
414
|
}
|
|
@@ -241,7 +416,7 @@ export class PickSequencer {
|
|
|
241
416
|
newHead = outcome.newHead ?? newHead;
|
|
242
417
|
if (sequenced) {
|
|
243
418
|
await this.writeTodo(todo.slice(k + 1));
|
|
244
|
-
await this.deps.state.write("sequencer/abort-safety", `${newHead}\n`);
|
|
419
|
+
await this.deps.state.write("sequencer/abort-safety", `${newHead ?? ""}\n`);
|
|
245
420
|
}
|
|
246
421
|
}
|
|
247
422
|
if (sequenced) await this.deps.state.remove("sequencer");
|
|
@@ -250,44 +425,58 @@ export class PickSequencer {
|
|
|
250
425
|
|
|
251
426
|
/** One commit's change merged into HEAD (do_pick_commit). */
|
|
252
427
|
private async pickOne(item: TodoItem, output: string[]): Promise<PickOutcome> {
|
|
253
|
-
const { deps } = this;
|
|
428
|
+
const { deps, flags } = this;
|
|
254
429
|
const action = item.action;
|
|
430
|
+
const name = ACTION_NAME[action];
|
|
431
|
+
const format = objectFormatOf(deps.workingCopy.history);
|
|
255
432
|
const commit = await deps.commits.load(item.id);
|
|
256
433
|
if (!commit) throw new RefNotFoundError(item.id, `Cannot find commit: ${item.id}`);
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
|
|
434
|
+
// an unborn HEAD picks onto the empty tree (repo_get_oid fails: `unborn`)
|
|
435
|
+
const headId = await this.headIfBorn();
|
|
436
|
+
const headCommit = headId ? await deps.commits.load(headId) : undefined;
|
|
437
|
+
if (headId && !headCommit) throw new RefNotFoundError(headId, "HEAD commit not found");
|
|
438
|
+
const headTree = headCommit?.tree ?? format.emptyTreeId;
|
|
260
439
|
// with --no-commit the change is merged into the index as it is (git's
|
|
261
440
|
// write_index_as_tree): each commit's change on top of the previous one's
|
|
262
|
-
const headTreeId =
|
|
263
|
-
? await writeIndexAsTree(deps.staging, deps.trees,
|
|
264
|
-
:
|
|
441
|
+
const headTreeId = flags.noCommit
|
|
442
|
+
? await writeIndexAsTree(deps.staging, deps.trees, format)
|
|
443
|
+
: headTree;
|
|
265
444
|
// a commit is never made on top of staged changes (error_dirty_index)
|
|
266
445
|
const { index } = await readIndex(deps.staging);
|
|
267
|
-
if (
|
|
268
|
-
!this.options.noCommit &&
|
|
269
|
-
(await indexChangesFromTree(index, deps.trees, headTreeId)).length > 0
|
|
270
|
-
) {
|
|
446
|
+
if (!flags.noCommit && (await indexChangesFromTree(index, deps.trees, headTreeId)).length > 0) {
|
|
271
447
|
return this.fail(
|
|
272
|
-
`error: your local changes would be overwritten by ${
|
|
448
|
+
`error: your local changes would be overwritten by ${name}.\nhint: commit your changes or stash them to proceed.\nfatal: ${name} failed`,
|
|
273
449
|
);
|
|
274
450
|
}
|
|
275
451
|
|
|
276
|
-
// the parent the change is taken against
|
|
452
|
+
// the parent the change is taken against (`-m`: a merge's parent, at most 1 otherwise)
|
|
277
453
|
let parentId: ObjectId | undefined;
|
|
454
|
+
const mainline = flags.mainline;
|
|
455
|
+
const noParent = (n: number) =>
|
|
456
|
+
new InvalidMainlineParentError(
|
|
457
|
+
n,
|
|
458
|
+
commit.parents.length,
|
|
459
|
+
`error: commit ${item.id} does not have parent ${n}\nfatal: ${name} failed`,
|
|
460
|
+
);
|
|
278
461
|
if (commit.parents.length > 1) {
|
|
279
|
-
if (
|
|
462
|
+
if (!mainline) {
|
|
280
463
|
throw new MultipleParentsNotAllowedError(
|
|
281
|
-
`error: commit ${item.id} is a merge but no -m option was given.\nfatal: ${
|
|
464
|
+
`error: commit ${item.id} is a merge but no -m option was given.\nfatal: ${name} failed`,
|
|
282
465
|
);
|
|
283
466
|
}
|
|
284
|
-
if (
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
467
|
+
if (mainline > commit.parents.length) throw noParent(mainline);
|
|
468
|
+
parentId = commit.parents[mainline - 1];
|
|
469
|
+
} else if (mainline !== undefined && mainline > 1) {
|
|
470
|
+
throw noParent(mainline);
|
|
288
471
|
} else {
|
|
289
472
|
parentId = commit.parents[0];
|
|
290
473
|
}
|
|
474
|
+
|
|
475
|
+
// --ff: a commit on HEAD (a root commit on an unborn branch) is fast-forwarded to
|
|
476
|
+
if (flags.allowFf && ((parentId && parentId === headId) || (!parentId && !headId))) {
|
|
477
|
+
return this.fastForward(item.id, headId, headTree, commit.tree, output);
|
|
478
|
+
}
|
|
479
|
+
|
|
291
480
|
const parentTreeId = parentId ? await deps.commits.getTree(parentId) : undefined;
|
|
292
481
|
const subject = subjectOf(commit.message);
|
|
293
482
|
// get_message: short_commit_name, repo_find_unique_abbrev with DEFAULT_ABBREV
|
|
@@ -323,25 +512,25 @@ export class PickSequencer {
|
|
|
323
512
|
const delta = await treeDelta(deps.trees, headTreeId, treeId);
|
|
324
513
|
const refused = await switchTrees(deps, delta.from, delta.to, {
|
|
325
514
|
action: "merge",
|
|
326
|
-
operation:
|
|
515
|
+
operation: name,
|
|
327
516
|
conflicts,
|
|
328
517
|
targetTree: treeId,
|
|
329
518
|
});
|
|
330
519
|
if (refused) {
|
|
331
|
-
return this.fail(`${refused.message}\nfatal: ${
|
|
520
|
+
return this.fail(`${refused.message}\nfatal: ${name} failed`);
|
|
332
521
|
}
|
|
333
522
|
output.push(...merge.messages);
|
|
334
523
|
await deps.state.setRef("AUTO_MERGE", treeId);
|
|
335
|
-
const message = this.messageFor(action, item.id, commit, parentId);
|
|
524
|
+
const message = await this.messageFor(action, item.id, commit, parentId);
|
|
336
525
|
|
|
337
526
|
if (conflicts.length > 0 || !merge.clean) {
|
|
338
527
|
const paths = [...new Set(conflicts.map((c) => c.stagePath))].sort(compareGitPaths);
|
|
339
528
|
// git records REVERT_HEAD for a revert -n too (do_pick_commit), never CHERRY_PICK_HEAD
|
|
340
|
-
if (!
|
|
529
|
+
if (!flags.noCommit || action === "revert") {
|
|
341
530
|
await deps.state.setRef(HEAD_REF[action], item.id);
|
|
342
531
|
}
|
|
343
532
|
await deps.state.write("MERGE_MSG", `${message}${conflictsComment(paths, true)}`);
|
|
344
|
-
const advice =
|
|
533
|
+
const advice = flags.noCommit
|
|
345
534
|
? [
|
|
346
535
|
"hint: after resolving the conflicts, mark the corrected paths",
|
|
347
536
|
"hint: with 'git add <paths>' or 'git rm <paths>'",
|
|
@@ -349,10 +538,10 @@ export class PickSequencer {
|
|
|
349
538
|
: [
|
|
350
539
|
"hint: After resolving the conflicts, mark them with",
|
|
351
540
|
'hint: "git add/rm <pathspec>", then run',
|
|
352
|
-
`hint: "git ${
|
|
353
|
-
`hint: You can instead skip this commit with "git ${
|
|
354
|
-
`hint: To abort and get back to the state before "git ${
|
|
355
|
-
`hint: run "git ${
|
|
541
|
+
`hint: "git ${name} --continue".`,
|
|
542
|
+
`hint: You can instead skip this commit with "git ${name} --skip".`,
|
|
543
|
+
`hint: To abort and get back to the state before "git ${name}",`,
|
|
544
|
+
`hint: run "git ${name} --abort".`,
|
|
356
545
|
];
|
|
357
546
|
return {
|
|
358
547
|
status: "conflicting",
|
|
@@ -365,28 +554,55 @@ export class PickSequencer {
|
|
|
365
554
|
].join("\n"),
|
|
366
555
|
};
|
|
367
556
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
557
|
+
// a clean merge: CHERRY_PICK_HEAD (not with --no-commit), MERGE_MSG, REVERT_HEAD for a
|
|
558
|
+
// revert -n, before allow_empty and do_commit (a commit that fails leaves them)
|
|
559
|
+
if (action === "pick" && !flags.noCommit) await deps.state.setRef(HEAD_REF[action], item.id);
|
|
560
|
+
await deps.state.write("MERGE_MSG", message);
|
|
561
|
+
if (action === "revert" && flags.noCommit) await deps.state.setRef(HEAD_REF[action], item.id);
|
|
562
|
+
|
|
563
|
+
// allow_empty: a result equal to HEAD's tree is committed (1), dropped (2) or stops (0)
|
|
564
|
+
let allow: 0 | 1 | 2 = 0;
|
|
565
|
+
if (treeId === headTree) {
|
|
566
|
+
const firstParentTree = commit.parents[0]
|
|
567
|
+
? await deps.commits.getTree(commit.parents[0])
|
|
568
|
+
: format.emptyTreeId;
|
|
569
|
+
const originallyEmpty = firstParentTree === commit.tree;
|
|
570
|
+
allow = originallyEmpty
|
|
571
|
+
? flags.allowEmpty
|
|
572
|
+
? 1
|
|
573
|
+
: 0
|
|
574
|
+
: flags.keepRedundant
|
|
575
|
+
? 1
|
|
576
|
+
: flags.dropRedundant
|
|
577
|
+
? 2
|
|
578
|
+
: 0;
|
|
579
|
+
}
|
|
580
|
+
if (allow === 2) {
|
|
581
|
+
await deps.state.deleteRef("CHERRY_PICK_HEAD");
|
|
582
|
+
await deps.state.remove("MERGE_MSG");
|
|
583
|
+
await deps.state.deleteRef("AUTO_MERGE");
|
|
584
|
+
output.push(`dropping ${item.id} ${subject} -- patch contents already upstream`);
|
|
585
|
+
return { status: "ok", newHead: headId, picked: [item.id], output };
|
|
586
|
+
}
|
|
587
|
+
if (flags.noCommit) {
|
|
371
588
|
return { status: "ok", newHead: headId, picked: [item.id], output };
|
|
372
589
|
}
|
|
373
|
-
if (treeId ===
|
|
374
|
-
// nothing to commit: git stops, the pick in
|
|
375
|
-
//
|
|
376
|
-
|
|
377
|
-
await deps.state.write("MERGE_MSG", message);
|
|
590
|
+
if (treeId === headTree && allow === 0) {
|
|
591
|
+
// nothing to commit: try_to_commit leaves it to `git commit`, which stops, the pick in
|
|
592
|
+
// progress, for `git commit --allow-empty` or --skip (CHERRY_PICK_HEAD only: git
|
|
593
|
+
// records REVERT_HEAD for a revert that conflicts)
|
|
378
594
|
return {
|
|
379
595
|
status: "conflicting",
|
|
380
596
|
conflicts: [],
|
|
381
597
|
picked: [],
|
|
382
598
|
output,
|
|
383
599
|
message: [
|
|
384
|
-
`The previous ${
|
|
600
|
+
`The previous ${name} is now empty, possibly due to conflict resolution.`,
|
|
385
601
|
"If you wish to commit it anyway, use:",
|
|
386
602
|
"",
|
|
387
603
|
" git commit --allow-empty",
|
|
388
604
|
"",
|
|
389
|
-
`Otherwise, please use 'git ${
|
|
605
|
+
`Otherwise, please use 'git ${name} --skip'`,
|
|
390
606
|
].join("\n"),
|
|
391
607
|
};
|
|
392
608
|
}
|
|
@@ -394,13 +610,12 @@ export class PickSequencer {
|
|
|
394
610
|
// do_pick_commit with EDIT_MSG: the message in MERGE_MSG, CHERRY_PICK_HEAD for a pick
|
|
395
611
|
// (git commit then takes its author and says it concludes a cherry-pick), then
|
|
396
612
|
// run_git_commit; git commit cleans up after itself (CHERRY_PICK_HEAD, MERGE_MSG)
|
|
397
|
-
if (action === "pick") await deps.state.setRef(HEAD_REF[action], item.id);
|
|
398
|
-
await deps.state.write("MERGE_MSG", message);
|
|
399
613
|
let newHead: ObjectId;
|
|
400
614
|
try {
|
|
401
615
|
newHead = await deps.gitCommit({
|
|
402
616
|
kind: "pick",
|
|
403
|
-
reflogAction: this.options.reflogAction ??
|
|
617
|
+
reflogAction: this.options.reflogAction ?? name,
|
|
618
|
+
allowEmpty: allow === 1,
|
|
404
619
|
});
|
|
405
620
|
} catch (error) {
|
|
406
621
|
if (!(error instanceof GitApiError)) throw error;
|
|
@@ -409,20 +624,15 @@ export class PickSequencer {
|
|
|
409
624
|
}
|
|
410
625
|
return { status: "ok", newHead, picked: [item.id], output };
|
|
411
626
|
}
|
|
412
|
-
// do_pick_commit records CHERRY_PICK_HEAD for a clean pick too, and writes MERGE_MSG,
|
|
413
|
-
// before do_commit: a commit that fails (HEAD's lock held) leaves both
|
|
414
|
-
if (action === "pick") await deps.state.setRef(HEAD_REF[action], item.id);
|
|
415
|
-
await deps.state.write("MERGE_MSG", message);
|
|
416
627
|
const committer = this.committer();
|
|
417
|
-
const commitMessage = action === "pick" ? commit.message : message;
|
|
418
628
|
const newHead = await this.commit(
|
|
419
629
|
treeId,
|
|
420
|
-
[headId],
|
|
630
|
+
headId ? [headId] : [],
|
|
421
631
|
action === "pick" ? commit.author : this.revertAuthor(committer),
|
|
422
632
|
committer,
|
|
423
|
-
|
|
633
|
+
message,
|
|
424
634
|
// the sequencer's update_head_with_reflog: "cherry-pick: <subject>", "revert: ..."
|
|
425
|
-
reflogMessages.pick(this.options.reflogAction ??
|
|
635
|
+
(text) => reflogMessages.pick(this.options.reflogAction ?? name, text),
|
|
426
636
|
);
|
|
427
637
|
// do_commit after try_to_commit: CHERRY_PICK_HEAD (deleted whether there or not) and
|
|
428
638
|
// MERGE_MSG go, a stopped empty pick's left over included (REVERT_HEAD and AUTO_MERGE stay)
|
|
@@ -431,6 +641,29 @@ export class PickSequencer {
|
|
|
431
641
|
return { status: "ok", newHead, picked: [item.id], output };
|
|
432
642
|
}
|
|
433
643
|
|
|
644
|
+
/**
|
|
645
|
+
* fast_forward_to: the index and worktree switched from HEAD's tree to the commit's
|
|
646
|
+
* (checkout_fast_forward, a two-way switch refusing over local changes), then HEAD moved
|
|
647
|
+
* there with the reflog line `<action>: fast-forward`.
|
|
648
|
+
*/
|
|
649
|
+
private async fastForward(
|
|
650
|
+
id: ObjectId,
|
|
651
|
+
headId: ObjectId | undefined,
|
|
652
|
+
headTree: ObjectId,
|
|
653
|
+
targetTree: ObjectId,
|
|
654
|
+
output: string[],
|
|
655
|
+
): Promise<PickOutcome> {
|
|
656
|
+
const delta = await treeDelta(this.deps.trees, headTree, targetTree);
|
|
657
|
+
const refused = await switchTrees(this.deps, delta.from, delta.to, {
|
|
658
|
+
action: "merge",
|
|
659
|
+
operation: this.name,
|
|
660
|
+
targetTree,
|
|
661
|
+
});
|
|
662
|
+
if (refused) return this.fail(`${refused.message}\nfatal: ${this.name} failed`);
|
|
663
|
+
await this.moveHead(id, `${this.name}: fast-forward`, headId ?? null);
|
|
664
|
+
return { status: "ok", newHead: id, picked: [id], output };
|
|
665
|
+
}
|
|
666
|
+
|
|
434
667
|
/** `--continue`: the resolved conflict committed, then the rest picked. */
|
|
435
668
|
async continue(): Promise<PickOutcome> {
|
|
436
669
|
const { state } = this.deps;
|
|
@@ -452,7 +685,7 @@ export class PickSequencer {
|
|
|
452
685
|
if (!commit) throw new RefNotFoundError(stopped, "Commit being picked not found");
|
|
453
686
|
const treeId = await this.deps.staging.writeTree(this.deps.trees);
|
|
454
687
|
const headCommit = await this.deps.commits.load(newHead);
|
|
455
|
-
const fallback = this.messageFor(action, stopped, commit, commit.parents[0]);
|
|
688
|
+
const fallback = await this.messageFor(action, stopped, commit, commit.parents[0]);
|
|
456
689
|
const prepared = (await state.read("MERGE_MSG")) ?? fallback;
|
|
457
690
|
// continue_single_pick runs `git commit --no-edit --cleanup=strip` (plain `git commit`
|
|
458
691
|
// under --edit): without the editor its prepare_to_commit writes MERGE_MSG with its
|
|
@@ -490,7 +723,8 @@ export class PickSequencer {
|
|
|
490
723
|
message,
|
|
491
724
|
// `--continue` commits as `git commit` does: "commit (cherry-pick): <subject>" (a
|
|
492
725
|
// revert is no whence of git commit: "commit: <subject>")
|
|
493
|
-
reflogMessages.commit(action === "pick" ? "cherry-pick" : undefined,
|
|
726
|
+
(text) => reflogMessages.commit(action === "pick" ? "cherry-pick" : undefined, text),
|
|
727
|
+
"verbatim",
|
|
494
728
|
);
|
|
495
729
|
// the commit ends the stopped pick (git commit's remove_merge_branch_state)
|
|
496
730
|
await state.removeRef("CHERRY_PICK_HEAD", "REVERT_HEAD", "AUTO_MERGE");
|
|
@@ -509,7 +743,8 @@ export class PickSequencer {
|
|
|
509
743
|
const { state } = this.deps;
|
|
510
744
|
const stopped = (await state.ref("CHERRY_PICK_HEAD")) ?? (await state.ref("REVERT_HEAD"));
|
|
511
745
|
if (!stopped) {
|
|
512
|
-
|
|
746
|
+
// sequencer_skip: neither this action's head nor a sequence of it to go on with
|
|
747
|
+
return this.fail(`error: no ${this.name} in progress\nfatal: ${this.name} failed`);
|
|
513
748
|
}
|
|
514
749
|
await this.readSavedOptions();
|
|
515
750
|
const headId = await this.headId();
|
|
@@ -548,6 +783,12 @@ export class PickSequencer {
|
|
|
548
783
|
await state.remove("sequencer");
|
|
549
784
|
return this.fail(`error: could not read 'sequencer/head'\nfatal: ${this.name} failed`);
|
|
550
785
|
}
|
|
786
|
+
if (/^0+$/.test(origHead)) {
|
|
787
|
+
// sequencer_rollback: a run started on an unborn branch is not rewound (state kept)
|
|
788
|
+
return this.fail(
|
|
789
|
+
`error: cannot abort from a branch yet to be born\nfatal: ${this.name} failed`,
|
|
790
|
+
);
|
|
791
|
+
}
|
|
551
792
|
if (safety && safety !== headId) {
|
|
552
793
|
await state.remove("sequencer");
|
|
553
794
|
return this.fail(
|
|
@@ -562,11 +803,18 @@ export class PickSequencer {
|
|
|
562
803
|
return { status: "ok", newHead: origHead, picked: [], output: errors };
|
|
563
804
|
}
|
|
564
805
|
|
|
565
|
-
/**
|
|
806
|
+
/**
|
|
807
|
+
* `--quit` (builtin/revert.c): sequencer_remove_state (`sequencer/` removed), then
|
|
808
|
+
* remove_branch_state (CHERRY_PICK_HEAD, REVERT_HEAD, AUTO_MERGE, SQUASH_MSG, MERGE_MSG,
|
|
809
|
+
* MERGE_HEAD, MERGE_MODE, MERGE_RR go, a MERGE_AUTOSTASH is kept on `refs/stash`); the
|
|
810
|
+
* index, the worktree, HEAD and ORIG_HEAD are kept. Nothing in progress is no error.
|
|
811
|
+
*/
|
|
566
812
|
async quit(): Promise<PickOutcome> {
|
|
567
813
|
await this.deps.state.remove("sequencer");
|
|
568
|
-
await this.deps.state
|
|
569
|
-
|
|
814
|
+
const output = await removeBranchState(this.deps, this.deps.state);
|
|
815
|
+
// an unborn HEAD is no error here
|
|
816
|
+
const head = (await this.deps.refs.resolve("HEAD").catch(() => undefined))?.objectId;
|
|
817
|
+
return { status: "ok", ...(head ? { newHead: head } : {}), picked: [], output };
|
|
570
818
|
}
|
|
571
819
|
|
|
572
820
|
/**
|
|
@@ -589,8 +837,9 @@ export class PickSequencer {
|
|
|
589
837
|
}
|
|
590
838
|
|
|
591
839
|
/**
|
|
592
|
-
* read_populate_opts: `options.edit` of `sequencer/opts` (git
|
|
593
|
-
* value wins), the `--edit` / `--no-edit` the run
|
|
840
|
+
* read_populate_opts: `options.edit` and `options.gpg-sign` of `sequencer/opts` (git
|
|
841
|
+
* config's syntax, the last value wins), the `--edit` / `--no-edit` and `-S` the run
|
|
842
|
+
* started with.
|
|
594
843
|
*/
|
|
595
844
|
private async readSavedOptions(): Promise<void> {
|
|
596
845
|
const text = await this.deps.state.read("sequencer/opts");
|
|
@@ -604,9 +853,27 @@ export class PickSequencer {
|
|
|
604
853
|
continue;
|
|
605
854
|
}
|
|
606
855
|
const entry = /^([A-Za-z][A-Za-z0-9-]*)\s*=\s*(.*)$/.exec(line);
|
|
607
|
-
if (section !== "options" || !entry
|
|
608
|
-
const
|
|
609
|
-
|
|
856
|
+
if (section !== "options" || !entry) continue;
|
|
857
|
+
const name = entry[1].toLowerCase();
|
|
858
|
+
const text = entry[2].replace(/^"(.*)"$/, "$1");
|
|
859
|
+
if (name === "gpg-sign") {
|
|
860
|
+
this.sign = text;
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
if (name === "mainline") {
|
|
864
|
+
const value = Number.parseInt(text, 10);
|
|
865
|
+
if (Number.isFinite(value)) this.flags.mainline = value;
|
|
866
|
+
continue;
|
|
867
|
+
}
|
|
868
|
+
if (name === "default-msg-cleanup") {
|
|
869
|
+
this.cleanup = cleanupOf(text) ?? this.cleanup;
|
|
870
|
+
continue;
|
|
871
|
+
}
|
|
872
|
+
const value = parseGitBool(text);
|
|
873
|
+
if (value === undefined) continue;
|
|
874
|
+
if (name === "edit") this.edit = value;
|
|
875
|
+
const key = SAVED_FLAGS[name];
|
|
876
|
+
if (key) this.flags[key] = value;
|
|
610
877
|
}
|
|
611
878
|
}
|
|
612
879
|
|
|
@@ -615,22 +882,74 @@ export class PickSequencer {
|
|
|
615
882
|
await this.deps.state.remove("MERGE_MSG", "sequencer");
|
|
616
883
|
}
|
|
617
884
|
|
|
618
|
-
/**
|
|
619
|
-
|
|
885
|
+
/**
|
|
886
|
+
* git's message for the commit a pick or revert makes (do_pick_commit's ctx->message): a
|
|
887
|
+
* pick's message from its subject on, with `-x`'s `(cherry picked from commit <id>)` (after a
|
|
888
|
+
* blank line unless the message ends with a trailer block); a revert's `Revert "<subject>"`
|
|
889
|
+
* (`Reapply "..."` for a revert of a revert, `--reference`'s comment and `<abbrev> (<subject>,
|
|
890
|
+
* <date>)`); then `-s`'s sign-off (append_signoff).
|
|
891
|
+
*/
|
|
892
|
+
private async messageFor(
|
|
620
893
|
action: PickAction,
|
|
621
894
|
id: ObjectId,
|
|
622
895
|
commit: Commit,
|
|
623
896
|
parentId: ObjectId | undefined,
|
|
624
|
-
): string {
|
|
897
|
+
): Promise<string> {
|
|
898
|
+
let message: string;
|
|
625
899
|
if (action === "pick") {
|
|
626
|
-
|
|
900
|
+
// find_commit_subject: the message from its first non-blank line
|
|
901
|
+
message = commit.message.replace(/^(?:[ \t]*\n)+/, "");
|
|
902
|
+
if (this.flags.recordOrigin) {
|
|
903
|
+
if (message.length > 0 && !message.endsWith("\n")) message += "\n";
|
|
904
|
+
if (trailerLinesOf(message, trailerConfigOf(this.deps.workingCopy)).length === 0) {
|
|
905
|
+
message += "\n";
|
|
906
|
+
}
|
|
907
|
+
message += `(cherry picked from commit ${id})\n`;
|
|
908
|
+
}
|
|
909
|
+
} else {
|
|
910
|
+
message = await this.revertMessage(id, commit, parentId);
|
|
627
911
|
}
|
|
912
|
+
if (this.flags.signoff) {
|
|
913
|
+
const committer = this.options.committer ?? committerIdentOf(this.deps.workingCopy);
|
|
914
|
+
message = appendSignoff(
|
|
915
|
+
message,
|
|
916
|
+
signoffLine(committer),
|
|
917
|
+
trailerConfigOf(this.deps.workingCopy),
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
return message;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/** sequencer_format_revert_message. */
|
|
924
|
+
private async revertMessage(
|
|
925
|
+
id: ObjectId,
|
|
926
|
+
commit: Commit,
|
|
927
|
+
parentId: ObjectId | undefined,
|
|
928
|
+
): Promise<string> {
|
|
628
929
|
const subject = subjectOf(commit.message);
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
930
|
+
const reference = this.options.reference ?? revertReferenceOf(this.deps.workingCopy);
|
|
931
|
+
let out: string;
|
|
932
|
+
if (reference) {
|
|
933
|
+
// git 2.43 wrote `#` whatever core.commentChar said (2.45 follows it)
|
|
934
|
+
const comment =
|
|
935
|
+
this.deps.hooks?.compatibility === "2.43" ? "#" : commentStringOf(this.deps.workingCopy);
|
|
936
|
+
out = `${comment} *** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***\n`;
|
|
937
|
+
} else if (subject.startsWith('Revert "') && !subject.slice(8).startsWith('Revert "')) {
|
|
938
|
+
out = `Reapply "${subject.slice(8)}\n`;
|
|
939
|
+
} else {
|
|
940
|
+
out = `Revert "${subject}"\n`;
|
|
941
|
+
}
|
|
942
|
+
const refer = async (target: ObjectId) => {
|
|
943
|
+
if (!reference) return target;
|
|
944
|
+
const referred = await this.deps.commits.load(target);
|
|
945
|
+
const short = await this.abbreviator.abbreviate(target);
|
|
946
|
+
return `${short} (${subjectOf(referred?.message ?? "")}, ${shortDate(referred?.author)})`;
|
|
947
|
+
};
|
|
948
|
+
out += `\nThis reverts commit ${await refer(id)}`;
|
|
949
|
+
if (commit.parents.length > 1 && parentId) {
|
|
950
|
+
out += `, reversing\nchanges made to ${await refer(parentId)}`;
|
|
951
|
+
}
|
|
952
|
+
return `${out}.\n`;
|
|
634
953
|
}
|
|
635
954
|
|
|
636
955
|
/**
|
|
@@ -658,24 +977,88 @@ export class PickSequencer {
|
|
|
658
977
|
author: PersonIdent,
|
|
659
978
|
committer: PersonIdent,
|
|
660
979
|
message: string,
|
|
661
|
-
reflogMessage: string,
|
|
980
|
+
reflogMessage: (text: string) => string,
|
|
981
|
+
/** a cleanup of the message after the hook (default: the sequencer's, see cleanupMode) */
|
|
982
|
+
cleanup: SequencerCleanup = this.commitCleanup(),
|
|
662
983
|
): Promise<ObjectId> {
|
|
663
984
|
// try_to_commit: prepare-commit-msg may rewrite the message; post-commit after
|
|
664
985
|
const hooks = this.deps.hooks;
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
986
|
+
let text = hooks ? await sequencerPrepareMessage(hooks, this.deps.state, message) : message;
|
|
987
|
+
if (cleanup !== "verbatim") {
|
|
988
|
+
text = stripspace(
|
|
989
|
+
text,
|
|
990
|
+
cleanup === "strip" ? commentStringOf(this.deps.workingCopy) : undefined,
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
const id = await this.deps.commits.store(
|
|
994
|
+
await this.signed({ tree, parents, author, committer, message: text }),
|
|
995
|
+
);
|
|
996
|
+
await this.moveHead(id, reflogMessage(text));
|
|
668
997
|
if (hooks) await sequencerPostCommit(hooks);
|
|
669
998
|
return id;
|
|
670
999
|
}
|
|
671
1000
|
|
|
1001
|
+
/**
|
|
1002
|
+
* try_to_commit's cleanup: whitespace for `-s`/`-x` unless commit.cleanup is set, else
|
|
1003
|
+
* commit.cleanup's (`scissors` is whitespace without an editor), else none.
|
|
1004
|
+
*/
|
|
1005
|
+
private commitCleanup(): SequencerCleanup {
|
|
1006
|
+
if ((this.flags.signoff || this.flags.recordOrigin) && !this.cleanup) return "whitespace";
|
|
1007
|
+
if (this.cleanup === "scissors") return "whitespace";
|
|
1008
|
+
return this.cleanup ?? "verbatim";
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* try_to_commit's commit_tree signing `commit` for the run's key (git's opts->gpg_sign),
|
|
1013
|
+
* the signing program in the worktree top. When it cannot be signed: gpg's error and
|
|
1014
|
+
* `error: failed to write commit object`, then in git 2.43 `fatal: <action> failed` (exit
|
|
1015
|
+
* 128); 2.5x returns after the error (exit 1). The pick stays in progress
|
|
1016
|
+
* (CHERRY_PICK_HEAD, MERGE_MSG), as git leaves it.
|
|
1017
|
+
*/
|
|
1018
|
+
private async signed(commit: Commit): Promise<Commit> {
|
|
1019
|
+
const sign = this.sign;
|
|
1020
|
+
if (sign === undefined) return commit;
|
|
1021
|
+
const legacy = this.deps.hooks?.compatibility === "2.43";
|
|
1022
|
+
const cwd = await this.deps.hooks?.hostWorkingDirectory().catch(() => undefined);
|
|
1023
|
+
try {
|
|
1024
|
+
return await signCommit(this.deps.workingCopy, sign, commit, {
|
|
1025
|
+
tail: [],
|
|
1026
|
+
...(cwd !== undefined ? { cwd } : {}),
|
|
1027
|
+
});
|
|
1028
|
+
} catch (error) {
|
|
1029
|
+
if (!(error instanceof SigningFailedError)) throw error;
|
|
1030
|
+
// the signing died itself (ssh without a key): git dies there
|
|
1031
|
+
if (/(^|\n)fatal: [^\n]*$/.test(error.message)) throw error;
|
|
1032
|
+
throw new SigningFailedError(
|
|
1033
|
+
[
|
|
1034
|
+
error.message,
|
|
1035
|
+
"error: failed to write commit object",
|
|
1036
|
+
...(legacy ? [`fatal: ${this.name} failed`] : []),
|
|
1037
|
+
].join("\n"),
|
|
1038
|
+
sign,
|
|
1039
|
+
legacy ? 128 : 1,
|
|
1040
|
+
{
|
|
1041
|
+
...(error.signerMessages ? { signerMessages: error.signerMessages } : {}),
|
|
1042
|
+
...(error.programExitCode !== undefined
|
|
1043
|
+
? { programExitCode: error.programExitCode }
|
|
1044
|
+
: {}),
|
|
1045
|
+
},
|
|
1046
|
+
);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
|
|
672
1050
|
/** HEAD (its branch, when attached) moved to `id`, with `message` in the reflogs. */
|
|
673
|
-
private async moveHead(
|
|
1051
|
+
private async moveHead(
|
|
1052
|
+
id: ObjectId,
|
|
1053
|
+
message: string,
|
|
1054
|
+
/** the old value the transaction expects (default HEAD's, null for an unborn HEAD) */
|
|
1055
|
+
expected?: ObjectId | null,
|
|
1056
|
+
): Promise<void> {
|
|
674
1057
|
this.clock ??= Math.floor(Date.now() / 1000);
|
|
675
1058
|
const log = reflogLine(this.deps.workingCopy, message, this.options.committer, this.clock);
|
|
676
1059
|
// update_head_with_reflog: one transaction on HEAD expecting the commit's parent, as the
|
|
677
1060
|
// reference-transaction hook sees it
|
|
678
|
-
const current =
|
|
1061
|
+
const current = expected !== undefined ? expected : await this.headIfBorn();
|
|
679
1062
|
const result = await this.deps.refs.batch(
|
|
680
1063
|
[{ name: "HEAD", old: current ?? null, new: id }],
|
|
681
1064
|
log,
|
|
@@ -731,6 +1114,12 @@ export class PickSequencer {
|
|
|
731
1114
|
);
|
|
732
1115
|
}
|
|
733
1116
|
|
|
1117
|
+
/** HEAD's commit, undefined while HEAD's branch is unborn. */
|
|
1118
|
+
private async headIfBorn(): Promise<ObjectId | undefined> {
|
|
1119
|
+
const resolved = await this.deps.refs.resolve("HEAD").catch(() => undefined);
|
|
1120
|
+
return resolved?.objectId || undefined;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
734
1123
|
private async headId(): Promise<ObjectId> {
|
|
735
1124
|
const resolved = await this.deps.refs.resolve("HEAD");
|
|
736
1125
|
if (!resolved?.objectId) throw new RefNotFoundError("HEAD", "HEAD cannot be resolved");
|
|
@@ -872,3 +1261,27 @@ export async function expandCommitIds(
|
|
|
872
1261
|
return found;
|
|
873
1262
|
});
|
|
874
1263
|
}
|
|
1264
|
+
|
|
1265
|
+
/** `revert.reference` (git_sequencer_config, revert only). */
|
|
1266
|
+
function revertReferenceOf(workingCopy: SequencerDeps["workingCopy"]): boolean {
|
|
1267
|
+
const value = RemoteConfigStore.from(workingCopy).value("revert.reference");
|
|
1268
|
+
return value === undefined ? false : (parseGitBool(value) ?? false);
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/** comment_line_str: `core.commentString`, else `core.commentChar` (`auto`: `#`). */
|
|
1272
|
+
function commentStringOf(workingCopy: SequencerDeps["workingCopy"]): string {
|
|
1273
|
+
const config = RemoteConfigStore.from(workingCopy);
|
|
1274
|
+
const value = config.value("core.commentString") ?? config.value("core.commentChar");
|
|
1275
|
+
return value && value !== "auto" ? value : "#";
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
/** DATE_SHORT of an ident: `YYYY-MM-DD` in its own zone. */
|
|
1279
|
+
function shortDate(ident: PersonIdent | undefined): string {
|
|
1280
|
+
if (!ident) return "";
|
|
1281
|
+
const tz = ident.tzOffset || "+0000";
|
|
1282
|
+
const sign = tz.startsWith("-") ? -1 : 1;
|
|
1283
|
+
const minutes = sign * (Number(tz.slice(1, 3)) * 60 + Number(tz.slice(3, 5)));
|
|
1284
|
+
const d = new Date((ident.timestamp + minutes * 60) * 1000);
|
|
1285
|
+
const pad = (n: number) => String(n).padStart(2, "0");
|
|
1286
|
+
return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())}`;
|
|
1287
|
+
}
|