@statewalker/vcs-commands 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/add-command.d.ts +38 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +55 -1
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/am/index.d.ts +1 -0
- package/dist/commands/am/index.d.ts.map +1 -1
- package/dist/commands/am/mailsplit.d.ts +88 -0
- package/dist/commands/am/mailsplit.d.ts.map +1 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-engine.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/bisect/bisect-command.d.ts +2 -0
- package/dist/commands/bisect/bisect-command.d.ts.map +1 -1
- package/dist/commands/bisect/bisect-engine.d.ts.map +1 -1
- package/dist/commands/branch-command.d.ts +148 -18
- package/dist/commands/branch-command.d.ts.map +1 -1
- package/dist/commands/branch-info-command.d.ts +55 -0
- package/dist/commands/branch-info-command.d.ts.map +1 -0
- package/dist/commands/branch-tracking.d.ts +106 -17
- package/dist/commands/branch-tracking.d.ts.map +1 -1
- package/dist/commands/branch-upstream-command.d.ts +83 -0
- package/dist/commands/branch-upstream-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +19 -3
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/cherry-pick-command.d.ts +59 -0
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +12 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +17 -0
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/comment-char-config.d.ts +35 -0
- package/dist/commands/comment-char-config.d.ts.map +1 -0
- package/dist/commands/commit-command.d.ts +191 -5
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/commit-reuse.d.ts +33 -0
- package/dist/commands/commit-reuse.d.ts.map +1 -0
- package/dist/commands/config-command.d.ts +236 -0
- package/dist/commands/config-command.d.ts.map +1 -0
- package/dist/commands/config-value-types.d.ts +91 -0
- package/dist/commands/config-value-types.d.ts.map +1 -0
- package/dist/commands/core-config.d.ts +20 -0
- package/dist/commands/core-config.d.ts.map +1 -1
- package/dist/commands/default-branch.d.ts +70 -0
- package/dist/commands/default-branch.d.ts.map +1 -0
- package/dist/commands/diff-color-config.d.ts +73 -0
- package/dist/commands/diff-color-config.d.ts.map +1 -0
- package/dist/commands/diff-command.d.ts +252 -5
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +20 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fmt-merge-msg-command.d.ts +124 -0
- package/dist/commands/fmt-merge-msg-command.d.ts.map +1 -0
- package/dist/commands/fork-point.d.ts +38 -0
- package/dist/commands/fork-point.d.ts.map +1 -0
- package/dist/commands/format-patch-command.d.ts +41 -1
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/fsck/fetch-fsck.d.ts +51 -0
- package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-command.d.ts +2 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-loose.d.ts +3 -0
- package/dist/commands/fsck/fsck-loose.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-object-checks.d.ts +25 -14
- package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-object-table.d.ts +15 -7
- package/dist/commands/fsck/fsck-object-table.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-pack.d.ts +11 -4
- package/dist/commands/fsck/fsck-pack.d.ts.map +1 -1
- package/dist/commands/fsck/verify-pack-command.d.ts.map +1 -1
- package/dist/commands/gc-command.d.ts +80 -48
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-date.d.ts +1 -65
- package/dist/commands/git-date.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +4 -0
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +43 -0
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/grep/grep-command.d.ts +210 -0
- package/dist/commands/grep/grep-command.d.ts.map +1 -0
- package/dist/commands/grep/grep-engine.d.ts +218 -0
- package/dist/commands/grep/grep-engine.d.ts.map +1 -0
- package/dist/commands/grep/index.d.ts +3 -0
- package/dist/commands/grep/index.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +15 -2
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index.d.ts +28 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -3
- package/dist/commands/init-command.d.ts +50 -3
- 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/legacy-remotes.d.ts +55 -0
- package/dist/commands/legacy-remotes.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts +36 -5
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +296 -11
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +26 -1
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +133 -5
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-remote-command.d.ts +2 -0
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/mailmap.d.ts +30 -0
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/merge-base-command.d.ts +60 -0
- package/dist/commands/merge-base-command.d.ts.map +1 -0
- package/dist/commands/merge-bases.d.ts +23 -0
- package/dist/commands/merge-bases.d.ts.map +1 -1
- package/dist/commands/merge-command.d.ts +108 -9
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-support.d.ts +11 -3
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/mv-command.d.ts +4 -0
- package/dist/commands/mv-command.d.ts.map +1 -1
- package/dist/commands/name-rev.d.ts +48 -0
- package/dist/commands/name-rev.d.ts.map +1 -0
- package/dist/commands/notes-command.d.ts.map +1 -1
- package/dist/commands/notes-merge-command.d.ts.map +1 -1
- package/dist/commands/notes-tree.d.ts +11 -1
- package/dist/commands/notes-tree.d.ts.map +1 -1
- package/dist/commands/patch-id.d.ts +3 -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 +28 -0
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +160 -9
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/read-tree-command.d.ts +6 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +168 -6
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/for-each-ref-command.d.ts +121 -0
- package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -0
- package/dist/commands/ref-filter/index.d.ts +8 -0
- package/dist/commands/ref-filter/index.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-atoms.d.ts +88 -0
- package/dist/commands/ref-filter/ref-atoms.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-filter.d.ts +178 -0
- package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-format.d.ts +222 -0
- package/dist/commands/ref-filter/ref-format.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts +56 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-quote.d.ts +20 -0
- package/dist/commands/ref-filter/ref-quote.d.ts.map +1 -0
- package/dist/commands/ref-filter/version-compare.d.ts +20 -0
- package/dist/commands/ref-filter/version-compare.d.ts.map +1 -0
- package/dist/commands/reflog-command.d.ts +120 -0
- package/dist/commands/reflog-command.d.ts.map +1 -1
- package/dist/commands/reflog-walk.d.ts +72 -0
- package/dist/commands/reflog-walk.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +138 -29
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-transport.d.ts +7 -1
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/reset-command.d.ts +2 -3
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +2 -3
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-filter/commit-filter.d.ts +95 -0
- package/dist/commands/rev-filter/commit-filter.d.ts.map +1 -0
- package/dist/commands/rev-filter/commit-grep.d.ts +91 -0
- package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -0
- package/dist/commands/rev-filter/index.d.ts +3 -0
- package/dist/commands/rev-filter/index.d.ts.map +1 -0
- package/dist/commands/rev-list-command.d.ts +154 -2
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/rev-parse-command.d.ts +9 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +32 -0
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +32 -1
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +21 -2
- 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 +85 -5
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +2 -0
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +7 -0
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/show-command.d.ts +130 -0
- package/dist/commands/show-command.d.ts.map +1 -0
- package/dist/commands/show-commit.d.ts +11 -0
- package/dist/commands/show-commit.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +164 -0
- package/dist/commands/signature-check.d.ts.map +1 -0
- package/dist/commands/signing.d.ts +160 -0
- package/dist/commands/signing.d.ts.map +1 -0
- package/dist/commands/sparse-checkout-command.d.ts.map +1 -1
- package/dist/commands/sparse-index-view.d.ts +45 -0
- package/dist/commands/sparse-index-view.d.ts.map +1 -0
- package/dist/commands/ssh-signer.d.ts +29 -0
- package/dist/commands/ssh-signer.d.ts.map +1 -0
- package/dist/commands/ssh-verifier.d.ts +42 -0
- package/dist/commands/ssh-verifier.d.ts.map +1 -0
- package/dist/commands/stash-apply-command.d.ts +5 -0
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-branch-command.d.ts +34 -0
- package/dist/commands/stash-branch-command.d.ts.map +1 -0
- package/dist/commands/stash-create-command.d.ts +18 -1
- package/dist/commands/stash-create-command.d.ts.map +1 -1
- package/dist/commands/stash-info.d.ts +93 -0
- package/dist/commands/stash-info.d.ts.map +1 -0
- package/dist/commands/stash-list-command.d.ts +16 -0
- package/dist/commands/stash-list-command.d.ts.map +1 -1
- package/dist/commands/stash-pop-command.d.ts +39 -0
- package/dist/commands/stash-pop-command.d.ts.map +1 -0
- package/dist/commands/stash-show-command.d.ts +48 -0
- package/dist/commands/stash-show-command.d.ts.map +1 -0
- package/dist/commands/stash-store-command.d.ts +29 -0
- package/dist/commands/stash-store-command.d.ts.map +1 -0
- package/dist/commands/stash-working-tree.d.ts.map +1 -1
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/status-header.d.ts +5 -0
- package/dist/commands/status-header.d.ts.map +1 -1
- package/dist/commands/submodule-add-command.d.ts +89 -0
- package/dist/commands/submodule-add-command.d.ts.map +1 -0
- package/dist/commands/submodule-auth.d.ts +90 -0
- package/dist/commands/submodule-auth.d.ts.map +1 -0
- package/dist/commands/submodule-commands.d.ts +375 -0
- package/dist/commands/submodule-commands.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +288 -0
- package/dist/commands/submodule-model.d.ts.map +1 -0
- package/dist/commands/submodule-summary-command.d.ts.map +1 -1
- package/dist/commands/submodule-update-command.d.ts +198 -0
- package/dist/commands/submodule-update-command.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts.map +1 -1
- package/dist/commands/tag-command.d.ts +259 -10
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/trailers.d.ts +218 -17
- package/dist/commands/trailers.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts +7 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/untracked-cache-support.d.ts +2 -1
- package/dist/commands/untracked-cache-support.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-list-command.d.ts.map +1 -1
- package/dist/commands/worktree-path-rules.d.ts +66 -0
- package/dist/commands/worktree-path-rules.d.ts.map +1 -0
- package/dist/commands/worktree-remove-command.d.ts +10 -3
- package/dist/commands/worktree-remove-command.d.ts.map +1 -1
- package/dist/commands/worktree-repair-command.d.ts +15 -2
- package/dist/commands/worktree-repair-command.d.ts.map +1 -1
- package/dist/commands/worktree-support.d.ts +5 -0
- package/dist/commands/worktree-support.d.ts.map +1 -1
- package/dist/{commands-DnmlfwGV.js → commands-ISM52N0n.js} +66120 -49271
- package/dist/errors/checkout-errors.d.ts +19 -0
- package/dist/errors/checkout-errors.d.ts.map +1 -1
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +57 -3
- package/dist/errors/ref-errors.d.ts +19 -0
- package/dist/errors/ref-errors.d.ts.map +1 -1
- package/dist/errors/worktree-errors.d.ts +6 -1
- package/dist/errors/worktree-errors.d.ts.map +1 -1
- package/dist/{git-command-DxvwPrPB.js → fsck-DLRpbwTj.js} +6863 -1070
- package/dist/git-command.d.ts +43 -2
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +276 -3
- package/dist/git.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/remote-config/index.d.ts +1 -1
- package/dist/remote-config/index.d.ts.map +1 -1
- package/dist/remote-config/remote-config-store.d.ts +117 -3
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/rename/detect-renames.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +8 -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-output.d.ts +85 -1
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/diff-pickaxe.d.ts +67 -0
- package/dist/results/diff-pickaxe.d.ts.map +1 -0
- package/dist/results/diff-words.d.ts +55 -0
- package/dist/results/diff-words.d.ts.map +1 -0
- package/dist/results/index.d.ts +4 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/init-result.d.ts +7 -0
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +5 -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.map +1 -1
- package/dist/{results-BZGa2Z3I.js → results-TB2IJ64h.js} +2178 -412
- package/dist/whitespace/index.d.ts +2 -0
- package/dist/whitespace/index.d.ts.map +1 -0
- package/dist/whitespace/whitespace-rule.d.ts +94 -0
- package/dist/whitespace/whitespace-rule.d.ts.map +1 -0
- package/package.json +12 -12
- package/src/commands/add-command.ts +178 -17
- package/src/commands/add-patch/add-interactive.ts +3 -3
- package/src/commands/am/am-command.ts +263 -43
- package/src/commands/am/index.ts +1 -0
- package/src/commands/am/mailsplit.ts +326 -0
- package/src/commands/apply/apply-command.ts +18 -8
- package/src/commands/apply/apply-engine.ts +6 -7
- package/src/commands/apply/apply-parse.ts +10 -10
- package/src/commands/attributes-source.ts +1 -1
- package/src/commands/bisect/bisect-command.ts +18 -5
- package/src/commands/bisect/bisect-engine.ts +2 -1
- package/src/commands/branch-command.ts +528 -53
- package/src/commands/branch-info-command.ts +150 -0
- package/src/commands/branch-tracking.ts +335 -60
- package/src/commands/branch-upstream-command.ts +218 -0
- package/src/commands/checkout-command.ts +70 -44
- package/src/commands/cherry-pick-command.ts +143 -0
- package/src/commands/clean-command.ts +34 -3
- package/src/commands/clone-command.ts +118 -5
- package/src/commands/comment-char-config.ts +160 -0
- package/src/commands/commit-command.ts +790 -71
- 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 +47 -2
- package/src/commands/default-branch.ts +196 -0
- package/src/commands/diff-color-config.ts +274 -0
- package/src/commands/diff-command.ts +1053 -75
- package/src/commands/fetch-command.ts +161 -13
- 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 +316 -43
- package/src/commands/fsck/fetch-fsck.ts +172 -18
- package/src/commands/fsck/fsck-command.ts +183 -66
- package/src/commands/fsck/fsck-loose.ts +14 -4
- package/src/commands/fsck/fsck-object-checks.ts +87 -46
- package/src/commands/fsck/fsck-object-table.ts +52 -42
- package/src/commands/fsck/fsck-pack.ts +64 -34
- package/src/commands/fsck/verify-pack-command.ts +5 -2
- package/src/commands/gc-command.ts +238 -107
- package/src/commands/git-date.ts +9 -895
- package/src/commands/git-describe.ts +31 -11
- package/src/commands/git-hooks.ts +92 -0
- package/src/commands/grep/grep-command.ts +1077 -0
- package/src/commands/grep/grep-engine.ts +1024 -0
- package/src/commands/grep/index.ts +2 -0
- package/src/commands/index-adder.ts +54 -10
- package/src/commands/index.ts +28 -0
- package/src/commands/init-command.ts +167 -11
- package/src/commands/interpret-trailers-command.ts +256 -0
- package/src/commands/legacy-remotes.ts +224 -0
- package/src/commands/local-transport.ts +109 -10
- package/src/commands/log-command.ts +1283 -232
- package/src/commands/log-graph.ts +123 -26
- package/src/commands/log-output.ts +280 -21
- package/src/commands/ls-remote-command.ts +9 -0
- package/src/commands/mailmap.ts +119 -0
- package/src/commands/merge-base-command.ts +170 -0
- package/src/commands/merge-bases.ts +63 -8
- package/src/commands/merge-command.ts +360 -82
- package/src/commands/merge-support.ts +43 -9
- package/src/commands/mv-command.ts +6 -3
- package/src/commands/name-rev.ts +171 -0
- package/src/commands/notes-command.ts +11 -1
- package/src/commands/notes-merge-command.ts +23 -14
- package/src/commands/notes-tree.ts +28 -13
- package/src/commands/octopus-merge.ts +3 -2
- package/src/commands/patch-id.ts +16 -8
- package/src/commands/pathspec-file.ts +72 -0
- package/src/commands/pathspec.ts +14 -2
- package/src/commands/pretty-format.ts +105 -20
- package/src/commands/promisor-remote.ts +10 -1
- package/src/commands/pull-command.ts +149 -22
- package/src/commands/push-command.ts +704 -72
- package/src/commands/read-tree-command.ts +34 -3
- package/src/commands/rebase-command.ts +957 -142
- package/src/commands/ref-filter/for-each-ref-command.ts +298 -0
- package/src/commands/ref-filter/index.ts +7 -0
- package/src/commands/ref-filter/ref-atoms.ts +581 -0
- package/src/commands/ref-filter/ref-filter.ts +651 -0
- package/src/commands/ref-filter/ref-format.ts +1070 -0
- package/src/commands/ref-filter/ref-listing-command.ts +421 -0
- package/src/commands/ref-filter/ref-quote.ts +69 -0
- package/src/commands/ref-filter/version-compare.ts +177 -0
- package/src/commands/reflog-command.ts +492 -2
- package/src/commands/reflog-walk.ts +234 -0
- package/src/commands/remote-command.ts +484 -74
- package/src/commands/remote-transport.ts +9 -1
- package/src/commands/reset-command.ts +40 -42
- package/src/commands/restore-command.ts +12 -41
- package/src/commands/rev-filter/commit-filter.ts +159 -0
- package/src/commands/rev-filter/commit-grep.ts +444 -0
- package/src/commands/rev-filter/index.ts +2 -0
- package/src/commands/rev-list-command.ts +402 -15
- package/src/commands/rev-parse-command.ts +22 -0
- package/src/commands/revert-command.ts +82 -0
- package/src/commands/revision-range.ts +204 -4
- package/src/commands/revision-resolver.ts +55 -22
- package/src/commands/rm-command.ts +282 -21
- package/src/commands/sequencer-pick.ts +504 -86
- package/src/commands/sequencer-support.ts +30 -5
- package/src/commands/serve-repository.ts +18 -3
- package/src/commands/show-command.ts +490 -0
- package/src/commands/show-commit.ts +24 -0
- package/src/commands/signature-check.ts +657 -0
- package/src/commands/signing.ts +385 -0
- package/src/commands/sparse-checkout-command.ts +2 -9
- package/src/commands/sparse-checkout-support.ts +2 -2
- package/src/commands/sparse-index-view.ts +135 -0
- package/src/commands/ssh-signer.ts +199 -0
- package/src/commands/ssh-verifier.ts +523 -0
- package/src/commands/stash-apply-command.ts +17 -5
- package/src/commands/stash-branch-command.ts +88 -0
- package/src/commands/stash-create-command.ts +30 -2
- 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 +7 -6
- package/src/commands/status-header.ts +44 -8
- package/src/commands/submodule-add-command.ts +509 -0
- package/src/commands/submodule-auth.ts +276 -0
- package/src/commands/submodule-commands.ts +1517 -0
- package/src/commands/submodule-model.ts +930 -0
- package/src/commands/submodule-summary-command.ts +6 -7
- package/src/commands/submodule-update-command.ts +1092 -0
- package/src/commands/switch-command.ts +3 -1
- package/src/commands/tag-command.ts +876 -64
- package/src/commands/trailers.ts +837 -100
- package/src/commands/tree-restore.ts +38 -10
- package/src/commands/untracked-cache-support.ts +16 -12
- package/src/commands/verify-command.ts +235 -0
- package/src/commands/worktree-add-command.ts +268 -24
- package/src/commands/worktree-list-command.ts +3 -5
- 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/core-commands/add.command.impl.ts +1 -1
- package/src/errors/checkout-errors.ts +29 -0
- package/src/errors/command-errors.ts +2 -1
- package/src/errors/ref-errors.ts +23 -0
- package/src/errors/worktree-errors.ts +8 -1
- package/src/git-command.ts +98 -3
- package/src/git.ts +420 -4
- package/src/remote-config/index.ts +4 -0
- package/src/remote-config/remote-config-store.ts +238 -11
- package/src/rename/detect-renames.ts +5 -1
- package/src/results/clone-result.ts +9 -0
- package/src/results/combined-diff.ts +38 -18
- package/src/results/diff-check.ts +185 -0
- package/src/results/diff-color.ts +868 -0
- package/src/results/diff-output.ts +204 -37
- package/src/results/diff-pickaxe.ts +304 -0
- package/src/results/diff-words.ts +395 -0
- package/src/results/index.ts +4 -0
- package/src/results/init-result.ts +9 -0
- package/src/results/pull-result.ts +5 -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 +5 -2
- 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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type Commit,
|
|
3
|
-
EMPTY_TREE_ID,
|
|
4
3
|
FileMode,
|
|
5
4
|
type ObjectId,
|
|
6
5
|
type PersonIdent,
|
|
7
6
|
type TreeEntry,
|
|
8
7
|
} from "@statewalker/vcs-core";
|
|
9
8
|
import { FileStagingStore } from "@statewalker/vcs-store-files";
|
|
9
|
+
import { compilePosixRegex, type PosixRegex } from "@statewalker/vcs-utils";
|
|
10
10
|
import { compareGitPaths } from "@statewalker/vcs-utils/encoding";
|
|
11
11
|
import type { FilesApi } from "@statewalker/vcs-utils/files";
|
|
12
12
|
import {
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
type Worktree,
|
|
18
18
|
type WorktreeEntry,
|
|
19
19
|
} from "@statewalker/vcs-working-tree";
|
|
20
|
-
|
|
21
20
|
import {
|
|
22
21
|
EmptyCommitError,
|
|
23
22
|
GitApiError,
|
|
@@ -34,10 +33,28 @@ import {
|
|
|
34
33
|
import { GitCommand } from "../git-command.js";
|
|
35
34
|
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
36
35
|
import { AddCommand } from "./add-command.js";
|
|
36
|
+
import {
|
|
37
|
+
amendCommitText,
|
|
38
|
+
autosquashSubject,
|
|
39
|
+
commitSubjectLength,
|
|
40
|
+
type FixupKind,
|
|
41
|
+
parseFixupSpec,
|
|
42
|
+
refuseIncompatible,
|
|
43
|
+
skipBlankLines,
|
|
44
|
+
} from "./commit-reuse.js";
|
|
37
45
|
import { worktreeModeTrust } from "./core-config.js";
|
|
38
46
|
import { DEFAULT_DATE_MODE, showDate } from "./date-format.js";
|
|
39
|
-
import {
|
|
47
|
+
import { approxidateCareful } from "./git-date.js";
|
|
48
|
+
import {
|
|
49
|
+
hostEnvironmentOf,
|
|
50
|
+
InvalidDateError,
|
|
51
|
+
InvalidIdentError,
|
|
52
|
+
parseGitDate,
|
|
53
|
+
withoutCrud,
|
|
54
|
+
} from "./git-ident.js";
|
|
40
55
|
import { IndexAdder, readGitlinkHead } from "./index-adder.js";
|
|
56
|
+
import { reencodedCommitParts } from "./log-output.js";
|
|
57
|
+
import { readRepositoryMailmap } from "./mailmap.js";
|
|
41
58
|
import {
|
|
42
59
|
flatTree,
|
|
43
60
|
OperationState,
|
|
@@ -64,8 +81,10 @@ import {
|
|
|
64
81
|
pathspecItemMayMatch,
|
|
65
82
|
} from "./pathspec.js";
|
|
66
83
|
import { PathspecAttributes } from "./pathspec-attributes.js";
|
|
84
|
+
import { PathspecFile } from "./pathspec-file.js";
|
|
67
85
|
import { type CommitReflogKind, reflogMessages, updateHead } from "./reflog-messages.js";
|
|
68
86
|
import { applyAutostash } from "./sequencer-support.js";
|
|
87
|
+
import { signCommit, signRequestOf } from "./signing.js";
|
|
69
88
|
import {
|
|
70
89
|
cutLine,
|
|
71
90
|
readShowUntrackedFiles,
|
|
@@ -75,6 +94,16 @@ import {
|
|
|
75
94
|
} from "./status-command.js";
|
|
76
95
|
import { type CommitWhence, StatusPrinter } from "./status-format.js";
|
|
77
96
|
import { readDiffSubmoduleConfig } from "./submodule-summary.js";
|
|
97
|
+
import {
|
|
98
|
+
amendWithTrailers,
|
|
99
|
+
appendSignoff,
|
|
100
|
+
ignoredLogMessageBytes,
|
|
101
|
+
signoffLine,
|
|
102
|
+
type TrailerCommandRunner,
|
|
103
|
+
trailerConfigOf,
|
|
104
|
+
validateTrailerArgs,
|
|
105
|
+
} from "./trailers.js";
|
|
106
|
+
import { worktreePathRules } from "./worktree-path-rules.js";
|
|
78
107
|
|
|
79
108
|
/**
|
|
80
109
|
* Result of a commit operation.
|
|
@@ -145,9 +174,13 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
145
174
|
private amend = false;
|
|
146
175
|
private noPostRewrite = false;
|
|
147
176
|
private noVerify = false;
|
|
177
|
+
/** `-S[<keyid>]` / `--no-gpg-sign` (undefined: `commit.gpgSign`) */
|
|
178
|
+
private sign?: boolean | string;
|
|
148
179
|
private allowEmpty = false;
|
|
149
180
|
private parents: ObjectId[] = [];
|
|
150
181
|
private onlyPaths: string[] = [];
|
|
182
|
+
/** `--pathspec-from-file` */
|
|
183
|
+
private readonly pathspecFile = new PathspecFile();
|
|
151
184
|
private all = false;
|
|
152
185
|
private include = false;
|
|
153
186
|
private includePaths: string[] = [];
|
|
@@ -164,6 +197,24 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
164
197
|
private nullTermination = false;
|
|
165
198
|
private aheadBehind?: boolean;
|
|
166
199
|
private templateFile?: string;
|
|
200
|
+
/** `--author=<string>` as given: `Name <email>`, or a pattern of an existing author */
|
|
201
|
+
private authorString?: string;
|
|
202
|
+
/** `--date=<date>`, and the clock its relative forms count from */
|
|
203
|
+
private forceDate?: { text: string; now?: number };
|
|
204
|
+
private signoff = false;
|
|
205
|
+
private trailerArgs: string[] = [];
|
|
206
|
+
/** `-C <commit>`: the commit whose message (and author) are reused */
|
|
207
|
+
private reuseMessage?: string;
|
|
208
|
+
/** The commit `-C` (or `-c`) names, read once the options are checked */
|
|
209
|
+
private reused?: Commit;
|
|
210
|
+
/** `-c <commit>` */
|
|
211
|
+
private reeditMessageFrom?: string;
|
|
212
|
+
/** `--fixup=[(amend|reword):]<commit>` as given */
|
|
213
|
+
private fixupSpec?: string;
|
|
214
|
+
/** `--squash=<commit>` */
|
|
215
|
+
private squashFrom?: string;
|
|
216
|
+
/** --fixup, parsed when the commit runs */
|
|
217
|
+
private fixup?: { kind: FixupKind; target: string };
|
|
167
218
|
|
|
168
219
|
/**
|
|
169
220
|
* Set the commit message, as git's `commit -m` takes it: its last line is ended and it is
|
|
@@ -222,17 +273,78 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
222
273
|
}
|
|
223
274
|
|
|
224
275
|
/**
|
|
225
|
-
* Set the author identity
|
|
276
|
+
* Set the author identity (git's `--author`): a name and an email, or one string as git's
|
|
277
|
+
* `--author=<author>` takes it. A string with a `>` is `Name <email>` (refused as
|
|
278
|
+
* `fatal: malformed --author parameter` without a `<`); any other is a pattern looked up as
|
|
279
|
+
* git's `find_author_by_nickname` does: the newest commit of `--all` whose (mailmapped)
|
|
280
|
+
* author matches it as a basic regular expression, ignoring case, gives its `Name <email>`,
|
|
281
|
+
* else `fatal: --author '<x>' is not 'Name <email>' and matches no existing author`.
|
|
226
282
|
*
|
|
227
|
-
* @
|
|
283
|
+
* @example
|
|
284
|
+
* ```typescript
|
|
285
|
+
* await git.commit().setAuthor("Ada <ada@example.com>").setMessage("m").call();
|
|
286
|
+
* await git.commit().setAuthor("ada").setMessage("m").call(); // an existing author
|
|
287
|
+
* ```
|
|
288
|
+
*
|
|
289
|
+
* @param name Author name, or the whole `--author` string when `email` is not given
|
|
228
290
|
* @param email Author email
|
|
229
291
|
*/
|
|
230
|
-
setAuthor(name: string, email
|
|
292
|
+
setAuthor(name: string, email?: string): this {
|
|
231
293
|
this.checkCallable();
|
|
232
294
|
// git's --author: the name and email; the date is the amended commit's, the picked
|
|
233
295
|
// commit's, else GIT_AUTHOR_DATE or now
|
|
234
296
|
this.author = undefined;
|
|
235
|
-
|
|
297
|
+
if (email === undefined) {
|
|
298
|
+
this.authorName = undefined;
|
|
299
|
+
this.authorString = name;
|
|
300
|
+
} else {
|
|
301
|
+
this.authorString = undefined;
|
|
302
|
+
this.authorName = { name, email };
|
|
303
|
+
}
|
|
304
|
+
return this;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* `--date=<date>`: the author's date, in any form git's `parse_date` reads (`@<seconds>
|
|
309
|
+
* <offset>`, RFC 2822, ISO 8601, ...) or else as `approxidate` reads it (`yesterday`,
|
|
310
|
+
* `2.weeks.ago`, `noon`), counting from `now` (seconds; default the command's clock, git's
|
|
311
|
+
* `GIT_TEST_DATE_NOW`). A date git cannot read fails as `fatal: invalid date format: <date>`.
|
|
312
|
+
*/
|
|
313
|
+
setDate(date: string, options: { now?: number } = {}): this {
|
|
314
|
+
this.checkCallable();
|
|
315
|
+
this.forceDate = { text: date, ...(options.now !== undefined ? { now: options.now } : {}) };
|
|
316
|
+
return this;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* `-s` / `--signoff`: a `Signed-off-by: <committer>` trailer added to the message as git's
|
|
321
|
+
* `append_signoff` adds it (after a blank line unless the message ends with trailers; none
|
|
322
|
+
* when the last trailer is that line already).
|
|
323
|
+
*/
|
|
324
|
+
setSignoff(signoff: boolean): this {
|
|
325
|
+
this.checkCallable();
|
|
326
|
+
this.signoff = signoff;
|
|
327
|
+
return this;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* `--trailer <token>[(=|:)<value>]`: a trailer added to the message as `git
|
|
332
|
+
* interpret-trailers --no-divider --trailer` adds it (`trailer.*` configuration applies).
|
|
333
|
+
* Each call adds one, in order.
|
|
334
|
+
*/
|
|
335
|
+
addTrailer(trailer: string): this {
|
|
336
|
+
this.checkCallable();
|
|
337
|
+
this.trailerArgs.push(trailer);
|
|
338
|
+
return this;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* `-C <commit>`: the commit's message taken as it is, and its author (name, email and
|
|
343
|
+
* date) unless {@link setResetAuthor}. With {@link setEdit}(true) it is `-c`.
|
|
344
|
+
*/
|
|
345
|
+
setReuseMessage(commit: string): this {
|
|
346
|
+
this.checkCallable();
|
|
347
|
+
this.reuseMessage = commit;
|
|
236
348
|
return this;
|
|
237
349
|
}
|
|
238
350
|
|
|
@@ -275,8 +387,8 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
275
387
|
}
|
|
276
388
|
|
|
277
389
|
/**
|
|
278
|
-
* `--reset-author`: an amended commit, or the commit that concludes a
|
|
279
|
-
* authored as a new one (the author resolved as git resolves it, dated now) instead of
|
|
390
|
+
* `--reset-author`: an amended commit, a `-C` commit, or the commit that concludes a
|
|
391
|
+
* cherry-pick, is authored as a new one (the author resolved as git resolves it, dated now) instead of
|
|
280
392
|
* keeping the earlier commit's author.
|
|
281
393
|
*
|
|
282
394
|
* @param reset Whether to reset the author
|
|
@@ -307,6 +419,29 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
307
419
|
return this;
|
|
308
420
|
}
|
|
309
421
|
|
|
422
|
+
/**
|
|
423
|
+
* `-S` (true) / `--no-gpg-sign` (false): whether to sign the commit; undefined (the
|
|
424
|
+
* default) leaves it to `commit.gpgSign`. The commit is signed with the default key
|
|
425
|
+
* (`user.signingKey`, else as `gpg.format` says) through the host's signer
|
|
426
|
+
* (`GitHostEnvironment.signer`) and carries the signature in its `gpgsig` header
|
|
427
|
+
* ({@link signCommit}). Without a signer, or when it fails, the commit fails as git fails
|
|
428
|
+
* when gpg cannot sign (`error: gpg failed to sign the data:`, `fatal: failed to write
|
|
429
|
+
* commit object`, exit 128: {@link SigningFailedError}) once everything before the signing
|
|
430
|
+
* is done, and nothing is committed.
|
|
431
|
+
*/
|
|
432
|
+
setSign(sign: boolean | undefined): this {
|
|
433
|
+
this.checkCallable();
|
|
434
|
+
this.sign = sign;
|
|
435
|
+
return this;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/** `-S<keyid>`: sign with this key (see {@link setSign}). */
|
|
439
|
+
setSigningKey(keyId: string): this {
|
|
440
|
+
this.checkCallable();
|
|
441
|
+
this.sign = keyId;
|
|
442
|
+
return this;
|
|
443
|
+
}
|
|
444
|
+
|
|
310
445
|
/**
|
|
311
446
|
* Set whether to amend the previous commit.
|
|
312
447
|
*
|
|
@@ -377,6 +512,29 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
377
512
|
return this;
|
|
378
513
|
}
|
|
379
514
|
|
|
515
|
+
/**
|
|
516
|
+
* `--pathspec-from-file` (and `--pathspec-file-nul` with `nul`): the pathspec elements of
|
|
517
|
+
* `content`, one per line (a line starting with `"` unquoted as a C string), or separated
|
|
518
|
+
* by NUL with `nul`, committed as {@link setOnly} paths (or {@link setInclude}'s with
|
|
519
|
+
* `setInclude()`). As git's prepare_index: refused with {@link setAll} ("options
|
|
520
|
+
* '--pathspec-from-file' and '-a' cannot be used together") and beside paths given to
|
|
521
|
+
* `setOnly`/`setInclude` ("'--pathspec-from-file' and pathspec arguments cannot be used
|
|
522
|
+
* together"); an empty file commits the index as it is (with `setInclude()`: "No paths
|
|
523
|
+
* with --include/--only does not make sense.").
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* ```typescript
|
|
527
|
+
* await git.commit().setPathspecFromFile("src/a.ts\n").setMessage("Fix a").call();
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* @throws InvalidArgumentError "fatal: line is badly quoted: <line>"
|
|
531
|
+
*/
|
|
532
|
+
setPathspecFromFile(content: string | Uint8Array, nul = false): this {
|
|
533
|
+
this.checkCallable();
|
|
534
|
+
this.pathspecFile.read(content, nul);
|
|
535
|
+
return this;
|
|
536
|
+
}
|
|
537
|
+
|
|
380
538
|
/**
|
|
381
539
|
* Set whether to auto-stage modified tracked files before committing.
|
|
382
540
|
*
|
|
@@ -482,6 +640,50 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
482
640
|
return this;
|
|
483
641
|
}
|
|
484
642
|
|
|
643
|
+
/**
|
|
644
|
+
* `-c <commit>` / `--reedit-message=<commit>`: as {@link setReuseMessage} (or `-C` with {@link setEdit}(true)), with the message
|
|
645
|
+
* then given to the editor ({@link setEditor}; without one it is taken as it is).
|
|
646
|
+
*/
|
|
647
|
+
setReeditMessage(commit: string): this {
|
|
648
|
+
this.checkCallable();
|
|
649
|
+
this.reeditMessageFrom = commit;
|
|
650
|
+
return this;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* `--fixup=[(amend|reword):]<commit>`: a commit `rebase --autosquash` folds into `commit`.
|
|
655
|
+
* Plain, its message is `fixup! <subject>` (then the {@link setMessage} text, if any) and
|
|
656
|
+
* no editor runs. `amend:<commit>` makes `amend! <subject>` followed by the commit's whole
|
|
657
|
+
* message (its body alone when it is an `amend!` commit itself) for the editor to change,
|
|
658
|
+
* empty commits allowed and a message given with {@link setMessage} refused; `reword:` is
|
|
659
|
+
* `amend:` committing HEAD's tree (only the message changes), refused with paths, `-a`,
|
|
660
|
+
* `-i`, and during a merge or cherry-pick. An `amend!` message without a body is refused
|
|
661
|
+
* (`Aborting commit due to empty commit message body.`).
|
|
662
|
+
*
|
|
663
|
+
* @example
|
|
664
|
+
* ```typescript
|
|
665
|
+
* await git.commit().setFixup("HEAD~1").call();
|
|
666
|
+
* await git.commit().setFixup("reword:HEAD~1").setEditor(edit).call();
|
|
667
|
+
* ```
|
|
668
|
+
*/
|
|
669
|
+
setFixup(commit: string): this {
|
|
670
|
+
this.checkCallable();
|
|
671
|
+
this.fixupSpec = commit;
|
|
672
|
+
return this;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* `--squash=<commit>`: the message starts with `squash! <subject>` and a blank line, then
|
|
677
|
+
* the message given ({@link setMessage}, {@link setReuseMessage}: only `squash! ` when it
|
|
678
|
+
* names the same commit as given here), else what the editor makes of it. Refused with
|
|
679
|
+
* {@link setFixup}.
|
|
680
|
+
*/
|
|
681
|
+
setSquash(commit: string): this {
|
|
682
|
+
this.checkCallable();
|
|
683
|
+
this.squashFrom = commit;
|
|
684
|
+
return this;
|
|
685
|
+
}
|
|
686
|
+
|
|
485
687
|
/** `-e` / `--no-edit`: edit a given message too, or never edit (default: edit when none is given). */
|
|
486
688
|
setEdit(edit: boolean): this {
|
|
487
689
|
this.checkCallable();
|
|
@@ -561,6 +763,8 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
561
763
|
// ... and git_diff_ui_config: a diff.submodule without a value dies
|
|
562
764
|
readDiffSubmoduleConfig(this.workingCopy);
|
|
563
765
|
await this.readCurrentIndex();
|
|
766
|
+
await this.checkReuseOptions();
|
|
767
|
+
this.applyPathspecFile();
|
|
564
768
|
// `-i` refuses what it refuses for a commit, before anything is read
|
|
565
769
|
if (this.include) this.checkIncludeOptions();
|
|
566
770
|
const state = new OperationState(this.workingCopy.checkout, this.refsStore);
|
|
@@ -621,7 +825,23 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
621
825
|
/** git's use_editor: an editor is set, and no message is given or `-e` asks for it. */
|
|
622
826
|
private usesEditor(): boolean {
|
|
623
827
|
if (!this.editor || this.edit === false) return false;
|
|
624
|
-
return this.edit === true || this.
|
|
828
|
+
return this.edit === true || this.editsByDefault();
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* git's use_editor before `-e`/`--no-edit`: no message given (`-m`, `-C`) and no plain
|
|
833
|
+
* `--fixup`, whose messages are taken as they are.
|
|
834
|
+
*/
|
|
835
|
+
private editsByDefault(): boolean {
|
|
836
|
+
if (this.message !== undefined || this.reuseMessage !== undefined) return false;
|
|
837
|
+
if (this.fixupSpec === undefined) return true;
|
|
838
|
+
const parsed = parseFixupSpec(this.fixupSpec);
|
|
839
|
+
return !("kind" in parsed) || parsed.kind !== "fixup";
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/** The revision `-c` or `-C` names (git's use_message), as given. */
|
|
843
|
+
private reusedName(): string | undefined {
|
|
844
|
+
return this.reeditMessageFrom ?? this.reuseMessage;
|
|
625
845
|
}
|
|
626
846
|
|
|
627
847
|
/**
|
|
@@ -651,7 +871,11 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
651
871
|
const { state } = ctx;
|
|
652
872
|
const config = RemoteConfigStore.from(this.workingCopy);
|
|
653
873
|
const mode = editorCleanupMode(this.workingCopy, this.cleanupMode);
|
|
654
|
-
|
|
874
|
+
// (-m, -C, -c and --fixup drop the template: git frees template_file)
|
|
875
|
+
const templateText =
|
|
876
|
+
this.message !== undefined || this.reused || this.fixup
|
|
877
|
+
? undefined
|
|
878
|
+
: await this.readTemplate(config);
|
|
655
879
|
const rebasing = (await state.read("rebase-merge/head-name")) !== undefined;
|
|
656
880
|
const whence: CommitWhence =
|
|
657
881
|
ctx.mergeHeads.length > 0
|
|
@@ -666,7 +890,9 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
666
890
|
let cutLineAdded = false;
|
|
667
891
|
const mergeMsg = await state.read("MERGE_MSG");
|
|
668
892
|
const squashMsg = await state.read("SQUASH_MSG");
|
|
669
|
-
|
|
893
|
+
const reusedMessage = await this.reusedMessage();
|
|
894
|
+
if (reusedMessage.text !== undefined) sb = reusedMessage.text;
|
|
895
|
+
else if (this.message !== undefined) sb = completeLine(this.message);
|
|
670
896
|
else if (this.amend && ctx.previousCommit) {
|
|
671
897
|
sb = ctx.previousCommit.message.replace(/^(?:[ \t\r]*\n)+/, "");
|
|
672
898
|
} else if (mergeMsg !== undefined) {
|
|
@@ -677,14 +903,17 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
677
903
|
}
|
|
678
904
|
} else if (squashMsg !== undefined) sb = squashMsg;
|
|
679
905
|
else if (templateText !== undefined) sb = templateText;
|
|
906
|
+
sb = reusedMessage.prefix + sb;
|
|
680
907
|
// clean_message_contents: not for a template, which goes in as it is
|
|
681
908
|
const fromTemplate =
|
|
909
|
+
reusedMessage.text === undefined &&
|
|
682
910
|
this.message === undefined &&
|
|
683
911
|
!(this.amend && ctx.previousCommit) &&
|
|
684
912
|
mergeMsg === undefined &&
|
|
685
913
|
squashMsg === undefined &&
|
|
686
914
|
templateText !== undefined;
|
|
687
915
|
if (mode !== CleanupMode.VERBATIM && !fromTemplate) sb = stripspace(sb);
|
|
916
|
+
sb = this.signedOff(sb, ctx.committer);
|
|
688
917
|
// core.commentChar=auto: a character the message does not start a line with
|
|
689
918
|
const comment = commentPrefixOf(this.workingCopy, sb);
|
|
690
919
|
// (a prepared message taken without an editor: as `--no-status`, unless asked for)
|
|
@@ -763,11 +992,13 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
763
992
|
// `cache_nr - ita_nr > 0`. The recorded tree says both without a status run.
|
|
764
993
|
const parentTree = ctx.firstParent
|
|
765
994
|
? (await this.commits.load(ctx.firstParent))?.tree
|
|
766
|
-
:
|
|
995
|
+
: this.objectFormat.emptyTreeId;
|
|
767
996
|
committable = ctx.treeId !== parentTree;
|
|
768
997
|
}
|
|
769
|
-
// COMMIT_EDITMSG written in full,
|
|
998
|
+
// COMMIT_EDITMSG written in full, its trailers added (amend_file_with_trailers), then an
|
|
999
|
+
// empty commit refused before the editor runs
|
|
770
1000
|
await state.write("COMMIT_EDITMSG", template);
|
|
1001
|
+
template = await this.withTrailers(template, state, comment);
|
|
771
1002
|
const isMerge = (ctx.previousCommit?.parents.length ?? 0) > 1;
|
|
772
1003
|
if (!committable && whence !== "merge" && !this.allowEmpty && !(this.amend && isMerge)) {
|
|
773
1004
|
throw new EmptyCommitError();
|
|
@@ -810,6 +1041,59 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
810
1041
|
};
|
|
811
1042
|
}
|
|
812
1043
|
|
|
1044
|
+
/**
|
|
1045
|
+
* `-s`: the message so far with the committer's sign-off (append_signoff with
|
|
1046
|
+
* ignored_log_message_bytes: before trailing comments and the scissors line).
|
|
1047
|
+
*/
|
|
1048
|
+
private signedOff(message: string, committer: PersonIdent): string {
|
|
1049
|
+
if (!this.signoff) return message;
|
|
1050
|
+
const config = trailerConfigOf(this.workingCopy);
|
|
1051
|
+
return appendSignoff(
|
|
1052
|
+
message,
|
|
1053
|
+
signoffLine(committer),
|
|
1054
|
+
config,
|
|
1055
|
+
false,
|
|
1056
|
+
ignoredLogMessageBytes(message, config.commentString),
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* `--trailer`: COMMIT_EDITMSG (written as `message`) with the trailers added, as git's
|
|
1062
|
+
* amend_file_with_trailers (2.43: a child `interpret-trailers --in-place --no-divider`,
|
|
1063
|
+
* which takes an empty argument for nothing and refuses none); the new text, written back.
|
|
1064
|
+
*/
|
|
1065
|
+
private async withTrailers(
|
|
1066
|
+
message: string,
|
|
1067
|
+
state: OperationState,
|
|
1068
|
+
comment: string | undefined,
|
|
1069
|
+
): Promise<string> {
|
|
1070
|
+
if (this.trailerArgs.length === 0) return message;
|
|
1071
|
+
const hooks = this.hooks;
|
|
1072
|
+
const compatibility = hooks.compatibility;
|
|
1073
|
+
const config = {
|
|
1074
|
+
...trailerConfigOf(this.workingCopy),
|
|
1075
|
+
...(comment !== undefined ? { commentString: comment } : {}),
|
|
1076
|
+
compatibility,
|
|
1077
|
+
};
|
|
1078
|
+
let args = this.trailerArgs;
|
|
1079
|
+
if (compatibility === "2.43") args = args.filter((a) => a !== "");
|
|
1080
|
+
else {
|
|
1081
|
+
const refused = validateTrailerArgs(args, config);
|
|
1082
|
+
if (refused !== undefined) {
|
|
1083
|
+
throw new GitApiError(`${refused}\nfatal: unable to pass trailers to --trailers`, {
|
|
1084
|
+
exitCode: 128,
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
if (args.length === 0) return message;
|
|
1089
|
+
const runCommand: TrailerCommandRunner | undefined = hooks.enabled
|
|
1090
|
+
? (command) => hooks.runShellCommand("trailer", command.command, command.args)
|
|
1091
|
+
: undefined;
|
|
1092
|
+
const { output } = await amendWithTrailers(message, args, config, runCommand);
|
|
1093
|
+
await state.write("COMMIT_EDITMSG", output);
|
|
1094
|
+
return output;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
813
1097
|
/**
|
|
814
1098
|
* The commit template (`-t`, else `commit.template`, `~/` expanded) read through the host,
|
|
815
1099
|
* undefined when none is set; one that cannot be read fails as git's `die_errno`.
|
|
@@ -970,11 +1254,14 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
970
1254
|
readShowUntrackedFiles(this.workingCopy);
|
|
971
1255
|
// ... and git_diff_ui_config: a diff.submodule without a value dies
|
|
972
1256
|
readDiffSubmoduleConfig(this.workingCopy);
|
|
1257
|
+
await this.parseAuthorOptions();
|
|
973
1258
|
// the index as it is now: one another writer replaced is read again (git reads the
|
|
974
1259
|
// index at its start), unless this instance holds unwritten edits (refused)
|
|
975
1260
|
await this.readCurrentIndex();
|
|
1261
|
+
this.applyPathspecFile();
|
|
976
1262
|
if (this.include) return this.commitIncluded();
|
|
977
|
-
|
|
1263
|
+
// `--fixup=reword:` is a partial commit of no path: HEAD's tree (git sets `only`)
|
|
1264
|
+
const partial = this.onlyPaths.length > 0 || this.fixup?.kind === "reword";
|
|
978
1265
|
if (!this.all) return this.commitWith(partial, undefined);
|
|
979
1266
|
// `-a` (git's COMMIT_NORMAL): the index lock held from before the tracked changes are
|
|
980
1267
|
// staged until HEAD has moved
|
|
@@ -1009,6 +1296,345 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1009
1296
|
}
|
|
1010
1297
|
}
|
|
1011
1298
|
|
|
1299
|
+
/**
|
|
1300
|
+
* parse_and_validate_options' handling of `--author`, `-m` with `-C`, `--reset-author`,
|
|
1301
|
+
* and `-C`'s commit (read_commit_message), in git's order.
|
|
1302
|
+
*/
|
|
1303
|
+
private async parseAuthorOptions(): Promise<void> {
|
|
1304
|
+
if (this.authorString !== undefined) {
|
|
1305
|
+
let text = this.authorString;
|
|
1306
|
+
if (!text.includes(">")) text = await this.findAuthorByNickname(text);
|
|
1307
|
+
if (this.resetAuthor) {
|
|
1308
|
+
throw new IncompatibleOptionsError(
|
|
1309
|
+
["--reset-author", "--author"],
|
|
1310
|
+
"fatal: options '--reset-author' and '--author' cannot be used together",
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1313
|
+
// split_ident_line: the name up to the `<` (trailing spaces dropped), the email up to
|
|
1314
|
+
// the first `>` after it
|
|
1315
|
+
const lt = text.indexOf("<");
|
|
1316
|
+
const gt = lt < 0 ? -1 : text.indexOf(">", lt + 1);
|
|
1317
|
+
if (gt < 0) {
|
|
1318
|
+
throw new InvalidArgumentError(
|
|
1319
|
+
"author",
|
|
1320
|
+
this.authorString,
|
|
1321
|
+
"fatal: malformed --author parameter",
|
|
1322
|
+
);
|
|
1323
|
+
}
|
|
1324
|
+
const name = text.slice(0, lt).replace(/[ \t\n\v\f\r]+$/, "");
|
|
1325
|
+
this.authorName = { name, email: text.slice(lt + 1, gt) };
|
|
1326
|
+
}
|
|
1327
|
+
await this.checkReuseOptions();
|
|
1328
|
+
if (this.forceDate) this.forcedDate();
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
/** A blob's bytes, undefined when it cannot be read. */
|
|
1332
|
+
private async readBlobBytes(id: ObjectId): Promise<Uint8Array | undefined> {
|
|
1333
|
+
try {
|
|
1334
|
+
const content = await this.blobs.load(id);
|
|
1335
|
+
if (!content) return undefined;
|
|
1336
|
+
const chunks: Uint8Array[] = [];
|
|
1337
|
+
let size = 0;
|
|
1338
|
+
for await (const c of content) {
|
|
1339
|
+
chunks.push(c);
|
|
1340
|
+
size += c.length;
|
|
1341
|
+
}
|
|
1342
|
+
const out = new Uint8Array(size);
|
|
1343
|
+
let at = 0;
|
|
1344
|
+
for (const c of chunks) {
|
|
1345
|
+
out.set(c, at);
|
|
1346
|
+
at += c.length;
|
|
1347
|
+
}
|
|
1348
|
+
return out;
|
|
1349
|
+
} catch {
|
|
1350
|
+
return undefined;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* `--date` (parse_force_date): the date as `parse_date` reads it, else as `approxidate`
|
|
1356
|
+
* does, refused as git refuses it.
|
|
1357
|
+
*/
|
|
1358
|
+
private forcedDate(): Pick<PersonIdent, "timestamp" | "tzOffset"> | undefined {
|
|
1359
|
+
if (!this.forceDate) return undefined;
|
|
1360
|
+
const { text } = this.forceDate;
|
|
1361
|
+
const parsed = parseGitDate(text);
|
|
1362
|
+
if (parsed) return parsed;
|
|
1363
|
+
const approx = approxidateCareful(text, this.forceDate.now ?? this.clock());
|
|
1364
|
+
// fmt_ident's parse_date of `@<seconds>`: the local offset of that time
|
|
1365
|
+
const date = approx.error ? undefined : parseGitDate(`@${approx.timestamp}`);
|
|
1366
|
+
if (!date) throw new InvalidDateError(text);
|
|
1367
|
+
return date;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* builtin/commit.c's find_author_by_nickname: the first commit of `rev-list --all -i
|
|
1372
|
+
* --author=<name>` (newest first, the mailmap applied before matching) gives `%aN <%aE>`.
|
|
1373
|
+
*/
|
|
1374
|
+
private async findAuthorByNickname(name: string): Promise<string> {
|
|
1375
|
+
let pattern: PosixRegex;
|
|
1376
|
+
try {
|
|
1377
|
+
pattern = compilePosixRegex(name, { icase: true });
|
|
1378
|
+
} catch (error) {
|
|
1379
|
+
throw new InvalidArgumentError(
|
|
1380
|
+
"author",
|
|
1381
|
+
name,
|
|
1382
|
+
`fatal: '${name}': ${error instanceof Error ? error.message : String(error)}`,
|
|
1383
|
+
);
|
|
1384
|
+
}
|
|
1385
|
+
const config = RemoteConfigStore.from(this.workingCopy);
|
|
1386
|
+
const mailmap = await readRepositoryMailmap({
|
|
1387
|
+
config: (key) => config.value(key),
|
|
1388
|
+
worktree: this.worktreeAccess,
|
|
1389
|
+
environment: hostEnvironmentOf(this.workingCopy),
|
|
1390
|
+
readBlobNamed: async (blob) => {
|
|
1391
|
+
const id = await this.revisionResolver()
|
|
1392
|
+
.resolve(blob)
|
|
1393
|
+
.catch(() => undefined);
|
|
1394
|
+
return id ? this.readBlobBytes(id) : undefined;
|
|
1395
|
+
},
|
|
1396
|
+
});
|
|
1397
|
+
const encoder = new TextEncoder();
|
|
1398
|
+
// revision.c's walk of --all: refs under refs/ in name order, then HEAD, tags peeled;
|
|
1399
|
+
// commits come out by commit date, newest first
|
|
1400
|
+
const starts: { name: string; id: ObjectId }[] = [];
|
|
1401
|
+
for await (const ref of this.refsStore.list()) {
|
|
1402
|
+
if (!ref.name.startsWith("refs/")) continue;
|
|
1403
|
+
let id = "objectId" in ref ? ref.objectId : undefined;
|
|
1404
|
+
if (!id) id = (await this.refsStore.resolve(ref.name).catch(() => undefined))?.objectId;
|
|
1405
|
+
if (id) starts.push({ name: ref.name, id });
|
|
1406
|
+
}
|
|
1407
|
+
starts.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
1408
|
+
const head = (await this.refsStore.resolve("HEAD").catch(() => undefined))?.objectId;
|
|
1409
|
+
const ids = starts.map((s) => s.id);
|
|
1410
|
+
if (head) ids.push(head);
|
|
1411
|
+
const queue: { id: ObjectId; commit: Commit; date: number; order: number }[] = [];
|
|
1412
|
+
const seen = new Set<ObjectId>();
|
|
1413
|
+
let order = 0;
|
|
1414
|
+
const put = async (start: ObjectId) => {
|
|
1415
|
+
let id = start;
|
|
1416
|
+
const tags = this.tagsStore;
|
|
1417
|
+
for (let depth = 0; depth < 32 && tags && (await tags.has(id).catch(() => false)); depth++) {
|
|
1418
|
+
const tag = await tags.load(id).catch(() => undefined);
|
|
1419
|
+
if (!tag) break;
|
|
1420
|
+
id = tag.object;
|
|
1421
|
+
}
|
|
1422
|
+
if (seen.has(id)) return;
|
|
1423
|
+
const commit = await this.commits.load(id).catch(() => undefined);
|
|
1424
|
+
if (!commit) return;
|
|
1425
|
+
seen.add(id);
|
|
1426
|
+
queue.push({ id, commit, date: commit.committer.timestamp, order: order++ });
|
|
1427
|
+
};
|
|
1428
|
+
for (const id of ids) await put(id);
|
|
1429
|
+
while (queue.length > 0) {
|
|
1430
|
+
let best = 0;
|
|
1431
|
+
for (let i = 1; i < queue.length; i++) {
|
|
1432
|
+
const a = queue[i] as (typeof queue)[number];
|
|
1433
|
+
const b = queue[best] as (typeof queue)[number];
|
|
1434
|
+
if (a.date > b.date || (a.date === b.date && a.order < b.order)) best = i;
|
|
1435
|
+
}
|
|
1436
|
+
const [next] = queue.splice(best, 1);
|
|
1437
|
+
if (!next) break;
|
|
1438
|
+
const who = mailmap.map(next.commit.author.name, next.commit.author.email);
|
|
1439
|
+
if (pattern.test(encoder.encode(`${who.name} <${who.email}>`))) {
|
|
1440
|
+
return `${who.name} <${who.email}>`;
|
|
1441
|
+
}
|
|
1442
|
+
for (const parent of next.commit.parents) await put(parent);
|
|
1443
|
+
}
|
|
1444
|
+
throw new InvalidArgumentError(
|
|
1445
|
+
"author",
|
|
1446
|
+
name,
|
|
1447
|
+
`fatal: --author '${name}' is not 'Name <email>' and matches no existing author`,
|
|
1448
|
+
);
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
/**
|
|
1452
|
+
* parse_and_validate_options for `-C`, `-c`, `--fixup` and `--squash`, in git's order: the
|
|
1453
|
+
* incompatible options, the commit `-C`/`-c` names read (`could not lookup commit`), then
|
|
1454
|
+
* `--fixup`'s suboption (`amend:`/`reword:` allow empty commits; `reword:` refuses paths,
|
|
1455
|
+
* `-a`, `-i` and a merge or cherry-pick in progress).
|
|
1456
|
+
*/
|
|
1457
|
+
private async checkReuseOptions(): Promise<void> {
|
|
1458
|
+
if (this.fixupSpec !== undefined && this.squashFrom !== undefined) {
|
|
1459
|
+
throw new IncompatibleOptionsError(
|
|
1460
|
+
["--squash", "--fixup"],
|
|
1461
|
+
"fatal: options '--squash' and '--fixup' cannot be used together",
|
|
1462
|
+
);
|
|
1463
|
+
}
|
|
1464
|
+
refuseIncompatible([
|
|
1465
|
+
["-C", this.reuseMessage !== undefined],
|
|
1466
|
+
["-c", this.reeditMessageFrom !== undefined],
|
|
1467
|
+
["--fixup", this.fixupSpec !== undefined],
|
|
1468
|
+
]);
|
|
1469
|
+
refuseIncompatible([
|
|
1470
|
+
["-m", this.message !== undefined],
|
|
1471
|
+
["-c", this.reeditMessageFrom !== undefined],
|
|
1472
|
+
["-C", this.reuseMessage !== undefined],
|
|
1473
|
+
]);
|
|
1474
|
+
const use = this.reusedName();
|
|
1475
|
+
if (use !== undefined) this.reused = await this.lookupCommit(use);
|
|
1476
|
+
if (this.fixupSpec === undefined) return;
|
|
1477
|
+
const parsed = parseFixupSpec(this.fixupSpec);
|
|
1478
|
+
if ("unknown" in parsed) {
|
|
1479
|
+
throw new InvalidArgumentError(
|
|
1480
|
+
"fixup",
|
|
1481
|
+
this.fixupSpec,
|
|
1482
|
+
`fatal: unknown option: --fixup=${parsed.unknown}:${parsed.target}`,
|
|
1483
|
+
);
|
|
1484
|
+
}
|
|
1485
|
+
this.fixup = parsed;
|
|
1486
|
+
if (parsed.kind === "fixup") return;
|
|
1487
|
+
this.allowEmpty = true;
|
|
1488
|
+
if (parsed.kind !== "reword") return;
|
|
1489
|
+
// check_fixup_reword_options
|
|
1490
|
+
const state = new OperationState(this.workingCopy.checkout, this.refsStore);
|
|
1491
|
+
if ((await this.mergeHeads(state)).length > 0) {
|
|
1492
|
+
throw new InvalidArgumentError(
|
|
1493
|
+
"fixup",
|
|
1494
|
+
this.fixupSpec,
|
|
1495
|
+
"fatal: You are in the middle of a merge -- cannot reword.",
|
|
1496
|
+
);
|
|
1497
|
+
}
|
|
1498
|
+
const pick = await state.ref("CHERRY_PICK_HEAD");
|
|
1499
|
+
// (a rebase stopped at a pick is no cherry-pick: git's is_from_cherry_pick)
|
|
1500
|
+
if (
|
|
1501
|
+
pick &&
|
|
1502
|
+
!(
|
|
1503
|
+
(await state.read("rebase-merge/head-name")) !== undefined &&
|
|
1504
|
+
(await state.ref("REBASE_HEAD")) === pick
|
|
1505
|
+
)
|
|
1506
|
+
) {
|
|
1507
|
+
throw new InvalidArgumentError(
|
|
1508
|
+
"fixup",
|
|
1509
|
+
this.fixupSpec,
|
|
1510
|
+
"fatal: You are in the middle of a cherry-pick -- cannot reword.",
|
|
1511
|
+
);
|
|
1512
|
+
}
|
|
1513
|
+
const path = this.onlyPaths[0] ?? this.includePaths[0];
|
|
1514
|
+
if (path !== undefined) {
|
|
1515
|
+
throw new IncompatibleOptionsError(
|
|
1516
|
+
["--fixup", "paths"],
|
|
1517
|
+
`fatal: reword option of '--fixup' and path '${path}' cannot be used together`,
|
|
1518
|
+
);
|
|
1519
|
+
}
|
|
1520
|
+
if (this.all || this.include) {
|
|
1521
|
+
throw new IncompatibleOptionsError(
|
|
1522
|
+
["--fixup", "--all"],
|
|
1523
|
+
"fatal: reword option of '--fixup' and '--patch/--interactive/--all/--include/--only' cannot be used together",
|
|
1524
|
+
);
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
/** git's lookup_commit_reference_by_name, dying as `could not lookup commit '<name>'`. */
|
|
1529
|
+
private async lookupCommit(name: string): Promise<Commit> {
|
|
1530
|
+
const fatal = `fatal: could not lookup commit '${name}'`;
|
|
1531
|
+
let id: ObjectId;
|
|
1532
|
+
try {
|
|
1533
|
+
id = await this.resolveRevision(name);
|
|
1534
|
+
} catch (error) {
|
|
1535
|
+
if (error instanceof RefNotFoundError) throw new GitApiError(fatal);
|
|
1536
|
+
throw error;
|
|
1537
|
+
}
|
|
1538
|
+
const peeled = await this.revisionResolver().peelTags(id);
|
|
1539
|
+
const commit = peeled.type === "commit" ? await this.commits.load(peeled.id) : undefined;
|
|
1540
|
+
if (!commit) {
|
|
1541
|
+
throw new GitApiError(
|
|
1542
|
+
peeled.type
|
|
1543
|
+
? `error: object ${peeled.id} is a ${peeled.type}, not a commit\n${fatal}`
|
|
1544
|
+
: fatal,
|
|
1545
|
+
);
|
|
1546
|
+
}
|
|
1547
|
+
return this.inCommitOutputEncoding(peeled.id, commit);
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* A commit's message and author as `git commit` reads another commit's (read_commit_message,
|
|
1552
|
+
* format_commit_message): converted from its `encoding` header into the commit output
|
|
1553
|
+
* encoding (`i18n.commitEncoding`, else UTF-8). Ours writes UTF-8 messages only, so a
|
|
1554
|
+
* commit is converted only when that encoding is UTF-8.
|
|
1555
|
+
*/
|
|
1556
|
+
private async inCommitOutputEncoding(id: ObjectId, commit: Commit): Promise<Commit> {
|
|
1557
|
+
if (commit.encoding === undefined) return commit;
|
|
1558
|
+
const configured = RemoteConfigStore.from(this.workingCopy).value("i18n.commitEncoding");
|
|
1559
|
+
const output = configured ? configured : "UTF-8";
|
|
1560
|
+
if (!/^utf-?8$/i.test(output)) return commit;
|
|
1561
|
+
const raw = await this.readRawObject(id);
|
|
1562
|
+
const parts = raw && reencodedCommitParts(raw, output);
|
|
1563
|
+
if (!parts) return commit;
|
|
1564
|
+
return { ...commit, message: parts.message, ...(parts.author ? { author: parts.author } : {}) };
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
/** The stored bytes of an object (undefined where the store cannot give them). */
|
|
1568
|
+
private async readRawObject(id: ObjectId): Promise<Uint8Array | undefined> {
|
|
1569
|
+
const objects = this.workingCopy.history?.objects;
|
|
1570
|
+
if (!objects) return undefined;
|
|
1571
|
+
try {
|
|
1572
|
+
const obj = await objects.get(id);
|
|
1573
|
+
if (!obj) return undefined;
|
|
1574
|
+
if (obj.bytes) return obj.bytes;
|
|
1575
|
+
const chunks: Uint8Array[] = [];
|
|
1576
|
+
let size = 0;
|
|
1577
|
+
for await (const c of obj.content) {
|
|
1578
|
+
chunks.push(c);
|
|
1579
|
+
size += c.length;
|
|
1580
|
+
}
|
|
1581
|
+
const out = new Uint8Array(size);
|
|
1582
|
+
let at = 0;
|
|
1583
|
+
for (const c of chunks) {
|
|
1584
|
+
out.set(c, at);
|
|
1585
|
+
at += c.length;
|
|
1586
|
+
}
|
|
1587
|
+
return out;
|
|
1588
|
+
} catch {
|
|
1589
|
+
return undefined;
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
/**
|
|
1594
|
+
* The start of prepare_to_commit's message from `-C`/`-c`/`--fixup`/`--squash`: the
|
|
1595
|
+
* `squash! ` subject (`prefix`, put before whatever message follows) and, for `-C`/`-c`
|
|
1596
|
+
* and `--fixup`, the text that replaces the other sources (undefined: they apply).
|
|
1597
|
+
*/
|
|
1598
|
+
private async reusedMessage(): Promise<{ prefix: string; text: string | undefined }> {
|
|
1599
|
+
let prefix = "";
|
|
1600
|
+
if (this.squashFrom !== undefined) {
|
|
1601
|
+
prefix =
|
|
1602
|
+
(this.reusedName() ?? (this.amend && !this.fixup ? "HEAD" : undefined)) === this.squashFrom
|
|
1603
|
+
? "squash! "
|
|
1604
|
+
: autosquashSubject("squash", (await this.lookupCommit(this.squashFrom)).message);
|
|
1605
|
+
}
|
|
1606
|
+
if (this.reused) return { prefix, text: skipBlankLines(this.reused.message) };
|
|
1607
|
+
if (!this.fixup) return { prefix, text: undefined };
|
|
1608
|
+
const target = await this.lookupCommit(this.fixup.target);
|
|
1609
|
+
if (this.fixup.kind === "fixup") {
|
|
1610
|
+
const given = this.message !== undefined ? completeLine(this.message) : "";
|
|
1611
|
+
return { prefix, text: autosquashSubject("fixup", target.message) + given };
|
|
1612
|
+
}
|
|
1613
|
+
if (this.message !== undefined) {
|
|
1614
|
+
throw new IncompatibleOptionsError(
|
|
1615
|
+
["-m", "--fixup"],
|
|
1616
|
+
`fatal: options '-m' and '--fixup:${this.fixup.kind}' cannot be used together`,
|
|
1617
|
+
);
|
|
1618
|
+
}
|
|
1619
|
+
return {
|
|
1620
|
+
prefix,
|
|
1621
|
+
text: autosquashSubject("amend", target.message) + amendCommitText(target.message),
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
/**
|
|
1626
|
+
* prepare_index's `--pathspec-from-file`: refused with `-a` and beside pathspec arguments
|
|
1627
|
+
* ({@link setOnly}, {@link setInclude}); its elements are then the paths of `-i`, else of
|
|
1628
|
+
* `--only`.
|
|
1629
|
+
*/
|
|
1630
|
+
private applyPathspecFile(): void {
|
|
1631
|
+
if (!this.pathspecFile.given) return;
|
|
1632
|
+
this.pathspecFile.refuse("-a", this.all);
|
|
1633
|
+
this.pathspecFile.refuseArguments([...this.onlyPaths, ...this.includePaths]);
|
|
1634
|
+
if (this.include) this.includePaths = [...this.pathspecFile.elements];
|
|
1635
|
+
else this.onlyPaths = [...this.pathspecFile.elements];
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1012
1638
|
/** `-i <paths>`: parse_and_validate_options' and prepare_index's refusals. */
|
|
1013
1639
|
private checkIncludeOptions(): void {
|
|
1014
1640
|
if (this.onlyPaths.length > 0) {
|
|
@@ -1059,6 +1685,13 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1059
1685
|
const state = new OperationState(this.workingCopy.checkout, this.refsStore);
|
|
1060
1686
|
const mergeHeads = await this.mergeHeads(state);
|
|
1061
1687
|
const pickHead = await state.ref("CHERRY_PICK_HEAD");
|
|
1688
|
+
if (this.resetAuthor && !this.amend && !this.reused && !pickHead) {
|
|
1689
|
+
throw new InvalidArgumentError(
|
|
1690
|
+
"reset-author",
|
|
1691
|
+
true,
|
|
1692
|
+
"fatal: --reset-author can be used only with -C, -c or --amend.",
|
|
1693
|
+
);
|
|
1694
|
+
}
|
|
1062
1695
|
if (this.amend && mergeHeads.length > 0) {
|
|
1063
1696
|
throw new InvalidArgumentError(
|
|
1064
1697
|
"amend",
|
|
@@ -1070,8 +1703,11 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1070
1703
|
const headId = (await this.refsStore.resolve("HEAD"))?.objectId;
|
|
1071
1704
|
let partialTree: ObjectId | undefined;
|
|
1072
1705
|
let falseIndexFile: FalseIndexFile | undefined;
|
|
1706
|
+
// (`--fixup=reword:` names no path: the false index is HEAD's tree)
|
|
1073
1707
|
const partialPaths = partial
|
|
1074
|
-
?
|
|
1708
|
+
? this.fixup?.kind === "reword"
|
|
1709
|
+
? new Map<string, boolean>()
|
|
1710
|
+
: await this.listPartialPaths(state, mergeHeads, headId)
|
|
1075
1711
|
: undefined;
|
|
1076
1712
|
if (partialPaths) {
|
|
1077
1713
|
// git's partial commit (prepare_index): the index lock taken once the paths are
|
|
@@ -1155,7 +1791,7 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1155
1791
|
hostPath: await this.hooks.gitPath(name, true),
|
|
1156
1792
|
reread: async () => {
|
|
1157
1793
|
await temp.read();
|
|
1158
|
-
return writeIndexAsTree(temp, this.trees, { write: false });
|
|
1794
|
+
return writeIndexAsTree(temp, this.trees, this.objectFormat, { write: false });
|
|
1159
1795
|
},
|
|
1160
1796
|
remove,
|
|
1161
1797
|
};
|
|
@@ -1183,17 +1819,90 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1183
1819
|
const mergeMsgPresent =
|
|
1184
1820
|
(await state.read("MERGE_MSG")) !== undefined ||
|
|
1185
1821
|
(await state.read("SQUASH_MSG")) !== undefined;
|
|
1822
|
+
const reused = this.reused;
|
|
1823
|
+
// (-c, --squash and --fixup=amend:/reword: prepare a message for the editor: without
|
|
1824
|
+
// one it is taken as it is, as with GIT_EDITOR=:)
|
|
1825
|
+
const preparedForEditor =
|
|
1826
|
+
this.reeditMessageFrom !== undefined ||
|
|
1827
|
+
this.squashFrom !== undefined ||
|
|
1828
|
+
(this.fixup !== undefined && this.fixup.kind !== "fixup");
|
|
1186
1829
|
const editorLike =
|
|
1187
1830
|
this.usesEditor() ||
|
|
1188
|
-
(this.
|
|
1831
|
+
(this.edit !== false &&
|
|
1832
|
+
this.editsByDefault() &&
|
|
1833
|
+
((!reused && !this.amend && mergeMsgPresent) || preparedForEditor));
|
|
1189
1834
|
const editor: CommitEditor = this.usesEditor()
|
|
1190
1835
|
? (this.editor as CommitEditor)
|
|
1191
1836
|
: async () => undefined;
|
|
1192
1837
|
const message = this.message;
|
|
1193
|
-
if (
|
|
1838
|
+
if (
|
|
1839
|
+
!editorLike &&
|
|
1840
|
+
message === undefined &&
|
|
1841
|
+
!reused &&
|
|
1842
|
+
!this.amend &&
|
|
1843
|
+
!mergeMsgPresent &&
|
|
1844
|
+
!this.fixup &&
|
|
1845
|
+
this.squashFrom === undefined
|
|
1846
|
+
) {
|
|
1194
1847
|
throw new NoMessageError();
|
|
1195
1848
|
}
|
|
1196
1849
|
|
|
1850
|
+
let previousCommit: Commit | undefined;
|
|
1851
|
+
let amendedId: ObjectId | undefined;
|
|
1852
|
+
|
|
1853
|
+
if (this.amend) {
|
|
1854
|
+
const headId = await this.resolveHead();
|
|
1855
|
+
amendedId = headId;
|
|
1856
|
+
previousCommit = await this.commits.load(headId);
|
|
1857
|
+
if (!previousCommit) {
|
|
1858
|
+
throw new NoHeadError("Cannot amend: HEAD commit not found");
|
|
1859
|
+
}
|
|
1860
|
+
// (its message and author as git reads them: use_message = "HEAD")
|
|
1861
|
+
previousCommit = await this.inCommitOutputEncoding(headId, previousCommit);
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
// The author (git's determine_author_info, which prepare_to_commit runs before the
|
|
1865
|
+
// pre-commit hook): the one given; else an amended commit's or
|
|
1866
|
+
// a concluded cherry-pick's author (its date too; `--author` replaces only the name and
|
|
1867
|
+
// email), unless --reset-author; else resolved as git does (GIT_AUTHOR_*, author.*,
|
|
1868
|
+
// user.*, GIT_AUTHOR_DATE or now)
|
|
1869
|
+
// (`--amend --fixup` keeps no author: git's author_message is use_message's, which
|
|
1870
|
+
// --fixup leaves unset)
|
|
1871
|
+
const amendKeeps = this.amend && !!previousCommit && !this.fixup;
|
|
1872
|
+
let author = this.author;
|
|
1873
|
+
if (!author) {
|
|
1874
|
+
// (git's author_message: a cherry-pick's CHERRY_PICK_HEAD, else -C's commit, else the
|
|
1875
|
+
// amended HEAD)
|
|
1876
|
+
const kept = this.resetAuthor
|
|
1877
|
+
? undefined
|
|
1878
|
+
: pickHead
|
|
1879
|
+
? (await this.commits.load(pickHead))?.author
|
|
1880
|
+
: reused
|
|
1881
|
+
? reused.author
|
|
1882
|
+
: amendKeeps
|
|
1883
|
+
? previousCommit?.author
|
|
1884
|
+
: undefined;
|
|
1885
|
+
// fmt_ident's IDENT_STRICT refusals of the name chosen (an empty one, crud only)
|
|
1886
|
+
if (kept || this.authorName) {
|
|
1887
|
+
strictAuthorName(
|
|
1888
|
+
this.authorName?.name ?? (kept as PersonIdent).name,
|
|
1889
|
+
this.authorName?.email ?? (kept as PersonIdent).email,
|
|
1890
|
+
);
|
|
1891
|
+
}
|
|
1892
|
+
if (kept) {
|
|
1893
|
+
author = this.authorName
|
|
1894
|
+
? {
|
|
1895
|
+
...kept,
|
|
1896
|
+
name: withoutCrud(this.authorName.name),
|
|
1897
|
+
email: withoutCrud(this.authorName.email),
|
|
1898
|
+
}
|
|
1899
|
+
: kept;
|
|
1900
|
+
} else if (this.authorName) author = this.datedIdent("author", this.authorName);
|
|
1901
|
+
else author = this.resolveAuthor(this.committer ?? this.committerName);
|
|
1902
|
+
}
|
|
1903
|
+
// --date: the author's date, whatever gave the rest
|
|
1904
|
+
const forced = this.forcedDate();
|
|
1905
|
+
if (forced) author = { ...author, ...forced };
|
|
1197
1906
|
// prepare_to_commit's pre-commit hook (not with --no-verify), over the index the commit
|
|
1198
1907
|
// records (the lock `-a` and a partial commit wrote); a hook that ran may have changed
|
|
1199
1908
|
// the index, which is read again (git's discard_index + read_index_from)
|
|
@@ -1246,49 +1955,15 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1246
1955
|
} else if (index) {
|
|
1247
1956
|
// `-a`: the index with a fully valid cache-tree (cache_tree_update), written into the
|
|
1248
1957
|
// lock
|
|
1249
|
-
treeId = await writeIndexAsTree(this.staging, this.trees, {
|
|
1958
|
+
treeId = await writeIndexAsTree(this.staging, this.trees, this.objectFormat, {
|
|
1959
|
+
write: false,
|
|
1960
|
+
});
|
|
1250
1961
|
await index.write();
|
|
1251
1962
|
} else {
|
|
1252
1963
|
// Normal mode: use full staging area; as git's prepare_index, the index is written
|
|
1253
1964
|
// again with a fully valid cache-tree (cache_tree_update, which keeps the valid nodes:
|
|
1254
1965
|
// a stored subtree no edit touched stays the one stored)
|
|
1255
|
-
treeId = await writeIndexAsTree(this.staging, this.trees);
|
|
1256
|
-
}
|
|
1257
|
-
let previousCommit: Commit | undefined;
|
|
1258
|
-
let amendedId: ObjectId | undefined;
|
|
1259
|
-
|
|
1260
|
-
if (this.amend) {
|
|
1261
|
-
const headId = await this.resolveHead();
|
|
1262
|
-
amendedId = headId;
|
|
1263
|
-
previousCommit = await this.commits.load(headId);
|
|
1264
|
-
if (!previousCommit) {
|
|
1265
|
-
throw new NoHeadError("Cannot amend: HEAD commit not found");
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
// The author (git's determine_author_info): the one given; else an amended commit's or
|
|
1270
|
-
// a concluded cherry-pick's author (its date too; `--author` replaces only the name and
|
|
1271
|
-
// email), unless --reset-author; else resolved as git does (GIT_AUTHOR_*, author.*,
|
|
1272
|
-
// user.*, GIT_AUTHOR_DATE or now)
|
|
1273
|
-
let author = this.author;
|
|
1274
|
-
if (!author) {
|
|
1275
|
-
const kept = this.resetAuthor
|
|
1276
|
-
? undefined
|
|
1277
|
-
: this.amend && previousCommit
|
|
1278
|
-
? previousCommit.author
|
|
1279
|
-
: pickHead
|
|
1280
|
-
? (await this.commits.load(pickHead))?.author
|
|
1281
|
-
: undefined;
|
|
1282
|
-
if (kept) {
|
|
1283
|
-
author = this.authorName
|
|
1284
|
-
? {
|
|
1285
|
-
...kept,
|
|
1286
|
-
name: withoutCrud(this.authorName.name),
|
|
1287
|
-
email: withoutCrud(this.authorName.email),
|
|
1288
|
-
}
|
|
1289
|
-
: kept;
|
|
1290
|
-
} else if (this.authorName) author = this.datedIdent("author", this.authorName);
|
|
1291
|
-
else author = this.resolveAuthor(this.committer ?? this.committerName);
|
|
1966
|
+
treeId = await writeIndexAsTree(this.staging, this.trees, this.objectFormat);
|
|
1292
1967
|
}
|
|
1293
1968
|
// the committer: always resolved (GIT_COMMITTER_*, committer.*, user.*), unless given
|
|
1294
1969
|
const committer =
|
|
@@ -1312,7 +1987,11 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1312
1987
|
previousCommit,
|
|
1313
1988
|
author,
|
|
1314
1989
|
committer,
|
|
1315
|
-
|
|
1990
|
+
// author_date_is_interesting: an author_message, or --date
|
|
1991
|
+
authorKept:
|
|
1992
|
+
!this.author &&
|
|
1993
|
+
(this.forceDate !== undefined ||
|
|
1994
|
+
(!this.resetAuthor && (amendKeeps || !!pickHead || !!reused))),
|
|
1316
1995
|
hookEnv,
|
|
1317
1996
|
},
|
|
1318
1997
|
editor,
|
|
@@ -1327,16 +2006,22 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1327
2006
|
// whitespace) is written to COMMIT_EDITMSG; then a commit with nothing to commit is
|
|
1328
2007
|
// refused; then the file's text is cleaned up (cleanup_message) and checked
|
|
1329
2008
|
cleanup = commitCleanupMode(this.workingCopy, this.cleanupMode);
|
|
2009
|
+
const reusedMessage = await this.reusedMessage();
|
|
1330
2010
|
let sb: string;
|
|
1331
|
-
if (
|
|
2011
|
+
if (reusedMessage.text !== undefined) sb = reusedMessage.text;
|
|
2012
|
+
else if (message !== undefined) sb = completeLine(message);
|
|
1332
2013
|
else if (previousCommit) sb = previousCommit.message.replace(/^(?:[ \t\r]*\n)+/, "");
|
|
1333
2014
|
else {
|
|
1334
2015
|
const mergeMsg = await state.read("MERGE_MSG");
|
|
1335
2016
|
const squashMsg = await state.read("SQUASH_MSG");
|
|
1336
2017
|
sb = mergeMsg !== undefined ? `${squashMsg ?? ""}${mergeMsg}` : (squashMsg ?? "");
|
|
1337
2018
|
}
|
|
2019
|
+
sb = reusedMessage.prefix + sb;
|
|
1338
2020
|
if (cleanup !== CleanupMode.VERBATIM) sb = stripspace(sb);
|
|
2021
|
+
sb = this.signedOff(sb, committer);
|
|
1339
2022
|
await state.write("COMMIT_EDITMSG", sb);
|
|
2023
|
+
// amend_file_with_trailers over COMMIT_EDITMSG
|
|
2024
|
+
sb = await this.withTrailers(sb, state, undefined);
|
|
1340
2025
|
await this.refuseNothingToCommit(treeId, parents, mergeHeads, previousCommit);
|
|
1341
2026
|
// prepare-commit-msg and commit-msg, which may rewrite COMMIT_EDITMSG: the commit
|
|
1342
2027
|
// takes the file's text (cmd_commit reads it back)
|
|
@@ -1379,6 +2064,13 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1379
2064
|
if (untouched && !this.allowEmptyMessage) {
|
|
1380
2065
|
throw new NoMessageError("Aborting commit; you did not edit the message.");
|
|
1381
2066
|
}
|
|
2067
|
+
// an `amend!` message needs a body (the message the amended commit takes)
|
|
2068
|
+
if (this.fixup && finalMessage.startsWith("amend! ") && !this.allowEmptyMessage) {
|
|
2069
|
+
const body = finalMessage.slice(commitSubjectLength(finalMessage));
|
|
2070
|
+
if ((cleanup !== CleanupMode.VERBATIM || body.length === 0) && isEmptyMessage(body)) {
|
|
2071
|
+
throw new NoMessageError("Aborting commit due to empty commit message body.");
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
1382
2074
|
|
|
1383
2075
|
return this.finishCommit(treeId, parents, mergeHeads, pickHead, {
|
|
1384
2076
|
author,
|
|
@@ -1407,7 +2099,7 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1407
2099
|
// no first parent (an initial commit, or --amend of a root commit): git counts the
|
|
1408
2100
|
// index, `cache_nr - ita_nr > 0`; only intent-to-add entries (or none) leave the tree
|
|
1409
2101
|
// empty
|
|
1410
|
-
if (treeId ===
|
|
2102
|
+
if (treeId === this.objectFormat.emptyTreeId) throw new EmptyCommitError();
|
|
1411
2103
|
return;
|
|
1412
2104
|
}
|
|
1413
2105
|
if (this.amend && (previousCommit?.parents.length ?? 0) > 1) return;
|
|
@@ -1435,15 +2127,15 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1435
2127
|
): Promise<CommitResult> {
|
|
1436
2128
|
const { author, committer, finalMessage, state, amendedId } = info;
|
|
1437
2129
|
|
|
1438
|
-
// Create commit
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
message: finalMessage,
|
|
1445
|
-
|
|
1446
|
-
|
|
2130
|
+
// Create commit; commit_tree_extended signs it before writing it (without a signer, or
|
|
2131
|
+
// when the signer fails: git's failure, nothing written)
|
|
2132
|
+
const sign = signRequestOf(this.workingCopy, this.sign);
|
|
2133
|
+
const commit: Commit = await signCommit(
|
|
2134
|
+
this.workingCopy,
|
|
2135
|
+
sign,
|
|
2136
|
+
{ tree: treeId, parents, author, committer, message: finalMessage },
|
|
2137
|
+
sign === undefined ? {} : { cwd: await this.signingCwd() },
|
|
2138
|
+
);
|
|
1447
2139
|
const commitId = await this.commits.store(commit);
|
|
1448
2140
|
|
|
1449
2141
|
// Update HEAD/branch ref, with git's reflog line in the branch's log and HEAD's
|
|
@@ -1506,6 +2198,15 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1506
2198
|
return { ...commit, id: commitId };
|
|
1507
2199
|
}
|
|
1508
2200
|
|
|
2201
|
+
/** The host directory the signing program runs in, if the repository has one. */
|
|
2202
|
+
private async signingCwd(): Promise<string | undefined> {
|
|
2203
|
+
try {
|
|
2204
|
+
return await this.hooks.hostWorkingDirectory();
|
|
2205
|
+
} catch {
|
|
2206
|
+
return undefined;
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
|
|
1509
2210
|
/**
|
|
1510
2211
|
* The variables of the commit hooks (git's `run_commit_hook`): `GIT_INDEX_FILE` names the
|
|
1511
2212
|
* index the commit records (the lock `-a` and a partial commit write; git's false index of
|
|
@@ -1556,7 +2257,12 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1556
2257
|
mergeHeads: ObjectId[],
|
|
1557
2258
|
pickHead: ObjectId | undefined,
|
|
1558
2259
|
): string[] {
|
|
2260
|
+
// --squash tells "message" whatever the message's source (an empty second argument)
|
|
2261
|
+
if (this.squashFrom !== undefined) return ["message", ""];
|
|
1559
2262
|
if (this.message !== undefined) return ["message"];
|
|
2263
|
+
const reusedName = this.reusedName();
|
|
2264
|
+
if (reusedName !== undefined) return ["commit", reusedName];
|
|
2265
|
+
if (this.fixup) return ["message"];
|
|
1560
2266
|
// --amend without a message reuses HEAD's (git's use_message = "HEAD")
|
|
1561
2267
|
if (this.amend) return ["commit", "HEAD"];
|
|
1562
2268
|
if (mergeMsg !== undefined) return [squashMsg !== undefined ? "squash" : "merge"];
|
|
@@ -1877,7 +2583,9 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1877
2583
|
found.set(path, entry);
|
|
1878
2584
|
}
|
|
1879
2585
|
const trust = worktreeModeTrust(this.workingCopy, worktree);
|
|
1880
|
-
const adder = await IndexAdder.open(this.staging, this.blobs, trust
|
|
2586
|
+
const adder = await IndexAdder.open(this.staging, this.blobs, trust, {
|
|
2587
|
+
pathRules: worktreePathRules(this.workingCopy),
|
|
2588
|
+
});
|
|
1881
2589
|
for (const path of taken) {
|
|
1882
2590
|
const entry = found.get(path);
|
|
1883
2591
|
if (entry) await adder.add(worktree, path, entry);
|
|
@@ -1887,7 +2595,7 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1887
2595
|
}
|
|
1888
2596
|
// the real index, with a cache-tree made valid as git's cache_tree_update before
|
|
1889
2597
|
// write_locked_index (none while it holds conflicts: the edits' invalidations stay)
|
|
1890
|
-
await updateIndexCacheTree(this.staging, this.trees);
|
|
2598
|
+
await updateIndexCacheTree(this.staging, this.trees, this.objectFormat);
|
|
1891
2599
|
await index.write();
|
|
1892
2600
|
|
|
1893
2601
|
// the false index: HEAD's tree with the same paths as the index now has them
|
|
@@ -2142,3 +2850,14 @@ export interface CommitDryRunResult extends StatusTextResult {
|
|
|
2142
2850
|
/** 0 when there is something to commit, 1 when not (dry_run_commit) */
|
|
2143
2851
|
exitCode: number;
|
|
2144
2852
|
}
|
|
2853
|
+
|
|
2854
|
+
/**
|
|
2855
|
+
* fmt_ident's IDENT_STRICT checks of an author name given or kept (`--author`, `-C`,
|
|
2856
|
+
* `--amend`): an empty name, or one of crud only, refused with git's line.
|
|
2857
|
+
*/
|
|
2858
|
+
function strictAuthorName(name: string, email: string): void {
|
|
2859
|
+
if (name === "") throw new InvalidIdentError("author", "empty", email, false);
|
|
2860
|
+
if (![...name].some((c) => !(c <= " " || ",:;<>\"\\'".includes(c)))) {
|
|
2861
|
+
throw new InvalidIdentError("author", "crud", name, false);
|
|
2862
|
+
}
|
|
2863
|
+
}
|