@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,617 @@
|
|
|
1
|
+
import type { Blobs, ObjectId, TreeEntry } from "@statewalker/vcs-core";
|
|
2
|
+
import { isNullObjectId, type ObjectFormat, SHA1_OBJECT_FORMAT } from "@statewalker/vcs-utils";
|
|
3
|
+
|
|
4
|
+
import type { CommandTrees } from "../git-command.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A notes tree as git's notes.c holds it in memory: a non-balancing 16-tree keyed by the
|
|
8
|
+
* nibbles of the annotated object's id, whose leaves are notes or not-yet-read subtrees of
|
|
9
|
+
* the stored tree (read when a lookup or a change reaches them), and the entries that are no
|
|
10
|
+
* notes (kept and written back). Written back, it takes git's fanout (`determine_fanout`):
|
|
11
|
+
* notes move into 2-digit directories once every slot of a level is taken, so the trees
|
|
12
|
+
* written are those native git writes for the same history of changes.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const t = await NotesTree.load({ blobs, trees }, treeId);
|
|
17
|
+
* await t.add(commitId, noteBlobId, combineNotesOverwrite);
|
|
18
|
+
* const newTree = await t.write();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** SHA-1's null id: `NOTES_NULL_ID` (a SHA-256 tree's is its format's, `NotesTree.nullId`) */
|
|
23
|
+
const NULL_ID = "0".repeat(40);
|
|
24
|
+
|
|
25
|
+
const PTR_NULL = 0;
|
|
26
|
+
const PTR_INTERNAL = 1;
|
|
27
|
+
const PTR_NOTE = 2;
|
|
28
|
+
const PTR_SUBTREE = 3;
|
|
29
|
+
|
|
30
|
+
interface IntNode {
|
|
31
|
+
type: typeof PTR_INTERNAL;
|
|
32
|
+
a: Ptr[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A note (key: the object's id) or a subtree (key: the prefix, padded with zeros, its last
|
|
37
|
+
* byte the prefix length in bytes, as notes.c keeps it).
|
|
38
|
+
*/
|
|
39
|
+
interface Leaf {
|
|
40
|
+
type: typeof PTR_NOTE | typeof PTR_SUBTREE;
|
|
41
|
+
key: string;
|
|
42
|
+
val: ObjectId;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type Ptr = IntNode | Leaf | null;
|
|
46
|
+
|
|
47
|
+
interface NonNote {
|
|
48
|
+
path: string;
|
|
49
|
+
mode: number;
|
|
50
|
+
id: ObjectId;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** How a note added over an existing one combines with it (notes.h's combine_notes_fn). */
|
|
54
|
+
export type CombineNotes = (
|
|
55
|
+
stores: NotesStores,
|
|
56
|
+
cur: ObjectId,
|
|
57
|
+
next: ObjectId,
|
|
58
|
+
) => Promise<ObjectId>;
|
|
59
|
+
|
|
60
|
+
/** The object stores a notes tree reads and writes. */
|
|
61
|
+
export interface NotesStores {
|
|
62
|
+
blobs: Blobs;
|
|
63
|
+
trees: CommandTrees;
|
|
64
|
+
/** The repository's object format (default: the blobs', else SHA-1) */
|
|
65
|
+
objectFormat?: ObjectFormat;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const typeOf = (p: Ptr): number => (p === null ? PTR_NULL : p.type);
|
|
69
|
+
const nibble = (n: number, key: string): number => Number.parseInt(key[n] ?? "0", 16);
|
|
70
|
+
/** A subtree key's prefix length in bytes: its last byte (the key is an id's length long) */
|
|
71
|
+
const prefixLength = (subtreeKey: string): number => Number.parseInt(subtreeKey.slice(-2), 16);
|
|
72
|
+
/** SUBTREE_SHA1_PREFIXCMP: whether `key` starts with the prefix of `subtree` (0: it does). */
|
|
73
|
+
const prefixMatches = (key: string, subtreeKey: string): boolean => {
|
|
74
|
+
const len = prefixLength(subtreeKey) * 2;
|
|
75
|
+
return key.slice(0, len) === subtreeKey.slice(0, len);
|
|
76
|
+
};
|
|
77
|
+
const isHex = (s: string): boolean => /^[0-9a-fA-F]*$/.test(s);
|
|
78
|
+
const isRegular = (mode: number): boolean => (mode & 0o170000) === 0o100000;
|
|
79
|
+
const isDir = (mode: number): boolean => (mode & 0o170000) === 0o040000;
|
|
80
|
+
const newNode = (): IntNode => ({ type: PTR_INTERNAL, a: new Array<Ptr>(16).fill(null) });
|
|
81
|
+
|
|
82
|
+
/** git's strcmp on paths: byte order. */
|
|
83
|
+
function compareBytes(a: string, b: string): number {
|
|
84
|
+
const x = new TextEncoder().encode(a);
|
|
85
|
+
const y = new TextEncoder().encode(b);
|
|
86
|
+
const n = Math.min(x.length, y.length);
|
|
87
|
+
for (let i = 0; i < n; i++) {
|
|
88
|
+
if (x[i] !== y[i]) return (x[i] as number) - (y[i] as number);
|
|
89
|
+
}
|
|
90
|
+
return x.length - y.length;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function readBytes(blobs: Blobs, id: ObjectId): Promise<Uint8Array | undefined> {
|
|
94
|
+
if (isNullObjectId(id)) return undefined;
|
|
95
|
+
const content = await blobs.load(id).catch(() => undefined);
|
|
96
|
+
if (!content) return undefined;
|
|
97
|
+
const chunks: Uint8Array[] = [];
|
|
98
|
+
for await (const chunk of content) chunks.push(chunk);
|
|
99
|
+
if (chunks.length === 1) return chunks[0];
|
|
100
|
+
const out = new Uint8Array(chunks.reduce((n, c) => n + c.length, 0));
|
|
101
|
+
let o = 0;
|
|
102
|
+
for (const c of chunks) {
|
|
103
|
+
out.set(c, o);
|
|
104
|
+
o += c.length;
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** combine_notes_overwrite: the new note replaces the one there. */
|
|
110
|
+
export const combineNotesOverwrite: CombineNotes = async (_s, _cur, next) => next;
|
|
111
|
+
|
|
112
|
+
/** combine_notes_ignore: the note there stays. */
|
|
113
|
+
export const combineNotesIgnore: CombineNotes = async (_s, cur) => cur;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* combine_notes_concatenate: the two notes joined by a blank line (the current one's final
|
|
117
|
+
* newline dropped); an empty or missing side gives the other.
|
|
118
|
+
*/
|
|
119
|
+
export const combineNotesConcatenate: CombineNotes = async (stores, cur, next) => {
|
|
120
|
+
const nextMsg = await readBytes(stores.blobs, next);
|
|
121
|
+
if (!nextMsg || nextMsg.length === 0) return cur;
|
|
122
|
+
const curMsg = await readBytes(stores.blobs, cur);
|
|
123
|
+
if (!curMsg || curMsg.length === 0) return next;
|
|
124
|
+
const curLen = curMsg[curMsg.length - 1] === 0x0a ? curMsg.length - 1 : curMsg.length;
|
|
125
|
+
const buf = new Uint8Array(curLen + 2 + nextMsg.length);
|
|
126
|
+
buf.set(curMsg.subarray(0, curLen), 0);
|
|
127
|
+
buf[curLen] = 0x0a;
|
|
128
|
+
buf[curLen + 1] = 0x0a;
|
|
129
|
+
buf.set(nextMsg, curLen + 2);
|
|
130
|
+
return stores.blobs.store([buf]);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/** git's string_list_split on "\n" of a note's bytes (latin1: byte per character). */
|
|
134
|
+
async function noteLines(stores: NotesStores, id: ObjectId): Promise<string[]> {
|
|
135
|
+
const bytes = await readBytes(stores.blobs, id);
|
|
136
|
+
if (!bytes || bytes.length === 0) return [];
|
|
137
|
+
let text = "";
|
|
138
|
+
for (const b of bytes) text += String.fromCharCode(b);
|
|
139
|
+
return text.split("\n");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* combine_notes_cat_sort_uniq: the lines of both notes, empty ones dropped, sorted (byte
|
|
144
|
+
* order) and unique, each ended by a newline.
|
|
145
|
+
*/
|
|
146
|
+
export const combineNotesCatSortUniq: CombineNotes = async (stores, cur, next) => {
|
|
147
|
+
const lines = [...(await noteLines(stores, cur)), ...(await noteLines(stores, next))].filter(
|
|
148
|
+
(l) => l !== "",
|
|
149
|
+
);
|
|
150
|
+
lines.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
151
|
+
const unique = lines.filter((l, i) => i === 0 || l !== lines[i - 1]);
|
|
152
|
+
const text = unique.map((l) => `${l}\n`).join("");
|
|
153
|
+
const buf = new Uint8Array(text.length);
|
|
154
|
+
for (let i = 0; i < text.length; i++) buf[i] = text.charCodeAt(i);
|
|
155
|
+
return stores.blobs.store([buf]);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/** notes-utils.c's parse_combine_notes_fn (case-insensitive), undefined for another name. */
|
|
159
|
+
export function parseCombineNotes(name: string): CombineNotes | undefined {
|
|
160
|
+
switch (name.toLowerCase()) {
|
|
161
|
+
case "overwrite":
|
|
162
|
+
return combineNotesOverwrite;
|
|
163
|
+
case "ignore":
|
|
164
|
+
return combineNotesIgnore;
|
|
165
|
+
case "concatenate":
|
|
166
|
+
return combineNotesConcatenate;
|
|
167
|
+
case "cat_sort_uniq":
|
|
168
|
+
return combineNotesCatSortUniq;
|
|
169
|
+
default:
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** for_each_note flags (notes.h). */
|
|
175
|
+
export const FOR_EACH_NOTE_DONT_UNPACK_SUBTREES = 1;
|
|
176
|
+
export const FOR_EACH_NOTE_YIELD_SUBTREES = 2;
|
|
177
|
+
|
|
178
|
+
/** A for_each_note callback: true stops the walk. */
|
|
179
|
+
export type EachNote = (
|
|
180
|
+
object: string,
|
|
181
|
+
note: ObjectId,
|
|
182
|
+
path: string,
|
|
183
|
+
) => Promise<boolean | undefined>;
|
|
184
|
+
|
|
185
|
+
interface WriteStack {
|
|
186
|
+
next?: WriteStack;
|
|
187
|
+
entries: TreeEntry[];
|
|
188
|
+
/** The directory being written in `next` ("" when none) */
|
|
189
|
+
path: string;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** notes.c's in-memory notes tree (struct notes_tree). */
|
|
193
|
+
export class NotesTree {
|
|
194
|
+
private readonly root: IntNode = newNode();
|
|
195
|
+
private readonly nonNotes: NonNote[] = [];
|
|
196
|
+
/** A change was made since loading (t->dirty) */
|
|
197
|
+
dirty = false;
|
|
198
|
+
|
|
199
|
+
/** Raw id bytes of the repository's format (20 for SHA-1, 32 for SHA-256): notes' path lengths */
|
|
200
|
+
private readonly raw: number;
|
|
201
|
+
/** The repository's null id: adding it as a note removes one */
|
|
202
|
+
readonly nullId: ObjectId;
|
|
203
|
+
|
|
204
|
+
private constructor(
|
|
205
|
+
private readonly stores: NotesStores,
|
|
206
|
+
/** The tree's combine function (t->combine_notes) */
|
|
207
|
+
readonly combine: CombineNotes,
|
|
208
|
+
) {
|
|
209
|
+
const format = stores.objectFormat ?? stores.blobs.objectFormat ?? SHA1_OBJECT_FORMAT;
|
|
210
|
+
this.raw = format.rawLength;
|
|
211
|
+
this.nullId = format.nullId;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* init_notes's load: the stored tree `treeId` as an unread subtree of the root (read
|
|
216
|
+
* one level now); an empty tree without `treeId`.
|
|
217
|
+
*/
|
|
218
|
+
static async load(
|
|
219
|
+
stores: NotesStores,
|
|
220
|
+
treeId: ObjectId | undefined,
|
|
221
|
+
combine: CombineNotes = combineNotesConcatenate,
|
|
222
|
+
): Promise<NotesTree> {
|
|
223
|
+
const t = new NotesTree(stores, combine);
|
|
224
|
+
if (treeId) await t.loadSubtree({ type: PTR_SUBTREE, key: t.nullId, val: treeId }, t.root, 0);
|
|
225
|
+
return t;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** get_note: the note of `object`, undefined when it has none. */
|
|
229
|
+
async get(object: ObjectId): Promise<ObjectId | undefined> {
|
|
230
|
+
const found = await this.search(this.root, 0, object);
|
|
231
|
+
const p = found.node.a[found.i] ?? null;
|
|
232
|
+
if (p !== null && p.type === PTR_NOTE && p.key === object) return p.val;
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** add_note: `note` for `object`, combined with one there (default: the tree's). */
|
|
237
|
+
async add(object: ObjectId, note: ObjectId, combine?: CombineNotes): Promise<void> {
|
|
238
|
+
this.dirty = true;
|
|
239
|
+
await this.insert(
|
|
240
|
+
this.root,
|
|
241
|
+
0,
|
|
242
|
+
{ type: PTR_NOTE, key: object, val: note },
|
|
243
|
+
combine ?? this.combine,
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** remove_note: whether `object` had a note (then removed). */
|
|
248
|
+
async remove(object: ObjectId): Promise<boolean> {
|
|
249
|
+
const removed = await this.removeLeaf(this.root, 0, object);
|
|
250
|
+
if (removed === undefined) return false;
|
|
251
|
+
this.dirty = true;
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* copy_note: the note of `from` copied to `to` (`to`'s removed when `from` has none);
|
|
257
|
+
* false when `to` has one and `force` is not set.
|
|
258
|
+
*/
|
|
259
|
+
async copy(
|
|
260
|
+
from: ObjectId,
|
|
261
|
+
to: ObjectId,
|
|
262
|
+
force: boolean,
|
|
263
|
+
combine?: CombineNotes,
|
|
264
|
+
): Promise<boolean> {
|
|
265
|
+
const note = await this.get(from);
|
|
266
|
+
const existing = await this.get(to);
|
|
267
|
+
if (!force && existing) return false;
|
|
268
|
+
if (note) await this.add(to, note, combine);
|
|
269
|
+
else if (existing) await this.add(to, this.nullId, combine);
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** for_each_note: the notes (and with the flags, subtrees) in id order. */
|
|
274
|
+
async forEach(flags: number, fn: EachNote): Promise<boolean> {
|
|
275
|
+
return this.forEachHelper(this.root, 0, 0, flags, fn);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* write_notes_tree: the tree objects written, the root's id.
|
|
280
|
+
*
|
|
281
|
+
* The non-notes are woven in as git weaves them: after the last one written (nn_prev),
|
|
282
|
+
* those up to each note's path. A subtree the walk reads meanwhile (one deeper than the
|
|
283
|
+
* fanout) can bring a non-note that sorts before the last one written: git never goes
|
|
284
|
+
* back for it, so it is dropped from the tree written, here too.
|
|
285
|
+
*
|
|
286
|
+
* Known difference: git writes each tree's entries in the order it weaves them, and that
|
|
287
|
+
* order is not always git's tree order (`x` and `x-y` beside a directory `x`, or a
|
|
288
|
+
* non-note of a subtree read late that sorts before an entry already written); git then
|
|
289
|
+
* writes an unsorted tree. Trees here go through the tree store, which writes its entries
|
|
290
|
+
* sorted (there is no writer of raw entry order), so such a tree gets another id.
|
|
291
|
+
*/
|
|
292
|
+
async write(): Promise<ObjectId> {
|
|
293
|
+
const root: WriteStack = { entries: [], path: "" };
|
|
294
|
+
/** nn_prev: the last non-note woven in, and where it was in the list then */
|
|
295
|
+
let prev: NonNote | undefined;
|
|
296
|
+
let prevIndex = -1;
|
|
297
|
+
const writeNonNotesUntil = async (notePath: string | undefined) => {
|
|
298
|
+
// the entry after nn_prev (inserts before it shift its index)
|
|
299
|
+
if (prev !== undefined && this.nonNotes[prevIndex] !== prev) {
|
|
300
|
+
prevIndex = this.nonNotes.indexOf(prev);
|
|
301
|
+
}
|
|
302
|
+
let i = prevIndex + 1;
|
|
303
|
+
while (i < this.nonNotes.length) {
|
|
304
|
+
const n = this.nonNotes[i] as NonNote;
|
|
305
|
+
const cmp = notePath === undefined ? -1 : compareBytes(n.path, notePath);
|
|
306
|
+
if (notePath !== undefined && cmp > 0) break;
|
|
307
|
+
// prefer note to non-note
|
|
308
|
+
if (!(notePath !== undefined && cmp === 0)) {
|
|
309
|
+
await this.writeEntry(root, n.path, n.mode, n.id);
|
|
310
|
+
}
|
|
311
|
+
prev = n;
|
|
312
|
+
prevIndex = i;
|
|
313
|
+
i++;
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
await this.forEach(
|
|
317
|
+
FOR_EACH_NOTE_DONT_UNPACK_SUBTREES | FOR_EACH_NOTE_YIELD_SUBTREES,
|
|
318
|
+
async (_object, note, path) => {
|
|
319
|
+
let notePath = path;
|
|
320
|
+
let mode = 0o100644;
|
|
321
|
+
if (notePath.endsWith("/")) {
|
|
322
|
+
notePath = notePath.slice(0, -1);
|
|
323
|
+
mode = 0o040000;
|
|
324
|
+
}
|
|
325
|
+
await writeNonNotesUntil(notePath);
|
|
326
|
+
await this.writeEntry(root, notePath, mode, note);
|
|
327
|
+
return false;
|
|
328
|
+
},
|
|
329
|
+
);
|
|
330
|
+
await writeNonNotesUntil(undefined);
|
|
331
|
+
await this.finishSubtree(root);
|
|
332
|
+
return this.stores.trees.storeTree(root.entries);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* prune_notes's walk: the objects whose notes `exists` refuses, in the order git lists them
|
|
337
|
+
* (the walk's, reversed).
|
|
338
|
+
*/
|
|
339
|
+
async unreachableObjects(exists: (id: ObjectId) => Promise<boolean>): Promise<ObjectId[]> {
|
|
340
|
+
const list: ObjectId[] = [];
|
|
341
|
+
await this.forEach(0, async (object) => {
|
|
342
|
+
if (!(await exists(object))) list.push(object);
|
|
343
|
+
return false;
|
|
344
|
+
});
|
|
345
|
+
return list.reverse();
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// ---- notes.c internals ----
|
|
349
|
+
|
|
350
|
+
/** note_tree_search: the slot for `key` (subtrees on the way read). */
|
|
351
|
+
private async search(
|
|
352
|
+
tree: IntNode,
|
|
353
|
+
n: number,
|
|
354
|
+
key: string,
|
|
355
|
+
): Promise<{ node: IntNode; n: number; i: number }> {
|
|
356
|
+
let p = tree.a[0] ?? null;
|
|
357
|
+
if (p !== null && p.type === PTR_SUBTREE && prefixMatches(key, p.key)) {
|
|
358
|
+
tree.a[0] = null;
|
|
359
|
+
await this.loadSubtree(p, tree, n);
|
|
360
|
+
return this.search(tree, n, key);
|
|
361
|
+
}
|
|
362
|
+
const i = nibble(n, key);
|
|
363
|
+
p = tree.a[i] ?? null;
|
|
364
|
+
if (p !== null && p.type === PTR_INTERNAL) return this.search(p, n + 1, key);
|
|
365
|
+
if (p !== null && p.type === PTR_SUBTREE && prefixMatches(key, p.key)) {
|
|
366
|
+
tree.a[i] = null;
|
|
367
|
+
await this.loadSubtree(p, tree, n);
|
|
368
|
+
return this.search(tree, n, key);
|
|
369
|
+
}
|
|
370
|
+
return { node: tree, n, i };
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** note_tree_consolidate: an int_node of one note (or none) replaced by it. */
|
|
374
|
+
private consolidate(tree: IntNode, parent: IntNode, index: number): boolean {
|
|
375
|
+
let p: Ptr = null;
|
|
376
|
+
for (let i = 0; i < 16; i++) {
|
|
377
|
+
if (typeOf(tree.a[i] ?? null) !== PTR_NULL) {
|
|
378
|
+
if (p) return false;
|
|
379
|
+
p = tree.a[i] ?? null;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (p && p.type !== PTR_NOTE) return false;
|
|
383
|
+
parent.a[index] = p;
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** note_tree_remove: the note of `key` removed, its value; undefined when none. */
|
|
388
|
+
private async removeLeaf(tree: IntNode, n0: number, key: string): Promise<ObjectId | undefined> {
|
|
389
|
+
const { node, n, i } = await this.search(tree, n0, key);
|
|
390
|
+
const p = node.a[i] ?? null;
|
|
391
|
+
if (p === null || p.type !== PTR_NOTE || p.key !== key) return undefined;
|
|
392
|
+
node.a[i] = null;
|
|
393
|
+
if (n === 0) return p.val;
|
|
394
|
+
const stack: IntNode[] = [this.root];
|
|
395
|
+
for (let k = 0; k < n; k++) {
|
|
396
|
+
stack.push((stack[k] as IntNode).a[nibble(k, key)] as IntNode);
|
|
397
|
+
}
|
|
398
|
+
let k = n;
|
|
399
|
+
while (
|
|
400
|
+
k > 0 &&
|
|
401
|
+
this.consolidate(stack[k] as IntNode, stack[k - 1] as IntNode, nibble(k - 1, key))
|
|
402
|
+
) {
|
|
403
|
+
k--;
|
|
404
|
+
}
|
|
405
|
+
return p.val;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** note_tree_insert */
|
|
409
|
+
private async insert(
|
|
410
|
+
tree: IntNode,
|
|
411
|
+
n0: number,
|
|
412
|
+
entry: Leaf,
|
|
413
|
+
combine: CombineNotes,
|
|
414
|
+
): Promise<void> {
|
|
415
|
+
const { node, n, i } = await this.search(tree, n0, entry.key);
|
|
416
|
+
const l = node.a[i] ?? null;
|
|
417
|
+
if (l === null) {
|
|
418
|
+
if (!isNullObjectId(entry.val)) node.a[i] = entry;
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (l.type === PTR_NOTE) {
|
|
422
|
+
if (entry.type === PTR_NOTE) {
|
|
423
|
+
if (l.key === entry.key) {
|
|
424
|
+
if (l.val === entry.val) return;
|
|
425
|
+
l.val = await combine(this.stores, l.val, entry.val);
|
|
426
|
+
if (isNullObjectId(l.val)) await this.removeLeaf(node, n, entry.key);
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
} else if (prefixMatches(l.key, entry.key)) {
|
|
430
|
+
await this.loadSubtree(entry, node, n);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
} else if (l.type === PTR_SUBTREE) {
|
|
434
|
+
if (prefixMatches(entry.key, l.key)) {
|
|
435
|
+
node.a[i] = null;
|
|
436
|
+
await this.loadSubtree(l, node, n);
|
|
437
|
+
return this.insert(node, n, entry, combine);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
// a non-matching leaf: both under a new int_node
|
|
441
|
+
if (isNullObjectId(entry.val)) return;
|
|
442
|
+
const created = newNode();
|
|
443
|
+
await this.insert(created, n + 1, l as Leaf, combine);
|
|
444
|
+
node.a[i] = created;
|
|
445
|
+
await this.insert(created, n + 1, entry, combine);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** add_non_note: sorted by path, a path given again replacing the entry. */
|
|
449
|
+
private addNonNote(path: string, mode: number, id: ObjectId): void {
|
|
450
|
+
let lo = 0;
|
|
451
|
+
let hi = this.nonNotes.length;
|
|
452
|
+
while (lo < hi) {
|
|
453
|
+
const mid = (lo + hi) >> 1;
|
|
454
|
+
if (compareBytes((this.nonNotes[mid] as NonNote).path, path) < 0) lo = mid + 1;
|
|
455
|
+
else hi = mid;
|
|
456
|
+
}
|
|
457
|
+
const at = this.nonNotes[lo];
|
|
458
|
+
if (at && at.path === path) {
|
|
459
|
+
at.mode = mode;
|
|
460
|
+
at.id = id;
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
this.nonNotes.splice(lo, 0, { path, mode, id });
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/** load_subtree: the entries of a stored (sub)tree inserted at `node`, level `n`. */
|
|
467
|
+
private async loadSubtree(subtree: Leaf, node: IntNode, n: number): Promise<void> {
|
|
468
|
+
const prefixLen = prefixLength(subtree.key);
|
|
469
|
+
const prefix = subtree.key.slice(0, prefixLen * 2);
|
|
470
|
+
const entries: TreeEntry[] = [];
|
|
471
|
+
const loaded = this.stores.trees.loadTree(subtree.val);
|
|
472
|
+
for await (const e of loaded) entries.push(e);
|
|
473
|
+
for (const entry of entries) {
|
|
474
|
+
const name = entry.name;
|
|
475
|
+
let leaf: Leaf | undefined;
|
|
476
|
+
if (name.length === 2 * (this.raw - prefixLen)) {
|
|
477
|
+
if (isRegular(entry.mode) && isHex(name)) {
|
|
478
|
+
leaf = { type: PTR_NOTE, key: prefix + name.toLowerCase(), val: entry.id };
|
|
479
|
+
}
|
|
480
|
+
} else if (name.length === 2) {
|
|
481
|
+
if (isDir(entry.mode) && isHex(name)) {
|
|
482
|
+
const len = prefixLen + 1;
|
|
483
|
+
const key =
|
|
484
|
+
prefix +
|
|
485
|
+
name.toLowerCase() +
|
|
486
|
+
"00".repeat(this.raw - len - 1) +
|
|
487
|
+
len.toString(16).padStart(2, "0");
|
|
488
|
+
leaf = { type: PTR_SUBTREE, key, val: entry.id };
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (leaf) {
|
|
492
|
+
await this.insert(node, n, leaf, combineNotesConcatenate);
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
// a non-note: its path from the fanout of the subtree it is in
|
|
496
|
+
let path = "";
|
|
497
|
+
for (let i = 0; i < prefixLen; i++) path += `${subtree.key.slice(2 * i, 2 * i + 2)}/`;
|
|
498
|
+
this.addNonNote(path + name, entry.mode, entry.id);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/** determine_fanout */
|
|
503
|
+
private determineFanout(tree: IntNode, n: number, fanout: number): number {
|
|
504
|
+
if (n % 2 || n > 2 * fanout) return fanout;
|
|
505
|
+
for (let i = 0; i < 16; i++) {
|
|
506
|
+
const t = typeOf(tree.a[i] ?? null);
|
|
507
|
+
if (t !== PTR_SUBTREE && t !== PTR_INTERNAL) return fanout;
|
|
508
|
+
}
|
|
509
|
+
return fanout + 1;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/** for_each_note_helper */
|
|
513
|
+
private async forEachHelper(
|
|
514
|
+
tree: IntNode,
|
|
515
|
+
n: number,
|
|
516
|
+
fanoutIn: number,
|
|
517
|
+
flags: number,
|
|
518
|
+
fn: EachNote,
|
|
519
|
+
): Promise<boolean> {
|
|
520
|
+
const fanout = this.determineFanout(tree, n, fanoutIn);
|
|
521
|
+
for (let i = 0; i < 16; i++) {
|
|
522
|
+
let ret = false;
|
|
523
|
+
for (;;) {
|
|
524
|
+
const p = tree.a[i] ?? null;
|
|
525
|
+
if (p === null) break;
|
|
526
|
+
if (p.type === PTR_INTERNAL) {
|
|
527
|
+
ret = await this.forEachHelper(p, n + 1, fanout, flags, fn);
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
if (p.type === PTR_SUBTREE) {
|
|
531
|
+
if (n < 2 * fanout && flags & FOR_EACH_NOTE_YIELD_SUBTREES) {
|
|
532
|
+
const pathLen = prefixLength(p.key) * 2 + fanout;
|
|
533
|
+
let path = pathWithFanout(p.key, fanout).slice(0, pathLen);
|
|
534
|
+
if (!path.endsWith("/")) path += "/";
|
|
535
|
+
ret = (await fn(p.key, p.val, path)) === true;
|
|
536
|
+
}
|
|
537
|
+
if (n >= 2 * fanout || !(flags & FOR_EACH_NOTE_DONT_UNPACK_SUBTREES)) {
|
|
538
|
+
tree.a[i] = null;
|
|
539
|
+
await this.loadSubtree(p, tree, n);
|
|
540
|
+
if (ret) return true;
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
ret = (await fn(p.key, p.val, pathWithFanout(p.key, fanout))) === true;
|
|
546
|
+
break;
|
|
547
|
+
}
|
|
548
|
+
if (ret) return true;
|
|
549
|
+
}
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/** tree_write_stack_finish_subtree */
|
|
554
|
+
private async finishSubtree(tws: WriteStack): Promise<void> {
|
|
555
|
+
const n = tws.next;
|
|
556
|
+
if (!n) return;
|
|
557
|
+
await this.finishSubtree(n);
|
|
558
|
+
const id = await this.stores.trees.storeTree(n.entries);
|
|
559
|
+
tws.next = undefined;
|
|
560
|
+
tws.entries.push({ mode: 0o040000, name: tws.path, id });
|
|
561
|
+
tws.path = "";
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/** write_each_note_helper */
|
|
565
|
+
private async writeEntry(
|
|
566
|
+
root: WriteStack,
|
|
567
|
+
path: string,
|
|
568
|
+
mode: number,
|
|
569
|
+
id: ObjectId,
|
|
570
|
+
): Promise<void> {
|
|
571
|
+
let tws: WriteStack = root;
|
|
572
|
+
let n = 0;
|
|
573
|
+
while (
|
|
574
|
+
3 * n < path.length &&
|
|
575
|
+
tws.path !== "" &&
|
|
576
|
+
path.slice(3 * n, 3 * n + 2) === tws.path &&
|
|
577
|
+
path[3 * n + 2] === "/"
|
|
578
|
+
) {
|
|
579
|
+
n++;
|
|
580
|
+
tws = tws.next as WriteStack;
|
|
581
|
+
}
|
|
582
|
+
await this.finishSubtree(tws);
|
|
583
|
+
while (3 * n + 2 < path.length && path[3 * n + 2] === "/") {
|
|
584
|
+
const next: WriteStack = { entries: [], path: "" };
|
|
585
|
+
tws.next = next;
|
|
586
|
+
tws.path = path.slice(3 * n, 3 * n + 2);
|
|
587
|
+
n++;
|
|
588
|
+
tws = next;
|
|
589
|
+
}
|
|
590
|
+
tws.entries.push({ mode, name: path.slice(3 * n), id });
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/** construct_path_with_fanout: `fanout` 2-digit directories, then the rest of the id. */
|
|
595
|
+
function pathWithFanout(key: string, fanout: number): string {
|
|
596
|
+
let out = "";
|
|
597
|
+
let j = 0;
|
|
598
|
+
for (let f = 0; f < fanout; f++) {
|
|
599
|
+
out += `${key.slice(j, j + 2)}/`;
|
|
600
|
+
j += 2;
|
|
601
|
+
}
|
|
602
|
+
return out + key.slice(j);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/** notes.c's GIT_NOTES_DEFAULT_REF */
|
|
606
|
+
export const NOTES_DEFAULT_REF = "refs/notes/commits";
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* SHA-1's null object id, which adding as a note removes one (any format's null id does: see
|
|
610
|
+
* `NotesTree.nullId` for the repository's own).
|
|
611
|
+
*/
|
|
612
|
+
export const NOTES_NULL_ID = NULL_ID;
|
|
613
|
+
|
|
614
|
+
/** Reads a note blob's bytes (undefined for a missing one). */
|
|
615
|
+
export function readNoteBytes(blobs: Blobs, id: ObjectId): Promise<Uint8Array | undefined> {
|
|
616
|
+
return readBytes(blobs, id);
|
|
617
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object ids as the commands take them from callers.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const FULL_HEX = /^(?:[0-9a-fA-F]{40}|[0-9a-fA-F]{64})$/;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A full hexadecimal object id in the form stores and refs hold it: lowercase, as git's
|
|
11
|
+
* `get_oid_hex` reads either case (`ABCD...` names the object `abcd...`). Anything else is
|
|
12
|
+
* returned as given.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* canonicalObjectId("D90F7D2AD59FC2F2D12C4A4BAEA96C445B5E625D"); // "d90f7d2a..."
|
|
17
|
+
* canonicalObjectId("main"); // "main"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function canonicalObjectId<T extends string>(id: T): T {
|
|
21
|
+
return (FULL_HEX.test(id) ? id.toLowerCase() : id) as T;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Whether `id` is a full hexadecimal object id, in either case. */
|
|
25
|
+
export function isFullHexObjectId(id: string): boolean {
|
|
26
|
+
return FULL_HEX.test(id);
|
|
27
|
+
}
|