@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
|
@@ -1,14 +1,44 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { FileMode, type ObjectId, type TreeEntry } from "@statewalker/vcs-core";
|
|
2
|
+
import {
|
|
3
|
+
compareWithWorktree,
|
|
4
|
+
type IndexEntry,
|
|
5
|
+
type Worktree,
|
|
6
|
+
withWorktreeEntries,
|
|
7
|
+
} from "@statewalker/vcs-working-tree";
|
|
2
8
|
|
|
3
|
-
import { NoFilepatternError } from "../errors/index.js";
|
|
9
|
+
import { InvalidConfigError, NoFilepatternError, RmFailedError } from "../errors/index.js";
|
|
4
10
|
import { GitCommand } from "../git-command.js";
|
|
11
|
+
import { worktreeModeTrust } from "./core-config.js";
|
|
12
|
+
import { IndexAdder } from "./index-adder.js";
|
|
13
|
+
import { configBool } from "./merge-config.js";
|
|
14
|
+
import {
|
|
15
|
+
DO_MATCH_DIRECTORY,
|
|
16
|
+
MATCHED_RECURSIVELY,
|
|
17
|
+
matchPathspecSeen,
|
|
18
|
+
parsePathspec,
|
|
19
|
+
} from "./pathspec.js";
|
|
20
|
+
import { PathspecAttributes } from "./pathspec-attributes.js";
|
|
21
|
+
import { sparsePathAdvice } from "./sparse-checkout-support.js";
|
|
22
|
+
import { StatusCommand } from "./status-command.js";
|
|
23
|
+
import { parseGitmodules } from "./submodule-config.js";
|
|
24
|
+
import {
|
|
25
|
+
pruneEmptyParents,
|
|
26
|
+
removeDirectoryIfEmpty,
|
|
27
|
+
statThroughLeadingLinks,
|
|
28
|
+
} from "./worktree-overwrite-checks.js";
|
|
5
29
|
|
|
6
30
|
/**
|
|
7
31
|
* Result of RmCommand execution.
|
|
8
32
|
*/
|
|
9
33
|
export interface RmResult {
|
|
10
|
-
/** Paths that were removed from the index */
|
|
34
|
+
/** Paths that were removed from the index (each once, whatever its stages) */
|
|
11
35
|
removedPaths: string[];
|
|
36
|
+
/**
|
|
37
|
+
* What could not be done once the removal was under way, the index written all the same:
|
|
38
|
+
* a file that could not be deleted after another one was (git passes over it silently),
|
|
39
|
+
* a submodule `.gitmodules` names no section for (git's warning)
|
|
40
|
+
*/
|
|
41
|
+
warnings?: string[];
|
|
12
42
|
}
|
|
13
43
|
|
|
14
44
|
/**
|
|
@@ -31,15 +61,80 @@ export interface RmResult {
|
|
|
31
61
|
* .setCached(true)
|
|
32
62
|
* .call();
|
|
33
63
|
*
|
|
34
|
-
* // Remove directory recursively
|
|
64
|
+
* // Remove directory recursively (`git rm -r`)
|
|
35
65
|
* await git.rm()
|
|
36
66
|
* .addFilepattern("src/old/")
|
|
67
|
+
* .setRecursive(true)
|
|
37
68
|
* .call();
|
|
38
69
|
* ```
|
|
39
70
|
*/
|
|
40
71
|
export class RmCommand extends GitCommand<RmResult> {
|
|
41
72
|
private filepatterns: string[] = [];
|
|
42
73
|
private cached = false;
|
|
74
|
+
private sparse = false;
|
|
75
|
+
private recursive = false;
|
|
76
|
+
private ignoreUnmatch = false;
|
|
77
|
+
private force = false;
|
|
78
|
+
private compatibility: "2.43" | "2.56" = "2.56";
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* `--sparse`: entries outside the sparse checkout (skip-worktree, or out of the patterns)
|
|
82
|
+
* are removed too. Without it a pattern that matches only such entries is refused with
|
|
83
|
+
* git's advice ({@link RmFailedError}), the other patterns removed all the same.
|
|
84
|
+
*/
|
|
85
|
+
setSparse(sparse: boolean): this {
|
|
86
|
+
this.checkCallable();
|
|
87
|
+
this.sparse = sparse;
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* `-r`: a pattern may name a directory (or `.`), removing every entry beneath. Without it
|
|
93
|
+
* such a pattern is refused before anything changes ("not removing 'd' recursively
|
|
94
|
+
* without -r"), as git does.
|
|
95
|
+
*/
|
|
96
|
+
setRecursive(recursive: boolean): this {
|
|
97
|
+
this.checkCallable();
|
|
98
|
+
this.recursive = recursive;
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* `--ignore-unmatch`: a pattern that matches no entry is passed over. Without it git dies
|
|
104
|
+
* before anything changes ("pathspec 'x' did not match any files").
|
|
105
|
+
*/
|
|
106
|
+
setIgnoreUnmatch(ignoreUnmatch: boolean): this {
|
|
107
|
+
this.checkCallable();
|
|
108
|
+
this.ignoreUnmatch = ignoreUnmatch;
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* `-f`: remove entries whatever they hold. Without it git's `check_local_mod` refuses,
|
|
114
|
+
* before anything changes ({@link RmFailedError}), an entry whose staged content differs
|
|
115
|
+
* from both its file and HEAD (with `--cached` too, unless it is intent-to-add), and,
|
|
116
|
+
* without `--cached`, one whose staged content differs from HEAD or whose file differs
|
|
117
|
+
* from the index: a submodule whose own worktree holds changes (modified, staged or
|
|
118
|
+
* untracked files, ignored ones aside) included, as a file reached through a symbolic link
|
|
119
|
+
* among the leading directories. Even forced, nothing is removed through such a link.
|
|
120
|
+
*/
|
|
121
|
+
setForce(force: boolean): this {
|
|
122
|
+
this.checkCallable();
|
|
123
|
+
this.force = force;
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The git version whose behaviour is reproduced where versions differ (default 2.56): the
|
|
129
|
+
* advice's last hint, as `AddCommand.setCompatibility`, and 2.43's pathspec matching, where
|
|
130
|
+
* an element that named an entry exactly matches no later entry (`rm 'b*'` with an entry
|
|
131
|
+
* `b*` removes only that one).
|
|
132
|
+
*/
|
|
133
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
134
|
+
this.checkCallable();
|
|
135
|
+
this.compatibility = version;
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
43
138
|
|
|
44
139
|
/**
|
|
45
140
|
* Add a file pattern to remove.
|
|
@@ -56,7 +151,12 @@ export class RmCommand extends GitCommand<RmResult> {
|
|
|
56
151
|
* Set whether to only remove from index (keep in working tree).
|
|
57
152
|
*
|
|
58
153
|
* When true, files are only removed from the staging area
|
|
59
|
-
* but remain in the working directory (like `git rm --cached`).
|
|
154
|
+
* but remain in the working directory (like `git rm --cached`). Otherwise the files of
|
|
155
|
+
* the removed entries are deleted too and the directories they leave empty pruned (git's
|
|
156
|
+
* `remove_path`); a submodule's directory goes with everything in it where its repository
|
|
157
|
+
* lives in the superproject (a gitfile), its `.gitmodules` section is removed and the
|
|
158
|
+
* file staged again. A submodule holding its own `.git` directory keeps its directory (git
|
|
159
|
+
* absorbs the repository first, which is not reproduced).
|
|
60
160
|
*
|
|
61
161
|
* @param cached true to only remove from index
|
|
62
162
|
*/
|
|
@@ -81,98 +181,544 @@ export class RmCommand extends GitCommand<RmResult> {
|
|
|
81
181
|
async call(): Promise<RmResult> {
|
|
82
182
|
this.checkCallable();
|
|
83
183
|
this.setCallable(false);
|
|
184
|
+
// the index as it is now, before the worktree or a ref is touched: one another writer
|
|
185
|
+
// replaced is read again (git reads the index at its start), unless this instance holds
|
|
186
|
+
// unwritten edits (refused)
|
|
187
|
+
await this.readCurrentIndex();
|
|
84
188
|
|
|
85
189
|
if (this.filepatterns.length === 0) {
|
|
86
190
|
throw new NoFilepatternError("At least one file pattern is required");
|
|
87
191
|
}
|
|
88
192
|
|
|
89
193
|
const removedPaths: string[] = [];
|
|
194
|
+
const removedEntries: IndexEntry[] = [];
|
|
195
|
+
// (the index as readCurrentIndex left it: reading it again would bring back the
|
|
196
|
+
// skip-worktree flags cleared for files present in a sparse checkout)
|
|
90
197
|
|
|
91
|
-
//
|
|
92
|
-
|
|
198
|
+
// cmd_rm: a skip-worktree entry, and with a sparse checkout an entry out of its
|
|
199
|
+
// patterns, is passed over unless --sparse (whether or not core.sparseCheckout is set);
|
|
200
|
+
// a pattern that matched only those is advised on (matches_skip_worktree)
|
|
201
|
+
const patterns = this.sparse ? undefined : await this.sparseCheckoutPatterns();
|
|
202
|
+
// git's pathspec (parse_pathspec, then ce_path_match): `.` and `./d` name everything
|
|
203
|
+
// beneath, a directory its files, a glob's `*` crosses slashes; `seen` tells which
|
|
204
|
+
// elements matched (git's ps_matched)
|
|
205
|
+
const items = parsePathspec(this.filepatterns, { attr: true });
|
|
206
|
+
// `:(attr:...)`: the attributes of the index's paths (match_pathspec_attrs)
|
|
207
|
+
const attributes = PathspecAttributes.forWorktree(items, this.worktreeAccess);
|
|
208
|
+
if (attributes) {
|
|
209
|
+
const paths: string[] = [];
|
|
210
|
+
for await (const entry of this.staging.entries()) paths.push(entry.path);
|
|
211
|
+
await attributes.load(paths);
|
|
212
|
+
}
|
|
213
|
+
const seen = items.map(() => 0);
|
|
214
|
+
const seenOutside = items.map(() => 0);
|
|
215
|
+
const exactStopsGlobs = this.compatibility === "2.43";
|
|
216
|
+
const removedSet = new Set<string>();
|
|
217
|
+
let gitmodulesEntry: IndexEntry | undefined;
|
|
218
|
+
let removesSubmodule = false;
|
|
219
|
+
for await (const entry of this.staging.entries()) {
|
|
220
|
+
if (entry.path === ".gitmodules" && entry.stage === 0) gitmodulesEntry = entry;
|
|
221
|
+
// ce_path_match: a submodule matches `sub/` as a directory would
|
|
222
|
+
const flags = entry.mode === FileMode.GITLINK ? DO_MATCH_DIRECTORY : 0;
|
|
223
|
+
const outside =
|
|
224
|
+
!this.sparse &&
|
|
225
|
+
(entry.skipWorktree || (patterns !== undefined && !patterns.includes(entry.path)));
|
|
226
|
+
if (outside) {
|
|
227
|
+
matchPathspecSeen(items, entry.path, flags, seenOutside, exactStopsGlobs);
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
if (matchPathspecSeen(items, entry.path, flags, seen, exactStopsGlobs)) {
|
|
231
|
+
if (!removedSet.has(entry.path)) removedPaths.push(entry.path);
|
|
232
|
+
removedSet.add(entry.path);
|
|
233
|
+
removedEntries.push(entry);
|
|
234
|
+
if (entry.mode === FileMode.GITLINK) removesSubmodule = true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// is_staging_gitmodules_ok: a submodule is not removed while .gitmodules holds changes
|
|
238
|
+
// the index does not
|
|
239
|
+
const worktree = this.worktreeAccess;
|
|
240
|
+
if (removesSubmodule && gitmodulesEntry && worktree) {
|
|
241
|
+
const compared = await compareWithWorktree(worktree, gitmodulesEntry, {
|
|
242
|
+
trust: worktreeModeTrust(this.workingCopy, worktree),
|
|
243
|
+
indexTime: this.staging.getUpdateTime(),
|
|
244
|
+
}).catch(() => undefined);
|
|
245
|
+
if (
|
|
246
|
+
compared?.kind === "modified" &&
|
|
247
|
+
compared.worktreeEntry &&
|
|
248
|
+
!compared.worktreeEntry.isDirectory
|
|
249
|
+
) {
|
|
250
|
+
const staged = compared.hashedId ?? (await worktree.computeHash(".gitmodules"));
|
|
251
|
+
if (staged !== gitmodulesEntry.objectId) {
|
|
252
|
+
throw new RmFailedError(
|
|
253
|
+
"fatal: please stage your changes to .gitmodules or stash them to proceed",
|
|
254
|
+
[],
|
|
255
|
+
{ removedPaths: [] },
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// cmd_rm's check of each element, in order, before anything is written: one that matched
|
|
261
|
+
// nothing dies (unless --ignore-unmatch, or it matched only entries outside the sparse
|
|
262
|
+
// checkout), one that named a directory needs -r (an implicit `.` is shown as `.`)
|
|
263
|
+
const sparsePaths: string[] = [];
|
|
264
|
+
let seenAny = false;
|
|
265
|
+
for (let i = 0; i < items.length; i++) {
|
|
266
|
+
const original = this.filepatterns[i] ?? "";
|
|
267
|
+
if (seen[i]) seenAny = true;
|
|
268
|
+
else if (this.ignoreUnmatch) continue;
|
|
269
|
+
else if (seenOutside[i]) sparsePaths.push(original);
|
|
270
|
+
else {
|
|
271
|
+
throw new RmFailedError(`fatal: pathspec '${original}' did not match any files`, [], {
|
|
272
|
+
removedPaths: [],
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
if (!this.recursive && seen[i] === MATCHED_RECURSIVELY) {
|
|
276
|
+
throw new RmFailedError(
|
|
277
|
+
`fatal: not removing '${original || "."}' recursively without -r`,
|
|
278
|
+
[],
|
|
279
|
+
{ removedPaths: [] },
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const matched = seenAny;
|
|
284
|
+
const advise = (result: RmResult = { removedPaths }) =>
|
|
285
|
+
new RmFailedError(
|
|
286
|
+
sparsePathAdvice(
|
|
287
|
+
sparsePaths,
|
|
288
|
+
configBool(this.workingCopy, "advice.updateSparsePath", true),
|
|
289
|
+
this.compatibility,
|
|
290
|
+
).join("\n"),
|
|
291
|
+
sparsePaths,
|
|
292
|
+
result,
|
|
293
|
+
);
|
|
294
|
+
// nothing else matched: git exits before writing anything
|
|
295
|
+
if (sparsePaths.length > 0 && !matched) throw advise();
|
|
296
|
+
// nothing matched at all (every element passed over by --ignore-unmatch)
|
|
297
|
+
if (!matched) return { removedPaths: [] };
|
|
93
298
|
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
299
|
+
// remove_path_from_gitmodules dies on an unmerged .gitmodules (checked before anything
|
|
300
|
+
// changes here, where git has removed the files already)
|
|
301
|
+
const editsGitmodules = removesSubmodule && !this.cached && worktree !== undefined;
|
|
302
|
+
if (editsGitmodules && (await this.gitmodulesUnmerged())) {
|
|
303
|
+
throw new RmFailedError(
|
|
304
|
+
"fatal: Cannot change unmerged .gitmodules, resolve merge conflicts first",
|
|
305
|
+
[],
|
|
306
|
+
{ removedPaths: [] },
|
|
307
|
+
);
|
|
308
|
+
}
|
|
101
309
|
|
|
102
|
-
|
|
103
|
-
|
|
310
|
+
// check_local_mod: unless forced, nothing is removed that the index alone holds
|
|
311
|
+
if (!this.force) {
|
|
312
|
+
const refusal = await this.checkLocalMod(removedEntries, worktree);
|
|
313
|
+
if (refusal) throw new RmFailedError(refusal, [], { removedPaths: [] });
|
|
314
|
+
}
|
|
104
315
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
316
|
+
// the files first (git commits the index only once they are gone): the first that cannot
|
|
317
|
+
// be removed dies before anything changes, a later one is passed over (the index is
|
|
318
|
+
// written all the same)
|
|
319
|
+
const warnings: string[] = [];
|
|
320
|
+
const removedSubmodules: string[] = [];
|
|
321
|
+
if (!this.cached && worktree) {
|
|
322
|
+
let removed = false;
|
|
323
|
+
const done = new Set<string>();
|
|
324
|
+
for (const entry of removedEntries) {
|
|
325
|
+
if (done.has(entry.path)) continue;
|
|
326
|
+
done.add(entry.path);
|
|
327
|
+
let failure: string | undefined;
|
|
328
|
+
try {
|
|
329
|
+
if (!(await removeWorktreePath(worktree, entry))) failure = "Is a directory";
|
|
330
|
+
} catch (error) {
|
|
331
|
+
failure = errnoMessage(error);
|
|
332
|
+
}
|
|
333
|
+
if (failure === undefined) {
|
|
334
|
+
removed = true;
|
|
335
|
+
if (entry.mode === FileMode.GITLINK) removedSubmodules.push(entry.path);
|
|
336
|
+
} else if (!removed) {
|
|
337
|
+
throw new RmFailedError(`fatal: git rm: '${entry.path}': ${failure}`, [], {
|
|
338
|
+
removedPaths: [],
|
|
339
|
+
});
|
|
340
|
+
} else {
|
|
341
|
+
warnings.push(`warning: git rm: '${entry.path}': ${failure}`);
|
|
342
|
+
}
|
|
114
343
|
}
|
|
115
344
|
}
|
|
345
|
+
// remove_path_from_gitmodules of each submodule removed, then the file staged again
|
|
346
|
+
// (stage_updated_gitmodules)
|
|
347
|
+
let gitmodulesEdited = false;
|
|
348
|
+
if (worktree && removedSubmodules.length > 0) {
|
|
349
|
+
gitmodulesEdited = await this.removeFromGitmodules(worktree, removedSubmodules, warnings);
|
|
350
|
+
}
|
|
116
351
|
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
352
|
+
// git's remove_file_from_index: every stage of each path goes (conflicts kept as
|
|
353
|
+
// resolve-undo); the kept entries go on as they are, flags and stat data included
|
|
354
|
+
const trust = worktree
|
|
355
|
+
? worktreeModeTrust(this.workingCopy, worktree)
|
|
356
|
+
: { executable: true, symlinks: true };
|
|
357
|
+
const adder = await IndexAdder.open(this.staging, this.blobs, trust);
|
|
358
|
+
for (const path of removedPaths) adder.remove(path);
|
|
359
|
+
if (gitmodulesEdited && worktree) {
|
|
360
|
+
const entry = await worktree.getEntry(".gitmodules");
|
|
361
|
+
if (entry && !entry.isDirectory) await adder.add(worktree, ".gitmodules", entry);
|
|
121
362
|
}
|
|
122
|
-
await
|
|
363
|
+
await adder.finish();
|
|
123
364
|
await this.staging.write();
|
|
124
365
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// implementation-specific.
|
|
366
|
+
const result: RmResult = { removedPaths, ...(warnings.length > 0 ? { warnings } : {}) };
|
|
367
|
+
if (sparsePaths.length > 0) throw advise(result);
|
|
368
|
+
return result;
|
|
369
|
+
}
|
|
130
370
|
|
|
131
|
-
|
|
371
|
+
/** Whether `.gitmodules` has conflict stages in the index (git's `is_gitmodules_unmerged`). */
|
|
372
|
+
private async gitmodulesUnmerged(): Promise<boolean> {
|
|
373
|
+
for await (const entry of this.staging.entries()) {
|
|
374
|
+
if (entry.path === ".gitmodules" && entry.stage !== 0) return true;
|
|
375
|
+
}
|
|
376
|
+
return false;
|
|
132
377
|
}
|
|
133
378
|
|
|
134
379
|
/**
|
|
135
|
-
*
|
|
380
|
+
* git's `remove_path_from_gitmodules` for each removed submodule: the `.gitmodules`
|
|
381
|
+
* section naming its path removed from the worktree's file (every line from its header to
|
|
382
|
+
* the next header, as `git_config_rename_section_in_file` drops it). Returns whether the
|
|
383
|
+
* file is to be staged again (git restages it once a section was looked for, even when
|
|
384
|
+
* none matched); nothing without a `.gitmodules`.
|
|
136
385
|
*/
|
|
137
|
-
private
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
386
|
+
private async removeFromGitmodules(
|
|
387
|
+
worktree: Worktree,
|
|
388
|
+
paths: readonly string[],
|
|
389
|
+
warnings: string[],
|
|
390
|
+
): Promise<boolean> {
|
|
391
|
+
let modified = false;
|
|
392
|
+
for (const path of paths) {
|
|
393
|
+
const file = await worktree.getEntry(".gitmodules");
|
|
394
|
+
if (!file || file.isDirectory) return modified;
|
|
395
|
+
const text = await readText(worktree, ".gitmodules");
|
|
396
|
+
const declared = parseGitmodules(text).filter((s) => s.path === path);
|
|
397
|
+
const submodule = declared[declared.length - 1];
|
|
398
|
+
if (!submodule) {
|
|
399
|
+
warnings.push(`warning: Could not find section in .gitmodules where path=${path}`);
|
|
400
|
+
continue;
|
|
142
401
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
402
|
+
const section = `submodule.${submodule.name}`;
|
|
403
|
+
const lines = text.split(/(?<=\n)/);
|
|
404
|
+
let removing = false;
|
|
405
|
+
const kept: string[] = [];
|
|
406
|
+
for (const line of lines) {
|
|
407
|
+
const at = line.search(/\S/);
|
|
408
|
+
if (at >= 0 && line[at] === "[") removing = sectionNameMatch(line.slice(at), section);
|
|
409
|
+
if (!removing) kept.push(line);
|
|
410
|
+
}
|
|
411
|
+
await worktree.writeContent(".gitmodules", new TextEncoder().encode(kept.join("")), {
|
|
412
|
+
raw: true,
|
|
413
|
+
});
|
|
414
|
+
modified = true;
|
|
415
|
+
}
|
|
416
|
+
return modified;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* git's `check_local_mod`: the entries whose removal would lose content, as git's error
|
|
420
|
+
* lines (singular or plural, each list with its hint unless `advice.rmHints` is off), or
|
|
421
|
+
* undefined. An unmerged entry, a file gone from the worktree or a directory standing at
|
|
422
|
+
* a file is passed over; a submodule is checked against its index entry only.
|
|
423
|
+
*/
|
|
424
|
+
private async checkLocalMod(
|
|
425
|
+
entries: readonly IndexEntry[],
|
|
426
|
+
worktree: Worktree | undefined,
|
|
427
|
+
): Promise<string | undefined> {
|
|
428
|
+
const headTree = await this.headTree();
|
|
429
|
+
const staged: string[] = [];
|
|
430
|
+
const cached: string[] = [];
|
|
431
|
+
const local: string[] = [];
|
|
432
|
+
// an unmerged path is passed over, unless its stage 2 (ours) is a populated submodule,
|
|
433
|
+
// which could lose history (get_ours_cache_pos)
|
|
434
|
+
const candidates: IndexEntry[] = [];
|
|
435
|
+
const stage0 = new Set(entries.filter((e) => e.stage === 0).map((e) => e.path));
|
|
436
|
+
for (const entry of entries) {
|
|
437
|
+
if (entry.stage === 0) candidates.push(entry);
|
|
438
|
+
else if (entry.stage === 2 && entry.mode === FileMode.GITLINK && !stage0.has(entry.path)) {
|
|
439
|
+
if (worktree && !(await isEmptyDirectory(worktree, entry.path))) candidates.push(entry);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
const trust = worktree ? worktreeModeTrust(this.workingCopy, worktree) : undefined;
|
|
443
|
+
const indexTime = this.staging.getUpdateTime();
|
|
444
|
+
const lookup = treeLookup(this.trees);
|
|
445
|
+
const stated = worktree
|
|
446
|
+
? withWorktreeEntries(worktree, candidates)
|
|
447
|
+
: candidates.map((item) => ({ item, current: null }));
|
|
448
|
+
for await (const { item: entry, current } of stated) {
|
|
449
|
+
if (!worktree) continue;
|
|
450
|
+
let localChanges = false;
|
|
451
|
+
if (!current) {
|
|
452
|
+
// lstat follows a symbolic link among the leading directories (refresh_index passed
|
|
453
|
+
// the path over): what stands there is a change, a directory as a vanished file
|
|
454
|
+
// (the removal then fails on it); nothing there, the file already vanished
|
|
455
|
+
const through = await statThroughLeadingLinks(worktree, entry.path);
|
|
456
|
+
if (!through || (!through.unknown && !through.entry)) continue;
|
|
457
|
+
if (through.entry?.isDirectory && entry.mode !== FileMode.GITLINK) continue;
|
|
458
|
+
localChanges = true;
|
|
459
|
+
} else {
|
|
460
|
+
// a directory standing at a file: the same as a vanished file
|
|
461
|
+
if (current.isDirectory && entry.mode !== FileMode.GITLINK) continue;
|
|
462
|
+
// ie_match_stat: skip-worktree and assume-unchanged entries match by definition, an
|
|
463
|
+
// intent-to-add one never does
|
|
464
|
+
if (entry.intentToAdd) localChanges = true;
|
|
465
|
+
else if (!entry.skipWorktree && !entry.assumeValid) {
|
|
466
|
+
const compared = await compareWithWorktree(
|
|
467
|
+
worktree,
|
|
468
|
+
entry,
|
|
469
|
+
{ trust, indexTime },
|
|
470
|
+
current,
|
|
471
|
+
);
|
|
472
|
+
localChanges = compared.kind !== undefined;
|
|
473
|
+
}
|
|
474
|
+
// a submodule whose own worktree holds changes (bad_to_remove_submodule)
|
|
475
|
+
if (!localChanges && entry.mode === FileMode.GITLINK && current.isDirectory) {
|
|
476
|
+
localChanges = await badToRemoveSubmodule(worktree, entry.path, this.cached);
|
|
149
477
|
}
|
|
150
478
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (
|
|
154
|
-
|
|
479
|
+
const inHead = headTree ? await lookup(headTree, entry.path) : undefined;
|
|
480
|
+
const stagedChanges = !inHead || inHead.mode !== entry.mode || inHead.id !== entry.objectId;
|
|
481
|
+
if (localChanges && stagedChanges) {
|
|
482
|
+
if (!this.cached || !entry.intentToAdd) staged.push(entry.path);
|
|
483
|
+
} else if (!this.cached) {
|
|
484
|
+
if (stagedChanges) cached.push(entry.path);
|
|
485
|
+
if (localChanges) local.push(entry.path);
|
|
155
486
|
}
|
|
487
|
+
}
|
|
488
|
+
const hints = configBool(this.workingCopy, "advice.rmHints", true);
|
|
489
|
+
const lines: string[] = [];
|
|
490
|
+
const report = (files: string[], one: string, many: string, hint: string) => {
|
|
491
|
+
if (files.length === 0) return;
|
|
492
|
+
let message = `error: ${files.length === 1 ? one : many}`;
|
|
493
|
+
for (const file of files) message += `\n ${file}`;
|
|
494
|
+
if (hints) message += `\n${hint}`;
|
|
495
|
+
lines.push(message);
|
|
496
|
+
};
|
|
497
|
+
report(
|
|
498
|
+
staged,
|
|
499
|
+
"the following file has staged content different from both the\nfile and the HEAD:",
|
|
500
|
+
"the following files have staged content different from both the\nfile and the HEAD:",
|
|
501
|
+
"(use -f to force removal)",
|
|
502
|
+
);
|
|
503
|
+
const keep = "(use --cached to keep the file, or -f to force removal)";
|
|
504
|
+
report(
|
|
505
|
+
cached,
|
|
506
|
+
"the following file has changes staged in the index:",
|
|
507
|
+
"the following files have changes staged in the index:",
|
|
508
|
+
keep,
|
|
509
|
+
);
|
|
510
|
+
report(
|
|
511
|
+
local,
|
|
512
|
+
"the following file has local modifications:",
|
|
513
|
+
"the following files have local modifications:",
|
|
514
|
+
keep,
|
|
515
|
+
);
|
|
516
|
+
return lines.length > 0 ? lines.join("\n") : undefined;
|
|
517
|
+
}
|
|
156
518
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
519
|
+
/** HEAD's tree; undefined before the first commit (everything staged counts as changed). */
|
|
520
|
+
private async headTree(): Promise<ObjectId | undefined> {
|
|
521
|
+
const head = await this.refsStore.resolve("HEAD");
|
|
522
|
+
if (!head?.objectId) return undefined;
|
|
523
|
+
return this.commits.getTree(head.objectId);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* The entry at `path` in a tree (git's `get_tree_entry`), each directory read once.
|
|
529
|
+
*/
|
|
530
|
+
function treeLookup(trees: {
|
|
531
|
+
getEntry(treeId: ObjectId, name: string): Promise<TreeEntry | undefined>;
|
|
532
|
+
}): (treeId: ObjectId, path: string) => Promise<TreeEntry | undefined> {
|
|
533
|
+
const dirs = new Map<string, Promise<TreeEntry | undefined>>();
|
|
534
|
+
const at = (treeId: ObjectId, dir: string, name: string) => {
|
|
535
|
+
const key = `${treeId}\0${dir}\0${name}`;
|
|
536
|
+
let found = dirs.get(key);
|
|
537
|
+
if (!found) {
|
|
538
|
+
found = trees.getEntry(treeId, name);
|
|
539
|
+
dirs.set(key, found);
|
|
540
|
+
}
|
|
541
|
+
return found;
|
|
542
|
+
};
|
|
543
|
+
return async (treeId, path) => {
|
|
544
|
+
const parts = path.split("/");
|
|
545
|
+
let id = treeId;
|
|
546
|
+
let entry: TreeEntry | undefined;
|
|
547
|
+
for (let k = 0; k < parts.length; k++) {
|
|
548
|
+
entry = await at(id, parts.slice(0, k).join("/"), parts[k] ?? "");
|
|
549
|
+
if (!entry) return undefined;
|
|
550
|
+
if (k < parts.length - 1) {
|
|
551
|
+
if (entry.mode !== FileMode.TREE) return undefined;
|
|
552
|
+
id = entry.id;
|
|
163
553
|
}
|
|
164
554
|
}
|
|
555
|
+
return entry;
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* git's `remove_path` for a removed entry: its file unlinked (one already gone is no error),
|
|
561
|
+
* then each parent directory left empty removed, bottom-up. A directory standing at a file
|
|
562
|
+
* cannot be unlinked (false: git's EISDIR), nor one reached through a symbolic link among
|
|
563
|
+
* the leading directories; a file reached that way is left alone (nothing is ever removed
|
|
564
|
+
* through a link). A submodule's directory goes with everything in it (git's
|
|
565
|
+
* `remove_dir_recursively`) where its repository lives elsewhere (a gitfile, nested
|
|
566
|
+
* submodules alike); one holding its own `.git` directory stays (git absorbs it into the
|
|
567
|
+
* superproject first, which is not reproduced).
|
|
568
|
+
*/
|
|
569
|
+
async function removeWorktreePath(worktree: Worktree, entry: IndexEntry): Promise<boolean> {
|
|
570
|
+
const current = await worktree.getEntry(entry.path);
|
|
571
|
+
if (current?.isDirectory) {
|
|
572
|
+
if (entry.mode !== FileMode.GITLINK) return false;
|
|
573
|
+
if (!(await removeDirectoryIfEmpty(worktree, entry.path))) {
|
|
574
|
+
if (!(await usesGitfile(worktree, entry.path))) return true;
|
|
575
|
+
await worktree.remove(entry.path, { recursive: true });
|
|
576
|
+
}
|
|
577
|
+
} else if (current) {
|
|
578
|
+
await worktree.remove(entry.path);
|
|
579
|
+
} else {
|
|
580
|
+
const through = await statThroughLeadingLinks(worktree, entry.path);
|
|
581
|
+
if (through?.entry?.isDirectory) return false;
|
|
582
|
+
if (through) return true;
|
|
583
|
+
}
|
|
584
|
+
await pruneEmptyParents(worktree, entry.path);
|
|
585
|
+
return true;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/** Whether the directory at `path` holds nothing (git's `is_empty_dir`: false when absent). */
|
|
589
|
+
async function isEmptyDirectory(worktree: Worktree, path: string): Promise<boolean> {
|
|
590
|
+
const entry = await worktree.getEntry(path);
|
|
591
|
+
if (!entry?.isDirectory) return false;
|
|
592
|
+
if (await worktree.getEntry(`${path}/.git`)) return false;
|
|
593
|
+
for await (const _ of worktree.walk({
|
|
594
|
+
pathPrefix: path,
|
|
595
|
+
includeIgnored: true,
|
|
596
|
+
includeDirectories: true,
|
|
597
|
+
})) {
|
|
165
598
|
return false;
|
|
166
599
|
}
|
|
600
|
+
return true;
|
|
601
|
+
}
|
|
167
602
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
603
|
+
/**
|
|
604
|
+
* git's `submodule_uses_gitfile`: the submodule at `path` has a `.git` file (its repository
|
|
605
|
+
* lives elsewhere), and so does every populated submodule nested in it.
|
|
606
|
+
*/
|
|
607
|
+
async function usesGitfile(worktree: Worktree, path: string, depth = 0): Promise<boolean> {
|
|
608
|
+
const dotGit = await worktree.getEntry(`${path}/.git`);
|
|
609
|
+
if (!dotGit || dotGit.isDirectory) return false;
|
|
610
|
+
if (depth > 32) return false;
|
|
611
|
+
const inner = await worktree.openGitlink?.(path).catch(() => undefined);
|
|
612
|
+
if (!inner) return false;
|
|
613
|
+
for await (const entry of inner.checkout.staging.entries()) {
|
|
614
|
+
if (entry.mode !== FileMode.GITLINK) continue;
|
|
615
|
+
const nested = `${path}/${entry.path}`;
|
|
616
|
+
if (!(await worktree.getEntry(`${nested}/.git`))) continue;
|
|
617
|
+
if (!(await usesGitfile(worktree, nested, depth + 1))) return false;
|
|
618
|
+
}
|
|
619
|
+
return true;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* git's `bad_to_remove_submodule` with `SUBMODULE_REMOVAL_DIE_ON_ERROR |
|
|
624
|
+
* SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED`: a populated submodule whose
|
|
625
|
+
* `git status --porcelain --ignore-submodules=none -uall` shows anything (a modified,
|
|
626
|
+
* staged or untracked file, a nested submodule's changes; ignored files do not count). An
|
|
627
|
+
* empty or absent directory is not. With `--cached` git has not absorbed the submodule's
|
|
628
|
+
* repository first, so one without a gitfile counts; without it git has, and its status is
|
|
629
|
+
* read here as it is. A submodule whose repository cannot be opened counts (git dies); a
|
|
630
|
+
* configuration the inner status cannot read (a bad `status.showUntrackedFiles`) fails the
|
|
631
|
+
* whole removal with its messages and git's "could not run 'git status'", nothing removed.
|
|
632
|
+
*/
|
|
633
|
+
async function badToRemoveSubmodule(
|
|
634
|
+
worktree: Worktree,
|
|
635
|
+
path: string,
|
|
636
|
+
cached: boolean,
|
|
637
|
+
): Promise<boolean> {
|
|
638
|
+
if (await isEmptyDirectory(worktree, path)) return false;
|
|
639
|
+
const dotGit = await worktree.getEntry(`${path}/.git`);
|
|
640
|
+
if (!dotGit) return true;
|
|
641
|
+
if (cached && !(await usesGitfile(worktree, path))) return true;
|
|
642
|
+
const inner = await worktree.openGitlink?.(path).catch(() => undefined);
|
|
643
|
+
if (!inner) return true;
|
|
644
|
+
try {
|
|
645
|
+
// `git status --porcelain --ignore-submodules=none -uall` there: every untracked file
|
|
646
|
+
// counts, whatever the submodule's status.showUntrackedFiles says
|
|
647
|
+
const status = await new StatusCommand(inner)
|
|
648
|
+
.setRenames(false)
|
|
649
|
+
.setUntrackedFiles("all")
|
|
650
|
+
.setIgnoreSubmodules("none")
|
|
651
|
+
.call();
|
|
652
|
+
return status.files.some((f) => f.index !== "!");
|
|
653
|
+
} catch (error) {
|
|
654
|
+
// the child status dies on its configuration (its own messages), then git rm does
|
|
655
|
+
if (error instanceof InvalidConfigError) {
|
|
656
|
+
throw new RmFailedError(
|
|
657
|
+
`${error.message}\nfatal: could not run 'git status' in submodule '${path}'`,
|
|
658
|
+
[],
|
|
659
|
+
{ removedPaths: [] },
|
|
660
|
+
);
|
|
661
|
+
}
|
|
662
|
+
return true;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/** git's `strerror` for a failed removal, from the error's code where it has one. */
|
|
667
|
+
function errnoMessage(error: unknown): string {
|
|
668
|
+
const code = (error as { code?: unknown } | undefined)?.code;
|
|
669
|
+
const known: Record<string, string> = {
|
|
670
|
+
EACCES: "Permission denied",
|
|
671
|
+
EPERM: "Operation not permitted",
|
|
672
|
+
EISDIR: "Is a directory",
|
|
673
|
+
EBUSY: "Device or resource busy",
|
|
674
|
+
EROFS: "Read-only file system",
|
|
675
|
+
ENOTEMPTY: "Directory not empty",
|
|
676
|
+
EIO: "Input/output error",
|
|
677
|
+
};
|
|
678
|
+
if (typeof code === "string" && known[code]) return known[code];
|
|
679
|
+
return error instanceof Error ? error.message : String(error);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/** The worktree file at `path` as text (UTF-8). */
|
|
683
|
+
async function readText(worktree: Worktree, path: string): Promise<string> {
|
|
684
|
+
const chunks: Uint8Array[] = [];
|
|
685
|
+
for await (const chunk of worktree.readContent(path)) chunks.push(chunk);
|
|
686
|
+
let size = 0;
|
|
687
|
+
for (const c of chunks) size += c.length;
|
|
688
|
+
const bytes = new Uint8Array(size);
|
|
689
|
+
let at = 0;
|
|
690
|
+
for (const c of chunks) {
|
|
691
|
+
bytes.set(c, at);
|
|
692
|
+
at += c.length;
|
|
693
|
+
}
|
|
694
|
+
return new TextDecoder().decode(bytes);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* git's `section_name_match`: whether the header beginning `line` (at its `[`) names
|
|
699
|
+
* `name` (`submodule.<name>`), as `[submodule "<name>"]` with its escapes or the old
|
|
700
|
+
* `[submodule.<name>]`; bytes compared as they are (case included).
|
|
701
|
+
*/
|
|
702
|
+
function sectionNameMatch(line: string, name: string): boolean {
|
|
703
|
+
if (line[0] !== "[") return false;
|
|
704
|
+
const space = (c: string | undefined) => c !== undefined && /\s/.test(c);
|
|
705
|
+
let i = 1;
|
|
706
|
+
let j = 0;
|
|
707
|
+
let dot = false;
|
|
708
|
+
for (; i < line.length && line[i] !== "]"; i++) {
|
|
709
|
+
if (!dot && space(line[i])) {
|
|
710
|
+
dot = true;
|
|
711
|
+
if (name[j++] !== ".") break;
|
|
712
|
+
for (i++; space(line[i]); i++);
|
|
713
|
+
if (line[i] !== '"') break;
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
if (line[i] === "\\" && dot) i++;
|
|
717
|
+
else if (line[i] === '"' && dot) {
|
|
718
|
+
for (i++; space(line[i]); i++);
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
if (line[i] !== name[j++]) break;
|
|
177
722
|
}
|
|
723
|
+
return line[i] === "]" && j === name.length;
|
|
178
724
|
}
|