@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,890 @@
|
|
|
1
|
+
import { type ObjectId, parsePersonIdent } from "@statewalker/vcs-core";
|
|
2
|
+
import { decodeGitPath, encodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
3
|
+
|
|
4
|
+
import { GitCommand } from "../git-command.js";
|
|
5
|
+
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
6
|
+
import { type DateMode, DEFAULT_DATE_MODE, parseDateMode, showDate } from "./date-format.js";
|
|
7
|
+
import { LogCommand } from "./log-command.js";
|
|
8
|
+
import { commentPrefixOf, stripspace } from "./message-cleanup.js";
|
|
9
|
+
import {
|
|
10
|
+
commitNotes,
|
|
11
|
+
copyNoteForRewrite,
|
|
12
|
+
defaultNotesRef,
|
|
13
|
+
expandNotesRef,
|
|
14
|
+
finishCopyNotesForRewrite,
|
|
15
|
+
initCopyNotesForRewrite,
|
|
16
|
+
initNotes,
|
|
17
|
+
type NotesContext,
|
|
18
|
+
NotesError,
|
|
19
|
+
type NotesHandle,
|
|
20
|
+
} from "./notes-support.js";
|
|
21
|
+
import { combineNotesOverwrite, readNoteBytes } from "./notes-tree.js";
|
|
22
|
+
|
|
23
|
+
/** strbuf_add_commented_lines: each line after the comment string (and a space, unless empty or tab-led). */
|
|
24
|
+
function commentedLines(text: string, comment: string): string {
|
|
25
|
+
if (text === "") return "";
|
|
26
|
+
let out = "";
|
|
27
|
+
let at = 0;
|
|
28
|
+
while (at < text.length) {
|
|
29
|
+
let end = text.indexOf("\n", at);
|
|
30
|
+
end = end < 0 ? text.length : end + 1;
|
|
31
|
+
const line = text.slice(at, end);
|
|
32
|
+
out += comment;
|
|
33
|
+
if (line[0] !== "\n" && line[0] !== "\t") out += " ";
|
|
34
|
+
out += line;
|
|
35
|
+
at = end;
|
|
36
|
+
}
|
|
37
|
+
return out.endsWith("\n") ? out : `${out}\n`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function concat(chunks: Uint8Array[]): Uint8Array {
|
|
41
|
+
if (chunks.length === 1) return chunks[0] as Uint8Array;
|
|
42
|
+
const out = new Uint8Array(chunks.reduce((n, c) => n + c.length, 0));
|
|
43
|
+
let o = 0;
|
|
44
|
+
for (const c of chunks) {
|
|
45
|
+
out.set(c, o);
|
|
46
|
+
o += c.length;
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* What a `git notes` subcommand printed and how it ended: `output` is its standard output,
|
|
53
|
+
* `errors` its standard error (git's `error: ` lines and notices such as `Removing note for
|
|
54
|
+
* object <id>`), `exitCode` its exit status (1 after an `error:`). Where git dies, the
|
|
55
|
+
* commands throw {@link NotesError} with git's `fatal:` message.
|
|
56
|
+
*/
|
|
57
|
+
export interface NotesResult {
|
|
58
|
+
exitCode: number;
|
|
59
|
+
output: string;
|
|
60
|
+
errors: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The message editor of `git notes add`/`append`/`edit` (git's `core.editor`): given the
|
|
65
|
+
* template git writes to `NOTES_EDITMSG`, it returns the edited text. Without one the text
|
|
66
|
+
* stays as it is, as with `GIT_EDITOR=:`. A throw is git's failed editor.
|
|
67
|
+
*/
|
|
68
|
+
export type NotesEditor = (text: string) => string | Promise<string>;
|
|
69
|
+
|
|
70
|
+
const NOTE_TEMPLATE = "Write/edit the notes for the following object:";
|
|
71
|
+
|
|
72
|
+
const STRIPSPACE_UNSPECIFIED = -1;
|
|
73
|
+
const NO_STRIPSPACE = 0;
|
|
74
|
+
const STRIPSPACE = 1;
|
|
75
|
+
|
|
76
|
+
/** The notes of `git notes` (`--ref`, `GIT_NOTES_REF`, `core.notesRef`) for each subcommand. */
|
|
77
|
+
export abstract class NotesSubcommand<T> extends GitCommand<T> {
|
|
78
|
+
protected refOverride?: string;
|
|
79
|
+
|
|
80
|
+
/** `git notes --ref=<ref>`: the notes ref used (expanded as git expands it, `x` is `refs/notes/x`). */
|
|
81
|
+
setNotesRef(ref: string): this {
|
|
82
|
+
this.checkCallable();
|
|
83
|
+
this.refOverride = expandNotesRef(ref);
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The notes ref used: `--ref`, `GIT_NOTES_REF`, `core.notesRef`, `refs/notes/commits`. */
|
|
88
|
+
protected notesRef(): string {
|
|
89
|
+
return defaultNotesRef(this.workingCopy, this.refOverride);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
protected get ctx(): NotesContext {
|
|
93
|
+
return this.notesContext();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* git's warnings printed before what the subcommand prints to its standard error (the
|
|
98
|
+
* `ignoring dangling symref` of init_notes's repo_get_oid of the notes ref).
|
|
99
|
+
*/
|
|
100
|
+
protected warnings: string[] = [];
|
|
101
|
+
|
|
102
|
+
/** The subcommand itself; {@link call} adds the {@link warnings} to what it printed. */
|
|
103
|
+
protected abstract execute(): Promise<T>;
|
|
104
|
+
|
|
105
|
+
async call(): Promise<T> {
|
|
106
|
+
this.checkCallable();
|
|
107
|
+
this.setCallable(false);
|
|
108
|
+
const prefix = () => this.warnings.map((w) => `warning: ${w}\n`).join("");
|
|
109
|
+
try {
|
|
110
|
+
const result = await this.execute();
|
|
111
|
+
if (this.warnings.length > 0 && typeof result === "object" && result !== null) {
|
|
112
|
+
const r = result as unknown as NotesResult;
|
|
113
|
+
r.errors = `${prefix()}${r.errors}`;
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (error instanceof NotesError) error.errors = `${prefix()}${error.errors}`;
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** builtin/notes.c's init_notes_check: the notes tree, refused outside of refs/notes/. */
|
|
123
|
+
protected async initCheck(subcommand: string, writable: boolean): Promise<NotesHandle> {
|
|
124
|
+
const ref = this.notesRef();
|
|
125
|
+
const t = await initNotes(this.ctx, ref, { writable, warnings: this.warnings });
|
|
126
|
+
if (!ref.startsWith("refs/notes/")) {
|
|
127
|
+
throw new NotesError(`refusing to ${subcommand} notes in ${ref} (outside of refs/notes/)`);
|
|
128
|
+
}
|
|
129
|
+
return t;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** repo_get_oid, or git's `failed to resolve '<name>' as a valid ref.` */
|
|
133
|
+
protected async resolveObject(name: string): Promise<ObjectId> {
|
|
134
|
+
const id = await this.ctx.resolve(name);
|
|
135
|
+
if (!id) throw new NotesError(`failed to resolve '${name}' as a valid ref.`);
|
|
136
|
+
return id;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
protected async readNoteText(id: ObjectId): Promise<string | undefined> {
|
|
140
|
+
const bytes = await readNoteBytes(this.blobs, id);
|
|
141
|
+
return bytes ? decodeGitPath(bytes) : undefined;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** `git notes list [<object>]`. */
|
|
146
|
+
export interface NotesListResult extends NotesResult {
|
|
147
|
+
/** The notes listed: the annotated object and its note blob, in id order */
|
|
148
|
+
notes: { object: ObjectId; note: ObjectId }[];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* `git notes list [<object>]`: every note as `<note> <object>` lines (in object id order),
|
|
153
|
+
* or the note blob of one object (`error: no note found for object <id>.` when it has none).
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const { output } = await git.notes().list().call(); // "<note> <commit>\n..."
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export class NotesListCommand extends NotesSubcommand<NotesListResult> {
|
|
161
|
+
private object?: string;
|
|
162
|
+
|
|
163
|
+
/** The object whose note is shown (default: every note listed). */
|
|
164
|
+
setObject(name: string): this {
|
|
165
|
+
this.checkCallable();
|
|
166
|
+
this.object = name;
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
protected async execute(): Promise<NotesListResult> {
|
|
171
|
+
const t = await this.initCheck("list", false);
|
|
172
|
+
if (this.object !== undefined) {
|
|
173
|
+
const object = await this.resolveObject(this.object);
|
|
174
|
+
const note = await t.tree.get(object);
|
|
175
|
+
if (note) return { exitCode: 0, output: `${note}\n`, errors: "", notes: [{ object, note }] };
|
|
176
|
+
return {
|
|
177
|
+
exitCode: 1,
|
|
178
|
+
output: "",
|
|
179
|
+
errors: `error: no note found for object ${object}.\n`,
|
|
180
|
+
notes: [],
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
const notes: { object: ObjectId; note: ObjectId }[] = [];
|
|
184
|
+
await t.tree.forEach(0, async (object, note) => {
|
|
185
|
+
notes.push({ object, note });
|
|
186
|
+
return false;
|
|
187
|
+
});
|
|
188
|
+
return {
|
|
189
|
+
exitCode: 0,
|
|
190
|
+
output: notes.map((n) => `${n.note} ${n.object}\n`).join(""),
|
|
191
|
+
errors: "",
|
|
192
|
+
notes,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** A message given (-m, -F, -C, -c). */
|
|
198
|
+
interface NoteMessage {
|
|
199
|
+
kind: "m" | "F" | "C" | "c";
|
|
200
|
+
value: string | Uint8Array;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** builtin/notes.c's struct note_data, once its messages are joined. */
|
|
204
|
+
interface NoteData {
|
|
205
|
+
buf: string;
|
|
206
|
+
count: number;
|
|
207
|
+
useEditor: boolean;
|
|
208
|
+
stripspace: number;
|
|
209
|
+
allowEmpty: boolean;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** The message options of `add`, `append` and `edit`. */
|
|
213
|
+
abstract class NotesMessageCommand<T> extends NotesSubcommand<T> {
|
|
214
|
+
protected messages: NoteMessage[] = [];
|
|
215
|
+
protected useEditor = false;
|
|
216
|
+
protected stripspaceMode = STRIPSPACE_UNSPECIFIED;
|
|
217
|
+
/** `--separator` (default a newline; null: `--no-separator`) */
|
|
218
|
+
protected separator: string | null = "\n";
|
|
219
|
+
protected allowEmpty = false;
|
|
220
|
+
protected object?: string;
|
|
221
|
+
protected editor?: NotesEditor;
|
|
222
|
+
|
|
223
|
+
/** `-m <msg>`: a paragraph of the note (whitespace cleaned up, as git's `stripspace`). */
|
|
224
|
+
addMessage(message: string): this {
|
|
225
|
+
this.checkCallable();
|
|
226
|
+
this.messages.push({ kind: "m", value: message });
|
|
227
|
+
return this;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** `-F <file>`: a paragraph read from a file, given as its content. */
|
|
231
|
+
addMessageFile(content: string | Uint8Array): this {
|
|
232
|
+
this.checkCallable();
|
|
233
|
+
this.messages.push({ kind: "F", value: content });
|
|
234
|
+
return this;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** `-C <object>`: the content of a blob as it is (no cleanup). */
|
|
238
|
+
setReuseMessage(object: string): this {
|
|
239
|
+
this.checkCallable();
|
|
240
|
+
this.messages.push({ kind: "C", value: object });
|
|
241
|
+
return this;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** `-c <object>`: as `-C`, then edited (see {@link setEditor}). */
|
|
245
|
+
setReeditMessage(object: string): this {
|
|
246
|
+
this.checkCallable();
|
|
247
|
+
this.useEditor = true;
|
|
248
|
+
this.messages.push({ kind: "c", value: object });
|
|
249
|
+
return this;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** `-e` / `--edit` (git 2.44+): the message given edited too. */
|
|
253
|
+
setEdit(edit: boolean): this {
|
|
254
|
+
this.checkCallable();
|
|
255
|
+
this.useEditor = edit;
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** `--allow-empty`: an empty note is stored instead of the note being removed. */
|
|
260
|
+
setAllowEmpty(allow: boolean): this {
|
|
261
|
+
this.checkCallable();
|
|
262
|
+
this.allowEmpty = allow;
|
|
263
|
+
return this;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* `--separator[=<paragraph-break>]` (`true`: a newline, the default), `--no-separator`
|
|
268
|
+
* (`false`): what goes between the paragraphs, and between an appended note and the one
|
|
269
|
+
* there (a newline added to a separator without one).
|
|
270
|
+
*/
|
|
271
|
+
setSeparator(separator: string | boolean): this {
|
|
272
|
+
this.checkCallable();
|
|
273
|
+
this.separator = separator === true ? "\n" : separator === false ? null : separator;
|
|
274
|
+
return this;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* `--stripspace` / `--no-stripspace`: whether the message is cleaned up (by default `-m`
|
|
279
|
+
* and `-F` paragraphs are, `-C`/`-c` blobs are not).
|
|
280
|
+
*/
|
|
281
|
+
setStripspace(strip: boolean): this {
|
|
282
|
+
this.checkCallable();
|
|
283
|
+
this.stripspaceMode = strip ? STRIPSPACE : NO_STRIPSPACE;
|
|
284
|
+
return this;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** The object annotated (default `HEAD`). */
|
|
288
|
+
setObject(name: string): this {
|
|
289
|
+
this.checkCallable();
|
|
290
|
+
this.object = name;
|
|
291
|
+
return this;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** The editor of the note (see {@link NotesEditor}). */
|
|
295
|
+
setEditor(editor: NotesEditor): this {
|
|
296
|
+
this.checkCallable();
|
|
297
|
+
this.editor = editor;
|
|
298
|
+
return this;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** append_separator */
|
|
302
|
+
protected appendSeparator(text: string): string {
|
|
303
|
+
const sep = this.separator;
|
|
304
|
+
if (sep === null) return text;
|
|
305
|
+
if (sep.length > 0 && sep.endsWith("\n")) return text + sep;
|
|
306
|
+
return `${text}${sep}\n`;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** The messages read (parse_*_arg) and joined (concat_messages). */
|
|
310
|
+
protected async noteData(): Promise<NoteData> {
|
|
311
|
+
const msgs: { text: string; strip: boolean }[] = [];
|
|
312
|
+
for (const m of this.messages) {
|
|
313
|
+
if (m.kind === "m") msgs.push({ text: m.value as string, strip: true });
|
|
314
|
+
else if (m.kind === "F") {
|
|
315
|
+
const v = m.value;
|
|
316
|
+
msgs.push({ text: typeof v === "string" ? v : decodeGitPath(v), strip: true });
|
|
317
|
+
} else {
|
|
318
|
+
const name = m.value as string;
|
|
319
|
+
const id = await this.ctx.resolve(name);
|
|
320
|
+
if (!id) throw new NotesError(`failed to resolve '${name}' as a valid ref.`);
|
|
321
|
+
const bytes = (await this.blobs.has(id).catch(() => false))
|
|
322
|
+
? await readNoteBytes(this.blobs, id)
|
|
323
|
+
: undefined;
|
|
324
|
+
if (!bytes) {
|
|
325
|
+
if (await this.objectExists(id)) {
|
|
326
|
+
throw new NotesError(`cannot read note data from non-blob object '${name}'.`);
|
|
327
|
+
}
|
|
328
|
+
throw new NotesError(`failed to read object '${name}'.`);
|
|
329
|
+
}
|
|
330
|
+
msgs.push({ text: decodeGitPath(bytes), strip: false });
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
let buf = "";
|
|
334
|
+
for (const msg of msgs) {
|
|
335
|
+
if (buf.length > 0) buf = this.appendSeparator(buf);
|
|
336
|
+
buf += msg.text;
|
|
337
|
+
if (
|
|
338
|
+
(this.stripspaceMode === STRIPSPACE_UNSPECIFIED && msg.strip) ||
|
|
339
|
+
this.stripspaceMode === STRIPSPACE
|
|
340
|
+
) {
|
|
341
|
+
buf = stripspace(buf);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return {
|
|
345
|
+
buf,
|
|
346
|
+
count: msgs.length,
|
|
347
|
+
useEditor: this.useEditor,
|
|
348
|
+
stripspace: this.stripspaceMode,
|
|
349
|
+
allowEmpty: this.allowEmpty,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
protected async objectExists(id: ObjectId): Promise<boolean> {
|
|
354
|
+
const stores = [this.blobs, this.trees, this.commits, this.tagsStore];
|
|
355
|
+
for (const s of stores) {
|
|
356
|
+
if (s && (await s.has(id).catch(() => false))) return true;
|
|
357
|
+
}
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* prepare_note_data: with `-e`/`-c`, or without a message, the editor runs on git's
|
|
363
|
+
* template (the message, else the note there, then the commented instructions), the
|
|
364
|
+
* result cleaned up of comments unless `--no-stripspace`.
|
|
365
|
+
*/
|
|
366
|
+
protected async prepare(
|
|
367
|
+
d: NoteData,
|
|
368
|
+
oldNote: ObjectId | undefined,
|
|
369
|
+
object: ObjectId,
|
|
370
|
+
errors: string[],
|
|
371
|
+
): Promise<string> {
|
|
372
|
+
if (!d.useEditor && d.count > 0) return d.buf;
|
|
373
|
+
const comment = commentPrefixOf(this.workingCopy);
|
|
374
|
+
let text = d.count > 0 ? d.buf : oldNote ? ((await this.readNoteText(oldNote)) ?? "") : "";
|
|
375
|
+
text += `\n${comment}\n${comment} ${NOTE_TEMPLATE}\n${comment}\n`;
|
|
376
|
+
// write_commented_object: `git show --stat --no-notes <object>`, commented
|
|
377
|
+
const shown = await this.showObject(object);
|
|
378
|
+
if (shown === undefined || "error" in shown) {
|
|
379
|
+
const error = new NotesError(`failed to finish 'show' for object '${object}'`);
|
|
380
|
+
const why = shown ? `error: ${shown.error}\n` : `fatal: bad object ${object}\n`;
|
|
381
|
+
error.errors = `${errors.join("")}${why}`;
|
|
382
|
+
throw error;
|
|
383
|
+
}
|
|
384
|
+
text += commentedLines(decodeGitPath(shown.bytes), comment);
|
|
385
|
+
let edited: string;
|
|
386
|
+
try {
|
|
387
|
+
edited = this.editor ? await this.editor(text) : text;
|
|
388
|
+
} catch {
|
|
389
|
+
throw new NotesError("please supply the note contents using either -m or -F option");
|
|
390
|
+
}
|
|
391
|
+
if (d.stripspace !== NO_STRIPSPACE) edited = stripspace(edited, comment);
|
|
392
|
+
return edited;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* What `git show --stat --no-notes <id>` prints to a pipe (builtin/log.c's cmd_show): a
|
|
397
|
+
* commit as `git log` shows it (with its `--stat`, a merge's against its first parent), a
|
|
398
|
+
* tag's header (`tag <name>`, `Tagger:`/`Date:`) and message and then the object it tags,
|
|
399
|
+
* a tree's `tree <name>` (the name given to show: `id`, also for a tree reached through
|
|
400
|
+
* tags) and its names (directories with a `/`), a blob's content. Whatever follows a tag
|
|
401
|
+
* starts with a newline (`rev.shown_one`), except a blob. Undefined when there is no such
|
|
402
|
+
* object (git's `fatal: bad object <id>`); `error` when a tag's target cannot be read (git's
|
|
403
|
+
* `error: could not read object <target>`, show failing).
|
|
404
|
+
*/
|
|
405
|
+
protected async showObject(
|
|
406
|
+
id: ObjectId,
|
|
407
|
+
): Promise<{ bytes: Uint8Array } | { error: string } | undefined> {
|
|
408
|
+
const resolver = this.revisionResolver();
|
|
409
|
+
let type = await resolver.objectType(id);
|
|
410
|
+
if (type === undefined) return undefined;
|
|
411
|
+
const parts: Uint8Array[] = [];
|
|
412
|
+
const done = () => ({ bytes: concat(parts) });
|
|
413
|
+
let current = id;
|
|
414
|
+
let shownOne = false;
|
|
415
|
+
const separator = () => {
|
|
416
|
+
if (shownOne) parts.push(encodeGitPath("\n"));
|
|
417
|
+
};
|
|
418
|
+
for (let depth = 0; depth < 64; depth++) {
|
|
419
|
+
switch (type) {
|
|
420
|
+
case "blob":
|
|
421
|
+
parts.push((await readNoteBytes(this.blobs, current)) ?? new Uint8Array());
|
|
422
|
+
return done();
|
|
423
|
+
case "tree": {
|
|
424
|
+
separator();
|
|
425
|
+
let out = `tree ${id}\n\n`;
|
|
426
|
+
for await (const e of this.trees.loadTree(current)) {
|
|
427
|
+
out += `${e.name}${(e.mode & 0o170000) === 0o040000 ? "/" : ""}\n`;
|
|
428
|
+
}
|
|
429
|
+
parts.push(encodeGitPath(out));
|
|
430
|
+
return done();
|
|
431
|
+
}
|
|
432
|
+
case "commit":
|
|
433
|
+
// log_tree_commit's separator: a commit shown after a tag starts a new entry
|
|
434
|
+
separator();
|
|
435
|
+
parts.push(
|
|
436
|
+
await new LogCommand(this.workingCopy)
|
|
437
|
+
.add(current)
|
|
438
|
+
.setMaxCount(1)
|
|
439
|
+
.callBytes({ stat: true, notes: false, diffMerges: "dense-combined" }),
|
|
440
|
+
);
|
|
441
|
+
return done();
|
|
442
|
+
case "tag": {
|
|
443
|
+
const raw = await this.readTagText(current);
|
|
444
|
+
if (raw === undefined) return { error: `could not read object ${current}` };
|
|
445
|
+
separator();
|
|
446
|
+
let name = "";
|
|
447
|
+
let target = "";
|
|
448
|
+
let header = "";
|
|
449
|
+
let offset = 0;
|
|
450
|
+
while (offset < raw.length && raw[offset] !== "\n") {
|
|
451
|
+
let end = raw.indexOf("\n", offset);
|
|
452
|
+
end = end < 0 ? raw.length : end + 1;
|
|
453
|
+
const line = raw.slice(offset, end).replace(/\n$/, "");
|
|
454
|
+
if (line.startsWith("object ")) target = line.slice(7);
|
|
455
|
+
else if (line.startsWith("tag ")) name = line.slice(4);
|
|
456
|
+
else if (line.startsWith("tagger ")) header += this.tagger(line.slice(7));
|
|
457
|
+
offset = end;
|
|
458
|
+
}
|
|
459
|
+
parts.push(encodeGitPath(`tag ${name}\n${header}${raw.slice(offset)}`));
|
|
460
|
+
shownOne = true;
|
|
461
|
+
type = await resolver.objectType(target);
|
|
462
|
+
if (type === undefined) return { error: `could not read object ${target}` };
|
|
463
|
+
current = target;
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
default:
|
|
467
|
+
return undefined;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return undefined;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/** The content of a tag object as stored, undefined when it cannot be read. */
|
|
474
|
+
private async readTagText(id: ObjectId): Promise<string | undefined> {
|
|
475
|
+
const obj = await this.workingCopy.history?.objects?.get(id).catch(() => undefined);
|
|
476
|
+
if (obj?.type !== "tag") return undefined;
|
|
477
|
+
if (obj.bytes) {
|
|
478
|
+
await obj.content[Symbol.asyncIterator]().return?.();
|
|
479
|
+
return decodeGitPath(obj.bytes);
|
|
480
|
+
}
|
|
481
|
+
const chunks: Uint8Array[] = [];
|
|
482
|
+
for await (const c of obj.content) chunks.push(c);
|
|
483
|
+
return decodeGitPath(concat(chunks));
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/** builtin/log.c's show_tagger: `Tagger:` and `Date:` lines as `git show` prints them. */
|
|
487
|
+
private tagger(ident: string): string {
|
|
488
|
+
let mode: DateMode = DEFAULT_DATE_MODE;
|
|
489
|
+
const spec = RemoteConfigStore.from(this.workingCopy).value("log.date");
|
|
490
|
+
if (spec !== undefined) {
|
|
491
|
+
try {
|
|
492
|
+
mode = parseDateMode(spec);
|
|
493
|
+
} catch {
|
|
494
|
+
// git dies on a bad log.date before it gets here
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
try {
|
|
498
|
+
const who = parsePersonIdent(ident);
|
|
499
|
+
return (
|
|
500
|
+
`Tagger: ${who.name} <${who.email}>\n` +
|
|
501
|
+
`Date: ${showDate(who.timestamp, who.tzOffset, mode)}\n`
|
|
502
|
+
);
|
|
503
|
+
} catch {
|
|
504
|
+
return `Tagger: ${ident}\n`;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
protected async writeNote(text: string): Promise<ObjectId> {
|
|
509
|
+
return this.blobs.store([encodeGitPath(text)]);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/** builtin/notes.c's append_edit: `append` (to the note there) or `edit`. */
|
|
513
|
+
protected async appendEdit(edit: boolean, d: NoteData, errors: string[]): Promise<NotesResult> {
|
|
514
|
+
const subcommand = edit ? "edit" : "append";
|
|
515
|
+
if (d.count > 0 && edit) {
|
|
516
|
+
errors.push(
|
|
517
|
+
"The -m/-F/-c/-C options have been deprecated for the 'edit' subcommand.\n" +
|
|
518
|
+
"Please use 'git notes add -f -m/-F/-c/-C' instead.\n",
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
const objectRef = this.object ?? "HEAD";
|
|
522
|
+
const object = await this.resolveObject(objectRef);
|
|
523
|
+
const t = await this.initCheck(subcommand, true);
|
|
524
|
+
const note = await t.tree.get(object);
|
|
525
|
+
let buf = await this.prepare(d, edit && note ? note : undefined, object, errors);
|
|
526
|
+
if (note && !edit) {
|
|
527
|
+
const prevBytes = await readNoteBytes(this.blobs, note);
|
|
528
|
+
if (!prevBytes) throw new NotesError(`unable to read ${note}`);
|
|
529
|
+
let prev = decodeGitPath(prevBytes);
|
|
530
|
+
if (buf.length > 0 && prevBytes.length > 0) prev = this.appendSeparator(prev);
|
|
531
|
+
buf = prev + buf;
|
|
532
|
+
}
|
|
533
|
+
let logmsg: string;
|
|
534
|
+
if (buf.length > 0 || d.allowEmpty) {
|
|
535
|
+
const id = await this.writeNote(buf);
|
|
536
|
+
await t.tree.add(object, id, combineNotesOverwrite);
|
|
537
|
+
logmsg = `Notes added by 'git notes ${subcommand}'`;
|
|
538
|
+
} else {
|
|
539
|
+
errors.push(`Removing note for object ${object}\n`);
|
|
540
|
+
await t.tree.remove(object);
|
|
541
|
+
logmsg = `Notes removed by 'git notes ${subcommand}'`;
|
|
542
|
+
}
|
|
543
|
+
await commitNotes(this.ctx, t, logmsg);
|
|
544
|
+
return { exitCode: 0, output: "", errors: errors.join("") };
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* `git notes add [-f] [--allow-empty] [-m/-F/-C/-c] [<object>]`: a note for the object
|
|
550
|
+
* (default `HEAD`), committed on the notes ref as `Notes added by 'git notes add'`. An
|
|
551
|
+
* object with a note is refused without `-f` (`error: Cannot add notes...`), or, without a
|
|
552
|
+
* message, edited as `git notes edit` does. An empty message removes the note.
|
|
553
|
+
*
|
|
554
|
+
* @example
|
|
555
|
+
* ```typescript
|
|
556
|
+
* await git.notes().add().addMessage("Reviewed-by: Ann").setObject("HEAD~1").call();
|
|
557
|
+
* ```
|
|
558
|
+
*/
|
|
559
|
+
export class NotesAddCommand extends NotesMessageCommand<NotesResult> {
|
|
560
|
+
private force = false;
|
|
561
|
+
|
|
562
|
+
/** `-f`: replace an existing note. */
|
|
563
|
+
setForce(force: boolean): this {
|
|
564
|
+
this.checkCallable();
|
|
565
|
+
this.force = force;
|
|
566
|
+
return this;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
protected async execute(): Promise<NotesResult> {
|
|
570
|
+
const errors: string[] = [];
|
|
571
|
+
const d = await this.noteData();
|
|
572
|
+
const objectRef = this.object ?? "HEAD";
|
|
573
|
+
const object = await this.resolveObject(objectRef);
|
|
574
|
+
const t = await this.initCheck("add", true);
|
|
575
|
+
const note = await t.tree.get(object);
|
|
576
|
+
if (note) {
|
|
577
|
+
if (!this.force) {
|
|
578
|
+
if (d.count > 0) {
|
|
579
|
+
return {
|
|
580
|
+
exitCode: 1,
|
|
581
|
+
output: "",
|
|
582
|
+
errors:
|
|
583
|
+
`error: Cannot add notes. Found existing notes for object ${object}. ` +
|
|
584
|
+
"Use '-f' to overwrite existing notes\n",
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
// redirected to "edit", its options parsed again (none of add's carried over)
|
|
588
|
+
return this.appendEdit(
|
|
589
|
+
true,
|
|
590
|
+
{
|
|
591
|
+
buf: "",
|
|
592
|
+
count: 0,
|
|
593
|
+
useEditor: false,
|
|
594
|
+
stripspace: STRIPSPACE_UNSPECIFIED,
|
|
595
|
+
allowEmpty: false,
|
|
596
|
+
},
|
|
597
|
+
errors,
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
errors.push(`Overwriting existing notes for object ${object}\n`);
|
|
601
|
+
}
|
|
602
|
+
const buf = await this.prepare(d, note, object, errors);
|
|
603
|
+
if (buf.length > 0 || d.allowEmpty) {
|
|
604
|
+
const id = await this.writeNote(buf);
|
|
605
|
+
await t.tree.add(object, id, combineNotesOverwrite);
|
|
606
|
+
await commitNotes(this.ctx, t, "Notes added by 'git notes add'");
|
|
607
|
+
} else {
|
|
608
|
+
errors.push(`Removing note for object ${object}\n`);
|
|
609
|
+
await t.tree.remove(object);
|
|
610
|
+
await commitNotes(this.ctx, t, "Notes removed by 'git notes add'");
|
|
611
|
+
}
|
|
612
|
+
return { exitCode: 0, output: "", errors: errors.join("") };
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* `git notes append [--allow-empty] [-m/-F/-C/-c] [<object>]`: the message added to the
|
|
618
|
+
* object's note (after the separator, a blank line by default), or its note when it has none.
|
|
619
|
+
*/
|
|
620
|
+
export class NotesAppendCommand extends NotesMessageCommand<NotesResult> {
|
|
621
|
+
protected async execute(): Promise<NotesResult> {
|
|
622
|
+
return this.appendEdit(false, await this.noteData(), []);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* `git notes edit [<object>]`: the object's note edited (see {@link NotesEditor}); an empty
|
|
628
|
+
* result removes it.
|
|
629
|
+
*/
|
|
630
|
+
export class NotesEditCommand extends NotesMessageCommand<NotesResult> {
|
|
631
|
+
protected async execute(): Promise<NotesResult> {
|
|
632
|
+
return this.appendEdit(true, await this.noteData(), []);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* `git notes copy [-f] <from> [<to>]`, `--stdin` (`<from> <to>` lines) and
|
|
638
|
+
* `--for-rewrite=<command>` (the notes rewriting configuration of `amend`/`rebase`).
|
|
639
|
+
*/
|
|
640
|
+
export class NotesCopyCommand extends NotesSubcommand<NotesResult> {
|
|
641
|
+
private force = false;
|
|
642
|
+
private from?: string;
|
|
643
|
+
private to?: string;
|
|
644
|
+
private stdin?: string;
|
|
645
|
+
private forRewrite?: string;
|
|
646
|
+
|
|
647
|
+
/** `-f`: replace the note of the target. */
|
|
648
|
+
setForce(force: boolean): this {
|
|
649
|
+
this.checkCallable();
|
|
650
|
+
this.force = force;
|
|
651
|
+
return this;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/** The object whose note is copied. */
|
|
655
|
+
setFrom(name: string): this {
|
|
656
|
+
this.checkCallable();
|
|
657
|
+
this.from = name;
|
|
658
|
+
return this;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/** The object it is copied to (default `HEAD`). */
|
|
662
|
+
setTo(name: string): this {
|
|
663
|
+
this.checkCallable();
|
|
664
|
+
this.to = name;
|
|
665
|
+
return this;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/** `--stdin`: the standard input, `<from> <to>` per line. */
|
|
669
|
+
setStdin(input: string): this {
|
|
670
|
+
this.checkCallable();
|
|
671
|
+
this.stdin = input;
|
|
672
|
+
return this;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/** `--for-rewrite=<command>` (implies `--stdin`). */
|
|
676
|
+
setForRewrite(command: string): this {
|
|
677
|
+
this.checkCallable();
|
|
678
|
+
this.forRewrite = command;
|
|
679
|
+
return this;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
protected async execute(): Promise<NotesResult> {
|
|
683
|
+
if (this.stdin !== undefined || this.forRewrite !== undefined) return this.fromStdin();
|
|
684
|
+
if (this.from === undefined) throw new NotesError("too few arguments");
|
|
685
|
+
const errors: string[] = [];
|
|
686
|
+
const fromObj = await this.resolveObject(this.from);
|
|
687
|
+
const object = await this.resolveObject(this.to ?? "HEAD");
|
|
688
|
+
const t = await this.initCheck("copy", true);
|
|
689
|
+
const note = await t.tree.get(object);
|
|
690
|
+
if (note) {
|
|
691
|
+
if (!this.force) {
|
|
692
|
+
return {
|
|
693
|
+
exitCode: 1,
|
|
694
|
+
output: "",
|
|
695
|
+
errors:
|
|
696
|
+
`error: Cannot copy notes. Found existing notes for object ${object}. ` +
|
|
697
|
+
"Use '-f' to overwrite existing notes\n",
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
errors.push(`Overwriting existing notes for object ${object}\n`);
|
|
701
|
+
}
|
|
702
|
+
const fromNote = await t.tree.get(fromObj);
|
|
703
|
+
if (!fromNote) {
|
|
704
|
+
errors.push(`error: missing notes on source object ${fromObj}. Cannot copy.\n`);
|
|
705
|
+
return { exitCode: 1, output: "", errors: errors.join("") };
|
|
706
|
+
}
|
|
707
|
+
await t.tree.add(object, fromNote, combineNotesOverwrite);
|
|
708
|
+
await commitNotes(this.ctx, t, "Notes added by 'git notes copy'");
|
|
709
|
+
return { exitCode: 0, output: "", errors: errors.join("") };
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/** notes_copy_from_stdin */
|
|
713
|
+
private async fromStdin(): Promise<NotesResult> {
|
|
714
|
+
const ctx = this.ctx;
|
|
715
|
+
const errors: string[] = [];
|
|
716
|
+
const msg = "Notes added by 'git notes copy'";
|
|
717
|
+
let ret = 0;
|
|
718
|
+
const rewrite =
|
|
719
|
+
this.forRewrite !== undefined
|
|
720
|
+
? await initCopyNotesForRewrite(ctx, this.forRewrite, errors)
|
|
721
|
+
: undefined;
|
|
722
|
+
if (this.forRewrite !== undefined && !rewrite) {
|
|
723
|
+
return { exitCode: 0, output: "", errors: errors.map((e) => `${e}\n`).join("") };
|
|
724
|
+
}
|
|
725
|
+
const t = rewrite
|
|
726
|
+
? undefined
|
|
727
|
+
: await initNotes(ctx, this.notesRef(), { writable: true, warnings: this.warnings });
|
|
728
|
+
const lines = (this.stdin ?? "").split("\n");
|
|
729
|
+
if (lines[lines.length - 1] === "") lines.pop();
|
|
730
|
+
const out = errors.map((e) => `${e}\n`);
|
|
731
|
+
for (const line of lines) {
|
|
732
|
+
const split = line.split(" ").map((p) => p.trim());
|
|
733
|
+
if (split.length < 2) throw new NotesError(`malformed input line: '${line}'.`);
|
|
734
|
+
const [a, b] = split as [string, string];
|
|
735
|
+
const from = await this.resolveObject(a);
|
|
736
|
+
const to = await this.resolveObject(b);
|
|
737
|
+
let failed = false;
|
|
738
|
+
if (rewrite) await copyNoteForRewrite(rewrite, from, to);
|
|
739
|
+
else
|
|
740
|
+
failed = !(await (t as NotesHandle).tree.copy(from, to, this.force, combineNotesOverwrite));
|
|
741
|
+
if (failed) {
|
|
742
|
+
out.push(`error: failed to copy notes from '${a}' to '${b}'\n`);
|
|
743
|
+
ret = 1;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
if (rewrite) await finishCopyNotesForRewrite(ctx, rewrite, msg);
|
|
747
|
+
else await commitNotes(ctx, t as NotesHandle, msg);
|
|
748
|
+
return { exitCode: ret, output: "", errors: out.join("") };
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/** `git notes show [<object>]`. */
|
|
753
|
+
export interface NotesShowResult extends NotesResult {
|
|
754
|
+
/** The note blob shown */
|
|
755
|
+
note?: ObjectId;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/** `git notes show [<object>]`: the note's text (`git show <note>`). */
|
|
759
|
+
export class NotesShowCommand extends NotesSubcommand<NotesShowResult> {
|
|
760
|
+
private object?: string;
|
|
761
|
+
|
|
762
|
+
/** The object (default `HEAD`). */
|
|
763
|
+
setObject(name: string): this {
|
|
764
|
+
this.checkCallable();
|
|
765
|
+
this.object = name;
|
|
766
|
+
return this;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
protected async execute(): Promise<NotesShowResult> {
|
|
770
|
+
const object = await this.resolveObject(this.object ?? "HEAD");
|
|
771
|
+
const t = await this.initCheck("show", false);
|
|
772
|
+
const note = await t.tree.get(object);
|
|
773
|
+
if (!note) {
|
|
774
|
+
return { exitCode: 1, output: "", errors: `error: no note found for object ${object}.\n` };
|
|
775
|
+
}
|
|
776
|
+
return { exitCode: 0, output: (await this.readNoteText(note)) ?? "", errors: "", note };
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* `git notes remove [--ignore-missing] [--stdin] [<object>...]`: the notes of the objects
|
|
782
|
+
* (default `HEAD`) removed, committed as `Notes removed by 'git notes remove'` when every one
|
|
783
|
+
* went well.
|
|
784
|
+
*/
|
|
785
|
+
export class NotesRemoveCommand extends NotesSubcommand<NotesResult> {
|
|
786
|
+
private objects: string[] = [];
|
|
787
|
+
private ignoreMissing = false;
|
|
788
|
+
private stdin?: string;
|
|
789
|
+
|
|
790
|
+
/** The objects whose notes are removed. */
|
|
791
|
+
addObjects(...names: string[]): this {
|
|
792
|
+
this.checkCallable();
|
|
793
|
+
this.objects.push(...names);
|
|
794
|
+
return this;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/** `--ignore-missing`: an object without a note is no error. */
|
|
798
|
+
setIgnoreMissing(ignore: boolean): this {
|
|
799
|
+
this.checkCallable();
|
|
800
|
+
this.ignoreMissing = ignore;
|
|
801
|
+
return this;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/** `--stdin`: object names, one per line, after those given. */
|
|
805
|
+
setStdin(input: string): this {
|
|
806
|
+
this.checkCallable();
|
|
807
|
+
this.stdin = input;
|
|
808
|
+
return this;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
protected async execute(): Promise<NotesResult> {
|
|
812
|
+
const t = await this.initCheck("remove", true);
|
|
813
|
+
const errors: string[] = [];
|
|
814
|
+
let retval = 0;
|
|
815
|
+
const removeOne = async (name: string): Promise<number> => {
|
|
816
|
+
const id = await this.ctx.resolve(name);
|
|
817
|
+
if (!id) {
|
|
818
|
+
errors.push(`error: Failed to resolve '${name}' as a valid ref.\n`);
|
|
819
|
+
return 1;
|
|
820
|
+
}
|
|
821
|
+
const status = (await t.tree.remove(id)) ? 0 : 1;
|
|
822
|
+
errors.push(status ? `Object ${name} has no note\n` : `Removing note for object ${name}\n`);
|
|
823
|
+
return this.ignoreMissing ? 0 : status;
|
|
824
|
+
};
|
|
825
|
+
if (this.objects.length === 0 && this.stdin === undefined) retval = await removeOne("HEAD");
|
|
826
|
+
else for (const name of this.objects) retval |= await removeOne(name);
|
|
827
|
+
if (this.stdin !== undefined) {
|
|
828
|
+
const lines = this.stdin.split("\n");
|
|
829
|
+
if (lines[lines.length - 1] === "") lines.pop();
|
|
830
|
+
for (const line of lines) retval |= await removeOne(line.replace(/\s+$/, ""));
|
|
831
|
+
}
|
|
832
|
+
if (!retval) await commitNotes(this.ctx, t, "Notes removed by 'git notes remove'");
|
|
833
|
+
return { exitCode: retval ? 1 : 0, output: "", errors: errors.join("") };
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/** `git notes prune [-n] [-v]`. */
|
|
838
|
+
export interface NotesPruneResult extends NotesResult {
|
|
839
|
+
/** The objects whose notes were (with `-n`: would be) removed */
|
|
840
|
+
pruned: ObjectId[];
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/** `git notes prune [-n] [-v]`: the notes of objects that are not in the repository removed. */
|
|
844
|
+
export class NotesPruneCommand extends NotesSubcommand<NotesPruneResult> {
|
|
845
|
+
private dryRun = false;
|
|
846
|
+
private verbose = false;
|
|
847
|
+
|
|
848
|
+
/** `-n`: list them (as `-v`), remove nothing. */
|
|
849
|
+
setDryRun(dryRun: boolean): this {
|
|
850
|
+
this.checkCallable();
|
|
851
|
+
this.dryRun = dryRun;
|
|
852
|
+
return this;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/** `-v`: list the objects whose notes are removed. */
|
|
856
|
+
setVerbose(verbose: boolean): this {
|
|
857
|
+
this.checkCallable();
|
|
858
|
+
this.verbose = verbose;
|
|
859
|
+
return this;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
protected async execute(): Promise<NotesPruneResult> {
|
|
863
|
+
const t = await this.initCheck("prune", true);
|
|
864
|
+
const missing = await t.tree.unreachableObjects((id) => this.objectExists(id));
|
|
865
|
+
let output = "";
|
|
866
|
+
for (const id of missing) {
|
|
867
|
+
if (this.verbose || this.dryRun) output += `${id}\n`;
|
|
868
|
+
if (!this.dryRun) await t.tree.remove(id);
|
|
869
|
+
}
|
|
870
|
+
if (!this.dryRun) await commitNotes(this.ctx, t, "Notes removed by 'git notes prune'");
|
|
871
|
+
return { exitCode: 0, output, errors: "", pruned: missing };
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/** odb_has_object: one typeless lookup where the store has its object kernel. */
|
|
875
|
+
private async objectExists(id: ObjectId): Promise<boolean> {
|
|
876
|
+
const objects = this.workingCopy.history?.objects;
|
|
877
|
+
if (objects) return objects.has(id).catch(() => false);
|
|
878
|
+
for (const s of [this.blobs, this.trees, this.commits, this.tagsStore]) {
|
|
879
|
+
if (s && (await s.has(id).catch(() => false))) return true;
|
|
880
|
+
}
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/** `git notes get-ref`: the notes ref used. */
|
|
886
|
+
export class NotesGetRefCommand extends NotesSubcommand<string> {
|
|
887
|
+
protected async execute(): Promise<string> {
|
|
888
|
+
return this.notesRef();
|
|
889
|
+
}
|
|
890
|
+
}
|