@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,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading one loose object as git's `read_loose_object` does for fsck, with git's messages:
|
|
3
|
+
*
|
|
4
|
+
* - the header is inflated into a 32-byte buffer first (`unpack_loose_header`): a zlib error
|
|
5
|
+
* there, or no NUL in those bytes, is `unable to unpack header of <path>`;
|
|
6
|
+
* - `unable to parse header of <path>` for a header that is not `<type> <size>`;
|
|
7
|
+
* - then the rest (`unpack_loose_rest`): a zlib error or a stream that does not end exactly at
|
|
8
|
+
* the declared size is `corrupt loose object '<id>'`, bytes after the stream are
|
|
9
|
+
* `garbage at end of loose object '<id>'`, both followed by `unable to unpack contents of
|
|
10
|
+
* <path>`;
|
|
11
|
+
* - zlib errors themselves are printed first, as git's `git_inflate` prints them
|
|
12
|
+
* (`inflate: data stream error (incorrect data check)`); a stream cut short is not (zlib's
|
|
13
|
+
* Z_BUF_ERROR);
|
|
14
|
+
* - content that hashes to another id than the file's name is `hash-path mismatch`.
|
|
15
|
+
*
|
|
16
|
+
* Blobs above `core.bigFileThreshold` are streamed as git's `check_stream_oid` streams them:
|
|
17
|
+
* hashed as they inflate, never held whole. git does not compare the length read with the
|
|
18
|
+
* declared size there, so a stream that ends early is fine when it hashes to the file's name;
|
|
19
|
+
* otherwise it is `hash mismatch for <path> (expected <id>)`. A zlib error, a cut stream or bytes
|
|
20
|
+
* after it are reported without `unable to unpack contents`. (A stream longer than declared
|
|
21
|
+
* makes git 2.43 and 2.56 loop forever there; it is `corrupt loose object` here.)
|
|
22
|
+
*
|
|
23
|
+
* Other objects are inflated whole, one at a time (git maps the file and inflates it whole
|
|
24
|
+
* too), into a buffer that grows as the output comes, up to the declared size or what zlib can
|
|
25
|
+
* produce from the file (1032 bytes per input byte) when that is less: a hostile header
|
|
26
|
+
* allocates nothing up front, and a stream that inflates further is `corrupt loose object`.
|
|
27
|
+
* One exception, as git's `unpack_loose_rest`: when the whole stream fit in the 32-byte header
|
|
28
|
+
* buffer, git copies at most the declared size of it and zlib, already at its end, reports
|
|
29
|
+
* success, so bytes past the declared size are dropped and the object can be fine.
|
|
30
|
+
*
|
|
31
|
+
* git inflates into a buffer of the declared size and hashes all of it, so a stream that ends
|
|
32
|
+
* early hashes as its bytes followed by what the buffer held: zeros for a buffer malloc maps
|
|
33
|
+
* fresh (above glibc's mmap threshold, at most 32 MiB), whatever was reused below. Zeros are
|
|
34
|
+
* hashed here in 64 KiB pieces for declared sizes up to 1 GiB (above that git takes as long or
|
|
35
|
+
* dies out of memory; it is `corrupt loose object` here). When they hash to the file's name, a
|
|
36
|
+
* blob's content is returned without them (shorter than its size); a tree, commit or tag is
|
|
37
|
+
* padded to its size, as the checks parse it with its zeros, as git does.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
import type { FilesApi } from "@statewalker/vcs-core";
|
|
41
|
+
import {
|
|
42
|
+
createInflater,
|
|
43
|
+
InflateError,
|
|
44
|
+
InflateOverflowError,
|
|
45
|
+
inflateWhole,
|
|
46
|
+
TruncatedStreamError,
|
|
47
|
+
} from "@statewalker/vcs-utils/compression";
|
|
48
|
+
import { createSha1, type Hasher } from "@statewalker/vcs-utils/hash/hasher";
|
|
49
|
+
import { bytesToHex } from "@statewalker/vcs-utils/hash/utils";
|
|
50
|
+
|
|
51
|
+
/** git's MAX_HEADER_LEN */
|
|
52
|
+
const MAX_HEADER_LEN = 32;
|
|
53
|
+
/** git's default `core.bigFileThreshold` (512 MiB). */
|
|
54
|
+
export const DEFAULT_BIG_FILE_THRESHOLD = 512 * 1024 * 1024;
|
|
55
|
+
/** The most bytes a deflate stream yields per input byte. */
|
|
56
|
+
const MAX_DEFLATE_RATIO = 1032;
|
|
57
|
+
/** The largest declared size whose missing tail is hashed as git's zeroed buffer. */
|
|
58
|
+
const MAX_ZERO_PADDING = 2 ** 30;
|
|
59
|
+
/** Input slice per push when streaming: at most ~1 MiB of output each. */
|
|
60
|
+
const STREAM_SLICE = 1024;
|
|
61
|
+
const ZEROS = new Uint8Array(64 * 1024);
|
|
62
|
+
const enc = new TextEncoder();
|
|
63
|
+
const dec = new TextDecoder();
|
|
64
|
+
|
|
65
|
+
/** A loose object as fsck read it. */
|
|
66
|
+
export interface LooseRead {
|
|
67
|
+
/** Messages git prints with `error()`, in order (without the `error: ` prefix). */
|
|
68
|
+
errors: string[];
|
|
69
|
+
/**
|
|
70
|
+
* The type, size and content, when the object could be read and hashes to its name. A blob
|
|
71
|
+
* above `core.bigFileThreshold` is streamed: no content (as git's NULL buffer). A blob whose
|
|
72
|
+
* stream ended early has content shorter than `size`: the rest is zeros.
|
|
73
|
+
*/
|
|
74
|
+
object?: { type: string; size: number; content?: Uint8Array };
|
|
75
|
+
/** The id the content hashes to, when it was read whole but hashes to another id. */
|
|
76
|
+
realId?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The message git's `git_inflate` prints for a zlib error, or undefined for a short stream. */
|
|
80
|
+
export function zlibErrorMessage(e: unknown): string | undefined {
|
|
81
|
+
if (e instanceof TruncatedStreamError || e instanceof InflateOverflowError) return undefined;
|
|
82
|
+
if (e instanceof InflateError) {
|
|
83
|
+
const message = e.message.replace(/^inflate failed: /, "");
|
|
84
|
+
if (message.includes("preset dictionary")) return "inflate: needs dictionary (no message)";
|
|
85
|
+
return `inflate: data stream error (${message})`;
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The first MAX_HEADER_LEN bytes a truncated stream inflates to, if they hold the header. */
|
|
91
|
+
function inflatedStart(data: Uint8Array): Uint8Array | undefined {
|
|
92
|
+
const inflater = createInflater();
|
|
93
|
+
try {
|
|
94
|
+
const { out } = inflater.push(data);
|
|
95
|
+
const all = new Uint8Array(out.reduce((n, c) => n + c.length, 0));
|
|
96
|
+
let at = 0;
|
|
97
|
+
for (const c of out) {
|
|
98
|
+
all.set(c, at);
|
|
99
|
+
at += c.length;
|
|
100
|
+
}
|
|
101
|
+
const start = all.subarray(0, MAX_HEADER_LEN);
|
|
102
|
+
return start.includes(0) ? start : undefined;
|
|
103
|
+
} catch {
|
|
104
|
+
return undefined;
|
|
105
|
+
} finally {
|
|
106
|
+
inflater.abort();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function readFile(files: FilesApi, path: string): Promise<Uint8Array | undefined> {
|
|
111
|
+
const parts: Uint8Array[] = [];
|
|
112
|
+
let n = 0;
|
|
113
|
+
try {
|
|
114
|
+
for await (const c of files.read(path)) {
|
|
115
|
+
parts.push(c);
|
|
116
|
+
n += c.length;
|
|
117
|
+
}
|
|
118
|
+
} catch {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
if (parts.length === 1) return parts[0];
|
|
122
|
+
const out = new Uint8Array(n);
|
|
123
|
+
let o = 0;
|
|
124
|
+
for (const p of parts) {
|
|
125
|
+
out.set(p, o);
|
|
126
|
+
o += p.length;
|
|
127
|
+
}
|
|
128
|
+
return out;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Options of `readLooseObject`. */
|
|
132
|
+
export interface LooseReadOptions {
|
|
133
|
+
/** `core.bigFileThreshold`: larger blobs are streamed (default 512 MiB). */
|
|
134
|
+
bigFileThreshold?: number;
|
|
135
|
+
/** The repository's hash (its `ObjectFormat.createHasher`); SHA-1 by default */
|
|
136
|
+
newHasher?: () => Hasher;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Reads the loose object `id` stored at `path`, as `read_loose_object` does. */
|
|
140
|
+
export async function readLooseObject(
|
|
141
|
+
files: FilesApi,
|
|
142
|
+
path: string,
|
|
143
|
+
id: string,
|
|
144
|
+
options: LooseReadOptions = {},
|
|
145
|
+
): Promise<LooseRead> {
|
|
146
|
+
const errors: string[] = [];
|
|
147
|
+
const data = await readFile(files, path);
|
|
148
|
+
if (!data) {
|
|
149
|
+
errors.push(`unable to mmap ${path}: No such file or directory`);
|
|
150
|
+
return { errors };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// unpack_loose_header: inflate into MAX_HEADER_LEN bytes
|
|
154
|
+
let head: Uint8Array;
|
|
155
|
+
// where the stream ended when all of it fit in the header buffer (zlib's Z_STREAM_END there)
|
|
156
|
+
let endedAt = -1;
|
|
157
|
+
try {
|
|
158
|
+
const r = inflateWhole(data, { into: new Uint8Array(MAX_HEADER_LEN), partial: true });
|
|
159
|
+
head = r.data.subarray(0, r.length);
|
|
160
|
+
if (r.ended) endedAt = r.consumed;
|
|
161
|
+
} catch (e) {
|
|
162
|
+
// zlib stops once the 32 bytes are out, even if the stream is cut short after them
|
|
163
|
+
const start = e instanceof TruncatedStreamError ? inflatedStart(data) : undefined;
|
|
164
|
+
if (!start) {
|
|
165
|
+
const zlib = zlibErrorMessage(e);
|
|
166
|
+
if (zlib) errors.push(zlib);
|
|
167
|
+
errors.push(`unable to unpack header of ${path}`);
|
|
168
|
+
return { errors };
|
|
169
|
+
}
|
|
170
|
+
head = start;
|
|
171
|
+
}
|
|
172
|
+
const nul = head.indexOf(0);
|
|
173
|
+
if (nul < 0) {
|
|
174
|
+
errors.push(`unable to unpack header of ${path}`);
|
|
175
|
+
return { errors };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// parse_loose_header
|
|
179
|
+
const header = dec.decode(head.subarray(0, nul));
|
|
180
|
+
const match = /^(commit|tree|blob|tag) (0|[1-9][0-9]*)$/.exec(header);
|
|
181
|
+
if (!match) {
|
|
182
|
+
errors.push(`unable to parse header of ${path}`);
|
|
183
|
+
return { errors };
|
|
184
|
+
}
|
|
185
|
+
const type = match[1] as string;
|
|
186
|
+
const size = Number(match[2]);
|
|
187
|
+
const headerLength = nul + 1;
|
|
188
|
+
|
|
189
|
+
if (type === "blob" && size > (options.bigFileThreshold ?? DEFAULT_BIG_FILE_THRESHOLD)) {
|
|
190
|
+
const streamed = checkStreamOid(
|
|
191
|
+
data,
|
|
192
|
+
headerLength,
|
|
193
|
+
size,
|
|
194
|
+
path,
|
|
195
|
+
id,
|
|
196
|
+
options.newHasher ?? createSha1,
|
|
197
|
+
);
|
|
198
|
+
if (streamed.length > 0) return { errors: streamed };
|
|
199
|
+
return { errors, object: { type, size } };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// unpack_loose_rest
|
|
203
|
+
const total = headerLength + size;
|
|
204
|
+
let content: Uint8Array;
|
|
205
|
+
try {
|
|
206
|
+
let consumed: number;
|
|
207
|
+
if (endedAt >= 0) {
|
|
208
|
+
// the whole stream is in the header buffer: git copies at most `size` bytes of it and
|
|
209
|
+
// zlib, at its end already, says Z_STREAM_END, so bytes past the declared size are dropped
|
|
210
|
+
consumed = endedAt;
|
|
211
|
+
content = head.subarray(headerLength, Math.min(head.length, total));
|
|
212
|
+
} else {
|
|
213
|
+
// a buffer that grows as the output comes, up to the declared size or what zlib can
|
|
214
|
+
// produce from the file if that is less: a hostile header allocates nothing up front
|
|
215
|
+
const r = inflateWhole(data, {
|
|
216
|
+
maxSize: Math.min(total, data.length * MAX_DEFLATE_RATIO + MAX_HEADER_LEN),
|
|
217
|
+
});
|
|
218
|
+
consumed = r.consumed;
|
|
219
|
+
content = r.data.subarray(headerLength, Math.max(headerLength, r.length));
|
|
220
|
+
}
|
|
221
|
+
if (consumed < data.length) {
|
|
222
|
+
errors.push(`garbage at end of loose object '${id}'`);
|
|
223
|
+
errors.push(`unable to unpack contents of ${path}`);
|
|
224
|
+
return { errors };
|
|
225
|
+
}
|
|
226
|
+
} catch (e) {
|
|
227
|
+
const zlib = zlibErrorMessage(e);
|
|
228
|
+
if (zlib) errors.push(zlib);
|
|
229
|
+
errors.push(`corrupt loose object '${id}'`);
|
|
230
|
+
errors.push(`unable to unpack contents of ${path}`);
|
|
231
|
+
return { errors };
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// a stream that ends early leaves the rest of git's buffer as malloc gave it: zeros here,
|
|
235
|
+
// hashed in pieces, never allocated for a blob (its content is shorter than `size` then)
|
|
236
|
+
const missing = size - content.length;
|
|
237
|
+
if (missing > 0 && size > MAX_ZERO_PADDING) {
|
|
238
|
+
errors.push(`corrupt loose object '${id}'`);
|
|
239
|
+
errors.push(`unable to unpack contents of ${path}`);
|
|
240
|
+
return { errors };
|
|
241
|
+
}
|
|
242
|
+
const hasher = (options.newHasher ?? createSha1)()
|
|
243
|
+
.update(enc.encode(`${type} ${size}\0`))
|
|
244
|
+
.update(content);
|
|
245
|
+
for (let left = missing; left > 0; left -= ZEROS.length) {
|
|
246
|
+
hasher.update(left >= ZEROS.length ? ZEROS : ZEROS.subarray(0, left));
|
|
247
|
+
}
|
|
248
|
+
const realId = bytesToHex(hasher.digest());
|
|
249
|
+
if (realId !== id) return { errors, realId };
|
|
250
|
+
if (missing > 0 && type !== "blob") {
|
|
251
|
+
// the checks parse a tree, commit or tag with its zeros (git's buffer is that long too)
|
|
252
|
+
const padded = new Uint8Array(size);
|
|
253
|
+
padded.set(content);
|
|
254
|
+
content = padded;
|
|
255
|
+
}
|
|
256
|
+
return { errors, object: { type, size, content } };
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* git's `check_stream_oid` for a blob above `core.bigFileThreshold`: the errors it prints, none
|
|
261
|
+
* when the stream hashes to `id`. Output is hashed as it inflates, in bounded pieces.
|
|
262
|
+
*/
|
|
263
|
+
function checkStreamOid(
|
|
264
|
+
data: Uint8Array,
|
|
265
|
+
headerLength: number,
|
|
266
|
+
size: number,
|
|
267
|
+
path: string,
|
|
268
|
+
id: string,
|
|
269
|
+
newHasher: () => Hasher,
|
|
270
|
+
): string[] {
|
|
271
|
+
const hasher = newHasher();
|
|
272
|
+
const inflater = createInflater();
|
|
273
|
+
let produced = 0;
|
|
274
|
+
const limit = headerLength + size;
|
|
275
|
+
let end = -1;
|
|
276
|
+
try {
|
|
277
|
+
for (let at = 0; at < data.length && end < 0; at += STREAM_SLICE) {
|
|
278
|
+
const slice = data.subarray(at, Math.min(data.length, at + STREAM_SLICE));
|
|
279
|
+
const { out, done, consumed } = inflater.push(slice);
|
|
280
|
+
for (const chunk of out) {
|
|
281
|
+
produced += chunk.length;
|
|
282
|
+
// git reads at most the declared size; past it, it loops (corrupt here)
|
|
283
|
+
if (produced > limit) throw new InflateOverflowError();
|
|
284
|
+
hasher.update(chunk);
|
|
285
|
+
}
|
|
286
|
+
if (done) end = at + consumed;
|
|
287
|
+
}
|
|
288
|
+
if (end < 0) throw new TruncatedStreamError();
|
|
289
|
+
} catch (e) {
|
|
290
|
+
inflater.abort();
|
|
291
|
+
const zlib = zlibErrorMessage(e);
|
|
292
|
+
return [...(zlib ? [zlib] : []), `corrupt loose object '${id}'`];
|
|
293
|
+
}
|
|
294
|
+
if (end < data.length) return [`garbage at end of loose object '${id}'`];
|
|
295
|
+
if (bytesToHex(hasher.digest()) !== id) return [`hash mismatch for ${path} (expected ${id})`];
|
|
296
|
+
return [];
|
|
297
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git's fsck message ids (`fsck.h`, `Documentation/fsck-msgids.txt`) and their severities, as
|
|
3
|
+
* `fsck.<msg-id>` config, `receive.fsck.<msg-id>` and `--strict` adjust them.
|
|
4
|
+
*
|
|
5
|
+
* Ids are written in git's camel case (`duplicateEntries`), the spelling git prints and the
|
|
6
|
+
* documentation uses. Config keys match case-insensitively and without underscores, as git's
|
|
7
|
+
* `parse_msg_id` matches them (`fsck.duplicateentries`, `fsck.DUPLICATE_ENTRIES` are not the
|
|
8
|
+
* same: git lowercases the key and drops underscores, so both match `duplicateEntries`).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const types = new FsckMessageTypes({ strict: true });
|
|
13
|
+
* types.severity("zeroPaddedFilemode"); // "error" (a warning, made an error by --strict)
|
|
14
|
+
* types.set("zeroPaddedFilemode", "ignore");
|
|
15
|
+
* types.severity("zeroPaddedFilemode"); // "ignore"
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** A severity in git's table: `fatal` and `info` are reported as `error` and `warning`. */
|
|
20
|
+
export type FsckMsgLevel = "fatal" | "error" | "warn" | "info" | "ignore";
|
|
21
|
+
|
|
22
|
+
/** What a message is reported as. */
|
|
23
|
+
export type FsckSeverity = "error" | "warning" | "ignore";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Every object message id git knows, with its default level, in git's order. The ref ids git
|
|
27
|
+
* 2.45+ added for `git refs verify` (`badRefContent`, ...) are not here: fsck's ref database
|
|
28
|
+
* checks are not done.
|
|
29
|
+
*/
|
|
30
|
+
export const FSCK_MSG_IDS = {
|
|
31
|
+
// fatal errors
|
|
32
|
+
nulInHeader: "fatal",
|
|
33
|
+
unterminatedHeader: "fatal",
|
|
34
|
+
// errors
|
|
35
|
+
badDate: "error",
|
|
36
|
+
badDateOverflow: "error",
|
|
37
|
+
badEmail: "error",
|
|
38
|
+
badGpgsig: "error",
|
|
39
|
+
badHeaderContinuation: "error",
|
|
40
|
+
badName: "error",
|
|
41
|
+
badObjectSha1: "error",
|
|
42
|
+
badParentSha1: "error",
|
|
43
|
+
badTimezone: "error",
|
|
44
|
+
badTree: "error",
|
|
45
|
+
badTreeSha1: "error",
|
|
46
|
+
badType: "error",
|
|
47
|
+
duplicateEntries: "error",
|
|
48
|
+
missingAuthor: "error",
|
|
49
|
+
missingCommitter: "error",
|
|
50
|
+
missingEmail: "error",
|
|
51
|
+
missingNameBeforeEmail: "error",
|
|
52
|
+
missingObject: "error",
|
|
53
|
+
missingSpaceBeforeDate: "error",
|
|
54
|
+
missingSpaceBeforeEmail: "error",
|
|
55
|
+
missingTag: "error",
|
|
56
|
+
missingTagEntry: "error",
|
|
57
|
+
missingTree: "error",
|
|
58
|
+
missingType: "error",
|
|
59
|
+
missingTypeEntry: "error",
|
|
60
|
+
multipleAuthors: "error",
|
|
61
|
+
treeNotSorted: "error",
|
|
62
|
+
unknownType: "error",
|
|
63
|
+
zeroPaddedDate: "error",
|
|
64
|
+
gitmodulesMissing: "error",
|
|
65
|
+
gitmodulesBlob: "error",
|
|
66
|
+
gitmodulesLarge: "error",
|
|
67
|
+
gitmodulesName: "error",
|
|
68
|
+
gitmodulesSymlink: "error",
|
|
69
|
+
gitmodulesUrl: "error",
|
|
70
|
+
gitmodulesPath: "error",
|
|
71
|
+
gitmodulesUpdate: "error",
|
|
72
|
+
gitattributesMissing: "error",
|
|
73
|
+
gitattributesLarge: "error",
|
|
74
|
+
gitattributesLineLength: "error",
|
|
75
|
+
gitattributesBlob: "error",
|
|
76
|
+
// warnings
|
|
77
|
+
emptyName: "warn",
|
|
78
|
+
fullPathname: "warn",
|
|
79
|
+
hasDot: "warn",
|
|
80
|
+
hasDotdot: "warn",
|
|
81
|
+
hasDotgit: "warn",
|
|
82
|
+
nullSha1: "warn",
|
|
83
|
+
zeroPaddedFilemode: "warn",
|
|
84
|
+
nulInCommit: "warn",
|
|
85
|
+
largePathname: "warn",
|
|
86
|
+
// infos (reported as warnings)
|
|
87
|
+
badFilemode: "info",
|
|
88
|
+
gitmodulesParse: "info",
|
|
89
|
+
gitignoreSymlink: "info",
|
|
90
|
+
gitattributesSymlink: "info",
|
|
91
|
+
mailmapSymlink: "info",
|
|
92
|
+
badTagName: "info",
|
|
93
|
+
missingTaggerEntry: "info",
|
|
94
|
+
// ignored unless asked for
|
|
95
|
+
extraHeaderEntry: "ignore",
|
|
96
|
+
} as const satisfies Record<string, FsckMsgLevel>;
|
|
97
|
+
|
|
98
|
+
/** A message id, in git's camel case. */
|
|
99
|
+
export type FsckMsgId = keyof typeof FSCK_MSG_IDS;
|
|
100
|
+
|
|
101
|
+
/** A message id given in config or on the command line was not one git knows. */
|
|
102
|
+
export class UnknownFsckMsgIdError extends Error {
|
|
103
|
+
override name = "UnknownFsckMsgIdError";
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const BY_DOWNCASED = new Map<string, FsckMsgId>(
|
|
107
|
+
(Object.keys(FSCK_MSG_IDS) as FsckMsgId[]).map((id) => [id.toLowerCase(), id]),
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The message id a config key or argument names (git's `parse_msg_id`: lowercased, underscores
|
|
112
|
+
* dropped), or undefined.
|
|
113
|
+
*/
|
|
114
|
+
export function parseFsckMsgId(text: string): FsckMsgId | undefined {
|
|
115
|
+
return BY_DOWNCASED.get(text.replace(/_/g, "").toLowerCase());
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The severities of one fsck run: git's defaults, `--strict` (warnings become errors, and the
|
|
120
|
+
* nonstandard mode `100664` a bad file mode), then overrides from `fsck.<msg-id>`.
|
|
121
|
+
*/
|
|
122
|
+
export class FsckMessageTypes {
|
|
123
|
+
readonly strict: boolean;
|
|
124
|
+
/** git's max_tree_entry_len, set with `fsck.largePathname=<type>:<length>` */
|
|
125
|
+
maxTreeEntryLength = 4096;
|
|
126
|
+
private readonly overrides = new Map<FsckMsgId, "error" | "warn" | "ignore">();
|
|
127
|
+
|
|
128
|
+
constructor(options: { strict?: boolean } = {}) {
|
|
129
|
+
this.strict = options.strict === true;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Sets a message's type (`error`, `warn` or `ignore`), as `fsck.<msg-id>=<type>` does.
|
|
134
|
+
* `largePathname` takes `<type>:<length>` too. A fatal message can only be set to `error`.
|
|
135
|
+
*/
|
|
136
|
+
set(msgId: string, type: string): void {
|
|
137
|
+
const id = parseFsckMsgId(msgId);
|
|
138
|
+
if (!id) throw new UnknownFsckMsgIdError(`Unhandled message id: ${msgId}`);
|
|
139
|
+
let value = type;
|
|
140
|
+
if (id === "largePathname") {
|
|
141
|
+
const colon = value.indexOf(":");
|
|
142
|
+
if (colon >= 0) {
|
|
143
|
+
const length = Number(value.slice(colon + 1));
|
|
144
|
+
if (!Number.isInteger(length)) {
|
|
145
|
+
throw new UnknownFsckMsgIdError(
|
|
146
|
+
`unable to parse max tree entry len: ${value.slice(colon + 1)}`,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
this.maxTreeEntryLength = length;
|
|
150
|
+
value = value.slice(0, colon);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (value !== "error" && value !== "warn" && value !== "ignore") {
|
|
154
|
+
throw new UnknownFsckMsgIdError(`Unknown fsck message type: '${value}'`);
|
|
155
|
+
}
|
|
156
|
+
if (value !== "error" && FSCK_MSG_IDS[id] === "fatal") {
|
|
157
|
+
throw new UnknownFsckMsgIdError(`Cannot demote ${msgId} to ${value}`);
|
|
158
|
+
}
|
|
159
|
+
this.overrides.set(id, value);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** The level a message has in this run, before fatal/info are folded (git's `fsck_msg_type`). */
|
|
163
|
+
level(id: FsckMsgId): FsckMsgLevel {
|
|
164
|
+
const override = this.overrides.get(id);
|
|
165
|
+
if (override) return override;
|
|
166
|
+
const level: FsckMsgLevel = FSCK_MSG_IDS[id];
|
|
167
|
+
return this.strict && level === "warn" ? "error" : level;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** What a message is reported as: fatal ones as errors, infos as warnings. */
|
|
171
|
+
severity(id: FsckMsgId): FsckSeverity {
|
|
172
|
+
const level = this.level(id);
|
|
173
|
+
if (level === "ignore") return "ignore";
|
|
174
|
+
return level === "fatal" || level === "error" ? "error" : "warning";
|
|
175
|
+
}
|
|
176
|
+
}
|