@statewalker/vcs-commands 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +123 -8
- package/dist/commands/add-command.d.ts +265 -34
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/add-interactive.d.ts +46 -0
- package/dist/commands/add-patch/add-interactive.d.ts.map +1 -0
- package/dist/commands/add-patch/add-patch.d.ts +139 -0
- package/dist/commands/add-patch/add-patch.d.ts.map +1 -0
- package/dist/commands/add-patch/index.d.ts +6 -0
- package/dist/commands/add-patch/index.d.ts.map +1 -0
- package/dist/commands/add-patch/patch-backend.d.ts +80 -0
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -0
- package/dist/commands/add-patch/patch-modes.d.ts +71 -0
- package/dist/commands/add-patch/patch-modes.d.ts.map +1 -0
- package/dist/commands/add-patch/patch-session.d.ts +49 -0
- package/dist/commands/add-patch/patch-session.d.ts.map +1 -0
- package/dist/commands/am/am-command.d.ts +175 -0
- package/dist/commands/am/am-command.d.ts.map +1 -0
- package/dist/commands/am/index.d.ts +3 -0
- package/dist/commands/am/index.d.ts.map +1 -0
- package/dist/commands/am/mailinfo.d.ts +58 -0
- package/dist/commands/am/mailinfo.d.ts.map +1 -0
- package/dist/commands/am/patch-format.d.ts +24 -0
- package/dist/commands/am/patch-format.d.ts.map +1 -0
- package/dist/commands/apply/apply-command.d.ts +153 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -0
- package/dist/commands/apply/apply-engine.d.ts +195 -0
- package/dist/commands/apply/apply-engine.d.ts.map +1 -0
- package/dist/commands/apply/apply-parse.d.ts +86 -0
- package/dist/commands/apply/apply-parse.d.ts.map +1 -0
- package/dist/commands/apply/apply-types.d.ts +70 -0
- package/dist/commands/apply/apply-types.d.ts.map +1 -0
- package/dist/commands/apply/index.d.ts +6 -0
- package/dist/commands/apply/index.d.ts.map +1 -0
- package/dist/commands/apply/latin1.d.ts +32 -0
- package/dist/commands/apply/latin1.d.ts.map +1 -0
- package/dist/commands/apply/whitespace.d.ts +58 -0
- package/dist/commands/apply/whitespace.d.ts.map +1 -0
- package/dist/commands/attributes-source.d.ts +26 -0
- package/dist/commands/attributes-source.d.ts.map +1 -0
- package/dist/commands/backfill-command.d.ts +110 -0
- package/dist/commands/backfill-command.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-checkout.d.ts +64 -0
- package/dist/commands/bisect/bisect-checkout.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-command.d.ts +201 -0
- package/dist/commands/bisect/bisect-command.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-engine.d.ts +219 -0
- package/dist/commands/bisect/bisect-engine.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-graph.d.ts +127 -0
- package/dist/commands/bisect/bisect-graph.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-quote.d.ts +27 -0
- package/dist/commands/bisect/bisect-quote.d.ts.map +1 -0
- package/dist/commands/bisect/index.d.ts +5 -0
- package/dist/commands/bisect/index.d.ts.map +1 -0
- package/dist/commands/blame-command.d.ts +122 -131
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/branch-command.d.ts +52 -2
- package/dist/commands/branch-command.d.ts.map +1 -1
- package/dist/commands/branch-tracking.d.ts +98 -0
- package/dist/commands/branch-tracking.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +299 -34
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-paths.d.ts +124 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +50 -42
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +67 -4
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +179 -7
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +311 -17
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/core-config.d.ts +93 -0
- package/dist/commands/core-config.d.ts.map +1 -0
- package/dist/commands/date-format.d.ts +58 -0
- package/dist/commands/date-format.d.ts.map +1 -0
- package/dist/commands/describe-command.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +377 -30
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/diff-textconv.d.ts +40 -0
- package/dist/commands/diff-textconv.d.ts.map +1 -0
- package/dist/commands/fetch-command.d.ts +244 -23
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/format-patch-command.d.ts +164 -0
- package/dist/commands/format-patch-command.d.ts.map +1 -0
- package/dist/commands/fsck/fetch-fsck.d.ts +60 -0
- package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-command.d.ts +225 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-loose.d.ts +68 -0
- package/dist/commands/fsck/fsck-loose.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-msg-ids.d.ts +122 -0
- package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-object-checks.d.ts +148 -0
- package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-object-table.d.ts +132 -0
- package/dist/commands/fsck/fsck-object-table.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-pack.d.ts +115 -0
- package/dist/commands/fsck/fsck-pack.d.ts.map +1 -0
- package/dist/commands/fsck/index.d.ts +6 -0
- package/dist/commands/fsck/index.d.ts.map +1 -0
- package/dist/commands/fsck/verify-pack-command.d.ts +81 -0
- package/dist/commands/fsck/verify-pack-command.d.ts.map +1 -0
- package/dist/commands/gc-command.d.ts +43 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-date.d.ts +66 -0
- package/dist/commands/git-date.d.ts.map +1 -0
- package/dist/commands/git-describe.d.ts +67 -0
- package/dist/commands/git-describe.d.ts.map +1 -0
- package/dist/commands/git-hooks.d.ts +416 -0
- package/dist/commands/git-hooks.d.ts.map +1 -0
- package/dist/commands/git-ident.d.ts +128 -0
- package/dist/commands/git-ident.d.ts.map +1 -0
- package/dist/commands/hook-command.d.ts +96 -0
- package/dist/commands/hook-command.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +231 -0
- package/dist/commands/index-adder.d.ts.map +1 -0
- package/dist/commands/index-host.d.ts +86 -0
- package/dist/commands/index-host.d.ts.map +1 -0
- package/dist/commands/index.d.ts +55 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -2
- package/dist/commands/init-command.d.ts +12 -1
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/local-clone.d.ts +60 -0
- package/dist/commands/local-clone.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts +117 -0
- package/dist/commands/local-transport.d.ts.map +1 -0
- package/dist/commands/log-command.d.ts +216 -24
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +120 -0
- package/dist/commands/log-graph.d.ts.map +1 -0
- package/dist/commands/log-output.d.ts +323 -0
- package/dist/commands/log-output.d.ts.map +1 -0
- package/dist/commands/ls-remote-command.d.ts +23 -7
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/mailmap.d.ts +31 -0
- package/dist/commands/mailmap.d.ts.map +1 -0
- package/dist/commands/merge-bases.d.ts +85 -0
- package/dist/commands/merge-bases.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +209 -74
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-config.d.ts +13 -0
- package/dist/commands/merge-config.d.ts.map +1 -0
- package/dist/commands/merge-drivers.d.ts +130 -0
- package/dist/commands/merge-drivers.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +252 -0
- package/dist/commands/merge-support.d.ts.map +1 -0
- package/dist/commands/message-cleanup.d.ts +86 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -0
- package/dist/commands/mv-command.d.ts +94 -0
- package/dist/commands/mv-command.d.ts.map +1 -0
- package/dist/commands/notes-command.d.ts +256 -0
- package/dist/commands/notes-command.d.ts.map +1 -0
- package/dist/commands/notes-commands.d.ts +41 -0
- package/dist/commands/notes-commands.d.ts.map +1 -0
- package/dist/commands/notes-merge-command.d.ts +105 -0
- package/dist/commands/notes-merge-command.d.ts.map +1 -0
- package/dist/commands/notes-support.d.ts +125 -0
- package/dist/commands/notes-support.d.ts.map +1 -0
- package/dist/commands/notes-tree.d.ts +106 -0
- package/dist/commands/notes-tree.d.ts.map +1 -0
- package/dist/commands/object-id-input.d.ts +20 -0
- package/dist/commands/object-id-input.d.ts.map +1 -0
- package/dist/commands/octopus-merge.d.ts +59 -0
- package/dist/commands/octopus-merge.d.ts.map +1 -0
- package/dist/commands/ort-merge.d.ts +126 -0
- package/dist/commands/ort-merge.d.ts.map +1 -0
- package/dist/commands/ort-recursive.d.ts +53 -0
- package/dist/commands/ort-recursive.d.ts.map +1 -0
- package/dist/commands/pack-refs-command.d.ts +20 -0
- package/dist/commands/pack-refs-command.d.ts.map +1 -1
- package/dist/commands/patch-id.d.ts +41 -0
- package/dist/commands/patch-id.d.ts.map +1 -0
- package/dist/commands/pathspec-attributes.d.ts +64 -0
- package/dist/commands/pathspec-attributes.d.ts.map +1 -0
- package/dist/commands/pathspec.d.ts +324 -0
- package/dist/commands/pathspec.d.ts.map +1 -0
- package/dist/commands/post-index-change.d.ts +33 -0
- package/dist/commands/post-index-change.d.ts.map +1 -0
- package/dist/commands/pretty-format.d.ts +222 -0
- package/dist/commands/pretty-format.d.ts.map +1 -0
- package/dist/commands/promisor-remote.d.ts +80 -0
- package/dist/commands/promisor-remote.d.ts.map +1 -0
- package/dist/commands/pull-command.d.ts +41 -8
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +24 -8
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/read-tree-command.d.ts +112 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -0
- package/dist/commands/rebase-command.d.ts +507 -75
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/rebase-todo.d.ts +130 -0
- package/dist/commands/rebase-todo.d.ts.map +1 -0
- package/dist/commands/ref-decoration-filter.d.ts +53 -0
- package/dist/commands/ref-decoration-filter.d.ts.map +1 -0
- package/dist/commands/reflog-messages.d.ts +98 -0
- package/dist/commands/reflog-messages.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +146 -6
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-transport.d.ts +120 -0
- package/dist/commands/remote-transport.d.ts.map +1 -0
- package/dist/commands/reset-command.d.ts +161 -7
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +103 -0
- package/dist/commands/restore-command.d.ts.map +1 -0
- package/dist/commands/rev-list-command.d.ts +78 -0
- package/dist/commands/rev-list-command.d.ts.map +1 -0
- package/dist/commands/rev-parse-command.d.ts +80 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -0
- package/dist/commands/revert-command.d.ts +46 -38
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-filenames.d.ts +95 -0
- package/dist/commands/revision-filenames.d.ts.map +1 -0
- package/dist/commands/revision-range.d.ts +67 -0
- package/dist/commands/revision-range.d.ts.map +1 -0
- package/dist/commands/revision-resolver.d.ts +321 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -0
- package/dist/commands/rm-command.d.ts +69 -7
- package/dist/commands/rm-command.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +191 -0
- package/dist/commands/sequencer-pick.d.ts.map +1 -0
- package/dist/commands/sequencer-support.d.ts +125 -0
- package/dist/commands/sequencer-support.d.ts.map +1 -0
- package/dist/commands/serve-repository.d.ts +52 -0
- package/dist/commands/serve-repository.d.ts.map +1 -0
- package/dist/commands/sparse-checkout-command.d.ts +190 -0
- package/dist/commands/sparse-checkout-command.d.ts.map +1 -0
- package/dist/commands/sparse-checkout-support.d.ts +268 -0
- package/dist/commands/sparse-checkout-support.d.ts.map +1 -0
- package/dist/commands/stash-apply-command.d.ts +69 -13
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-create-command.d.ts +214 -26
- package/dist/commands/stash-create-command.d.ts.map +1 -1
- package/dist/commands/stash-drop-command.d.ts +10 -2
- package/dist/commands/stash-drop-command.d.ts.map +1 -1
- package/dist/commands/stash-list-command.d.ts +2 -4
- package/dist/commands/stash-list-command.d.ts.map +1 -1
- package/dist/commands/stash-working-tree.d.ts +95 -0
- package/dist/commands/stash-working-tree.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +320 -28
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/status-format.d.ts +155 -0
- package/dist/commands/status-format.d.ts.map +1 -0
- package/dist/commands/status-header.d.ts +64 -0
- package/dist/commands/status-header.d.ts.map +1 -0
- package/dist/commands/strerror.d.ts +7 -0
- package/dist/commands/strerror.d.ts.map +1 -0
- package/dist/commands/submodule-config.d.ts +38 -0
- package/dist/commands/submodule-config.d.ts.map +1 -0
- package/dist/commands/submodule-summary-command.d.ts +80 -0
- package/dist/commands/submodule-summary-command.d.ts.map +1 -0
- package/dist/commands/submodule-summary.d.ts +150 -0
- package/dist/commands/submodule-summary.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts +132 -0
- package/dist/commands/switch-command.d.ts.map +1 -0
- package/dist/commands/tag-command.d.ts +23 -2
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/tracking-info.d.ts +64 -0
- package/dist/commands/tracking-info.d.ts.map +1 -0
- package/dist/commands/trailers.d.ts +73 -0
- package/dist/commands/trailers.d.ts.map +1 -0
- package/dist/commands/tree-restore.d.ts +137 -6
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/untracked-cache-support.d.ts +53 -0
- package/dist/commands/untracked-cache-support.d.ts.map +1 -0
- package/dist/commands/worktree-add-command.d.ts +108 -0
- package/dist/commands/worktree-add-command.d.ts.map +1 -0
- package/dist/commands/worktree-list-command.d.ts +69 -0
- package/dist/commands/worktree-list-command.d.ts.map +1 -0
- package/dist/commands/worktree-lock-command.d.ts +44 -0
- package/dist/commands/worktree-lock-command.d.ts.map +1 -0
- package/dist/commands/worktree-overwrite-checks.d.ts +204 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -0
- package/dist/commands/worktree-prune-command.d.ts +48 -0
- package/dist/commands/worktree-prune-command.d.ts.map +1 -0
- package/dist/commands/worktree-remove-command.d.ts +59 -0
- package/dist/commands/worktree-remove-command.d.ts.map +1 -0
- package/dist/commands/worktree-repair-command.d.ts +35 -0
- package/dist/commands/worktree-repair-command.d.ts.map +1 -0
- package/dist/commands/worktree-support.d.ts +64 -0
- package/dist/commands/worktree-support.d.ts.map +1 -0
- package/dist/commands-DnmlfwGV.js +61620 -0
- package/dist/core-commands/add.command.impl.d.ts.map +1 -1
- package/dist/core-commands/index.d.ts +0 -3
- package/dist/core-commands/index.d.ts.map +1 -1
- package/dist/errors/add-errors.d.ts +55 -0
- package/dist/errors/add-errors.d.ts.map +1 -1
- package/dist/errors/checkout-errors.d.ts +29 -0
- package/dist/errors/checkout-errors.d.ts.map +1 -1
- package/dist/errors/command-errors.d.ts +77 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/commit-errors.d.ts +9 -0
- package/dist/errors/commit-errors.d.ts.map +1 -1
- package/dist/errors/git-api-error.d.ts +59 -2
- package/dist/errors/git-api-error.d.ts.map +1 -1
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +371 -19
- package/dist/errors/rebase-errors.d.ts +9 -0
- package/dist/errors/rebase-errors.d.ts.map +1 -1
- package/dist/errors/ref-errors.d.ts +32 -0
- package/dist/errors/ref-errors.d.ts.map +1 -1
- package/dist/errors/transport-errors.d.ts +12 -2
- package/dist/errors/transport-errors.d.ts.map +1 -1
- package/dist/errors/worktree-errors.d.ts +35 -0
- package/dist/errors/worktree-errors.d.ts.map +1 -0
- package/dist/git-command-DxvwPrPB.js +7612 -0
- package/dist/git-command.d.ts +422 -32
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +326 -5
- package/dist/git.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/remote-config/index.d.ts +1 -0
- package/dist/remote-config/index.d.ts.map +1 -1
- package/dist/remote-config/remote-config-store.d.ts +123 -3
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/remote-config/remote-refs.d.ts +41 -0
- package/dist/remote-config/remote-refs.d.ts.map +1 -0
- package/dist/rename/detect-renames.d.ts +148 -0
- package/dist/rename/detect-renames.d.ts.map +1 -0
- package/dist/rename/git-similarity.d.ts +44 -0
- package/dist/rename/git-similarity.d.ts.map +1 -0
- package/dist/rename/index.d.ts +2 -0
- package/dist/rename/index.d.ts.map +1 -1
- package/dist/results/binary-patch.d.ts +11 -0
- package/dist/results/binary-patch.d.ts.map +1 -0
- package/dist/results/blame-format.d.ts +55 -0
- package/dist/results/blame-format.d.ts.map +1 -0
- package/dist/results/cherry-pick-result.d.ts +10 -0
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +16 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/combined-diff.d.ts +77 -0
- package/dist/results/combined-diff.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +32 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts +34 -60
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-order.d.ts +25 -0
- package/dist/results/diff-order.d.ts.map +1 -0
- package/dist/results/diff-output.d.ts +249 -0
- package/dist/results/diff-output.d.ts.map +1 -0
- package/dist/results/fetch-result.d.ts +24 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +5 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -252
- package/dist/results/merge-result.d.ts +15 -1
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +12 -3
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +42 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/quote-path.d.ts +27 -0
- package/dist/results/quote-path.d.ts.map +1 -0
- package/dist/results/rebase-result.d.ts +28 -1
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +10 -0
- package/dist/results/revert-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +5 -0
- package/dist/results/stash-result.d.ts.map +1 -1
- package/dist/results/status-result.d.ts +143 -18
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-BZGa2Z3I.js +2934 -0
- package/dist/transport-command.d.ts +56 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +15 -10
- package/src/commands/add-command.ts +1291 -224
- package/src/commands/add-patch/add-interactive.ts +941 -0
- package/src/commands/add-patch/add-patch.ts +1169 -0
- package/src/commands/add-patch/index.ts +5 -0
- package/src/commands/add-patch/patch-backend.ts +239 -0
- package/src/commands/add-patch/patch-modes.ts +249 -0
- package/src/commands/add-patch/patch-session.ts +159 -0
- package/src/commands/am/am-command.ts +1111 -0
- package/src/commands/am/index.ts +2 -0
- package/src/commands/am/mailinfo.ts +1015 -0
- package/src/commands/am/patch-format.ts +121 -0
- package/src/commands/apply/apply-command.ts +832 -0
- package/src/commands/apply/apply-engine.ts +1603 -0
- package/src/commands/apply/apply-parse.ts +1209 -0
- package/src/commands/apply/apply-types.ts +112 -0
- package/src/commands/apply/index.ts +5 -0
- package/src/commands/apply/latin1.ts +171 -0
- package/src/commands/apply/whitespace.ts +260 -0
- package/src/commands/attributes-source.ts +96 -0
- package/src/commands/backfill-command.ts +694 -0
- package/src/commands/bisect/bisect-checkout.ts +217 -0
- package/src/commands/bisect/bisect-command.ts +788 -0
- package/src/commands/bisect/bisect-engine.ts +1079 -0
- package/src/commands/bisect/bisect-graph.ts +595 -0
- package/src/commands/bisect/bisect-quote.ts +92 -0
- package/src/commands/bisect/index.ts +4 -0
- package/src/commands/blame-command.ts +711 -986
- package/src/commands/branch-command.ts +354 -32
- package/src/commands/branch-tracking.ts +331 -0
- package/src/commands/checkout-command.ts +1426 -297
- package/src/commands/checkout-paths.ts +784 -0
- package/src/commands/cherry-pick-command.ts +156 -396
- package/src/commands/clean-command.ts +532 -85
- package/src/commands/clone-command.ts +826 -55
- package/src/commands/commit-command.ts +1781 -166
- package/src/commands/core-config.ts +196 -0
- package/src/commands/date-format.ts +668 -0
- package/src/commands/describe-command.ts +2 -0
- package/src/commands/diff-command.ts +1898 -110
- package/src/commands/diff-textconv.ts +50 -0
- package/src/commands/fetch-command.ts +1038 -79
- package/src/commands/format-patch-command.ts +969 -0
- package/src/commands/fsck/fetch-fsck.ts +229 -0
- package/src/commands/fsck/fsck-command.ts +3347 -0
- package/src/commands/fsck/fsck-loose.ts +287 -0
- package/src/commands/fsck/fsck-msg-ids.ts +176 -0
- package/src/commands/fsck/fsck-object-checks.ts +1044 -0
- package/src/commands/fsck/fsck-object-table.ts +363 -0
- package/src/commands/fsck/fsck-pack.ts +604 -0
- package/src/commands/fsck/index.ts +5 -0
- package/src/commands/fsck/verify-pack-command.ts +249 -0
- package/src/commands/gc-command.ts +147 -1
- package/src/commands/git-date.ts +895 -0
- package/src/commands/git-describe.ts +316 -0
- package/src/commands/git-hooks.ts +1472 -0
- package/src/commands/git-ident.ts +344 -0
- package/src/commands/hook-command.ts +247 -0
- package/src/commands/index-adder.ts +706 -0
- package/src/commands/index-host.ts +291 -0
- package/src/commands/index.ts +83 -0
- package/src/commands/init-command.ts +60 -11
- package/src/commands/local-clone.ts +183 -0
- package/src/commands/local-transport.ts +762 -0
- package/src/commands/log-command.ts +1915 -170
- package/src/commands/log-graph.ts +671 -0
- package/src/commands/log-output.ts +1359 -0
- package/src/commands/ls-remote-command.ts +101 -58
- package/src/commands/mailmap.ts +129 -0
- package/src/commands/merge-bases.ts +296 -0
- package/src/commands/merge-command.ts +1386 -491
- package/src/commands/merge-config.ts +25 -0
- package/src/commands/merge-drivers.ts +306 -0
- package/src/commands/merge-support.ts +1198 -0
- package/src/commands/message-cleanup.ts +275 -0
- package/src/commands/mv-command.ts +976 -0
- package/src/commands/notes-command.ts +890 -0
- package/src/commands/notes-commands.ts +87 -0
- package/src/commands/notes-merge-command.ts +768 -0
- package/src/commands/notes-support.ts +402 -0
- package/src/commands/notes-tree.ts +602 -0
- package/src/commands/object-id-input.ts +27 -0
- package/src/commands/octopus-merge.ts +377 -0
- package/src/commands/ort-merge.ts +1660 -0
- package/src/commands/ort-recursive.ts +160 -0
- package/src/commands/pack-refs-command.ts +39 -22
- package/src/commands/patch-id.ts +196 -0
- package/src/commands/pathspec-attributes.ts +162 -0
- package/src/commands/pathspec.ts +1199 -0
- package/src/commands/post-index-change.ts +62 -0
- package/src/commands/pretty-format.ts +1431 -0
- package/src/commands/promisor-remote.ts +298 -0
- package/src/commands/pull-command.ts +207 -22
- package/src/commands/push-command.ts +236 -23
- package/src/commands/read-tree-command.ts +857 -0
- package/src/commands/rebase-command.ts +3808 -371
- package/src/commands/rebase-todo.ts +584 -0
- package/src/commands/ref-decoration-filter.ts +118 -0
- package/src/commands/reflog-messages.ts +177 -0
- package/src/commands/remote-command.ts +500 -19
- package/src/commands/remote-transport.ts +383 -0
- package/src/commands/reset-command.ts +828 -91
- package/src/commands/restore-command.ts +350 -0
- package/src/commands/rev-list-command.ts +167 -0
- package/src/commands/rev-parse-command.ts +277 -0
- package/src/commands/revert-command.ts +152 -399
- package/src/commands/revision-filenames.ts +254 -0
- package/src/commands/revision-range.ts +222 -0
- package/src/commands/revision-resolver.ts +1379 -0
- package/src/commands/rm-command.ts +613 -67
- package/src/commands/sequencer-pick.ts +869 -0
- package/src/commands/sequencer-support.ts +869 -0
- package/src/commands/serve-repository.ts +125 -0
- package/src/commands/sparse-checkout-command.ts +1389 -0
- package/src/commands/sparse-checkout-support.ts +793 -0
- package/src/commands/stash-apply-command.ts +692 -124
- package/src/commands/stash-create-command.ts +752 -89
- package/src/commands/stash-drop-command.ts +67 -6
- package/src/commands/stash-list-command.ts +10 -4
- package/src/commands/stash-working-tree.ts +387 -0
- package/src/commands/status-command.ts +1426 -97
- package/src/commands/status-format.ts +775 -0
- package/src/commands/status-header.ts +330 -0
- package/src/commands/strerror.ts +29 -0
- package/src/commands/submodule-config.ts +94 -0
- package/src/commands/submodule-summary-command.ts +334 -0
- package/src/commands/submodule-summary.ts +446 -0
- package/src/commands/switch-command.ts +402 -0
- package/src/commands/tag-command.ts +129 -41
- package/src/commands/tracking-info.ts +201 -0
- package/src/commands/trailers.ts +417 -0
- package/src/commands/tree-restore.ts +344 -15
- package/src/commands/untracked-cache-support.ts +194 -0
- package/src/commands/worktree-add-command.ts +458 -0
- package/src/commands/worktree-list-command.ts +208 -0
- package/src/commands/worktree-lock-command.ts +96 -0
- package/src/commands/worktree-overwrite-checks.ts +641 -0
- package/src/commands/worktree-prune-command.ts +99 -0
- package/src/commands/worktree-remove-command.ts +186 -0
- package/src/commands/worktree-repair-command.ts +59 -0
- package/src/commands/worktree-support.ts +214 -0
- package/src/core-commands/add.command.impl.ts +9 -5
- package/src/core-commands/index.ts +0 -8
- package/src/errors/add-errors.ts +45 -0
- package/src/errors/checkout-errors.ts +46 -2
- package/src/errors/command-errors.ts +101 -1
- package/src/errors/commit-errors.ts +18 -2
- package/src/errors/git-api-error.ts +82 -2
- package/src/errors/index.ts +1 -0
- package/src/errors/merge-errors.ts +2 -2
- package/src/errors/rebase-errors.ts +12 -0
- package/src/errors/ref-errors.ts +56 -2
- package/src/errors/remote-errors.ts +2 -2
- package/src/errors/stash-errors.ts +1 -1
- package/src/errors/transport-errors.ts +20 -4
- package/src/errors/worktree-errors.ts +49 -0
- package/src/git-command.ts +1218 -118
- package/src/git.ts +552 -11
- package/src/index.ts +1 -1
- package/src/remote-config/index.ts +1 -0
- package/src/remote-config/remote-config-store.ts +326 -16
- package/src/remote-config/remote-refs.ts +119 -0
- package/src/rename/detect-renames.ts +711 -0
- package/src/rename/git-similarity.ts +116 -0
- package/src/rename/index.ts +2 -0
- package/src/results/binary-patch.ts +401 -0
- package/src/results/blame-format.ts +239 -0
- package/src/results/cherry-pick-result.ts +10 -0
- package/src/results/clone-result.ts +18 -0
- package/src/results/combined-diff.ts +585 -0
- package/src/results/diff-entry.ts +35 -0
- package/src/results/diff-formatter.ts +152 -288
- package/src/results/diff-order.ts +64 -0
- package/src/results/diff-output.ts +1051 -0
- package/src/results/fetch-result.ts +24 -1
- package/src/results/index.ts +5 -0
- package/src/results/merge-result.ts +15 -1
- package/src/results/pull-result.ts +12 -3
- package/src/results/push-result.ts +43 -0
- package/src/results/quote-path.ts +103 -0
- package/src/results/rebase-result.ts +37 -0
- package/src/results/revert-result.ts +10 -0
- package/src/results/stash-result.ts +6 -0
- package/src/results/status-result.ts +288 -27
- package/src/transport-command.ts +139 -2
- package/dist/commands-BpeXZTC3.js +0 -10278
- package/dist/core-commands/checkout.command.d.ts +0 -103
- package/dist/core-commands/checkout.command.d.ts.map +0 -1
- package/dist/core-commands/checkout.command.impl.d.ts +0 -110
- package/dist/core-commands/checkout.command.impl.d.ts.map +0 -1
- package/dist/status-result-BapZoQaR.js +0 -411
- package/src/core-commands/checkout.command.impl.ts +0 -564
- package/src/core-commands/checkout.command.ts +0 -125
|
@@ -0,0 +1,969 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `git format-patch`: each commit of a range as an email (`From <id> Mon Sep 17 00:00:00
|
|
3
|
+
* 2001`, `From:`, `Date:`, `Subject: [PATCH n/m] ...`, the message, `---`, the diffstat,
|
|
4
|
+
* the summary, the patch with binary hunks, the `-- ` signature), as git writes them byte
|
|
5
|
+
* for byte: numbered subjects, cover letters with the shortlog and diffstat, threading
|
|
6
|
+
* headers, `--base` prerequisite patch ids, signoffs and the `format.*` settings.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { ObjectId, PersonIdent } from "@statewalker/vcs-core";
|
|
10
|
+
import { decodeGitPath, encodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
11
|
+
import { GitCommand } from "../git-command.js";
|
|
12
|
+
import { ChangeType } from "../results/diff-entry.js";
|
|
13
|
+
import { showDate } from "./date-format.js";
|
|
14
|
+
import { DiffCommand } from "./diff-command.js";
|
|
15
|
+
import { LogCommand } from "./log-command.js";
|
|
16
|
+
import { mailFromHeader } from "./log-output.js";
|
|
17
|
+
import { configValue } from "./merge-config.js";
|
|
18
|
+
import { type PatchIdChange, patchIdOfChanges } from "./patch-id.js";
|
|
19
|
+
import { sanitizedSubject, wrapText } from "./pretty-format.js";
|
|
20
|
+
|
|
21
|
+
/** One file `git format-patch` writes (or one mail of `--stdout`). */
|
|
22
|
+
export interface FormatPatchFile {
|
|
23
|
+
/** The file name (with the output directory), as git prints it */
|
|
24
|
+
name: string;
|
|
25
|
+
/** The mail */
|
|
26
|
+
content: Uint8Array;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** What `git format-patch` produced. */
|
|
30
|
+
export interface FormatPatchResult {
|
|
31
|
+
/** The mails, in order (the cover letter first) */
|
|
32
|
+
patches: FormatPatchFile[];
|
|
33
|
+
/** Standard output: the file names, or the mails with `--stdout` */
|
|
34
|
+
output: Uint8Array;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Thrown where git dies (`fatal: ...`). */
|
|
38
|
+
export class FormatPatchError extends Error {}
|
|
39
|
+
|
|
40
|
+
/** Whether a version string (`2.56.0`, `2.43.0.windows.1`) is at least `major.minor`. */
|
|
41
|
+
function gitVersionAtLeast(version: string, major: number, minor: number): boolean {
|
|
42
|
+
const m = /^(\d+)\.(\d+)/.exec(version);
|
|
43
|
+
if (!m) return true;
|
|
44
|
+
const a = Number(m[1]);
|
|
45
|
+
const b = Number(m[2]);
|
|
46
|
+
return a > major || (a === major && b >= minor);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const MAIL_DEFAULT_WRAP = 72;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* `git format-patch`.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const { patches } = await git.formatPatch().addRevision("main..topic").setCoverLetter(true).call();
|
|
57
|
+
* const { output } = await git.formatPatch().setMaxCount(1).setStdout(true).call();
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export class FormatPatchCommand extends GitCommand<FormatPatchResult> {
|
|
61
|
+
private revisions: string[] = [];
|
|
62
|
+
private maxCount?: number;
|
|
63
|
+
private root = false;
|
|
64
|
+
private stdout = false;
|
|
65
|
+
private outputDirectory?: string;
|
|
66
|
+
private numbered?: boolean;
|
|
67
|
+
private numberedCmdline = false;
|
|
68
|
+
private startNumber?: number;
|
|
69
|
+
private subjectPrefix?: string;
|
|
70
|
+
private rfc?: string;
|
|
71
|
+
private rerollCount?: string;
|
|
72
|
+
private keepSubject = false;
|
|
73
|
+
private signoff = false;
|
|
74
|
+
private coverLetter?: boolean;
|
|
75
|
+
private numberedFiles = false;
|
|
76
|
+
private suffix?: string;
|
|
77
|
+
private noStat = false;
|
|
78
|
+
private noBinary = false;
|
|
79
|
+
private zeroCommit = false;
|
|
80
|
+
private to: string[] = [];
|
|
81
|
+
private cc: string[] = [];
|
|
82
|
+
private headers: string[] = [];
|
|
83
|
+
private noTo = false;
|
|
84
|
+
private noCc = false;
|
|
85
|
+
private from?: string | true;
|
|
86
|
+
private forceInBodyFrom = false;
|
|
87
|
+
private inReplyTo?: string;
|
|
88
|
+
private thread?: "shallow" | "deep" | false;
|
|
89
|
+
private signature?: string | false;
|
|
90
|
+
private base?: string;
|
|
91
|
+
private quiet = false;
|
|
92
|
+
private filenameMaxLength?: number;
|
|
93
|
+
private versionString = "2.56.0";
|
|
94
|
+
private messageIdTime?: () => number;
|
|
95
|
+
private writeFiles = true;
|
|
96
|
+
|
|
97
|
+
/** A revision argument: `<since>` (to HEAD), `<a>..<b>`, `^<a>`, `<b>`. */
|
|
98
|
+
addRevision(revision: string): this {
|
|
99
|
+
this.revisions.push(revision);
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** `-<n>`: the last n commits. */
|
|
104
|
+
setMaxCount(n: number): this {
|
|
105
|
+
this.maxCount = n;
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** `--root`: from the root commit, a single revision taken as the tip. */
|
|
110
|
+
setRoot(root: boolean): this {
|
|
111
|
+
this.root = root;
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** `--stdout`: the mails to standard output (no files). */
|
|
116
|
+
setStdout(value: boolean): this {
|
|
117
|
+
this.stdout = value;
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** `-o <dir>`: where the files go (relative to the worktree's top). */
|
|
122
|
+
setOutputDirectory(dir: string): this {
|
|
123
|
+
this.outputDirectory = dir;
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Whether to write the files into the worktree (default true); false only returns them. */
|
|
128
|
+
setWriteFiles(value: boolean): this {
|
|
129
|
+
this.writeFiles = value;
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** `-n` (true) / `-N` (false). */
|
|
134
|
+
setNumbered(value: boolean): this {
|
|
135
|
+
this.numbered = value;
|
|
136
|
+
this.numberedCmdline = true;
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** `--start-number=<n>`. */
|
|
141
|
+
setStartNumber(n: number): this {
|
|
142
|
+
this.startNumber = n;
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** `--subject-prefix=<prefix>` (default `format.subjectPrefix`, else `PATCH`). */
|
|
147
|
+
setSubjectPrefix(prefix: string): this {
|
|
148
|
+
this.subjectPrefix = prefix;
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** `--rfc[=<rfc>]`. */
|
|
153
|
+
setRfc(rfc: string | true): this {
|
|
154
|
+
this.rfc = rfc === true ? "RFC" : rfc;
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** `-v <n>` / `--reroll-count=<n>`. */
|
|
159
|
+
setRerollCount(n: string | number): this {
|
|
160
|
+
this.rerollCount = String(n);
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** `-k`: keep the subject as it is. */
|
|
165
|
+
setKeepSubject(value: boolean): this {
|
|
166
|
+
this.keepSubject = value;
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** `-s` / `--signoff`. */
|
|
171
|
+
setSignoff(value: boolean): this {
|
|
172
|
+
this.signoff = value;
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** `--cover-letter` / `--no-cover-letter` (default `format.coverLetter`). */
|
|
177
|
+
setCoverLetter(value: boolean): this {
|
|
178
|
+
this.coverLetter = value;
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** `--numbered-files`. */
|
|
183
|
+
setNumberedFiles(value: boolean): this {
|
|
184
|
+
this.numberedFiles = value;
|
|
185
|
+
return this;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** `--suffix=<sfx>` (default `format.suffix`, else `.patch`). */
|
|
189
|
+
setSuffix(suffix: string): this {
|
|
190
|
+
this.suffix = suffix;
|
|
191
|
+
return this;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** `-p` / `--no-stat`. */
|
|
195
|
+
setNoStat(value: boolean): this {
|
|
196
|
+
this.noStat = value;
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** `--no-binary`. */
|
|
201
|
+
setNoBinary(value: boolean): this {
|
|
202
|
+
this.noBinary = value;
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** `--zero-commit`. */
|
|
207
|
+
setZeroCommit(value: boolean): this {
|
|
208
|
+
this.zeroCommit = value;
|
|
209
|
+
return this;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** `--to=<email>` (repeatable). */
|
|
213
|
+
addTo(address: string): this {
|
|
214
|
+
this.to.push(address);
|
|
215
|
+
return this;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** `--cc=<email>` (repeatable). */
|
|
219
|
+
addCc(address: string): this {
|
|
220
|
+
this.cc.push(address);
|
|
221
|
+
return this;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** `--no-to` / `--no-cc`: drop the configured ones. */
|
|
225
|
+
setNoTo(value: boolean): this {
|
|
226
|
+
this.noTo = value;
|
|
227
|
+
return this;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
setNoCc(value: boolean): this {
|
|
231
|
+
this.noCc = value;
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** `--add-header=<header>` (repeatable). */
|
|
236
|
+
addHeader(header: string): this {
|
|
237
|
+
this.headers.push(header);
|
|
238
|
+
return this;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** `--from[=<ident>]`: true for the committer. */
|
|
242
|
+
setFrom(from: string | true): this {
|
|
243
|
+
this.from = from;
|
|
244
|
+
return this;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** `--force-in-body-from`. */
|
|
248
|
+
setForceInBodyFrom(value: boolean): this {
|
|
249
|
+
this.forceInBodyFrom = value;
|
|
250
|
+
return this;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** `--in-reply-to=<message-id>`. */
|
|
254
|
+
setInReplyTo(id: string): this {
|
|
255
|
+
this.inReplyTo = id;
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** `--thread[=shallow|deep]` / `--no-thread`. */
|
|
260
|
+
setThread(style: "shallow" | "deep" | boolean): this {
|
|
261
|
+
this.thread = style === true ? "shallow" : style;
|
|
262
|
+
return this;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** `--signature=<text>` / `--no-signature` (false). */
|
|
266
|
+
setSignature(signature: string | false): this {
|
|
267
|
+
this.signature = signature;
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** `--base=<commit>` (or `auto`). */
|
|
272
|
+
setBase(base: string): this {
|
|
273
|
+
this.base = base;
|
|
274
|
+
return this;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** `-q`: no file names printed. */
|
|
278
|
+
setQuiet(value: boolean): this {
|
|
279
|
+
this.quiet = value;
|
|
280
|
+
return this;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** `--filename-max-length=<n>` (default `format.filenameMaxLength`, else 64). */
|
|
284
|
+
setFilenameMaxLength(n: number): this {
|
|
285
|
+
this.filenameMaxLength = n;
|
|
286
|
+
return this;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* The default signature: git's version string (`git_version_string`). Defaults to
|
|
291
|
+
* "2.56.0", the git this port follows; set it to match another git. It also picks the
|
|
292
|
+
* cover letter's `From:` with `--from`: the given ident dated at the epoch from 2.54 on,
|
|
293
|
+
* the committer (and the commit date) before.
|
|
294
|
+
*/
|
|
295
|
+
setVersionString(version: string): this {
|
|
296
|
+
this.versionString = version;
|
|
297
|
+
return this;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** The clock of the generated Message-IDs, in seconds (default: now). */
|
|
301
|
+
setMessageIdTime(now: () => number): this {
|
|
302
|
+
this.messageIdTime = now;
|
|
303
|
+
return this;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
private config(key: string): string | undefined {
|
|
307
|
+
return configValue(this.workingCopy, key);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
private configAll(key: string): string[] {
|
|
311
|
+
const store = (this.workingCopy as unknown as { config?: { getAll?(k: string): string[] } })
|
|
312
|
+
.config;
|
|
313
|
+
const all = store?.getAll?.(key);
|
|
314
|
+
if (all) return all;
|
|
315
|
+
const one = this.config(key);
|
|
316
|
+
return one === undefined ? [] : [one];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async call(): Promise<FormatPatchResult> {
|
|
320
|
+
this.checkCallable();
|
|
321
|
+
this.setCallable(false);
|
|
322
|
+
|
|
323
|
+
// git_format_config
|
|
324
|
+
const bool = (v: string | undefined) =>
|
|
325
|
+
v === undefined ? undefined : ["true", "yes", "on", "1", ""].includes(v.toLowerCase());
|
|
326
|
+
const cfgHeaders = this.configAll("format.headers");
|
|
327
|
+
const cfgTo = this.noTo ? [] : this.configAll("format.to");
|
|
328
|
+
const cfgCc = this.noCc ? [] : this.configAll("format.cc");
|
|
329
|
+
let autoNumber = true;
|
|
330
|
+
let numbered = false;
|
|
331
|
+
const fmtNumbered = this.config("format.numbered");
|
|
332
|
+
if (fmtNumbered !== undefined) {
|
|
333
|
+
if (fmtNumbered.toLowerCase() === "auto") autoNumber = true;
|
|
334
|
+
else {
|
|
335
|
+
numbered = bool(fmtNumbered) ?? false;
|
|
336
|
+
autoNumber = autoNumber && numbered;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (this.numbered !== undefined) {
|
|
340
|
+
numbered = this.numbered;
|
|
341
|
+
autoNumber = false;
|
|
342
|
+
if (!this.numbered) numbered = false;
|
|
343
|
+
}
|
|
344
|
+
const suffix = this.suffix ?? this.config("format.suffix") ?? ".patch";
|
|
345
|
+
let nameMax = this.filenameMaxLength ?? Number(this.config("format.filenameMaxLength") ?? 64);
|
|
346
|
+
if (nameMax <= 5 + suffix.length) nameMax = 5 + suffix.length;
|
|
347
|
+
let thread: "shallow" | "deep" | false = false;
|
|
348
|
+
const cfgThread = this.config("format.thread");
|
|
349
|
+
if (cfgThread !== undefined) {
|
|
350
|
+
const t = cfgThread.toLowerCase();
|
|
351
|
+
thread = t === "deep" ? "deep" : t === "shallow" ? "shallow" : bool(t) ? "shallow" : false;
|
|
352
|
+
}
|
|
353
|
+
if (this.thread !== undefined) thread = this.thread;
|
|
354
|
+
const cfgCover = this.config("format.coverLetter");
|
|
355
|
+
let configCover: "on" | "off" | "auto" = "off";
|
|
356
|
+
if (cfgCover !== undefined)
|
|
357
|
+
configCover = cfgCover.toLowerCase() === "auto" ? "auto" : bool(cfgCover) ? "on" : "off";
|
|
358
|
+
const encodeHeaders = bool(this.config("format.encodeEmailHeaders")) ?? true;
|
|
359
|
+
// get_log_output_encoding
|
|
360
|
+
const outputEncoding =
|
|
361
|
+
this.config("i18n.logOutputEncoding") || this.config("i18n.commitEncoding") || "UTF-8";
|
|
362
|
+
// format.noprefix (diff.noprefix is ignored)
|
|
363
|
+
const noPrefixCfg = this.config("format.noprefix");
|
|
364
|
+
let noPrefix = false;
|
|
365
|
+
if (noPrefixCfg !== undefined) {
|
|
366
|
+
const v = noPrefixCfg.toLowerCase();
|
|
367
|
+
if (["true", "yes", "on", "1", ""].includes(v)) noPrefix = true;
|
|
368
|
+
else if (["false", "no", "off", "0"].includes(v)) noPrefix = false;
|
|
369
|
+
else
|
|
370
|
+
throw new FormatPatchError(
|
|
371
|
+
`bad boolean config value '${noPrefixCfg}' for 'format.noprefix'`,
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
const outDir = this.stdout
|
|
375
|
+
? undefined
|
|
376
|
+
: (this.outputDirectory ?? this.config("format.outputDirectory"));
|
|
377
|
+
let signature: string | false = this.versionString;
|
|
378
|
+
if (this.signature !== undefined) signature = this.signature;
|
|
379
|
+
else {
|
|
380
|
+
const cfgSig = this.config("format.signature");
|
|
381
|
+
if (cfgSig !== undefined) signature = cfgSig;
|
|
382
|
+
}
|
|
383
|
+
let signoff = this.signoff || (bool(this.config("format.signOff")) ?? false);
|
|
384
|
+
if (this.signoff) signoff = true;
|
|
385
|
+
const fromCfg = this.config("format.from");
|
|
386
|
+
let fromSpec: string | true | undefined = this.from;
|
|
387
|
+
if (fromSpec === undefined && fromCfg !== undefined) {
|
|
388
|
+
// git_parse_maybe_bool: an ident where the value is not a boolean (a valueless
|
|
389
|
+
// `format.from`, read here as "", is true)
|
|
390
|
+
const b = maybeBool(fromCfg);
|
|
391
|
+
fromSpec = b === undefined ? fromCfg : b ? true : undefined;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
let sprefix = this.subjectPrefix ?? this.config("format.subjectPrefix") ?? "PATCH";
|
|
395
|
+
const subjectPrefixGiven = this.subjectPrefix !== undefined;
|
|
396
|
+
if (this.rfc) {
|
|
397
|
+
if (this.rfc.startsWith("-")) sprefix = `${sprefix} ${this.rfc.slice(1)}`;
|
|
398
|
+
else sprefix = `${this.rfc} ${sprefix}`;
|
|
399
|
+
}
|
|
400
|
+
if (this.rerollCount) sprefix = `${sprefix} v${this.rerollCount}`;
|
|
401
|
+
|
|
402
|
+
let extraHeaders = "";
|
|
403
|
+
for (const h of [...cfgHeaders, ...this.headers]) extraHeaders += `${h}\n`;
|
|
404
|
+
const toList = [...cfgTo, ...this.to];
|
|
405
|
+
const ccList = [...cfgCc, ...this.cc];
|
|
406
|
+
const addressHeader = (name: string, list: string[]) => {
|
|
407
|
+
if (!list.length) return;
|
|
408
|
+
extraHeaders += `${name}: `;
|
|
409
|
+
list.forEach((a, i) => {
|
|
410
|
+
if (i) extraHeaders += " ";
|
|
411
|
+
extraHeaders += a;
|
|
412
|
+
if (i + 1 < list.length) extraHeaders += ",";
|
|
413
|
+
extraHeaders += "\n";
|
|
414
|
+
});
|
|
415
|
+
};
|
|
416
|
+
addressHeader("To", toList);
|
|
417
|
+
addressHeader("Cc", ccList);
|
|
418
|
+
|
|
419
|
+
const committer = this.resolveCommitter();
|
|
420
|
+
let fromIdent: { name: string; email: string } | undefined;
|
|
421
|
+
if (fromSpec === true) fromIdent = { name: committer.name, email: committer.email };
|
|
422
|
+
else if (fromSpec !== undefined) {
|
|
423
|
+
const m = /^(.*?)\s*<([^>]*)>/.exec(fromSpec);
|
|
424
|
+
if (!m) throw new FormatPatchError(`invalid ident line: ${fromSpec}`);
|
|
425
|
+
fromIdent = { name: m[1] as string, email: m[2] as string };
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const startNumber = this.startNumber ?? 1;
|
|
429
|
+
if (numbered && this.keepSubject && !this.numberedCmdline) numbered = false;
|
|
430
|
+
if (numbered && this.keepSubject)
|
|
431
|
+
throw new FormatPatchError("options '-n' and '-k' cannot be used together");
|
|
432
|
+
if (this.keepSubject && (subjectPrefixGiven || this.rfc))
|
|
433
|
+
throw new FormatPatchError(
|
|
434
|
+
"options '--subject-prefix/--rfc' and '-k' cannot be used together",
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
// the commits: newest first, merges left out
|
|
438
|
+
const { list, origin } = await this.walk();
|
|
439
|
+
if (!list.length) return { patches: [], output: new Uint8Array(0) };
|
|
440
|
+
const total0 = list.length;
|
|
441
|
+
let cover = this.coverLetter;
|
|
442
|
+
if (cover === undefined) {
|
|
443
|
+
if (configCover === "auto") cover = total0 > 1;
|
|
444
|
+
else cover = configCover === "on";
|
|
445
|
+
}
|
|
446
|
+
if (!this.keepSubject && autoNumber && (total0 > 1 || cover)) numbered = true;
|
|
447
|
+
// rev.total: the last number shown (0: not numbered, -1: -k)
|
|
448
|
+
const total = numbered ? total0 + startNumber - 1 : this.keepSubject ? -1 : 0;
|
|
449
|
+
|
|
450
|
+
// --base
|
|
451
|
+
const bases = await this.prepareBases(list);
|
|
452
|
+
|
|
453
|
+
const time = () => (this.messageIdTime ? this.messageIdTime() : Math.floor(Date.now() / 1000));
|
|
454
|
+
const messageId = (base: string) => `${base}.${time()}.git.${committer.email}`;
|
|
455
|
+
const refIds: string[] = [];
|
|
456
|
+
let ownId: string | undefined;
|
|
457
|
+
if (this.inReplyTo) refIds.push(cleanMessageId(this.inReplyTo));
|
|
458
|
+
|
|
459
|
+
const patches: FormatPatchFile[] = [];
|
|
460
|
+
const stdoutParts: Uint8Array[] = [];
|
|
461
|
+
const out: string[] = [];
|
|
462
|
+
let nr = 0;
|
|
463
|
+
const subjectOf = () => {
|
|
464
|
+
if (total > 0) {
|
|
465
|
+
const width = String(total).length;
|
|
466
|
+
return `Subject: [${sprefix}${sprefix ? " " : ""}${String(nr).padStart(width, "0")}/${total}] `;
|
|
467
|
+
}
|
|
468
|
+
if (total === 0 && sprefix) return `Subject: [${sprefix}] `;
|
|
469
|
+
return "Subject: ";
|
|
470
|
+
};
|
|
471
|
+
const threadHeaders = () => {
|
|
472
|
+
let h = "";
|
|
473
|
+
if (ownId) h += `Message-ID: <${ownId}>\n`;
|
|
474
|
+
if (refIds.length) {
|
|
475
|
+
h += `In-Reply-To: <${refIds[refIds.length - 1]}>\n`;
|
|
476
|
+
refIds.forEach((id, i) => {
|
|
477
|
+
h += `${i > 0 ? "\t" : "References: "}<${id}>\n`;
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
return h;
|
|
481
|
+
};
|
|
482
|
+
const fileName = (subject: string | undefined) => {
|
|
483
|
+
let name = outDir ? (outDir.endsWith("/") ? outDir : `${outDir}/`) : "";
|
|
484
|
+
if (this.numberedFiles) return `${name}${nr}`;
|
|
485
|
+
const maxLen = encodeGitPath(name).length + nameMax - (suffix.length + 1);
|
|
486
|
+
if (this.rerollCount) name += `${sanitizedSubject(`v${this.rerollCount}`)}-`;
|
|
487
|
+
name += `${String(nr).padStart(4, "0")}-${subject ?? ""}`;
|
|
488
|
+
let bytes = encodeGitPath(name);
|
|
489
|
+
if (maxLen < bytes.length) bytes = bytes.subarray(0, maxLen);
|
|
490
|
+
return `${decodeGitPath(bytes)}${suffix}`;
|
|
491
|
+
};
|
|
492
|
+
const emit = (name: string, content: Uint8Array) => {
|
|
493
|
+
if (this.stdout) {
|
|
494
|
+
stdoutParts.push(content);
|
|
495
|
+
patches.push({ name: "", content });
|
|
496
|
+
} else {
|
|
497
|
+
patches.push({ name, content });
|
|
498
|
+
if (!this.quiet) out.push(`${name}\n`);
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
const sig = (): string => {
|
|
502
|
+
if (signature === false || signature === "") return "";
|
|
503
|
+
return `-- \n${signature}${signature.endsWith("\n") ? "" : "\n"}\n`;
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
if (cover) {
|
|
507
|
+
if (thread) ownId = messageId("cover");
|
|
508
|
+
nr = 0;
|
|
509
|
+
const text = await this.coverLetterText(list, origin, {
|
|
510
|
+
subject: subjectOf(),
|
|
511
|
+
thread: threadHeaders(),
|
|
512
|
+
afterSubject: extraHeaders,
|
|
513
|
+
from: fromIdent,
|
|
514
|
+
committer,
|
|
515
|
+
encodeHeaders,
|
|
516
|
+
zeroCommit: this.zeroCommit,
|
|
517
|
+
outputEncoding,
|
|
518
|
+
});
|
|
519
|
+
const content = concat([text, latin(bases.text), latin(sig())]);
|
|
520
|
+
bases.text = "";
|
|
521
|
+
emit(fileName(this.numberedFiles ? undefined : "cover-letter"), content);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
const sob = signoff ? `Signed-off-by: ${committer.name} <${committer.email}>\n` : undefined;
|
|
525
|
+
let shownOne = false;
|
|
526
|
+
for (let k = 0; k < list.length; k++) {
|
|
527
|
+
const id = list[list.length - 1 - k] as ObjectId;
|
|
528
|
+
nr = startNumber + k;
|
|
529
|
+
if (thread) {
|
|
530
|
+
if (ownId) {
|
|
531
|
+
// shallow: every mail replies to the first one (or to --in-reply-to, or to the
|
|
532
|
+
// cover letter); deep: each to the one before
|
|
533
|
+
const keepFirst = thread === "shallow" && refIds.length > 0 && (!cover || nr > 1);
|
|
534
|
+
if (!keepFirst) refIds.push(ownId);
|
|
535
|
+
}
|
|
536
|
+
ownId = messageId(id);
|
|
537
|
+
}
|
|
538
|
+
const subject = this.numberedFiles ? undefined : await this.fileSubject(id);
|
|
539
|
+
const log = new LogCommand(this.workingCopy)
|
|
540
|
+
.add(id)
|
|
541
|
+
.setMaxCount(1)
|
|
542
|
+
.setDiffOptions({
|
|
543
|
+
stat: { width: MAIL_DEFAULT_WRAP },
|
|
544
|
+
binaryPatch: !this.noBinary,
|
|
545
|
+
ignoreConfigNoPrefix: true,
|
|
546
|
+
// git_format_config ignores diff.submodule
|
|
547
|
+
submoduleFormat: "short",
|
|
548
|
+
uiConfig: false,
|
|
549
|
+
...(noPrefix ? { noPrefix: true } : {}),
|
|
550
|
+
});
|
|
551
|
+
const bytes = await log.callBytes({
|
|
552
|
+
pretty: this.stdout && bool(this.config("format.mboxrd")) ? "mboxrd" : "email",
|
|
553
|
+
stat: !this.noStat,
|
|
554
|
+
summary: !this.noStat,
|
|
555
|
+
patch: true,
|
|
556
|
+
showRoot: true,
|
|
557
|
+
mailmap: false,
|
|
558
|
+
notes: false,
|
|
559
|
+
abbrevCommit: false,
|
|
560
|
+
decorate: false,
|
|
561
|
+
mail: {
|
|
562
|
+
subject: subjectOf,
|
|
563
|
+
threadHeaders,
|
|
564
|
+
afterSubject: extraHeaders,
|
|
565
|
+
zeroCommit: this.zeroCommit,
|
|
566
|
+
preserveSubject: this.keepSubject,
|
|
567
|
+
...(sob ? { signoff: sob } : {}),
|
|
568
|
+
...(fromIdent ? { from: fromIdent } : {}),
|
|
569
|
+
forceInBodyFrom: this.forceInBodyFrom,
|
|
570
|
+
encodeHeaders,
|
|
571
|
+
outputEncoding,
|
|
572
|
+
},
|
|
573
|
+
});
|
|
574
|
+
const parts: Uint8Array[] = [];
|
|
575
|
+
// log-tree's shown_one: one blank line between the mails of --stdout
|
|
576
|
+
if (this.stdout && shownOne) parts.push(latin("\n"));
|
|
577
|
+
shownOne = true;
|
|
578
|
+
parts.push(bytes, latin(bases.text), latin(sig()));
|
|
579
|
+
bases.text = "";
|
|
580
|
+
emit(fileName(subject), concat(parts));
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
if (!this.stdout && this.writeFiles) {
|
|
584
|
+
const worktree = this.worktreeAccess;
|
|
585
|
+
if (worktree) {
|
|
586
|
+
for (const p of patches) {
|
|
587
|
+
await worktree.writeContent(p.name, p.content, { createParents: true, raw: true });
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
const output = this.stdout ? concat(stdoutParts) : new TextEncoder().encode(out.join(""));
|
|
592
|
+
return { patches, output };
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/** The subject for the file name (`%f`). */
|
|
596
|
+
private async fileSubject(id: ObjectId): Promise<string> {
|
|
597
|
+
const commit = await this.commits.load(id);
|
|
598
|
+
const message = commit?.message ?? "";
|
|
599
|
+
const lines = message.split("\n");
|
|
600
|
+
let at = 0;
|
|
601
|
+
while (at < lines.length && (lines[at] as string).trim() === "") at++;
|
|
602
|
+
const subject: string[] = [];
|
|
603
|
+
for (; at < lines.length && (lines[at] as string).trim() !== ""; at++)
|
|
604
|
+
subject.push(lines[at] as string);
|
|
605
|
+
return sanitizedSubject(subject.join(" "));
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/** The commits to format (newest first), the single boundary commit, the branch name. */
|
|
609
|
+
private async walk(): Promise<{ list: ObjectId[]; origin?: ObjectId; branchName?: string }> {
|
|
610
|
+
const resolver = this.revisionResolver();
|
|
611
|
+
const resolve = async (spec: string) => {
|
|
612
|
+
const id = await resolver.resolve(spec, { type: "commit" } as never);
|
|
613
|
+
if (!id)
|
|
614
|
+
throw new FormatPatchError(
|
|
615
|
+
`ambiguous argument '${spec}': unknown revision or path not in the working tree.`,
|
|
616
|
+
);
|
|
617
|
+
const peeled = (await resolver.peelToType(id, "commit")) ?? id;
|
|
618
|
+
return peeled;
|
|
619
|
+
};
|
|
620
|
+
const positive: ObjectId[] = [];
|
|
621
|
+
const negative: ObjectId[] = [];
|
|
622
|
+
let singleName: string | undefined;
|
|
623
|
+
for (const rev of this.revisions) {
|
|
624
|
+
const dots = rev.indexOf("..");
|
|
625
|
+
if (dots >= 0 && rev[dots + 2] !== ".") {
|
|
626
|
+
const a = rev.slice(0, dots) || "HEAD";
|
|
627
|
+
const b = rev.slice(dots + 2) || "HEAD";
|
|
628
|
+
negative.push(await resolve(a));
|
|
629
|
+
positive.push(await resolve(b));
|
|
630
|
+
} else if (rev.startsWith("^")) negative.push(await resolve(rev.slice(1)));
|
|
631
|
+
else {
|
|
632
|
+
positive.push(await resolve(rev));
|
|
633
|
+
singleName = rev;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (!positive.length && !negative.length) {
|
|
637
|
+
positive.push(await resolve("HEAD"));
|
|
638
|
+
singleName = "HEAD";
|
|
639
|
+
}
|
|
640
|
+
let branchName: string | undefined;
|
|
641
|
+
if (this.revisions.length <= 1 && positive.length === 1 && negative.length === 0) {
|
|
642
|
+
let checkHead = false;
|
|
643
|
+
if (this.maxCount === undefined && !this.root) {
|
|
644
|
+
negative.push(positive.pop() as ObjectId);
|
|
645
|
+
positive.push(await resolve("HEAD"));
|
|
646
|
+
checkHead = true;
|
|
647
|
+
}
|
|
648
|
+
if (singleName === "HEAD") checkHead = true;
|
|
649
|
+
if (checkHead) {
|
|
650
|
+
const branch = await this.getCurrentBranch();
|
|
651
|
+
branchName = branch?.startsWith("refs/heads/") ? branch.slice(11) : "";
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
const log = new LogCommand(this.workingCopy);
|
|
655
|
+
for (const p of positive) log.add(p);
|
|
656
|
+
for (const n of negative) log.not(n);
|
|
657
|
+
const list: ObjectId[] = [];
|
|
658
|
+
const listed = new Set<ObjectId>();
|
|
659
|
+
const parentsOf = new Map<ObjectId, ObjectId[]>();
|
|
660
|
+
for await (const c of await log.call()) {
|
|
661
|
+
if (c.parents.length > 1) continue;
|
|
662
|
+
if (this.maxCount !== undefined && list.length >= this.maxCount) break;
|
|
663
|
+
list.push(c.id);
|
|
664
|
+
listed.add(c.id);
|
|
665
|
+
parentsOf.set(c.id, c.parents);
|
|
666
|
+
}
|
|
667
|
+
const boundary = new Set<ObjectId>();
|
|
668
|
+
for (const id of list)
|
|
669
|
+
for (const p of parentsOf.get(id) ?? []) if (!listed.has(p)) boundary.add(p);
|
|
670
|
+
const origin = boundary.size === 1 ? [...boundary][0] : undefined;
|
|
671
|
+
return {
|
|
672
|
+
list,
|
|
673
|
+
...(origin ? { origin } : {}),
|
|
674
|
+
...(branchName !== undefined ? { branchName } : {}),
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/** `get_base_commit` + `prepare_bases`: the text `print_bases` writes once. */
|
|
679
|
+
private async prepareBases(list: ObjectId[]): Promise<{ text: string }> {
|
|
680
|
+
let spec = this.base;
|
|
681
|
+
if (spec === undefined && (this.config("format.useAutoBase") ?? "").toLowerCase() === "true")
|
|
682
|
+
spec = "auto";
|
|
683
|
+
if (spec === undefined) return { text: "" };
|
|
684
|
+
if (spec === "auto") {
|
|
685
|
+
throw new FormatPatchError(
|
|
686
|
+
"failed to get upstream, if you want to record base commit automatically,\nplease use git branch --set-upstream-to to track a remote branch.\nOr you could specify base commit by --base=<base-commit-id> manually",
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
const resolver = this.revisionResolver();
|
|
690
|
+
const base = await resolver.resolve(spec);
|
|
691
|
+
if (!base) throw new FormatPatchError(`unknown commit ${spec}`);
|
|
692
|
+
for (const id of list) {
|
|
693
|
+
if (!(await this.commits.isAncestor(base, id)))
|
|
694
|
+
throw new FormatPatchError("base commit should be the ancestor of revision list");
|
|
695
|
+
}
|
|
696
|
+
if (list.includes(base))
|
|
697
|
+
throw new FormatPatchError("base commit shouldn't be in revision list");
|
|
698
|
+
// the commits between the base and the series (topological, merges left out)
|
|
699
|
+
const log = new LogCommand(this.workingCopy);
|
|
700
|
+
for (const id of list) log.add(id);
|
|
701
|
+
log.not(base);
|
|
702
|
+
const inList = new Set(list);
|
|
703
|
+
const ids: string[] = [];
|
|
704
|
+
for await (const c of await log.call()) {
|
|
705
|
+
if (c.parents.length > 1 || inList.has(c.id)) continue;
|
|
706
|
+
// commit_patch_id: the diff against the parent with rename detection (diff.renames)
|
|
707
|
+
const parent = c.parents[0];
|
|
708
|
+
const diff = new DiffCommand(this.workingCopy).setNewTree(c.id).setRenames(true);
|
|
709
|
+
if (parent) diff.setOldTree(parent);
|
|
710
|
+
const changes: PatchIdChange[] = [];
|
|
711
|
+
for (const e of await diff.call()) {
|
|
712
|
+
const del = e.changeType === ChangeType.DELETE;
|
|
713
|
+
const add = e.changeType === ChangeType.ADD;
|
|
714
|
+
changes.push({
|
|
715
|
+
path: (del ? e.oldPath : e.newPath) as string,
|
|
716
|
+
...(e.changeType === ChangeType.RENAME || e.changeType === ChangeType.COPY
|
|
717
|
+
? { oldPath: e.oldPath as string }
|
|
718
|
+
: {}),
|
|
719
|
+
...(!add && e.oldId ? { old: { mode: e.oldMode as number, id: e.oldId } } : {}),
|
|
720
|
+
...(!del && e.newId ? { new: { mode: e.newMode as number, id: e.newId } } : {}),
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
ids.push(changes.length ? await patchIdOfChanges(this.blobs, changes) : "0".repeat(40));
|
|
724
|
+
}
|
|
725
|
+
let text = `\nbase-commit: ${base}\n`;
|
|
726
|
+
for (let i = ids.length - 1; i >= 0; i--) text += `prerequisite-patch-id: ${ids[i]}\n`;
|
|
727
|
+
return { text };
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/** `make_cover_letter`. */
|
|
731
|
+
private async coverLetterText(
|
|
732
|
+
list: ObjectId[],
|
|
733
|
+
origin: ObjectId | undefined,
|
|
734
|
+
mail: {
|
|
735
|
+
subject: string;
|
|
736
|
+
thread: string;
|
|
737
|
+
afterSubject: string;
|
|
738
|
+
from?: { name: string; email: string };
|
|
739
|
+
committer: PersonIdent;
|
|
740
|
+
encodeHeaders: boolean;
|
|
741
|
+
zeroCommit: boolean;
|
|
742
|
+
/** get_log_output_encoding(): the shortlog's (the headers stay UTF-8) */
|
|
743
|
+
outputEncoding: string;
|
|
744
|
+
},
|
|
745
|
+
): Promise<Uint8Array> {
|
|
746
|
+
const head = list[0] as ObjectId;
|
|
747
|
+
const commits = await Promise.all(list.map((id) => this.commits.load(id)));
|
|
748
|
+
// need_8bit_cte: any commit (headers included) with a byte above 0x7f
|
|
749
|
+
let eightBit = false;
|
|
750
|
+
for (const id of list) {
|
|
751
|
+
const raw = await this.rawCommitBytes(id);
|
|
752
|
+
if (raw.some((b) => b >= 0x80)) {
|
|
753
|
+
eightBit = true;
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
// git 2.54 and later: the --from ident (no date: the epoch); before, the committer's
|
|
758
|
+
const fromIdent = gitVersionAtLeast(this.versionString, 2, 54) ? mail.from : undefined;
|
|
759
|
+
const who = fromIdent ?? { name: mail.committer.name, email: mail.committer.email };
|
|
760
|
+
const date = fromIdent
|
|
761
|
+
? { timestamp: 0, tzOffset: "+0000" }
|
|
762
|
+
: { timestamp: mail.committer.timestamp, tzOffset: mail.committer.tzOffset };
|
|
763
|
+
let text = `From ${mail.zeroCommit ? "0".repeat(40) : head} Mon Sep 17 00:00:00 2001\n`;
|
|
764
|
+
text += mail.thread;
|
|
765
|
+
text += mailFromHeader(who.name, who.email, { encodeHeaders: mail.encodeHeaders });
|
|
766
|
+
text += `Date: ${showDate(date.timestamp, date.tzOffset, { type: "rfc2822", local: false })}\n`;
|
|
767
|
+
text += `${mail.subject}*** SUBJECT HERE ***\n`;
|
|
768
|
+
if (eightBit)
|
|
769
|
+
text +=
|
|
770
|
+
"MIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n";
|
|
771
|
+
text += mail.afterSubject;
|
|
772
|
+
text += "\n*** BLURB HERE ***\n\n";
|
|
773
|
+
const parts: Uint8Array[] = [new TextEncoder().encode(text)];
|
|
774
|
+
text = "";
|
|
775
|
+
// shortlog: authors in byte order, their subjects oldest first, wrapped at 72; each
|
|
776
|
+
// commit's name and subject in the log output encoding (shortlog_add_commit), as
|
|
777
|
+
// stored where they do not convert (logmsg_reencode)
|
|
778
|
+
const byAuthor = new Map<string, string[]>();
|
|
779
|
+
const encoderOf = new Map<string, (s: string) => Uint8Array>();
|
|
780
|
+
for (const [k, c] of commits.entries()) {
|
|
781
|
+
if (!c) continue;
|
|
782
|
+
const utf8 = await this.utf8AuthorAndMessage(list[k] as ObjectId, c);
|
|
783
|
+
const name = utf8.name;
|
|
784
|
+
const encoder = outputEncoder(mail.outputEncoding, `${name}\n${utf8.message}`, utf8.stored);
|
|
785
|
+
let subject = subjectLine(utf8.message);
|
|
786
|
+
if (subject.startsWith("[PATCH")) {
|
|
787
|
+
const eob = subject.indexOf("]");
|
|
788
|
+
if (eob >= 0) subject = subject.slice(eob + 1).replace(/^[ \t]+/, "");
|
|
789
|
+
}
|
|
790
|
+
const listFor = byAuthor.get(name) ?? [];
|
|
791
|
+
listFor.push(subject);
|
|
792
|
+
byAuthor.set(name, listFor);
|
|
793
|
+
encoderOf.set(`${name}\n${listFor.length - 1}`, encoder);
|
|
794
|
+
if (!encoderOf.has(name)) encoderOf.set(name, encoder);
|
|
795
|
+
}
|
|
796
|
+
const names = [...byAuthor.keys()].sort(compareBytes);
|
|
797
|
+
const utf8Encode = (x: string) => new TextEncoder().encode(x);
|
|
798
|
+
for (const name of names) {
|
|
799
|
+
const subjects = byAuthor.get(name) as string[];
|
|
800
|
+
parts.push((encoderOf.get(name) ?? utf8Encode)(`${name} (${subjects.length}):\n`));
|
|
801
|
+
for (let j = subjects.length; j >= 1; j--)
|
|
802
|
+
parts.push(
|
|
803
|
+
(encoderOf.get(`${name}\n${j - 1}`) ?? utf8Encode)(
|
|
804
|
+
`${wrapText(subjects[j - 1] as string, 2, 4, MAIL_DEFAULT_WRAP)}\n`,
|
|
805
|
+
),
|
|
806
|
+
);
|
|
807
|
+
parts.push(utf8Encode("\n"));
|
|
808
|
+
}
|
|
809
|
+
if (origin) {
|
|
810
|
+
const originTree = (await this.commits.load(origin))?.tree;
|
|
811
|
+
const headTree = commits[0]?.tree;
|
|
812
|
+
text += await this.treeDiffstat(originTree, headTree as string);
|
|
813
|
+
text += "\n";
|
|
814
|
+
}
|
|
815
|
+
parts.push(new TextEncoder().encode(text));
|
|
816
|
+
return concat(parts);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/** The commit as stored (its fields encoded again when the store has no raw bytes). */
|
|
820
|
+
private async rawCommitBytes(id: ObjectId): Promise<Uint8Array> {
|
|
821
|
+
const objects = this.workingCopy.history?.objects;
|
|
822
|
+
try {
|
|
823
|
+
const obj = await objects?.get(id);
|
|
824
|
+
if (obj) {
|
|
825
|
+
if (obj.bytes) return obj.bytes;
|
|
826
|
+
const chunks: Uint8Array[] = [];
|
|
827
|
+
for await (const c of obj.content) chunks.push(c);
|
|
828
|
+
return concat(chunks);
|
|
829
|
+
}
|
|
830
|
+
} catch {
|
|
831
|
+
// fall back to the parsed commit
|
|
832
|
+
}
|
|
833
|
+
const commit = await this.commits.load(id);
|
|
834
|
+
return encodeGitPath(
|
|
835
|
+
`author ${commit?.author.name ?? ""} <${commit?.author.email ?? ""}>\ncommitter ${commit?.committer.name ?? ""} <${commit?.committer.email ?? ""}>\n\n${commit?.message ?? ""}`,
|
|
836
|
+
);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* The author name and message of a commit in UTF-8 (the cover letter's encoding): from its
|
|
841
|
+
* `encoding` header when it has one (logmsg_reencode), as stored when that fails.
|
|
842
|
+
*/
|
|
843
|
+
private async utf8AuthorAndMessage(
|
|
844
|
+
id: ObjectId,
|
|
845
|
+
commit: { author: { name: string }; message: string },
|
|
846
|
+
): Promise<{ name: string; message: string; stored: string }> {
|
|
847
|
+
const raw = await this.rawCommitBytes(id);
|
|
848
|
+
let end = 0;
|
|
849
|
+
let encoding: string | undefined;
|
|
850
|
+
let authorLine: Uint8Array | undefined;
|
|
851
|
+
for (;;) {
|
|
852
|
+
const nl = raw.indexOf(0x0a, end);
|
|
853
|
+
if (nl < 0 || nl === end) break;
|
|
854
|
+
const line = raw.subarray(end, nl);
|
|
855
|
+
const text = decodeGitPath(line);
|
|
856
|
+
if (text.startsWith("encoding ")) encoding = text.slice(9);
|
|
857
|
+
if (text.startsWith("author ")) authorLine = line.subarray(7);
|
|
858
|
+
end = nl + 1;
|
|
859
|
+
}
|
|
860
|
+
const stored = { name: commit.author.name, message: commit.message, stored: "UTF-8" };
|
|
861
|
+
if (!encoding || /^utf-?8$/i.test(encoding)) return stored;
|
|
862
|
+
const decode = (bytes: Uint8Array): string | undefined => {
|
|
863
|
+
if (/^(iso[-_]?8859-1|latin-?1|l1)$/i.test(encoding as string)) {
|
|
864
|
+
let out = "";
|
|
865
|
+
for (const b of bytes) out += String.fromCharCode(b);
|
|
866
|
+
return out;
|
|
867
|
+
}
|
|
868
|
+
try {
|
|
869
|
+
return new TextDecoder(encoding, { fatal: true }).decode(bytes);
|
|
870
|
+
} catch {
|
|
871
|
+
return undefined;
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
const message = decode(raw.subarray(end + 1));
|
|
875
|
+
const ident = authorLine ? decode(authorLine) : undefined;
|
|
876
|
+
const name = ident?.replace(/ ?<[^>]*>.*$/s, "");
|
|
877
|
+
if (message === undefined) return stored;
|
|
878
|
+
return { name: name ?? stored.name, message, stored: encoding };
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/** `--stat --summary` of two trees, as format-patch's cover letter shows them. */
|
|
882
|
+
private async treeDiffstat(a: ObjectId | undefined, b: ObjectId): Promise<string> {
|
|
883
|
+
const diff = new DiffCommand(this.workingCopy).setNewTree(b).setOptions({
|
|
884
|
+
stat: { width: MAIL_DEFAULT_WRAP },
|
|
885
|
+
uiConfig: false,
|
|
886
|
+
});
|
|
887
|
+
if (a) diff.setOldTree(a);
|
|
888
|
+
const r = await diff.callFormats(["stat", "summary"]);
|
|
889
|
+
return r.bytes ? decodeGitPath(r.bytes) : "";
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/** git_parse_maybe_bool: undefined (git's -1) for a value that is not a boolean. */
|
|
894
|
+
function maybeBool(value: string): boolean | undefined {
|
|
895
|
+
const v = value.toLowerCase();
|
|
896
|
+
if (v === "" || v === "true" || v === "yes" || v === "on") return true;
|
|
897
|
+
if (v === "false" || v === "no" || v === "off") return false;
|
|
898
|
+
// git_parse_int: an integer with an optional k/m/g unit
|
|
899
|
+
const m = /^\s*[+-]?(0x[0-9a-f]+|\d+)[kmg]?$/i.exec(value);
|
|
900
|
+
if (m) return Number(m[1]) !== 0;
|
|
901
|
+
return undefined;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
const LATIN1_NAME = /^(iso[-_]?8859-1|iso8859-1|latin-?1|l1|iso-ir-100|cp819|ibm819|csisolatin1)$/i;
|
|
905
|
+
|
|
906
|
+
const latin1Bytes = (s: string) => {
|
|
907
|
+
const out = new Uint8Array(s.length);
|
|
908
|
+
for (let i = 0; i < s.length; i++) out[i] = s.charCodeAt(i);
|
|
909
|
+
return out;
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* How a commit's text is written in the log output encoding: UTF-8 or ISO-8859-1 (when
|
|
914
|
+
* every character converts); otherwise in the encoding the commit is stored in, as git
|
|
915
|
+
* keeps a message iconv cannot convert.
|
|
916
|
+
*/
|
|
917
|
+
function outputEncoder(output: string, text: string, stored: string): (s: string) => Uint8Array {
|
|
918
|
+
const utf8 = (s: string) => new TextEncoder().encode(s);
|
|
919
|
+
const encoderFor = (charset: string) =>
|
|
920
|
+
/^utf-?8$/i.test(charset)
|
|
921
|
+
? utf8
|
|
922
|
+
: LATIN1_NAME.test(charset) && [...text].every((ch) => (ch.codePointAt(0) ?? 0) <= 0xff)
|
|
923
|
+
? latin1Bytes
|
|
924
|
+
: undefined;
|
|
925
|
+
return encoderFor(output) ?? encoderFor(stored) ?? utf8;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
function subjectLine(message: string): string {
|
|
929
|
+
const lines = message.split("\n");
|
|
930
|
+
let at = 0;
|
|
931
|
+
while (at < lines.length && (lines[at] as string).trim() === "") at++;
|
|
932
|
+
const parts: string[] = [];
|
|
933
|
+
for (; at < lines.length && (lines[at] as string).trim() !== ""; at++)
|
|
934
|
+
parts.push((lines[at] as string).trim());
|
|
935
|
+
return parts.join(" ");
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
function compareBytes(a: string, b: string): number {
|
|
939
|
+
const x = encodeGitPath(a);
|
|
940
|
+
const y = encodeGitPath(b);
|
|
941
|
+
for (let i = 0; i < Math.min(x.length, y.length); i++)
|
|
942
|
+
if (x[i] !== y[i]) return (x[i] as number) - (y[i] as number);
|
|
943
|
+
return x.length - y.length;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
/** `clean_message_id`: the id without its angle brackets and surrounding blanks. */
|
|
947
|
+
function cleanMessageId(id: string): string {
|
|
948
|
+
let a = 0;
|
|
949
|
+
let z = id.length;
|
|
950
|
+
while (a < z && (/\s/.test(id[a] as string) || id[a] === "<")) a++;
|
|
951
|
+
while (a < z && (/\s/.test(id[z - 1] as string) || id[z - 1] === ">")) z--;
|
|
952
|
+
return id.slice(a, z);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
function latin(text: string): Uint8Array {
|
|
956
|
+
return new TextEncoder().encode(text);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
function concat(parts: Uint8Array[]): Uint8Array {
|
|
960
|
+
let size = 0;
|
|
961
|
+
for (const p of parts) size += p.length;
|
|
962
|
+
const out = new Uint8Array(size);
|
|
963
|
+
let at = 0;
|
|
964
|
+
for (const p of parts) {
|
|
965
|
+
out.set(p, at);
|
|
966
|
+
at += p.length;
|
|
967
|
+
}
|
|
968
|
+
return out;
|
|
969
|
+
}
|