@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isValidRefName, parseCoreAbbrev } from "@statewalker/vcs-core";
|
|
2
2
|
import {
|
|
3
|
+
countRefspecMatch,
|
|
3
4
|
createRepositoryFacade,
|
|
4
5
|
createTransportRefStore,
|
|
5
6
|
expandFromSource,
|
|
@@ -7,8 +8,12 @@ import {
|
|
|
7
8
|
formatPushStatus,
|
|
8
9
|
mapRejectReason,
|
|
9
10
|
matchSource,
|
|
11
|
+
ObjectFormatMismatchError,
|
|
12
|
+
objectSource,
|
|
13
|
+
PushCertificateError,
|
|
10
14
|
type PushClientResult,
|
|
11
15
|
type PushCommandResult,
|
|
16
|
+
PushRefspecError,
|
|
12
17
|
type PushRefUpdate,
|
|
13
18
|
PushRefusedByHookError,
|
|
14
19
|
parseRefSpec,
|
|
@@ -16,10 +21,13 @@ import {
|
|
|
16
21
|
type PushOptions as TransportPushOptions,
|
|
17
22
|
} from "@statewalker/vcs-transport";
|
|
18
23
|
import { parseGitBool, parseGitInt } from "@statewalker/vcs-utils/encoding";
|
|
24
|
+
import { isNullObjectId } from "@statewalker/vcs-utils/hash";
|
|
19
25
|
|
|
20
26
|
import {
|
|
21
27
|
HookFailedError,
|
|
28
|
+
IncompatibleOptionsError,
|
|
22
29
|
InvalidArgumentError,
|
|
30
|
+
InvalidConfigError,
|
|
23
31
|
InvalidRemoteError,
|
|
24
32
|
NonFastForwardError,
|
|
25
33
|
PushRejectedException,
|
|
@@ -28,11 +36,11 @@ import {
|
|
|
28
36
|
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
29
37
|
import { type PushResult, PushStatus, type RemoteRefUpdate } from "../results/push-result.js";
|
|
30
38
|
import { TransportCommand } from "../transport-command.js";
|
|
39
|
+
import { endOfSymbolicChain, installTracking, pushTrackingPlan } from "./branch-tracking.js";
|
|
40
|
+
import { hostEnvironmentOf } from "./git-ident.js";
|
|
31
41
|
import { remoteHookSession } from "./local-transport.js";
|
|
32
42
|
import { withRemoteReceivePack } from "./remote-transport.js";
|
|
33
|
-
|
|
34
|
-
/** All-zero object id — Git's "no object", used to express a ref delete. */
|
|
35
|
-
const ZERO_OBJECT_ID = "0".repeat(40);
|
|
43
|
+
import { SIGNING_FAILED_LINES, SigningFailedError } from "./signing.js";
|
|
36
44
|
|
|
37
45
|
/**
|
|
38
46
|
* How a server's rejection reason (`ng <ref> <reason>`) lands on the statuses this package
|
|
@@ -69,6 +77,7 @@ function toPushStatus(update: PushRefUpdate): PushStatus {
|
|
|
69
77
|
case "rejected-fetch-first":
|
|
70
78
|
return PushStatus.REJECTED_NONFASTFORWARD;
|
|
71
79
|
case "rejected-stale":
|
|
80
|
+
case "rejected-remote-updated":
|
|
72
81
|
return PushStatus.REJECTED_REMOTE_CHANGED;
|
|
73
82
|
case "remote-rejected":
|
|
74
83
|
return REJECT_REASON_STATUS[mapRejectReason(update.message ?? "")];
|
|
@@ -119,10 +128,16 @@ function toPushStatus(update: PushRefUpdate): PushStatus {
|
|
|
119
128
|
* ```
|
|
120
129
|
*/
|
|
121
130
|
export class PushCommand extends TransportCommand<PushResult> {
|
|
131
|
+
/** The remote, once set or resolved in `call` (git's `pushremote_for_branch`) */
|
|
122
132
|
private remote = "origin";
|
|
133
|
+
private remoteGiven = false;
|
|
134
|
+
/** Whether the remote was set or came from the configuration (git's `explicit`) */
|
|
135
|
+
private remoteExplicit = false;
|
|
123
136
|
private refSpecs: string[] = [];
|
|
124
137
|
private force = false;
|
|
125
138
|
private atomic = false;
|
|
139
|
+
/** `--[no-]signed[=if-asked]` (undefined: `push.gpgSign`) */
|
|
140
|
+
private signed?: boolean | "if-asked";
|
|
126
141
|
private noVerify = false;
|
|
127
142
|
|
|
128
143
|
/** `--no-verify`: the pre-push hook does not run. */
|
|
@@ -142,23 +157,125 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
142
157
|
private streamRequestBody?: boolean;
|
|
143
158
|
/** Leases (an entry without a ref: every other pushed ref at its tracking value) */
|
|
144
159
|
private leases?: ForceWithLease[];
|
|
160
|
+
/** `-u` / `--set-upstream` */
|
|
161
|
+
private setUpstream = false;
|
|
162
|
+
/** `--[no-]follow-tags` (undefined: `push.followTags`) */
|
|
163
|
+
private followTags?: boolean;
|
|
164
|
+
/** `--[no-]force-if-includes` (undefined: `push.useForceIfIncludes`) */
|
|
165
|
+
private forceIfIncludes?: boolean;
|
|
166
|
+
/** `--mirror` (undefined: `remote.<name>.mirror`) */
|
|
167
|
+
private mirror?: boolean;
|
|
168
|
+
/** `-d` / `--delete` */
|
|
169
|
+
private deleteRefs = false;
|
|
170
|
+
/** Whose messages to give where git 2.43 and 2.5x differ (undefined: the hook runner's) */
|
|
171
|
+
private compatibility?: "2.43" | "2.56";
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* `--mirror` (true): every local ref (`refs/*`) is pushed to the same name, forced, and every
|
|
175
|
+
* remote ref without a local one is deleted, as git's `TRANSPORT_PUSH_MIRROR`. Undefined
|
|
176
|
+
* (the default) reads `remote.<name>.mirror` of a configured remote; false is no mirror,
|
|
177
|
+
* whatever that says. A mirror push takes no refspecs, nor `setPushAll`, `setPushTags` or
|
|
178
|
+
* `setDelete` (git's refusals).
|
|
179
|
+
*/
|
|
180
|
+
setMirror(mirror: boolean | undefined): this {
|
|
181
|
+
this.checkCallable();
|
|
182
|
+
this.mirror = mirror;
|
|
183
|
+
return this;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** `--mirror` as set (undefined: `remote.<name>.mirror` decides in `call`). */
|
|
187
|
+
isMirror(): boolean | undefined {
|
|
188
|
+
return this.mirror;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* `-d` / `--delete`: each refspec is a remote ref to delete (`main` as `:main`, `tag v1` as
|
|
193
|
+
* `:refs/tags/v1`); a `src:dst` refspec or an empty one is refused, and so is a delete with
|
|
194
|
+
* no refspec, `setPushAll`, `setPushTags` or `setMirror`, as git refuses them.
|
|
195
|
+
*/
|
|
196
|
+
setDelete(deleteRefs: boolean): this {
|
|
197
|
+
this.checkCallable();
|
|
198
|
+
this.deleteRefs = deleteRefs;
|
|
199
|
+
return this;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Whether `setDelete` is on. */
|
|
203
|
+
isDelete(): boolean {
|
|
204
|
+
return this.deleteRefs;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Whose messages to give where git 2.43 and 2.5x differ (the incompatible options of
|
|
209
|
+
* `--delete`, `--tags`, `--all` and `--mirror`, and when they are checked). Default: the hook
|
|
210
|
+
* runner's compatibility, else 2.56.
|
|
211
|
+
*/
|
|
212
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
213
|
+
this.checkCallable();
|
|
214
|
+
this.compatibility = version;
|
|
215
|
+
return this;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* `-u` / `--set-upstream`: each local branch pushed to a remote branch (accepted or already
|
|
220
|
+
* up to date, not deleted) gets that branch of this remote as its upstream
|
|
221
|
+
* (`branch.<name>.remote` = the remote's name, or the URL as given; `.merge` = the remote
|
|
222
|
+
* ref), written as `git branch --set-upstream-to` writes it; git's `branch '<b>' set up to
|
|
223
|
+
* track '<remote>/<branch>'.` lines are {@link PushResult.upstreamMessages}. A dry run
|
|
224
|
+
* writes nothing and tells `Would set upstream of '<b>' to '<branch>' of '<remote>'`.
|
|
225
|
+
*/
|
|
226
|
+
setSetUpstream(setUpstream: boolean): this {
|
|
227
|
+
this.checkCallable();
|
|
228
|
+
this.setUpstream = setUpstream;
|
|
229
|
+
return this;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* `--follow-tags` (true) / `--no-follow-tags` (false); undefined (the default) reads
|
|
234
|
+
* `push.followTags`. Also pushes every local annotated tag the remote lacks whose commit
|
|
235
|
+
* the pushed refs reach (or the remote's refs that are not pushed), as git's
|
|
236
|
+
* `add_missing_tags`; lightweight tags and tags of trees or blobs are never followed.
|
|
237
|
+
*/
|
|
238
|
+
setFollowTags(followTags: boolean | undefined): this {
|
|
239
|
+
this.checkCallable();
|
|
240
|
+
this.followTags = followTags;
|
|
241
|
+
return this;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* `--force-if-includes` (true) / `--no-force-if-includes` (false); undefined (the default)
|
|
246
|
+
* reads `push.useForceIfIncludes`. With a `--force-with-lease` that expects a
|
|
247
|
+
* remote-tracking value (no explicit value), a ref whose remote value is in no reflog entry
|
|
248
|
+
* of the local ref of the same name, nor reachable from one made since the tracking ref's
|
|
249
|
+
* last update, is refused ("remote ref updated since checkout",
|
|
250
|
+
* {@link PushStatus.REJECTED_REMOTE_CHANGED}). Without a lease it does nothing, as in git.
|
|
251
|
+
*/
|
|
252
|
+
setForceIfIncludes(forceIfIncludes: boolean | undefined): this {
|
|
253
|
+
this.checkCallable();
|
|
254
|
+
this.forceIfIncludes = forceIfIncludes;
|
|
255
|
+
return this;
|
|
256
|
+
}
|
|
145
257
|
|
|
146
258
|
/**
|
|
147
259
|
* Set the remote to push to.
|
|
148
260
|
*
|
|
149
|
-
* Can be either a remote name (e.g., "origin") or a URL.
|
|
150
|
-
*
|
|
261
|
+
* Can be either a remote name (e.g., "origin") or a URL. When none is set, `call` picks
|
|
262
|
+
* the remote as `git push` does (`pushremote_for_branch`): `branch.<current>.pushRemote`,
|
|
263
|
+
* `remote.pushDefault`, `branch.<current>.remote`, the one configured remote, else `origin`
|
|
264
|
+
* (a detached HEAD skips the branch's settings).
|
|
151
265
|
*
|
|
152
266
|
* @param remote Remote name or URL
|
|
153
267
|
*/
|
|
154
268
|
setRemote(remote: string): this {
|
|
155
269
|
this.checkCallable();
|
|
156
270
|
this.remote = remote;
|
|
271
|
+
this.remoteGiven = true;
|
|
272
|
+
this.remoteExplicit = true;
|
|
157
273
|
return this;
|
|
158
274
|
}
|
|
159
275
|
|
|
160
276
|
/**
|
|
161
|
-
* Get the remote being pushed to
|
|
277
|
+
* Get the remote being pushed to: the one set, or after `call` the one it chose (`origin`
|
|
278
|
+
* before then).
|
|
162
279
|
*/
|
|
163
280
|
getRemote(): string {
|
|
164
281
|
return this.remote;
|
|
@@ -265,6 +382,37 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
265
382
|
return this;
|
|
266
383
|
}
|
|
267
384
|
|
|
385
|
+
/**
|
|
386
|
+
* `--signed` (true), `--no-signed` (false) or `--signed=if-asked`: whether to sign a push
|
|
387
|
+
* certificate; undefined (the default) leaves it to `push.gpgSign` (a boolean or
|
|
388
|
+
* `if-asked`). A server that takes no certificate refuses a signed push (`fatal: the
|
|
389
|
+
* receiving end does not support --signed push`) and gets an `if-asked` one unsigned,
|
|
390
|
+
* with git's warning ({@link PushResult.warnings}). Not signed yet: a certificate
|
|
391
|
+
* the server takes fails as git fails when gpg cannot sign (`error: gpg failed to sign
|
|
392
|
+
* the data:`, `fatal: failed to sign the push certificate`, exit 128:
|
|
393
|
+
* {@link SigningFailedError}), before anything is sent.
|
|
394
|
+
*/
|
|
395
|
+
setSigned(signed: boolean | "if-asked" | undefined): this {
|
|
396
|
+
this.checkCallable();
|
|
397
|
+
this.signed = signed;
|
|
398
|
+
return this;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* The push certificate asked for (git's SEND_PACK_PUSH_CERT_*): the option, else
|
|
403
|
+
* `push.gpgSign` (a boolean or `if-asked`, case-insensitive; another value signs nothing).
|
|
404
|
+
*/
|
|
405
|
+
private pushCertMode(): "always" | "if-asked" | undefined {
|
|
406
|
+
let value: boolean | "if-asked" | undefined = this.signed;
|
|
407
|
+
if (value === undefined) {
|
|
408
|
+
const raw = RemoteConfigStore.from(this.workingCopy).value("push.gpgSign");
|
|
409
|
+
if (raw !== undefined) {
|
|
410
|
+
value = raw.trim().toLowerCase() === "if-asked" ? "if-asked" : parseGitBool(raw);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return value === true ? "always" : value === "if-asked" ? "if-asked" : undefined;
|
|
414
|
+
}
|
|
415
|
+
|
|
268
416
|
/**
|
|
269
417
|
* Whether atomic push is enabled.
|
|
270
418
|
*/
|
|
@@ -374,7 +522,10 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
374
522
|
* Set push options associated with the push operation.
|
|
375
523
|
*
|
|
376
524
|
* Push options are strings passed to the receive-pack on the server
|
|
377
|
-
* side, where they can be used by hooks.
|
|
525
|
+
* side, where they can be used by hooks (`GIT_PUSH_OPTION_COUNT`, `GIT_PUSH_OPTION_<n>`).
|
|
526
|
+
* As git's `-o`: when none are given, `push.pushOption` gives them (each value added in
|
|
527
|
+
* order, an empty value clearing the list). A server that does not advertise them
|
|
528
|
+
* (`receive.advertisePushOptions`) refuses the push before anything is sent.
|
|
378
529
|
*
|
|
379
530
|
* @param options Push option strings
|
|
380
531
|
*/
|
|
@@ -429,51 +580,140 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
429
580
|
async call(): Promise<PushResult> {
|
|
430
581
|
this.checkCallable();
|
|
431
582
|
this.setCallable(false);
|
|
583
|
+
const compatibility = this.compatibility ?? this.hooks.compatibility;
|
|
432
584
|
|
|
585
|
+
// git_push_config: push.pushOption is read (and a bad one dies) before anything else;
|
|
586
|
+
// the command line's options replace the configured ones
|
|
587
|
+
const configuredOptions = this.configuredPushOptions();
|
|
588
|
+
const transmitted = this.pushOptions.length > 0 ? this.pushOptions : configuredOptions;
|
|
589
|
+
this.checkOptionCombinations(compatibility);
|
|
590
|
+
if (this.deleteRefs && this.refSpecs.length === 0) {
|
|
591
|
+
throw new InvalidArgumentError(
|
|
592
|
+
"refspecs",
|
|
593
|
+
undefined,
|
|
594
|
+
"--delete doesn't make sense without any refs",
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
// 2.43 checks the refspecs given before it looks the remote up
|
|
598
|
+
if (compatibility === "2.43") this.checkRefspecArguments();
|
|
599
|
+
|
|
600
|
+
// pushremote_get(NULL): the push remote the configuration names for the current branch
|
|
601
|
+
if (!this.remoteGiven) {
|
|
602
|
+
const ref = await this.getCurrentBranch();
|
|
603
|
+
const branch = ref?.startsWith("refs/heads/") ? ref.slice("refs/heads/".length) : undefined;
|
|
604
|
+
const choice = RemoteConfigStore.from(this.workingCopy).pushRemoteChoiceForBranch(branch);
|
|
605
|
+
this.remote = choice.name;
|
|
606
|
+
this.remoteExplicit = choice.explicit;
|
|
607
|
+
}
|
|
608
|
+
// pushremote_get: a remote the configuration gives no URL may come from .git/remotes/ or
|
|
609
|
+
// .git/branches/ (git 2.x)
|
|
610
|
+
const legacyWarnings = await this.loadLegacyRemote(this.remote);
|
|
611
|
+
const warnings = legacyWarnings.length > 0 ? { warnings: legacyWarnings } : {};
|
|
612
|
+
// git's push.c: a fallback remote (the one configured, origin) must be configured
|
|
613
|
+
// (remote_get(NULL) gives no remote otherwise); a name given or taken from the
|
|
614
|
+
// configuration is also tried as a URL or path (remotes_remote_get_1's add_url_alias)
|
|
615
|
+
if (
|
|
616
|
+
!this.remoteExplicit &&
|
|
617
|
+
!RemoteConfigStore.from(this.workingCopy).isConfigured(this.remote)
|
|
618
|
+
) {
|
|
619
|
+
throw new InvalidRemoteError(
|
|
620
|
+
this.remote,
|
|
621
|
+
"No configured push destination.\nEither specify the URL from the command-line or " +
|
|
622
|
+
"configure a remote repository using\n\n git remote add <name> <url>\n\n" +
|
|
623
|
+
"and then push using the remote name\n\n git push <name>" +
|
|
624
|
+
// 2.5x's remote groups
|
|
625
|
+
(compatibility === "2.43"
|
|
626
|
+
? ""
|
|
627
|
+
: "\n\nTo push to multiple remotes at once, configure a remote group using\n\n" +
|
|
628
|
+
' git config remotes.<groupname> "<remote1> <remote2>"\n\n' +
|
|
629
|
+
"and then push using the group name\n\n git push <groupname>"),
|
|
630
|
+
);
|
|
631
|
+
}
|
|
433
632
|
const remoteUrl = await this.resolveRemoteUrl(this.remote);
|
|
434
633
|
if (!remoteUrl) {
|
|
435
634
|
throw new InvalidRemoteError(this.remote);
|
|
436
635
|
}
|
|
636
|
+
// a mirror remote (remote.<name>.mirror) pushes as --mirror; --mirror implies --force
|
|
637
|
+
const mirror = this.mirror ?? this.remoteMirror();
|
|
638
|
+
const checks = this.remoteChecks(compatibility, mirror);
|
|
639
|
+
if (compatibility === "2.43") checks();
|
|
640
|
+
for (const option of transmitted) {
|
|
641
|
+
if (option.includes("\n")) {
|
|
642
|
+
throw new InvalidArgumentError(
|
|
643
|
+
"pushOptions",
|
|
644
|
+
option,
|
|
645
|
+
"push options must not have new line characters",
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
if (compatibility !== "2.43") {
|
|
650
|
+
checks();
|
|
651
|
+
this.checkRefspecArguments();
|
|
652
|
+
}
|
|
437
653
|
|
|
438
654
|
// transport_get: the remote's transport is decided (git's errors for one that cannot be
|
|
439
655
|
// reached) before the refspecs are worked out
|
|
440
656
|
const resolved = this.resolveRemote(remoteUrl);
|
|
441
|
-
const
|
|
657
|
+
const defaults = { setUpstream: false };
|
|
658
|
+
const refspecs = await this.buildRefSpecs(mirror, defaults, compatibility);
|
|
659
|
+
const setUpstream = this.setUpstream || defaults.setUpstream;
|
|
442
660
|
if (refspecs.length === 0) {
|
|
443
|
-
return {
|
|
661
|
+
return {
|
|
662
|
+
uri: remoteUrl,
|
|
663
|
+
remoteUpdates: [],
|
|
664
|
+
bytesSent: 0,
|
|
665
|
+
objectCount: 0,
|
|
666
|
+
messages: [],
|
|
667
|
+
...warnings,
|
|
668
|
+
};
|
|
444
669
|
}
|
|
445
670
|
|
|
446
671
|
const remote = await this.openRemote(resolved);
|
|
447
672
|
const localRemote = remote.kind === "local" ? remote.repository : undefined;
|
|
448
673
|
const history = this._workingCopy.history;
|
|
449
|
-
const tracking = this.trackingRefMapper();
|
|
674
|
+
const tracking = this.trackingRefMapper(remoteUrl, compatibility);
|
|
450
675
|
const messages: string[] = [];
|
|
451
676
|
const leases = this.leases;
|
|
677
|
+
const repository = createRepositoryFacade({
|
|
678
|
+
history,
|
|
679
|
+
useBitmaps: this.bitmapsInUse(),
|
|
680
|
+
// send-pack's pack-objects reads core.maxTreeDepth
|
|
681
|
+
maxTreeDepth: this.maxTreeDepth(),
|
|
682
|
+
});
|
|
683
|
+
// builtin/push.c: --force-if-includes counts only with a lease
|
|
684
|
+
const forceIfIncludes =
|
|
685
|
+
leases !== undefined &&
|
|
686
|
+
leases.length > 0 &&
|
|
687
|
+
(this.forceIfIncludes ?? this.configBool("push.useForceIfIncludes") ?? false);
|
|
452
688
|
const pushOptions: TransportPushOptions = {
|
|
453
689
|
url: remoteUrl,
|
|
454
690
|
auth: this.credentials,
|
|
455
691
|
headers: this.headers,
|
|
456
692
|
timeout: this.timeout,
|
|
457
|
-
repository
|
|
458
|
-
history,
|
|
459
|
-
useBitmaps: this.bitmapsInUse(),
|
|
460
|
-
// send-pack's pack-objects reads core.maxTreeDepth
|
|
461
|
-
maxTreeDepth: this.maxTreeDepth(),
|
|
462
|
-
}),
|
|
693
|
+
repository,
|
|
463
694
|
refStore: createTransportRefStore(history.refs),
|
|
464
695
|
refspecs,
|
|
465
|
-
force: this.force,
|
|
696
|
+
force: this.force || mirror,
|
|
466
697
|
atomic: this.atomic,
|
|
698
|
+
...(this.pushCertMode() ? { signed: this.pushCertMode() } : {}),
|
|
467
699
|
thin: this.thin,
|
|
468
700
|
dryRun: this.dryRun,
|
|
469
701
|
prune: this.prune,
|
|
702
|
+
mirror,
|
|
470
703
|
streamRequestBody: this.streamRequestBody,
|
|
471
|
-
pushOptions:
|
|
704
|
+
pushOptions: transmitted.length > 0 ? transmitted : undefined,
|
|
472
705
|
forceWithLease: leases,
|
|
473
706
|
trackingValue: async (remoteRef) => {
|
|
474
707
|
const local = tracking(remoteRef);
|
|
475
708
|
return local ? (await history.refs.resolve(local))?.objectId : undefined;
|
|
476
709
|
},
|
|
710
|
+
...(forceIfIncludes
|
|
711
|
+
? {
|
|
712
|
+
includesRemote: (remoteRef: string, remoteOid: string) =>
|
|
713
|
+
this.isReachableInReflog(remoteRef, tracking(remoteRef), remoteOid, repository),
|
|
714
|
+
}
|
|
715
|
+
: {}),
|
|
716
|
+
followTags: this.followTags ?? this.configBool("push.followTags") ?? false,
|
|
477
717
|
onProgress: (message) => {
|
|
478
718
|
messages.push(message);
|
|
479
719
|
this.progressMessageCallback?.(message);
|
|
@@ -495,6 +735,8 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
495
735
|
localRemote === undefined
|
|
496
736
|
? undefined
|
|
497
737
|
: remoteHookSession(this.workingCopy, localRemote, { localPush: true });
|
|
738
|
+
const environment = hostEnvironmentOf(this.workingCopy);
|
|
739
|
+
const receiveWarnings: string[] = [];
|
|
498
740
|
// --receive-pack, else remote.<name>.receivepack
|
|
499
741
|
const receivePack = this.receivePack ?? this.remoteProgram(this.remote, "receivepack");
|
|
500
742
|
try {
|
|
@@ -511,8 +753,51 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
511
753
|
? undefined
|
|
512
754
|
: remoteHookSession(this.workingCopy, localRemote, { localPush: true }),
|
|
513
755
|
transactionHooks,
|
|
756
|
+
{
|
|
757
|
+
host: {
|
|
758
|
+
...(environment ? { environment } : {}),
|
|
759
|
+
compatibility: this.hooks.compatibility,
|
|
760
|
+
},
|
|
761
|
+
// receive-pack's config warnings reach the shared stderr
|
|
762
|
+
onWarning: (line) => receiveWarnings.push(line),
|
|
763
|
+
},
|
|
514
764
|
);
|
|
515
765
|
} catch (error) {
|
|
766
|
+
// match_push_refs' refusals: errors (git exits 1 with "failed to push some refs"), or
|
|
767
|
+
// deaths for a refspec or a lease it cannot parse
|
|
768
|
+
if (error instanceof PushRefspecError) {
|
|
769
|
+
if (/^(invalid refspec|cannot parse expected object name) /.test(error.message)) {
|
|
770
|
+
throw new TransportError(`fatal: ${error.message}`, undefined, { cause: error });
|
|
771
|
+
}
|
|
772
|
+
throw new TransportError(
|
|
773
|
+
`error: ${error.message}\nerror: failed to push some refs to '${remoteUrl}'`,
|
|
774
|
+
undefined,
|
|
775
|
+
{ cause: error, exitCode: 1 },
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
// send_pack dies: --atomic or push options the server does not advertise
|
|
779
|
+
if (
|
|
780
|
+
error instanceof Error &&
|
|
781
|
+
!(error instanceof TransportError) &&
|
|
782
|
+
/^the receiving end does not support (--atomic push|push options)$/.test(error.message)
|
|
783
|
+
) {
|
|
784
|
+
throw new TransportError(`fatal: ${error.message}`, undefined, { cause: error });
|
|
785
|
+
}
|
|
786
|
+
// send_pack dies: the remote's repository names objects with another hash
|
|
787
|
+
if (error instanceof ObjectFormatMismatchError) {
|
|
788
|
+
throw new TransportError(`fatal: ${error.message}`, undefined, { cause: error });
|
|
789
|
+
}
|
|
790
|
+
// send_pack dies: no push certificate for this server, or none could be signed
|
|
791
|
+
if (error instanceof PushCertificateError) {
|
|
792
|
+
if (error.reason === "unsupported") {
|
|
793
|
+
throw new TransportError(`fatal: ${error.message}`, undefined, { cause: error });
|
|
794
|
+
}
|
|
795
|
+
throw new SigningFailedError(
|
|
796
|
+
[...SIGNING_FAILED_LINES, `fatal: ${error.message}`].join("\n"),
|
|
797
|
+
"",
|
|
798
|
+
128,
|
|
799
|
+
);
|
|
800
|
+
}
|
|
516
801
|
if (error instanceof PushRefusedByHookError) {
|
|
517
802
|
throw new HookFailedError(
|
|
518
803
|
"pre-push",
|
|
@@ -526,6 +811,9 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
526
811
|
if (transactionHooks) this.hooks.append(transactionHooks.output);
|
|
527
812
|
}
|
|
528
813
|
|
|
814
|
+
// transport_push: set_upstreams, before the remote-tracking refs are updated
|
|
815
|
+
const upstreamMessages = setUpstream ? await this.setUpstreams(result.updates) : [];
|
|
816
|
+
|
|
529
817
|
// git updates the remote-tracking refs of what the server accepted, and of what it had
|
|
530
818
|
// already (transport.c: update_tracking_ref for ok and up-to-date refs)
|
|
531
819
|
// receive_status's lines (read with the report), then the tracking refs' errors
|
|
@@ -557,7 +845,7 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
557
845
|
// error lines (the push is done: git exits 0). The names and ids come from the
|
|
558
846
|
// server (a proc-receive hook's `option refname` / `new-oid`): a bad name or an
|
|
559
847
|
// object we lack is refused, as refs.c's transaction refuses it
|
|
560
|
-
if (target.oid
|
|
848
|
+
if (isNullObjectId(target.oid)) {
|
|
561
849
|
if (!refNameIsSafe(local)) {
|
|
562
850
|
trackingErrors.push(`error: refusing to update ref with bad name '${local}'`);
|
|
563
851
|
continue;
|
|
@@ -607,7 +895,7 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
607
895
|
message: update.message ?? (update.status === "ok" ? undefined : update.summary),
|
|
608
896
|
summary: update.summary,
|
|
609
897
|
forceUpdate: update.force,
|
|
610
|
-
delete: update.newOid
|
|
898
|
+
delete: isNullObjectId(update.newOid),
|
|
611
899
|
...(update.reports?.length
|
|
612
900
|
? {
|
|
613
901
|
reports: update.reports.map((r) => ({
|
|
@@ -626,10 +914,18 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
626
914
|
bytesSent: result.bytesSent,
|
|
627
915
|
objectCount: result.packObjects,
|
|
628
916
|
messages,
|
|
917
|
+
// git's order: the legacy-remote deprecation, receive-pack's startup warnings (a local
|
|
918
|
+
// push), then send-pack's (an unsent push certificate)
|
|
919
|
+
...(legacyWarnings.length + receiveWarnings.length + (result.warnings?.length ?? 0) > 0
|
|
920
|
+
? { warnings: [...legacyWarnings, ...receiveWarnings, ...(result.warnings ?? [])] }
|
|
921
|
+
: {}),
|
|
629
922
|
display: formatPushStatus(result, { dest: remoteUrl }),
|
|
630
923
|
porcelain: formatPushStatus(result, { dest: remoteUrl, porcelain: true }),
|
|
631
924
|
...(trackingErrors.length ? { errors: trackingErrors } : {}),
|
|
632
|
-
...(
|
|
925
|
+
...(upstreamMessages.length ? { upstreamMessages } : {}),
|
|
926
|
+
// send_pack left at once (nothing to push to a remote without refs): the receiving end
|
|
927
|
+
// hung up, and git fails
|
|
928
|
+
...(result.reportFailed || result.noRefsInCommon ? { failed: true } : {}),
|
|
633
929
|
};
|
|
634
930
|
}
|
|
635
931
|
|
|
@@ -644,8 +940,13 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
644
940
|
remoteUrl: string,
|
|
645
941
|
exit: (code: number) => void,
|
|
646
942
|
): Promise<boolean> {
|
|
647
|
-
const skipped = new Set([
|
|
648
|
-
|
|
943
|
+
const skipped = new Set([
|
|
944
|
+
"rejected-nonfastforward",
|
|
945
|
+
"rejected-remote-updated",
|
|
946
|
+
"rejected-stale",
|
|
947
|
+
"up-to-date",
|
|
948
|
+
]);
|
|
949
|
+
const zero = this.objectFormat.nullId;
|
|
649
950
|
const stdin = updates
|
|
650
951
|
.filter((u) => !skipped.has(u.status))
|
|
651
952
|
.map((u) => {
|
|
@@ -663,6 +964,75 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
663
964
|
return false;
|
|
664
965
|
}
|
|
665
966
|
|
|
967
|
+
/**
|
|
968
|
+
* transport.c's `set_upstreams`: each update accepted or up to date, not a delete, whose
|
|
969
|
+
* local side is a branch (a symbolic ref such as HEAD followed to its branch) and whose
|
|
970
|
+
* remote side is a branch, sets that branch's upstream through `installTracking`; a dry run
|
|
971
|
+
* only says what it would set. git's stdout lines.
|
|
972
|
+
*/
|
|
973
|
+
private async setUpstreams(updates: readonly PushRefUpdate[]): Promise<string[]> {
|
|
974
|
+
const lines: string[] = [];
|
|
975
|
+
for (const update of updates) {
|
|
976
|
+
if (update.status !== "ok" && update.status !== "up-to-date") continue;
|
|
977
|
+
if (isNullObjectId(update.newOid)) continue;
|
|
978
|
+
// the peer ref: the local ref matched, else HEAD for a `HEAD` source
|
|
979
|
+
let local = update.localRef ?? (update.source === "HEAD" ? "HEAD" : undefined);
|
|
980
|
+
if (!local) continue;
|
|
981
|
+
const end = await endOfSymbolicChain(this.refsStore, local);
|
|
982
|
+
if (end?.startsWith("refs/heads/")) local = end;
|
|
983
|
+
if (!local.startsWith("refs/heads/") || !update.remoteRef.startsWith("refs/heads/")) {
|
|
984
|
+
continue;
|
|
985
|
+
}
|
|
986
|
+
const branch = local.slice("refs/heads/".length);
|
|
987
|
+
if (this.dryRun) {
|
|
988
|
+
lines.push(
|
|
989
|
+
`Would set upstream of '${branch}' to '${update.remoteRef.slice("refs/heads/".length)}' of '${this.remote}'`,
|
|
990
|
+
);
|
|
991
|
+
continue;
|
|
992
|
+
}
|
|
993
|
+
const plan = pushTrackingPlan(this.workingCopy, this.remote, update.remoteRef);
|
|
994
|
+
lines.push(...(await installTracking(this.workingCopy, branch, plan)));
|
|
995
|
+
}
|
|
996
|
+
return lines;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
/**
|
|
1000
|
+
* remote.c's `is_reachable_in_reflog` for `--force-if-includes`: whether the remote's value
|
|
1001
|
+
* (peeled to a commit) is the new value of an entry of the local ref's reflog (the local ref
|
|
1002
|
+
* of the remote ref's name), or an ancestor of one of the entries read until one older than
|
|
1003
|
+
* the remote-tracking ref's latest reflog entry.
|
|
1004
|
+
*/
|
|
1005
|
+
private async isReachableInReflog(
|
|
1006
|
+
localRef: string,
|
|
1007
|
+
trackingRef: string | undefined,
|
|
1008
|
+
remoteOid: string,
|
|
1009
|
+
repository: ReturnType<typeof createRepositoryFacade>,
|
|
1010
|
+
): Promise<boolean> {
|
|
1011
|
+
const objects = objectSource(repository);
|
|
1012
|
+
const commit = await objects.peelToCommit(remoteOid);
|
|
1013
|
+
if (!commit) return false;
|
|
1014
|
+
const refs = this.refsStore;
|
|
1015
|
+
// git leaves the date unset without a tracking reflog: nothing stops the walk early
|
|
1016
|
+
const latest = trackingRef
|
|
1017
|
+
? (await (await refs.getReflog?.(trackingRef))?.getLastEntry())?.who.timestamp
|
|
1018
|
+
: undefined;
|
|
1019
|
+
const since = latest ?? Number.NEGATIVE_INFINITY;
|
|
1020
|
+
const entries = (await (await refs.getReflog?.(localRef))?.getReverseEntries()) ?? [];
|
|
1021
|
+
const collected: string[] = [];
|
|
1022
|
+
for (const entry of entries) {
|
|
1023
|
+
if (entry.newId === commit) return true;
|
|
1024
|
+
const entryCommit = isNullObjectId(entry.newId)
|
|
1025
|
+
? undefined
|
|
1026
|
+
: await objects.peelToCommit(entry.newId);
|
|
1027
|
+
if (entryCommit) collected.push(entryCommit);
|
|
1028
|
+
if (entry.who.timestamp < since) break;
|
|
1029
|
+
}
|
|
1030
|
+
for (const c of collected) {
|
|
1031
|
+
if (await objects.isAncestor(commit, c)) return true;
|
|
1032
|
+
}
|
|
1033
|
+
return false;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
666
1036
|
/**
|
|
667
1037
|
* Push and throw on failure.
|
|
668
1038
|
*/
|
|
@@ -704,9 +1074,190 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
704
1074
|
}
|
|
705
1075
|
|
|
706
1076
|
/**
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
|
|
1077
|
+
* `push.pushOption` in config order (git's `parse_transport_option`): each value added, an
|
|
1078
|
+
* empty one clearing the list; a value-less one dies as git's config reader dies.
|
|
1079
|
+
*/
|
|
1080
|
+
private configuredPushOptions(): string[] {
|
|
1081
|
+
const key = "push.pushoption";
|
|
1082
|
+
const out: string[] = [];
|
|
1083
|
+
for (const { text, file, line } of RemoteConfigStore.from(this._workingCopy).valuesWithOrigin(
|
|
1084
|
+
"push.pushOption",
|
|
1085
|
+
)) {
|
|
1086
|
+
if (text === undefined) {
|
|
1087
|
+
const fatal =
|
|
1088
|
+
file !== undefined && line !== undefined
|
|
1089
|
+
? `fatal: bad config variable '${key}' in file '${file}' at line ${line}`
|
|
1090
|
+
: `fatal: unable to parse '${key}' from command-line config`;
|
|
1091
|
+
throw new InvalidConfigError(key, `error: missing value for '${key}'\n${fatal}`);
|
|
1092
|
+
}
|
|
1093
|
+
if (text === "") out.length = 0;
|
|
1094
|
+
else out.push(text);
|
|
1095
|
+
}
|
|
1096
|
+
return out;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* The options that cannot go together: 2.5x's `die_for_incompatible_opt4` (`--delete`,
|
|
1101
|
+
* `--tags`, `--all/--branches`, `--mirror`, all named), 2.43's `--delete` with any of the
|
|
1102
|
+
* others (the rest it checks once the remote is known, `remoteChecks`).
|
|
1103
|
+
*/
|
|
1104
|
+
private checkOptionCombinations(compatibility: "2.43" | "2.56"): void {
|
|
1105
|
+
if (compatibility === "2.43") {
|
|
1106
|
+
if (this.deleteRefs && (this.pushTags || this.pushAll || this.mirror)) {
|
|
1107
|
+
throw new IncompatibleOptionsError(
|
|
1108
|
+
["--delete", "--all/--branches/--mirror/--tags"],
|
|
1109
|
+
"options '--delete' and '--all/--branches/--mirror/--tags' cannot be used together",
|
|
1110
|
+
);
|
|
1111
|
+
}
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
const given = [
|
|
1115
|
+
this.deleteRefs && "--delete",
|
|
1116
|
+
this.pushTags && "--tags",
|
|
1117
|
+
this.pushAll && "--all/--branches",
|
|
1118
|
+
this.mirror && "--mirror",
|
|
1119
|
+
].filter((o): o is string => typeof o === "string");
|
|
1120
|
+
if (given.length < 2) return;
|
|
1121
|
+
const quoted = given.map((o) => `'${o}'`);
|
|
1122
|
+
const list =
|
|
1123
|
+
quoted.length === 2
|
|
1124
|
+
? `${quoted[0]} and ${quoted[1]}`
|
|
1125
|
+
: `${quoted.slice(0, -1).join(", ")}, and ${quoted.at(-1)}`;
|
|
1126
|
+
throw new IncompatibleOptionsError(given, `options ${list} cannot be used together`);
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
/** `remote.<name>.mirror` of a configured remote (git_config_bool). */
|
|
1130
|
+
private remoteMirror(): boolean {
|
|
1131
|
+
const store = RemoteConfigStore.from(this._workingCopy);
|
|
1132
|
+
if (!store.isConfigured(this.remote)) return false;
|
|
1133
|
+
const value = store.value(`remote.${this.remote}.mirror`);
|
|
1134
|
+
return value === undefined ? false : (parseGitBool(value) ?? false);
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* The checks git makes once the remote is known (a mirror remote counts as `--mirror`):
|
|
1139
|
+
* `--all` or `--mirror` with refspecs, and in 2.43 their combinations with `--tags` and
|
|
1140
|
+
* each other.
|
|
1141
|
+
*/
|
|
1142
|
+
private remoteChecks(compatibility: "2.43" | "2.56", mirror: boolean): () => void {
|
|
1143
|
+
const refused = (options: string[], message: string) => {
|
|
1144
|
+
throw new IncompatibleOptionsError(options, message);
|
|
1145
|
+
};
|
|
1146
|
+
const together = (a: string, b: string) =>
|
|
1147
|
+
refused([a, b], `options '${a}' and '${b}' cannot be used together`);
|
|
1148
|
+
return () => {
|
|
1149
|
+
const legacy = compatibility === "2.43";
|
|
1150
|
+
if (this.pushAll) {
|
|
1151
|
+
if (legacy && this.pushTags) together("--all", "--tags");
|
|
1152
|
+
if (this.refSpecs.length > 0) {
|
|
1153
|
+
refused(["--all"], "--all can't be combined with refspecs");
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
if (mirror) {
|
|
1157
|
+
if (legacy && this.pushTags) together("--mirror", "--tags");
|
|
1158
|
+
if (this.refSpecs.length > 0) {
|
|
1159
|
+
refused(["--mirror"], "--mirror can't be combined with refspecs");
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
if (legacy && this.pushAll && mirror) together("--all", "--mirror");
|
|
1163
|
+
};
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
/** set_refspecs' refusals of the refspecs given: `tag` without a name, `--delete` of `a:b`. */
|
|
1167
|
+
private checkRefspecArguments(): void {
|
|
1168
|
+
const refs = this.refSpecs;
|
|
1169
|
+
for (let i = 0; i < refs.length; i++) {
|
|
1170
|
+
const ref = refs[i] as string;
|
|
1171
|
+
if (ref === "tag") {
|
|
1172
|
+
if (++i >= refs.length) {
|
|
1173
|
+
throw new InvalidArgumentError("refspecs", ref, "tag shorthand without <tag>");
|
|
1174
|
+
}
|
|
1175
|
+
} else if (this.deleteRefs && (ref === "" || ref.includes(":"))) {
|
|
1176
|
+
throw new InvalidArgumentError(
|
|
1177
|
+
"refspecs",
|
|
1178
|
+
ref,
|
|
1179
|
+
"--delete only accepts plain target ref names",
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
/**
|
|
1186
|
+
* git's `set_refspecs`: the refspecs given, `tag <name>` as `refs/tags/<name>`, each a
|
|
1187
|
+
* deletion under `--delete`; a name without `:` that names exactly one local ref goes where
|
|
1188
|
+
* `remote.<name>.push` maps that ref, else (`push.default=upstream`) a branch to its single
|
|
1189
|
+
* upstream (`refspec_append_mapped`).
|
|
1190
|
+
*/
|
|
1191
|
+
private async givenRefspecs(): Promise<string[]> {
|
|
1192
|
+
const out: string[] = [];
|
|
1193
|
+
const refs = this.refSpecs;
|
|
1194
|
+
let local: string[] | undefined;
|
|
1195
|
+
for (let i = 0; i < refs.length; i++) {
|
|
1196
|
+
let ref = refs[i] as string;
|
|
1197
|
+
if (ref === "tag") {
|
|
1198
|
+
ref = refs[++i] as string;
|
|
1199
|
+
out.push(this.deleteRefs ? `:refs/tags/${ref}` : `refs/tags/${ref}`);
|
|
1200
|
+
} else if (this.deleteRefs) {
|
|
1201
|
+
out.push(`:${ref}`);
|
|
1202
|
+
} else if (!ref.includes(":")) {
|
|
1203
|
+
local ??= [...(await createTransportRefStore(this._workingCopy.history.refs).listAll())]
|
|
1204
|
+
.map(([name]) => name)
|
|
1205
|
+
.filter((name) => name.startsWith("refs/"));
|
|
1206
|
+
const { count, match } = countRefspecMatch(ref, local);
|
|
1207
|
+
out.push(count === 1 && match ? this.mappedRefspec(ref, match) : ref);
|
|
1208
|
+
} else {
|
|
1209
|
+
out.push(ref);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
return out;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/** git's `refspec_append_mapped`: where `ref` (naming the local ref `matched`) is pushed. */
|
|
1216
|
+
private mappedRefspec(ref: string, matched: string): string {
|
|
1217
|
+
const store = RemoteConfigStore.from(this._workingCopy);
|
|
1218
|
+
if (store.isConfigured(this.remote)) {
|
|
1219
|
+
for (const text of store.pushRefspecs(this.remote)) {
|
|
1220
|
+
const spec = parseRefSpec(text);
|
|
1221
|
+
if (spec.negative || !spec.source || !matchSource(spec, matched)) continue;
|
|
1222
|
+
const dst = spec.wildcard
|
|
1223
|
+
? expandFromSource(spec, matched).destination
|
|
1224
|
+
: (spec.destination ?? spec.source);
|
|
1225
|
+
if (dst) return `${spec.force ? "+" : ""}${matched}:${dst}`;
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
if (this.pushDefault() === "upstream" && matched.startsWith("refs/heads/")) {
|
|
1229
|
+
const merges = this.upstreamsOf(matched.slice("refs/heads/".length));
|
|
1230
|
+
if (merges.length === 1) return `${ref}:${merges[0]}`;
|
|
1231
|
+
}
|
|
1232
|
+
return ref;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* `push.default` as git reads it: `tracking` is `upstream`; undefined when unset (git's
|
|
1237
|
+
* `PUSH_DEFAULT_UNSPECIFIED`, which acts as `simple`).
|
|
1238
|
+
*/
|
|
1239
|
+
private pushDefault(): string | undefined {
|
|
1240
|
+
const value = RemoteConfigStore.from(this._workingCopy).value("push.default");
|
|
1241
|
+
return value === "tracking" ? "upstream" : value;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
/**
|
|
1245
|
+
* A branch's upstream merges (`branch.<name>.merge`), counted only while it has a remote
|
|
1246
|
+
* (`branch.<name>.remote`), as remote.c's `set_merge`.
|
|
1247
|
+
*/
|
|
1248
|
+
private upstreamsOf(branch: string): string[] {
|
|
1249
|
+
const store = RemoteConfigStore.from(this._workingCopy);
|
|
1250
|
+
if (!store.value(`branch.${branch}.remote`)) return [];
|
|
1251
|
+
return store.values(`branch.${branch}.merge`);
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
/**
|
|
1255
|
+
* The refspecs to push: `--mirror` (`remote.<name>.push`, else `:` over every ref; see
|
|
1256
|
+
* `PushClientOptions.mirror`),
|
|
1257
|
+
* `--tags`, the refspecs
|
|
1258
|
+
* given (`givenRefspecs`), `--all` (every branch); else the remote's configured push
|
|
1259
|
+
* refspecs; else what `push.default` says (git's builtin/push.c
|
|
1260
|
+
* `setup_default_push_refspecs`, default `simple`):
|
|
710
1261
|
*
|
|
711
1262
|
* - `simple`: the current branch to its upstream of the same name when pushing to the
|
|
712
1263
|
* branch's own remote (refused without an upstream, or with one of another name); to the
|
|
@@ -716,20 +1267,34 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
716
1267
|
* - `matching`: `:` (the branches both sides have)
|
|
717
1268
|
* - `nothing`: refused
|
|
718
1269
|
*
|
|
719
|
-
* A detached HEAD is refused, except with `matching`.
|
|
1270
|
+
* A detached HEAD is refused, except with `matching`. Under `push.autoSetupRemote` a branch
|
|
1271
|
+
* without an upstream is pushed to its own name and gets it as its upstream
|
|
1272
|
+
* (`defaults.setUpstream`).
|
|
720
1273
|
*/
|
|
721
|
-
private async buildRefSpecs(
|
|
722
|
-
|
|
723
|
-
|
|
1274
|
+
private async buildRefSpecs(
|
|
1275
|
+
mirror: boolean,
|
|
1276
|
+
defaults: { setUpstream: boolean },
|
|
1277
|
+
compatibility: "2.43" | "2.56",
|
|
1278
|
+
): Promise<string[]> {
|
|
1279
|
+
const store = RemoteConfigStore.from(this.workingCopy);
|
|
1280
|
+
// --mirror: do_push's refspecs (a mirror remote's --tags in 2.5x, else remote.<name>.push),
|
|
1281
|
+
// else ":" over every ref; send_mirror then deletes every remote ref they leave out
|
|
1282
|
+
if (mirror) {
|
|
1283
|
+
if (this.pushTags) return ["refs/tags/*:refs/tags/*"];
|
|
1284
|
+
const configured = store.isConfigured(this.remote) ? store.pushRefspecs(this.remote) : [];
|
|
1285
|
+
return configured.length > 0 ? configured : [":"];
|
|
1286
|
+
}
|
|
1287
|
+
if (this.pushAll) return ["refs/heads/*:refs/heads/*"];
|
|
1288
|
+
const specs: string[] = [];
|
|
724
1289
|
if (this.pushTags) specs.push("refs/tags/*:refs/tags/*");
|
|
1290
|
+
specs.push(...(await this.givenRefspecs()));
|
|
725
1291
|
if (specs.length > 0) return specs;
|
|
726
1292
|
|
|
727
|
-
const store = RemoteConfigStore.from(this.workingCopy);
|
|
728
1293
|
if (store.isConfigured(this.remote)) {
|
|
729
|
-
const configured = store.
|
|
1294
|
+
const configured = store.pushRefspecs(this.remote);
|
|
730
1295
|
if (configured.length > 0) return configured;
|
|
731
1296
|
}
|
|
732
|
-
const mode =
|
|
1297
|
+
const mode = this.pushDefault();
|
|
733
1298
|
if (mode === "matching") return [":"];
|
|
734
1299
|
if (mode === "nothing") {
|
|
735
1300
|
throw new InvalidArgumentError(
|
|
@@ -745,61 +1310,128 @@ export class PushCommand extends TransportCommand<PushResult> {
|
|
|
745
1310
|
throw new InvalidArgumentError(
|
|
746
1311
|
"refspecs",
|
|
747
1312
|
undefined,
|
|
748
|
-
"You are not currently on a branch
|
|
749
|
-
"
|
|
1313
|
+
"You are not currently on a branch.\n" +
|
|
1314
|
+
"To push the history leading to the current (detached HEAD)\n" +
|
|
1315
|
+
"state now, use\n\n" +
|
|
1316
|
+
` git push ${this.remote} HEAD:<name-of-remote-branch>\n`,
|
|
750
1317
|
);
|
|
751
1318
|
}
|
|
752
1319
|
const branch = ref.slice("refs/heads/".length);
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
//
|
|
756
|
-
const
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
const noUpstream = () =>
|
|
760
|
-
new InvalidArgumentError(
|
|
761
|
-
"refspecs",
|
|
762
|
-
undefined,
|
|
763
|
-
`The current branch ${branch} has no upstream branch. To push the current branch and ` +
|
|
764
|
-
`set the remote as upstream, use git push --set-upstream ${this.remote} ${branch}`,
|
|
765
|
-
);
|
|
766
|
-
if (mode === "upstream" || mode === "tracking") {
|
|
767
|
-
if (triangular) {
|
|
1320
|
+
const autoUpstream = this.configBool("push.autoSetupRemote") ?? false;
|
|
1321
|
+
const merges = this.upstreamsOf(branch);
|
|
1322
|
+
// get_upstream_ref
|
|
1323
|
+
const upstreamRef = (): string => {
|
|
1324
|
+
if (merges.length === 0 && autoUpstream) return ref;
|
|
1325
|
+
if (merges.length === 0) {
|
|
768
1326
|
throw new InvalidArgumentError(
|
|
769
1327
|
"refspecs",
|
|
770
1328
|
undefined,
|
|
771
|
-
`
|
|
772
|
-
|
|
773
|
-
|
|
1329
|
+
`The current branch ${branch} has no upstream branch.\n` +
|
|
1330
|
+
"To push the current branch and set the remote as upstream, use\n\n" +
|
|
1331
|
+
` git push --set-upstream ${this.remote} ${branch}\n` +
|
|
1332
|
+
(autoUpstream
|
|
1333
|
+
? ""
|
|
1334
|
+
: "\nTo have this happen automatically for branches without a tracking\n" +
|
|
1335
|
+
"upstream, see 'push.autoSetupRemote' in 'git help config'.\n"),
|
|
774
1336
|
);
|
|
775
1337
|
}
|
|
776
|
-
if (
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
1338
|
+
if (merges.length !== 1) {
|
|
1339
|
+
throw new InvalidArgumentError(
|
|
1340
|
+
"refspecs",
|
|
1341
|
+
undefined,
|
|
1342
|
+
`The current branch ${branch} has multiple upstream branches, refusing to push.`,
|
|
1343
|
+
);
|
|
1344
|
+
}
|
|
1345
|
+
return merges[0] as string;
|
|
1346
|
+
};
|
|
1347
|
+
// 2.5x: remote_for_branch (branch.<name>.remote, the one configured remote, else
|
|
1348
|
+
// "origin") names the pushed-to remote; 2.43's is_workflow_triangular: the fetch remote
|
|
1349
|
+
// (remote_get(NULL)) exists and is another one
|
|
1350
|
+
// remote_state's remotes are the configured ones and the one pushed to (a URL is made a
|
|
1351
|
+
// remote of its own by remote_get), so pushing to a URL from a repository without
|
|
1352
|
+
// remotes counts that URL as "the one remote"
|
|
1353
|
+
const own = store.value(`branch.${branch}.remote`);
|
|
1354
|
+
const known = new Set(store.configuredNames());
|
|
1355
|
+
known.add(this.remote);
|
|
1356
|
+
const fetchName = own ?? (known.size === 1 ? this.remote : "origin");
|
|
1357
|
+
const fetchValid =
|
|
1358
|
+
own !== undefined || fetchName === this.remote || store.isConfigured(fetchName);
|
|
1359
|
+
const sameRemote =
|
|
1360
|
+
compatibility === "2.43"
|
|
1361
|
+
? !(fetchValid && fetchName !== this.remote)
|
|
1362
|
+
: this.remote === fetchName;
|
|
1363
|
+
let dst = ref;
|
|
1364
|
+
if (mode === "current") {
|
|
1365
|
+
// the same name
|
|
1366
|
+
} else if (mode === "upstream") {
|
|
1367
|
+
if (!sameRemote) {
|
|
1368
|
+
throw new InvalidArgumentError(
|
|
1369
|
+
"refspecs",
|
|
1370
|
+
undefined,
|
|
1371
|
+
`You are pushing to remote '${this.remote}', which is not the upstream of\n` +
|
|
1372
|
+
`your current branch '${branch}', without telling me what to push\n` +
|
|
1373
|
+
"to update which remote branch.",
|
|
1374
|
+
);
|
|
1375
|
+
}
|
|
1376
|
+
dst = upstreamRef();
|
|
1377
|
+
} else if (sameRemote) {
|
|
1378
|
+
// simple, unspecified (and anything git does not know)
|
|
1379
|
+
const upstream = upstreamRef();
|
|
1380
|
+
if (upstream !== ref) throw this.simpleRefusal(upstream, mode === undefined);
|
|
790
1381
|
}
|
|
791
|
-
|
|
1382
|
+
if (autoUpstream && merges.length === 0) defaults.setUpstream = true;
|
|
1383
|
+
return [`${ref}:${dst}`];
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
/** builtin/push.c's `die_push_simple`: an upstream of another name than the branch. */
|
|
1387
|
+
private simpleRefusal(upstream: string, unspecified: boolean): InvalidArgumentError {
|
|
1388
|
+
const short = upstream.startsWith("refs/heads/")
|
|
1389
|
+
? upstream.slice("refs/heads/".length)
|
|
1390
|
+
: upstream;
|
|
1391
|
+
const autoSetupMerge = RemoteConfigStore.from(this._workingCopy).value("branch.autoSetupMerge");
|
|
1392
|
+
return new InvalidArgumentError(
|
|
1393
|
+
"refspecs",
|
|
1394
|
+
undefined,
|
|
1395
|
+
"The upstream branch of your current branch does not match\n" +
|
|
1396
|
+
"the name of your current branch. To push to the upstream branch\n" +
|
|
1397
|
+
"on the remote, use\n\n" +
|
|
1398
|
+
` git push ${this.remote} HEAD:${short}\n\n` +
|
|
1399
|
+
"To push to the branch of the same name on the remote, use\n\n" +
|
|
1400
|
+
` git push ${this.remote} HEAD\n` +
|
|
1401
|
+
(unspecified
|
|
1402
|
+
? "\nTo choose either option permanently, see push.default in 'git help config'.\n"
|
|
1403
|
+
: "") +
|
|
1404
|
+
(autoSetupMerge !== "simple"
|
|
1405
|
+
? "\nTo avoid automatically configuring an upstream branch when its name\n" +
|
|
1406
|
+
"won't match the local branch, see option 'simple' of branch.autoSetupMerge\n" +
|
|
1407
|
+
"in 'git help config'.\n"
|
|
1408
|
+
: ""),
|
|
1409
|
+
);
|
|
792
1410
|
}
|
|
793
1411
|
|
|
794
1412
|
/**
|
|
795
1413
|
* The remote-tracking ref of a remote ref (`refs/heads/main` → `refs/remotes/origin/main`)
|
|
796
|
-
* through the named remote's fetch refspecs;
|
|
1414
|
+
* through the named remote's fetch refspecs; for a URL, none (2.5x: those of the one remote
|
|
1415
|
+
* pushing to that URL).
|
|
797
1416
|
*/
|
|
798
|
-
private trackingRefMapper(
|
|
1417
|
+
private trackingRefMapper(
|
|
1418
|
+
remoteUrl: string,
|
|
1419
|
+
compatibility: "2.43" | "2.56",
|
|
1420
|
+
): (remoteRef: string) => string | undefined {
|
|
799
1421
|
const store = RemoteConfigStore.from(this.workingCopy);
|
|
800
|
-
|
|
1422
|
+
let tracking = this.remote;
|
|
1423
|
+
if (!store.isConfigured(this.remote)) {
|
|
1424
|
+
// 2.5x's remote_for_push_tracking: a URL that is the push URL of exactly one configured
|
|
1425
|
+
// remote updates that remote's tracking refs
|
|
1426
|
+
if (compatibility === "2.43") return () => undefined;
|
|
1427
|
+
const matches = store
|
|
1428
|
+
.configuredNames()
|
|
1429
|
+
.filter((name) => store.remotePushUrls(name).includes(remoteUrl));
|
|
1430
|
+
if (matches.length !== 1) return () => undefined;
|
|
1431
|
+
tracking = matches[0] as string;
|
|
1432
|
+
}
|
|
801
1433
|
const specs = store
|
|
802
|
-
.read(
|
|
1434
|
+
.read(tracking)
|
|
803
1435
|
.fetchRefspecs.map((spec) => parseRefSpec(spec))
|
|
804
1436
|
.filter((spec) => !spec.negative && spec.source && spec.destination);
|
|
805
1437
|
return (remoteRef) => {
|