@statewalker/vcs-commands 0.6.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/bisect/bisect-engine.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 +17 -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 +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/default-branch.d.ts +70 -0
- package/dist/commands/default-branch.d.ts.map +1 -0
- 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/fsck/fsck-command.d.ts +2 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-loose.d.ts +3 -0
- package/dist/commands/fsck/fsck-loose.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-object-checks.d.ts +25 -14
- package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-object-table.d.ts +15 -7
- package/dist/commands/fsck/fsck-object-table.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-pack.d.ts +11 -4
- package/dist/commands/fsck/fsck-pack.d.ts.map +1 -1
- package/dist/commands/fsck/verify-pack-command.d.ts.map +1 -1
- package/dist/commands/gc-command.d.ts +80 -48
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-date.d.ts +1 -65
- package/dist/commands/git-date.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 +43 -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 +15 -2
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index.d.ts +28 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -3
- package/dist/commands/init-command.d.ts +50 -3
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/interpret-trailers-command.d.ts +90 -0
- package/dist/commands/interpret-trailers-command.d.ts.map +1 -0
- package/dist/commands/legacy-remotes.d.ts +55 -0
- package/dist/commands/legacy-remotes.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 +108 -9
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-support.d.ts +11 -3
- 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/notes-merge-command.d.ts.map +1 -1
- package/dist/commands/notes-tree.d.ts +11 -1
- package/dist/commands/notes-tree.d.ts.map +1 -1
- package/dist/commands/patch-id.d.ts +3 -0
- package/dist/commands/patch-id.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 +28 -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/rev-parse-command.d.ts +9 -0
- package/dist/commands/rev-parse-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 +21 -2
- 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 +85 -5
- 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 +18 -1
- 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-summary-command.d.ts.map +1 -1
- 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/untracked-cache-support.d.ts +2 -1
- package/dist/commands/untracked-cache-support.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-list-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-DnmlfwGV.js → commands-ISM52N0n.js} +66120 -49271
- 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-DxvwPrPB.js → fsck-DLRpbwTj.js} +6863 -1070
- package/dist/git-command.d.ts +43 -2
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +276 -3
- 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 +117 -3
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/rename/detect-renames.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +8 -0
- package/dist/results/clone-result.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/init-result.d.ts +7 -0
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +5 -0
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +12 -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/status-result.d.ts.map +1 -1
- package/dist/{results-BZGa2Z3I.js → results-TB2IJ64h.js} +2178 -412
- 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/add-patch/add-interactive.ts +3 -3
- package/src/commands/am/am-command.ts +263 -43
- package/src/commands/am/index.ts +1 -0
- package/src/commands/am/mailsplit.ts +326 -0
- package/src/commands/apply/apply-command.ts +18 -8
- package/src/commands/apply/apply-engine.ts +6 -7
- package/src/commands/apply/apply-parse.ts +10 -10
- package/src/commands/attributes-source.ts +1 -1
- package/src/commands/bisect/bisect-command.ts +18 -5
- package/src/commands/bisect/bisect-engine.ts +2 -1
- 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 +70 -44
- package/src/commands/cherry-pick-command.ts +143 -0
- package/src/commands/clean-command.ts +34 -3
- package/src/commands/clone-command.ts +118 -5
- package/src/commands/comment-char-config.ts +160 -0
- package/src/commands/commit-command.ts +790 -71
- 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 +47 -2
- package/src/commands/default-branch.ts +196 -0
- package/src/commands/diff-color-config.ts +274 -0
- package/src/commands/diff-command.ts +1053 -75
- package/src/commands/fetch-command.ts +161 -13
- 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 +316 -43
- package/src/commands/fsck/fetch-fsck.ts +172 -18
- package/src/commands/fsck/fsck-command.ts +183 -66
- package/src/commands/fsck/fsck-loose.ts +14 -4
- package/src/commands/fsck/fsck-object-checks.ts +87 -46
- package/src/commands/fsck/fsck-object-table.ts +52 -42
- package/src/commands/fsck/fsck-pack.ts +64 -34
- package/src/commands/fsck/verify-pack-command.ts +5 -2
- package/src/commands/gc-command.ts +238 -107
- package/src/commands/git-date.ts +9 -895
- package/src/commands/git-describe.ts +31 -11
- package/src/commands/git-hooks.ts +92 -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 +54 -10
- package/src/commands/index.ts +28 -0
- package/src/commands/init-command.ts +167 -11
- package/src/commands/interpret-trailers-command.ts +256 -0
- package/src/commands/legacy-remotes.ts +224 -0
- package/src/commands/local-transport.ts +109 -10
- package/src/commands/log-command.ts +1283 -232
- package/src/commands/log-graph.ts +123 -26
- package/src/commands/log-output.ts +280 -21
- package/src/commands/ls-remote-command.ts +9 -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 +360 -82
- package/src/commands/merge-support.ts +43 -9
- 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/notes-merge-command.ts +23 -14
- package/src/commands/notes-tree.ts +28 -13
- package/src/commands/octopus-merge.ts +3 -2
- package/src/commands/patch-id.ts +16 -8
- package/src/commands/pathspec-file.ts +72 -0
- package/src/commands/pathspec.ts +14 -2
- package/src/commands/pretty-format.ts +105 -20
- package/src/commands/promisor-remote.ts +10 -1
- package/src/commands/pull-command.ts +149 -22
- package/src/commands/push-command.ts +704 -72
- package/src/commands/read-tree-command.ts +34 -3
- package/src/commands/rebase-command.ts +957 -142
- 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 +484 -74
- package/src/commands/remote-transport.ts +9 -1
- package/src/commands/reset-command.ts +40 -42
- 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/rev-parse-command.ts +22 -0
- package/src/commands/revert-command.ts +82 -0
- package/src/commands/revision-range.ts +204 -4
- package/src/commands/revision-resolver.ts +55 -22
- package/src/commands/rm-command.ts +282 -21
- package/src/commands/sequencer-pick.ts +504 -86
- package/src/commands/sequencer-support.ts +30 -5
- 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 +17 -5
- package/src/commands/stash-branch-command.ts +88 -0
- package/src/commands/stash-create-command.ts +30 -2
- 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 +7 -6
- package/src/commands/status-header.ts +44 -8
- 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-summary-command.ts +6 -7
- 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/untracked-cache-support.ts +16 -12
- package/src/commands/verify-command.ts +235 -0
- package/src/commands/worktree-add-command.ts +268 -24
- package/src/commands/worktree-list-command.ts +3 -5
- 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/core-commands/add.command.impl.ts +1 -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 +98 -3
- package/src/git.ts +420 -4
- package/src/remote-config/index.ts +4 -0
- package/src/remote-config/remote-config-store.ts +238 -11
- package/src/rename/detect-renames.ts +5 -1
- package/src/results/clone-result.ts +9 -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 +204 -37
- 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/init-result.ts +9 -0
- package/src/results/pull-result.ts +5 -0
- package/src/results/push-result.ts +12 -0
- package/src/results/rebase-result.ts +3 -0
- package/src/results/stash-result.ts +7 -0
- package/src/results/status-result.ts +5 -2
- 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
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
FileMode,
|
|
9
9
|
isValidWorktreePath,
|
|
10
10
|
type ObjectId,
|
|
11
|
+
type WorktreePathOptions,
|
|
11
12
|
} from "@statewalker/vcs-core";
|
|
12
13
|
import { compareGitPaths, foldAsciiCase } from "@statewalker/vcs-utils/encoding";
|
|
13
14
|
import {
|
|
@@ -30,6 +31,7 @@ import {
|
|
|
30
31
|
wholeSeconds,
|
|
31
32
|
} from "@statewalker/vcs-working-tree";
|
|
32
33
|
import { storeWorktreeFile } from "../core-commands/index.js";
|
|
34
|
+
import { strerror } from "./strerror.js";
|
|
33
35
|
|
|
34
36
|
const SURROGATE = /[\ud800-\udfff]/;
|
|
35
37
|
|
|
@@ -58,6 +60,19 @@ export interface AddToIndexOptions {
|
|
|
58
60
|
indexed?: StagingEntry;
|
|
59
61
|
}
|
|
60
62
|
|
|
63
|
+
/**
|
|
64
|
+
* A file `index_path` cannot open (an errno such as EACCES): git's `error_errno` of its
|
|
65
|
+
* `open`, then add_to_index's "unable to index file" line. Anything else is rethrown.
|
|
66
|
+
*/
|
|
67
|
+
function unreadable(path: string, error: unknown): never {
|
|
68
|
+
const code = (error as { code?: unknown })?.code;
|
|
69
|
+
if (typeof code !== "string" || !/^E[A-Z]+$/.test(code) || code === "ENOENT") throw error;
|
|
70
|
+
throw new AddToIndexError(path, [
|
|
71
|
+
`error: open("${path}"): ${strerror(error)}`,
|
|
72
|
+
`error: unable to index file '${path}'`,
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
|
|
61
76
|
/** A path `add_to_index` cannot add: git's error lines (`fatal: adding files failed` follows). */
|
|
62
77
|
export class AddToIndexError extends Error {
|
|
63
78
|
constructor(
|
|
@@ -184,13 +199,29 @@ export async function chmodIndexEntries(
|
|
|
184
199
|
staging: Staging,
|
|
185
200
|
flip: "+" | "-",
|
|
186
201
|
matches: (entry: StagingEntry) => boolean,
|
|
187
|
-
|
|
202
|
+
/**
|
|
203
|
+
* `includeSkipWorktree`: skip-worktree entries too (`git add --sparse --chmod`);
|
|
204
|
+
* `collapsed`: sparse directories git holds as one entry each (`out/`), refused as any
|
|
205
|
+
* entry that is no regular file when matched
|
|
206
|
+
*/
|
|
207
|
+
options: { pretend?: boolean; includeSkipWorktree?: boolean; collapsed?: readonly string[] } = {},
|
|
188
208
|
): Promise<string[]> {
|
|
189
209
|
const errors: string[] = [];
|
|
190
210
|
const editor = staging.createEditor();
|
|
191
211
|
const touched: string[] = [];
|
|
212
|
+
const collapsed = options.collapsed ?? [];
|
|
213
|
+
let lastDir: string | undefined;
|
|
192
214
|
for await (const entry of staging.entries()) {
|
|
193
|
-
|
|
215
|
+
const dir = collapsed.find((d) => entry.path.startsWith(d));
|
|
216
|
+
if (dir) {
|
|
217
|
+
if (dir !== lastDir) {
|
|
218
|
+
lastDir = dir;
|
|
219
|
+
const dirEntry: StagingEntry = { ...entry, path: dir, mode: FileMode.TREE };
|
|
220
|
+
if (matches(dirEntry)) errors.push(`error: cannot chmod ${flip}x '${dir}'`);
|
|
221
|
+
}
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if ((entry.skipWorktree && !options.includeSkipWorktree) || !matches(entry)) continue;
|
|
194
225
|
if ((entry.mode & 0o170000) !== 0o100000) {
|
|
195
226
|
errors.push(`error: cannot chmod ${flip}x '${entry.path}'`);
|
|
196
227
|
continue;
|
|
@@ -261,6 +292,8 @@ export class IndexAdder {
|
|
|
261
292
|
private readonly trust: WorktreeModeTrust,
|
|
262
293
|
/** git's `ADD_CACHE_PRETEND` (`add --dry-run`): nothing is written or edited */
|
|
263
294
|
private readonly pretend: boolean,
|
|
295
|
+
/** `verify_path`'s rules (`core.protectNTFS`, `core.protectHFS`; default both on) */
|
|
296
|
+
private readonly pathRules: WorktreePathOptions = {},
|
|
264
297
|
) {
|
|
265
298
|
this.editor = staging.createEditor();
|
|
266
299
|
this.indexTime = staging.getUpdateTime();
|
|
@@ -274,9 +307,15 @@ export class IndexAdder {
|
|
|
274
307
|
staging: Staging,
|
|
275
308
|
blobs: Blobs,
|
|
276
309
|
trust: WorktreeModeTrust,
|
|
277
|
-
options: { pretend?: boolean } = {},
|
|
310
|
+
options: { pretend?: boolean; pathRules?: WorktreePathOptions } = {},
|
|
278
311
|
): Promise<IndexAdder> {
|
|
279
|
-
const adder = new IndexAdder(
|
|
312
|
+
const adder = new IndexAdder(
|
|
313
|
+
staging,
|
|
314
|
+
blobs,
|
|
315
|
+
trust,
|
|
316
|
+
options.pretend === true,
|
|
317
|
+
options.pathRules,
|
|
318
|
+
);
|
|
280
319
|
const take = (entry: StagingEntry) => {
|
|
281
320
|
if (entry.stage === 0) {
|
|
282
321
|
adder.basePaths.push(entry.path);
|
|
@@ -396,7 +435,7 @@ export class IndexAdder {
|
|
|
396
435
|
// add_index_entry's verify_path (after the file is hashed; never with ADD_CACHE_PRETEND)
|
|
397
436
|
if (!this.pretend) {
|
|
398
437
|
const mode = modeFromWorktree(entry.mode, indexed?.mode, this.trust);
|
|
399
|
-
if (!isValidWorktreePath(name, mode)) {
|
|
438
|
+
if (!isValidWorktreePath(name, mode, this.pathRules)) {
|
|
400
439
|
const shown = options.displayPath ?? path;
|
|
401
440
|
throw new AddToIndexError(path, [
|
|
402
441
|
`error: invalid path '${shown}'`,
|
|
@@ -412,7 +451,7 @@ export class IndexAdder {
|
|
|
412
451
|
await this.storeEmptyBlob();
|
|
413
452
|
if (indexed) {
|
|
414
453
|
if (!this.pretend) this.touched.add(name);
|
|
415
|
-
return indexed.objectId ===
|
|
454
|
+
return indexed.objectId === this.emptyBlobId ? "same" : "added";
|
|
416
455
|
}
|
|
417
456
|
if (this.pretend) return "added";
|
|
418
457
|
this.resolve(name);
|
|
@@ -423,7 +462,7 @@ export class IndexAdder {
|
|
|
423
462
|
this.editor.add(
|
|
424
463
|
new UpdateStagingEntry(
|
|
425
464
|
name,
|
|
426
|
-
|
|
465
|
+
this.emptyBlobId,
|
|
427
466
|
mode,
|
|
428
467
|
{ size: 0, mtime: 0 },
|
|
429
468
|
{ intentToAdd: true },
|
|
@@ -437,7 +476,7 @@ export class IndexAdder {
|
|
|
437
476
|
const known = indexed ?? this.unmerged.get(name)?.[0];
|
|
438
477
|
if (this.pretend) {
|
|
439
478
|
// git's ADD_CACHE_PRETEND: hashed, never written
|
|
440
|
-
const id = await worktree.computeHash(path);
|
|
479
|
+
const id = await worktree.computeHash(path).catch((error) => unreadable(path, error));
|
|
441
480
|
const mode = modeFromWorktree(entry.mode, known?.mode, this.trust);
|
|
442
481
|
return indexed && indexed.objectId === id && indexed.mode === mode ? "same" : "added";
|
|
443
482
|
}
|
|
@@ -445,7 +484,7 @@ export class IndexAdder {
|
|
|
445
484
|
const stored = await storeWorktreeFile(this.blobs, worktree, path, entry, {
|
|
446
485
|
onWarning: options.onWarning,
|
|
447
486
|
...(options.renormalize ? { renormalize: true } : {}),
|
|
448
|
-
});
|
|
487
|
+
}).catch((error) => unreadable(path, error));
|
|
449
488
|
const mode = modeFromWorktree(stored.entry.mode, known?.mode, this.trust);
|
|
450
489
|
this.stage(name, stored.id, mode, entryStatOf(stored.entry));
|
|
451
490
|
return indexed && indexed.objectId === stored.id && indexed.mode === mode ? "same" : "added";
|
|
@@ -500,7 +539,7 @@ export class IndexAdder {
|
|
|
500
539
|
this.editor.add(
|
|
501
540
|
new UpdateStagingEntry(
|
|
502
541
|
path,
|
|
503
|
-
|
|
542
|
+
this.emptyBlobId,
|
|
504
543
|
FileMode.GITLINK,
|
|
505
544
|
{ size: 0, mtime: 0 },
|
|
506
545
|
{ intentToAdd: true },
|
|
@@ -542,6 +581,11 @@ export class IndexAdder {
|
|
|
542
581
|
}
|
|
543
582
|
|
|
544
583
|
/** git's `set_object_name_for_intent_to_add_entry`: the empty blob written (once). */
|
|
584
|
+
/** The empty blob's id in the repository's format (the id an intent-to-add entry gets) */
|
|
585
|
+
private get emptyBlobId(): ObjectId {
|
|
586
|
+
return this.blobs.objectFormat?.emptyBlobId ?? EMPTY_BLOB_ID;
|
|
587
|
+
}
|
|
588
|
+
|
|
545
589
|
private async storeEmptyBlob(): Promise<void> {
|
|
546
590
|
if (this.emptyBlobStored) return;
|
|
547
591
|
this.emptyBlobStored = true;
|
package/src/commands/index.ts
CHANGED
|
@@ -6,24 +6,32 @@ export * from "./backfill-command.js";
|
|
|
6
6
|
export * from "./bisect/index.js";
|
|
7
7
|
export * from "./blame-command.js";
|
|
8
8
|
export * from "./branch-command.js";
|
|
9
|
+
export * from "./branch-info-command.js";
|
|
9
10
|
export { TrackMode } from "./branch-tracking.js";
|
|
11
|
+
export * from "./branch-upstream-command.js";
|
|
10
12
|
export * from "./checkout-command.js";
|
|
11
13
|
export * from "./checkout-paths.js";
|
|
12
14
|
export * from "./cherry-pick-command.js";
|
|
13
15
|
export * from "./clean-command.js";
|
|
14
16
|
export * from "./clone-command.js";
|
|
17
|
+
export * from "./comment-char-config.js";
|
|
15
18
|
export * from "./commit-command.js";
|
|
19
|
+
export * from "./config-command.js";
|
|
16
20
|
export * from "./date-format.js";
|
|
21
|
+
export * from "./default-branch.js";
|
|
17
22
|
export * from "./describe-command.js";
|
|
23
|
+
export * from "./diff-color-config.js";
|
|
18
24
|
export * from "./diff-command.js";
|
|
19
25
|
export * from "./diff-textconv.js";
|
|
20
26
|
export * from "./fetch-command.js";
|
|
27
|
+
export * from "./fmt-merge-msg-command.js";
|
|
21
28
|
export * from "./format-patch-command.js";
|
|
22
29
|
export * from "./fsck/index.js";
|
|
23
30
|
export * from "./gc-command.js";
|
|
24
31
|
export * from "./git-describe.js";
|
|
25
32
|
export * from "./git-hooks.js";
|
|
26
33
|
export * from "./git-ident.js";
|
|
34
|
+
export * from "./grep/index.js";
|
|
27
35
|
export * from "./hook-command.js";
|
|
28
36
|
export {
|
|
29
37
|
IndexVersionConfigError,
|
|
@@ -32,12 +40,14 @@ export {
|
|
|
32
40
|
takeIndexWarnings,
|
|
33
41
|
} from "./index-host.js";
|
|
34
42
|
export * from "./init-command.js";
|
|
43
|
+
export * from "./interpret-trailers-command.js";
|
|
35
44
|
export { httpBackendEnv, quarantineEnv, remoteHookSession } from "./local-transport.js";
|
|
36
45
|
export * from "./log-command.js";
|
|
37
46
|
export * from "./log-graph.js";
|
|
38
47
|
export * from "./log-output.js";
|
|
39
48
|
export * from "./ls-remote-command.js";
|
|
40
49
|
export * from "./mailmap.js";
|
|
50
|
+
export * from "./merge-base-command.js";
|
|
41
51
|
export * from "./merge-command.js";
|
|
42
52
|
export {
|
|
43
53
|
createMergeDriver,
|
|
@@ -71,6 +81,7 @@ export * from "./push-command.js";
|
|
|
71
81
|
export * from "./read-tree-command.js";
|
|
72
82
|
export * from "./rebase-command.js";
|
|
73
83
|
export * from "./ref-decoration-filter.js";
|
|
84
|
+
export * from "./ref-filter/index.js";
|
|
74
85
|
export * from "./reflog-command.js";
|
|
75
86
|
export {
|
|
76
87
|
committerIdent,
|
|
@@ -80,6 +91,7 @@ export {
|
|
|
80
91
|
export * from "./remote-command.js";
|
|
81
92
|
export * from "./reset-command.js";
|
|
82
93
|
export * from "./restore-command.js";
|
|
94
|
+
export * from "./rev-filter/index.js";
|
|
83
95
|
export * from "./rev-list-command.js";
|
|
84
96
|
export * from "./rev-parse-command.js";
|
|
85
97
|
export * from "./revert-command.js";
|
|
@@ -89,19 +101,35 @@ export * from "./revision-resolver.js";
|
|
|
89
101
|
export * from "./rm-command.js";
|
|
90
102
|
export { SequencerOperation } from "./sequencer-pick.js";
|
|
91
103
|
export * from "./serve-repository.js";
|
|
104
|
+
export * from "./show-command.js";
|
|
105
|
+
export * from "./signature-check.js";
|
|
106
|
+
export * from "./signing.js";
|
|
92
107
|
export * from "./sparse-checkout-command.js";
|
|
108
|
+
export * from "./ssh-signer.js";
|
|
109
|
+
export * from "./ssh-verifier.js";
|
|
93
110
|
export * from "./stash-apply-command.js";
|
|
111
|
+
export * from "./stash-branch-command.js";
|
|
94
112
|
export * from "./stash-create-command.js";
|
|
95
113
|
export * from "./stash-drop-command.js";
|
|
114
|
+
export * from "./stash-info.js";
|
|
96
115
|
export * from "./stash-list-command.js";
|
|
116
|
+
export * from "./stash-pop-command.js";
|
|
117
|
+
export * from "./stash-show-command.js";
|
|
118
|
+
export * from "./stash-store-command.js";
|
|
97
119
|
export * from "./stash-working-tree.js";
|
|
98
120
|
export * from "./status-command.js";
|
|
99
121
|
export * from "./status-format.js";
|
|
122
|
+
export * from "./submodule-add-command.js";
|
|
123
|
+
export * from "./submodule-auth.js";
|
|
124
|
+
export * from "./submodule-commands.js";
|
|
125
|
+
export * from "./submodule-model.js";
|
|
100
126
|
export * from "./submodule-summary.js";
|
|
101
127
|
export * from "./submodule-summary-command.js";
|
|
128
|
+
export * from "./submodule-update-command.js";
|
|
102
129
|
export * from "./switch-command.js";
|
|
103
130
|
export * from "./tag-command.js";
|
|
104
131
|
export * from "./trailers.js";
|
|
132
|
+
export * from "./verify-command.js";
|
|
105
133
|
export * from "./worktree-add-command.js";
|
|
106
134
|
export * from "./worktree-list-command.js";
|
|
107
135
|
export * from "./worktree-lock-command.js";
|
|
@@ -10,10 +10,18 @@ import {
|
|
|
10
10
|
createGitFilesHistoryFromFiles,
|
|
11
11
|
FileStagingStore,
|
|
12
12
|
probeCaseFolding,
|
|
13
|
+
readProtectedConfig,
|
|
14
|
+
readRepositoryFormat,
|
|
13
15
|
resolveLinkedGitDir,
|
|
14
16
|
} from "@statewalker/vcs-store-files";
|
|
15
17
|
import { MemoryStagingStore } from "@statewalker/vcs-store-mem";
|
|
16
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
decodeGitPath,
|
|
20
|
+
encodeGitPath,
|
|
21
|
+
type ObjectFormat,
|
|
22
|
+
objectFormatByName,
|
|
23
|
+
SHA1_OBJECT_FORMAT,
|
|
24
|
+
} from "@statewalker/vcs-utils";
|
|
17
25
|
import {
|
|
18
26
|
createMemoryCheckout,
|
|
19
27
|
type GitHostEnvironment,
|
|
@@ -24,6 +32,12 @@ import {
|
|
|
24
32
|
|
|
25
33
|
import { Git } from "../git.js";
|
|
26
34
|
import type { InitResult } from "../results/init-result.js";
|
|
35
|
+
import {
|
|
36
|
+
defaultInitialBranch,
|
|
37
|
+
defaultRefFormat,
|
|
38
|
+
InvalidInitialBranchError,
|
|
39
|
+
isValidBranchName,
|
|
40
|
+
} from "./default-branch.js";
|
|
27
41
|
|
|
28
42
|
/**
|
|
29
43
|
* Command to initialize a new Git repository.
|
|
@@ -67,13 +81,35 @@ export class InitCommand {
|
|
|
67
81
|
private directory?: string;
|
|
68
82
|
private gitDir?: string;
|
|
69
83
|
private bare = false;
|
|
70
|
-
|
|
84
|
+
/** `--initial-branch`; undefined: git's default (see {@link defaultInitialBranch}) */
|
|
85
|
+
private initialBranch?: string;
|
|
71
86
|
private stagingStore?: Staging;
|
|
72
87
|
private worktreeEnabled = false;
|
|
73
88
|
private worktreeStore?: Worktree;
|
|
74
89
|
private environment?: GitHostEnvironment;
|
|
90
|
+
/** `--object-format`; undefined: `$GIT_DEFAULT_HASH`, `init.defaultObjectFormat`, else sha1 */
|
|
91
|
+
private objectFormatName?: string;
|
|
92
|
+
/** `--ref-format`; undefined: git's default (see {@link defaultRefFormat}) */
|
|
93
|
+
private refFormat?: string;
|
|
75
94
|
private callable = true;
|
|
76
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Set the object format of the new repository (`git init --object-format=<format>`):
|
|
98
|
+
* `sha1` (git's default) or `sha256`. Without it, `$GIT_DEFAULT_HASH`
|
|
99
|
+
* (`GitHostEnvironment.defaultHash`), then `init.defaultObjectFormat` from the system or
|
|
100
|
+
* global configuration (or `git -c`), else SHA-1. A name git does not know fails the call
|
|
101
|
+
* (`UnknownHashAlgorithmError`), and so does re-initialising an existing repository with
|
|
102
|
+
* another format (`ReinitializeHashError`); an existing repository keeps its own otherwise.
|
|
103
|
+
*
|
|
104
|
+
* @param format `sha1` or `sha256`
|
|
105
|
+
* @returns this for method chaining
|
|
106
|
+
*/
|
|
107
|
+
setObjectFormat(format: string): this {
|
|
108
|
+
this.checkCallable();
|
|
109
|
+
this.objectFormatName = format;
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
|
|
77
113
|
/**
|
|
78
114
|
* Set the FilesApi implementation for storage.
|
|
79
115
|
*
|
|
@@ -136,8 +172,9 @@ export class InitCommand {
|
|
|
136
172
|
/**
|
|
137
173
|
* Set the initial branch name.
|
|
138
174
|
*
|
|
139
|
-
* This is the branch that HEAD will point to after initialization.
|
|
140
|
-
*
|
|
175
|
+
* This is the branch that HEAD will point to after initialization. Without it, git's
|
|
176
|
+
* default: `init.defaultBranch` from the system or global configuration (or `git -c`),
|
|
177
|
+
* else `master`, or `main` with `GitHostEnvironment.breakingChanges` (git 3.0).
|
|
141
178
|
*
|
|
142
179
|
* @param branch The initial branch name
|
|
143
180
|
* @returns this for method chaining
|
|
@@ -148,6 +185,21 @@ export class InitCommand {
|
|
|
148
185
|
return this;
|
|
149
186
|
}
|
|
150
187
|
|
|
188
|
+
/**
|
|
189
|
+
* Set the ref storage format of a new repository (`git init --ref-format`): `files` (loose
|
|
190
|
+
* refs and packed-refs) or `reftable` (`.git/reftable`). Without it, git's default:
|
|
191
|
+
* `$GIT_DEFAULT_REF_FORMAT`, `init.defaultRefFormat`, else `files`, or `reftable` with
|
|
192
|
+
* `GitHostEnvironment.breakingChanges` (git 3.0). An existing repository keeps its format.
|
|
193
|
+
*
|
|
194
|
+
* @param format "files" or "reftable"
|
|
195
|
+
* @returns this for method chaining
|
|
196
|
+
*/
|
|
197
|
+
setRefFormat(format: "files" | "reftable" | string): this {
|
|
198
|
+
this.checkCallable();
|
|
199
|
+
this.refFormat = format;
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
|
|
151
203
|
/**
|
|
152
204
|
* Set a custom staging store.
|
|
153
205
|
*
|
|
@@ -243,6 +295,29 @@ export class InitCommand {
|
|
|
243
295
|
this.checkCallable();
|
|
244
296
|
this.setCallable(false);
|
|
245
297
|
|
|
298
|
+
// git's -b / init.defaultBranch / built-in default (repo_default_branch_name), worked out
|
|
299
|
+
// only for a repository without HEAD (create_reference_database runs only then): an
|
|
300
|
+
// existing repository keeps its HEAD, ignores -b with a warning and checks no name
|
|
301
|
+
let initialBranch = "";
|
|
302
|
+
let hints: string[] | undefined;
|
|
303
|
+
const warnings: string[] = [];
|
|
304
|
+
const chooseBranch = async () => {
|
|
305
|
+
if (this.initialBranch !== undefined && !isValidBranchName(this.initialBranch)) {
|
|
306
|
+
throw new InvalidInitialBranchError(this.initialBranch);
|
|
307
|
+
}
|
|
308
|
+
const chosen =
|
|
309
|
+
this.initialBranch !== undefined
|
|
310
|
+
? { name: this.initialBranch }
|
|
311
|
+
: await defaultInitialBranch(this.environment);
|
|
312
|
+
initialBranch = chosen.name;
|
|
313
|
+
hints = chosen.hint;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
// an explicit --object-format git does not know dies before anything is written
|
|
317
|
+
const explicitFormat =
|
|
318
|
+
this.objectFormatName === undefined ? undefined : knownHashAlgorithm(this.objectFormatName);
|
|
319
|
+
let objectFormat: ObjectFormat = SHA1_OBJECT_FORMAT;
|
|
320
|
+
|
|
246
321
|
// Use in-memory FilesApi if none provided
|
|
247
322
|
const files = this.files ?? createInMemoryFilesApi();
|
|
248
323
|
|
|
@@ -264,12 +339,33 @@ export class InitCommand {
|
|
|
264
339
|
// A repository with a config but no HEAD (damaged or half-made) is opened, not
|
|
265
340
|
// re-created: creating rewrites the config, and its remotes and settings with it.
|
|
266
341
|
const fresh = !hasHead && !(await isFile(`${dir}/config`));
|
|
342
|
+
if (fresh) {
|
|
343
|
+
objectFormat = explicitFormat ?? (await this.defaultObjectFormat(warnings));
|
|
344
|
+
} else {
|
|
345
|
+
// validate_hash_algorithm: an existing repository keeps its format, and refuses
|
|
346
|
+
// another one asked for explicitly (git 2.5x ignores $GIT_DEFAULT_HASH there)
|
|
347
|
+
objectFormat = (await readRepositoryFormat(repoFiles, dir)).objectFormat;
|
|
348
|
+
if (explicitFormat && explicitFormat.name !== objectFormat.name) {
|
|
349
|
+
throw new ReinitializeHashError();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (!hasHead) await chooseBranch();
|
|
353
|
+
else if (this.initialBranch !== undefined) {
|
|
354
|
+
warnings.push(`warning: re-init: ignored --initial-branch=${this.initialBranch}`);
|
|
355
|
+
}
|
|
356
|
+
// the ref storage of a repository created here (an existing one keeps its own)
|
|
357
|
+
const refFormat = fresh
|
|
358
|
+
? await defaultRefFormat(this.environment, this.refFormat)
|
|
359
|
+
: undefined;
|
|
360
|
+
if (refFormat) warnings.push(...refFormat.warnings);
|
|
267
361
|
const open = (create: boolean) =>
|
|
268
362
|
createGitFilesHistoryFromFiles({
|
|
269
363
|
files: repoFiles,
|
|
270
364
|
gitDir,
|
|
271
365
|
create,
|
|
272
|
-
defaultBranch:
|
|
366
|
+
defaultBranch: initialBranch,
|
|
367
|
+
...(create ? { objectFormat } : {}),
|
|
368
|
+
...(create && refFormat ? { refFormat: refFormat.format } : {}),
|
|
273
369
|
...(this.environment ? { environment: this.environment } : {}),
|
|
274
370
|
});
|
|
275
371
|
if (fresh && this.bare && dir !== ".") {
|
|
@@ -282,6 +378,14 @@ export class InitCommand {
|
|
|
282
378
|
history = await open(fresh);
|
|
283
379
|
}
|
|
284
380
|
await history.initialize();
|
|
381
|
+
if (hasHead) {
|
|
382
|
+
// the branch an existing repository's HEAD names (empty when detached)
|
|
383
|
+
const head = await history.refs.get("HEAD");
|
|
384
|
+
initialBranch =
|
|
385
|
+
head && "target" in head && head.target.startsWith("refs/heads/")
|
|
386
|
+
? head.target.slice("refs/heads/".length)
|
|
387
|
+
: "";
|
|
388
|
+
}
|
|
285
389
|
if (fresh) {
|
|
286
390
|
// git init's probe: a filesystem that folds case or Unicode composition
|
|
287
391
|
const folding = await probeCaseFolding(repoFiles as PosixFilesApi, dir);
|
|
@@ -292,7 +396,7 @@ export class InitCommand {
|
|
|
292
396
|
}
|
|
293
397
|
}
|
|
294
398
|
if (!hasHead && !fresh) {
|
|
295
|
-
await history.refs.setSymbolic("HEAD", `refs/heads/${
|
|
399
|
+
await history.refs.setSymbolic("HEAD", `refs/heads/${initialBranch}`);
|
|
296
400
|
}
|
|
297
401
|
// The index lives in the repository too: a reopened repository keeps what was staged
|
|
298
402
|
// (its last commit's files), so the next commit does not drop them.
|
|
@@ -301,15 +405,18 @@ export class InitCommand {
|
|
|
301
405
|
} else if (this.bare) {
|
|
302
406
|
staging = new MemoryStagingStore();
|
|
303
407
|
} else {
|
|
304
|
-
const fileStaging = new FileStagingStore(repoFiles, `${dir}/index
|
|
305
|
-
|
|
408
|
+
const fileStaging = new FileStagingStore(repoFiles, `${dir}/index`, { objectFormat });
|
|
409
|
+
// a SHA-256 repository's index is not read yet: its first use refuses
|
|
410
|
+
if (objectFormat.name === "sha1") await fileStaging.read();
|
|
306
411
|
staging = fileStaging;
|
|
307
412
|
}
|
|
308
413
|
} else {
|
|
309
|
-
|
|
414
|
+
objectFormat = explicitFormat ?? (await this.defaultObjectFormat(warnings));
|
|
415
|
+
await chooseBranch();
|
|
416
|
+
history = createMemoryHistory({ objectFormat });
|
|
310
417
|
await history.initialize();
|
|
311
418
|
// Set initial branch by creating symbolic ref for HEAD
|
|
312
|
-
await history.refs.setSymbolic("HEAD", `refs/heads/${
|
|
419
|
+
await history.refs.setSymbolic("HEAD", `refs/heads/${initialBranch}`);
|
|
313
420
|
staging = this.stagingStore ?? new MemoryStagingStore();
|
|
314
421
|
}
|
|
315
422
|
|
|
@@ -405,12 +512,34 @@ export class InitCommand {
|
|
|
405
512
|
git,
|
|
406
513
|
workingCopy,
|
|
407
514
|
repository: history,
|
|
408
|
-
initialBranch
|
|
515
|
+
initialBranch,
|
|
516
|
+
...(hints ? { hints } : {}),
|
|
517
|
+
...(warnings.length > 0 ? { warnings } : {}),
|
|
409
518
|
bare: this.bare,
|
|
410
519
|
gitDir,
|
|
411
520
|
};
|
|
412
521
|
}
|
|
413
522
|
|
|
523
|
+
/**
|
|
524
|
+
* The format of a new repository without `--object-format` (validate_hash_algorithm):
|
|
525
|
+
* `$GIT_DEFAULT_HASH` (an unknown name dies), else `init.defaultObjectFormat` (git 2.45+;
|
|
526
|
+
* an unknown name warns and is ignored), else SHA-1.
|
|
527
|
+
*/
|
|
528
|
+
private async defaultObjectFormat(warnings: string[]): Promise<ObjectFormat> {
|
|
529
|
+
const env = this.environment?.defaultHash;
|
|
530
|
+
if (env !== undefined) return knownHashAlgorithm(env);
|
|
531
|
+
const config = await readProtectedConfig(this.environment);
|
|
532
|
+
const configured = config
|
|
533
|
+
.filter((e) => e.key.toLowerCase() === "init.defaultobjectformat")
|
|
534
|
+
.at(-1);
|
|
535
|
+
if (configured?.value !== undefined) {
|
|
536
|
+
const found = objectFormatByName(configured.value);
|
|
537
|
+
if (found) return found;
|
|
538
|
+
warnings.push(`warning: unknown hash algorithm '${configured.value}'`);
|
|
539
|
+
}
|
|
540
|
+
return SHA1_OBJECT_FORMAT;
|
|
541
|
+
}
|
|
542
|
+
|
|
414
543
|
/**
|
|
415
544
|
* Resolve the git directory path based on configuration.
|
|
416
545
|
*/
|
|
@@ -453,6 +582,33 @@ export class InitCommand {
|
|
|
453
582
|
}
|
|
454
583
|
}
|
|
455
584
|
|
|
585
|
+
/** `--object-format` or `$GIT_DEFAULT_HASH` names no format git knows: git dies (exit 128). */
|
|
586
|
+
export class UnknownHashAlgorithmError extends Error {
|
|
587
|
+
override name = "UnknownHashAlgorithmError";
|
|
588
|
+
readonly lines: string[];
|
|
589
|
+
constructor(readonly value: string) {
|
|
590
|
+
const line = `fatal: unknown hash algorithm '${value}'`;
|
|
591
|
+
super(line);
|
|
592
|
+
this.lines = [line];
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/** `--object-format` names another format than the existing repository's: git dies (exit 128). */
|
|
597
|
+
export class ReinitializeHashError extends Error {
|
|
598
|
+
override name = "ReinitializeHashError";
|
|
599
|
+
readonly lines = ["fatal: attempt to reinitialize repository with different hash"];
|
|
600
|
+
constructor() {
|
|
601
|
+
super("fatal: attempt to reinitialize repository with different hash");
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/** The format named `name`, or `UnknownHashAlgorithmError` (git's `hash_algo_by_name`). */
|
|
606
|
+
function knownHashAlgorithm(name: string): ObjectFormat {
|
|
607
|
+
const found = objectFormatByName(name);
|
|
608
|
+
if (!found) throw new UnknownHashAlgorithmError(name);
|
|
609
|
+
return found;
|
|
610
|
+
}
|
|
611
|
+
|
|
456
612
|
/** Sets `core.bare = true` in a config file written by the git directory layout. */
|
|
457
613
|
async function markBare(files: FilesApi, configPath: string): Promise<void> {
|
|
458
614
|
await setCoreValue(files, configPath, "bare", "true");
|