@statewalker/vcs-commands 0.5.0 → 0.7.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 +300 -18
- 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 +49 -16
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +134 -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 +311 -17
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/core-config.d.ts +78 -1
- package/dist/commands/core-config.d.ts.map +1 -1
- package/dist/commands/date-format.d.ts +58 -0
- package/dist/commands/date-format.d.ts.map +1 -0
- package/dist/commands/default-branch.d.ts +70 -0
- package/dist/commands/default-branch.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 +149 -10
- 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 +227 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-loose.d.ts +71 -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 +159 -0
- package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-object-table.d.ts +140 -0
- package/dist/commands/fsck/fsck-object-table.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-pack.d.ts +122 -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 +106 -39
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-date.d.ts +2 -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 +424 -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 +233 -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 +56 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -2
- package/dist/commands/init-command.d.ts +62 -4
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/legacy-remotes.d.ts +55 -0
- package/dist/commands/legacy-remotes.d.ts.map +1 -0
- 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 +221 -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 +260 -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 +116 -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 +44 -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 +59 -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 +31 -0
- 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 +89 -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 +325 -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 +42 -8
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-create-command.d.ts +156 -2
- package/dist/commands/stash-create-command.d.ts.map +1 -1
- package/dist/commands/stash-drop-command.d.ts +2 -0
- package/dist/commands/stash-drop-command.d.ts.map +1 -1
- package/dist/commands/stash-working-tree.d.ts +23 -0
- package/dist/commands/stash-working-tree.d.ts.map +1 -1
- package/dist/commands/status-command.d.ts +300 -15
- 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 +85 -1
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/untracked-cache-support.d.ts +54 -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 +146 -6
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- 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-DIJ91NnD.js +62225 -0
- package/dist/core-commands/add.command.impl.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 +16 -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 +354 -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-BGiOJ8Zk.js +7246 -0
- package/dist/git-command.d.ts +428 -32
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +315 -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 -1
- package/dist/remote-config/index.d.ts.map +1 -1
- package/dist/remote-config/remote-config-store.d.ts +167 -6
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/remote-config/remote-refs.d.ts +7 -3
- package/dist/remote-config/remote-refs.d.ts.map +1 -1
- 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 +18 -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 +15 -0
- 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/init-result.d.ts +7 -0
- package/dist/results/init-result.d.ts.map +1 -1
- 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 +17 -3
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +47 -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 +60 -6
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-WVlBhVb1.js +2935 -0
- package/dist/transport-command.d.ts +44 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +15 -11
- package/src/commands/add-command.ts +1291 -226
- 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 +842 -0
- package/src/commands/apply/apply-engine.ts +1602 -0
- package/src/commands/apply/apply-parse.ts +1210 -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 +1080 -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 +1290 -243
- package/src/commands/checkout-paths.ts +784 -0
- package/src/commands/cherry-pick-command.ts +156 -396
- package/src/commands/clean-command.ts +504 -156
- package/src/commands/clone-command.ts +748 -69
- package/src/commands/comment-char-config.ts +160 -0
- package/src/commands/commit-command.ts +1782 -166
- package/src/commands/core-config.ts +166 -6
- package/src/commands/date-format.ts +668 -0
- package/src/commands/default-branch.ts +196 -0
- package/src/commands/describe-command.ts +2 -0
- package/src/commands/diff-command.ts +1916 -110
- package/src/commands/diff-textconv.ts +50 -0
- package/src/commands/fetch-command.ts +622 -68
- package/src/commands/format-patch-command.ts +974 -0
- package/src/commands/fsck/fetch-fsck.ts +229 -0
- package/src/commands/fsck/fsck-command.ts +3464 -0
- package/src/commands/fsck/fsck-loose.ts +297 -0
- package/src/commands/fsck/fsck-msg-ids.ts +176 -0
- package/src/commands/fsck/fsck-object-checks.ts +1085 -0
- package/src/commands/fsck/fsck-object-table.ts +373 -0
- package/src/commands/fsck/fsck-pack.ts +634 -0
- package/src/commands/fsck/index.ts +5 -0
- package/src/commands/fsck/verify-pack-command.ts +252 -0
- package/src/commands/gc-command.ts +324 -77
- package/src/commands/git-date.ts +9 -0
- package/src/commands/git-describe.ts +316 -0
- package/src/commands/git-hooks.ts +1483 -0
- package/src/commands/git-ident.ts +344 -0
- package/src/commands/hook-command.ts +247 -0
- package/src/commands/index-adder.ts +711 -0
- package/src/commands/index-host.ts +291 -0
- package/src/commands/index.ts +84 -0
- package/src/commands/init-command.ts +194 -14
- package/src/commands/legacy-remotes.ts +224 -0
- package/src/commands/local-clone.ts +183 -0
- package/src/commands/local-transport.ts +762 -0
- package/src/commands/log-command.ts +1930 -170
- package/src/commands/log-graph.ts +671 -0
- package/src/commands/log-output.ts +1359 -0
- package/src/commands/ls-remote-command.ts +105 -58
- package/src/commands/mailmap.ts +129 -0
- package/src/commands/merge-bases.ts +296 -0
- package/src/commands/merge-command.ts +1416 -491
- package/src/commands/merge-config.ts +25 -0
- package/src/commands/merge-drivers.ts +306 -0
- package/src/commands/merge-support.ts +1219 -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 +777 -0
- package/src/commands/notes-support.ts +402 -0
- package/src/commands/notes-tree.ts +617 -0
- package/src/commands/object-id-input.ts +27 -0
- package/src/commands/octopus-merge.ts +378 -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 +204 -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 +1432 -0
- package/src/commands/promisor-remote.ts +298 -0
- package/src/commands/pull-command.ts +326 -33
- package/src/commands/push-command.ts +257 -29
- package/src/commands/read-tree-command.ts +861 -0
- package/src/commands/rebase-command.ts +3820 -372
- 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 +124 -23
- package/src/commands/remote-transport.ts +383 -0
- package/src/commands/reset-command.ts +821 -104
- package/src/commands/restore-command.ts +350 -0
- package/src/commands/rev-list-command.ts +167 -0
- package/src/commands/rev-parse-command.ts +299 -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 +1397 -0
- package/src/commands/rm-command.ts +613 -67
- package/src/commands/sequencer-pick.ts +874 -0
- package/src/commands/sequencer-support.ts +876 -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 +376 -343
- package/src/commands/stash-create-command.ts +625 -42
- package/src/commands/stash-drop-command.ts +15 -2
- package/src/commands/stash-working-tree.ts +168 -24
- package/src/commands/status-command.ts +1326 -105
- package/src/commands/status-format.ts +775 -0
- package/src/commands/status-header.ts +332 -0
- package/src/commands/strerror.ts +29 -0
- package/src/commands/submodule-config.ts +94 -0
- package/src/commands/submodule-summary-command.ts +333 -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 +204 -4
- package/src/commands/untracked-cache-support.ts +198 -0
- package/src/commands/worktree-add-command.ts +458 -0
- package/src/commands/worktree-list-command.ts +206 -0
- package/src/commands/worktree-lock-command.ts +96 -0
- package/src/commands/worktree-overwrite-checks.ts +452 -26
- 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 +8 -2
- package/src/errors/add-errors.ts +45 -0
- package/src/errors/checkout-errors.ts +26 -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 +1207 -118
- package/src/git.ts +538 -12
- package/src/index.ts +1 -1
- package/src/remote-config/index.ts +2 -0
- package/src/remote-config/remote-config-store.ts +378 -18
- package/src/remote-config/remote-refs.ts +22 -6
- package/src/rename/detect-renames.ts +715 -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 +21 -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 +1053 -0
- package/src/results/fetch-result.ts +15 -0
- package/src/results/index.ts +5 -0
- package/src/results/init-result.ts +9 -0
- package/src/results/merge-result.ts +15 -1
- package/src/results/pull-result.ts +17 -3
- package/src/results/push-result.ts +48 -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 +127 -46
- package/src/transport-command.ts +121 -2
- package/dist/commands-CsLNyvZ1.js +0 -12587
- package/dist/status-result-BpyUK1Sg.js +0 -519
|
@@ -0,0 +1,1111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `git am`: applies a series of patches from mailboxes, committing each with the author,
|
|
3
|
+
* date and message of its mail, as git does: the state in `.git/rebase-apply/` (the split
|
|
4
|
+
* mails `0001`..., `next`, `last`, `info`, `msg`, `patch`, `final-commit`,
|
|
5
|
+
* `author-script`, the option files, `abort-safety`), `ORIG_HEAD`, the reflog lines
|
|
6
|
+
* (`am: <subject>`, `am --abort`), the output ("Applying: <subject>", "Patch failed at
|
|
7
|
+
* ...") and the advice, and `--continue`, `--skip`, `--abort`, `--quit`.
|
|
8
|
+
*
|
|
9
|
+
* Not run: the `applypatch-msg`, `pre-applypatch` and `post-applypatch` hooks, rerere,
|
|
10
|
+
* and the auto maintenance git starts at the end. Notes are not copied: plain `git am`
|
|
11
|
+
* copies none (only `rebase --apply` does, through `rewritten`).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { formatPersonIdent, type ObjectId, type PersonIdent } from "@statewalker/vcs-core";
|
|
15
|
+
|
|
16
|
+
import { compareGitPaths, encodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
17
|
+
|
|
18
|
+
import { GitCommand } from "../../git-command.js";
|
|
19
|
+
import { quotePath } from "../../results/quote-path.js";
|
|
20
|
+
import { ApplyCommand } from "../apply/apply-command.js";
|
|
21
|
+
import { ApplyEngine, type ApplyIO } from "../apply/apply-engine.js";
|
|
22
|
+
import {
|
|
23
|
+
bytesToLatin1,
|
|
24
|
+
latin1ToBytes,
|
|
25
|
+
latin1ToPath,
|
|
26
|
+
latin1ToText,
|
|
27
|
+
pathToLatin1,
|
|
28
|
+
textToLatin1,
|
|
29
|
+
} from "../apply/latin1.js";
|
|
30
|
+
import { coreBool } from "../core-config.js";
|
|
31
|
+
import { localTimezoneOffset, parseGitDate } from "../git-date.js";
|
|
32
|
+
import { withoutCrud } from "../git-ident.js";
|
|
33
|
+
import { configValue, conflictStyleOf } from "../merge-config.js";
|
|
34
|
+
import { ortConfigOptions } from "../merge-drivers.js";
|
|
35
|
+
import {
|
|
36
|
+
flatTree,
|
|
37
|
+
indexChangesFromTree,
|
|
38
|
+
OperationState,
|
|
39
|
+
readIndex,
|
|
40
|
+
storeFlatTree,
|
|
41
|
+
storeFlatTreeOver,
|
|
42
|
+
switchTrees,
|
|
43
|
+
treeDelta,
|
|
44
|
+
} from "../merge-support.js";
|
|
45
|
+
import { stripspace } from "../message-cleanup.js";
|
|
46
|
+
import { ortResultEntries } from "../ort-merge.js";
|
|
47
|
+
import { mergeStoredTrees, storedBase } from "../ort-recursive.js";
|
|
48
|
+
import { updateHead, updateHeadExpecting } from "../reflog-messages.js";
|
|
49
|
+
import { removeBranchState, resetMerge, resetUnmergedToHead } from "../sequencer-support.js";
|
|
50
|
+
import { appendSignoff } from "../trailers.js";
|
|
51
|
+
import { mailinfo, mailsplit } from "./mailinfo.js";
|
|
52
|
+
import {
|
|
53
|
+
type AmPatchFormat,
|
|
54
|
+
detectPatchFormat,
|
|
55
|
+
hgPatchToMail,
|
|
56
|
+
stgitPatchToMail,
|
|
57
|
+
} from "./patch-format.js";
|
|
58
|
+
|
|
59
|
+
const DIR = "rebase-apply";
|
|
60
|
+
|
|
61
|
+
/** What `git am` printed and how it ended. */
|
|
62
|
+
export interface AmResult {
|
|
63
|
+
/** 0 done, 128 stopped (a patch that does not apply, an error) */
|
|
64
|
+
exitCode: number;
|
|
65
|
+
output: string;
|
|
66
|
+
errors: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type Resume = "apply" | "continue" | "allow-empty" | "skip" | "abort" | "quit";
|
|
70
|
+
|
|
71
|
+
/** The options `git am` passes to `git apply` (kept in `apply-opt`). */
|
|
72
|
+
export interface AmApplyOptions {
|
|
73
|
+
/** `-C<n>` */
|
|
74
|
+
context?: number;
|
|
75
|
+
/** `-p<n>` */
|
|
76
|
+
strip?: number;
|
|
77
|
+
/** `--whitespace=<action>` */
|
|
78
|
+
whitespace?: string;
|
|
79
|
+
/** `--directory=<dir>` */
|
|
80
|
+
directory?: string;
|
|
81
|
+
/** `--exclude=<path>` */
|
|
82
|
+
exclude?: string[];
|
|
83
|
+
/** `--include=<path>` */
|
|
84
|
+
include?: string[];
|
|
85
|
+
/** `--reject` */
|
|
86
|
+
reject?: boolean;
|
|
87
|
+
/** `--ignore-whitespace` */
|
|
88
|
+
ignoreWhitespace?: boolean;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** `sq_quote_buf`. */
|
|
92
|
+
function sqQuote(s: string): string {
|
|
93
|
+
return `'${s.replace(/['!]/g, (c) => `'\\${c}'`)}'`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** `sq_dequote_to_strvec` of what `sqQuote` wrote. */
|
|
97
|
+
function sqDequoteAll(s: string): string[] {
|
|
98
|
+
const out: string[] = [];
|
|
99
|
+
let i = 0;
|
|
100
|
+
while (i < s.length) {
|
|
101
|
+
while (s[i] === " ") i++;
|
|
102
|
+
if (i >= s.length) break;
|
|
103
|
+
if (s[i] !== "'") break;
|
|
104
|
+
let cur = "";
|
|
105
|
+
i++;
|
|
106
|
+
for (;;) {
|
|
107
|
+
const c = s[i++];
|
|
108
|
+
if (c === undefined) break;
|
|
109
|
+
if (c === "'") {
|
|
110
|
+
if (s[i] === "\\" && s[i + 2] === "'") {
|
|
111
|
+
cur += s[i + 1];
|
|
112
|
+
i += 3;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
cur += c;
|
|
118
|
+
}
|
|
119
|
+
out.push(cur);
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* `git am`.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* await git.am().addMbox(mboxBytes).setThreeWay(true).call();
|
|
130
|
+
* await git.am().setResume("continue").call();
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export class AmCommand extends GitCommand<AmResult> {
|
|
134
|
+
private mboxes: { content: string; name?: string }[] = [];
|
|
135
|
+
private patchFormat?: AmPatchFormat;
|
|
136
|
+
private fixedClock?: number;
|
|
137
|
+
private resume?: Resume;
|
|
138
|
+
private threeWay?: boolean;
|
|
139
|
+
private signoff = false;
|
|
140
|
+
private keepCr?: boolean;
|
|
141
|
+
private keep: "t" | "b" | "f" = "f";
|
|
142
|
+
private messageId?: boolean;
|
|
143
|
+
private scissors?: boolean;
|
|
144
|
+
private quiet = false;
|
|
145
|
+
private noVerify = false;
|
|
146
|
+
private utf8 = true;
|
|
147
|
+
private ignoreDate = false;
|
|
148
|
+
private committerDateIsAuthorDate = false;
|
|
149
|
+
private mboxrd = false;
|
|
150
|
+
private emptyMode: "stop" | "drop" | "keep" = "stop";
|
|
151
|
+
private applyOptions: AmApplyOptions = {};
|
|
152
|
+
private legacyMessages = false;
|
|
153
|
+
private out = "";
|
|
154
|
+
private err = "";
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* A mailbox (mbox) to apply, in order. `name` is its file's name as git shows it in
|
|
158
|
+
* messages (the file argument); a named file's format is detected (from the first one)
|
|
159
|
+
* and it must not be empty, while one without a name reads as standard input (an mbox).
|
|
160
|
+
*/
|
|
161
|
+
addMbox(mbox: Uint8Array | string, name?: string): this {
|
|
162
|
+
const content = typeof mbox === "string" ? textToLatin1(mbox) : bytesToLatin1(mbox);
|
|
163
|
+
this.mboxes.push({ content, ...(name !== undefined ? { name } : {}) });
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* `--patch-format=<format>`: mbox, mboxrd, stgit or hg (Mercurial); detected from the
|
|
169
|
+
* first named mailbox when not given. An StGit series (`stgit-series`) names its patch
|
|
170
|
+
* files, which a command given contents cannot open: it is refused.
|
|
171
|
+
*/
|
|
172
|
+
setPatchFormat(format: AmPatchFormat): this {
|
|
173
|
+
this.patchFormat = format;
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The clock (seconds since the epoch) for the dates git takes from it: the author date of
|
|
179
|
+
* `--ignore-date` or of a mail without a `Date:` header, the committer date and the reflog
|
|
180
|
+
* lines (default: the system clock).
|
|
181
|
+
*/
|
|
182
|
+
setClock(seconds: number): this {
|
|
183
|
+
this.fixedClock = seconds;
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
protected override clock(): number {
|
|
188
|
+
return this.fixedClock ?? super.clock();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** `--continue`/`--resolved`, `--allow-empty`, `--skip`, `--abort`, `--quit`. */
|
|
192
|
+
setResume(mode: "continue" | "resolved" | "allow-empty" | "skip" | "abort" | "quit"): this {
|
|
193
|
+
this.resume = mode === "resolved" ? "continue" : mode;
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** `-3` / `--3way` (default `am.threeWay`). */
|
|
198
|
+
setThreeWay(value: boolean): this {
|
|
199
|
+
this.threeWay = value;
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** `-s` / `--signoff`. */
|
|
204
|
+
setSignoff(value: boolean): this {
|
|
205
|
+
this.signoff = value;
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** `--keep-cr` (default `am.keepcr`). */
|
|
210
|
+
setKeepCr(value: boolean): this {
|
|
211
|
+
this.keepCr = value;
|
|
212
|
+
return this;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** `-k` (true) / `--keep-non-patch` ("non-patch"). */
|
|
216
|
+
setKeep(value: boolean | "non-patch"): this {
|
|
217
|
+
this.keep = value === "non-patch" ? "b" : value ? "t" : "f";
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** `-m` / `--message-id` (default `am.messageid`). */
|
|
222
|
+
setMessageId(value: boolean): this {
|
|
223
|
+
this.messageId = value;
|
|
224
|
+
return this;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** `-c` / `--scissors`, `--no-scissors`. */
|
|
228
|
+
setScissors(value: boolean): this {
|
|
229
|
+
this.scissors = value;
|
|
230
|
+
return this;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** `--no-verify`: the applypatch-msg and pre-applypatch hooks do not run. */
|
|
234
|
+
setNoVerify(value: boolean): this {
|
|
235
|
+
this.checkCallable();
|
|
236
|
+
this.noVerify = value;
|
|
237
|
+
return this;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** `-q`. */
|
|
241
|
+
setQuiet(value: boolean): this {
|
|
242
|
+
this.quiet = value;
|
|
243
|
+
return this;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** `-u` (default) / `-n`. */
|
|
247
|
+
setUtf8(value: boolean): this {
|
|
248
|
+
this.utf8 = value;
|
|
249
|
+
return this;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** `--ignore-date`. */
|
|
253
|
+
setIgnoreDate(value: boolean): this {
|
|
254
|
+
this.ignoreDate = value;
|
|
255
|
+
return this;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** `--committer-date-is-author-date`. */
|
|
259
|
+
setCommitterDateIsAuthorDate(value: boolean): this {
|
|
260
|
+
this.committerDateIsAuthorDate = value;
|
|
261
|
+
return this;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** `--patch-format=mboxrd`. */
|
|
265
|
+
setMboxrd(value: boolean): this {
|
|
266
|
+
this.mboxrd = value;
|
|
267
|
+
return this;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** `--empty=stop|drop|keep`. */
|
|
271
|
+
setEmpty(mode: "stop" | "drop" | "keep"): this {
|
|
272
|
+
this.emptyMode = mode;
|
|
273
|
+
return this;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** The options passed through to `git apply`. */
|
|
277
|
+
setApplyOptions(options: AmApplyOptions): this {
|
|
278
|
+
this.applyOptions = options;
|
|
279
|
+
return this;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** git before 2.46 prints the resolve advice on stdout, not as hints. */
|
|
283
|
+
setLegacyMessages(value: boolean): this {
|
|
284
|
+
this.legacyMessages = value;
|
|
285
|
+
return this;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
private state(): OperationState {
|
|
289
|
+
return new OperationState(this.workingCopy.checkout, this.refsStore);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
private say(text: string): void {
|
|
293
|
+
if (!this.quiet) this.out += `${text}\n`;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
private result(exitCode: number): AmResult {
|
|
297
|
+
return { exitCode, output: latin1ToText(this.out), errors: latin1ToText(this.err) };
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async call(): Promise<AmResult> {
|
|
301
|
+
this.checkCallable();
|
|
302
|
+
this.setCallable(false);
|
|
303
|
+
// the index as it is now, before the worktree or a ref is touched: one another writer
|
|
304
|
+
// replaced is read again (git reads the index at its start), unless this instance holds
|
|
305
|
+
// unwritten edits (refused)
|
|
306
|
+
await this.readCurrentIndex();
|
|
307
|
+
try {
|
|
308
|
+
// one worktree operation for every patch applied (attributes read once)
|
|
309
|
+
return await this.inOneOperation(() => this.run());
|
|
310
|
+
} catch (error) {
|
|
311
|
+
if (error instanceof AmStop) return this.result(error.status);
|
|
312
|
+
throw error;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
private fatal(message: string): never {
|
|
317
|
+
this.err += `fatal: ${message}\n`;
|
|
318
|
+
throw new AmStop(128);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private async read(name: string): Promise<string | undefined> {
|
|
322
|
+
const bytes = await this.workingCopy.checkout.readStateFile?.(`${DIR}/${name}`);
|
|
323
|
+
return bytes ? bytesToLatin1(bytes) : undefined;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** `write_file_buf`: the content as it is. */
|
|
327
|
+
private async write(name: string, content: string): Promise<void> {
|
|
328
|
+
await this.workingCopy.checkout.writeStateFile?.(`${DIR}/${name}`, latin1ToBytes(content));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** `write_state_text` (`write_file`): the line completed. */
|
|
332
|
+
private async writeText(name: string, content: string): Promise<void> {
|
|
333
|
+
await this.write(name, content && !content.endsWith("\n") ? `${content}\n` : content);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
private async headId(): Promise<ObjectId | undefined> {
|
|
337
|
+
return (await this.refsStore.resolve("HEAD").catch(() => undefined))?.objectId;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
private async run(): Promise<AmResult> {
|
|
341
|
+
const state = this.state();
|
|
342
|
+
const inProgress =
|
|
343
|
+
(await this.read("next")) !== undefined && (await this.read("last")) !== undefined;
|
|
344
|
+
if (inProgress) {
|
|
345
|
+
if (this.mboxes.length)
|
|
346
|
+
this.fatal(`previous rebase directory .git/${DIR} still exists but mbox given.`);
|
|
347
|
+
const mode = this.resume ?? "apply";
|
|
348
|
+
if (mode === "quit") {
|
|
349
|
+
await state.remove(DIR);
|
|
350
|
+
return this.result(0);
|
|
351
|
+
}
|
|
352
|
+
if (mode === "abort") return this.abort();
|
|
353
|
+
const st = await this.load();
|
|
354
|
+
if (mode === "skip") {
|
|
355
|
+
// am_skip: clean_index(HEAD, HEAD), then the next patch
|
|
356
|
+
const head = await this.headId();
|
|
357
|
+
await this.cleanIndex(head, head);
|
|
358
|
+
await this.next(st);
|
|
359
|
+
return this.amRun(st, false);
|
|
360
|
+
}
|
|
361
|
+
if (mode === "continue" || mode === "allow-empty")
|
|
362
|
+
return this.resolve(st, mode === "allow-empty");
|
|
363
|
+
return this.amRun(st, true);
|
|
364
|
+
}
|
|
365
|
+
if (await state.exists(DIR)) {
|
|
366
|
+
if (this.resume === "abort" || this.resume === "quit") {
|
|
367
|
+
await state.remove(DIR);
|
|
368
|
+
return this.result(0);
|
|
369
|
+
}
|
|
370
|
+
this.fatal(`Stray .git/${DIR} directory found.\nUse "git am --abort" to remove it.`);
|
|
371
|
+
}
|
|
372
|
+
if (this.resume) this.fatal("Resolve operation not in progress, we are not resuming.");
|
|
373
|
+
return this.setup();
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
private async setup(): Promise<AmResult> {
|
|
377
|
+
const state = this.state();
|
|
378
|
+
const bool = (k: string) => {
|
|
379
|
+
const v = configValue(this.workingCopy, k)?.toLowerCase();
|
|
380
|
+
return v === undefined ? undefined : ["true", "yes", "on", "1", ""].includes(v);
|
|
381
|
+
};
|
|
382
|
+
const threeway = this.threeWay ?? bool("am.threeWay") ?? false;
|
|
383
|
+
const keepCr = this.keepCr ?? bool("am.keepcr") ?? false;
|
|
384
|
+
const messageId = this.messageId ?? bool("am.messageid") ?? false;
|
|
385
|
+
// detect_patch_format: standard input is a mailbox, a file is looked at
|
|
386
|
+
const first = this.mboxes[0];
|
|
387
|
+
const format =
|
|
388
|
+
this.patchFormat ??
|
|
389
|
+
(this.mboxrd
|
|
390
|
+
? "mboxrd"
|
|
391
|
+
: first?.name !== undefined
|
|
392
|
+
? detectPatchFormat(first.content)
|
|
393
|
+
: "mbox");
|
|
394
|
+
if (!format) {
|
|
395
|
+
this.err += "Patch format detection failed.\n";
|
|
396
|
+
throw new AmStop(128);
|
|
397
|
+
}
|
|
398
|
+
await state.deleteRef("REBASE_HEAD");
|
|
399
|
+
const mails: string[] = [];
|
|
400
|
+
const failSplit = (error: string): never => {
|
|
401
|
+
this.err += `error: ${error}\n`;
|
|
402
|
+
this.fatal("Failed to split patches.");
|
|
403
|
+
};
|
|
404
|
+
const inputs = this.mboxes.length ? this.mboxes : [{ content: "" }];
|
|
405
|
+
if (format === "mbox" || format === "mboxrd") {
|
|
406
|
+
for (const mbox of inputs) {
|
|
407
|
+
// mailsplit: an empty file (git's isspace: space, tab, LF, CR) is an error, empty
|
|
408
|
+
// standard input is not
|
|
409
|
+
if (mbox.name !== undefined && /^[ \t\n\r]*$/.test(mbox.content)) {
|
|
410
|
+
this.err += `error: empty mbox: '${mbox.name}'\n`;
|
|
411
|
+
failSplit(`cannot split patches from ${mbox.name}`);
|
|
412
|
+
}
|
|
413
|
+
mails.push(...mailsplit(mbox.content, { keepCr, mboxrd: format === "mboxrd" }));
|
|
414
|
+
}
|
|
415
|
+
} else if (format === "stgit-series") {
|
|
416
|
+
// split_mail_stgit_series: one named series file, whose patches are files next to it
|
|
417
|
+
// (this command reads no files: the first one cannot be opened)
|
|
418
|
+
const series = this.mboxes.length === 1 ? this.mboxes[0] : undefined;
|
|
419
|
+
if (!series || series.name === undefined)
|
|
420
|
+
failSplit("Only one StGIT patch series can be applied at once");
|
|
421
|
+
const { name, content } = series as { name: string; content: string };
|
|
422
|
+
const slash = name.replace(/\/+$/, "").lastIndexOf("/");
|
|
423
|
+
const dir = slash < 0 ? "." : slash === 0 ? "/" : name.slice(0, slash);
|
|
424
|
+
const first = content
|
|
425
|
+
.split("\n")
|
|
426
|
+
.find((l, i, all) => !l.startsWith("#") && (l || i < all.length - 1));
|
|
427
|
+
if (first !== undefined)
|
|
428
|
+
failSplit(`could not open '${dir}/${first}' for reading: No such file or directory`);
|
|
429
|
+
// no patches: split_mail_conv reads standard input
|
|
430
|
+
mails.push(stgitPatchToMail(""));
|
|
431
|
+
} else {
|
|
432
|
+
for (const mbox of inputs) {
|
|
433
|
+
if (format === "stgit") mails.push(stgitPatchToMail(mbox.content));
|
|
434
|
+
else {
|
|
435
|
+
const r = hgPatchToMail(mbox.content);
|
|
436
|
+
if ("error" in r) {
|
|
437
|
+
this.err += `error: ${r.error}\n`;
|
|
438
|
+
failSplit(`could not parse patch '${mbox.name ?? "-"}'`);
|
|
439
|
+
}
|
|
440
|
+
mails.push((r as { mail: string }).mail);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
let n = 0;
|
|
445
|
+
for (const mail of mails) await this.write(String(++n).padStart(4, "0"), mail);
|
|
446
|
+
await this.writeText("threeway", threeway ? "t" : "f");
|
|
447
|
+
await this.writeText("quiet", this.quiet ? "t" : "f");
|
|
448
|
+
await this.writeText("sign", this.signoff ? "t" : "f");
|
|
449
|
+
await this.writeText("utf8", this.utf8 ? "t" : "f");
|
|
450
|
+
await this.writeText("keep", this.keep);
|
|
451
|
+
await this.writeText("messageid", messageId ? "t" : "f");
|
|
452
|
+
await this.writeText("scissors", this.scissors === undefined ? "" : this.scissors ? "t" : "f");
|
|
453
|
+
await this.writeText("quoted-cr", "");
|
|
454
|
+
await this.writeText(
|
|
455
|
+
"apply-opt",
|
|
456
|
+
this.applyArgs()
|
|
457
|
+
.map((a) => ` ${sqQuote(a)}`)
|
|
458
|
+
.join(""),
|
|
459
|
+
);
|
|
460
|
+
await this.writeText("applying", "");
|
|
461
|
+
const head = await this.headId();
|
|
462
|
+
if (head) {
|
|
463
|
+
await this.writeText("abort-safety", head);
|
|
464
|
+
await state.setRef("ORIG_HEAD", head);
|
|
465
|
+
} else {
|
|
466
|
+
await this.writeText("abort-safety", "");
|
|
467
|
+
await state.removeRef("ORIG_HEAD");
|
|
468
|
+
}
|
|
469
|
+
await this.writeText("next", "1");
|
|
470
|
+
await this.writeText("last", String(n));
|
|
471
|
+
return this.amRun(await this.load(), false);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
private applyArgs(): string[] {
|
|
475
|
+
const o = this.applyOptions;
|
|
476
|
+
const args: string[] = [];
|
|
477
|
+
if (o.context !== undefined) args.push(`-C${o.context}`);
|
|
478
|
+
if (o.strip !== undefined) args.push(`-p${o.strip}`);
|
|
479
|
+
if (o.whitespace !== undefined) args.push(`--whitespace=${o.whitespace}`);
|
|
480
|
+
if (o.directory !== undefined) args.push(`--directory=${o.directory}`);
|
|
481
|
+
for (const e of o.exclude ?? []) args.push(`--exclude=${e}`);
|
|
482
|
+
for (const e of o.include ?? []) args.push(`--include=${e}`);
|
|
483
|
+
if (o.reject) args.push("--reject");
|
|
484
|
+
if (o.ignoreWhitespace) args.push("--ignore-whitespace");
|
|
485
|
+
return args;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
private async load(): Promise<AmState> {
|
|
489
|
+
const t = async (name: string) => (await this.read(name))?.trim() ?? "";
|
|
490
|
+
const st: AmState = {
|
|
491
|
+
cur: Number.parseInt(await t("next"), 10),
|
|
492
|
+
last: Number.parseInt(await t("last"), 10),
|
|
493
|
+
threeway: (await t("threeway")) === "t",
|
|
494
|
+
quiet: (await t("quiet")) === "t",
|
|
495
|
+
signoff: (await t("sign")) === "t",
|
|
496
|
+
utf8: (await t("utf8")) === "t",
|
|
497
|
+
keep: ((await t("keep")) || "f") as "t" | "b" | "f",
|
|
498
|
+
messageId: (await t("messageid")) === "t",
|
|
499
|
+
scissors: await t("scissors"),
|
|
500
|
+
applyOpts: sqDequoteAll(await t("apply-opt")),
|
|
501
|
+
};
|
|
502
|
+
const script = await this.read("author-script");
|
|
503
|
+
if (script !== undefined) {
|
|
504
|
+
const get = (k: string) => {
|
|
505
|
+
const m = new RegExp(`^${k}=(.*)$`, "m").exec(script);
|
|
506
|
+
return m ? (sqDequoteAll(m[1] as string)[0] ?? "") : undefined;
|
|
507
|
+
};
|
|
508
|
+
st.author = {
|
|
509
|
+
name: get("GIT_AUTHOR_NAME") ?? "",
|
|
510
|
+
email: get("GIT_AUTHOR_EMAIL") ?? "",
|
|
511
|
+
date: get("GIT_AUTHOR_DATE") ?? "",
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
st.msg = await this.read("final-commit");
|
|
515
|
+
this.quiet = st.quiet;
|
|
516
|
+
return st;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
private async next(st: AmState): Promise<void> {
|
|
520
|
+
const state = this.state();
|
|
521
|
+
st.author = undefined;
|
|
522
|
+
st.msg = undefined;
|
|
523
|
+
await state.remove(`${DIR}/author-script`, `${DIR}/final-commit`, `${DIR}/original-commit`);
|
|
524
|
+
// am_next: REBASE_HEAD deleted whether it exists or not (the hook hears it either way)
|
|
525
|
+
await state.deleteRef("REBASE_HEAD");
|
|
526
|
+
await this.writeText("abort-safety", (await this.headId()) ?? "");
|
|
527
|
+
st.cur++;
|
|
528
|
+
await this.writeText("next", String(st.cur));
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
private firstLine(msg: string): string {
|
|
532
|
+
const nl = msg.indexOf("\n");
|
|
533
|
+
return nl < 0 ? msg : msg.slice(0, nl);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
private async indexHasChanges(): Promise<string[]> {
|
|
537
|
+
const head = await this.headId();
|
|
538
|
+
const tree = head ? (await this.commits.load(head))?.tree : undefined;
|
|
539
|
+
const { index } = await readIndex(this.staging);
|
|
540
|
+
return indexChangesFromTree(index, this.trees, tree);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/** `die_user_resolve`: the advice, then the stop. */
|
|
544
|
+
private async dieUserResolve(): Promise<never> {
|
|
545
|
+
const bool = (k: string) => {
|
|
546
|
+
const v = configValue(this.workingCopy, k)?.toLowerCase();
|
|
547
|
+
return v === undefined ? undefined : ["true", "yes", "on", "1", ""].includes(v);
|
|
548
|
+
};
|
|
549
|
+
const patchEmptyAndClean =
|
|
550
|
+
bool("advice.amWorkDir") !== false &&
|
|
551
|
+
(await this.patchIsEmpty()) &&
|
|
552
|
+
(await this.indexHasChanges()).length === 0;
|
|
553
|
+
if (bool("advice.mergeConflict") === false && !this.legacyMessages) throw new AmStop(128);
|
|
554
|
+
const lines = [
|
|
555
|
+
'When you have resolved this problem, run "git am --continue".',
|
|
556
|
+
'If you prefer to skip this patch, run "git am --skip" instead.',
|
|
557
|
+
...(patchEmptyAndClean
|
|
558
|
+
? ['To record the empty patch as an empty commit, run "git am --allow-empty".']
|
|
559
|
+
: []),
|
|
560
|
+
'To restore the original branch and stop patching, run "git am --abort".',
|
|
561
|
+
];
|
|
562
|
+
if (this.legacyMessages) this.out += `${lines.join("\n")}\n`;
|
|
563
|
+
else {
|
|
564
|
+
for (const l of lines) this.err += `hint: ${l}\n`;
|
|
565
|
+
this.err += 'hint: Disable this message with "git config set advice.mergeConflict false"\n';
|
|
566
|
+
}
|
|
567
|
+
throw new AmStop(128);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
private async patchIsEmpty(): Promise<boolean> {
|
|
571
|
+
const p = await this.read("patch");
|
|
572
|
+
return p === undefined || p.length === 0;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
private async amRun(st: AmState, resume0: boolean): Promise<AmResult> {
|
|
576
|
+
const state = this.state();
|
|
577
|
+
let resume = resume0;
|
|
578
|
+
await state.remove(`${DIR}/dirtyindex`);
|
|
579
|
+
const dirty = await this.indexHasChanges();
|
|
580
|
+
if (dirty.length) {
|
|
581
|
+
await this.writeText("dirtyindex", "t");
|
|
582
|
+
this.fatal(`Dirty index: cannot apply patches (dirty: ${dirty.join(" ")})`);
|
|
583
|
+
}
|
|
584
|
+
while (st.cur <= st.last) {
|
|
585
|
+
const name = String(st.cur).padStart(4, "0");
|
|
586
|
+
const mail = await this.read(name);
|
|
587
|
+
if (mail === undefined) {
|
|
588
|
+
await this.next(st);
|
|
589
|
+
resume = false;
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
if (resume) {
|
|
593
|
+
if (st.msg === undefined)
|
|
594
|
+
this.fatal(`cannot resume: .git/${DIR}/final-commit does not exist.`);
|
|
595
|
+
if (!st.author) this.fatal(`cannot resume: .git/${DIR}/author-script does not exist.`);
|
|
596
|
+
} else {
|
|
597
|
+
const mi = mailinfo(mail, {
|
|
598
|
+
keepSubject: st.keep === "t",
|
|
599
|
+
keepNonPatchBrackets: st.keep === "b",
|
|
600
|
+
addMessageId: st.messageId,
|
|
601
|
+
...(st.scissors ? { useScissors: st.scissors === "t" } : {}),
|
|
602
|
+
utf8: st.utf8,
|
|
603
|
+
// metainfo_charset: get_commit_output_encoding()
|
|
604
|
+
charset: configValue(this.workingCopy, "i18n.commitEncoding") ?? "UTF-8",
|
|
605
|
+
});
|
|
606
|
+
await this.write("info", mi.info);
|
|
607
|
+
await this.write("msg", mi.msg);
|
|
608
|
+
await this.write("patch", mi.patch);
|
|
609
|
+
this.err += mi.errors;
|
|
610
|
+
if (mi.failed) this.fatal("could not parse patch");
|
|
611
|
+
if (mi.formatFlowed)
|
|
612
|
+
this.err +=
|
|
613
|
+
"warning: Patch sent with format=flowed; space at the end of lines might be lost.\n";
|
|
614
|
+
if (mi.author === "Mail System Internal Data") {
|
|
615
|
+
await this.next(st);
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
let msg = `${mi.subject}\n\n${mi.msg}`;
|
|
619
|
+
msg = stripspace(msg);
|
|
620
|
+
if (st.signoff) {
|
|
621
|
+
const c = this.resolveCommitter();
|
|
622
|
+
msg = appendSignoff(msg, pathToLatin1(`Signed-off-by: ${c.name} <${c.email}>\n`));
|
|
623
|
+
}
|
|
624
|
+
st.author = { name: mi.author, email: mi.email, date: mi.date };
|
|
625
|
+
st.msg = msg;
|
|
626
|
+
await this.writeText(
|
|
627
|
+
"author-script",
|
|
628
|
+
`GIT_AUTHOR_NAME=${sqQuote(mi.author)}\nGIT_AUTHOR_EMAIL=${sqQuote(mi.email)}\nGIT_AUTHOR_DATE=${sqQuote(mi.date)}\n`,
|
|
629
|
+
);
|
|
630
|
+
await this.write("final-commit", msg);
|
|
631
|
+
}
|
|
632
|
+
let msg = st.msg as string;
|
|
633
|
+
let toKeep = false;
|
|
634
|
+
if (await this.patchIsEmpty()) {
|
|
635
|
+
if (this.emptyMode === "drop") {
|
|
636
|
+
this.say(`Skipping: ${this.firstLine(msg)}`);
|
|
637
|
+
await this.next(st);
|
|
638
|
+
resume = false;
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
if (this.emptyMode === "keep") {
|
|
642
|
+
toKeep = true;
|
|
643
|
+
this.say(`Creating an empty commit: ${this.firstLine(msg)}`);
|
|
644
|
+
} else {
|
|
645
|
+
this.out += "Patch is empty.\n";
|
|
646
|
+
await this.dieUserResolve();
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
// run_applypatch_msg_hook (not with --no-verify): it may edit final-commit, which is
|
|
650
|
+
// read back; a refusal stops the am with its state kept
|
|
651
|
+
if (!this.noVerify) {
|
|
652
|
+
const hooked = await this.runAmHook("applypatch-msg", [
|
|
653
|
+
await this.hooks.gitPath(`${DIR}/final-commit`),
|
|
654
|
+
]);
|
|
655
|
+
if (hooked && hooked.exitCode !== 0) throw new AmStop(1);
|
|
656
|
+
}
|
|
657
|
+
if (this.hooks.enabled) {
|
|
658
|
+
const text = await this.read("final-commit");
|
|
659
|
+
if (text === undefined) {
|
|
660
|
+
this.fatal(`'.git/${DIR}/final-commit' was deleted by the applypatch-msg hook`);
|
|
661
|
+
}
|
|
662
|
+
msg = text;
|
|
663
|
+
st.msg = text;
|
|
664
|
+
}
|
|
665
|
+
if (!toKeep) {
|
|
666
|
+
this.say(`Applying: ${this.firstLine(msg)}`);
|
|
667
|
+
let status = await this.runApply(st);
|
|
668
|
+
if (status && st.threeway) {
|
|
669
|
+
status = await this.fallBackThreeway(st, msg);
|
|
670
|
+
// the patch applied to an earlier tree merges into what HEAD has already
|
|
671
|
+
if (!status && !(await this.indexHasChanges()).length) {
|
|
672
|
+
this.say("No changes -- Patch already applied.");
|
|
673
|
+
await this.next(st);
|
|
674
|
+
resume = false;
|
|
675
|
+
continue;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
if (status) {
|
|
679
|
+
this.out += `Patch failed at ${name} ${this.firstLine(msg)}\n`;
|
|
680
|
+
this.err += "hint: Use 'git am --show-current-patch=diff' to see the failed patch\n";
|
|
681
|
+
await this.dieUserResolve();
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
await this.doCommit(st);
|
|
685
|
+
await this.next(st);
|
|
686
|
+
resume = false;
|
|
687
|
+
}
|
|
688
|
+
await state.remove(DIR);
|
|
689
|
+
return this.result(0);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
private async runApply(st: AmState): Promise<number> {
|
|
693
|
+
const patch = (await this.read("patch")) ?? "";
|
|
694
|
+
const cmd = new ApplyCommand(this.workingCopy)
|
|
695
|
+
.addPatch(latin1ToBytes(patch), `.git/${DIR}/patch`)
|
|
696
|
+
.setIndex(true)
|
|
697
|
+
.setLegacyMessages(this.legacyMessages);
|
|
698
|
+
for (const a of st.applyOpts) {
|
|
699
|
+
if (a.startsWith("-C")) cmd.setContext(Number(a.slice(2)));
|
|
700
|
+
else if (a.startsWith("-p")) cmd.setStrip(Number(a.slice(2)));
|
|
701
|
+
else if (a.startsWith("--whitespace=")) cmd.setWhitespace(a.slice(13));
|
|
702
|
+
else if (a.startsWith("--directory=")) cmd.setDirectory(a.slice(12));
|
|
703
|
+
else if (a.startsWith("--exclude=")) cmd.addExclude(a.slice(10));
|
|
704
|
+
else if (a.startsWith("--include=")) cmd.addInclude(a.slice(10));
|
|
705
|
+
else if (a === "--reject") cmd.setReject(true);
|
|
706
|
+
else if (a === "--ignore-whitespace") cmd.setIgnoreWhitespace(true);
|
|
707
|
+
}
|
|
708
|
+
if (st.threeway) cmd.setVerbose(false);
|
|
709
|
+
const r = await cmd.call();
|
|
710
|
+
this.out += pathToLatin1(r.output);
|
|
711
|
+
this.err += pathToLatin1(r.errors);
|
|
712
|
+
return r.exitCode;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/** `fall_back_threeway`: the patch applied to the blobs it names, merged into HEAD. */
|
|
716
|
+
private async fallBackThreeway(st: AmState, msg: string): Promise<number> {
|
|
717
|
+
const head = await this.headId();
|
|
718
|
+
const ourTree = head ? (await this.commits.load(head))?.tree : undefined;
|
|
719
|
+
const patch = (await this.read("patch")) ?? "";
|
|
720
|
+
// build_fake_ancestor (git apply --build-fake-ancestor)
|
|
721
|
+
const parser = new ApplyEngine(
|
|
722
|
+
undefined as unknown as ApplyIO,
|
|
723
|
+
() => undefined,
|
|
724
|
+
async () => 0,
|
|
725
|
+
() => false,
|
|
726
|
+
);
|
|
727
|
+
for (const a of st.applyOpts) {
|
|
728
|
+
if (a.startsWith("-p")) {
|
|
729
|
+
parser.pValue = Number(a.slice(2));
|
|
730
|
+
parser.pValueKnown = true;
|
|
731
|
+
} else if (a.startsWith("--directory="))
|
|
732
|
+
parser.root = pathToLatin1(`${a.slice(12).replace(/\/?$/, "/")}`);
|
|
733
|
+
}
|
|
734
|
+
parser.apply = false;
|
|
735
|
+
const list = await parser.parsePatches({
|
|
736
|
+
text: patch,
|
|
737
|
+
name: `.git/${DIR}/patch`,
|
|
738
|
+
fromFile: true,
|
|
739
|
+
});
|
|
740
|
+
this.err += parser.stderr;
|
|
741
|
+
const fake = new Map<string, { mode: number; objectId: string }>();
|
|
742
|
+
const resolver = this.revisionResolver();
|
|
743
|
+
let failed: string | undefined = typeof list === "number" ? "" : undefined;
|
|
744
|
+
const { index } = await readIndex(this.staging);
|
|
745
|
+
for (const p of typeof list === "number" ? [] : list) {
|
|
746
|
+
const name = latin1ToPath((p.oldName ?? p.newName) as string);
|
|
747
|
+
if (p.isNew > 0) continue;
|
|
748
|
+
let oid: string | undefined;
|
|
749
|
+
try {
|
|
750
|
+
oid = /^[0-9a-f]{4,64}$/.test(p.oldOidPrefix)
|
|
751
|
+
? await resolver.resolve(p.oldOidPrefix)
|
|
752
|
+
: undefined;
|
|
753
|
+
if (oid && !(await this.blobs.has(oid))) oid = undefined;
|
|
754
|
+
} catch {
|
|
755
|
+
oid = undefined;
|
|
756
|
+
}
|
|
757
|
+
if (!oid) {
|
|
758
|
+
if (!p.linesAdded && !p.linesDeleted) {
|
|
759
|
+
oid = index.get(latin1ToPath(p.oldName as string))?.objectId;
|
|
760
|
+
if (!oid) {
|
|
761
|
+
failed = `mode change for ${name}, which is not in current HEAD`;
|
|
762
|
+
break;
|
|
763
|
+
}
|
|
764
|
+
} else {
|
|
765
|
+
failed = `sha1 information is lacking or useless (${name}).`;
|
|
766
|
+
break;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
// make_cache_entry's create_ce_mode: a pure rename carries no mode, a regular file's
|
|
770
|
+
// permissions collapse to 644 or 755
|
|
771
|
+
const m = p.oldMode;
|
|
772
|
+
const mode =
|
|
773
|
+
(m & 0o170000) === 0o120000
|
|
774
|
+
? 0o120000
|
|
775
|
+
: (m & 0o170000) === 0o040000 || (m & 0o170000) === 0o160000
|
|
776
|
+
? 0o160000
|
|
777
|
+
: m & 0o100
|
|
778
|
+
? 0o100755
|
|
779
|
+
: 0o100644;
|
|
780
|
+
fake.set(name, { mode, objectId: oid });
|
|
781
|
+
}
|
|
782
|
+
if (failed !== undefined) {
|
|
783
|
+
if (failed) this.err += `error: ${failed}\n`;
|
|
784
|
+
this.err += "error: could not build fake ancestor\n";
|
|
785
|
+
return 1;
|
|
786
|
+
}
|
|
787
|
+
const flatOf = (m: Map<string, { mode: number; objectId: string }>) =>
|
|
788
|
+
new Map([...m].map(([k, v]) => [k, { mode: v.mode, objectId: v.objectId }] as const));
|
|
789
|
+
const baseTree = await storeFlatTree(this.trees, flatOf(fake));
|
|
790
|
+
this.say("Using index info to reconstruct a base tree...");
|
|
791
|
+
if (!this.quiet) {
|
|
792
|
+
const ours = await flatTree(this.trees, ourTree);
|
|
793
|
+
for (const path of [...fake.keys()].sort(compareGitPaths)) {
|
|
794
|
+
const e = fake.get(path) as { mode: number; objectId: string };
|
|
795
|
+
const o = ours.get(path);
|
|
796
|
+
if (!o) this.out += `A\t${pathToLatin1(quotePath(path))}\n`;
|
|
797
|
+
else if (o.objectId !== e.objectId || o.mode !== e.mode)
|
|
798
|
+
this.out += `M\t${pathToLatin1(quotePath(path))}\n`;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
// run_apply on the fake ancestor's index
|
|
802
|
+
const apply = new ApplyCommand(this.workingCopy)
|
|
803
|
+
.addPatch(latin1ToBytes(patch), `.git/${DIR}/patch`)
|
|
804
|
+
.setTemporaryIndex(fake)
|
|
805
|
+
.setLegacyMessages(this.legacyMessages);
|
|
806
|
+
for (const a of st.applyOpts) {
|
|
807
|
+
if (a.startsWith("-C")) apply.setContext(Number(a.slice(2)));
|
|
808
|
+
else if (a.startsWith("-p")) apply.setStrip(Number(a.slice(2)));
|
|
809
|
+
else if (a.startsWith("--whitespace=")) apply.setWhitespace(a.slice(13));
|
|
810
|
+
else if (a.startsWith("--directory=")) apply.setDirectory(a.slice(12));
|
|
811
|
+
}
|
|
812
|
+
const applied = await apply.call();
|
|
813
|
+
this.out += pathToLatin1(applied.output);
|
|
814
|
+
this.err += pathToLatin1(applied.errors);
|
|
815
|
+
if (applied.exitCode || !applied.index) {
|
|
816
|
+
this.err +=
|
|
817
|
+
"error: Did you hand edit your patch?\nIt does not apply to blobs recorded in its index.\n";
|
|
818
|
+
return 1;
|
|
819
|
+
}
|
|
820
|
+
const theirTree = await storeFlatTree(this.trees, flatOf(applied.index));
|
|
821
|
+
this.say("Falling back to patching base and 3-way merge...");
|
|
822
|
+
const subject = latin1ToPath(this.firstLine(msg));
|
|
823
|
+
const merge = await mergeStoredTrees(
|
|
824
|
+
{ trees: this.trees, blobs: this.blobs },
|
|
825
|
+
storedBase(baseTree, "constructed fake ancestor", () => flatTree(this.trees, baseTree)),
|
|
826
|
+
ourTree,
|
|
827
|
+
theirTree,
|
|
828
|
+
{
|
|
829
|
+
oursLabel: "HEAD",
|
|
830
|
+
theirsLabel: subject,
|
|
831
|
+
baseLabel: "constructed fake ancestor",
|
|
832
|
+
style: conflictStyleOf(this.workingCopy),
|
|
833
|
+
ignoreCase: coreBool(this.workingCopy, "ignorecase", false),
|
|
834
|
+
...ortConfigOptions(this.workingCopy, this.worktreeAccess),
|
|
835
|
+
directoryRenames: "false",
|
|
836
|
+
},
|
|
837
|
+
);
|
|
838
|
+
const target = await ortResultEntries(this.blobs, merge);
|
|
839
|
+
const treeId = await storeFlatTreeOver(this.trees, ourTree, merge.ours, target);
|
|
840
|
+
const conflicts = [...merge.conflicts.values()];
|
|
841
|
+
const delta = await treeDelta(this.trees, ourTree, treeId);
|
|
842
|
+
const refused = await switchTrees(this.sequencerContext(), delta.from, delta.to, {
|
|
843
|
+
action: "merge",
|
|
844
|
+
operation: "merge",
|
|
845
|
+
conflicts,
|
|
846
|
+
targetTree: treeId,
|
|
847
|
+
});
|
|
848
|
+
if (refused) {
|
|
849
|
+
this.err += `${pathToLatin1(refused.message)}\n`;
|
|
850
|
+
this.err += "error: Failed to merge in the changes.\n";
|
|
851
|
+
return 1;
|
|
852
|
+
}
|
|
853
|
+
if (!this.quiet) for (const m of merge.messages) this.out += `${pathToLatin1(m)}\n`;
|
|
854
|
+
if (conflicts.length || !merge.clean) {
|
|
855
|
+
await this.state().setRef("AUTO_MERGE", treeId);
|
|
856
|
+
this.err += "error: Failed to merge in the changes.\n";
|
|
857
|
+
return 1;
|
|
858
|
+
}
|
|
859
|
+
return 0;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/** Runs an am hook, its output (git's stderr) added to the am's in order. */
|
|
863
|
+
private async runAmHook(name: string, args: string[] = []) {
|
|
864
|
+
if (!this.hooks.enabled) return undefined;
|
|
865
|
+
const before = this.hooks.output.length;
|
|
866
|
+
const result = await this.hooks.run(name, { args });
|
|
867
|
+
this.err += this.hooks.output.slice(before);
|
|
868
|
+
return result;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
private async doCommit(st: AmState): Promise<void> {
|
|
872
|
+
// do_commit's pre-applypatch (not with --no-verify): a refusal exits 1, the patch applied
|
|
873
|
+
// and the am stopped (the index git commits is the one in memory: what the hook changed
|
|
874
|
+
// in the index file is not seen)
|
|
875
|
+
if (!this.noVerify && this.hooks.enabled) {
|
|
876
|
+
const pre = await this.runAmHook("pre-applypatch");
|
|
877
|
+
if (pre && pre.exitCode !== 0) throw new AmStop(1);
|
|
878
|
+
}
|
|
879
|
+
const tree = await this.staging.writeTree(this.trees);
|
|
880
|
+
const head = await this.headId();
|
|
881
|
+
if (!head) {
|
|
882
|
+
if (!this.quiet) this.err += "applying to an empty history\n";
|
|
883
|
+
}
|
|
884
|
+
const a = st.author as { name: string; email: string; date: string };
|
|
885
|
+
if (!a.name) this.fatal(`empty ident name (for <${a.email}>) not allowed`);
|
|
886
|
+
if (!withoutCrud(a.name)) this.fatal(`name consists only of disallowed characters: ${a.name}`);
|
|
887
|
+
// fmt_ident: crud trimmed; no date (--ignore-date, a mail without Date:) is now, not
|
|
888
|
+
// GIT_AUTHOR_DATE
|
|
889
|
+
const date = this.ignoreDate ? "" : a.date;
|
|
890
|
+
const parsed = date ? parseGitDate(date) : undefined;
|
|
891
|
+
if (date && !parsed) this.fatal(`invalid date format: ${date}`);
|
|
892
|
+
const now = this.clock();
|
|
893
|
+
let author: PersonIdent = {
|
|
894
|
+
name: withoutCrud(a.name),
|
|
895
|
+
email: withoutCrud(a.email),
|
|
896
|
+
...(parsed ?? { timestamp: now, tzOffset: localTimezoneOffset(now) }),
|
|
897
|
+
};
|
|
898
|
+
let committer = this.resolveCommitter();
|
|
899
|
+
if (this.committerDateIsAuthorDate)
|
|
900
|
+
committer = { ...committer, timestamp: author.timestamp, tzOffset: author.tzOffset };
|
|
901
|
+
// commit_tree's ensure_utf8: bytes that are not UTF-8 read as Latin-1
|
|
902
|
+
let msg = st.msg as string;
|
|
903
|
+
const commitEncoding = configValue(this.workingCopy, "i18n.commitEncoding");
|
|
904
|
+
if (isUtf8Encoding(commitEncoding)) {
|
|
905
|
+
const fixed = [author.name, author.email, msg].map(ensureUtf8);
|
|
906
|
+
const committerFixed = [committer.name, committer.email].map((v) =>
|
|
907
|
+
ensureUtf8(pathToLatin1(v)),
|
|
908
|
+
);
|
|
909
|
+
if ([...fixed, ...committerFixed].some((f) => f.changed)) {
|
|
910
|
+
this.err +=
|
|
911
|
+
"Warning: commit message did not conform to UTF-8.\nYou may want to amend it after fixing the message, or set the config\nvariable i18n.commitEncoding to the encoding your project uses.\n";
|
|
912
|
+
}
|
|
913
|
+
author = { ...author, name: (fixed[0] as Fixed).text, email: (fixed[1] as Fixed).text };
|
|
914
|
+
msg = (fixed[2] as Fixed).text;
|
|
915
|
+
committer = {
|
|
916
|
+
...committer,
|
|
917
|
+
name: latin1ToPath((committerFixed[0] as Fixed).text),
|
|
918
|
+
email: latin1ToPath((committerFixed[1] as Fixed).text),
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
author = { ...author, name: latin1ToPath(author.name), email: latin1ToPath(author.email) };
|
|
922
|
+
const message = latin1ToPath(msg);
|
|
923
|
+
const parents = head ? [head] : [];
|
|
924
|
+
const objects = this.workingCopy.history?.objects;
|
|
925
|
+
let id: ObjectId;
|
|
926
|
+
if (!isUtf8Encoding(commitEncoding) && objects) {
|
|
927
|
+
// commit_tree_extended: the `encoding` header, the message and idents as their bytes
|
|
928
|
+
let text = `tree ${tree}\n`;
|
|
929
|
+
for (const p of parents) text += `parent ${p}\n`;
|
|
930
|
+
text += `author ${formatPersonIdent(author)}\ncommitter ${formatPersonIdent(committer)}\n`;
|
|
931
|
+
text += `encoding ${commitEncoding}\n\n${message}`;
|
|
932
|
+
id = await objects.putUnsized("commit", [encodeGitPath(text)]);
|
|
933
|
+
} else {
|
|
934
|
+
id = await this.commits.store({ tree, parents, author, committer, message });
|
|
935
|
+
}
|
|
936
|
+
const action = this.reflogAction("am");
|
|
937
|
+
// do_commit's update_ref("HEAD", commit, old_oid): HEAD expecting the commit it left
|
|
938
|
+
await updateHeadExpecting(
|
|
939
|
+
this.refsStore,
|
|
940
|
+
id,
|
|
941
|
+
head,
|
|
942
|
+
// the subject as the mail had it, before commit_tree's UTF-8 fixup
|
|
943
|
+
this.reflogLine(`${action}: ${latin1ToPath(this.firstLine(st.msg as string))}`, committer),
|
|
944
|
+
);
|
|
945
|
+
await this.runAmHook("post-applypatch");
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
private async resolve(st: AmState, allowEmpty: boolean): Promise<AmResult> {
|
|
949
|
+
if (st.msg === undefined) this.fatal(`cannot resume: .git/${DIR}/final-commit does not exist.`);
|
|
950
|
+
if (!st.author) this.fatal(`cannot resume: .git/${DIR}/author-script does not exist.`);
|
|
951
|
+
this.say(`Applying: ${this.firstLine(st.msg)}`);
|
|
952
|
+
if (!(await this.indexHasChanges()).length) {
|
|
953
|
+
if (allowEmpty && (await this.patchIsEmpty())) {
|
|
954
|
+
this.out += "No changes - recorded it as an empty commit.\n";
|
|
955
|
+
} else {
|
|
956
|
+
this.out +=
|
|
957
|
+
"No changes - did you forget to use 'git add'?\nIf there is nothing left to stage, chances are that something else\nalready introduced the same changes; you might want to skip this patch.\n";
|
|
958
|
+
await this.dieUserResolve();
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
const { unmerged } = await readIndex(this.staging);
|
|
962
|
+
if (unmerged.length) {
|
|
963
|
+
this.out +=
|
|
964
|
+
"You still have unmerged paths in your index.\nYou should 'git add' each file with resolved conflicts to mark them as such.\nYou might run `git rm` on a file to accept \"deleted by them\" for it.\n";
|
|
965
|
+
await this.dieUserResolve();
|
|
966
|
+
}
|
|
967
|
+
await this.doCommit(st);
|
|
968
|
+
await this.next(st);
|
|
969
|
+
return this.amRun(await this.load(), false);
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
private async abort(): Promise<AmResult> {
|
|
973
|
+
const state = this.state();
|
|
974
|
+
const head = await this.headId();
|
|
975
|
+
const safety = (await this.read("abort-safety"))?.trim() ?? "";
|
|
976
|
+
if ((await this.read("dirtyindex")) !== undefined || (head ?? "") !== safety) {
|
|
977
|
+
if ((await this.read("dirtyindex")) === undefined)
|
|
978
|
+
this.err +=
|
|
979
|
+
"warning: You seem to have moved HEAD since the last 'am' failure.\nNot rewinding to ORIG_HEAD\n";
|
|
980
|
+
await state.remove(DIR);
|
|
981
|
+
return this.result(0);
|
|
982
|
+
}
|
|
983
|
+
const orig = await state.ref("ORIG_HEAD");
|
|
984
|
+
await this.cleanIndex(head, orig ?? head);
|
|
985
|
+
if (orig) await updateHead(this.refsStore, orig, this.reflogLine("am --abort"));
|
|
986
|
+
await state.remove(DIR);
|
|
987
|
+
return this.result(0);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* git's `clean_index(head, remote)` (`am --skip`, `am --abort`): conflicted entries reset to
|
|
992
|
+
* HEAD (a two-way merge from HEAD to HEAD that leaves every other entry, staged changes and
|
|
993
|
+
* deletions included, as it is), then the index moved to `remote` (a two-way merge from
|
|
994
|
+
* the index's own tree, so a one-way reset with git's up-to-date and untracked checks),
|
|
995
|
+
* then a merge in progress forgotten (`remove_branch_state`). A refusal prints
|
|
996
|
+
* unpack-trees' error, then dies with "failed to clean index".
|
|
997
|
+
*/
|
|
998
|
+
private async cleanIndex(head: ObjectId | undefined, remote: ObjectId | undefined) {
|
|
999
|
+
const ctx = this.sequencerContext();
|
|
1000
|
+
await resetUnmergedToHead(ctx, head);
|
|
1001
|
+
if (remote) {
|
|
1002
|
+
const refused = await resetMerge(ctx, remote, "HEAD");
|
|
1003
|
+
if (refused) {
|
|
1004
|
+
this.err += `${refused.message.replace(/\nfatal: Could not reset index file to revision '[^\n]*'\.$/, "")}\n`;
|
|
1005
|
+
this.fatal("failed to clean index");
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
for (const line of await removeBranchState(
|
|
1009
|
+
{ commits: this.commits, refs: this.refsStore },
|
|
1010
|
+
this.state(),
|
|
1011
|
+
)) {
|
|
1012
|
+
this.err += `${line}\n`;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
private sequencerContext() {
|
|
1017
|
+
return {
|
|
1018
|
+
workingCopy: this.workingCopy,
|
|
1019
|
+
...(this.worktreeAccess ? { worktree: this.worktreeAccess } : {}),
|
|
1020
|
+
staging: this.staging,
|
|
1021
|
+
blobs: this.blobs,
|
|
1022
|
+
trees: this.trees,
|
|
1023
|
+
commits: this.commits,
|
|
1024
|
+
refs: this.refsStore,
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
interface AmState {
|
|
1030
|
+
cur: number;
|
|
1031
|
+
last: number;
|
|
1032
|
+
threeway: boolean;
|
|
1033
|
+
quiet: boolean;
|
|
1034
|
+
signoff: boolean;
|
|
1035
|
+
utf8: boolean;
|
|
1036
|
+
keep: "t" | "b" | "f";
|
|
1037
|
+
messageId: boolean;
|
|
1038
|
+
scissors: string;
|
|
1039
|
+
applyOpts: string[];
|
|
1040
|
+
author?: { name: string; email: string; date: string };
|
|
1041
|
+
msg?: string;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
interface Fixed {
|
|
1045
|
+
text: string;
|
|
1046
|
+
changed: boolean;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/** `is_encoding_utf8` of `i18n.commitEncoding` (unset is UTF-8). */
|
|
1050
|
+
function isUtf8Encoding(encoding: string | undefined): boolean {
|
|
1051
|
+
return encoding === undefined || /^utf-?8$/i.test(encoding);
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* commit.c's `ensure_utf8` of a binary string: each byte that starts no valid UTF-8
|
|
1056
|
+
* sequence (`has_invalid_utf8`: overlong forms, surrogates and non-characters included)
|
|
1057
|
+
* read as Latin-1.
|
|
1058
|
+
*/
|
|
1059
|
+
export function ensureUtf8(text: string): Fixed {
|
|
1060
|
+
const max = [0x7f, 0x7ff, 0xffff, 0x10ffff];
|
|
1061
|
+
let out = "";
|
|
1062
|
+
let changed = false;
|
|
1063
|
+
let i = 0;
|
|
1064
|
+
const n = text.length;
|
|
1065
|
+
while (i < n) {
|
|
1066
|
+
const c0 = text.charCodeAt(i);
|
|
1067
|
+
if (c0 < 0x80) {
|
|
1068
|
+
out += text[i++];
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
let c = c0;
|
|
1072
|
+
let bytes = 0;
|
|
1073
|
+
while (c & 0x40) {
|
|
1074
|
+
c = (c << 1) & 0xff;
|
|
1075
|
+
bytes++;
|
|
1076
|
+
}
|
|
1077
|
+
let valid = bytes >= 1 && bytes <= 3 && n - i - 1 >= bytes;
|
|
1078
|
+
if (valid) {
|
|
1079
|
+
let cp = (c & 0x7f) >> bytes;
|
|
1080
|
+
for (let k = 1; k <= bytes; k++) {
|
|
1081
|
+
const b = text.charCodeAt(i + k);
|
|
1082
|
+
cp = (cp << 6) | (b & 0x3f);
|
|
1083
|
+
if ((b & 0xc0) !== 0x80) valid = false;
|
|
1084
|
+
}
|
|
1085
|
+
if (
|
|
1086
|
+
valid &&
|
|
1087
|
+
(cp < (max[bytes - 1] as number) + 1 ||
|
|
1088
|
+
cp > (max[bytes] as number) ||
|
|
1089
|
+
(cp & 0x1ff800) === 0xd800 ||
|
|
1090
|
+
(cp & 0xfffe) === 0xfffe ||
|
|
1091
|
+
(cp >= 0xfdd0 && cp <= 0xfdef))
|
|
1092
|
+
)
|
|
1093
|
+
valid = false;
|
|
1094
|
+
}
|
|
1095
|
+
if (valid) {
|
|
1096
|
+
out += text.slice(i, i + bytes + 1);
|
|
1097
|
+
i += bytes + 1;
|
|
1098
|
+
} else {
|
|
1099
|
+
out += String.fromCharCode(0xc0 + (c0 >> 6), 0x80 + (c0 & 0x3f));
|
|
1100
|
+
changed = true;
|
|
1101
|
+
i++;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
return { text: out, changed };
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
class AmStop extends Error {
|
|
1108
|
+
constructor(readonly status: number) {
|
|
1109
|
+
super(`git am stopped (${status})`);
|
|
1110
|
+
}
|
|
1111
|
+
}
|