@statewalker/vcs-commands 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/add-command.d.ts +70 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/add-patch.d.ts +7 -0
- package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +102 -1
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/am/index.d.ts +1 -0
- package/dist/commands/am/index.d.ts.map +1 -1
- package/dist/commands/am/mailsplit.d.ts +88 -0
- package/dist/commands/am/mailsplit.d.ts.map +1 -0
- package/dist/commands/apply/apply-command.d.ts +2 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-engine.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.d.ts +7 -0
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/apply/index.d.ts +1 -1
- package/dist/commands/apply/index.d.ts.map +1 -1
- package/dist/commands/bisect/bisect-command.d.ts +2 -0
- package/dist/commands/bisect/bisect-command.d.ts.map +1 -1
- package/dist/commands/blame-command.d.ts +303 -8
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/blame-ignore.d.ts +48 -0
- package/dist/commands/blame-ignore.d.ts.map +1 -0
- package/dist/commands/branch-command.d.ts +148 -18
- package/dist/commands/branch-command.d.ts.map +1 -1
- package/dist/commands/branch-info-command.d.ts +55 -0
- package/dist/commands/branch-info-command.d.ts.map +1 -0
- package/dist/commands/branch-tracking.d.ts +106 -17
- package/dist/commands/branch-tracking.d.ts.map +1 -1
- package/dist/commands/branch-upstream-command.d.ts +83 -0
- package/dist/commands/branch-upstream-command.d.ts.map +1 -0
- package/dist/commands/check-mailmap-command.d.ts +49 -0
- package/dist/commands/check-mailmap-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +26 -3
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-paths.d.ts +4 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-command.d.ts +61 -0
- package/dist/commands/cherry-command.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +82 -1
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +44 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +56 -0
- package/dist/commands/clean-interactive.d.ts.map +1 -0
- package/dist/commands/clone-command.d.ts +116 -2
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +239 -5
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/commit-reuse.d.ts +33 -0
- package/dist/commands/commit-reuse.d.ts.map +1 -0
- package/dist/commands/config-command.d.ts +236 -0
- package/dist/commands/config-command.d.ts.map +1 -0
- package/dist/commands/config-value-types.d.ts +91 -0
- package/dist/commands/config-value-types.d.ts.map +1 -0
- package/dist/commands/core-config.d.ts +20 -0
- package/dist/commands/core-config.d.ts.map +1 -1
- package/dist/commands/describe-command.d.ts +71 -64
- package/dist/commands/describe-command.d.ts.map +1 -1
- package/dist/commands/diff-color-config.d.ts +73 -0
- package/dist/commands/diff-color-config.d.ts.map +1 -0
- package/dist/commands/diff-command.d.ts +369 -10
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +80 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fetch-multiple-command.d.ts +193 -0
- package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
- package/dist/commands/fmt-merge-msg-command.d.ts +124 -0
- package/dist/commands/fmt-merge-msg-command.d.ts.map +1 -0
- package/dist/commands/fork-point.d.ts +38 -0
- package/dist/commands/fork-point.d.ts.map +1 -0
- package/dist/commands/format-patch-command.d.ts +69 -3
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/fsck/fetch-fsck.d.ts +51 -0
- package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -1
- package/dist/commands/gc-command.d.ts +8 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +81 -4
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +50 -1
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/grep/grep-command.d.ts +210 -0
- package/dist/commands/grep/grep-command.d.ts.map +1 -0
- package/dist/commands/grep/grep-engine.d.ts +218 -0
- package/dist/commands/grep/grep-engine.d.ts.map +1 -0
- package/dist/commands/grep/index.d.ts +3 -0
- package/dist/commands/grep/index.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +13 -2
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index.d.ts +38 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +5 -3
- package/dist/commands/init-command.d.ts +89 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/interpret-trailers-command.d.ts +90 -0
- package/dist/commands/interpret-trailers-command.d.ts.map +1 -0
- package/dist/commands/line-log.d.ts +161 -0
- package/dist/commands/line-log.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts +36 -5
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +527 -13
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +30 -3
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +199 -6
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-remote-command.d.ts +2 -0
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/mailmap.d.ts +53 -0
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/merge-base-command.d.ts +60 -0
- package/dist/commands/merge-base-command.d.ts.map +1 -0
- package/dist/commands/merge-bases.d.ts +23 -0
- package/dist/commands/merge-bases.d.ts.map +1 -1
- package/dist/commands/merge-command.d.ts +147 -10
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-drivers.d.ts +2 -0
- package/dist/commands/merge-drivers.d.ts.map +1 -1
- package/dist/commands/merge-strategy-options.d.ts +69 -0
- package/dist/commands/merge-strategy-options.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +10 -0
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/message-cleanup.d.ts +2 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -1
- package/dist/commands/mv-command.d.ts +4 -0
- package/dist/commands/mv-command.d.ts.map +1 -1
- package/dist/commands/name-rev-command.d.ts +65 -0
- package/dist/commands/name-rev-command.d.ts.map +1 -0
- package/dist/commands/name-rev.d.ts +136 -0
- package/dist/commands/name-rev.d.ts.map +1 -0
- package/dist/commands/notes-command.d.ts.map +1 -1
- package/dist/commands/octopus-merge.d.ts +26 -1
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/ort-merge.d.ts +16 -0
- package/dist/commands/ort-merge.d.ts.map +1 -1
- package/dist/commands/ort-recursive.d.ts.map +1 -1
- package/dist/commands/patch-id.d.ts +58 -0
- package/dist/commands/patch-id.d.ts.map +1 -1
- package/dist/commands/pathspec-file.d.ts +39 -0
- package/dist/commands/pathspec-file.d.ts.map +1 -0
- package/dist/commands/pathspec.d.ts +3 -0
- package/dist/commands/pathspec.d.ts.map +1 -1
- package/dist/commands/pretty-format.d.ts +43 -3
- package/dist/commands/pretty-format.d.ts.map +1 -1
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +186 -32
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +225 -9
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/index.d.ts +4 -0
- package/dist/commands/range-diff/index.d.ts.map +1 -0
- package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
- package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff.d.ts +106 -0
- package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
- package/dist/commands/read-tree-command.d.ts +20 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +189 -8
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/for-each-ref-command.d.ts +121 -0
- package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -0
- package/dist/commands/ref-filter/index.d.ts +8 -0
- package/dist/commands/ref-filter/index.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-atoms.d.ts +88 -0
- package/dist/commands/ref-filter/ref-atoms.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-filter.d.ts +178 -0
- package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-format.d.ts +222 -0
- package/dist/commands/ref-filter/ref-format.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts +56 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-quote.d.ts +20 -0
- package/dist/commands/ref-filter/ref-quote.d.ts.map +1 -0
- package/dist/commands/ref-filter/version-compare.d.ts +20 -0
- package/dist/commands/ref-filter/version-compare.d.ts.map +1 -0
- package/dist/commands/reflog-command.d.ts +120 -0
- package/dist/commands/reflog-command.d.ts.map +1 -1
- package/dist/commands/reflog-walk.d.ts +72 -0
- package/dist/commands/reflog-walk.d.ts.map +1 -0
- package/dist/commands/remerge-diff.d.ts +59 -0
- package/dist/commands/remerge-diff.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +179 -29
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-show-command.d.ts +204 -0
- package/dist/commands/remote-show-command.d.ts.map +1 -0
- package/dist/commands/remote-transport.d.ts +7 -1
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/reset-command.d.ts +21 -4
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +9 -3
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-filter/commit-filter.d.ts +95 -0
- package/dist/commands/rev-filter/commit-filter.d.ts.map +1 -0
- package/dist/commands/rev-filter/commit-grep.d.ts +91 -0
- package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -0
- package/dist/commands/rev-filter/index.d.ts +3 -0
- package/dist/commands/rev-filter/index.d.ts.map +1 -0
- package/dist/commands/rev-list-command.d.ts +226 -2
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +54 -1
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +34 -1
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +15 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/rm-command.d.ts +70 -2
- package/dist/commands/rm-command.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +186 -5
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +12 -1
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +7 -0
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/shortlog-command.d.ts +109 -0
- package/dist/commands/shortlog-command.d.ts.map +1 -0
- package/dist/commands/shortlog.d.ts +151 -0
- package/dist/commands/shortlog.d.ts.map +1 -0
- package/dist/commands/show-command.d.ts +130 -0
- package/dist/commands/show-command.d.ts.map +1 -0
- package/dist/commands/show-commit.d.ts +11 -0
- package/dist/commands/show-commit.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +164 -0
- package/dist/commands/signature-check.d.ts.map +1 -0
- package/dist/commands/signing.d.ts +160 -0
- package/dist/commands/signing.d.ts.map +1 -0
- package/dist/commands/sparse-checkout-command.d.ts.map +1 -1
- package/dist/commands/sparse-index-view.d.ts +45 -0
- package/dist/commands/sparse-index-view.d.ts.map +1 -0
- package/dist/commands/ssh-signer.d.ts +29 -0
- package/dist/commands/ssh-signer.d.ts.map +1 -0
- package/dist/commands/ssh-verifier.d.ts +42 -0
- package/dist/commands/ssh-verifier.d.ts.map +1 -0
- package/dist/commands/stash-apply-command.d.ts +5 -0
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-branch-command.d.ts +34 -0
- package/dist/commands/stash-branch-command.d.ts.map +1 -0
- package/dist/commands/stash-create-command.d.ts +17 -0
- package/dist/commands/stash-create-command.d.ts.map +1 -1
- package/dist/commands/stash-info.d.ts +93 -0
- package/dist/commands/stash-info.d.ts.map +1 -0
- package/dist/commands/stash-list-command.d.ts +16 -0
- package/dist/commands/stash-list-command.d.ts.map +1 -1
- package/dist/commands/stash-pop-command.d.ts +39 -0
- package/dist/commands/stash-pop-command.d.ts.map +1 -0
- package/dist/commands/stash-show-command.d.ts +48 -0
- package/dist/commands/stash-show-command.d.ts.map +1 -0
- package/dist/commands/stash-store-command.d.ts +29 -0
- package/dist/commands/stash-store-command.d.ts.map +1 -0
- package/dist/commands/stash-working-tree.d.ts.map +1 -1
- package/dist/commands/status-command.d.ts +31 -2
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/status-header.d.ts +5 -0
- package/dist/commands/status-header.d.ts.map +1 -1
- package/dist/commands/submodule-add-command.d.ts +89 -0
- package/dist/commands/submodule-add-command.d.ts.map +1 -0
- package/dist/commands/submodule-auth.d.ts +90 -0
- package/dist/commands/submodule-auth.d.ts.map +1 -0
- package/dist/commands/submodule-commands.d.ts +463 -0
- package/dist/commands/submodule-commands.d.ts.map +1 -0
- package/dist/commands/submodule-fetch.d.ts +149 -0
- package/dist/commands/submodule-fetch.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +296 -0
- package/dist/commands/submodule-model.d.ts.map +1 -0
- package/dist/commands/submodule-unpack.d.ts +120 -0
- package/dist/commands/submodule-unpack.d.ts.map +1 -0
- package/dist/commands/submodule-update-command.d.ts +206 -0
- package/dist/commands/submodule-update-command.d.ts.map +1 -0
- package/dist/commands/subtree-shift.d.ts +27 -0
- package/dist/commands/subtree-shift.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts +3 -0
- package/dist/commands/switch-command.d.ts.map +1 -1
- package/dist/commands/tag-command.d.ts +259 -10
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/trailers.d.ts +218 -17
- package/dist/commands/trailers.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts +7 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/verify-command.d.ts +92 -0
- package/dist/commands/verify-command.d.ts.map +1 -0
- package/dist/commands/worktree-add-command.d.ts +79 -7
- package/dist/commands/worktree-add-command.d.ts.map +1 -1
- package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/commands/worktree-path-rules.d.ts +66 -0
- package/dist/commands/worktree-path-rules.d.ts.map +1 -0
- package/dist/commands/worktree-remove-command.d.ts +10 -3
- package/dist/commands/worktree-remove-command.d.ts.map +1 -1
- package/dist/commands/worktree-repair-command.d.ts +15 -2
- package/dist/commands/worktree-repair-command.d.ts.map +1 -1
- package/dist/commands/worktree-support.d.ts +5 -0
- package/dist/commands/worktree-support.d.ts.map +1 -1
- package/dist/{commands-DIJ91NnD.js → commands-CNvli5bl.js} +49442 -54941
- package/dist/errors/checkout-errors.d.ts +19 -0
- package/dist/errors/checkout-errors.d.ts.map +1 -1
- package/dist/errors/command-errors.d.ts +25 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +85 -3
- package/dist/errors/ref-errors.d.ts +19 -0
- package/dist/errors/ref-errors.d.ts.map +1 -1
- package/dist/errors/worktree-errors.d.ts +6 -1
- package/dist/errors/worktree-errors.d.ts.map +1 -1
- package/dist/fsck-CPeDh9fh.js +5138 -0
- package/dist/git-command.d.ts +58 -2
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +363 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +82 -0
- package/dist/guarded-transport-command.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/remote-config/index.d.ts +1 -1
- package/dist/remote-config/index.d.ts.map +1 -1
- package/dist/remote-config/remote-config-store.d.ts +55 -0
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/remote-transport-CCmBadm-.js +1606 -0
- package/dist/rename/detect-renames.d.ts +20 -0
- package/dist/rename/detect-renames.d.ts.map +1 -1
- package/dist/rename/diffcore-break.d.ts +51 -0
- package/dist/rename/diffcore-break.d.ts.map +1 -0
- package/dist/rename/index.d.ts +1 -0
- package/dist/rename/index.d.ts.map +1 -1
- package/dist/results/blame-format.d.ts +62 -1
- package/dist/results/blame-format.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +9 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/combined-diff.d.ts +3 -0
- package/dist/results/combined-diff.d.ts.map +1 -1
- package/dist/results/diff-check.d.ts +38 -0
- package/dist/results/diff-check.d.ts.map +1 -0
- package/dist/results/diff-color.d.ts +135 -0
- package/dist/results/diff-color.d.ts.map +1 -0
- package/dist/results/diff-dirstat.d.ts +36 -0
- package/dist/results/diff-dirstat.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +10 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +103 -1
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/diff-pickaxe.d.ts +67 -0
- package/dist/results/diff-pickaxe.d.ts.map +1 -0
- package/dist/results/diff-words.d.ts +55 -0
- package/dist/results/diff-words.d.ts.map +1 -0
- package/dist/results/fetch-result.d.ts +12 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +6 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/init-result.d.ts +8 -1
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/line-range-hunks.d.ts +27 -0
- package/dist/results/line-range-hunks.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +8 -1
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +11 -0
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +12 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +2 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +6 -0
- package/dist/results/stash-result.d.ts.map +1 -1
- package/dist/results/status-result.d.ts +1 -1
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-BDuEgdLU.js +46847 -0
- package/dist/transport-command.d.ts +14 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/dist/whitespace/index.d.ts +2 -0
- package/dist/whitespace/index.d.ts.map +1 -0
- package/dist/whitespace/whitespace-rule.d.ts +94 -0
- package/dist/whitespace/whitespace-rule.d.ts.map +1 -0
- package/package.json +12 -12
- package/src/commands/add-command.ts +293 -17
- package/src/commands/add-patch/add-patch.ts +8 -0
- package/src/commands/add-patch/patch-backend.ts +20 -2
- package/src/commands/am/am-command.ts +400 -46
- package/src/commands/am/index.ts +1 -0
- package/src/commands/am/mailsplit.ts +326 -0
- package/src/commands/apply/apply-command.ts +58 -15
- package/src/commands/apply/apply-engine.ts +1 -1
- package/src/commands/apply/apply-parse.ts +17 -8
- package/src/commands/apply/index.ts +8 -1
- package/src/commands/bisect/bisect-command.ts +18 -5
- package/src/commands/blame-command.ts +1450 -51
- package/src/commands/blame-ignore.ts +307 -0
- package/src/commands/branch-command.ts +528 -53
- package/src/commands/branch-info-command.ts +150 -0
- package/src/commands/branch-tracking.ts +335 -60
- package/src/commands/branch-upstream-command.ts +218 -0
- package/src/commands/check-mailmap-command.ts +129 -0
- package/src/commands/checkout-command.ts +166 -55
- package/src/commands/checkout-paths.ts +28 -0
- package/src/commands/cherry-command.ts +187 -0
- package/src/commands/cherry-pick-command.ts +185 -1
- package/src/commands/clean-command.ts +126 -15
- package/src/commands/clean-interactive.ts +522 -0
- package/src/commands/clone-command.ts +598 -45
- package/src/commands/commit-command.ts +925 -74
- package/src/commands/commit-reuse.ts +94 -0
- package/src/commands/config-command.ts +1256 -0
- package/src/commands/config-value-types.ts +358 -0
- package/src/commands/core-config.ts +40 -0
- package/src/commands/describe-command.ts +341 -254
- package/src/commands/diff-color-config.ts +274 -0
- package/src/commands/diff-command.ts +1619 -99
- package/src/commands/fetch-command.ts +495 -14
- package/src/commands/fetch-multiple-command.ts +665 -0
- package/src/commands/fmt-merge-msg-command.ts +715 -0
- package/src/commands/fork-point.ts +63 -0
- package/src/commands/format-patch-command.ts +496 -116
- package/src/commands/fsck/fetch-fsck.ts +172 -18
- package/src/commands/gc-command.ts +31 -1
- package/src/commands/git-describe.ts +460 -201
- package/src/commands/git-hooks.ts +123 -3
- package/src/commands/grep/grep-command.ts +1077 -0
- package/src/commands/grep/grep-engine.ts +1024 -0
- package/src/commands/grep/index.ts +2 -0
- package/src/commands/index-adder.ts +46 -7
- package/src/commands/index.ts +43 -0
- package/src/commands/init-command.ts +603 -49
- package/src/commands/interpret-trailers-command.ts +256 -0
- package/src/commands/line-log.ts +931 -0
- package/src/commands/local-transport.ts +109 -10
- package/src/commands/log-command.ts +2599 -326
- package/src/commands/log-graph.ts +129 -29
- package/src/commands/log-output.ts +449 -27
- package/src/commands/ls-remote-command.ts +5 -0
- package/src/commands/mailmap.ts +155 -0
- package/src/commands/merge-base-command.ts +170 -0
- package/src/commands/merge-bases.ts +63 -8
- package/src/commands/merge-command.ts +601 -95
- package/src/commands/merge-drivers.ts +3 -0
- package/src/commands/merge-strategy-options.ts +224 -0
- package/src/commands/merge-support.ts +115 -22
- package/src/commands/message-cleanup.ts +1 -1
- package/src/commands/mv-command.ts +6 -3
- package/src/commands/name-rev-command.ts +184 -0
- package/src/commands/name-rev.ts +762 -0
- package/src/commands/notes-command.ts +11 -1
- package/src/commands/octopus-merge.ts +35 -11
- package/src/commands/ort-merge.ts +41 -7
- package/src/commands/ort-recursive.ts +40 -2
- package/src/commands/patch-id.ts +109 -0
- package/src/commands/pathspec-file.ts +72 -0
- package/src/commands/pathspec.ts +14 -2
- package/src/commands/pretty-format.ts +103 -19
- package/src/commands/promisor-remote.ts +10 -1
- package/src/commands/pull-command.ts +734 -221
- package/src/commands/push-command.ts +1035 -68
- package/src/commands/range-diff/index.ts +3 -0
- package/src/commands/range-diff/linear-assignment.ts +203 -0
- package/src/commands/range-diff/range-diff-command.ts +433 -0
- package/src/commands/range-diff/range-diff.ts +617 -0
- package/src/commands/read-tree-command.ts +102 -4
- package/src/commands/rebase-command.ts +1074 -194
- package/src/commands/ref-filter/for-each-ref-command.ts +298 -0
- package/src/commands/ref-filter/index.ts +7 -0
- package/src/commands/ref-filter/ref-atoms.ts +581 -0
- package/src/commands/ref-filter/ref-filter.ts +651 -0
- package/src/commands/ref-filter/ref-format.ts +1070 -0
- package/src/commands/ref-filter/ref-listing-command.ts +421 -0
- package/src/commands/ref-filter/ref-quote.ts +69 -0
- package/src/commands/ref-filter/version-compare.ts +177 -0
- package/src/commands/reflog-command.ts +492 -2
- package/src/commands/reflog-walk.ts +234 -0
- package/src/commands/remerge-diff.ts +241 -0
- package/src/commands/remote-command.ts +537 -69
- package/src/commands/remote-show-command.ts +836 -0
- package/src/commands/remote-transport.ts +9 -1
- package/src/commands/reset-command.ts +114 -34
- package/src/commands/restore-command.ts +27 -41
- package/src/commands/rev-filter/commit-filter.ts +159 -0
- package/src/commands/rev-filter/commit-grep.ts +444 -0
- package/src/commands/rev-filter/index.ts +2 -0
- package/src/commands/rev-list-command.ts +578 -15
- package/src/commands/revert-command.ts +123 -1
- package/src/commands/revision-range.ts +207 -5
- package/src/commands/revision-resolver.ts +23 -8
- package/src/commands/rm-command.ts +282 -21
- package/src/commands/sequencer-pick.ts +818 -111
- package/src/commands/sequencer-support.ts +184 -4
- package/src/commands/serve-repository.ts +18 -3
- package/src/commands/shortlog-command.ts +354 -0
- package/src/commands/shortlog.ts +361 -0
- package/src/commands/show-command.ts +491 -0
- package/src/commands/show-commit.ts +24 -0
- package/src/commands/signature-check.ts +657 -0
- package/src/commands/signing.ts +385 -0
- package/src/commands/sparse-checkout-command.ts +2 -9
- package/src/commands/sparse-checkout-support.ts +2 -2
- package/src/commands/sparse-index-view.ts +135 -0
- package/src/commands/ssh-signer.ts +199 -0
- package/src/commands/ssh-verifier.ts +523 -0
- package/src/commands/stash-apply-command.ts +16 -4
- package/src/commands/stash-branch-command.ts +88 -0
- package/src/commands/stash-create-command.ts +28 -0
- package/src/commands/stash-info.ts +243 -0
- package/src/commands/stash-list-command.ts +33 -0
- package/src/commands/stash-pop-command.ts +83 -0
- package/src/commands/stash-show-command.ts +141 -0
- package/src/commands/stash-store-command.ts +82 -0
- package/src/commands/stash-working-tree.ts +2 -2
- package/src/commands/status-command.ts +120 -27
- package/src/commands/status-format.ts +1 -1
- package/src/commands/status-header.ts +41 -7
- package/src/commands/submodule-add-command.ts +509 -0
- package/src/commands/submodule-auth.ts +276 -0
- package/src/commands/submodule-commands.ts +1835 -0
- package/src/commands/submodule-fetch.ts +789 -0
- package/src/commands/submodule-model.ts +938 -0
- package/src/commands/submodule-unpack.ts +265 -0
- package/src/commands/submodule-update-command.ts +1126 -0
- package/src/commands/subtree-shift.ts +215 -0
- package/src/commands/switch-command.ts +12 -1
- package/src/commands/tag-command.ts +876 -64
- package/src/commands/trailers.ts +837 -100
- package/src/commands/tree-restore.ts +44 -11
- package/src/commands/verify-command.ts +235 -0
- package/src/commands/worktree-add-command.ts +268 -24
- package/src/commands/worktree-overwrite-checks.ts +5 -0
- package/src/commands/worktree-path-rules.ts +183 -0
- package/src/commands/worktree-remove-command.ts +39 -5
- package/src/commands/worktree-repair-command.ts +52 -5
- package/src/commands/worktree-support.ts +22 -1
- package/src/errors/checkout-errors.ts +29 -0
- package/src/errors/command-errors.ts +37 -1
- package/src/errors/ref-errors.ts +23 -0
- package/src/errors/worktree-errors.ts +8 -1
- package/src/git-command.ts +153 -2
- package/src/git.ts +550 -1
- package/src/guarded-transport-command.ts +171 -0
- package/src/index.ts +1 -0
- package/src/remote-config/index.ts +2 -0
- package/src/remote-config/remote-config-store.ts +101 -0
- package/src/rename/detect-renames.ts +42 -8
- package/src/rename/diffcore-break.ts +166 -0
- package/src/rename/index.ts +1 -0
- package/src/results/blame-format.ts +268 -43
- package/src/results/clone-result.ts +6 -0
- package/src/results/combined-diff.ts +38 -18
- package/src/results/diff-check.ts +185 -0
- package/src/results/diff-color.ts +868 -0
- package/src/results/diff-dirstat.ts +117 -0
- package/src/results/diff-entry.ts +12 -0
- package/src/results/diff-formatter.ts +1 -0
- package/src/results/diff-output.ts +322 -32
- package/src/results/diff-pickaxe.ts +304 -0
- package/src/results/diff-words.ts +395 -0
- package/src/results/fetch-result.ts +12 -1
- package/src/results/index.ts +6 -0
- package/src/results/init-result.ts +10 -1
- package/src/results/line-range-hunks.ts +126 -0
- package/src/results/merge-result.ts +9 -0
- package/src/results/pull-result.ts +7 -0
- package/src/results/push-result.ts +12 -0
- package/src/results/rebase-result.ts +3 -0
- package/src/results/stash-result.ts +7 -0
- package/src/results/status-result.ts +2 -2
- package/src/transport-command.ts +34 -3
- package/src/whitespace/index.ts +1 -0
- package/src/{commands/apply/whitespace.ts → whitespace/whitespace-rule.ts} +173 -23
- package/dist/commands/apply/whitespace.d.ts +0 -58
- package/dist/commands/apply/whitespace.d.ts.map +0 -1
- package/dist/git-command-BGiOJ8Zk.js +0 -7246
- package/dist/results-WVlBhVb1.js +0 -2935
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
type TreeEntry,
|
|
7
7
|
} from "@statewalker/vcs-core";
|
|
8
8
|
import { FileStagingStore } from "@statewalker/vcs-store-files";
|
|
9
|
+
import { compilePosixRegex, type PosixRegex } from "@statewalker/vcs-utils";
|
|
9
10
|
import { compareGitPaths } from "@statewalker/vcs-utils/encoding";
|
|
10
11
|
import type { FilesApi } from "@statewalker/vcs-utils/files";
|
|
11
12
|
import {
|
|
@@ -16,7 +17,6 @@ import {
|
|
|
16
17
|
type Worktree,
|
|
17
18
|
type WorktreeEntry,
|
|
18
19
|
} from "@statewalker/vcs-working-tree";
|
|
19
|
-
|
|
20
20
|
import {
|
|
21
21
|
EmptyCommitError,
|
|
22
22
|
GitApiError,
|
|
@@ -33,13 +33,40 @@ import {
|
|
|
33
33
|
import { GitCommand } from "../git-command.js";
|
|
34
34
|
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
35
35
|
import { AddCommand } from "./add-command.js";
|
|
36
|
+
import {
|
|
37
|
+
type PatchCompatibility,
|
|
38
|
+
type PatchOptions,
|
|
39
|
+
type PatchResult,
|
|
40
|
+
type PatchSelector,
|
|
41
|
+
patchModeFor,
|
|
42
|
+
runPatchSelection,
|
|
43
|
+
type TemporaryIndex,
|
|
44
|
+
} from "./add-patch/index.js";
|
|
45
|
+
import {
|
|
46
|
+
amendCommitText,
|
|
47
|
+
autosquashSubject,
|
|
48
|
+
commitSubjectLength,
|
|
49
|
+
type FixupKind,
|
|
50
|
+
parseFixupSpec,
|
|
51
|
+
refuseIncompatible,
|
|
52
|
+
skipBlankLines,
|
|
53
|
+
} from "./commit-reuse.js";
|
|
36
54
|
import { worktreeModeTrust } from "./core-config.js";
|
|
37
55
|
import { DEFAULT_DATE_MODE, showDate } from "./date-format.js";
|
|
38
|
-
import {
|
|
56
|
+
import { approxidateCareful } from "./git-date.js";
|
|
57
|
+
import {
|
|
58
|
+
hostEnvironmentOf,
|
|
59
|
+
InvalidDateError,
|
|
60
|
+
InvalidIdentError,
|
|
61
|
+
parseGitDate,
|
|
62
|
+
withoutCrud,
|
|
63
|
+
} from "./git-ident.js";
|
|
39
64
|
import { IndexAdder, readGitlinkHead } from "./index-adder.js";
|
|
65
|
+
import { reencodedCommitParts } from "./log-output.js";
|
|
40
66
|
import {
|
|
41
67
|
flatTree,
|
|
42
68
|
OperationState,
|
|
69
|
+
rewriteIndex,
|
|
43
70
|
updateIndexCacheTree,
|
|
44
71
|
writeIndexAsTree,
|
|
45
72
|
} from "./merge-support.js";
|
|
@@ -63,8 +90,10 @@ import {
|
|
|
63
90
|
pathspecItemMayMatch,
|
|
64
91
|
} from "./pathspec.js";
|
|
65
92
|
import { PathspecAttributes } from "./pathspec-attributes.js";
|
|
93
|
+
import { PathspecFile } from "./pathspec-file.js";
|
|
66
94
|
import { type CommitReflogKind, reflogMessages, updateHead } from "./reflog-messages.js";
|
|
67
95
|
import { applyAutostash } from "./sequencer-support.js";
|
|
96
|
+
import { signCommit, signRequestOf } from "./signing.js";
|
|
68
97
|
import {
|
|
69
98
|
cutLine,
|
|
70
99
|
readShowUntrackedFiles,
|
|
@@ -74,6 +103,16 @@ import {
|
|
|
74
103
|
} from "./status-command.js";
|
|
75
104
|
import { type CommitWhence, StatusPrinter } from "./status-format.js";
|
|
76
105
|
import { readDiffSubmoduleConfig } from "./submodule-summary.js";
|
|
106
|
+
import {
|
|
107
|
+
amendWithTrailers,
|
|
108
|
+
appendSignoff,
|
|
109
|
+
ignoredLogMessageBytes,
|
|
110
|
+
signoffLine,
|
|
111
|
+
type TrailerCommandRunner,
|
|
112
|
+
trailerConfigOf,
|
|
113
|
+
validateTrailerArgs,
|
|
114
|
+
} from "./trailers.js";
|
|
115
|
+
import { worktreePathRules } from "./worktree-path-rules.js";
|
|
77
116
|
|
|
78
117
|
/**
|
|
79
118
|
* Result of a commit operation.
|
|
@@ -133,6 +172,8 @@ export interface CommitResult extends Commit {
|
|
|
133
172
|
* ```
|
|
134
173
|
*/
|
|
135
174
|
export class CommitCommand extends GitCommand<CommitResult> {
|
|
175
|
+
/** git's `error:` lines that do not stop the commit ({@link getWarnings}) */
|
|
176
|
+
private readonly stderrLines: string[] = [];
|
|
136
177
|
private message?: string;
|
|
137
178
|
private author?: PersonIdent;
|
|
138
179
|
private committer?: PersonIdent;
|
|
@@ -144,9 +185,13 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
144
185
|
private amend = false;
|
|
145
186
|
private noPostRewrite = false;
|
|
146
187
|
private noVerify = false;
|
|
188
|
+
/** `-S[<keyid>]` / `--no-gpg-sign` (undefined: `commit.gpgSign`) */
|
|
189
|
+
private sign?: boolean | string;
|
|
147
190
|
private allowEmpty = false;
|
|
148
191
|
private parents: ObjectId[] = [];
|
|
149
192
|
private onlyPaths: string[] = [];
|
|
193
|
+
/** `--pathspec-from-file` */
|
|
194
|
+
private readonly pathspecFile = new PathspecFile();
|
|
150
195
|
private all = false;
|
|
151
196
|
private include = false;
|
|
152
197
|
private includePaths: string[] = [];
|
|
@@ -163,6 +208,30 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
163
208
|
private nullTermination = false;
|
|
164
209
|
private aheadBehind?: boolean;
|
|
165
210
|
private templateFile?: string;
|
|
211
|
+
/** `--author=<string>` as given: `Name <email>`, or a pattern of an existing author */
|
|
212
|
+
private authorString?: string;
|
|
213
|
+
/** `--date=<date>`, and the clock its relative forms count from */
|
|
214
|
+
private forceDate?: { text: string; now?: number };
|
|
215
|
+
private signoff = false;
|
|
216
|
+
private trailerArgs: string[] = [];
|
|
217
|
+
/** `-C <commit>`: the commit whose message (and author) are reused */
|
|
218
|
+
private reuseMessage?: string;
|
|
219
|
+
/** The commit `-C` (or `-c`) names, read once the options are checked */
|
|
220
|
+
private reused?: Commit;
|
|
221
|
+
/** `-c <commit>` */
|
|
222
|
+
private reeditMessageFrom?: string;
|
|
223
|
+
/** `--fixup=[(amend|reword):]<commit>` as given */
|
|
224
|
+
private fixupSpec?: string;
|
|
225
|
+
/** `--squash=<commit>` */
|
|
226
|
+
private squashFrom?: string;
|
|
227
|
+
/** --fixup, parsed when the commit runs */
|
|
228
|
+
private fixup?: { kind: FixupKind; target: string };
|
|
229
|
+
/** `-p` / `--patch` */
|
|
230
|
+
private patch = false;
|
|
231
|
+
private patchSelector?: PatchSelector;
|
|
232
|
+
private patchOptions: PatchOptions = {};
|
|
233
|
+
private patchCompatibility: PatchCompatibility = "2.56";
|
|
234
|
+
private patchResult?: PatchResult;
|
|
166
235
|
|
|
167
236
|
/**
|
|
168
237
|
* Set the commit message, as git's `commit -m` takes it: its last line is ended and it is
|
|
@@ -221,17 +290,78 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
221
290
|
}
|
|
222
291
|
|
|
223
292
|
/**
|
|
224
|
-
* Set the author identity
|
|
293
|
+
* Set the author identity (git's `--author`): a name and an email, or one string as git's
|
|
294
|
+
* `--author=<author>` takes it. A string with a `>` is `Name <email>` (refused as
|
|
295
|
+
* `fatal: malformed --author parameter` without a `<`); any other is a pattern looked up as
|
|
296
|
+
* git's `find_author_by_nickname` does: the newest commit of `--all` whose (mailmapped)
|
|
297
|
+
* author matches it as a basic regular expression, ignoring case, gives its `Name <email>`,
|
|
298
|
+
* else `fatal: --author '<x>' is not 'Name <email>' and matches no existing author`.
|
|
225
299
|
*
|
|
226
|
-
* @
|
|
300
|
+
* @example
|
|
301
|
+
* ```typescript
|
|
302
|
+
* await git.commit().setAuthor("Ada <ada@example.com>").setMessage("m").call();
|
|
303
|
+
* await git.commit().setAuthor("ada").setMessage("m").call(); // an existing author
|
|
304
|
+
* ```
|
|
305
|
+
*
|
|
306
|
+
* @param name Author name, or the whole `--author` string when `email` is not given
|
|
227
307
|
* @param email Author email
|
|
228
308
|
*/
|
|
229
|
-
setAuthor(name: string, email
|
|
309
|
+
setAuthor(name: string, email?: string): this {
|
|
230
310
|
this.checkCallable();
|
|
231
311
|
// git's --author: the name and email; the date is the amended commit's, the picked
|
|
232
312
|
// commit's, else GIT_AUTHOR_DATE or now
|
|
233
313
|
this.author = undefined;
|
|
234
|
-
|
|
314
|
+
if (email === undefined) {
|
|
315
|
+
this.authorName = undefined;
|
|
316
|
+
this.authorString = name;
|
|
317
|
+
} else {
|
|
318
|
+
this.authorString = undefined;
|
|
319
|
+
this.authorName = { name, email };
|
|
320
|
+
}
|
|
321
|
+
return this;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* `--date=<date>`: the author's date, in any form git's `parse_date` reads (`@<seconds>
|
|
326
|
+
* <offset>`, RFC 2822, ISO 8601, ...) or else as `approxidate` reads it (`yesterday`,
|
|
327
|
+
* `2.weeks.ago`, `noon`), counting from `now` (seconds; default the command's clock, git's
|
|
328
|
+
* `GIT_TEST_DATE_NOW`). A date git cannot read fails as `fatal: invalid date format: <date>`.
|
|
329
|
+
*/
|
|
330
|
+
setDate(date: string, options: { now?: number } = {}): this {
|
|
331
|
+
this.checkCallable();
|
|
332
|
+
this.forceDate = { text: date, ...(options.now !== undefined ? { now: options.now } : {}) };
|
|
333
|
+
return this;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* `-s` / `--signoff`: a `Signed-off-by: <committer>` trailer added to the message as git's
|
|
338
|
+
* `append_signoff` adds it (after a blank line unless the message ends with trailers; none
|
|
339
|
+
* when the last trailer is that line already).
|
|
340
|
+
*/
|
|
341
|
+
setSignoff(signoff: boolean): this {
|
|
342
|
+
this.checkCallable();
|
|
343
|
+
this.signoff = signoff;
|
|
344
|
+
return this;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* `--trailer <token>[(=|:)<value>]`: a trailer added to the message as `git
|
|
349
|
+
* interpret-trailers --no-divider --trailer` adds it (`trailer.*` configuration applies).
|
|
350
|
+
* Each call adds one, in order.
|
|
351
|
+
*/
|
|
352
|
+
addTrailer(trailer: string): this {
|
|
353
|
+
this.checkCallable();
|
|
354
|
+
this.trailerArgs.push(trailer);
|
|
355
|
+
return this;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* `-C <commit>`: the commit's message taken as it is, and its author (name, email and
|
|
360
|
+
* date) unless {@link setResetAuthor}. With {@link setEdit}(true) it is `-c`.
|
|
361
|
+
*/
|
|
362
|
+
setReuseMessage(commit: string): this {
|
|
363
|
+
this.checkCallable();
|
|
364
|
+
this.reuseMessage = commit;
|
|
235
365
|
return this;
|
|
236
366
|
}
|
|
237
367
|
|
|
@@ -274,8 +404,8 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
274
404
|
}
|
|
275
405
|
|
|
276
406
|
/**
|
|
277
|
-
* `--reset-author`: an amended commit, or the commit that concludes a
|
|
278
|
-
* authored as a new one (the author resolved as git resolves it, dated now) instead of
|
|
407
|
+
* `--reset-author`: an amended commit, a `-C` commit, or the commit that concludes a
|
|
408
|
+
* cherry-pick, is authored as a new one (the author resolved as git resolves it, dated now) instead of
|
|
279
409
|
* keeping the earlier commit's author.
|
|
280
410
|
*
|
|
281
411
|
* @param reset Whether to reset the author
|
|
@@ -306,6 +436,29 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
306
436
|
return this;
|
|
307
437
|
}
|
|
308
438
|
|
|
439
|
+
/**
|
|
440
|
+
* `-S` (true) / `--no-gpg-sign` (false): whether to sign the commit; undefined (the
|
|
441
|
+
* default) leaves it to `commit.gpgSign`. The commit is signed with the default key
|
|
442
|
+
* (`user.signingKey`, else as `gpg.format` says) through the host's signer
|
|
443
|
+
* (`GitHostEnvironment.signer`) and carries the signature in its `gpgsig` header
|
|
444
|
+
* ({@link signCommit}). Without a signer, or when it fails, the commit fails as git fails
|
|
445
|
+
* when gpg cannot sign (`error: gpg failed to sign the data:`, `fatal: failed to write
|
|
446
|
+
* commit object`, exit 128: {@link SigningFailedError}) once everything before the signing
|
|
447
|
+
* is done, and nothing is committed.
|
|
448
|
+
*/
|
|
449
|
+
setSign(sign: boolean | undefined): this {
|
|
450
|
+
this.checkCallable();
|
|
451
|
+
this.sign = sign;
|
|
452
|
+
return this;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/** `-S<keyid>`: sign with this key (see {@link setSign}). */
|
|
456
|
+
setSigningKey(keyId: string): this {
|
|
457
|
+
this.checkCallable();
|
|
458
|
+
this.sign = keyId;
|
|
459
|
+
return this;
|
|
460
|
+
}
|
|
461
|
+
|
|
309
462
|
/**
|
|
310
463
|
* Set whether to amend the previous commit.
|
|
311
464
|
*
|
|
@@ -376,6 +529,82 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
376
529
|
return this;
|
|
377
530
|
}
|
|
378
531
|
|
|
532
|
+
/**
|
|
533
|
+
* `--pathspec-from-file` (and `--pathspec-file-nul` with `nul`): the pathspec elements of
|
|
534
|
+
* `content`, one per line (a line starting with `"` unquoted as a C string), or separated
|
|
535
|
+
* by NUL with `nul`, committed as {@link setOnly} paths (or {@link setInclude}'s with
|
|
536
|
+
* `setInclude()`). As git's prepare_index: refused with {@link setAll} ("options
|
|
537
|
+
* '--pathspec-from-file' and '-a' cannot be used together") and beside paths given to
|
|
538
|
+
* `setOnly`/`setInclude` ("'--pathspec-from-file' and pathspec arguments cannot be used
|
|
539
|
+
* together"); an empty file commits the index as it is (with `setInclude()`: "No paths
|
|
540
|
+
* with --include/--only does not make sense.").
|
|
541
|
+
*
|
|
542
|
+
* @example
|
|
543
|
+
* ```typescript
|
|
544
|
+
* await git.commit().setPathspecFromFile("src/a.ts\n").setMessage("Fix a").call();
|
|
545
|
+
* ```
|
|
546
|
+
*
|
|
547
|
+
* @throws InvalidArgumentError "fatal: line is badly quoted: <line>"
|
|
548
|
+
*/
|
|
549
|
+
setPathspecFromFile(content: string | Uint8Array, nul = false): this {
|
|
550
|
+
this.checkCallable();
|
|
551
|
+
this.pathspecFile.read(content, nul);
|
|
552
|
+
return this;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* `git commit -p` (`--patch`): the changes between the index and the worktree are offered
|
|
557
|
+
* hunk by hunk as `git add -p` offers them, and the selected hunks are committed along
|
|
558
|
+
* with what is staged already. As git's prepare_index for `--interactive`: the index lock
|
|
559
|
+
* is taken and the refreshed index written into it, the hunks are applied to that
|
|
560
|
+
* temporary index (`GIT_INDEX_FILE` at the lock), and the commit is made from it; the lock
|
|
561
|
+
* becomes the index once HEAD has moved, and on any failure (nothing selected: "no changes
|
|
562
|
+
* added to commit") the index stays as it was. The paths of {@link setOnly} limit the
|
|
563
|
+
* hunks offered. The prompts are answered by {@link setPatchSelector}; what patch mode
|
|
564
|
+
* printed is {@link getPatchResult}'s. Refused with {@link setAll} and
|
|
565
|
+
* {@link setInclude}.
|
|
566
|
+
*
|
|
567
|
+
* @example
|
|
568
|
+
* ```typescript
|
|
569
|
+
* const answers = ["y", "n"];
|
|
570
|
+
* const commit = git.commit().setMessage("Part").setPatch(true)
|
|
571
|
+
* .setPatchSelector(() => answers.shift());
|
|
572
|
+
* await commit.call();
|
|
573
|
+
* process.stdout.write(commit.getPatchResult()?.output ?? "");
|
|
574
|
+
* ```
|
|
575
|
+
*/
|
|
576
|
+
setPatch(patch: boolean): this {
|
|
577
|
+
this.checkCallable();
|
|
578
|
+
this.patch = patch;
|
|
579
|
+
return this;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/** Answers the prompts of {@link setPatch} (git's reads from standard input and its editor). */
|
|
583
|
+
setPatchSelector(selector: PatchSelector): this {
|
|
584
|
+
this.checkCallable();
|
|
585
|
+
this.patchSelector = selector;
|
|
586
|
+
return this;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/** `-U<n>` and `--inter-hunk-context=<n>` of {@link setPatch}. */
|
|
590
|
+
setPatchOptions(options: PatchOptions): this {
|
|
591
|
+
this.checkCallable();
|
|
592
|
+
this.patchOptions = { ...options };
|
|
593
|
+
return this;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/** The git version whose patch-mode prompts {@link setPatch} reproduces (default 2.56). */
|
|
597
|
+
setCompatibility(version: PatchCompatibility): this {
|
|
598
|
+
this.checkCallable();
|
|
599
|
+
this.patchCompatibility = version;
|
|
600
|
+
return this;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/** What {@link setPatch}'s selection printed and applied; read after {@link call}. */
|
|
604
|
+
getPatchResult(): PatchResult | undefined {
|
|
605
|
+
return this.patchResult;
|
|
606
|
+
}
|
|
607
|
+
|
|
379
608
|
/**
|
|
380
609
|
* Set whether to auto-stage modified tracked files before committing.
|
|
381
610
|
*
|
|
@@ -481,6 +710,50 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
481
710
|
return this;
|
|
482
711
|
}
|
|
483
712
|
|
|
713
|
+
/**
|
|
714
|
+
* `-c <commit>` / `--reedit-message=<commit>`: as {@link setReuseMessage} (or `-C` with {@link setEdit}(true)), with the message
|
|
715
|
+
* then given to the editor ({@link setEditor}; without one it is taken as it is).
|
|
716
|
+
*/
|
|
717
|
+
setReeditMessage(commit: string): this {
|
|
718
|
+
this.checkCallable();
|
|
719
|
+
this.reeditMessageFrom = commit;
|
|
720
|
+
return this;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* `--fixup=[(amend|reword):]<commit>`: a commit `rebase --autosquash` folds into `commit`.
|
|
725
|
+
* Plain, its message is `fixup! <subject>` (then the {@link setMessage} text, if any) and
|
|
726
|
+
* no editor runs. `amend:<commit>` makes `amend! <subject>` followed by the commit's whole
|
|
727
|
+
* message (its body alone when it is an `amend!` commit itself) for the editor to change,
|
|
728
|
+
* empty commits allowed and a message given with {@link setMessage} refused; `reword:` is
|
|
729
|
+
* `amend:` committing HEAD's tree (only the message changes), refused with paths, `-a`,
|
|
730
|
+
* `-i`, and during a merge or cherry-pick. An `amend!` message without a body is refused
|
|
731
|
+
* (`Aborting commit due to empty commit message body.`).
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* ```typescript
|
|
735
|
+
* await git.commit().setFixup("HEAD~1").call();
|
|
736
|
+
* await git.commit().setFixup("reword:HEAD~1").setEditor(edit).call();
|
|
737
|
+
* ```
|
|
738
|
+
*/
|
|
739
|
+
setFixup(commit: string): this {
|
|
740
|
+
this.checkCallable();
|
|
741
|
+
this.fixupSpec = commit;
|
|
742
|
+
return this;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* `--squash=<commit>`: the message starts with `squash! <subject>` and a blank line, then
|
|
747
|
+
* the message given ({@link setMessage}, {@link setReuseMessage}: only `squash! ` when it
|
|
748
|
+
* names the same commit as given here), else what the editor makes of it. Refused with
|
|
749
|
+
* {@link setFixup}.
|
|
750
|
+
*/
|
|
751
|
+
setSquash(commit: string): this {
|
|
752
|
+
this.checkCallable();
|
|
753
|
+
this.squashFrom = commit;
|
|
754
|
+
return this;
|
|
755
|
+
}
|
|
756
|
+
|
|
484
757
|
/** `-e` / `--no-edit`: edit a given message too, or never edit (default: edit when none is given). */
|
|
485
758
|
setEdit(edit: boolean): this {
|
|
486
759
|
this.checkCallable();
|
|
@@ -560,6 +833,8 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
560
833
|
// ... and git_diff_ui_config: a diff.submodule without a value dies
|
|
561
834
|
readDiffSubmoduleConfig(this.workingCopy);
|
|
562
835
|
await this.readCurrentIndex();
|
|
836
|
+
await this.checkReuseOptions();
|
|
837
|
+
this.applyPathspecFile();
|
|
563
838
|
// `-i` refuses what it refuses for a commit, before anything is read
|
|
564
839
|
if (this.include) this.checkIncludeOptions();
|
|
565
840
|
const state = new OperationState(this.workingCopy.checkout, this.refsStore);
|
|
@@ -620,7 +895,23 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
620
895
|
/** git's use_editor: an editor is set, and no message is given or `-e` asks for it. */
|
|
621
896
|
private usesEditor(): boolean {
|
|
622
897
|
if (!this.editor || this.edit === false) return false;
|
|
623
|
-
return this.edit === true || this.
|
|
898
|
+
return this.edit === true || this.editsByDefault();
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* git's use_editor before `-e`/`--no-edit`: no message given (`-m`, `-C`) and no plain
|
|
903
|
+
* `--fixup`, whose messages are taken as they are.
|
|
904
|
+
*/
|
|
905
|
+
private editsByDefault(): boolean {
|
|
906
|
+
if (this.message !== undefined || this.reuseMessage !== undefined) return false;
|
|
907
|
+
if (this.fixupSpec === undefined) return true;
|
|
908
|
+
const parsed = parseFixupSpec(this.fixupSpec);
|
|
909
|
+
return !("kind" in parsed) || parsed.kind !== "fixup";
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/** The revision `-c` or `-C` names (git's use_message), as given. */
|
|
913
|
+
private reusedName(): string | undefined {
|
|
914
|
+
return this.reeditMessageFrom ?? this.reuseMessage;
|
|
624
915
|
}
|
|
625
916
|
|
|
626
917
|
/**
|
|
@@ -650,7 +941,11 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
650
941
|
const { state } = ctx;
|
|
651
942
|
const config = RemoteConfigStore.from(this.workingCopy);
|
|
652
943
|
const mode = editorCleanupMode(this.workingCopy, this.cleanupMode);
|
|
653
|
-
|
|
944
|
+
// (-m, -C, -c and --fixup drop the template: git frees template_file)
|
|
945
|
+
const templateText =
|
|
946
|
+
this.message !== undefined || this.reused || this.fixup
|
|
947
|
+
? undefined
|
|
948
|
+
: await this.readTemplate(config);
|
|
654
949
|
const rebasing = (await state.read("rebase-merge/head-name")) !== undefined;
|
|
655
950
|
const whence: CommitWhence =
|
|
656
951
|
ctx.mergeHeads.length > 0
|
|
@@ -665,7 +960,9 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
665
960
|
let cutLineAdded = false;
|
|
666
961
|
const mergeMsg = await state.read("MERGE_MSG");
|
|
667
962
|
const squashMsg = await state.read("SQUASH_MSG");
|
|
668
|
-
|
|
963
|
+
const reusedMessage = await this.reusedMessage();
|
|
964
|
+
if (reusedMessage.text !== undefined) sb = reusedMessage.text;
|
|
965
|
+
else if (this.message !== undefined) sb = completeLine(this.message);
|
|
669
966
|
else if (this.amend && ctx.previousCommit) {
|
|
670
967
|
sb = ctx.previousCommit.message.replace(/^(?:[ \t\r]*\n)+/, "");
|
|
671
968
|
} else if (mergeMsg !== undefined) {
|
|
@@ -676,14 +973,17 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
676
973
|
}
|
|
677
974
|
} else if (squashMsg !== undefined) sb = squashMsg;
|
|
678
975
|
else if (templateText !== undefined) sb = templateText;
|
|
976
|
+
sb = reusedMessage.prefix + sb;
|
|
679
977
|
// clean_message_contents: not for a template, which goes in as it is
|
|
680
978
|
const fromTemplate =
|
|
979
|
+
reusedMessage.text === undefined &&
|
|
681
980
|
this.message === undefined &&
|
|
682
981
|
!(this.amend && ctx.previousCommit) &&
|
|
683
982
|
mergeMsg === undefined &&
|
|
684
983
|
squashMsg === undefined &&
|
|
685
984
|
templateText !== undefined;
|
|
686
985
|
if (mode !== CleanupMode.VERBATIM && !fromTemplate) sb = stripspace(sb);
|
|
986
|
+
sb = this.signedOff(sb, ctx.committer);
|
|
687
987
|
// core.commentChar=auto: a character the message does not start a line with
|
|
688
988
|
const comment = commentPrefixOf(this.workingCopy, sb);
|
|
689
989
|
// (a prepared message taken without an editor: as `--no-status`, unless asked for)
|
|
@@ -765,8 +1065,10 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
765
1065
|
: this.objectFormat.emptyTreeId;
|
|
766
1066
|
committable = ctx.treeId !== parentTree;
|
|
767
1067
|
}
|
|
768
|
-
// COMMIT_EDITMSG written in full,
|
|
1068
|
+
// COMMIT_EDITMSG written in full, its trailers added (amend_file_with_trailers), then an
|
|
1069
|
+
// empty commit refused before the editor runs
|
|
769
1070
|
await state.write("COMMIT_EDITMSG", template);
|
|
1071
|
+
template = await this.withTrailers(template, state, comment);
|
|
770
1072
|
const isMerge = (ctx.previousCommit?.parents.length ?? 0) > 1;
|
|
771
1073
|
if (!committable && whence !== "merge" && !this.allowEmpty && !(this.amend && isMerge)) {
|
|
772
1074
|
throw new EmptyCommitError();
|
|
@@ -809,6 +1111,59 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
809
1111
|
};
|
|
810
1112
|
}
|
|
811
1113
|
|
|
1114
|
+
/**
|
|
1115
|
+
* `-s`: the message so far with the committer's sign-off (append_signoff with
|
|
1116
|
+
* ignored_log_message_bytes: before trailing comments and the scissors line).
|
|
1117
|
+
*/
|
|
1118
|
+
private signedOff(message: string, committer: PersonIdent): string {
|
|
1119
|
+
if (!this.signoff) return message;
|
|
1120
|
+
const config = trailerConfigOf(this.workingCopy);
|
|
1121
|
+
return appendSignoff(
|
|
1122
|
+
message,
|
|
1123
|
+
signoffLine(committer),
|
|
1124
|
+
config,
|
|
1125
|
+
false,
|
|
1126
|
+
ignoredLogMessageBytes(message, config.commentString),
|
|
1127
|
+
);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* `--trailer`: COMMIT_EDITMSG (written as `message`) with the trailers added, as git's
|
|
1132
|
+
* amend_file_with_trailers (2.43: a child `interpret-trailers --in-place --no-divider`,
|
|
1133
|
+
* which takes an empty argument for nothing and refuses none); the new text, written back.
|
|
1134
|
+
*/
|
|
1135
|
+
private async withTrailers(
|
|
1136
|
+
message: string,
|
|
1137
|
+
state: OperationState,
|
|
1138
|
+
comment: string | undefined,
|
|
1139
|
+
): Promise<string> {
|
|
1140
|
+
if (this.trailerArgs.length === 0) return message;
|
|
1141
|
+
const hooks = this.hooks;
|
|
1142
|
+
const compatibility = hooks.compatibility;
|
|
1143
|
+
const config = {
|
|
1144
|
+
...trailerConfigOf(this.workingCopy),
|
|
1145
|
+
...(comment !== undefined ? { commentString: comment } : {}),
|
|
1146
|
+
compatibility,
|
|
1147
|
+
};
|
|
1148
|
+
let args = this.trailerArgs;
|
|
1149
|
+
if (compatibility === "2.43") args = args.filter((a) => a !== "");
|
|
1150
|
+
else {
|
|
1151
|
+
const refused = validateTrailerArgs(args, config);
|
|
1152
|
+
if (refused !== undefined) {
|
|
1153
|
+
throw new GitApiError(`${refused}\nfatal: unable to pass trailers to --trailers`, {
|
|
1154
|
+
exitCode: 128,
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
if (args.length === 0) return message;
|
|
1159
|
+
const runCommand: TrailerCommandRunner | undefined = hooks.enabled
|
|
1160
|
+
? (command) => hooks.runShellCommand("trailer", command.command, command.args)
|
|
1161
|
+
: undefined;
|
|
1162
|
+
const { output } = await amendWithTrailers(message, args, config, runCommand);
|
|
1163
|
+
await state.write("COMMIT_EDITMSG", output);
|
|
1164
|
+
return output;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
812
1167
|
/**
|
|
813
1168
|
* The commit template (`-t`, else `commit.template`, `~/` expanded) read through the host,
|
|
814
1169
|
* undefined when none is set; one that cannot be read fails as git's `die_errno`.
|
|
@@ -969,11 +1324,15 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
969
1324
|
readShowUntrackedFiles(this.workingCopy);
|
|
970
1325
|
// ... and git_diff_ui_config: a diff.submodule without a value dies
|
|
971
1326
|
readDiffSubmoduleConfig(this.workingCopy);
|
|
1327
|
+
await this.parseAuthorOptions();
|
|
972
1328
|
// the index as it is now: one another writer replaced is read again (git reads the
|
|
973
1329
|
// index at its start), unless this instance holds unwritten edits (refused)
|
|
974
1330
|
await this.readCurrentIndex();
|
|
1331
|
+
if (this.patch) return this.commitPatch();
|
|
1332
|
+
this.applyPathspecFile();
|
|
975
1333
|
if (this.include) return this.commitIncluded();
|
|
976
|
-
|
|
1334
|
+
// `--fixup=reword:` is a partial commit of no path: HEAD's tree (git sets `only`)
|
|
1335
|
+
const partial = this.onlyPaths.length > 0 || this.fixup?.kind === "reword";
|
|
977
1336
|
if (!this.all) return this.commitWith(partial, undefined);
|
|
978
1337
|
// `-a` (git's COMMIT_NORMAL): the index lock held from before the tracked changes are
|
|
979
1338
|
// staged until HEAD has moved
|
|
@@ -991,6 +1350,85 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
991
1350
|
}
|
|
992
1351
|
}
|
|
993
1352
|
|
|
1353
|
+
/**
|
|
1354
|
+
* `-p` (git's prepare_index for `interactive`): the option checks, then the index lock held
|
|
1355
|
+
* and the hunks selected into the index it holds (`interactive_add` with `GIT_INDEX_FILE`
|
|
1356
|
+
* at the lock), then the commit from it.
|
|
1357
|
+
*/
|
|
1358
|
+
private async commitPatch(): Promise<CommitResult> {
|
|
1359
|
+
// parse_and_validate_options: -i, -o, -a and --interactive/-p exclude each other
|
|
1360
|
+
if (this.include || this.all) {
|
|
1361
|
+
const other = this.include ? "-i/--include" : "-a/--all";
|
|
1362
|
+
throw new IncompatibleOptionsError(
|
|
1363
|
+
[other, "--interactive/-p/--patch"],
|
|
1364
|
+
`fatal: options '${other}' and '--interactive/-p/--patch' cannot be used together`,
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1367
|
+
if (this.pathspecFile.given) {
|
|
1368
|
+
throw new IncompatibleOptionsError(
|
|
1369
|
+
["--pathspec-from-file", "--interactive/--patch"],
|
|
1370
|
+
"fatal: options '--pathspec-from-file' and '--interactive/--patch' cannot be used together",
|
|
1371
|
+
);
|
|
1372
|
+
}
|
|
1373
|
+
const index = await this.holdIndex();
|
|
1374
|
+
try {
|
|
1375
|
+
// refresh_cache_or_die: an unmerged entry dies before anything is asked
|
|
1376
|
+
if (await this.staging.hasConflicts())
|
|
1377
|
+
throw unmergedPathsError(await this.staging.getConflictedPaths());
|
|
1378
|
+
const temporary: TemporaryIndex = new Map();
|
|
1379
|
+
const entries = new Map<string, StagingEntry>();
|
|
1380
|
+
for await (const entry of this.staging.entries()) {
|
|
1381
|
+
if (entry.stage !== 0) continue;
|
|
1382
|
+
entries.set(entry.path, entry);
|
|
1383
|
+
const { path: _p, mode, objectId, stage: _s, ...carried } = entry;
|
|
1384
|
+
temporary.set(entry.path, { mode, objectId, carried });
|
|
1385
|
+
}
|
|
1386
|
+
this.patchResult = await runPatchSelection(this.workingCopy, {
|
|
1387
|
+
hookSource: this,
|
|
1388
|
+
...this.patchOptions,
|
|
1389
|
+
mode: patchModeFor("add"),
|
|
1390
|
+
selector: this.patchSelector,
|
|
1391
|
+
paths: this.onlyPaths,
|
|
1392
|
+
compatibility: this.patchCompatibility,
|
|
1393
|
+
temporaryIndex: temporary,
|
|
1394
|
+
});
|
|
1395
|
+
// the temporary index read back into the held index: entries apply rewrote (no stat
|
|
1396
|
+
// data, as `apply --cached` writes them), and the paths it removed
|
|
1397
|
+
const changes = new Map<string, StagingEntry[]>();
|
|
1398
|
+
for (const [path, entry] of temporary) {
|
|
1399
|
+
const old = entries.get(path);
|
|
1400
|
+
// an entry apply rewrote with the same blob (an empty intent-to-add file staged)
|
|
1401
|
+
// loses its intent-to-add flag, so it is no longer the entry it was
|
|
1402
|
+
if (
|
|
1403
|
+
old &&
|
|
1404
|
+
old.mode === entry.mode &&
|
|
1405
|
+
old.objectId === entry.objectId &&
|
|
1406
|
+
!!old.intentToAdd === !!entry.carried?.intentToAdd
|
|
1407
|
+
) {
|
|
1408
|
+
continue;
|
|
1409
|
+
}
|
|
1410
|
+
changes.set(path, [
|
|
1411
|
+
{
|
|
1412
|
+
path,
|
|
1413
|
+
mode: entry.mode,
|
|
1414
|
+
objectId: entry.objectId,
|
|
1415
|
+
stage: 0,
|
|
1416
|
+
size: 0,
|
|
1417
|
+
mtime: 0,
|
|
1418
|
+
} as StagingEntry,
|
|
1419
|
+
]);
|
|
1420
|
+
}
|
|
1421
|
+
for (const path of entries.keys()) if (!temporary.has(path)) changes.set(path, []);
|
|
1422
|
+
if (changes.size > 0) {
|
|
1423
|
+
await rewriteIndex(this.staging, changes, { upToDate: false, write: false });
|
|
1424
|
+
}
|
|
1425
|
+
return await this.withOneIndexWrite("first", () => this.commitWith(false, index));
|
|
1426
|
+
} catch (error) {
|
|
1427
|
+
await index.release();
|
|
1428
|
+
throw error;
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
|
|
994
1432
|
/**
|
|
995
1433
|
* `-i <paths>` (git's prepare_index for `also`): the option checks of
|
|
996
1434
|
* parse_and_validate_options and prepare_index, then the index lock held from before the
|
|
@@ -1008,6 +1446,324 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1008
1446
|
}
|
|
1009
1447
|
}
|
|
1010
1448
|
|
|
1449
|
+
/**
|
|
1450
|
+
* parse_and_validate_options' handling of `--author`, `-m` with `-C`, `--reset-author`,
|
|
1451
|
+
* and `-C`'s commit (read_commit_message), in git's order.
|
|
1452
|
+
*/
|
|
1453
|
+
private async parseAuthorOptions(): Promise<void> {
|
|
1454
|
+
if (this.authorString !== undefined) {
|
|
1455
|
+
let text = this.authorString;
|
|
1456
|
+
if (!text.includes(">")) text = await this.findAuthorByNickname(text);
|
|
1457
|
+
if (this.resetAuthor) {
|
|
1458
|
+
throw new IncompatibleOptionsError(
|
|
1459
|
+
["--reset-author", "--author"],
|
|
1460
|
+
"fatal: options '--reset-author' and '--author' cannot be used together",
|
|
1461
|
+
);
|
|
1462
|
+
}
|
|
1463
|
+
// split_ident_line: the name up to the `<` (trailing spaces dropped), the email up to
|
|
1464
|
+
// the first `>` after it
|
|
1465
|
+
const lt = text.indexOf("<");
|
|
1466
|
+
const gt = lt < 0 ? -1 : text.indexOf(">", lt + 1);
|
|
1467
|
+
if (gt < 0) {
|
|
1468
|
+
throw new InvalidArgumentError(
|
|
1469
|
+
"author",
|
|
1470
|
+
this.authorString,
|
|
1471
|
+
"fatal: malformed --author parameter",
|
|
1472
|
+
);
|
|
1473
|
+
}
|
|
1474
|
+
const name = text.slice(0, lt).replace(/[ \t\n\v\f\r]+$/, "");
|
|
1475
|
+
this.authorName = { name, email: text.slice(lt + 1, gt) };
|
|
1476
|
+
}
|
|
1477
|
+
await this.checkReuseOptions();
|
|
1478
|
+
if (this.forceDate) this.forcedDate();
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
/**
|
|
1482
|
+
* `--date` (parse_force_date): the date as `parse_date` reads it, else as `approxidate`
|
|
1483
|
+
* does, refused as git refuses it.
|
|
1484
|
+
*/
|
|
1485
|
+
private forcedDate(): Pick<PersonIdent, "timestamp" | "tzOffset"> | undefined {
|
|
1486
|
+
if (!this.forceDate) return undefined;
|
|
1487
|
+
const { text } = this.forceDate;
|
|
1488
|
+
const parsed = parseGitDate(text);
|
|
1489
|
+
if (parsed) return parsed;
|
|
1490
|
+
const approx = approxidateCareful(text, this.forceDate.now ?? this.clock());
|
|
1491
|
+
// fmt_ident's parse_date of `@<seconds>`: the local offset of that time
|
|
1492
|
+
const date = approx.error ? undefined : parseGitDate(`@${approx.timestamp}`);
|
|
1493
|
+
if (!date) throw new InvalidDateError(text);
|
|
1494
|
+
return date;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
/**
|
|
1498
|
+
* git's `error:` lines that did not stop the command (the mailmap's, read for an
|
|
1499
|
+
* `--author` that is no `Name <email>`), in order; also after a failure.
|
|
1500
|
+
*/
|
|
1501
|
+
getWarnings(): string[] {
|
|
1502
|
+
return [...this.stderrLines];
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
/**
|
|
1506
|
+
* builtin/commit.c's find_author_by_nickname: the first commit of `rev-list --all -i
|
|
1507
|
+
* --author=<name>` (newest first, the mailmap applied before matching) gives `%aN <%aE>`.
|
|
1508
|
+
*/
|
|
1509
|
+
private async findAuthorByNickname(name: string): Promise<string> {
|
|
1510
|
+
let pattern: PosixRegex;
|
|
1511
|
+
try {
|
|
1512
|
+
pattern = compilePosixRegex(name, { icase: true });
|
|
1513
|
+
} catch (error) {
|
|
1514
|
+
throw new InvalidArgumentError(
|
|
1515
|
+
"author",
|
|
1516
|
+
name,
|
|
1517
|
+
`fatal: '${name}': ${error instanceof Error ? error.message : String(error)}`,
|
|
1518
|
+
);
|
|
1519
|
+
}
|
|
1520
|
+
// rev.mailmap's read; pretty.c reads it again for the `%aN <%aE>` of the match
|
|
1521
|
+
const mailmapErrors: string[] = [];
|
|
1522
|
+
const mailmap = await this.readMailmap((line) => mailmapErrors.push(line));
|
|
1523
|
+
this.stderrLines.push(...mailmapErrors);
|
|
1524
|
+
const encoder = new TextEncoder();
|
|
1525
|
+
// revision.c's walk of --all: refs under refs/ in name order, then HEAD, tags peeled;
|
|
1526
|
+
// commits come out by commit date, newest first
|
|
1527
|
+
const starts: { name: string; id: ObjectId }[] = [];
|
|
1528
|
+
for await (const ref of this.refsStore.list()) {
|
|
1529
|
+
if (!ref.name.startsWith("refs/")) continue;
|
|
1530
|
+
let id = "objectId" in ref ? ref.objectId : undefined;
|
|
1531
|
+
if (!id) id = (await this.refsStore.resolve(ref.name).catch(() => undefined))?.objectId;
|
|
1532
|
+
if (id) starts.push({ name: ref.name, id });
|
|
1533
|
+
}
|
|
1534
|
+
starts.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
1535
|
+
const head = (await this.refsStore.resolve("HEAD").catch(() => undefined))?.objectId;
|
|
1536
|
+
const ids = starts.map((s) => s.id);
|
|
1537
|
+
if (head) ids.push(head);
|
|
1538
|
+
const queue: { id: ObjectId; commit: Commit; date: number; order: number }[] = [];
|
|
1539
|
+
const seen = new Set<ObjectId>();
|
|
1540
|
+
let order = 0;
|
|
1541
|
+
const put = async (start: ObjectId) => {
|
|
1542
|
+
let id = start;
|
|
1543
|
+
const tags = this.tagsStore;
|
|
1544
|
+
for (let depth = 0; depth < 32 && tags && (await tags.has(id).catch(() => false)); depth++) {
|
|
1545
|
+
const tag = await tags.load(id).catch(() => undefined);
|
|
1546
|
+
if (!tag) break;
|
|
1547
|
+
id = tag.object;
|
|
1548
|
+
}
|
|
1549
|
+
if (seen.has(id)) return;
|
|
1550
|
+
const commit = await this.commits.load(id).catch(() => undefined);
|
|
1551
|
+
if (!commit) return;
|
|
1552
|
+
seen.add(id);
|
|
1553
|
+
queue.push({ id, commit, date: commit.committer.timestamp, order: order++ });
|
|
1554
|
+
};
|
|
1555
|
+
for (const id of ids) await put(id);
|
|
1556
|
+
while (queue.length > 0) {
|
|
1557
|
+
let best = 0;
|
|
1558
|
+
for (let i = 1; i < queue.length; i++) {
|
|
1559
|
+
const a = queue[i] as (typeof queue)[number];
|
|
1560
|
+
const b = queue[best] as (typeof queue)[number];
|
|
1561
|
+
if (a.date > b.date || (a.date === b.date && a.order < b.order)) best = i;
|
|
1562
|
+
}
|
|
1563
|
+
const [next] = queue.splice(best, 1);
|
|
1564
|
+
if (!next) break;
|
|
1565
|
+
const who = mailmap.map(next.commit.author.name, next.commit.author.email);
|
|
1566
|
+
if (pattern.test(encoder.encode(`${who.name} <${who.email}>`))) {
|
|
1567
|
+
this.stderrLines.push(...mailmapErrors);
|
|
1568
|
+
return `${who.name} <${who.email}>`;
|
|
1569
|
+
}
|
|
1570
|
+
for (const parent of next.commit.parents) await put(parent);
|
|
1571
|
+
}
|
|
1572
|
+
throw new InvalidArgumentError(
|
|
1573
|
+
"author",
|
|
1574
|
+
name,
|
|
1575
|
+
`fatal: --author '${name}' is not 'Name <email>' and matches no existing author`,
|
|
1576
|
+
);
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
/**
|
|
1580
|
+
* parse_and_validate_options for `-C`, `-c`, `--fixup` and `--squash`, in git's order: the
|
|
1581
|
+
* incompatible options, the commit `-C`/`-c` names read (`could not lookup commit`), then
|
|
1582
|
+
* `--fixup`'s suboption (`amend:`/`reword:` allow empty commits; `reword:` refuses paths,
|
|
1583
|
+
* `-a`, `-i` and a merge or cherry-pick in progress).
|
|
1584
|
+
*/
|
|
1585
|
+
private async checkReuseOptions(): Promise<void> {
|
|
1586
|
+
if (this.fixupSpec !== undefined && this.squashFrom !== undefined) {
|
|
1587
|
+
throw new IncompatibleOptionsError(
|
|
1588
|
+
["--squash", "--fixup"],
|
|
1589
|
+
"fatal: options '--squash' and '--fixup' cannot be used together",
|
|
1590
|
+
);
|
|
1591
|
+
}
|
|
1592
|
+
refuseIncompatible([
|
|
1593
|
+
["-C", this.reuseMessage !== undefined],
|
|
1594
|
+
["-c", this.reeditMessageFrom !== undefined],
|
|
1595
|
+
["--fixup", this.fixupSpec !== undefined],
|
|
1596
|
+
]);
|
|
1597
|
+
refuseIncompatible([
|
|
1598
|
+
["-m", this.message !== undefined],
|
|
1599
|
+
["-c", this.reeditMessageFrom !== undefined],
|
|
1600
|
+
["-C", this.reuseMessage !== undefined],
|
|
1601
|
+
]);
|
|
1602
|
+
const use = this.reusedName();
|
|
1603
|
+
if (use !== undefined) this.reused = await this.lookupCommit(use);
|
|
1604
|
+
if (this.fixupSpec === undefined) return;
|
|
1605
|
+
const parsed = parseFixupSpec(this.fixupSpec);
|
|
1606
|
+
if ("unknown" in parsed) {
|
|
1607
|
+
throw new InvalidArgumentError(
|
|
1608
|
+
"fixup",
|
|
1609
|
+
this.fixupSpec,
|
|
1610
|
+
`fatal: unknown option: --fixup=${parsed.unknown}:${parsed.target}`,
|
|
1611
|
+
);
|
|
1612
|
+
}
|
|
1613
|
+
this.fixup = parsed;
|
|
1614
|
+
if (parsed.kind === "fixup") return;
|
|
1615
|
+
this.allowEmpty = true;
|
|
1616
|
+
if (parsed.kind !== "reword") return;
|
|
1617
|
+
// check_fixup_reword_options
|
|
1618
|
+
const state = new OperationState(this.workingCopy.checkout, this.refsStore);
|
|
1619
|
+
if ((await this.mergeHeads(state)).length > 0) {
|
|
1620
|
+
throw new InvalidArgumentError(
|
|
1621
|
+
"fixup",
|
|
1622
|
+
this.fixupSpec,
|
|
1623
|
+
"fatal: You are in the middle of a merge -- cannot reword.",
|
|
1624
|
+
);
|
|
1625
|
+
}
|
|
1626
|
+
const pick = await state.ref("CHERRY_PICK_HEAD");
|
|
1627
|
+
// (a rebase stopped at a pick is no cherry-pick: git's is_from_cherry_pick)
|
|
1628
|
+
if (
|
|
1629
|
+
pick &&
|
|
1630
|
+
!(
|
|
1631
|
+
(await state.read("rebase-merge/head-name")) !== undefined &&
|
|
1632
|
+
(await state.ref("REBASE_HEAD")) === pick
|
|
1633
|
+
)
|
|
1634
|
+
) {
|
|
1635
|
+
throw new InvalidArgumentError(
|
|
1636
|
+
"fixup",
|
|
1637
|
+
this.fixupSpec,
|
|
1638
|
+
"fatal: You are in the middle of a cherry-pick -- cannot reword.",
|
|
1639
|
+
);
|
|
1640
|
+
}
|
|
1641
|
+
const path = this.onlyPaths[0] ?? this.includePaths[0];
|
|
1642
|
+
if (path !== undefined) {
|
|
1643
|
+
throw new IncompatibleOptionsError(
|
|
1644
|
+
["--fixup", "paths"],
|
|
1645
|
+
`fatal: reword option of '--fixup' and path '${path}' cannot be used together`,
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1648
|
+
// check_fixup_reword_options: patch_interactive || interactive || all || also || only
|
|
1649
|
+
if (this.all || this.include || this.patch) {
|
|
1650
|
+
throw new IncompatibleOptionsError(
|
|
1651
|
+
["--fixup", "--all"],
|
|
1652
|
+
"fatal: reword option of '--fixup' and '--patch/--interactive/--all/--include/--only' cannot be used together",
|
|
1653
|
+
);
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
/** git's lookup_commit_reference_by_name, dying as `could not lookup commit '<name>'`. */
|
|
1658
|
+
private async lookupCommit(name: string): Promise<Commit> {
|
|
1659
|
+
const fatal = `fatal: could not lookup commit '${name}'`;
|
|
1660
|
+
let id: ObjectId;
|
|
1661
|
+
try {
|
|
1662
|
+
id = await this.resolveRevision(name);
|
|
1663
|
+
} catch (error) {
|
|
1664
|
+
if (error instanceof RefNotFoundError) throw new GitApiError(fatal);
|
|
1665
|
+
throw error;
|
|
1666
|
+
}
|
|
1667
|
+
const peeled = await this.revisionResolver().peelTags(id);
|
|
1668
|
+
const commit = peeled.type === "commit" ? await this.commits.load(peeled.id) : undefined;
|
|
1669
|
+
if (!commit) {
|
|
1670
|
+
throw new GitApiError(
|
|
1671
|
+
peeled.type
|
|
1672
|
+
? `error: object ${peeled.id} is a ${peeled.type}, not a commit\n${fatal}`
|
|
1673
|
+
: fatal,
|
|
1674
|
+
);
|
|
1675
|
+
}
|
|
1676
|
+
return this.inCommitOutputEncoding(peeled.id, commit);
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
/**
|
|
1680
|
+
* A commit's message and author as `git commit` reads another commit's (read_commit_message,
|
|
1681
|
+
* format_commit_message): converted from its `encoding` header into the commit output
|
|
1682
|
+
* encoding (`i18n.commitEncoding`, else UTF-8). Ours writes UTF-8 messages only, so a
|
|
1683
|
+
* commit is converted only when that encoding is UTF-8.
|
|
1684
|
+
*/
|
|
1685
|
+
private async inCommitOutputEncoding(id: ObjectId, commit: Commit): Promise<Commit> {
|
|
1686
|
+
if (commit.encoding === undefined) return commit;
|
|
1687
|
+
const configured = RemoteConfigStore.from(this.workingCopy).value("i18n.commitEncoding");
|
|
1688
|
+
const output = configured ? configured : "UTF-8";
|
|
1689
|
+
if (!/^utf-?8$/i.test(output)) return commit;
|
|
1690
|
+
const raw = await this.readRawObject(id);
|
|
1691
|
+
const parts = raw && reencodedCommitParts(raw, output);
|
|
1692
|
+
if (!parts) return commit;
|
|
1693
|
+
return { ...commit, message: parts.message, ...(parts.author ? { author: parts.author } : {}) };
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
/** The stored bytes of an object (undefined where the store cannot give them). */
|
|
1697
|
+
private async readRawObject(id: ObjectId): Promise<Uint8Array | undefined> {
|
|
1698
|
+
const objects = this.workingCopy.history?.objects;
|
|
1699
|
+
if (!objects) return undefined;
|
|
1700
|
+
try {
|
|
1701
|
+
const obj = await objects.get(id);
|
|
1702
|
+
if (!obj) return undefined;
|
|
1703
|
+
if (obj.bytes) return obj.bytes;
|
|
1704
|
+
const chunks: Uint8Array[] = [];
|
|
1705
|
+
let size = 0;
|
|
1706
|
+
for await (const c of obj.content) {
|
|
1707
|
+
chunks.push(c);
|
|
1708
|
+
size += c.length;
|
|
1709
|
+
}
|
|
1710
|
+
const out = new Uint8Array(size);
|
|
1711
|
+
let at = 0;
|
|
1712
|
+
for (const c of chunks) {
|
|
1713
|
+
out.set(c, at);
|
|
1714
|
+
at += c.length;
|
|
1715
|
+
}
|
|
1716
|
+
return out;
|
|
1717
|
+
} catch {
|
|
1718
|
+
return undefined;
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* The start of prepare_to_commit's message from `-C`/`-c`/`--fixup`/`--squash`: the
|
|
1724
|
+
* `squash! ` subject (`prefix`, put before whatever message follows) and, for `-C`/`-c`
|
|
1725
|
+
* and `--fixup`, the text that replaces the other sources (undefined: they apply).
|
|
1726
|
+
*/
|
|
1727
|
+
private async reusedMessage(): Promise<{ prefix: string; text: string | undefined }> {
|
|
1728
|
+
let prefix = "";
|
|
1729
|
+
if (this.squashFrom !== undefined) {
|
|
1730
|
+
prefix =
|
|
1731
|
+
(this.reusedName() ?? (this.amend && !this.fixup ? "HEAD" : undefined)) === this.squashFrom
|
|
1732
|
+
? "squash! "
|
|
1733
|
+
: autosquashSubject("squash", (await this.lookupCommit(this.squashFrom)).message);
|
|
1734
|
+
}
|
|
1735
|
+
if (this.reused) return { prefix, text: skipBlankLines(this.reused.message) };
|
|
1736
|
+
if (!this.fixup) return { prefix, text: undefined };
|
|
1737
|
+
const target = await this.lookupCommit(this.fixup.target);
|
|
1738
|
+
if (this.fixup.kind === "fixup") {
|
|
1739
|
+
const given = this.message !== undefined ? completeLine(this.message) : "";
|
|
1740
|
+
return { prefix, text: autosquashSubject("fixup", target.message) + given };
|
|
1741
|
+
}
|
|
1742
|
+
if (this.message !== undefined) {
|
|
1743
|
+
throw new IncompatibleOptionsError(
|
|
1744
|
+
["-m", "--fixup"],
|
|
1745
|
+
`fatal: options '-m' and '--fixup:${this.fixup.kind}' cannot be used together`,
|
|
1746
|
+
);
|
|
1747
|
+
}
|
|
1748
|
+
return {
|
|
1749
|
+
prefix,
|
|
1750
|
+
text: autosquashSubject("amend", target.message) + amendCommitText(target.message),
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
/**
|
|
1755
|
+
* prepare_index's `--pathspec-from-file`: refused with `-a` and beside pathspec arguments
|
|
1756
|
+
* ({@link setOnly}, {@link setInclude}); its elements are then the paths of `-i`, else of
|
|
1757
|
+
* `--only`.
|
|
1758
|
+
*/
|
|
1759
|
+
private applyPathspecFile(): void {
|
|
1760
|
+
if (!this.pathspecFile.given) return;
|
|
1761
|
+
this.pathspecFile.refuse("-a", this.all);
|
|
1762
|
+
this.pathspecFile.refuseArguments([...this.onlyPaths, ...this.includePaths]);
|
|
1763
|
+
if (this.include) this.includePaths = [...this.pathspecFile.elements];
|
|
1764
|
+
else this.onlyPaths = [...this.pathspecFile.elements];
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1011
1767
|
/** `-i <paths>`: parse_and_validate_options' and prepare_index's refusals. */
|
|
1012
1768
|
private checkIncludeOptions(): void {
|
|
1013
1769
|
if (this.onlyPaths.length > 0) {
|
|
@@ -1041,16 +1797,7 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1041
1797
|
// Check for conflicts (a partial commit records HEAD and the named paths: other
|
|
1042
1798
|
// unmerged paths stay in the index, as git's)
|
|
1043
1799
|
if (!partial && (await this.staging.hasConflicts())) {
|
|
1044
|
-
|
|
1045
|
-
throw new UnmergedPathsError(
|
|
1046
|
-
conflictPaths,
|
|
1047
|
-
[
|
|
1048
|
-
"error: Committing is not possible because you have unmerged files.",
|
|
1049
|
-
"hint: Fix them up in the work tree, and then use 'git add/rm <file>'",
|
|
1050
|
-
"hint: as appropriate to mark resolution and make a commit.",
|
|
1051
|
-
"fatal: Exiting because of an unresolved conflict.",
|
|
1052
|
-
].join("\n"),
|
|
1053
|
-
);
|
|
1800
|
+
throw unmergedPathsError(await this.staging.getConflictedPaths());
|
|
1054
1801
|
}
|
|
1055
1802
|
|
|
1056
1803
|
// a merge, cherry-pick or revert in progress (git's whence: MERGE_HEAD,
|
|
@@ -1058,6 +1805,13 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1058
1805
|
const state = new OperationState(this.workingCopy.checkout, this.refsStore);
|
|
1059
1806
|
const mergeHeads = await this.mergeHeads(state);
|
|
1060
1807
|
const pickHead = await state.ref("CHERRY_PICK_HEAD");
|
|
1808
|
+
if (this.resetAuthor && !this.amend && !this.reused && !pickHead) {
|
|
1809
|
+
throw new InvalidArgumentError(
|
|
1810
|
+
"reset-author",
|
|
1811
|
+
true,
|
|
1812
|
+
"fatal: --reset-author can be used only with -C, -c or --amend.",
|
|
1813
|
+
);
|
|
1814
|
+
}
|
|
1061
1815
|
if (this.amend && mergeHeads.length > 0) {
|
|
1062
1816
|
throw new InvalidArgumentError(
|
|
1063
1817
|
"amend",
|
|
@@ -1069,8 +1823,11 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1069
1823
|
const headId = (await this.refsStore.resolve("HEAD"))?.objectId;
|
|
1070
1824
|
let partialTree: ObjectId | undefined;
|
|
1071
1825
|
let falseIndexFile: FalseIndexFile | undefined;
|
|
1826
|
+
// (`--fixup=reword:` names no path: the false index is HEAD's tree)
|
|
1072
1827
|
const partialPaths = partial
|
|
1073
|
-
?
|
|
1828
|
+
? this.fixup?.kind === "reword"
|
|
1829
|
+
? new Map<string, boolean>()
|
|
1830
|
+
: await this.listPartialPaths(state, mergeHeads, headId)
|
|
1074
1831
|
: undefined;
|
|
1075
1832
|
if (partialPaths) {
|
|
1076
1833
|
// git's partial commit (prepare_index): the index lock taken once the paths are
|
|
@@ -1182,17 +1939,90 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1182
1939
|
const mergeMsgPresent =
|
|
1183
1940
|
(await state.read("MERGE_MSG")) !== undefined ||
|
|
1184
1941
|
(await state.read("SQUASH_MSG")) !== undefined;
|
|
1942
|
+
const reused = this.reused;
|
|
1943
|
+
// (-c, --squash and --fixup=amend:/reword: prepare a message for the editor: without
|
|
1944
|
+
// one it is taken as it is, as with GIT_EDITOR=:)
|
|
1945
|
+
const preparedForEditor =
|
|
1946
|
+
this.reeditMessageFrom !== undefined ||
|
|
1947
|
+
this.squashFrom !== undefined ||
|
|
1948
|
+
(this.fixup !== undefined && this.fixup.kind !== "fixup");
|
|
1185
1949
|
const editorLike =
|
|
1186
1950
|
this.usesEditor() ||
|
|
1187
|
-
(this.
|
|
1951
|
+
(this.edit !== false &&
|
|
1952
|
+
this.editsByDefault() &&
|
|
1953
|
+
((!reused && !this.amend && mergeMsgPresent) || preparedForEditor));
|
|
1188
1954
|
const editor: CommitEditor = this.usesEditor()
|
|
1189
1955
|
? (this.editor as CommitEditor)
|
|
1190
1956
|
: async () => undefined;
|
|
1191
1957
|
const message = this.message;
|
|
1192
|
-
if (
|
|
1958
|
+
if (
|
|
1959
|
+
!editorLike &&
|
|
1960
|
+
message === undefined &&
|
|
1961
|
+
!reused &&
|
|
1962
|
+
!this.amend &&
|
|
1963
|
+
!mergeMsgPresent &&
|
|
1964
|
+
!this.fixup &&
|
|
1965
|
+
this.squashFrom === undefined
|
|
1966
|
+
) {
|
|
1193
1967
|
throw new NoMessageError();
|
|
1194
1968
|
}
|
|
1195
1969
|
|
|
1970
|
+
let previousCommit: Commit | undefined;
|
|
1971
|
+
let amendedId: ObjectId | undefined;
|
|
1972
|
+
|
|
1973
|
+
if (this.amend) {
|
|
1974
|
+
const headId = await this.resolveHead();
|
|
1975
|
+
amendedId = headId;
|
|
1976
|
+
previousCommit = await this.commits.load(headId);
|
|
1977
|
+
if (!previousCommit) {
|
|
1978
|
+
throw new NoHeadError("Cannot amend: HEAD commit not found");
|
|
1979
|
+
}
|
|
1980
|
+
// (its message and author as git reads them: use_message = "HEAD")
|
|
1981
|
+
previousCommit = await this.inCommitOutputEncoding(headId, previousCommit);
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
// The author (git's determine_author_info, which prepare_to_commit runs before the
|
|
1985
|
+
// pre-commit hook): the one given; else an amended commit's or
|
|
1986
|
+
// a concluded cherry-pick's author (its date too; `--author` replaces only the name and
|
|
1987
|
+
// email), unless --reset-author; else resolved as git does (GIT_AUTHOR_*, author.*,
|
|
1988
|
+
// user.*, GIT_AUTHOR_DATE or now)
|
|
1989
|
+
// (`--amend --fixup` keeps no author: git's author_message is use_message's, which
|
|
1990
|
+
// --fixup leaves unset)
|
|
1991
|
+
const amendKeeps = this.amend && !!previousCommit && !this.fixup;
|
|
1992
|
+
let author = this.author;
|
|
1993
|
+
if (!author) {
|
|
1994
|
+
// (git's author_message: a cherry-pick's CHERRY_PICK_HEAD, else -C's commit, else the
|
|
1995
|
+
// amended HEAD)
|
|
1996
|
+
const kept = this.resetAuthor
|
|
1997
|
+
? undefined
|
|
1998
|
+
: pickHead
|
|
1999
|
+
? (await this.commits.load(pickHead))?.author
|
|
2000
|
+
: reused
|
|
2001
|
+
? reused.author
|
|
2002
|
+
: amendKeeps
|
|
2003
|
+
? previousCommit?.author
|
|
2004
|
+
: undefined;
|
|
2005
|
+
// fmt_ident's IDENT_STRICT refusals of the name chosen (an empty one, crud only)
|
|
2006
|
+
if (kept || this.authorName) {
|
|
2007
|
+
strictAuthorName(
|
|
2008
|
+
this.authorName?.name ?? (kept as PersonIdent).name,
|
|
2009
|
+
this.authorName?.email ?? (kept as PersonIdent).email,
|
|
2010
|
+
);
|
|
2011
|
+
}
|
|
2012
|
+
if (kept) {
|
|
2013
|
+
author = this.authorName
|
|
2014
|
+
? {
|
|
2015
|
+
...kept,
|
|
2016
|
+
name: withoutCrud(this.authorName.name),
|
|
2017
|
+
email: withoutCrud(this.authorName.email),
|
|
2018
|
+
}
|
|
2019
|
+
: kept;
|
|
2020
|
+
} else if (this.authorName) author = this.datedIdent("author", this.authorName);
|
|
2021
|
+
else author = this.resolveAuthor(this.committer ?? this.committerName);
|
|
2022
|
+
}
|
|
2023
|
+
// --date: the author's date, whatever gave the rest
|
|
2024
|
+
const forced = this.forcedDate();
|
|
2025
|
+
if (forced) author = { ...author, ...forced };
|
|
1196
2026
|
// prepare_to_commit's pre-commit hook (not with --no-verify), over the index the commit
|
|
1197
2027
|
// records (the lock `-a` and a partial commit wrote); a hook that ran may have changed
|
|
1198
2028
|
// the index, which is read again (git's discard_index + read_index_from)
|
|
@@ -1255,42 +2085,6 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1255
2085
|
// a stored subtree no edit touched stays the one stored)
|
|
1256
2086
|
treeId = await writeIndexAsTree(this.staging, this.trees, this.objectFormat);
|
|
1257
2087
|
}
|
|
1258
|
-
let previousCommit: Commit | undefined;
|
|
1259
|
-
let amendedId: ObjectId | undefined;
|
|
1260
|
-
|
|
1261
|
-
if (this.amend) {
|
|
1262
|
-
const headId = await this.resolveHead();
|
|
1263
|
-
amendedId = headId;
|
|
1264
|
-
previousCommit = await this.commits.load(headId);
|
|
1265
|
-
if (!previousCommit) {
|
|
1266
|
-
throw new NoHeadError("Cannot amend: HEAD commit not found");
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
// The author (git's determine_author_info): the one given; else an amended commit's or
|
|
1271
|
-
// a concluded cherry-pick's author (its date too; `--author` replaces only the name and
|
|
1272
|
-
// email), unless --reset-author; else resolved as git does (GIT_AUTHOR_*, author.*,
|
|
1273
|
-
// user.*, GIT_AUTHOR_DATE or now)
|
|
1274
|
-
let author = this.author;
|
|
1275
|
-
if (!author) {
|
|
1276
|
-
const kept = this.resetAuthor
|
|
1277
|
-
? undefined
|
|
1278
|
-
: this.amend && previousCommit
|
|
1279
|
-
? previousCommit.author
|
|
1280
|
-
: pickHead
|
|
1281
|
-
? (await this.commits.load(pickHead))?.author
|
|
1282
|
-
: undefined;
|
|
1283
|
-
if (kept) {
|
|
1284
|
-
author = this.authorName
|
|
1285
|
-
? {
|
|
1286
|
-
...kept,
|
|
1287
|
-
name: withoutCrud(this.authorName.name),
|
|
1288
|
-
email: withoutCrud(this.authorName.email),
|
|
1289
|
-
}
|
|
1290
|
-
: kept;
|
|
1291
|
-
} else if (this.authorName) author = this.datedIdent("author", this.authorName);
|
|
1292
|
-
else author = this.resolveAuthor(this.committer ?? this.committerName);
|
|
1293
|
-
}
|
|
1294
2088
|
// the committer: always resolved (GIT_COMMITTER_*, committer.*, user.*), unless given
|
|
1295
2089
|
const committer =
|
|
1296
2090
|
this.committer ??
|
|
@@ -1313,7 +2107,11 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1313
2107
|
previousCommit,
|
|
1314
2108
|
author,
|
|
1315
2109
|
committer,
|
|
1316
|
-
|
|
2110
|
+
// author_date_is_interesting: an author_message, or --date
|
|
2111
|
+
authorKept:
|
|
2112
|
+
!this.author &&
|
|
2113
|
+
(this.forceDate !== undefined ||
|
|
2114
|
+
(!this.resetAuthor && (amendKeeps || !!pickHead || !!reused))),
|
|
1317
2115
|
hookEnv,
|
|
1318
2116
|
},
|
|
1319
2117
|
editor,
|
|
@@ -1328,16 +2126,22 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1328
2126
|
// whitespace) is written to COMMIT_EDITMSG; then a commit with nothing to commit is
|
|
1329
2127
|
// refused; then the file's text is cleaned up (cleanup_message) and checked
|
|
1330
2128
|
cleanup = commitCleanupMode(this.workingCopy, this.cleanupMode);
|
|
2129
|
+
const reusedMessage = await this.reusedMessage();
|
|
1331
2130
|
let sb: string;
|
|
1332
|
-
if (
|
|
2131
|
+
if (reusedMessage.text !== undefined) sb = reusedMessage.text;
|
|
2132
|
+
else if (message !== undefined) sb = completeLine(message);
|
|
1333
2133
|
else if (previousCommit) sb = previousCommit.message.replace(/^(?:[ \t\r]*\n)+/, "");
|
|
1334
2134
|
else {
|
|
1335
2135
|
const mergeMsg = await state.read("MERGE_MSG");
|
|
1336
2136
|
const squashMsg = await state.read("SQUASH_MSG");
|
|
1337
2137
|
sb = mergeMsg !== undefined ? `${squashMsg ?? ""}${mergeMsg}` : (squashMsg ?? "");
|
|
1338
2138
|
}
|
|
2139
|
+
sb = reusedMessage.prefix + sb;
|
|
1339
2140
|
if (cleanup !== CleanupMode.VERBATIM) sb = stripspace(sb);
|
|
2141
|
+
sb = this.signedOff(sb, committer);
|
|
1340
2142
|
await state.write("COMMIT_EDITMSG", sb);
|
|
2143
|
+
// amend_file_with_trailers over COMMIT_EDITMSG
|
|
2144
|
+
sb = await this.withTrailers(sb, state, undefined);
|
|
1341
2145
|
await this.refuseNothingToCommit(treeId, parents, mergeHeads, previousCommit);
|
|
1342
2146
|
// prepare-commit-msg and commit-msg, which may rewrite COMMIT_EDITMSG: the commit
|
|
1343
2147
|
// takes the file's text (cmd_commit reads it back)
|
|
@@ -1380,6 +2184,13 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1380
2184
|
if (untouched && !this.allowEmptyMessage) {
|
|
1381
2185
|
throw new NoMessageError("Aborting commit; you did not edit the message.");
|
|
1382
2186
|
}
|
|
2187
|
+
// an `amend!` message needs a body (the message the amended commit takes)
|
|
2188
|
+
if (this.fixup && finalMessage.startsWith("amend! ") && !this.allowEmptyMessage) {
|
|
2189
|
+
const body = finalMessage.slice(commitSubjectLength(finalMessage));
|
|
2190
|
+
if ((cleanup !== CleanupMode.VERBATIM || body.length === 0) && isEmptyMessage(body)) {
|
|
2191
|
+
throw new NoMessageError("Aborting commit due to empty commit message body.");
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
1383
2194
|
|
|
1384
2195
|
return this.finishCommit(treeId, parents, mergeHeads, pickHead, {
|
|
1385
2196
|
author,
|
|
@@ -1436,15 +2247,15 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1436
2247
|
): Promise<CommitResult> {
|
|
1437
2248
|
const { author, committer, finalMessage, state, amendedId } = info;
|
|
1438
2249
|
|
|
1439
|
-
// Create commit
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
message: finalMessage,
|
|
1446
|
-
|
|
1447
|
-
|
|
2250
|
+
// Create commit; commit_tree_extended signs it before writing it (without a signer, or
|
|
2251
|
+
// when the signer fails: git's failure, nothing written)
|
|
2252
|
+
const sign = signRequestOf(this.workingCopy, this.sign);
|
|
2253
|
+
const commit: Commit = await signCommit(
|
|
2254
|
+
this.workingCopy,
|
|
2255
|
+
sign,
|
|
2256
|
+
{ tree: treeId, parents, author, committer, message: finalMessage },
|
|
2257
|
+
sign === undefined ? {} : { cwd: await this.signingCwd() },
|
|
2258
|
+
);
|
|
1448
2259
|
const commitId = await this.commits.store(commit);
|
|
1449
2260
|
|
|
1450
2261
|
// Update HEAD/branch ref, with git's reflog line in the branch's log and HEAD's
|
|
@@ -1507,6 +2318,15 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1507
2318
|
return { ...commit, id: commitId };
|
|
1508
2319
|
}
|
|
1509
2320
|
|
|
2321
|
+
/** The host directory the signing program runs in, if the repository has one. */
|
|
2322
|
+
private async signingCwd(): Promise<string | undefined> {
|
|
2323
|
+
try {
|
|
2324
|
+
return await this.hooks.hostWorkingDirectory();
|
|
2325
|
+
} catch {
|
|
2326
|
+
return undefined;
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
|
|
1510
2330
|
/**
|
|
1511
2331
|
* The variables of the commit hooks (git's `run_commit_hook`): `GIT_INDEX_FILE` names the
|
|
1512
2332
|
* index the commit records (the lock `-a` and a partial commit write; git's false index of
|
|
@@ -1557,7 +2377,12 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1557
2377
|
mergeHeads: ObjectId[],
|
|
1558
2378
|
pickHead: ObjectId | undefined,
|
|
1559
2379
|
): string[] {
|
|
2380
|
+
// --squash tells "message" whatever the message's source (an empty second argument)
|
|
2381
|
+
if (this.squashFrom !== undefined) return ["message", ""];
|
|
1560
2382
|
if (this.message !== undefined) return ["message"];
|
|
2383
|
+
const reusedName = this.reusedName();
|
|
2384
|
+
if (reusedName !== undefined) return ["commit", reusedName];
|
|
2385
|
+
if (this.fixup) return ["message"];
|
|
1561
2386
|
// --amend without a message reuses HEAD's (git's use_message = "HEAD")
|
|
1562
2387
|
if (this.amend) return ["commit", "HEAD"];
|
|
1563
2388
|
if (mergeMsg !== undefined) return [squashMsg !== undefined ? "squash" : "merge"];
|
|
@@ -1878,7 +2703,9 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1878
2703
|
found.set(path, entry);
|
|
1879
2704
|
}
|
|
1880
2705
|
const trust = worktreeModeTrust(this.workingCopy, worktree);
|
|
1881
|
-
const adder = await IndexAdder.open(this.staging, this.blobs, trust
|
|
2706
|
+
const adder = await IndexAdder.open(this.staging, this.blobs, trust, {
|
|
2707
|
+
pathRules: worktreePathRules(this.workingCopy),
|
|
2708
|
+
});
|
|
1882
2709
|
for (const path of taken) {
|
|
1883
2710
|
const entry = found.get(path);
|
|
1884
2711
|
if (entry) await adder.add(worktree, path, entry);
|
|
@@ -2012,6 +2839,19 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
2012
2839
|
}
|
|
2013
2840
|
}
|
|
2014
2841
|
|
|
2842
|
+
/** git's `die_resolve_conflict("commit")`. */
|
|
2843
|
+
function unmergedPathsError(paths: string[]): UnmergedPathsError {
|
|
2844
|
+
return new UnmergedPathsError(
|
|
2845
|
+
paths,
|
|
2846
|
+
[
|
|
2847
|
+
"error: Committing is not possible because you have unmerged files.",
|
|
2848
|
+
"hint: Fix them up in the work tree, and then use 'git add/rm <file>'",
|
|
2849
|
+
"hint: as appropriate to mark resolution and make a commit.",
|
|
2850
|
+
"fatal: Exiting because of an unresolved conflict.",
|
|
2851
|
+
].join("\n"),
|
|
2852
|
+
);
|
|
2853
|
+
}
|
|
2854
|
+
|
|
2015
2855
|
/** git's "paths '<first> ...' with -a does not make sense". */
|
|
2016
2856
|
function pathsWithAllError(paths: readonly string[]): IncompatibleOptionsError {
|
|
2017
2857
|
return new IncompatibleOptionsError(
|
|
@@ -2143,3 +2983,14 @@ export interface CommitDryRunResult extends StatusTextResult {
|
|
|
2143
2983
|
/** 0 when there is something to commit, 1 when not (dry_run_commit) */
|
|
2144
2984
|
exitCode: number;
|
|
2145
2985
|
}
|
|
2986
|
+
|
|
2987
|
+
/**
|
|
2988
|
+
* fmt_ident's IDENT_STRICT checks of an author name given or kept (`--author`, `-C`,
|
|
2989
|
+
* `--amend`): an empty name, or one of crud only, refused with git's line.
|
|
2990
|
+
*/
|
|
2991
|
+
function strictAuthorName(name: string, email: string): void {
|
|
2992
|
+
if (name === "") throw new InvalidIdentError("author", "empty", email, false);
|
|
2993
|
+
if (![...name].some((c) => !(c <= " " || ",:;<>\"\\'".includes(c)))) {
|
|
2994
|
+
throw new InvalidIdentError("author", "crud", name, false);
|
|
2995
|
+
}
|
|
2996
|
+
}
|