@statewalker/vcs-commands 0.7.0 → 0.8.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/dist/commands/add-command.d.ts +38 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +55 -1
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/am/index.d.ts +1 -0
- package/dist/commands/am/index.d.ts.map +1 -1
- package/dist/commands/am/mailsplit.d.ts +88 -0
- package/dist/commands/am/mailsplit.d.ts.map +1 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-engine.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/bisect/bisect-command.d.ts +2 -0
- package/dist/commands/bisect/bisect-command.d.ts.map +1 -1
- package/dist/commands/branch-command.d.ts +148 -18
- package/dist/commands/branch-command.d.ts.map +1 -1
- package/dist/commands/branch-info-command.d.ts +55 -0
- package/dist/commands/branch-info-command.d.ts.map +1 -0
- package/dist/commands/branch-tracking.d.ts +106 -17
- package/dist/commands/branch-tracking.d.ts.map +1 -1
- package/dist/commands/branch-upstream-command.d.ts +83 -0
- package/dist/commands/branch-upstream-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +19 -3
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/cherry-pick-command.d.ts +59 -0
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +12 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +191 -5
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/commit-reuse.d.ts +33 -0
- package/dist/commands/commit-reuse.d.ts.map +1 -0
- package/dist/commands/config-command.d.ts +236 -0
- package/dist/commands/config-command.d.ts.map +1 -0
- package/dist/commands/config-value-types.d.ts +91 -0
- package/dist/commands/config-value-types.d.ts.map +1 -0
- package/dist/commands/core-config.d.ts +20 -0
- package/dist/commands/core-config.d.ts.map +1 -1
- package/dist/commands/diff-color-config.d.ts +73 -0
- package/dist/commands/diff-color-config.d.ts.map +1 -0
- package/dist/commands/diff-command.d.ts +252 -5
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +20 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fmt-merge-msg-command.d.ts +124 -0
- package/dist/commands/fmt-merge-msg-command.d.ts.map +1 -0
- package/dist/commands/fork-point.d.ts +38 -0
- package/dist/commands/fork-point.d.ts.map +1 -0
- package/dist/commands/format-patch-command.d.ts +41 -1
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/fsck/fetch-fsck.d.ts +51 -0
- package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -1
- package/dist/commands/gc-command.d.ts +8 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +4 -0
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +35 -0
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/grep/grep-command.d.ts +210 -0
- package/dist/commands/grep/grep-command.d.ts.map +1 -0
- package/dist/commands/grep/grep-engine.d.ts +218 -0
- package/dist/commands/grep/grep-engine.d.ts.map +1 -0
- package/dist/commands/grep/index.d.ts +3 -0
- package/dist/commands/grep/index.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +13 -2
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index.d.ts +26 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -3
- package/dist/commands/interpret-trailers-command.d.ts +90 -0
- package/dist/commands/interpret-trailers-command.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts +36 -5
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +296 -11
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +26 -1
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +133 -5
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-remote-command.d.ts +2 -0
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/mailmap.d.ts +30 -0
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/merge-base-command.d.ts +60 -0
- package/dist/commands/merge-base-command.d.ts.map +1 -0
- package/dist/commands/merge-bases.d.ts +23 -0
- package/dist/commands/merge-bases.d.ts.map +1 -1
- package/dist/commands/merge-command.d.ts +96 -9
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/mv-command.d.ts +4 -0
- package/dist/commands/mv-command.d.ts.map +1 -1
- package/dist/commands/name-rev.d.ts +48 -0
- package/dist/commands/name-rev.d.ts.map +1 -0
- package/dist/commands/notes-command.d.ts.map +1 -1
- package/dist/commands/pathspec-file.d.ts +39 -0
- package/dist/commands/pathspec-file.d.ts.map +1 -0
- package/dist/commands/pathspec.d.ts +3 -0
- package/dist/commands/pathspec.d.ts.map +1 -1
- package/dist/commands/pretty-format.d.ts +43 -3
- package/dist/commands/pretty-format.d.ts.map +1 -1
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +10 -0
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +160 -9
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/read-tree-command.d.ts +6 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +168 -6
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/for-each-ref-command.d.ts +121 -0
- package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -0
- package/dist/commands/ref-filter/index.d.ts +8 -0
- package/dist/commands/ref-filter/index.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-atoms.d.ts +88 -0
- package/dist/commands/ref-filter/ref-atoms.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-filter.d.ts +178 -0
- package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-format.d.ts +222 -0
- package/dist/commands/ref-filter/ref-format.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts +56 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-quote.d.ts +20 -0
- package/dist/commands/ref-filter/ref-quote.d.ts.map +1 -0
- package/dist/commands/ref-filter/version-compare.d.ts +20 -0
- package/dist/commands/ref-filter/version-compare.d.ts.map +1 -0
- package/dist/commands/reflog-command.d.ts +120 -0
- package/dist/commands/reflog-command.d.ts.map +1 -1
- package/dist/commands/reflog-walk.d.ts +72 -0
- package/dist/commands/reflog-walk.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +138 -29
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-transport.d.ts +7 -1
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/reset-command.d.ts +2 -3
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +2 -3
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-filter/commit-filter.d.ts +95 -0
- package/dist/commands/rev-filter/commit-filter.d.ts.map +1 -0
- package/dist/commands/rev-filter/commit-grep.d.ts +91 -0
- package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -0
- package/dist/commands/rev-filter/index.d.ts +3 -0
- package/dist/commands/rev-filter/index.d.ts.map +1 -0
- package/dist/commands/rev-list-command.d.ts +154 -2
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +32 -0
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +32 -1
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +15 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/rm-command.d.ts +70 -2
- package/dist/commands/rm-command.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +84 -4
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +2 -0
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +7 -0
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/show-command.d.ts +130 -0
- package/dist/commands/show-command.d.ts.map +1 -0
- package/dist/commands/show-commit.d.ts +11 -0
- package/dist/commands/show-commit.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +164 -0
- package/dist/commands/signature-check.d.ts.map +1 -0
- package/dist/commands/signing.d.ts +160 -0
- package/dist/commands/signing.d.ts.map +1 -0
- package/dist/commands/sparse-checkout-command.d.ts.map +1 -1
- package/dist/commands/sparse-index-view.d.ts +45 -0
- package/dist/commands/sparse-index-view.d.ts.map +1 -0
- package/dist/commands/ssh-signer.d.ts +29 -0
- package/dist/commands/ssh-signer.d.ts.map +1 -0
- package/dist/commands/ssh-verifier.d.ts +42 -0
- package/dist/commands/ssh-verifier.d.ts.map +1 -0
- package/dist/commands/stash-apply-command.d.ts +5 -0
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-branch-command.d.ts +34 -0
- package/dist/commands/stash-branch-command.d.ts.map +1 -0
- package/dist/commands/stash-create-command.d.ts +17 -0
- package/dist/commands/stash-create-command.d.ts.map +1 -1
- package/dist/commands/stash-info.d.ts +93 -0
- package/dist/commands/stash-info.d.ts.map +1 -0
- package/dist/commands/stash-list-command.d.ts +16 -0
- package/dist/commands/stash-list-command.d.ts.map +1 -1
- package/dist/commands/stash-pop-command.d.ts +39 -0
- package/dist/commands/stash-pop-command.d.ts.map +1 -0
- package/dist/commands/stash-show-command.d.ts +48 -0
- package/dist/commands/stash-show-command.d.ts.map +1 -0
- package/dist/commands/stash-store-command.d.ts +29 -0
- package/dist/commands/stash-store-command.d.ts.map +1 -0
- package/dist/commands/stash-working-tree.d.ts.map +1 -1
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/status-header.d.ts +5 -0
- package/dist/commands/status-header.d.ts.map +1 -1
- package/dist/commands/submodule-add-command.d.ts +89 -0
- package/dist/commands/submodule-add-command.d.ts.map +1 -0
- package/dist/commands/submodule-auth.d.ts +90 -0
- package/dist/commands/submodule-auth.d.ts.map +1 -0
- package/dist/commands/submodule-commands.d.ts +375 -0
- package/dist/commands/submodule-commands.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +288 -0
- package/dist/commands/submodule-model.d.ts.map +1 -0
- package/dist/commands/submodule-update-command.d.ts +198 -0
- package/dist/commands/submodule-update-command.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts.map +1 -1
- package/dist/commands/tag-command.d.ts +259 -10
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/trailers.d.ts +218 -17
- package/dist/commands/trailers.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts +7 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/verify-command.d.ts +92 -0
- package/dist/commands/verify-command.d.ts.map +1 -0
- package/dist/commands/worktree-add-command.d.ts +79 -7
- package/dist/commands/worktree-add-command.d.ts.map +1 -1
- package/dist/commands/worktree-path-rules.d.ts +66 -0
- package/dist/commands/worktree-path-rules.d.ts.map +1 -0
- package/dist/commands/worktree-remove-command.d.ts +10 -3
- package/dist/commands/worktree-remove-command.d.ts.map +1 -1
- package/dist/commands/worktree-repair-command.d.ts +15 -2
- package/dist/commands/worktree-repair-command.d.ts.map +1 -1
- package/dist/commands/worktree-support.d.ts +5 -0
- package/dist/commands/worktree-support.d.ts.map +1 -1
- package/dist/{commands-DIJ91NnD.js → commands-ISM52N0n.js} +70736 -54492
- package/dist/errors/checkout-errors.d.ts +19 -0
- package/dist/errors/checkout-errors.d.ts.map +1 -1
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +57 -3
- package/dist/errors/ref-errors.d.ts +19 -0
- package/dist/errors/ref-errors.d.ts.map +1 -1
- package/dist/errors/worktree-errors.d.ts +6 -1
- package/dist/errors/worktree-errors.d.ts.map +1 -1
- package/dist/{git-command-BGiOJ8Zk.js → fsck-DLRpbwTj.js} +6230 -71
- package/dist/git-command.d.ts +27 -1
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +267 -1
- package/dist/git.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 +55 -0
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/results/combined-diff.d.ts +3 -0
- package/dist/results/combined-diff.d.ts.map +1 -1
- package/dist/results/diff-check.d.ts +38 -0
- package/dist/results/diff-check.d.ts.map +1 -0
- package/dist/results/diff-color.d.ts +135 -0
- package/dist/results/diff-color.d.ts.map +1 -0
- package/dist/results/diff-output.d.ts +85 -1
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/diff-pickaxe.d.ts +67 -0
- package/dist/results/diff-pickaxe.d.ts.map +1 -0
- package/dist/results/diff-words.d.ts +55 -0
- package/dist/results/diff-words.d.ts.map +1 -0
- package/dist/results/index.d.ts +4 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/push-result.d.ts +7 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +2 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +6 -0
- package/dist/results/stash-result.d.ts.map +1 -1
- package/dist/{results-WVlBhVb1.js → results-TB2IJ64h.js} +2168 -403
- package/dist/whitespace/index.d.ts +2 -0
- package/dist/whitespace/index.d.ts.map +1 -0
- package/dist/whitespace/whitespace-rule.d.ts +94 -0
- package/dist/whitespace/whitespace-rule.d.ts.map +1 -0
- package/package.json +12 -12
- package/src/commands/add-command.ts +178 -17
- package/src/commands/am/am-command.ts +262 -42
- package/src/commands/am/index.ts +1 -0
- package/src/commands/am/mailsplit.ts +326 -0
- package/src/commands/apply/apply-command.ts +6 -6
- package/src/commands/apply/apply-engine.ts +1 -1
- package/src/commands/apply/apply-parse.ts +7 -8
- package/src/commands/bisect/bisect-command.ts +18 -5
- package/src/commands/branch-command.ts +528 -53
- package/src/commands/branch-info-command.ts +150 -0
- package/src/commands/branch-tracking.ts +335 -60
- package/src/commands/branch-upstream-command.ts +218 -0
- package/src/commands/checkout-command.ts +69 -43
- package/src/commands/cherry-pick-command.ts +143 -0
- package/src/commands/clean-command.ts +34 -3
- package/src/commands/clone-command.ts +2 -1
- package/src/commands/commit-command.ts +782 -64
- package/src/commands/commit-reuse.ts +94 -0
- package/src/commands/config-command.ts +1256 -0
- package/src/commands/config-value-types.ts +358 -0
- package/src/commands/core-config.ts +40 -0
- package/src/commands/diff-color-config.ts +274 -0
- package/src/commands/diff-command.ts +1009 -49
- package/src/commands/fetch-command.ts +142 -8
- package/src/commands/fmt-merge-msg-command.ts +715 -0
- package/src/commands/fork-point.ts +63 -0
- package/src/commands/format-patch-command.ts +314 -46
- package/src/commands/fsck/fetch-fsck.ts +172 -18
- package/src/commands/gc-command.ts +31 -1
- package/src/commands/git-describe.ts +31 -11
- package/src/commands/git-hooks.ts +81 -0
- package/src/commands/grep/grep-command.ts +1077 -0
- package/src/commands/grep/grep-engine.ts +1024 -0
- package/src/commands/grep/index.ts +2 -0
- package/src/commands/index-adder.ts +46 -7
- package/src/commands/index.ts +26 -0
- package/src/commands/interpret-trailers-command.ts +256 -0
- package/src/commands/local-transport.ts +109 -10
- package/src/commands/log-command.ts +1246 -210
- package/src/commands/log-graph.ts +123 -26
- package/src/commands/log-output.ts +280 -21
- package/src/commands/ls-remote-command.ts +5 -0
- package/src/commands/mailmap.ts +119 -0
- package/src/commands/merge-base-command.ts +170 -0
- package/src/commands/merge-bases.ts +63 -8
- package/src/commands/merge-command.ts +330 -82
- package/src/commands/merge-support.ts +14 -1
- package/src/commands/mv-command.ts +6 -3
- package/src/commands/name-rev.ts +171 -0
- package/src/commands/notes-command.ts +11 -1
- package/src/commands/pathspec-file.ts +72 -0
- package/src/commands/pathspec.ts +14 -2
- package/src/commands/pretty-format.ts +103 -19
- package/src/commands/promisor-remote.ts +10 -1
- package/src/commands/pull-command.ts +26 -7
- package/src/commands/push-command.ts +682 -65
- package/src/commands/read-tree-command.ts +28 -1
- package/src/commands/rebase-command.ts +933 -129
- package/src/commands/ref-filter/for-each-ref-command.ts +298 -0
- package/src/commands/ref-filter/index.ts +7 -0
- package/src/commands/ref-filter/ref-atoms.ts +581 -0
- package/src/commands/ref-filter/ref-filter.ts +651 -0
- package/src/commands/ref-filter/ref-format.ts +1070 -0
- package/src/commands/ref-filter/ref-listing-command.ts +421 -0
- package/src/commands/ref-filter/ref-quote.ts +69 -0
- package/src/commands/ref-filter/version-compare.ts +177 -0
- package/src/commands/reflog-command.ts +492 -2
- package/src/commands/reflog-walk.ts +234 -0
- package/src/commands/remote-command.ts +449 -69
- package/src/commands/remote-transport.ts +9 -1
- package/src/commands/reset-command.ts +36 -31
- package/src/commands/restore-command.ts +12 -41
- package/src/commands/rev-filter/commit-filter.ts +159 -0
- package/src/commands/rev-filter/commit-grep.ts +444 -0
- package/src/commands/rev-filter/index.ts +2 -0
- package/src/commands/rev-list-command.ts +402 -15
- package/src/commands/revert-command.ts +82 -0
- package/src/commands/revision-range.ts +204 -4
- package/src/commands/revision-resolver.ts +23 -8
- package/src/commands/rm-command.ts +282 -21
- package/src/commands/sequencer-pick.ts +498 -85
- package/src/commands/sequencer-support.ts +20 -2
- package/src/commands/serve-repository.ts +18 -3
- package/src/commands/show-command.ts +490 -0
- package/src/commands/show-commit.ts +24 -0
- package/src/commands/signature-check.ts +657 -0
- package/src/commands/signing.ts +385 -0
- package/src/commands/sparse-checkout-command.ts +2 -9
- package/src/commands/sparse-checkout-support.ts +2 -2
- package/src/commands/sparse-index-view.ts +135 -0
- package/src/commands/ssh-signer.ts +199 -0
- package/src/commands/ssh-verifier.ts +523 -0
- package/src/commands/stash-apply-command.ts +16 -4
- package/src/commands/stash-branch-command.ts +88 -0
- package/src/commands/stash-create-command.ts +28 -0
- package/src/commands/stash-info.ts +243 -0
- package/src/commands/stash-list-command.ts +33 -0
- package/src/commands/stash-pop-command.ts +83 -0
- package/src/commands/stash-show-command.ts +141 -0
- package/src/commands/stash-store-command.ts +82 -0
- package/src/commands/stash-working-tree.ts +2 -2
- package/src/commands/status-command.ts +5 -2
- package/src/commands/status-header.ts +41 -7
- package/src/commands/submodule-add-command.ts +509 -0
- package/src/commands/submodule-auth.ts +276 -0
- package/src/commands/submodule-commands.ts +1517 -0
- package/src/commands/submodule-model.ts +930 -0
- package/src/commands/submodule-update-command.ts +1092 -0
- package/src/commands/switch-command.ts +3 -1
- package/src/commands/tag-command.ts +876 -64
- package/src/commands/trailers.ts +837 -100
- package/src/commands/tree-restore.ts +38 -10
- package/src/commands/verify-command.ts +235 -0
- package/src/commands/worktree-add-command.ts +268 -24
- package/src/commands/worktree-path-rules.ts +183 -0
- package/src/commands/worktree-remove-command.ts +39 -5
- package/src/commands/worktree-repair-command.ts +52 -5
- package/src/commands/worktree-support.ts +22 -1
- package/src/errors/checkout-errors.ts +29 -0
- package/src/errors/command-errors.ts +2 -1
- package/src/errors/ref-errors.ts +23 -0
- package/src/errors/worktree-errors.ts +8 -1
- package/src/git-command.ts +66 -1
- package/src/git.ts +404 -1
- package/src/remote-config/index.ts +2 -0
- package/src/remote-config/remote-config-store.ts +101 -0
- package/src/results/combined-diff.ts +38 -18
- package/src/results/diff-check.ts +185 -0
- package/src/results/diff-color.ts +868 -0
- package/src/results/diff-output.ts +195 -30
- package/src/results/diff-pickaxe.ts +304 -0
- package/src/results/diff-words.ts +395 -0
- package/src/results/index.ts +4 -0
- package/src/results/push-result.ts +7 -0
- package/src/results/rebase-result.ts +3 -0
- package/src/results/stash-result.ts +7 -0
- package/src/whitespace/index.ts +1 -0
- package/src/{commands/apply/whitespace.ts → whitespace/whitespace-rule.ts} +173 -23
- package/dist/commands/apply/whitespace.d.ts +0 -58
- package/dist/commands/apply/whitespace.d.ts.map +0 -1
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
isSymbolicRef,
|
|
6
6
|
isValidBranchName,
|
|
7
7
|
} from "@statewalker/vcs-core";
|
|
8
|
-
import { parseGitBool } from "@statewalker/vcs-utils";
|
|
8
|
+
import { encodeGitPath, gitStrWidth, parseGitBool } from "@statewalker/vcs-utils";
|
|
9
9
|
import type { LinkedWorktrees, WorktreeInfo } from "@statewalker/vcs-working-tree";
|
|
10
10
|
|
|
11
11
|
import {
|
|
@@ -15,14 +15,36 @@ import {
|
|
|
15
15
|
InvalidRefNameError,
|
|
16
16
|
NotMergedError,
|
|
17
17
|
RefAlreadyExistsError,
|
|
18
|
+
RefFilterError,
|
|
18
19
|
RefNotFoundError,
|
|
19
20
|
} from "../errors/index.js";
|
|
20
21
|
import { GitCommand } from "../git-command.js";
|
|
21
22
|
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
22
23
|
import { ListBranchMode } from "../types.js";
|
|
24
|
+
import {
|
|
25
|
+
installTracking,
|
|
26
|
+
planTracking,
|
|
27
|
+
TrackMode,
|
|
28
|
+
trackableStart,
|
|
29
|
+
upstreamMissingError,
|
|
30
|
+
} from "./branch-tracking.js";
|
|
23
31
|
import { configBool } from "./merge-config.js";
|
|
32
|
+
import { OperationState } from "./merge-support.js";
|
|
24
33
|
import { canonicalObjectId } from "./object-id-input.js";
|
|
34
|
+
import { parseColorSpec } from "./pretty-format.js";
|
|
35
|
+
import {
|
|
36
|
+
fillAheadBehind,
|
|
37
|
+
filterRefs,
|
|
38
|
+
parseRefSorting,
|
|
39
|
+
type RefFilterOptions,
|
|
40
|
+
RefFormat,
|
|
41
|
+
RefKind,
|
|
42
|
+
RefListingCommand,
|
|
43
|
+
type RefSortKey,
|
|
44
|
+
sortRefs,
|
|
45
|
+
} from "./ref-filter/index.js";
|
|
25
46
|
import { reflogMessages } from "./reflog-messages.js";
|
|
47
|
+
import { readHeadDescription } from "./status-header.js";
|
|
26
48
|
import { shortBranchName, worktreeUsingBranch } from "./worktree-support.js";
|
|
27
49
|
|
|
28
50
|
/**
|
|
@@ -56,6 +78,11 @@ export class CreateBranchCommand extends GitCommand<Ref> {
|
|
|
56
78
|
private name?: string;
|
|
57
79
|
private startPoint?: string;
|
|
58
80
|
private force = false;
|
|
81
|
+
private track = TrackMode.DEFAULT;
|
|
82
|
+
private createReflog = false;
|
|
83
|
+
private quiet = false;
|
|
84
|
+
private readonly output: string[] = [];
|
|
85
|
+
private readonly warnings: string[] = [];
|
|
59
86
|
|
|
60
87
|
/**
|
|
61
88
|
* Set the name of the branch to create.
|
|
@@ -96,11 +123,69 @@ export class CreateBranchCommand extends GitCommand<Ref> {
|
|
|
96
123
|
}
|
|
97
124
|
|
|
98
125
|
/**
|
|
99
|
-
*
|
|
126
|
+
* How the new branch tracks its start point: git's `-t`/`--track[=direct]`
|
|
127
|
+
* (`TrackMode.DIRECT`: the start point must be a branch, a local one tracked with
|
|
128
|
+
* `remote = .`), `--track=inherit` (the start branch's own upstream copied), `--no-track`;
|
|
129
|
+
* by default `branch.autoSetupMerge` decides (`true`: a remote-tracking start point is
|
|
130
|
+
* tracked; `always`, `inherit`, `simple`, `false`). `branch.autoSetupRebase` adds
|
|
131
|
+
* `branch.<name>.rebase = true`.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const command = git.branchCreate().setName("topic").setStartPoint("origin/topic");
|
|
136
|
+
* await command.setTrack(TrackMode.DIRECT).call();
|
|
137
|
+
* command.getOutput(); // ["branch 'topic' set up to track 'origin/topic'."]
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
setTrack(mode: TrackMode): this {
|
|
141
|
+
this.checkCallable();
|
|
142
|
+
this.track = mode;
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* git's `--create-reflog`: the branch's reflog is created whatever
|
|
148
|
+
* `core.logAllRefUpdates` says.
|
|
149
|
+
*/
|
|
150
|
+
setCreateReflog(createReflog: boolean): this {
|
|
151
|
+
this.checkCallable();
|
|
152
|
+
this.createReflog = createReflog;
|
|
153
|
+
return this;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** git's `-q`: no "set up to track" message ({@link getOutput} stays empty). */
|
|
157
|
+
setQuiet(quiet: boolean): this {
|
|
158
|
+
this.checkCallable();
|
|
159
|
+
this.quiet = quiet;
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* What git printed on stdout, line by line: `branch '<b>' set up to track
|
|
165
|
+
* '<upstream>'.` (see {@link setTrack}). Read after {@link call}.
|
|
166
|
+
*/
|
|
167
|
+
getOutput(): string[] {
|
|
168
|
+
return [...this.output];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* What git printed on stderr, line by line: `warning: asked to inherit tracking from
|
|
173
|
+
* '<b>', but no remote is set` and the like. Read after {@link call}.
|
|
174
|
+
*/
|
|
175
|
+
getWarnings(): string[] {
|
|
176
|
+
return [...this.warnings];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Execute the branch creation (git's `create_branch`).
|
|
100
181
|
*
|
|
101
182
|
* @returns The created branch ref
|
|
102
183
|
* @throws InvalidRefNameError if branch name is invalid
|
|
103
184
|
* @throws RefAlreadyExistsError if branch exists and force is false
|
|
185
|
+
* @throws RefNotFoundError when the start point names nothing (`fatal: not a valid object
|
|
186
|
+
* name: '<start>'`), or when several remotes fetch into the tracked start point (once the
|
|
187
|
+
* branch is created, as git dies)
|
|
188
|
+
* @throws InvalidArgumentError when `--track` cannot track the start point
|
|
104
189
|
*/
|
|
105
190
|
async call(): Promise<Ref> {
|
|
106
191
|
this.checkCallable();
|
|
@@ -133,22 +218,62 @@ export class CreateBranchCommand extends GitCommand<Ref> {
|
|
|
133
218
|
}
|
|
134
219
|
}
|
|
135
220
|
|
|
136
|
-
// Resolve start point
|
|
137
|
-
const targetId = this.startPoint
|
|
138
|
-
? await this.resolveRef(this.startPoint, (n) => `fatal: not a valid branch point: '${n}'`)
|
|
139
|
-
: await this.resolveHead();
|
|
140
|
-
|
|
141
|
-
// git's create_branch: "branch: Created from <start>", "branch: Reset to <start>" (-f);
|
|
142
221
|
// without a start point, cmd_branch names the branch checked out (`HEAD` when detached)
|
|
143
222
|
const current = await this.getCurrentBranch();
|
|
144
223
|
const start = this.startPoint ?? (current ? current.replace(/^refs\/heads\//, "") : "HEAD");
|
|
224
|
+
|
|
225
|
+
// git's dwim_branch_start: the object, then (tracking) the branch it names, then a commit
|
|
226
|
+
const compatibility = this.hooks.compatibility;
|
|
227
|
+
const objectId = await this.revisionResolver()
|
|
228
|
+
.resolve(start)
|
|
229
|
+
.catch((error) => {
|
|
230
|
+
if (error instanceof RefNotFoundError) return undefined;
|
|
231
|
+
throw error;
|
|
232
|
+
});
|
|
233
|
+
if (objectId === undefined) {
|
|
234
|
+
if (this.track === TrackMode.DIRECT) {
|
|
235
|
+
throw upstreamMissingError(this.workingCopy, start, compatibility);
|
|
236
|
+
}
|
|
237
|
+
throw new RefNotFoundError(start, `fatal: not a valid object name: '${start}'`);
|
|
238
|
+
}
|
|
239
|
+
const startRef =
|
|
240
|
+
this.track === TrackMode.NONE
|
|
241
|
+
? undefined
|
|
242
|
+
: await trackableStart(this.workingCopy, this.refsStore, start, this.track);
|
|
243
|
+
const targetId = await this.resolveRef(start, (n) => `fatal: not a valid branch point: '${n}'`);
|
|
244
|
+
|
|
245
|
+
// git's create_branch: "branch: Created from <start>", "branch: Reset to <start>" (-f)
|
|
145
246
|
const message = exists
|
|
146
247
|
? reflogMessages.branchReset(start)
|
|
147
248
|
: reflogMessages.branchCreated(start);
|
|
148
|
-
|
|
249
|
+
if (this.createReflog) {
|
|
250
|
+
// REF_FORCE_CREATE_REFLOG
|
|
251
|
+
const result = await this.refsStore.batch([{ name: refName, new: targetId }], {
|
|
252
|
+
...this.reflogLine(message),
|
|
253
|
+
createReflog: true,
|
|
254
|
+
});
|
|
255
|
+
if (!result.ok) {
|
|
256
|
+
const reasons = result.rejected.map((r) => r.reason).join(", ");
|
|
257
|
+
throw new GitApiError(`fatal: cannot lock ref '${refName}': ${reasons}`);
|
|
258
|
+
}
|
|
259
|
+
} else {
|
|
260
|
+
await this.refsStore.set(refName, targetId, this.reflogLine(message));
|
|
261
|
+
}
|
|
149
262
|
|
|
150
263
|
this.setCallable(false);
|
|
151
264
|
|
|
265
|
+
// setup_tracking, once the branch exists (its refusals die after the write)
|
|
266
|
+
if (startRef !== undefined) {
|
|
267
|
+
const { plan, warnings } = planTracking(this.workingCopy, this.name, startRef, this.track, {
|
|
268
|
+
compatibility,
|
|
269
|
+
});
|
|
270
|
+
this.warnings.push(...warnings);
|
|
271
|
+
if (plan) {
|
|
272
|
+
const lines = await installTracking(this.workingCopy, this.name, plan);
|
|
273
|
+
if (!this.quiet) this.output.push(...lines);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
152
277
|
const ref = await this.refsStore.get(refName);
|
|
153
278
|
return ref as Ref;
|
|
154
279
|
}
|
|
@@ -338,35 +463,95 @@ export class DeleteBranchCommand extends GitCommand<string[]> {
|
|
|
338
463
|
}
|
|
339
464
|
}
|
|
340
465
|
|
|
466
|
+
/** What {@link ListBranchCommand.callText} printed. */
|
|
467
|
+
export interface BranchListResult {
|
|
468
|
+
/** git's stdout: each branch's line and its newline (bytes outside UTF-8 as `decodeGitPath` keeps them) */
|
|
469
|
+
output: string;
|
|
470
|
+
/** Each shown branch's line, in order (an empty one left out with `--omit-empty`) */
|
|
471
|
+
lines: string[];
|
|
472
|
+
/** The refs shown, in order (`HEAD` for a detached HEAD) */
|
|
473
|
+
branches: { refname: string; objectId: ObjectId }[];
|
|
474
|
+
/** git's warnings on stderr */
|
|
475
|
+
warnings: string[];
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** git's branch colors (builtin/branch.c `branch_colors`), by `color.branch.<slot>`. */
|
|
479
|
+
const BRANCH_COLORS = {
|
|
480
|
+
reset: "\x1b[m",
|
|
481
|
+
plain: "",
|
|
482
|
+
remote: "\x1b[31m",
|
|
483
|
+
local: "",
|
|
484
|
+
current: "\x1b[32m",
|
|
485
|
+
upstream: "\x1b[34m",
|
|
486
|
+
worktree: "\x1b[36m",
|
|
487
|
+
} as const;
|
|
488
|
+
|
|
489
|
+
type BranchColorSlot = keyof typeof BRANCH_COLORS;
|
|
490
|
+
|
|
491
|
+
/** quote_literal_for_format: `%` doubled. */
|
|
492
|
+
const quoteLiteral = (s: string) => s.replaceAll("%", "%%");
|
|
493
|
+
|
|
341
494
|
/**
|
|
342
495
|
* List branches.
|
|
343
496
|
*
|
|
344
|
-
* Equivalent to `git branch
|
|
497
|
+
* Equivalent to `git branch --list`. {@link call} returns the branch refs (symbolic ones
|
|
498
|
+
* left out); {@link callText} prints git's listing: `* ` before the branch checked out here,
|
|
499
|
+
* `+ ` before one another worktree has checked out, a detached HEAD first as
|
|
500
|
+
* `(HEAD detached at <name>)` (or `from`, `(no branch, rebasing <branch>)`,
|
|
501
|
+
* `(no branch, bisect started on <branch>)`), symbolic refs as `name -> target`, and with
|
|
502
|
+
* `-v` each branch's abbreviated id, upstream tracking and subject (`-vv`: the upstream's
|
|
503
|
+
* name and other worktrees' paths), aligned as git aligns them.
|
|
504
|
+
*
|
|
505
|
+
* The ref filter is git's (`ref-filter`): patterns match after `refs/heads/` or
|
|
506
|
+
* `refs/remotes/` (`setPatterns("feature/*")`), `setSort` keys follow `--sort` (the last is
|
|
507
|
+
* primary; `branch.sort` keys come before them, `refname` when none), `setFormat` takes the
|
|
508
|
+
* `for-each-ref` language, and the reachability filters (`setContains`, `setNoContains`,
|
|
509
|
+
* `setMerged`, `setNoMerged`, `setPointsAt`) take revision names (HEAD when none is given).
|
|
510
|
+
* Colors follow `--color` or `color.branch`/`color.ui` set to `always` (no terminal is
|
|
511
|
+
* assumed), with `color.branch.<slot>`. Not supported: `--column` layouts (lines are
|
|
512
|
+
* printed as `--no-column` prints them).
|
|
345
513
|
*
|
|
346
|
-
* Based on JGit's ListBranchCommand.
|
|
514
|
+
* Based on JGit's ListBranchCommand and git's builtin/branch.c.
|
|
347
515
|
*
|
|
348
516
|
* @example
|
|
349
517
|
* ```typescript
|
|
350
518
|
* // List local branches
|
|
351
519
|
* const branches = await git.branchList().call();
|
|
352
520
|
*
|
|
353
|
-
* //
|
|
354
|
-
* const
|
|
355
|
-
* .setListMode(ListBranchMode.REMOTE)
|
|
356
|
-
* .call();
|
|
357
|
-
*
|
|
358
|
-
* // List all branches
|
|
359
|
-
* const all = await git.branchList()
|
|
521
|
+
* // git branch -a -vv --merged
|
|
522
|
+
* const { output } = await git.branchList()
|
|
360
523
|
* .setListMode(ListBranchMode.ALL)
|
|
361
|
-
* .
|
|
524
|
+
* .setVerbose(2)
|
|
525
|
+
* .setMerged()
|
|
526
|
+
* .callText();
|
|
527
|
+
*
|
|
528
|
+
* // git branch --sort=-committerdate --format='%(refname:short)' 'feature/*'
|
|
529
|
+
* const { lines } = await git.branchList()
|
|
530
|
+
* .setSort("-committerdate")
|
|
531
|
+
* .setFormat("%(refname:short)")
|
|
532
|
+
* .setPatterns("feature/*")
|
|
533
|
+
* .callText();
|
|
362
534
|
* ```
|
|
363
535
|
*/
|
|
364
|
-
export class ListBranchCommand extends
|
|
536
|
+
export class ListBranchCommand extends RefListingCommand<Ref[]> {
|
|
365
537
|
private listMode = ListBranchMode.LOCAL;
|
|
366
|
-
private
|
|
538
|
+
private patterns: string[] = [];
|
|
539
|
+
private verbose = 0;
|
|
540
|
+
private abbrev?: number;
|
|
541
|
+
private format?: string;
|
|
542
|
+
private sortKeys: string[] = [];
|
|
543
|
+
private ignoreCase = false;
|
|
544
|
+
private omitEmpty = false;
|
|
545
|
+
private color?: boolean;
|
|
546
|
+
private pointsAt: string[] = [];
|
|
547
|
+
private contains: string[] = [];
|
|
548
|
+
private noContains: string[] = [];
|
|
549
|
+
private merged: string[] = [];
|
|
550
|
+
private noMerged: string[] = [];
|
|
551
|
+
private compatibility: "2.43" | "2.56" = "2.56";
|
|
367
552
|
|
|
368
553
|
/**
|
|
369
|
-
* Set the listing mode.
|
|
554
|
+
* Set the listing mode: local branches (default), `-r` (remote-tracking) or `-a` (both).
|
|
370
555
|
*
|
|
371
556
|
* @param mode Which branches to list
|
|
372
557
|
*/
|
|
@@ -376,63 +561,353 @@ export class ListBranchCommand extends GitCommand<Ref[]> {
|
|
|
376
561
|
return this;
|
|
377
562
|
}
|
|
378
563
|
|
|
564
|
+
/** `<pattern>...`: branches whose name after `refs/heads/` or `refs/remotes/` matches one. */
|
|
565
|
+
setPatterns(...patterns: string[]): this {
|
|
566
|
+
this.checkCallable();
|
|
567
|
+
this.patterns = patterns;
|
|
568
|
+
return this;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/** `-v` (1) or `-vv` (2): ids and subjects, then upstreams and worktree paths. */
|
|
572
|
+
setVerbose(level: number): this {
|
|
573
|
+
this.checkCallable();
|
|
574
|
+
this.verbose = level;
|
|
575
|
+
return this;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/** `--abbrev=<n>` for `-v`'s ids (0: `--no-abbrev`, the full id). */
|
|
579
|
+
setAbbrev(length: number): this {
|
|
580
|
+
this.checkCallable();
|
|
581
|
+
// parse_opt_abbrev_cb: at least 4, at most the id's length
|
|
582
|
+
this.abbrev = length && length < 4 ? 4 : Math.min(length, 64);
|
|
583
|
+
return this;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/** `--format=<format>`: each branch through git's ref format language. */
|
|
587
|
+
setFormat(format: string): this {
|
|
588
|
+
this.checkCallable();
|
|
589
|
+
this.format = format;
|
|
590
|
+
return this;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/** `--sort=<key>` for each key, in command-line order (the last is the primary key). */
|
|
594
|
+
setSort(...keys: string[]): this {
|
|
595
|
+
this.checkCallable();
|
|
596
|
+
this.sortKeys = keys;
|
|
597
|
+
return this;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/** `-i`: patterns and sorting without case. */
|
|
601
|
+
setIgnoreCase(ignore: boolean): this {
|
|
602
|
+
this.checkCallable();
|
|
603
|
+
this.ignoreCase = ignore;
|
|
604
|
+
return this;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/** `--omit-empty`: no line for a branch whose format expands to nothing. */
|
|
608
|
+
setOmitEmpty(omit: boolean): this {
|
|
609
|
+
this.checkCallable();
|
|
610
|
+
this.omitEmpty = omit;
|
|
611
|
+
return this;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/** `--color` (true) or `--no-color` (false); default `color.branch`/`color.ui` `always`. */
|
|
615
|
+
setColor(color: boolean): this {
|
|
616
|
+
this.checkCallable();
|
|
617
|
+
this.color = color;
|
|
618
|
+
return this;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/** `--points-at=<object>`: branches naming one of these objects. */
|
|
622
|
+
setPointsAt(...objects: string[]): this {
|
|
623
|
+
this.checkCallable();
|
|
624
|
+
this.pointsAt = objects;
|
|
625
|
+
return this;
|
|
626
|
+
}
|
|
627
|
+
|
|
379
628
|
/**
|
|
380
|
-
*
|
|
629
|
+
* `--contains[=<commit>]` (HEAD without one): branches whose commit reaches one of these.
|
|
381
630
|
*
|
|
382
|
-
* @param
|
|
631
|
+
* @param commits Revision names or object ids
|
|
383
632
|
*/
|
|
384
|
-
setContains(
|
|
385
|
-
commit = canonicalObjectId(commit);
|
|
633
|
+
setContains(...commits: string[]): this {
|
|
386
634
|
this.checkCallable();
|
|
387
|
-
this.
|
|
635
|
+
this.contains = commits.length ? commits.map(canonicalName) : ["HEAD"];
|
|
388
636
|
return this;
|
|
389
637
|
}
|
|
390
638
|
|
|
639
|
+
/** `--no-contains[=<commit>]` (HEAD without one): branches whose commit reaches none. */
|
|
640
|
+
setNoContains(...commits: string[]): this {
|
|
641
|
+
this.checkCallable();
|
|
642
|
+
this.noContains = commits.length ? commits.map(canonicalName) : ["HEAD"];
|
|
643
|
+
return this;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/** `--merged[=<commit>]` (HEAD without one): branches one of these reaches. */
|
|
647
|
+
setMerged(...commits: string[]): this {
|
|
648
|
+
this.checkCallable();
|
|
649
|
+
this.merged = commits.length ? commits.map(canonicalName) : ["HEAD"];
|
|
650
|
+
return this;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/** `--no-merged[=<commit>]` (HEAD without one): branches none of these reaches. */
|
|
654
|
+
setNoMerged(...commits: string[]): this {
|
|
655
|
+
this.checkCallable();
|
|
656
|
+
this.noMerged = commits.length ? commits.map(canonicalName) : ["HEAD"];
|
|
657
|
+
return this;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* The git version whose `--format` output to follow where versions differ (default 2.56;
|
|
662
|
+
* see `ForEachRefCommand.setCompatibility`).
|
|
663
|
+
*/
|
|
664
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
665
|
+
this.checkCallable();
|
|
666
|
+
this.compatibility = version;
|
|
667
|
+
return this;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
private kind(): number {
|
|
671
|
+
return this.listMode === ListBranchMode.REMOTE
|
|
672
|
+
? RefKind.REMOTES
|
|
673
|
+
: this.listMode === ListBranchMode.ALL
|
|
674
|
+
? RefKind.BRANCHES | RefKind.REMOTES
|
|
675
|
+
: RefKind.BRANCHES;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
private async filterOptions(kind: number): Promise<RefFilterOptions> {
|
|
679
|
+
const resolved = await this.resolveFilterArgs({
|
|
680
|
+
pointsAt: this.pointsAt,
|
|
681
|
+
contains: this.contains,
|
|
682
|
+
noContains: this.noContains,
|
|
683
|
+
merged: this.merged,
|
|
684
|
+
noMerged: this.noMerged,
|
|
685
|
+
});
|
|
686
|
+
return {
|
|
687
|
+
kind,
|
|
688
|
+
patterns: this.patterns,
|
|
689
|
+
ignoreCase: this.ignoreCase,
|
|
690
|
+
...resolved,
|
|
691
|
+
...(this.verbose ? { needCommit: true } : {}),
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
|
|
391
695
|
/**
|
|
392
696
|
* Execute the branch listing.
|
|
393
697
|
*
|
|
394
|
-
* @returns
|
|
698
|
+
* @returns The branch refs the filters keep, symbolic refs left out, in name order
|
|
395
699
|
*/
|
|
396
700
|
async call(): Promise<Ref[]> {
|
|
397
701
|
this.checkCallable();
|
|
398
702
|
this.setCallable(false);
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
703
|
+
const { items } = await filterRefs(this.filterSource(), await this.filterOptions(this.kind()));
|
|
704
|
+
// one listing of the refs, not a lookup per kept branch (a packed ref's lookup reads
|
|
705
|
+
// packed-refs again: quadratic over thousands of branches)
|
|
706
|
+
const listed = new Map<string, Ref>();
|
|
707
|
+
for await (const ref of this.refsStore.list("refs/")) {
|
|
708
|
+
if (!isSymbolicRef(ref)) listed.set(ref.name, ref);
|
|
403
709
|
}
|
|
404
|
-
if (this.listMode === ListBranchMode.REMOTE || this.listMode === ListBranchMode.ALL) {
|
|
405
|
-
prefixes.push("refs/remotes/");
|
|
406
|
-
}
|
|
407
|
-
|
|
408
710
|
const branches: Ref[] = [];
|
|
711
|
+
for (const item of items) {
|
|
712
|
+
if (item.flags.symref) continue;
|
|
713
|
+
const ref = listed.get(item.refname);
|
|
714
|
+
if (ref) branches.push(ref);
|
|
715
|
+
}
|
|
716
|
+
branches.sort((a, b) => compareRefNames(a.name, b.name));
|
|
717
|
+
return branches;
|
|
718
|
+
}
|
|
409
719
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
720
|
+
/**
|
|
721
|
+
* `git branch --list`'s output.
|
|
722
|
+
*
|
|
723
|
+
* @throws RefFilterError where git refuses an option or dies (bad format, bad sort key,
|
|
724
|
+
* a name that is no commit)
|
|
725
|
+
*/
|
|
726
|
+
async callText(): Promise<BranchListResult> {
|
|
727
|
+
this.checkCallable();
|
|
728
|
+
this.setCallable(false);
|
|
729
|
+
const config = RemoteConfigStore.from(this.workingCopy);
|
|
730
|
+
// refs_resolve_refdup("HEAD")
|
|
731
|
+
const head = await this.refsStore.get("HEAD").catch(() => undefined);
|
|
732
|
+
if (!head) throw new RefFilterError("fatal: failed to resolve HEAD as a valid ref", 128);
|
|
733
|
+
const detached = !isSymbolicRef(head);
|
|
734
|
+
if (!detached && !head.target.startsWith("refs/heads/")) {
|
|
735
|
+
throw new RefFilterError("fatal: HEAD not found below refs/heads!", 128);
|
|
736
|
+
}
|
|
737
|
+
// branch.sort keys first, then --sort (parse_opt_ref_sorting appends)
|
|
738
|
+
const sortKeys = [...config.values("branch.sort"), ...this.sortKeys];
|
|
739
|
+
if (sortKeys.length === 0) sortKeys.push("refname");
|
|
740
|
+
const useColor = this.color ?? wantsColor(config);
|
|
741
|
+
const colors = branchColors(config, useColor);
|
|
742
|
+
const formatSource = this.formatSource();
|
|
743
|
+
let description: Promise<string> | undefined;
|
|
744
|
+
formatSource.headDescription = () => {
|
|
745
|
+
description ??= this.headDescription();
|
|
746
|
+
return description;
|
|
747
|
+
};
|
|
748
|
+
const compatibility = this.compatibility;
|
|
749
|
+
const formatOptions = { useColor, compatibility } as const;
|
|
750
|
+
// ref_sorting_options runs before the format is verified
|
|
751
|
+
const sortFormat = new RefFormat("", formatSource, formatOptions);
|
|
752
|
+
parseRefSorting(sortKeys, sortFormat);
|
|
753
|
+
// git 2.43 collects `%(ahead-behind)` bases per format: atoms the sort keys parsed
|
|
754
|
+
// first (into a dummy format) get none
|
|
755
|
+
const sortedFirst = new Set(
|
|
756
|
+
compatibility === "2.43" ? sortFormat.atoms.map((a) => a.name) : [],
|
|
757
|
+
);
|
|
416
758
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
759
|
+
let kind = this.kind();
|
|
760
|
+
if (kind & RefKind.BRANCHES && detached) kind |= RefKind.DETACHED_HEAD;
|
|
761
|
+
const source = this.filterSource();
|
|
762
|
+
const { items, warnings } = await filterRefs(source, await this.filterOptions(kind));
|
|
763
|
+
const remotePrefix = kind === RefKind.REMOTES ? "" : "remotes/";
|
|
764
|
+
let maxwidth = 0;
|
|
765
|
+
if (this.verbose) {
|
|
766
|
+
for (const item of items) {
|
|
767
|
+
let w: number;
|
|
768
|
+
if (item.kind & RefKind.DETACHED_HEAD) {
|
|
769
|
+
w = textWidth(await formatSource.headDescription());
|
|
770
|
+
} else {
|
|
771
|
+
let desc = item.refname;
|
|
772
|
+
if (desc.startsWith("refs/heads/")) desc = desc.slice(11);
|
|
773
|
+
if (desc.startsWith("refs/remotes/")) desc = desc.slice(13);
|
|
774
|
+
w = textWidth(desc);
|
|
423
775
|
}
|
|
424
|
-
|
|
425
|
-
|
|
776
|
+
if (item.kind === RefKind.REMOTES) w += remotePrefix.length;
|
|
777
|
+
if (w > maxwidth) maxwidth = w;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
const formatText =
|
|
781
|
+
this.format ?? buildBranchFormat(this.verbose, this.abbrev, maxwidth, remotePrefix, colors);
|
|
782
|
+
let format: RefFormat;
|
|
783
|
+
try {
|
|
784
|
+
format = new RefFormat(formatText, formatSource, formatOptions);
|
|
785
|
+
} catch (e) {
|
|
786
|
+
// verify_ref_format's error, then branch's death
|
|
787
|
+
if (e instanceof RefFilterError && e.message.startsWith("error: malformed format string")) {
|
|
788
|
+
throw new RefFilterError(`${e.message}\nfatal: unable to parse format string`, 128);
|
|
426
789
|
}
|
|
790
|
+
throw e;
|
|
427
791
|
}
|
|
792
|
+
const sorting: RefSortKey[] = parseRefSorting(sortKeys, format).map((key) => ({
|
|
793
|
+
...key,
|
|
794
|
+
detachedHeadFirst: true,
|
|
795
|
+
...(this.ignoreCase ? { icase: true } : {}),
|
|
796
|
+
}));
|
|
797
|
+
const bases: ObjectId[] = [];
|
|
798
|
+
for (const atom of format.atoms) {
|
|
799
|
+
if (atom.type !== "ahead-behind" || sortedFirst.has(atom.name)) continue;
|
|
800
|
+
const name = atom.base as string;
|
|
801
|
+
const commit = await source.commitByName(name, warnings);
|
|
802
|
+
if (!commit) throw new RefFilterError(`fatal: failed to find '${name}'`, 128);
|
|
803
|
+
bases.push(commit);
|
|
804
|
+
}
|
|
805
|
+
await fillAheadBehind(items, bases, source, warnings);
|
|
806
|
+
await sortRefs(items, sorting, format, source, warnings);
|
|
807
|
+
const lines: string[] = [];
|
|
808
|
+
let output = "";
|
|
809
|
+
for (const item of items) {
|
|
810
|
+
const line = await format.format(item);
|
|
811
|
+
if (line.length || !this.omitEmpty) {
|
|
812
|
+
lines.push(line);
|
|
813
|
+
output += `${line}\n`;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return {
|
|
817
|
+
output,
|
|
818
|
+
lines,
|
|
819
|
+
branches: items.map((i) => ({ refname: i.refname, objectId: i.objectId })),
|
|
820
|
+
warnings,
|
|
821
|
+
};
|
|
822
|
+
}
|
|
428
823
|
|
|
429
|
-
|
|
430
|
-
|
|
824
|
+
/** get_head_description over this repository's state. */
|
|
825
|
+
private headDescription(): Promise<string> {
|
|
826
|
+
const resolver = this.revisionResolver();
|
|
827
|
+
const refs = this.refsStore;
|
|
828
|
+
return readHeadDescription({
|
|
829
|
+
refs,
|
|
830
|
+
state: new OperationState(this.workingCopy.checkout, refs),
|
|
831
|
+
abbreviate: (id) => this.abbreviateObjectId(id),
|
|
832
|
+
dwimRef: (name) => resolver.dwimRef(name).catch(() => []),
|
|
833
|
+
commitOf: async (id) => resolver.commitReference(id).catch(() => undefined),
|
|
834
|
+
objectExists: async (id) =>
|
|
835
|
+
(await resolver.objectType(id).catch(() => undefined)) !== undefined,
|
|
836
|
+
config: (key) => RemoteConfigStore.from(this.workingCopy).value(key),
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
}
|
|
431
840
|
|
|
432
|
-
|
|
841
|
+
/** A full object id canonicalised (lowercase), any other name as given. */
|
|
842
|
+
function canonicalName(name: string): string {
|
|
843
|
+
return /^[0-9a-fA-F]{40}(?:[0-9a-fA-F]{24})?$/.test(name) ? canonicalObjectId(name) : name;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/** git_config_colorbool of `color.branch`, else `color.ui`: only `always` colors without a terminal. */
|
|
847
|
+
function wantsColor(config: RemoteConfigStore): boolean {
|
|
848
|
+
const value = config.value("color.branch") ?? config.value("color.ui");
|
|
849
|
+
return value?.trim().toLowerCase() === "always";
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/** branch_get_color for every slot: `color.branch.<slot>` over git's defaults, "" without color. */
|
|
853
|
+
function branchColors(
|
|
854
|
+
config: RemoteConfigStore,
|
|
855
|
+
useColor: boolean,
|
|
856
|
+
): Record<BranchColorSlot, string> {
|
|
857
|
+
const out = { ...BRANCH_COLORS } as Record<BranchColorSlot, string>;
|
|
858
|
+
for (const slot of Object.keys(out) as BranchColorSlot[]) {
|
|
859
|
+
if (!useColor) {
|
|
860
|
+
out[slot] = "";
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
const value = config.value(`color.branch.${slot}`);
|
|
864
|
+
if (value === undefined) continue;
|
|
865
|
+
try {
|
|
866
|
+
out[slot] = parseColorSpec(value);
|
|
867
|
+
} catch {
|
|
868
|
+
// git refuses the configuration; the default stays
|
|
869
|
+
}
|
|
433
870
|
}
|
|
871
|
+
return out;
|
|
434
872
|
}
|
|
435
873
|
|
|
874
|
+
/** builtin/branch.c's build_format. */
|
|
875
|
+
function buildBranchFormat(
|
|
876
|
+
verbose: number,
|
|
877
|
+
abbrev: number | undefined,
|
|
878
|
+
maxwidth: number,
|
|
879
|
+
remotePrefix: string,
|
|
880
|
+
c: Record<BranchColorSlot, string>,
|
|
881
|
+
): string {
|
|
882
|
+
let local = `%(if)%(HEAD)%(then)* ${c.current}%(else)%(if)%(worktreepath)%(then)+ ${c.worktree}%(else) ${c.local}%(end)%(end)`;
|
|
883
|
+
let remote = ` ${c.remote}`;
|
|
884
|
+
if (verbose) {
|
|
885
|
+
const obname =
|
|
886
|
+
abbrev === undefined || abbrev < 0
|
|
887
|
+
? "%(objectname:short)"
|
|
888
|
+
: abbrev === 0
|
|
889
|
+
? "%(objectname)"
|
|
890
|
+
: `%(objectname:short=${abbrev})`;
|
|
891
|
+
local += `%(align:${maxwidth},left)%(refname:lstrip=2)%(end)`;
|
|
892
|
+
local += c.reset;
|
|
893
|
+
local += ` ${obname} `;
|
|
894
|
+
if (verbose > 1) {
|
|
895
|
+
local += `%(if:notequals=*)%(HEAD)%(then)%(if)%(worktreepath)%(then)(${c.worktree}%(worktreepath)${c.reset}) %(end)%(end)`;
|
|
896
|
+
local += `%(if)%(upstream)%(then)[${c.upstream}%(upstream:short)${c.reset}%(if)%(upstream:track)%(then): %(upstream:track,nobracket)%(end)] %(end)%(contents:subject)`;
|
|
897
|
+
} else {
|
|
898
|
+
local += "%(if)%(upstream:track)%(then)%(upstream:track) %(end)%(contents:subject)";
|
|
899
|
+
}
|
|
900
|
+
remote += `%(align:${maxwidth},left)${quoteLiteral(remotePrefix)}%(refname:lstrip=2)%(end)${c.reset}%(if)%(symref)%(then) -> %(symref:short)%(else) ${obname} %(contents:subject)%(end)`;
|
|
901
|
+
} else {
|
|
902
|
+
local += `%(refname:lstrip=2)${c.reset}%(if)%(symref)%(then) -> %(symref:short)%(end)`;
|
|
903
|
+
remote += `${quoteLiteral(remotePrefix)}%(refname:lstrip=2)${c.reset}%(if)%(symref)%(then) -> %(symref:short)%(end)`;
|
|
904
|
+
}
|
|
905
|
+
return `%(if:notequals=refs/remotes)%(refname:rstrip=-2)%(then)${local}%(else)${remote}%(end)`;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/** utf8_strwidth. */
|
|
909
|
+
const textWidth = (text: string) => gitStrWidth(encodeGitPath(text));
|
|
910
|
+
|
|
436
911
|
/**
|
|
437
912
|
* Rename a branch. Other worktrees whose HEAD is on it follow the new name, with git's
|
|
438
913
|
* `Branch: renamed <old> to <new>` line in their HEAD reflog (git's
|