@statewalker/vcs-commands 0.7.0 → 0.9.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 +70 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/add-patch.d.ts +7 -0
- package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +102 -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 +2 -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 +7 -0
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/apply/index.d.ts +1 -1
- package/dist/commands/apply/index.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/blame-command.d.ts +303 -8
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/blame-ignore.d.ts +48 -0
- package/dist/commands/blame-ignore.d.ts.map +1 -0
- 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/check-mailmap-command.d.ts +49 -0
- package/dist/commands/check-mailmap-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +26 -3
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-paths.d.ts +4 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-command.d.ts +61 -0
- package/dist/commands/cherry-command.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +82 -1
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +44 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +56 -0
- package/dist/commands/clean-interactive.d.ts.map +1 -0
- package/dist/commands/clone-command.d.ts +116 -2
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +239 -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/describe-command.d.ts +71 -64
- package/dist/commands/describe-command.d.ts.map +1 -1
- package/dist/commands/diff-color-config.d.ts +73 -0
- package/dist/commands/diff-color-config.d.ts.map +1 -0
- package/dist/commands/diff-command.d.ts +369 -10
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +80 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fetch-multiple-command.d.ts +193 -0
- package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
- 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 +69 -3
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/fsck/fetch-fsck.d.ts +51 -0
- package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -1
- package/dist/commands/gc-command.d.ts +8 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +81 -4
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +50 -1
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/grep/grep-command.d.ts +210 -0
- package/dist/commands/grep/grep-command.d.ts.map +1 -0
- package/dist/commands/grep/grep-engine.d.ts +218 -0
- package/dist/commands/grep/grep-engine.d.ts.map +1 -0
- package/dist/commands/grep/index.d.ts +3 -0
- package/dist/commands/grep/index.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +13 -2
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index.d.ts +38 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +5 -3
- package/dist/commands/init-command.d.ts +89 -0
- 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/line-log.d.ts +161 -0
- package/dist/commands/line-log.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 +527 -13
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +30 -3
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +199 -6
- 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 +53 -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 +147 -10
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-drivers.d.ts +2 -0
- package/dist/commands/merge-drivers.d.ts.map +1 -1
- package/dist/commands/merge-strategy-options.d.ts +69 -0
- package/dist/commands/merge-strategy-options.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +10 -0
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/message-cleanup.d.ts +2 -0
- package/dist/commands/message-cleanup.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-command.d.ts +65 -0
- package/dist/commands/name-rev-command.d.ts.map +1 -0
- package/dist/commands/name-rev.d.ts +136 -0
- package/dist/commands/name-rev.d.ts.map +1 -0
- package/dist/commands/notes-command.d.ts.map +1 -1
- package/dist/commands/octopus-merge.d.ts +26 -1
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/ort-merge.d.ts +16 -0
- package/dist/commands/ort-merge.d.ts.map +1 -1
- package/dist/commands/ort-recursive.d.ts.map +1 -1
- package/dist/commands/patch-id.d.ts +58 -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 +186 -32
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +225 -9
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/index.d.ts +4 -0
- package/dist/commands/range-diff/index.d.ts.map +1 -0
- package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
- package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff.d.ts +106 -0
- package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
- package/dist/commands/read-tree-command.d.ts +20 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +189 -8
- 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/remerge-diff.d.ts +59 -0
- package/dist/commands/remerge-diff.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +179 -29
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-show-command.d.ts +204 -0
- package/dist/commands/remote-show-command.d.ts.map +1 -0
- 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 +21 -4
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +9 -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 +226 -2
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +54 -1
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +34 -1
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +15 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/rm-command.d.ts +70 -2
- package/dist/commands/rm-command.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +186 -5
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +12 -1
- 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/shortlog-command.d.ts +109 -0
- package/dist/commands/shortlog-command.d.ts.map +1 -0
- package/dist/commands/shortlog.d.ts +151 -0
- package/dist/commands/shortlog.d.ts.map +1 -0
- package/dist/commands/show-command.d.ts +130 -0
- package/dist/commands/show-command.d.ts.map +1 -0
- package/dist/commands/show-commit.d.ts +11 -0
- package/dist/commands/show-commit.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +164 -0
- package/dist/commands/signature-check.d.ts.map +1 -0
- package/dist/commands/signing.d.ts +160 -0
- package/dist/commands/signing.d.ts.map +1 -0
- package/dist/commands/sparse-checkout-command.d.ts.map +1 -1
- package/dist/commands/sparse-index-view.d.ts +45 -0
- package/dist/commands/sparse-index-view.d.ts.map +1 -0
- package/dist/commands/ssh-signer.d.ts +29 -0
- package/dist/commands/ssh-signer.d.ts.map +1 -0
- package/dist/commands/ssh-verifier.d.ts +42 -0
- package/dist/commands/ssh-verifier.d.ts.map +1 -0
- package/dist/commands/stash-apply-command.d.ts +5 -0
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-branch-command.d.ts +34 -0
- package/dist/commands/stash-branch-command.d.ts.map +1 -0
- package/dist/commands/stash-create-command.d.ts +17 -0
- package/dist/commands/stash-create-command.d.ts.map +1 -1
- package/dist/commands/stash-info.d.ts +93 -0
- package/dist/commands/stash-info.d.ts.map +1 -0
- package/dist/commands/stash-list-command.d.ts +16 -0
- package/dist/commands/stash-list-command.d.ts.map +1 -1
- package/dist/commands/stash-pop-command.d.ts +39 -0
- package/dist/commands/stash-pop-command.d.ts.map +1 -0
- package/dist/commands/stash-show-command.d.ts +48 -0
- package/dist/commands/stash-show-command.d.ts.map +1 -0
- package/dist/commands/stash-store-command.d.ts +29 -0
- package/dist/commands/stash-store-command.d.ts.map +1 -0
- package/dist/commands/stash-working-tree.d.ts.map +1 -1
- package/dist/commands/status-command.d.ts +31 -2
- 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 +463 -0
- package/dist/commands/submodule-commands.d.ts.map +1 -0
- package/dist/commands/submodule-fetch.d.ts +149 -0
- package/dist/commands/submodule-fetch.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +296 -0
- package/dist/commands/submodule-model.d.ts.map +1 -0
- package/dist/commands/submodule-unpack.d.ts +120 -0
- package/dist/commands/submodule-unpack.d.ts.map +1 -0
- package/dist/commands/submodule-update-command.d.ts +206 -0
- package/dist/commands/submodule-update-command.d.ts.map +1 -0
- package/dist/commands/subtree-shift.d.ts +27 -0
- package/dist/commands/subtree-shift.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts +3 -0
- package/dist/commands/switch-command.d.ts.map +1 -1
- package/dist/commands/tag-command.d.ts +259 -10
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/trailers.d.ts +218 -17
- package/dist/commands/trailers.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts +7 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/verify-command.d.ts +92 -0
- package/dist/commands/verify-command.d.ts.map +1 -0
- package/dist/commands/worktree-add-command.d.ts +79 -7
- package/dist/commands/worktree-add-command.d.ts.map +1 -1
- package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/commands/worktree-path-rules.d.ts +66 -0
- package/dist/commands/worktree-path-rules.d.ts.map +1 -0
- package/dist/commands/worktree-remove-command.d.ts +10 -3
- package/dist/commands/worktree-remove-command.d.ts.map +1 -1
- package/dist/commands/worktree-repair-command.d.ts +15 -2
- package/dist/commands/worktree-repair-command.d.ts.map +1 -1
- package/dist/commands/worktree-support.d.ts +5 -0
- package/dist/commands/worktree-support.d.ts.map +1 -1
- package/dist/{commands-DIJ91NnD.js → commands-CNvli5bl.js} +49442 -54941
- 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 +25 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +85 -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/fsck-CPeDh9fh.js +5138 -0
- package/dist/git-command.d.ts +58 -2
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +363 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +82 -0
- package/dist/guarded-transport-command.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/remote-config/index.d.ts +1 -1
- package/dist/remote-config/index.d.ts.map +1 -1
- package/dist/remote-config/remote-config-store.d.ts +55 -0
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/remote-transport-CCmBadm-.js +1606 -0
- package/dist/rename/detect-renames.d.ts +20 -0
- package/dist/rename/detect-renames.d.ts.map +1 -1
- package/dist/rename/diffcore-break.d.ts +51 -0
- package/dist/rename/diffcore-break.d.ts.map +1 -0
- package/dist/rename/index.d.ts +1 -0
- package/dist/rename/index.d.ts.map +1 -1
- package/dist/results/blame-format.d.ts +62 -1
- package/dist/results/blame-format.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +9 -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-dirstat.d.ts +36 -0
- package/dist/results/diff-dirstat.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +10 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +103 -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/fetch-result.d.ts +12 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +6 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/init-result.d.ts +8 -1
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/line-range-hunks.d.ts +27 -0
- package/dist/results/line-range-hunks.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +8 -1
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +11 -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 +1 -1
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-BDuEgdLU.js +46847 -0
- package/dist/transport-command.d.ts +14 -0
- package/dist/transport-command.d.ts.map +1 -1
- 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 +293 -17
- package/src/commands/add-patch/add-patch.ts +8 -0
- package/src/commands/add-patch/patch-backend.ts +20 -2
- package/src/commands/am/am-command.ts +400 -46
- package/src/commands/am/index.ts +1 -0
- package/src/commands/am/mailsplit.ts +326 -0
- package/src/commands/apply/apply-command.ts +58 -15
- package/src/commands/apply/apply-engine.ts +1 -1
- package/src/commands/apply/apply-parse.ts +17 -8
- package/src/commands/apply/index.ts +8 -1
- package/src/commands/bisect/bisect-command.ts +18 -5
- package/src/commands/blame-command.ts +1450 -51
- package/src/commands/blame-ignore.ts +307 -0
- 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/check-mailmap-command.ts +129 -0
- package/src/commands/checkout-command.ts +166 -55
- package/src/commands/checkout-paths.ts +28 -0
- package/src/commands/cherry-command.ts +187 -0
- package/src/commands/cherry-pick-command.ts +185 -1
- package/src/commands/clean-command.ts +126 -15
- package/src/commands/clean-interactive.ts +522 -0
- package/src/commands/clone-command.ts +598 -45
- package/src/commands/commit-command.ts +925 -74
- package/src/commands/commit-reuse.ts +94 -0
- package/src/commands/config-command.ts +1256 -0
- package/src/commands/config-value-types.ts +358 -0
- package/src/commands/core-config.ts +40 -0
- package/src/commands/describe-command.ts +341 -254
- package/src/commands/diff-color-config.ts +274 -0
- package/src/commands/diff-command.ts +1619 -99
- package/src/commands/fetch-command.ts +495 -14
- package/src/commands/fetch-multiple-command.ts +665 -0
- 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 +496 -116
- package/src/commands/fsck/fetch-fsck.ts +172 -18
- package/src/commands/gc-command.ts +31 -1
- package/src/commands/git-describe.ts +460 -201
- package/src/commands/git-hooks.ts +123 -3
- package/src/commands/grep/grep-command.ts +1077 -0
- package/src/commands/grep/grep-engine.ts +1024 -0
- package/src/commands/grep/index.ts +2 -0
- package/src/commands/index-adder.ts +46 -7
- package/src/commands/index.ts +43 -0
- package/src/commands/init-command.ts +603 -49
- package/src/commands/interpret-trailers-command.ts +256 -0
- package/src/commands/line-log.ts +931 -0
- package/src/commands/local-transport.ts +109 -10
- package/src/commands/log-command.ts +2599 -326
- package/src/commands/log-graph.ts +129 -29
- package/src/commands/log-output.ts +449 -27
- package/src/commands/ls-remote-command.ts +5 -0
- package/src/commands/mailmap.ts +155 -0
- package/src/commands/merge-base-command.ts +170 -0
- package/src/commands/merge-bases.ts +63 -8
- package/src/commands/merge-command.ts +601 -95
- package/src/commands/merge-drivers.ts +3 -0
- package/src/commands/merge-strategy-options.ts +224 -0
- package/src/commands/merge-support.ts +115 -22
- package/src/commands/message-cleanup.ts +1 -1
- package/src/commands/mv-command.ts +6 -3
- package/src/commands/name-rev-command.ts +184 -0
- package/src/commands/name-rev.ts +762 -0
- package/src/commands/notes-command.ts +11 -1
- package/src/commands/octopus-merge.ts +35 -11
- package/src/commands/ort-merge.ts +41 -7
- package/src/commands/ort-recursive.ts +40 -2
- package/src/commands/patch-id.ts +109 -0
- package/src/commands/pathspec-file.ts +72 -0
- package/src/commands/pathspec.ts +14 -2
- package/src/commands/pretty-format.ts +103 -19
- package/src/commands/promisor-remote.ts +10 -1
- package/src/commands/pull-command.ts +734 -221
- package/src/commands/push-command.ts +1035 -68
- package/src/commands/range-diff/index.ts +3 -0
- package/src/commands/range-diff/linear-assignment.ts +203 -0
- package/src/commands/range-diff/range-diff-command.ts +433 -0
- package/src/commands/range-diff/range-diff.ts +617 -0
- package/src/commands/read-tree-command.ts +102 -4
- package/src/commands/rebase-command.ts +1074 -194
- 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/remerge-diff.ts +241 -0
- package/src/commands/remote-command.ts +537 -69
- package/src/commands/remote-show-command.ts +836 -0
- package/src/commands/remote-transport.ts +9 -1
- package/src/commands/reset-command.ts +114 -34
- package/src/commands/restore-command.ts +27 -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 +578 -15
- package/src/commands/revert-command.ts +123 -1
- package/src/commands/revision-range.ts +207 -5
- package/src/commands/revision-resolver.ts +23 -8
- package/src/commands/rm-command.ts +282 -21
- package/src/commands/sequencer-pick.ts +818 -111
- package/src/commands/sequencer-support.ts +184 -4
- package/src/commands/serve-repository.ts +18 -3
- package/src/commands/shortlog-command.ts +354 -0
- package/src/commands/shortlog.ts +361 -0
- package/src/commands/show-command.ts +491 -0
- package/src/commands/show-commit.ts +24 -0
- package/src/commands/signature-check.ts +657 -0
- package/src/commands/signing.ts +385 -0
- package/src/commands/sparse-checkout-command.ts +2 -9
- package/src/commands/sparse-checkout-support.ts +2 -2
- package/src/commands/sparse-index-view.ts +135 -0
- package/src/commands/ssh-signer.ts +199 -0
- package/src/commands/ssh-verifier.ts +523 -0
- package/src/commands/stash-apply-command.ts +16 -4
- package/src/commands/stash-branch-command.ts +88 -0
- package/src/commands/stash-create-command.ts +28 -0
- package/src/commands/stash-info.ts +243 -0
- package/src/commands/stash-list-command.ts +33 -0
- package/src/commands/stash-pop-command.ts +83 -0
- package/src/commands/stash-show-command.ts +141 -0
- package/src/commands/stash-store-command.ts +82 -0
- package/src/commands/stash-working-tree.ts +2 -2
- package/src/commands/status-command.ts +120 -27
- package/src/commands/status-format.ts +1 -1
- package/src/commands/status-header.ts +41 -7
- package/src/commands/submodule-add-command.ts +509 -0
- package/src/commands/submodule-auth.ts +276 -0
- package/src/commands/submodule-commands.ts +1835 -0
- package/src/commands/submodule-fetch.ts +789 -0
- package/src/commands/submodule-model.ts +938 -0
- package/src/commands/submodule-unpack.ts +265 -0
- package/src/commands/submodule-update-command.ts +1126 -0
- package/src/commands/subtree-shift.ts +215 -0
- package/src/commands/switch-command.ts +12 -1
- package/src/commands/tag-command.ts +876 -64
- package/src/commands/trailers.ts +837 -100
- package/src/commands/tree-restore.ts +44 -11
- package/src/commands/verify-command.ts +235 -0
- package/src/commands/worktree-add-command.ts +268 -24
- package/src/commands/worktree-overwrite-checks.ts +5 -0
- package/src/commands/worktree-path-rules.ts +183 -0
- package/src/commands/worktree-remove-command.ts +39 -5
- package/src/commands/worktree-repair-command.ts +52 -5
- package/src/commands/worktree-support.ts +22 -1
- package/src/errors/checkout-errors.ts +29 -0
- package/src/errors/command-errors.ts +37 -1
- package/src/errors/ref-errors.ts +23 -0
- package/src/errors/worktree-errors.ts +8 -1
- package/src/git-command.ts +153 -2
- package/src/git.ts +550 -1
- package/src/guarded-transport-command.ts +171 -0
- package/src/index.ts +1 -0
- package/src/remote-config/index.ts +2 -0
- package/src/remote-config/remote-config-store.ts +101 -0
- package/src/rename/detect-renames.ts +42 -8
- package/src/rename/diffcore-break.ts +166 -0
- package/src/rename/index.ts +1 -0
- package/src/results/blame-format.ts +268 -43
- package/src/results/clone-result.ts +6 -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-dirstat.ts +117 -0
- package/src/results/diff-entry.ts +12 -0
- package/src/results/diff-formatter.ts +1 -0
- package/src/results/diff-output.ts +322 -32
- package/src/results/diff-pickaxe.ts +304 -0
- package/src/results/diff-words.ts +395 -0
- package/src/results/fetch-result.ts +12 -1
- package/src/results/index.ts +6 -0
- package/src/results/init-result.ts +10 -1
- package/src/results/line-range-hunks.ts +126 -0
- package/src/results/merge-result.ts +9 -0
- package/src/results/pull-result.ts +7 -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 +2 -2
- package/src/transport-command.ts +34 -3
- 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
- package/dist/git-command-BGiOJ8Zk.js +0 -7246
- package/dist/results-WVlBhVb1.js +0 -2935
|
@@ -7,8 +7,10 @@ import {
|
|
|
7
7
|
canonTreeMode,
|
|
8
8
|
commitFromBytes,
|
|
9
9
|
type GitObject,
|
|
10
|
+
isSymbolicRef,
|
|
10
11
|
type ObjectId,
|
|
11
12
|
type ObjectReplacements,
|
|
13
|
+
type PersonIdent,
|
|
12
14
|
parseGraphCommit,
|
|
13
15
|
replacementOf,
|
|
14
16
|
} from "@statewalker/vcs-core";
|
|
@@ -16,27 +18,61 @@ import { ByteSink, OrderedMap, parseGitBool, type XdiffAlgorithm } from "@statew
|
|
|
16
18
|
import { decodeGitPath, encodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
17
19
|
import { bytesToHex, hexToBytes } from "@statewalker/vcs-utils/hash/utils";
|
|
18
20
|
|
|
19
|
-
import {
|
|
20
|
-
type AttributesResolver,
|
|
21
|
-
type ContentAttributesContext,
|
|
22
|
-
expandUserPath,
|
|
23
|
-
} from "@statewalker/vcs-working-tree";
|
|
21
|
+
import type { AttributesResolver, ContentAttributesContext } from "@statewalker/vcs-working-tree";
|
|
24
22
|
|
|
25
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
GitApiError,
|
|
25
|
+
IncompatibleOptionsError,
|
|
26
|
+
InvalidArgumentError,
|
|
27
|
+
InvalidConfigError,
|
|
28
|
+
NotImplementedError,
|
|
29
|
+
} from "../errors/index.js";
|
|
26
30
|
import { GitCommand } from "../git-command.js";
|
|
27
31
|
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
32
|
+
import {
|
|
33
|
+
DEFAULT_RENAME_LIMIT,
|
|
34
|
+
detectRenames,
|
|
35
|
+
renameScoreOption,
|
|
36
|
+
scorePercent,
|
|
37
|
+
} from "../rename/index.js";
|
|
28
38
|
import { type CombinedDiffOptions, writeCombinedDiff } from "../results/combined-diff.js";
|
|
39
|
+
import type { DiffColors } from "../results/diff-color.js";
|
|
40
|
+
import type { DiffEntry } from "../results/diff-entry.js";
|
|
41
|
+
import { DiffPickaxe } from "../results/diff-pickaxe.js";
|
|
29
42
|
import { quotePath } from "../results/quote-path.js";
|
|
30
43
|
import { bareAttributesResolver } from "./attributes-source.js";
|
|
31
|
-
import {
|
|
44
|
+
import { parseGitColor } from "./config-value-types.js";
|
|
45
|
+
import {
|
|
46
|
+
DEFAULT_DECORATION_COLORS,
|
|
47
|
+
type DiffColorSettings,
|
|
48
|
+
readDiffColorSettings,
|
|
49
|
+
} from "./diff-color-config.js";
|
|
50
|
+
import {
|
|
51
|
+
checkPickaxeOptions,
|
|
52
|
+
DiffCommand,
|
|
53
|
+
type DiffOutputFormat,
|
|
54
|
+
type DiffTextOptions,
|
|
55
|
+
hasPickaxe,
|
|
56
|
+
renamesValue,
|
|
57
|
+
} from "./diff-command.js";
|
|
32
58
|
import { hostEnvironmentOf } from "./git-ident.js";
|
|
59
|
+
import {
|
|
60
|
+
gitlinkText,
|
|
61
|
+
type LineLogHost,
|
|
62
|
+
type LineLogPair,
|
|
63
|
+
LineLogWalk,
|
|
64
|
+
lineLogEntry,
|
|
65
|
+
parseLineRanges,
|
|
66
|
+
} from "./line-log.js";
|
|
67
|
+
import { GRAPH_COLUMN_COLORS_ANSI, graphColumnColors } from "./log-graph.js";
|
|
33
68
|
import {
|
|
34
69
|
type LogOutputEntry,
|
|
35
70
|
type LogOutputHost,
|
|
36
71
|
type LogOutputOptions,
|
|
37
72
|
LogPrinter,
|
|
73
|
+
type LogReflogEntry,
|
|
38
74
|
} from "./log-output.js";
|
|
39
|
-
import { Mailmap } from "./mailmap.js";
|
|
75
|
+
import type { Mailmap } from "./mailmap.js";
|
|
40
76
|
import { configBool, configValue } from "./merge-config.js";
|
|
41
77
|
import {
|
|
42
78
|
addRefsByGlob,
|
|
@@ -49,6 +85,7 @@ import {
|
|
|
49
85
|
} from "./notes-support.js";
|
|
50
86
|
import { combineNotesIgnore } from "./notes-tree.js";
|
|
51
87
|
import { canonicalObjectId } from "./object-id-input.js";
|
|
88
|
+
import { PatchIds } from "./patch-id.js";
|
|
52
89
|
import {
|
|
53
90
|
ALL_ENTRIES_NOT_INTERESTING,
|
|
54
91
|
bloomPathOf,
|
|
@@ -64,8 +101,30 @@ import {
|
|
|
64
101
|
treePathspec,
|
|
65
102
|
} from "./pathspec.js";
|
|
66
103
|
import { PathspecAttributes } from "./pathspec-attributes.js";
|
|
67
|
-
import {
|
|
104
|
+
import {
|
|
105
|
+
type DecorationPalette,
|
|
106
|
+
type LoadRefDecorationsOptions,
|
|
107
|
+
loadRefDecorations,
|
|
108
|
+
type RefDecorations,
|
|
109
|
+
} from "./pretty-format.js";
|
|
110
|
+
import { openReflogWalk, walkReflogs } from "./reflog-walk.js";
|
|
111
|
+
import { RemergeTreeCommand, remergeObjectsView } from "./remerge-diff.js";
|
|
112
|
+
import {
|
|
113
|
+
type CommitFilter,
|
|
114
|
+
CommitFilters,
|
|
115
|
+
type FilteredCommit,
|
|
116
|
+
type GrepPatternType,
|
|
117
|
+
} from "./rev-filter/index.js";
|
|
118
|
+
import {
|
|
119
|
+
checkSignature,
|
|
120
|
+
mergetagsOf,
|
|
121
|
+
parseBufferSignedByHeader,
|
|
122
|
+
parseSignature,
|
|
123
|
+
type SignatureCheck,
|
|
124
|
+
verifyCommitBytes,
|
|
125
|
+
} from "./signature-check.js";
|
|
68
126
|
import { readDiffSubmoduleConfig } from "./submodule-summary.js";
|
|
127
|
+
import { shortenUnambiguousRef } from "./worktree-list-command.js";
|
|
69
128
|
|
|
70
129
|
/** What {@link LogCommand.callBytes} asks of the walk. */
|
|
71
130
|
interface OutputWalk {
|
|
@@ -81,6 +140,49 @@ interface OutputWalk {
|
|
|
81
140
|
unwalkedShown?: Set<ObjectId>;
|
|
82
141
|
}
|
|
83
142
|
|
|
143
|
+
/** A commit given to the walk: excluded or not, and the name it was given by. */
|
|
144
|
+
interface PendingCommit {
|
|
145
|
+
id: ObjectId;
|
|
146
|
+
exclude: boolean;
|
|
147
|
+
name?: string;
|
|
148
|
+
/** The left side of a symmetric difference (`a` of `a...b`, git's SYMMETRIC_LEFT) */
|
|
149
|
+
left?: boolean;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** A commit of the walk as the log printer takes it. */
|
|
153
|
+
function outputEntry(c: LogResult): LogOutputEntry {
|
|
154
|
+
const { id, boundary, source, left, patchSame, reflog: _reflog, savedParents, ...commit } = c;
|
|
155
|
+
return {
|
|
156
|
+
id,
|
|
157
|
+
commit,
|
|
158
|
+
parents: c.parents,
|
|
159
|
+
...(savedParents ? { savedParents } : {}),
|
|
160
|
+
...(boundary ? { boundary: true } : {}),
|
|
161
|
+
...(source !== undefined ? { source } : {}),
|
|
162
|
+
...(left ? { left: true } : {}),
|
|
163
|
+
...(patchSame ? { patchSame: true } : {}),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** git's get_revision under `--reverse`: every commit read first, then given oldest first. */
|
|
168
|
+
async function* reversed<T>(source: AsyncIterable<T>): AsyncIterable<T> {
|
|
169
|
+
const all: T[] = [];
|
|
170
|
+
for await (const item of source) all.push(item);
|
|
171
|
+
for (let i = all.length - 1; i >= 0; i--) yield all[i] as T;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** A commit's parents as the walk holds them, by id */
|
|
175
|
+
function lineLogParentIds(t: RevTable, n: number): ObjectId[] {
|
|
176
|
+
const ids: ObjectId[] = [];
|
|
177
|
+
for (let k = 0, c = t.parentCount(n); k < c; k++) ids.push(t.idOf(t.parent(n, k)));
|
|
178
|
+
return ids;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** A death of `git log -L` (`die()`: `fatal:`, exit 128) */
|
|
182
|
+
function lineLogDeath(message: string): GitApiError {
|
|
183
|
+
return new GitApiError(`fatal: ${message}`).withExitCode(128);
|
|
184
|
+
}
|
|
185
|
+
|
|
84
186
|
/** git log reads no index: the in-tree attributes files are the worktree's only. */
|
|
85
187
|
const NO_INDEX = { attributesBlob: () => undefined };
|
|
86
188
|
|
|
@@ -92,8 +194,65 @@ const NO_INDEX = { attributesBlob: () => undefined };
|
|
|
92
194
|
export interface LogResult extends Commit {
|
|
93
195
|
/** The SHA-1 object ID of the commit */
|
|
94
196
|
id: ObjectId;
|
|
197
|
+
/**
|
|
198
|
+
* A boundary commit ({@link LogCommand.setBoundary}): a parent of a commit listed that is
|
|
199
|
+
* not listed itself, given after the others (git's `BOUNDARY`, the `-` mark)
|
|
200
|
+
*/
|
|
201
|
+
boundary?: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* On the left side of a symmetric difference (`a` of `a...b`, reached from it only): git's
|
|
204
|
+
* SYMMETRIC_LEFT, the `<` mark of {@link LogCommand.setLeftRight} (`>` otherwise)
|
|
205
|
+
*/
|
|
206
|
+
left?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* {@link LogCommand.setCherryMark}: the other side of the symmetric difference has a commit
|
|
209
|
+
* with the same patch-id (git's PATCHSAME, the `=` mark)
|
|
210
|
+
*/
|
|
211
|
+
patchSame?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* The name the commit was reached from ({@link LogCommand.setSource}, git's `--source`):
|
|
214
|
+
* the revision as given, or the ref `--all`, `--branches`... named
|
|
215
|
+
*/
|
|
216
|
+
source?: string;
|
|
217
|
+
/** In a reflog walk ({@link LogCommand.addReflogWalk}), the entry the commit is listed for */
|
|
218
|
+
reflog?: LogReflogEntry;
|
|
219
|
+
/**
|
|
220
|
+
* The parents before {@link LogCommand.setParents} rewrote `parents` (git's saved parents,
|
|
221
|
+
* which `--full-diff` diffs against)
|
|
222
|
+
*/
|
|
223
|
+
savedParents?: ObjectId[];
|
|
95
224
|
}
|
|
96
225
|
|
|
226
|
+
/**
|
|
227
|
+
* What `git show` prints through one log printer (see {@link LogCommand.showSession}).
|
|
228
|
+
*
|
|
229
|
+
* @internal
|
|
230
|
+
*/
|
|
231
|
+
export interface ShowSession {
|
|
232
|
+
/** Shows a commit as git show does; false when it was not shown (already, or TREESAME) */
|
|
233
|
+
commit(id: ObjectId): Promise<boolean>;
|
|
234
|
+
/** The newline before a tag or tree once something was shown */
|
|
235
|
+
separate(): void;
|
|
236
|
+
/** Marks something shown (a tag's or tree's header) */
|
|
237
|
+
markShown(): void;
|
|
238
|
+
text(text: string): void;
|
|
239
|
+
bytes(bytes: Uint8Array): void;
|
|
240
|
+
/** A tag's `tagger` line as `Tagger:` (and its date) in the format */
|
|
241
|
+
tagger(ident: PersonIdent): void;
|
|
242
|
+
/** Everything printed */
|
|
243
|
+
result(): Uint8Array;
|
|
244
|
+
/** The `color.diff.commit` color and its reset of a tag's or tree's header ("" without color) */
|
|
245
|
+
readonly commitColor: { set: string; reset: string };
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* The order of the commits listed: git's `--topo-order` (`topo`: no parent before all its
|
|
250
|
+
* children, a line of history kept together), `--date-order` (`date`: no parent before its
|
|
251
|
+
* children, else newest commit date first), `--author-date-order` (`author-date`: as `date`
|
|
252
|
+
* by author date).
|
|
253
|
+
*/
|
|
254
|
+
export type LogOrder = "topo" | "date" | "author-date";
|
|
255
|
+
|
|
97
256
|
/**
|
|
98
257
|
* What a path-limited walk did (git's trace2 `bloom` statistics, and the tree work behind
|
|
99
258
|
* them): how often the changed-path filters answered, and how many tree entries the walk read
|
|
@@ -189,7 +348,7 @@ export enum RevFilter {
|
|
|
189
348
|
export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
190
349
|
private startCommits: ObjectId[] = [];
|
|
191
350
|
/** The commits given, included and excluded, in the order given (git's pending list) */
|
|
192
|
-
private readonly pending:
|
|
351
|
+
private readonly pending: PendingCommit[] = [];
|
|
193
352
|
private paths: string[] = [];
|
|
194
353
|
private excludePaths: string[] = [];
|
|
195
354
|
private maxCount?: number;
|
|
@@ -205,6 +364,21 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
205
364
|
private authorPattern?: string;
|
|
206
365
|
private committerPattern?: string;
|
|
207
366
|
private revFilter = RevFilter.ALL;
|
|
367
|
+
/** `--grep` patterns */
|
|
368
|
+
private readonly grepMessages: string[] = [];
|
|
369
|
+
/** `--author` patterns */
|
|
370
|
+
private readonly grepAuthors: string[] = [];
|
|
371
|
+
/** `--committer` patterns */
|
|
372
|
+
private readonly grepCommitters: string[] = [];
|
|
373
|
+
private allMatch = false;
|
|
374
|
+
private invertGrep = false;
|
|
375
|
+
private regexpIgnoreCase = false;
|
|
376
|
+
private patternType?: GrepPatternType;
|
|
377
|
+
private useMailmap?: boolean;
|
|
378
|
+
private logConfig = true;
|
|
379
|
+
private readonly commitFilters: CommitFilter[] = [];
|
|
380
|
+
/** The filter of the walk under way (git's options and the added filters) */
|
|
381
|
+
private activeFilter?: CommitFilter;
|
|
208
382
|
private useBloomFilters = true;
|
|
209
383
|
private readonly statistics: LogPathStatistics = {
|
|
210
384
|
bloomDefinitelyNot: 0,
|
|
@@ -218,6 +392,293 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
218
392
|
private lastWalk: RevTable | undefined;
|
|
219
393
|
/** Set while {@link callBytes} collects the walk for its output */
|
|
220
394
|
private outputWalk: OutputWalk | undefined;
|
|
395
|
+
/** `-g <ref>...`: the reflogs walked instead of the history (names as given) */
|
|
396
|
+
private reflogWalkNames?: string[];
|
|
397
|
+
/** `--grep-reflog` patterns */
|
|
398
|
+
private readonly grepReflogs: string[] = [];
|
|
399
|
+
/** The git version whose behaviour differs where versions differ */
|
|
400
|
+
private compatibility: "2.43" | "2.56" = "2.56";
|
|
401
|
+
/** `-L` arguments, as given */
|
|
402
|
+
private readonly lineRangeArgs: string[] = [];
|
|
403
|
+
/** The ranges `-L` follows through the walk under way */
|
|
404
|
+
private lineLog?: LineLogWalk;
|
|
405
|
+
/** `--topo-order`, `--date-order`, `--author-date-order` */
|
|
406
|
+
private order?: LogOrder;
|
|
407
|
+
/** `--reverse` */
|
|
408
|
+
private reverse = false;
|
|
409
|
+
/** `--boundary` */
|
|
410
|
+
private boundary = false;
|
|
411
|
+
/** `--source` */
|
|
412
|
+
private source = false;
|
|
413
|
+
/** `--left-right` */
|
|
414
|
+
private leftRight = false;
|
|
415
|
+
/** `--left-only` */
|
|
416
|
+
private leftOnly = false;
|
|
417
|
+
/** `--right-only` (and `--cherry`) */
|
|
418
|
+
private rightOnly = false;
|
|
419
|
+
/** `--cherry-pick` */
|
|
420
|
+
private cherryPick = false;
|
|
421
|
+
/** `--cherry-mark` (and `--cherry`) */
|
|
422
|
+
private cherryMark = false;
|
|
423
|
+
/** `--cherry`: no merges (git's max_parents 1) */
|
|
424
|
+
private cherry = false;
|
|
425
|
+
/** `--simplify-merges` (and `--simplify-by-decoration`) */
|
|
426
|
+
private simplifyMerges = false;
|
|
427
|
+
/** `--simplify-by-decoration` */
|
|
428
|
+
private simplifyByDecoration = false;
|
|
429
|
+
/** git's `dense`: `--dense` (the default), off with `--sparse` */
|
|
430
|
+
private dense = true;
|
|
431
|
+
/** `--show-pulls` */
|
|
432
|
+
private showPulls = false;
|
|
433
|
+
/** `--parents` (git's `rewrite_parents` by itself) */
|
|
434
|
+
private rewriteParents = false;
|
|
435
|
+
/** `--ancestry-path` without a commit: the bottom commits are the ones */
|
|
436
|
+
private ancestryPathImplicit = false;
|
|
437
|
+
/** `--ancestry-path=<commit>`: the commits given */
|
|
438
|
+
private readonly ancestryPathCommits: ObjectId[] = [];
|
|
439
|
+
/**
|
|
440
|
+
* Commits a revision reaches through an annotated tag `--ancestry-path=<tag>` names: the
|
|
441
|
+
* tag's ANCESTRY_PATH passes to them (handle_commit's `object->flags |= flags`)
|
|
442
|
+
*/
|
|
443
|
+
private readonly ancestryPathPeeled: ObjectId[] = [];
|
|
444
|
+
/** `git log --reverse` collects the walk itself: shown commits keep their parents */
|
|
445
|
+
private keepShownParents = false;
|
|
446
|
+
/** Loads the decorations `--simplify-by-decoration` keeps (the log's filter), when set */
|
|
447
|
+
private decorationLoader?: () => Promise<RefDecorations>;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* The order of the commits ({@link LogOrder}); undefined is git's default, newest commit
|
|
451
|
+
* date first as the walk meets them. A sorted walk reads the whole history it lists
|
|
452
|
+
* before giving the first commit.
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```typescript
|
|
456
|
+
* // git rev-list --topo-order main
|
|
457
|
+
* await git.log().add(main).setOrder("topo").call();
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
460
|
+
setOrder(order: LogOrder | undefined): this {
|
|
461
|
+
this.checkCallable();
|
|
462
|
+
this.order = order;
|
|
463
|
+
return this;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* `--reverse`: the commits chosen (after `-n` and `--skip`, boundary commits included)
|
|
468
|
+
* given oldest first.
|
|
469
|
+
*/
|
|
470
|
+
setReverse(reverse: boolean): this {
|
|
471
|
+
this.checkCallable();
|
|
472
|
+
this.reverse = reverse;
|
|
473
|
+
return this;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* `--boundary`: after the commits listed, the parents of those that are not listed
|
|
478
|
+
* themselves (excluded, cut by `-n`, `--since` or a filter), each with `boundary: true`,
|
|
479
|
+
* as git's get_revision lists them (sorted as `sort_in_topological_order` sorts them).
|
|
480
|
+
*
|
|
481
|
+
* @example
|
|
482
|
+
* ```typescript
|
|
483
|
+
* // git rev-list --boundary main..topic
|
|
484
|
+
* for await (const c of await git.log().addRange(main, topic).setBoundary(true).call())
|
|
485
|
+
* console.log(`${c.boundary ? "-" : ""}${c.id}`);
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
setBoundary(boundary: boolean): this {
|
|
489
|
+
this.checkCallable();
|
|
490
|
+
this.boundary = boundary;
|
|
491
|
+
return this;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* `--source`: each commit carries the name it was reached from (`source`): the name given
|
|
496
|
+
* to {@link add}/{@link not}, the ref of {@link all}, `HEAD` for the default, passed from
|
|
497
|
+
* child to parent as the walk goes (the first name to reach a commit wins).
|
|
498
|
+
*/
|
|
499
|
+
setSource(source: boolean): this {
|
|
500
|
+
this.checkCallable();
|
|
501
|
+
this.source = source;
|
|
502
|
+
return this;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* `--left-right`: each commit is marked by the side of the symmetric difference it is
|
|
507
|
+
* reached from: `<` for the left (`a` of `a...b`, {@link add} with `left`), `>` for the
|
|
508
|
+
* right (`commit < <id>`, `< <id> <subject>` under `--oneline`, the graph's `<`/`>` in place
|
|
509
|
+
* of `*`); `left` on each {@link LogResult} says it whatever this says.
|
|
510
|
+
*
|
|
511
|
+
* @example
|
|
512
|
+
* ```typescript
|
|
513
|
+
* // git log --left-right --oneline main...topic
|
|
514
|
+
* await git.revList().addRevision("main...topic").setLeftRight(true).callLogText({ oneline: true });
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
setLeftRight(leftRight: boolean): this {
|
|
518
|
+
this.checkCallable();
|
|
519
|
+
this.leftRight = leftRight;
|
|
520
|
+
return this;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* `--left-only`: only the commits of the left side of a symmetric difference (none without
|
|
525
|
+
* one). Refused with {@link setRightOnly} or {@link setCherry}, as git refuses them.
|
|
526
|
+
*/
|
|
527
|
+
setLeftOnly(leftOnly: boolean): this {
|
|
528
|
+
this.checkCallable();
|
|
529
|
+
if (leftOnly && this.rightOnly) {
|
|
530
|
+
throw new IncompatibleOptionsError(
|
|
531
|
+
["--left-only", "--right-only/--cherry"],
|
|
532
|
+
"options '--left-only' and '--right-only/--cherry' cannot be used together",
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
this.leftOnly = leftOnly;
|
|
536
|
+
return this;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/** `--right-only`: only the commits of the right side (see {@link setLeftOnly}). */
|
|
540
|
+
setRightOnly(rightOnly: boolean): this {
|
|
541
|
+
this.checkCallable();
|
|
542
|
+
if (rightOnly && this.leftOnly) {
|
|
543
|
+
throw new IncompatibleOptionsError(
|
|
544
|
+
["--right-only", "--left-only"],
|
|
545
|
+
"options '--right-only' and '--left-only' cannot be used together",
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
this.rightOnly = rightOnly;
|
|
549
|
+
return this;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* `--cherry-pick`: commits whose change (patch-id, as `git patch-id` computes it, limited to
|
|
554
|
+
* the paths) a commit on the other side of the symmetric difference makes too are left out,
|
|
555
|
+
* on both sides. The cheap id of each diff's headers is computed for the smaller side, and
|
|
556
|
+
* full patch-ids only where those collide (revision.c's cherry_pick_list).
|
|
557
|
+
*
|
|
558
|
+
* @example
|
|
559
|
+
* ```typescript
|
|
560
|
+
* // git rev-list --left-right --cherry-pick main...topic
|
|
561
|
+
* await git.revList().addRevision("main...topic").setLeftRight(true).setCherryPick(true).callText();
|
|
562
|
+
* ```
|
|
563
|
+
*/
|
|
564
|
+
setCherryPick(cherryPick: boolean): this {
|
|
565
|
+
this.checkCallable();
|
|
566
|
+
if (cherryPick && this.cherryMark) {
|
|
567
|
+
throw new IncompatibleOptionsError(
|
|
568
|
+
["--cherry-pick", "--cherry-mark"],
|
|
569
|
+
"options '--cherry-pick' and '--cherry-mark' cannot be used together",
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
this.cherryPick = cherryPick;
|
|
573
|
+
return this;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* `--cherry-mark`: as {@link setCherryPick}, but the equivalent commits are kept and marked
|
|
578
|
+
* (`patchSame`, the `=` mark; the others `+` when nothing else marks them).
|
|
579
|
+
*/
|
|
580
|
+
setCherryMark(cherryMark: boolean): this {
|
|
581
|
+
this.checkCallable();
|
|
582
|
+
if (cherryMark && this.cherryPick) {
|
|
583
|
+
throw new IncompatibleOptionsError(
|
|
584
|
+
["--cherry-mark", "--cherry-pick"],
|
|
585
|
+
"options '--cherry-mark' and '--cherry-pick' cannot be used together",
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
this.cherryMark = cherryMark;
|
|
589
|
+
return this;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* `--cherry`: `--right-only --cherry-mark --no-merges`, the commits of the right side marked
|
|
594
|
+
* by whether the left side has their change (`git cherry` as a walk).
|
|
595
|
+
*/
|
|
596
|
+
setCherry(cherry: boolean): this {
|
|
597
|
+
this.checkCallable();
|
|
598
|
+
if (cherry && this.leftOnly) {
|
|
599
|
+
throw new IncompatibleOptionsError(
|
|
600
|
+
["--cherry", "--left-only"],
|
|
601
|
+
"options '--cherry' and '--left-only' cannot be used together",
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
this.cherry = cherry;
|
|
605
|
+
if (cherry) {
|
|
606
|
+
this.cherryMark = true;
|
|
607
|
+
this.rightOnly = true;
|
|
608
|
+
}
|
|
609
|
+
return this;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/** The revision options of the marks the output prints (get_revision_mark). */
|
|
613
|
+
private revisionMarks(): { leftRight: boolean; cherryMark: boolean } {
|
|
614
|
+
return { leftRight: this.leftRight, cherryMark: this.cherryMark };
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* `git log -g <ref>` (`--walk-reflogs`) for the printed log ({@link callText}): the
|
|
619
|
+
* commits of `ref`'s reflog, newest entry first, each shown with its entry (`Reflog:`
|
|
620
|
+
* lines, `<sel>: <message>` under `--oneline`, `%gd`/`%gD`/`%gs`/`%gn`/`%ge` in a format,
|
|
621
|
+
* `<ref>@{<date>}` under an explicit `--date`). `-n`, `--skip` and the commit filters
|
|
622
|
+
* (`--grep`, `--author`...) apply; entries whose object is no commit are passed over.
|
|
623
|
+
*/
|
|
624
|
+
setReflogWalk(ref: string): this {
|
|
625
|
+
this.checkCallable();
|
|
626
|
+
this.reflogWalkNames = [ref];
|
|
627
|
+
return this;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* One more reflog of a reflog walk (`git log -g <name>...`): `HEAD`, `main`,
|
|
632
|
+
* `refs/heads/main`, with a selector of its first entry (`main@{2}`, `HEAD@{now}`,
|
|
633
|
+
* `@{0}` for the current branch, `@{-1}`). The walk takes the newest of the logs' entries
|
|
634
|
+
* each time (reflog-walk.c), so several logs interleave by date; a name without a reflog
|
|
635
|
+
* shows nothing. {@link call} gives the commits, {@link callText} the log with each entry.
|
|
636
|
+
*
|
|
637
|
+
* @example
|
|
638
|
+
* ```typescript
|
|
639
|
+
* // git log -g --format='%gd %gs' HEAD main
|
|
640
|
+
* await git.log().addReflogWalk("HEAD").addReflogWalk("main").callText({ pretty: "format:%gd %gs" });
|
|
641
|
+
* ```
|
|
642
|
+
*/
|
|
643
|
+
addReflogWalk(name: string): this {
|
|
644
|
+
this.checkCallable();
|
|
645
|
+
this.reflogWalkNames = [...(this.reflogWalkNames ?? []), name];
|
|
646
|
+
return this;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* `-g` / `--walk-reflogs`: walk reflogs instead of history, those {@link addReflogWalk}
|
|
651
|
+
* names, HEAD's when it names none (`git log -g`).
|
|
652
|
+
*/
|
|
653
|
+
setWalkReflogs(walk: boolean): this {
|
|
654
|
+
this.checkCallable();
|
|
655
|
+
if (!walk) this.reflogWalkNames = undefined;
|
|
656
|
+
else this.reflogWalkNames ??= [];
|
|
657
|
+
return this;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* The git version to follow where versions differ (default 2.56): 2.43 refuses a reflog
|
|
662
|
+
* walk's `--reverse` before a sorted walk (`--topo-order`, `--graph`), 2.56 after; 2.43's
|
|
663
|
+
* `--left-only`/`--right-only` hide nothing in a walk nothing else limits (no excluded
|
|
664
|
+
* commit: `a...b` of unrelated histories, or no range at all).
|
|
665
|
+
*/
|
|
666
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
667
|
+
this.checkCallable();
|
|
668
|
+
this.compatibility = version;
|
|
669
|
+
return this;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* `--grep-reflog=<pattern>`: a reflog walk shows only entries whose message matches (a
|
|
674
|
+
* header pattern beside `--author`/`--committer`, combined with `--grep` as git's
|
|
675
|
+
* commit_match). Without a reflog walk the log dies, as git does.
|
|
676
|
+
*/
|
|
677
|
+
addGrepReflog(pattern: string): this {
|
|
678
|
+
this.checkCallable();
|
|
679
|
+
this.grepReflogs.push(pattern);
|
|
680
|
+
return this;
|
|
681
|
+
}
|
|
221
682
|
|
|
222
683
|
/**
|
|
223
684
|
* Add a starting commit for the log.
|
|
@@ -227,11 +688,42 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
227
688
|
* peels it; with {@link all} the refs are walked besides (`git log --all <commit>`).
|
|
228
689
|
*
|
|
229
690
|
* @param commit ObjectId of commit to start from
|
|
691
|
+
* @param name The name it was given by, which {@link setSource} reports (the id without)
|
|
692
|
+
* @param options `left`: the commit is the left side of a symmetric difference (`a` of
|
|
693
|
+
* `a...b`): it and what only it reaches are marked so ({@link setLeftRight})
|
|
230
694
|
*/
|
|
231
|
-
add(commit: ObjectId): this {
|
|
695
|
+
add(commit: ObjectId, name?: string, options: { left?: boolean } = {}): this {
|
|
232
696
|
this.checkCallable();
|
|
233
697
|
this.startCommits.push(commit);
|
|
234
|
-
this.pending.push({
|
|
698
|
+
this.pending.push({
|
|
699
|
+
id: commit,
|
|
700
|
+
exclude: false,
|
|
701
|
+
...(name !== undefined ? { name } : {}),
|
|
702
|
+
...(options.left ? { left: true } : {}),
|
|
703
|
+
});
|
|
704
|
+
return this;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* `-L <start>,<end>:<file>` / `-L :<funcname>:<file>`: follow lines of a file back through
|
|
709
|
+
* history ({@link callBytes} only). The range is given as git takes it: `<start>` and
|
|
710
|
+
* `<end>` line numbers, `+<n>`/`-<n>` offsets, `/<regex>/` (searched from the previous
|
|
711
|
+
* range of the file, or the top with `^/<regex>/`), or `:<regex>` naming a function as the
|
|
712
|
+
* path's diff driver finds them (`diff.<driver>.xfuncname`, the builtin drivers). Each
|
|
713
|
+
* commit whose change touches the lines is shown with its diff cut to them; renames are
|
|
714
|
+
* followed (`diff.renames`, `-M`). Several ranges, of one file or several, are followed
|
|
715
|
+
* together. The log starts from one commit (HEAD by default), and paths cannot be given.
|
|
716
|
+
* Errors are git's deaths (`fatal: ...`, exit 128).
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
* ```typescript
|
|
720
|
+
* // git log -L 4,12:a.c -L :main:a.c
|
|
721
|
+
* await git.log().addLineRange("4,12:a.c").addLineRange(":main:a.c").callText();
|
|
722
|
+
* ```
|
|
723
|
+
*/
|
|
724
|
+
addLineRange(range: string): this {
|
|
725
|
+
this.checkCallable();
|
|
726
|
+
this.lineRangeArgs.push(range);
|
|
235
727
|
return this;
|
|
236
728
|
}
|
|
237
729
|
|
|
@@ -315,6 +807,86 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
315
807
|
return this;
|
|
316
808
|
}
|
|
317
809
|
|
|
810
|
+
/**
|
|
811
|
+
* `--simplify-merges`: a path-limited walk keeps every parent of a merge (as
|
|
812
|
+
* {@link setFullHistory}), then removes the merges whose parents simplify to one commit and
|
|
813
|
+
* the parents another parent reaches (revision.c's simplify_merges). Commits come in
|
|
814
|
+
* topological order (`--topo-order` unless another order is set), with their parents
|
|
815
|
+
* rewritten past the commits not shown.
|
|
816
|
+
*/
|
|
817
|
+
setSimplifyMerges(simplify: boolean): this {
|
|
818
|
+
this.checkCallable();
|
|
819
|
+
this.simplifyMerges = simplify;
|
|
820
|
+
return this;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* `--simplify-by-decoration`: only commits a ref names (git's ref decorations: every ref and
|
|
825
|
+
* HEAD, or `git log`'s decoration filter in {@link callText}), commits that change the
|
|
826
|
+
* paths when paths are given, and merges tying them together; merges simplified as
|
|
827
|
+
* {@link setSimplifyMerges}.
|
|
828
|
+
*/
|
|
829
|
+
setSimplifyByDecoration(simplify: boolean): this {
|
|
830
|
+
this.checkCallable();
|
|
831
|
+
this.simplifyByDecoration = simplify;
|
|
832
|
+
return this;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* `--dense` (true, the default) / `--sparse` (false): with `--sparse` a path-limited walk
|
|
837
|
+
* shows every commit it walks, also those that change none of the paths (merges are still
|
|
838
|
+
* simplified to the parent they match).
|
|
839
|
+
*/
|
|
840
|
+
setDense(dense: boolean): this {
|
|
841
|
+
this.checkCallable();
|
|
842
|
+
this.dense = dense;
|
|
843
|
+
return this;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* `--show-pulls`: a merge that differs from its first parent at the paths but matches
|
|
848
|
+
* another parent is shown too (it "pulled" the change into the first-parent history).
|
|
849
|
+
*/
|
|
850
|
+
setShowPulls(showPulls: boolean): this {
|
|
851
|
+
this.checkCallable();
|
|
852
|
+
this.showPulls = showPulls;
|
|
853
|
+
return this;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* `--parents`: each commit's `parents` are the ones the walk shows (rewritten past the
|
|
858
|
+
* commits a path-limited walk leaves out, as git's `rewrite_parents`), and TREESAME merges
|
|
859
|
+
* of two relevant lines are kept to tie them together.
|
|
860
|
+
*/
|
|
861
|
+
setParents(parents: boolean): this {
|
|
862
|
+
this.checkCallable();
|
|
863
|
+
this.rewriteParents = parents;
|
|
864
|
+
return this;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* `--ancestry-path`: of `A..B`, only the commits that are descendants of an excluded
|
|
869
|
+
* (bottom) commit and ancestors of B. A walk without bottom commits fails (`--ancestry-path
|
|
870
|
+
* given but there are no bottom commits`). Turns history simplification off, as
|
|
871
|
+
* {@link setFullHistory}.
|
|
872
|
+
*/
|
|
873
|
+
setAncestryPath(ancestryPath: boolean): this {
|
|
874
|
+
this.checkCallable();
|
|
875
|
+
this.ancestryPathImplicit = ancestryPath;
|
|
876
|
+
return this;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* `--ancestry-path=<commit>` (repeatable): only the commits that are the commit, its
|
|
881
|
+
* ancestors or its descendants (of any commit given). A tag is peeled: its commit then
|
|
882
|
+
* keeps only its descendants, as git marks the tag object and not the commit.
|
|
883
|
+
*/
|
|
884
|
+
addAncestryPath(commit: ObjectId): this {
|
|
885
|
+
this.checkCallable();
|
|
886
|
+
this.ancestryPathCommits.push(canonicalObjectId(commit));
|
|
887
|
+
return this;
|
|
888
|
+
}
|
|
889
|
+
|
|
318
890
|
/**
|
|
319
891
|
* Follow only the first parent on merges.
|
|
320
892
|
*
|
|
@@ -333,10 +905,16 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
333
905
|
* Useful for finding commits in one branch but not another.
|
|
334
906
|
*
|
|
335
907
|
* @param commit ObjectId to exclude along with its ancestors
|
|
908
|
+
* @param name The name it was given by (see {@link add})
|
|
336
909
|
*/
|
|
337
|
-
not(commit: ObjectId): this {
|
|
910
|
+
not(commit: ObjectId, name?: string, options: { left?: boolean } = {}): this {
|
|
338
911
|
this.checkCallable();
|
|
339
|
-
this.pending.push({
|
|
912
|
+
this.pending.push({
|
|
913
|
+
id: commit,
|
|
914
|
+
exclude: true,
|
|
915
|
+
...(name !== undefined ? { name } : {}),
|
|
916
|
+
...(options.left ? { left: true } : {}),
|
|
917
|
+
});
|
|
340
918
|
return this;
|
|
341
919
|
}
|
|
342
920
|
|
|
@@ -409,6 +987,106 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
409
987
|
return this;
|
|
410
988
|
}
|
|
411
989
|
|
|
990
|
+
/**
|
|
991
|
+
* `--grep=<pattern>`: commits whose message has a line matching the pattern (several:
|
|
992
|
+
* any of them, every one with {@link setAllMatch}). Patterns are basic POSIX regexes unless
|
|
993
|
+
* {@link setPatternType} or `grep.patternType`/`grep.extendedRegexp` say otherwise, matched
|
|
994
|
+
* as git's grep.c matches them (`--grep=` matches every commit with a message part).
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
* ```typescript
|
|
998
|
+
* // git log --grep=fix --grep=bug --all-match -i
|
|
999
|
+
* await git.log().addGrep("fix").addGrep("bug").setAllMatch(true).setRegexpIgnoreCase(true).call();
|
|
1000
|
+
* ```
|
|
1001
|
+
*/
|
|
1002
|
+
addGrep(pattern: string): this {
|
|
1003
|
+
this.checkCallable();
|
|
1004
|
+
this.grepMessages.push(pattern);
|
|
1005
|
+
return this;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* `--author=<pattern>`: commits whose `author` header line (name and email, the date left
|
|
1010
|
+
* out; mapped through the mailmap under `log.mailmap`) matches the pattern; several are
|
|
1011
|
+
* or-ed. Unlike {@link setAuthorFilter}, the pattern is git's (a basic regex, case-sensitive
|
|
1012
|
+
* without {@link setRegexpIgnoreCase}).
|
|
1013
|
+
*/
|
|
1014
|
+
addAuthor(pattern: string): this {
|
|
1015
|
+
this.checkCallable();
|
|
1016
|
+
this.grepAuthors.push(pattern);
|
|
1017
|
+
return this;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/** `--committer=<pattern>`: as {@link addAuthor}, on the `committer` header line. */
|
|
1021
|
+
addCommitter(pattern: string): this {
|
|
1022
|
+
this.checkCallable();
|
|
1023
|
+
this.grepCommitters.push(pattern);
|
|
1024
|
+
return this;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
/** `--all-match`: every `--grep` pattern must match (author and committer patterns always must). */
|
|
1028
|
+
setAllMatch(allMatch: boolean): this {
|
|
1029
|
+
this.checkCallable();
|
|
1030
|
+
this.allMatch = allMatch;
|
|
1031
|
+
return this;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
/** `--invert-grep`: commits whose message matches no `--grep` pattern (not `--author`'s). */
|
|
1035
|
+
setInvertGrep(invert: boolean): this {
|
|
1036
|
+
this.checkCallable();
|
|
1037
|
+
this.invertGrep = invert;
|
|
1038
|
+
return this;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
/** `-i` / `--regexp-ignore-case`: the patterns fold ASCII case. */
|
|
1042
|
+
setRegexpIgnoreCase(ignoreCase: boolean): this {
|
|
1043
|
+
this.checkCallable();
|
|
1044
|
+
this.regexpIgnoreCase = ignoreCase;
|
|
1045
|
+
return this;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* The patterns' type: `--basic-regexp`, `-E` (`extended`), `-F` (`fixed`) or `-P`
|
|
1050
|
+
* (`perl`: refused as a git built without PCRE refuses it, unless the pattern has no regex
|
|
1051
|
+
* character). Default: `grep.patternType`, else `grep.extendedRegexp`, else basic.
|
|
1052
|
+
*/
|
|
1053
|
+
setPatternType(type: GrepPatternType): this {
|
|
1054
|
+
this.checkCallable();
|
|
1055
|
+
this.patternType = type;
|
|
1056
|
+
return this;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* Whether `--author`/`--committer` match the identities as the mailmap maps them
|
|
1061
|
+
* (`--use-mailmap`/`--no-mailmap`; default `log.mailmap`, true, as `git log`).
|
|
1062
|
+
*/
|
|
1063
|
+
setUseMailmap(use: boolean): this {
|
|
1064
|
+
this.checkCallable();
|
|
1065
|
+
this.useMailmap = use;
|
|
1066
|
+
return this;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Whether the filters read `git log`'s configuration (default true): `grep.patternType`,
|
|
1071
|
+
* `grep.extendedRegexp` and `log.mailmap`. False reads none of them, as `git rev-list`.
|
|
1072
|
+
*/
|
|
1073
|
+
setLogConfig(read: boolean): this {
|
|
1074
|
+
this.checkCallable();
|
|
1075
|
+
this.logConfig = read;
|
|
1076
|
+
return this;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* A filter of the commits shown (see `CommitFilters`); several must all include a commit,
|
|
1081
|
+
* as must git's options above. The walk still goes through the commits a filter hides, and
|
|
1082
|
+
* `setMaxCount`/`setSkip` count only shown ones.
|
|
1083
|
+
*/
|
|
1084
|
+
addCommitFilter(filter: CommitFilter): this {
|
|
1085
|
+
this.checkCallable();
|
|
1086
|
+
this.commitFilters.push(filter);
|
|
1087
|
+
return this;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
412
1090
|
/**
|
|
413
1091
|
* Whether a path-limited walk asks the commit-graph's changed-path Bloom filters before it
|
|
414
1092
|
* compares trees (default true, as git does whenever the graph has filters).
|
|
@@ -456,21 +1134,132 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
456
1134
|
this.setCallable(false);
|
|
457
1135
|
// git_log_config ends in git_diff_ui_config: a diff.submodule without a value dies
|
|
458
1136
|
readDiffSubmoduleConfig(this.workingCopy);
|
|
1137
|
+
if (this.reflogWalkNames !== undefined || this.grepReflogs.length > 0) {
|
|
1138
|
+
await this.checkReflogWalkOptions({});
|
|
1139
|
+
const entries = await this.reflogEntries(this.reflogWalkNames ?? [], false);
|
|
1140
|
+
const walk = (async function* () {
|
|
1141
|
+
for (const e of entries) yield { ...e.commit, id: e.id, reflog: e.reflog } as LogResult;
|
|
1142
|
+
})();
|
|
1143
|
+
return walk;
|
|
1144
|
+
}
|
|
1145
|
+
this.activeFilter = await this.buildCommitFilter();
|
|
459
1146
|
|
|
460
1147
|
// the commits given, in order, the refs of `all()` where it was called; HEAD without
|
|
461
1148
|
// either
|
|
462
|
-
const pending:
|
|
1149
|
+
const pending: PendingCommit[] = [];
|
|
463
1150
|
for (let i = 0; i <= this.pending.length; i++) {
|
|
464
1151
|
if (this.includeAll && i === this.allAt) {
|
|
465
|
-
for (const id of await this.getAllRefs())
|
|
1152
|
+
for (const { id, name, raw } of await this.getAllRefs()) {
|
|
1153
|
+
if (raw !== id && this.ancestryPathCommits.includes(raw))
|
|
1154
|
+
this.ancestryPathPeeled.push(id);
|
|
1155
|
+
pending.push({ id, exclude: false, name });
|
|
1156
|
+
}
|
|
466
1157
|
}
|
|
467
1158
|
const e = this.pending[i];
|
|
468
|
-
if (e
|
|
1159
|
+
if (e && e.id !== (await this.peelToCommit(e.id)) && this.ancestryPathCommits.includes(e.id))
|
|
1160
|
+
this.ancestryPathPeeled.push(await this.peelToCommit(e.id));
|
|
1161
|
+
if (e)
|
|
1162
|
+
pending.push({
|
|
1163
|
+
id: await this.peelToCommit(e.id),
|
|
1164
|
+
exclude: e.exclude,
|
|
1165
|
+
name: e.name ?? e.id,
|
|
1166
|
+
...(e.left ? { left: true } : {}),
|
|
1167
|
+
});
|
|
469
1168
|
}
|
|
470
1169
|
if (this.startCommits.length === 0 && !this.includeAll) {
|
|
471
|
-
pending.push({ id: await this.resolveHead(), exclude: false });
|
|
1170
|
+
pending.push({ id: await this.resolveHead(), exclude: false, name: "HEAD" });
|
|
472
1171
|
}
|
|
473
|
-
|
|
1172
|
+
if (this.lineRangeArgs.length > 0) await this.startLineLog(pending);
|
|
1173
|
+
const walk = this.walk(pending);
|
|
1174
|
+
return this.reverse ? reversed(walk) : walk;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* The walk's filter: git's `--grep`/`--author`/`--committer` options as one `commit_match`
|
|
1179
|
+
* (revision.c), then the filters added. The walk reads `grep.patternType` (and refuses a
|
|
1180
|
+
* value git does not know) only when a pattern is given; the log output (`callBytes`, git
|
|
1181
|
+
* log and git show) reads it on every run, as git does.
|
|
1182
|
+
*/
|
|
1183
|
+
private async buildCommitFilter(): Promise<CommitFilter | undefined> {
|
|
1184
|
+
const filters: CommitFilter[] = [];
|
|
1185
|
+
const headers =
|
|
1186
|
+
this.grepAuthors.length > 0 || this.grepCommitters.length > 0 || this.grepReflogs.length > 0;
|
|
1187
|
+
// the grep configuration and the mailmap are read only for a walk that greps: the
|
|
1188
|
+
// commands walking through LogCommand for git's other commands (bisect, notes, rev-list)
|
|
1189
|
+
// never see them
|
|
1190
|
+
if (this.grepMessages.length > 0 || headers) {
|
|
1191
|
+
let type = this.patternType;
|
|
1192
|
+
if (this.logConfig) {
|
|
1193
|
+
const configured = this.configuredPatternType();
|
|
1194
|
+
if (type === undefined) type = configured;
|
|
1195
|
+
if (type === undefined && configBool(this.workingCopy, "grep.extendedRegexp", false)) {
|
|
1196
|
+
type = "extended";
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
let mailmap: Mailmap | undefined;
|
|
1200
|
+
const mapped =
|
|
1201
|
+
this.useMailmap ??
|
|
1202
|
+
(this.logConfig ? configBool(this.workingCopy, "log.mailmap", true) : false);
|
|
1203
|
+
if (headers && mapped) mailmap = await this.loadedMailmap();
|
|
1204
|
+
filters.push(
|
|
1205
|
+
CommitFilters.grep({
|
|
1206
|
+
messages: this.grepMessages,
|
|
1207
|
+
authors: this.grepAuthors,
|
|
1208
|
+
committers: this.grepCommitters,
|
|
1209
|
+
...(this.grepReflogs.length > 0 ? { reflogs: this.grepReflogs } : {}),
|
|
1210
|
+
allMatch: this.allMatch,
|
|
1211
|
+
invertGrep: this.invertGrep,
|
|
1212
|
+
ignoreCase: this.regexpIgnoreCase,
|
|
1213
|
+
patternType: type,
|
|
1214
|
+
mailmap,
|
|
1215
|
+
}),
|
|
1216
|
+
);
|
|
1217
|
+
}
|
|
1218
|
+
filters.push(...this.commitFilters);
|
|
1219
|
+
return filters.length > 0 ? CommitFilters.and(...filters) : undefined;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* `grep.patternType` as grep_config reads it (`default` is undefined); a value git does not
|
|
1224
|
+
* know dies, as every `git log`/`git show` dies on it whatever it is asked.
|
|
1225
|
+
*/
|
|
1226
|
+
private configuredPatternType(): GrepPatternType | undefined {
|
|
1227
|
+
const value = configValue(this.workingCopy, "grep.patternType");
|
|
1228
|
+
if (value === undefined || value === "default") return undefined;
|
|
1229
|
+
if (value === "basic" || value === "extended" || value === "fixed" || value === "perl") {
|
|
1230
|
+
return value;
|
|
1231
|
+
}
|
|
1232
|
+
throw new InvalidConfigError(
|
|
1233
|
+
"grep.patternType",
|
|
1234
|
+
`fatal: bad grep.patterntype argument: ${value}`,
|
|
1235
|
+
);
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
/** The bytes of a commit as the walk reads it (the replacement's under replace refs) */
|
|
1239
|
+
private async rawCommit(id: ObjectId, replacements?: ObjectReplacements): Promise<Uint8Array> {
|
|
1240
|
+
const read = replacements ? replacementOf(replacements.replace, id) : id;
|
|
1241
|
+
const bytes = await this.readObjectBytes(read);
|
|
1242
|
+
if (!bytes) throw new GitApiError(`could not read commit ${id}`);
|
|
1243
|
+
return bytes;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* The author date of a commit as commit.c's record_author_date reads it (0 when the
|
|
1248
|
+
* header has no well-formed author line).
|
|
1249
|
+
*/
|
|
1250
|
+
private async authorDate(id: ObjectId): Promise<number> {
|
|
1251
|
+
const bytes = await this.readObjectBytes(
|
|
1252
|
+
replacementOf((await this.objectReplacements())?.replace ?? new Map(), id),
|
|
1253
|
+
).catch(() => undefined);
|
|
1254
|
+
if (!bytes) return 0;
|
|
1255
|
+
const text = NAME_DECODER.decode(bytes);
|
|
1256
|
+
const end = text.indexOf("\n\n");
|
|
1257
|
+
for (const line of (end < 0 ? text : text.slice(0, end)).split("\n")) {
|
|
1258
|
+
if (!line.startsWith("author ")) continue;
|
|
1259
|
+
const m = /> (\d+) [+-]?\d+$/.exec(line) ?? /> (\d+)$/.exec(line);
|
|
1260
|
+
return m ? Number(m[1]) : 0;
|
|
1261
|
+
}
|
|
1262
|
+
return 0;
|
|
474
1263
|
}
|
|
475
1264
|
|
|
476
1265
|
/** The commit an annotated tag (or a chain of them) tags; any other id as it is. */
|
|
@@ -490,7 +1279,7 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
490
1279
|
* (refs_for_each_ref, symbolic ones resolved), then HEAD (refs_head_ref); annotated tags
|
|
491
1280
|
* peeled.
|
|
492
1281
|
*/
|
|
493
|
-
private async getAllRefs(): Promise<ObjectId[]> {
|
|
1282
|
+
private async getAllRefs(): Promise<{ id: ObjectId; name: string; raw: ObjectId }[]> {
|
|
494
1283
|
const named: { name: Uint8Array; id: ObjectId }[] = [];
|
|
495
1284
|
for await (const ref of this.refsStore.list()) {
|
|
496
1285
|
if (!ref.name.startsWith("refs/")) continue;
|
|
@@ -499,10 +1288,11 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
499
1288
|
if (id) named.push({ name: encodeGitPath(ref.name), id });
|
|
500
1289
|
}
|
|
501
1290
|
named.sort((a, b) => compareBytes(a.name, b.name));
|
|
502
|
-
const ids: ObjectId[] = [];
|
|
503
|
-
for (const { id } of named)
|
|
1291
|
+
const ids: { id: ObjectId; name: string; raw: ObjectId }[] = [];
|
|
1292
|
+
for (const { id, name } of named)
|
|
1293
|
+
ids.push({ id: await this.peelToCommit(id), name: decodeGitPath(name), raw: id });
|
|
504
1294
|
const head = (await this.refsStore.resolve("HEAD").catch(() => undefined))?.objectId;
|
|
505
|
-
if (head) ids.push(await this.peelToCommit(head));
|
|
1295
|
+
if (head) ids.push({ id: await this.peelToCommit(head), name: "HEAD", raw: head });
|
|
506
1296
|
return ids;
|
|
507
1297
|
}
|
|
508
1298
|
|
|
@@ -526,8 +1316,21 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
526
1316
|
* The commits met are held in a `RevTable` (typed arrays, a few dozen bytes each); commits
|
|
527
1317
|
* the commit-graph has are reached by their graph positions, without building their ids.
|
|
528
1318
|
*/
|
|
529
|
-
private async *walk(pending:
|
|
530
|
-
const
|
|
1319
|
+
private async *walk(pending: PendingCommit[]): AsyncIterable<LogResult> {
|
|
1320
|
+
const hasPaths = this.paths.length > 0 || this.excludePaths.length > 0;
|
|
1321
|
+
const simplifyByDecoration = this.simplifyByDecoration;
|
|
1322
|
+
// --simplify-by-decoration prunes without paths: a commit no ref names is TREESAME
|
|
1323
|
+
const prune = hasPaths || simplifyByDecoration;
|
|
1324
|
+
const simplifyMerges = this.simplifyMerges || simplifyByDecoration;
|
|
1325
|
+
const ancestryPath = this.ancestryPathImplicit || this.ancestryPathCommits.length > 0;
|
|
1326
|
+
const dense = this.dense;
|
|
1327
|
+
const showPulls = this.showPulls;
|
|
1328
|
+
// git's want_ancestry: rewrite_parents (--parents, --graph, --simplify-merges)
|
|
1329
|
+
const wantAncestry = this.rewriteParents || simplifyMerges || !!this.outputWalk?.rewrite;
|
|
1330
|
+
const rewrite = prune && dense && wantAncestry;
|
|
1331
|
+
const decorations = simplifyByDecoration
|
|
1332
|
+
? await (this.decorationLoader?.() ?? this.refDecorations())
|
|
1333
|
+
: undefined;
|
|
531
1334
|
// a shallow commit has no parents (git's shallow grafts); the graph is off then
|
|
532
1335
|
const shallowIds = (await this.refsStore.getShallow?.().catch(() => undefined)) ?? [];
|
|
533
1336
|
const shallow = new Set(shallowIds);
|
|
@@ -540,13 +1343,13 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
540
1343
|
shallow.size > 0 || replacements
|
|
541
1344
|
? undefined
|
|
542
1345
|
: await this.commits.commitGraph?.get().catch(() => undefined);
|
|
543
|
-
const pathspec =
|
|
1346
|
+
const pathspec = hasPaths ? this.pathspec() : undefined;
|
|
544
1347
|
const bloom =
|
|
545
1348
|
pathspec && this.useBloomFilters ? this.bloomKeys(graph, pathspec.items) : undefined;
|
|
546
1349
|
const bloomVersion = bloom ? this.changedPathsVersion() : -1;
|
|
547
1350
|
const fast = pathspec?.literal;
|
|
548
1351
|
const firstParentOnly = this.firstParentOnly;
|
|
549
|
-
const simplifyHistory = this.simplifyHistory;
|
|
1352
|
+
const simplifyHistory = this.simplifyHistory && !simplifyMerges && !ancestryPath;
|
|
550
1353
|
/**
|
|
551
1354
|
* Each merge's TREESAME to each parent (git's `treesame` decoration), kept when limiting
|
|
552
1355
|
* can make it TREESAME later (limiting_can_increase_treesame: full history, a limited walk)
|
|
@@ -555,6 +1358,8 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
555
1358
|
let trackTreesame = false;
|
|
556
1359
|
const t = new RevTable(graph);
|
|
557
1360
|
this.lastWalk = t;
|
|
1361
|
+
/** `--source`: the name each commit was reached from (git's revision_sources slab) */
|
|
1362
|
+
const sources = this.source ? new Map<number, string>() : undefined;
|
|
558
1363
|
/** Raw commits read by `parse` (no graph), kept until shown: read once, not twice. */
|
|
559
1364
|
const raw = new Map<number, Uint8Array>();
|
|
560
1365
|
|
|
@@ -600,8 +1405,20 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
600
1405
|
for (let k = 0, c = t.parentCount(n); k < c; k++) markOne(t.parent(n, k));
|
|
601
1406
|
for (let p = stack.pop(); p !== undefined; p = stack.pop()) markOne(p);
|
|
602
1407
|
};
|
|
603
|
-
const
|
|
604
|
-
|
|
1408
|
+
const emptyTree = this.objectFormat.emptyTreeId;
|
|
1409
|
+
/** git's rev_compare_tree (`from` given) and rev_same_tree_as_empty: whether n differs */
|
|
1410
|
+
const differs = async (
|
|
1411
|
+
from: ObjectId | undefined,
|
|
1412
|
+
n: number,
|
|
1413
|
+
nth: number,
|
|
1414
|
+
): Promise<boolean> => {
|
|
1415
|
+
if (decorations && from !== undefined) {
|
|
1416
|
+
// a commit a ref names is worth showing; without paths, no other is
|
|
1417
|
+
if ((decorations.get(t.idOf(n))?.length ?? 0) > 0) return true;
|
|
1418
|
+
if (!pathspec) return false;
|
|
1419
|
+
}
|
|
1420
|
+
if (!pathspec) return t.treeOf(n) !== emptyTree;
|
|
1421
|
+
return this.differsAtPaths(
|
|
605
1422
|
from,
|
|
606
1423
|
t.treeOf(n),
|
|
607
1424
|
pathspec as TreePathspec,
|
|
@@ -611,14 +1428,18 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
611
1428
|
graph,
|
|
612
1429
|
t.bloomPos(n),
|
|
613
1430
|
);
|
|
614
|
-
|
|
1431
|
+
};
|
|
1432
|
+
/** git's try_to_simplify_commit */
|
|
615
1433
|
const simplify = async (n: number): Promise<void> => {
|
|
616
|
-
|
|
1434
|
+
// an unparsed commit has no tree (a parent --first-parent never read, met by rewriting)
|
|
1435
|
+
if (!prune || !t.parsed(n)) return;
|
|
617
1436
|
const count = t.parentCount(n);
|
|
618
1437
|
if (count === 0) {
|
|
619
1438
|
if (!(await differs(undefined, n, 0))) t.mark(n, TREESAME);
|
|
620
1439
|
return;
|
|
621
1440
|
}
|
|
1441
|
+
// --sparse: a non-merge always counts as a change
|
|
1442
|
+
if (!dense && count === 1) return;
|
|
622
1443
|
let relevantParents = 0;
|
|
623
1444
|
let relevantChange = false;
|
|
624
1445
|
let irrelevantChange = false;
|
|
@@ -645,11 +1466,13 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
645
1466
|
continue;
|
|
646
1467
|
}
|
|
647
1468
|
t.keepOnlyParent(n, p);
|
|
648
|
-
|
|
1469
|
+
// a merge diverted to a later parent is shown under --show-pulls
|
|
1470
|
+
if (!showPulls || nth === 0) t.mark(n, TREESAME);
|
|
649
1471
|
return;
|
|
650
1472
|
}
|
|
651
1473
|
if (relevant(p)) relevantChange = true;
|
|
652
1474
|
else irrelevantChange = true;
|
|
1475
|
+
if (nth === 0) t.mark(n, PULL_MERGE);
|
|
653
1476
|
}
|
|
654
1477
|
if (relevantParents ? !relevantChange : !irrelevantChange) t.mark(n, TREESAME);
|
|
655
1478
|
};
|
|
@@ -670,11 +1493,17 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
670
1493
|
return;
|
|
671
1494
|
}
|
|
672
1495
|
await simplify(n);
|
|
1496
|
+
const passFlags = t.flag(n) & (SYMMETRIC_LEFT | ANCESTRY_PATH);
|
|
673
1497
|
for (let k = 0, c = t.parentCount(n); k < c; k++) {
|
|
674
1498
|
const p = t.parent(n, k);
|
|
675
1499
|
if (!(await parse(p))) {
|
|
676
1500
|
throw new GitApiError(`Failed to traverse parents of commit ${t.idOf(n)}`);
|
|
677
1501
|
}
|
|
1502
|
+
if (passFlags) t.mark(p, passFlags);
|
|
1503
|
+
if (sources && !sources.has(p)) {
|
|
1504
|
+
const source = sources.get(n);
|
|
1505
|
+
if (source !== undefined) sources.set(p, source);
|
|
1506
|
+
}
|
|
678
1507
|
if (!(t.flag(p) & SEEN)) {
|
|
679
1508
|
t.mark(p, SEEN);
|
|
680
1509
|
queue.put(p, t.date(p));
|
|
@@ -683,22 +1512,25 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
683
1512
|
}
|
|
684
1513
|
};
|
|
685
1514
|
/** git's get_commit_action (no parent rewriting: TREESAME commits are never shown) */
|
|
686
|
-
const shown = async (n: number,
|
|
1515
|
+
const shown = async (n: number, ancestry = false): Promise<LogResult | undefined> => {
|
|
687
1516
|
const bytes = raw.get(n);
|
|
688
1517
|
if (bytes) raw.delete(n);
|
|
689
|
-
|
|
690
|
-
if (t.flag(n) &
|
|
1518
|
+
// commit_early_ignore
|
|
1519
|
+
if (t.flag(n) & (UNINTERESTING | SHOWN)) return undefined;
|
|
1520
|
+
if (dense && t.flag(n) & TREESAME) {
|
|
691
1521
|
// with parents rewritten, a merge of two relevant lines ties the topology together
|
|
692
|
-
if (!
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
1522
|
+
if (!ancestry) return undefined;
|
|
1523
|
+
if (!(showPulls && t.flag(n) & PULL_MERGE)) {
|
|
1524
|
+
let relevantParents = 0;
|
|
1525
|
+
for (let k = 0, c = t.parentCount(n); k < c; k++)
|
|
1526
|
+
if (relevant(t.parent(n, k))) relevantParents++;
|
|
1527
|
+
if (relevantParents < 2) return undefined;
|
|
1528
|
+
}
|
|
697
1529
|
}
|
|
698
1530
|
if (this.untilTime !== undefined && t.date(n) > this.untilTime) return undefined;
|
|
699
1531
|
const parents = t.parentCount(n);
|
|
700
1532
|
if (this.revFilter === RevFilter.ONLY_MERGES && parents < 2) return undefined;
|
|
701
|
-
if (this.revFilter === RevFilter.NO_MERGES && parents > 1) return undefined;
|
|
1533
|
+
if ((this.revFilter === RevFilter.NO_MERGES || this.cherry) && parents > 1) return undefined;
|
|
702
1534
|
const id = t.idOf(n);
|
|
703
1535
|
const commit = bytes ? decodeCommit(bytes) : await this.walkCommits.load(id);
|
|
704
1536
|
if (!commit) return undefined;
|
|
@@ -708,17 +1540,63 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
708
1540
|
if (shallow.has(id)) commit.parents = [];
|
|
709
1541
|
if (this.authorPattern !== undefined && !this.matchesAuthor(commit)) return undefined;
|
|
710
1542
|
if (this.committerPattern !== undefined && !this.matchesCommitter(commit)) return undefined;
|
|
711
|
-
|
|
1543
|
+
const filter = this.activeFilter;
|
|
1544
|
+
if (filter) {
|
|
1545
|
+
const view: FilteredCommit = {
|
|
1546
|
+
id,
|
|
1547
|
+
parentCount: parents,
|
|
1548
|
+
commitTime: t.date(n),
|
|
1549
|
+
raw: async () => bytes ?? (await this.rawCommit(id, replacements)),
|
|
1550
|
+
commit: async () => commit,
|
|
1551
|
+
};
|
|
1552
|
+
if (!(await filter.include(view))) return undefined;
|
|
1553
|
+
}
|
|
1554
|
+
const source = sources?.get(n);
|
|
1555
|
+
return {
|
|
1556
|
+
...commit,
|
|
1557
|
+
id,
|
|
1558
|
+
...(source !== undefined ? { source } : {}),
|
|
1559
|
+
...sideOf(n),
|
|
1560
|
+
};
|
|
1561
|
+
};
|
|
1562
|
+
/** The side marks of a commit (SYMMETRIC_LEFT, PATCHSAME) */
|
|
1563
|
+
const sideOf = (n: number): { left?: true; patchSame?: true } => {
|
|
1564
|
+
const f = t.flag(n);
|
|
1565
|
+
return {
|
|
1566
|
+
...(f & SYMMETRIC_LEFT ? { left: true } : {}),
|
|
1567
|
+
...(f & PATCHSAME ? { patchSame: true } : {}),
|
|
1568
|
+
};
|
|
712
1569
|
};
|
|
713
1570
|
|
|
1571
|
+
// --ancestry-path=<commit>: the commits (git marks the object named: a tag's commit is
|
|
1572
|
+
// not marked, only listed among the bottoms)
|
|
1573
|
+
const ancestryBottoms: number[] = [];
|
|
1574
|
+
for (const id of this.ancestryPathCommits) {
|
|
1575
|
+
const commit = await this.peelToCommit(id);
|
|
1576
|
+
const n = t.lookup(commit);
|
|
1577
|
+
if (commit === id) t.mark(n, ANCESTRY_PATH);
|
|
1578
|
+
ancestryBottoms.unshift(n);
|
|
1579
|
+
}
|
|
1580
|
+
for (const id of this.ancestryPathPeeled) t.mark(t.lookup(id), ANCESTRY_PATH);
|
|
714
1581
|
// prepare_revision_walk: the flags of every argument first, then handle_commit in order
|
|
715
1582
|
for (const e of pending) {
|
|
1583
|
+
if (e.left) t.mark(t.lookup(e.id), SYMMETRIC_LEFT);
|
|
716
1584
|
if (!e.exclude) continue;
|
|
717
1585
|
const n = t.lookup(e.id);
|
|
718
1586
|
t.mark(n, UNINTERESTING | BOTTOM);
|
|
719
1587
|
}
|
|
720
1588
|
const list: number[] = [];
|
|
721
|
-
|
|
1589
|
+
// --cherry-pick and --cherry-mark need limit_list, and so do --left-only and
|
|
1590
|
+
// --right-only from git 2.44 on (2.43 applies them only to a walk limited otherwise)
|
|
1591
|
+
// --ancestry-path and --simplify-merges limit the walk too (--parents does not: a
|
|
1592
|
+
// streaming walk rewrites parents as it goes)
|
|
1593
|
+
let limited =
|
|
1594
|
+
!!this.lineLog ||
|
|
1595
|
+
this.cherryPick ||
|
|
1596
|
+
this.cherryMark ||
|
|
1597
|
+
(this.compatibility !== "2.43" && (this.leftOnly || this.rightOnly)) ||
|
|
1598
|
+
ancestryPath ||
|
|
1599
|
+
simplifyMerges;
|
|
722
1600
|
/** git's update_treesame: TREESAME again from the per-parent marks, relevance as it is now */
|
|
723
1601
|
const updateTreesame = (n: number): void => {
|
|
724
1602
|
const count = t.parentCount(n);
|
|
@@ -736,9 +1614,281 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
736
1614
|
if (relevantParents ? relevantChange : irrelevantChange) t.unmark(n, TREESAME);
|
|
737
1615
|
else t.mark(n, TREESAME);
|
|
738
1616
|
};
|
|
1617
|
+
/**
|
|
1618
|
+
* revision.c's limit_to_ancestry: of `list`, the commits neither descending from a bottom
|
|
1619
|
+
* (TMP_MARK) nor marked ANCESTRY_PATH (ancestors of a commit given) become UNINTERESTING.
|
|
1620
|
+
*/
|
|
1621
|
+
const limitToAncestry = (bottoms: number[], list: number[]): void => {
|
|
1622
|
+
const marked = new Set(bottoms);
|
|
1623
|
+
const rlist = [...list].reverse();
|
|
1624
|
+
let progress: boolean;
|
|
1625
|
+
do {
|
|
1626
|
+
progress = false;
|
|
1627
|
+
for (const c of rlist) {
|
|
1628
|
+
if (marked.has(c) || t.flag(c) & UNINTERESTING) continue;
|
|
1629
|
+
for (let k = 0, n = t.parentCount(c); k < n; k++) {
|
|
1630
|
+
if (!marked.has(t.parent(c, k))) continue;
|
|
1631
|
+
marked.add(c);
|
|
1632
|
+
progress = true;
|
|
1633
|
+
break;
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
} while (progress);
|
|
1637
|
+
for (const c of list) {
|
|
1638
|
+
if (marked.has(c) || t.flag(c) & ANCESTRY_PATH) continue;
|
|
1639
|
+
t.mark(c, UNINTERESTING);
|
|
1640
|
+
}
|
|
1641
|
+
for (const c of list) t.unmark(c, ANCESTRY_PATH);
|
|
1642
|
+
for (const c of bottoms) t.unmark(c, ANCESTRY_PATH);
|
|
1643
|
+
};
|
|
1644
|
+
/**
|
|
1645
|
+
* revision.c's compact_treesame: parent `nth` was just removed from n's parents (git's
|
|
1646
|
+
* treesame decoration follows; a merge become a non-merge takes its TREESAME at once).
|
|
1647
|
+
*/
|
|
1648
|
+
const compactTreesame = async (n: number, nth: number): Promise<void> => {
|
|
1649
|
+
if (t.parentCount(n) === 0) {
|
|
1650
|
+
if (await differs(undefined, n, nth)) t.unmark(n, TREESAME);
|
|
1651
|
+
else t.mark(n, TREESAME);
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1654
|
+
const st = treesame.get(n);
|
|
1655
|
+
if (!st || nth >= st.length) throw new GitApiError(`compact_treesame ${nth}`);
|
|
1656
|
+
const next = new Uint8Array(st.length - 1);
|
|
1657
|
+
next.set(st.subarray(0, nth));
|
|
1658
|
+
next.set(st.subarray(nth + 1), nth);
|
|
1659
|
+
if (next.length === 1) {
|
|
1660
|
+
if (next[0] && dense) t.mark(n, TREESAME);
|
|
1661
|
+
else t.unmark(n, TREESAME);
|
|
1662
|
+
treesame.delete(n);
|
|
1663
|
+
} else treesame.set(n, next);
|
|
1664
|
+
};
|
|
1665
|
+
/** revision.c's remove_duplicate_parents: how many parents are left */
|
|
1666
|
+
const removeDuplicateParents = async (n: number): Promise<number> => {
|
|
1667
|
+
const tracked = treesame.has(n);
|
|
1668
|
+
const parents = t.parentList(n);
|
|
1669
|
+
const current = [...parents];
|
|
1670
|
+
let surviving = 0;
|
|
1671
|
+
for (const p of parents) {
|
|
1672
|
+
if (current.slice(0, surviving).includes(p)) {
|
|
1673
|
+
// the list shrinks before the treesame marks follow
|
|
1674
|
+
current.splice(surviving, 1);
|
|
1675
|
+
t.setParentList(n, current);
|
|
1676
|
+
if (tracked) await compactTreesame(n, surviving);
|
|
1677
|
+
continue;
|
|
1678
|
+
}
|
|
1679
|
+
surviving++;
|
|
1680
|
+
}
|
|
1681
|
+
return surviving;
|
|
1682
|
+
};
|
|
1683
|
+
/**
|
|
1684
|
+
* commit-reach.c's paint_down_to_common for remove_redundant (no generation cut): the
|
|
1685
|
+
* PARENT1 (from `one`) and PARENT2 (from `twos`) marks of the commits, through the
|
|
1686
|
+
* parents as the walk holds them (simplified ones included, as git's in-memory commits).
|
|
1687
|
+
*/
|
|
1688
|
+
const paintDown = async (one: number, twos: number[]): Promise<Map<number, number>> => {
|
|
1689
|
+
const P1 = 1;
|
|
1690
|
+
const P2 = 2;
|
|
1691
|
+
const STALE = 4;
|
|
1692
|
+
const RESULT = 8;
|
|
1693
|
+
const marks = new Map<number, number>();
|
|
1694
|
+
const queue = new CommitQueue<number>();
|
|
1695
|
+
const markOf = (c: number) => marks.get(c) ?? 0;
|
|
1696
|
+
marks.set(one, P1);
|
|
1697
|
+
queue.put(one, t.date(one));
|
|
1698
|
+
for (const c of twos) {
|
|
1699
|
+
if (c === one) return marks;
|
|
1700
|
+
marks.set(c, markOf(c) | P2);
|
|
1701
|
+
queue.put(c, t.date(c));
|
|
1702
|
+
}
|
|
1703
|
+
const nonStale = () => queue.items().some((c) => !(markOf(c) & STALE));
|
|
1704
|
+
while (nonStale()) {
|
|
1705
|
+
const c = queue.get() as number;
|
|
1706
|
+
let flags = markOf(c) & (P1 | P2 | STALE);
|
|
1707
|
+
if (flags === (P1 | P2)) {
|
|
1708
|
+
marks.set(c, markOf(c) | RESULT);
|
|
1709
|
+
flags |= STALE;
|
|
1710
|
+
}
|
|
1711
|
+
for (let k = 0, n = t.parentCount(c); k < n; k++) {
|
|
1712
|
+
const p = t.parent(c, k);
|
|
1713
|
+
if ((markOf(p) & flags) === flags) continue;
|
|
1714
|
+
if (!(await parse(p))) {
|
|
1715
|
+
throw new GitApiError(`could not parse commit ${t.idOf(p)}`);
|
|
1716
|
+
}
|
|
1717
|
+
marks.set(p, markOf(p) | flags);
|
|
1718
|
+
queue.put(p, t.date(p));
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
return marks;
|
|
1722
|
+
};
|
|
1723
|
+
/** commit-reach.c's reduce_heads: the commits no other one of `heads` reaches, in order */
|
|
1724
|
+
const reduceHeads = async (heads: number[]): Promise<number[]> => {
|
|
1725
|
+
const array = [...new Set(heads)];
|
|
1726
|
+
for (const c of array) await parse(c);
|
|
1727
|
+
const redundant = new Array<boolean>(array.length).fill(false);
|
|
1728
|
+
for (let i = 0; i < array.length; i++) {
|
|
1729
|
+
if (redundant[i]) continue;
|
|
1730
|
+
const others: number[] = [];
|
|
1731
|
+
const index: number[] = [];
|
|
1732
|
+
for (let j = 0; j < array.length; j++) {
|
|
1733
|
+
if (i === j || redundant[j]) continue;
|
|
1734
|
+
others.push(array[j] as number);
|
|
1735
|
+
index.push(j);
|
|
1736
|
+
}
|
|
1737
|
+
const marks = await paintDown(array[i] as number, others);
|
|
1738
|
+
if ((marks.get(array[i] as number) ?? 0) & 2) redundant[i] = true;
|
|
1739
|
+
for (let j = 0; j < others.length; j++) {
|
|
1740
|
+
if ((marks.get(others[j] as number) ?? 0) & 1) redundant[index[j] as number] = true;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
return array.filter((_, i) => !redundant[i]);
|
|
1744
|
+
};
|
|
1745
|
+
/** revision.c's simplify_merges over the sorted list: the commits that stay */
|
|
1746
|
+
const simplifyMergesOf = async (list: number[]): Promise<number[]> => {
|
|
1747
|
+
const simplified = new Map<number, number>();
|
|
1748
|
+
const simplifyOne = async (commit: number, tail: number[]): Promise<void> => {
|
|
1749
|
+
if (simplified.has(commit)) return;
|
|
1750
|
+
// an UNINTERESTING commit and a root simplify to themselves
|
|
1751
|
+
if (t.flag(commit) & UNINTERESTING || t.parentCount(commit) === 0) {
|
|
1752
|
+
simplified.set(commit, commit);
|
|
1753
|
+
return;
|
|
1754
|
+
}
|
|
1755
|
+
let pending = 0;
|
|
1756
|
+
for (let k = 0, c = t.parentCount(commit); k < c; k++) {
|
|
1757
|
+
const p = t.parent(commit, k);
|
|
1758
|
+
if (!simplified.has(p)) {
|
|
1759
|
+
tail.push(p);
|
|
1760
|
+
pending++;
|
|
1761
|
+
}
|
|
1762
|
+
if (firstParentOnly) break;
|
|
1763
|
+
}
|
|
1764
|
+
if (pending) {
|
|
1765
|
+
tail.push(commit);
|
|
1766
|
+
return;
|
|
1767
|
+
}
|
|
1768
|
+
// each parent rewritten to what it simplifies to
|
|
1769
|
+
for (let k = 0, c = t.parentCount(commit); k < c; k++) {
|
|
1770
|
+
t.setParent(commit, k, simplified.get(t.parent(commit, k)) as number);
|
|
1771
|
+
if (firstParentOnly) break;
|
|
1772
|
+
}
|
|
1773
|
+
let cnt = firstParentOnly ? 1 : await removeDuplicateParents(commit);
|
|
1774
|
+
if (cnt > 1) {
|
|
1775
|
+
// mark_redundant_parents and mark_treesame_root_parents (git's TMP_MARK)
|
|
1776
|
+
const parents = t.parentList(commit);
|
|
1777
|
+
const reduced = await reduceHeads(parents);
|
|
1778
|
+
const marked = new Set<number>();
|
|
1779
|
+
let count = 0;
|
|
1780
|
+
for (const p of parents) {
|
|
1781
|
+
if (!reduced.includes(p)) {
|
|
1782
|
+
marked.add(p);
|
|
1783
|
+
count++;
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
for (const p of parents) {
|
|
1787
|
+
if (t.parentCount(p) === 0 && t.flag(p) & TREESAME) {
|
|
1788
|
+
marked.add(p);
|
|
1789
|
+
count++;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
if (count) {
|
|
1793
|
+
// leave_one_treesame_to_parent
|
|
1794
|
+
const ts = treesame.get(commit);
|
|
1795
|
+
let unmarked: number | undefined;
|
|
1796
|
+
let markedOne: number | undefined;
|
|
1797
|
+
for (let k = 0; k < parents.length; k++) {
|
|
1798
|
+
if (!ts?.[k]) continue;
|
|
1799
|
+
const p = parents[k] as number;
|
|
1800
|
+
if (marked.has(p)) markedOne ??= p;
|
|
1801
|
+
else {
|
|
1802
|
+
unmarked = p;
|
|
1803
|
+
break;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
if (unmarked === undefined && markedOne !== undefined) {
|
|
1807
|
+
marked.delete(markedOne);
|
|
1808
|
+
count--;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
if (count) {
|
|
1812
|
+
// remove_marked_parents
|
|
1813
|
+
const current = [...parents];
|
|
1814
|
+
let nth = 0;
|
|
1815
|
+
let removed = 0;
|
|
1816
|
+
for (const p of parents) {
|
|
1817
|
+
if (marked.has(p)) {
|
|
1818
|
+
current.splice(nth, 1);
|
|
1819
|
+
t.setParentList(commit, current);
|
|
1820
|
+
removed++;
|
|
1821
|
+
await compactTreesame(commit, nth);
|
|
1822
|
+
continue;
|
|
1823
|
+
}
|
|
1824
|
+
nth++;
|
|
1825
|
+
}
|
|
1826
|
+
// removing parents can only make the commit TREESAME
|
|
1827
|
+
if (removed && !(t.flag(commit) & TREESAME)) updateTreesame(commit);
|
|
1828
|
+
cnt = nth;
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
const parent =
|
|
1832
|
+
!cnt || t.flag(commit) & UNINTERESTING || !(t.flag(commit) & TREESAME)
|
|
1833
|
+
? undefined
|
|
1834
|
+
: oneRelevantParent(t, commit, firstParentOnly, relevant);
|
|
1835
|
+
if (parent === undefined || (showPulls && t.flag(commit) & PULL_MERGE)) {
|
|
1836
|
+
simplified.set(commit, commit);
|
|
1837
|
+
} else simplified.set(commit, simplified.get(parent) as number);
|
|
1838
|
+
};
|
|
1839
|
+
let yetToDo = [...list].reverse();
|
|
1840
|
+
while (yetToDo.length > 0) {
|
|
1841
|
+
const todo = yetToDo;
|
|
1842
|
+
yetToDo = [];
|
|
1843
|
+
for (const commit of todo) await simplifyOne(commit, yetToDo);
|
|
1844
|
+
}
|
|
1845
|
+
return list.filter((c) => simplified.get(c) === c);
|
|
1846
|
+
};
|
|
1847
|
+
/**
|
|
1848
|
+
* revision.c's rewrite_parents with rewrite_one in a streaming walk: each commit passed on
|
|
1849
|
+
* the way down is processed first (process_parents, its parents queued through a queue
|
|
1850
|
+
* of its own merged into the walk's), as git rewrites while it streams.
|
|
1851
|
+
*/
|
|
1852
|
+
const rewriteStreaming = async (n: number, walkQueue: CommitQueue<number>) => {
|
|
1853
|
+
const out: number[] = [];
|
|
1854
|
+
for (let k = 0, c = t.parentCount(n); k < c; k++) {
|
|
1855
|
+
let p: number | undefined = t.parent(n, k);
|
|
1856
|
+
const own = new CommitQueue<number>();
|
|
1857
|
+
for (;;) {
|
|
1858
|
+
await processParents(p, own);
|
|
1859
|
+
if (t.flag(p) & UNINTERESTING || !(t.flag(p) & TREESAME)) break;
|
|
1860
|
+
if (t.parentCount(p) === 0) {
|
|
1861
|
+
p = undefined;
|
|
1862
|
+
break;
|
|
1863
|
+
}
|
|
1864
|
+
const next = oneRelevantParent(t, p, firstParentOnly, relevant);
|
|
1865
|
+
if (next === undefined) break;
|
|
1866
|
+
p = next;
|
|
1867
|
+
}
|
|
1868
|
+
for (let q = own.get(); q !== undefined; q = own.get()) walkQueue.put(q, t.date(q));
|
|
1869
|
+
if (p !== undefined && !out.includes(p)) out.push(p);
|
|
1870
|
+
}
|
|
1871
|
+
return out;
|
|
1872
|
+
};
|
|
1873
|
+
// `a...b`: git's get_merge_bases parsed every commit it painted while reading the
|
|
1874
|
+
// arguments, so mark_parents_uninteresting from the merge bases reaches through them
|
|
1875
|
+
for (let i = 0; i + 1 < pending.length; i++) {
|
|
1876
|
+
const a = pending[i] as PendingCommit;
|
|
1877
|
+
const b = pending[i + 1] as PendingCommit;
|
|
1878
|
+
if (!a.left || b.left || a.exclude !== b.exclude) continue;
|
|
1879
|
+
const na = t.lookup(a.id);
|
|
1880
|
+
const nb = t.lookup(b.id);
|
|
1881
|
+
if (!(await parse(na)) || !(await parse(nb))) continue;
|
|
1882
|
+
const marks = await paintDown(na, [nb]);
|
|
1883
|
+
const bases: number[] = [];
|
|
1884
|
+
for (const [c, m] of marks) if (m & 8 && !(m & 4)) bases.push(c);
|
|
1885
|
+
// get_merge_bases_many_0's remove_redundant over several candidates parses more
|
|
1886
|
+
if (bases.length > 1) await reduceHeads(bases);
|
|
1887
|
+
}
|
|
739
1888
|
for (const e of pending) {
|
|
740
1889
|
const n = t.lookup(e.id);
|
|
741
1890
|
if (!(await parse(n))) continue;
|
|
1891
|
+
if (sources && !sources.has(n) && e.name !== undefined) sources.set(n, e.name);
|
|
742
1892
|
if (t.flag(n) & UNINTERESTING) {
|
|
743
1893
|
markParentsUninteresting(n);
|
|
744
1894
|
limited = true;
|
|
@@ -750,98 +1900,276 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
750
1900
|
}
|
|
751
1901
|
// commit_list_sort_by_date (stable), then into the date queue in that order
|
|
752
1902
|
list.sort((a, b) => t.date(b) - t.date(a));
|
|
1903
|
+
// limit_list's collect_bottom_commits
|
|
1904
|
+
if (this.ancestryPathImplicit) {
|
|
1905
|
+
for (const n of list) if (t.flag(n) & BOTTOM) ancestryBottoms.unshift(n);
|
|
1906
|
+
if (ancestryBottoms.length === 0) {
|
|
1907
|
+
throw new GitApiError("--ancestry-path given but there are no bottom commits");
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
753
1910
|
const queue = new CommitQueue<number>();
|
|
754
1911
|
for (const n of list) queue.put(n, t.date(n));
|
|
755
1912
|
|
|
756
|
-
let count = 0;
|
|
757
|
-
let skipped = 0;
|
|
758
|
-
// git's -n 0 reads nothing more in a streaming walk; a limited walk is done before
|
|
759
1913
|
const none = this.maxCount !== undefined && this.maxCount <= 0;
|
|
760
1914
|
const output = this.outputWalk;
|
|
761
|
-
//
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
1915
|
+
// --simplify-merges sorts topologically (in graph order unless another order is set)
|
|
1916
|
+
const order = this.order ?? (simplifyMerges ? "topo" : undefined);
|
|
1917
|
+
// the output's walk and a sorted one are limited (git without generation numbers limits
|
|
1918
|
+
// a topo walk); per-parent TREESAME is kept where limiting or simplify_merges needs it
|
|
1919
|
+
trackTreesame =
|
|
1920
|
+
prune &&
|
|
1921
|
+
!simplifyHistory &&
|
|
1922
|
+
!firstParentOnly &&
|
|
1923
|
+
(simplifyMerges || ((limited || !!output || !!order) && dense));
|
|
1924
|
+
/** git's sort_in_topological_order of `list` (parents as simplified, unparsed: none) */
|
|
1925
|
+
const sortTopo = async (list: number[], sort: LogOrder | undefined): Promise<number[]> => {
|
|
1926
|
+
if (list.length === 0) return list;
|
|
1927
|
+
const indegree = new Map<number, number>();
|
|
1928
|
+
for (const n of list) indegree.set(n, 1);
|
|
1929
|
+
const parentCount = (n: number) => (t.parsed(n) ? t.parentCount(n) : 0);
|
|
1930
|
+
for (const n of list) {
|
|
1931
|
+
for (let k = 0, c = parentCount(n); k < c; k++) {
|
|
1932
|
+
const p = t.parent(n, k);
|
|
1933
|
+
const d = indegree.get(p);
|
|
1934
|
+
if (d) indegree.set(p, d + 1);
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
const out: number[] = [];
|
|
1938
|
+
let put: (n: number) => void;
|
|
1939
|
+
let get: () => number | undefined;
|
|
1940
|
+
if (sort === undefined || sort === "topo") {
|
|
1941
|
+
// REV_SORT_IN_GRAPH_ORDER: a LIFO, the tips first in the order given
|
|
1942
|
+
const stack: number[] = [];
|
|
1943
|
+
for (const n of list) if (indegree.get(n) === 1) stack.push(n);
|
|
1944
|
+
stack.reverse();
|
|
1945
|
+
put = (n) => stack.push(n);
|
|
1946
|
+
get = () => stack.pop();
|
|
1947
|
+
} else {
|
|
1948
|
+
const dates = new Map<number, number>();
|
|
1949
|
+
for (const n of list)
|
|
1950
|
+
dates.set(n, sort === "date" ? t.date(n) : await this.authorDate(t.idOf(n)));
|
|
1951
|
+
const queue = new CommitQueue<number>();
|
|
1952
|
+
put = (n) => queue.put(n, dates.get(n) ?? 0);
|
|
1953
|
+
get = () => queue.get();
|
|
1954
|
+
for (const n of list) if (indegree.get(n) === 1) put(n);
|
|
1955
|
+
}
|
|
1956
|
+
for (let n = get(); n !== undefined; n = get()) {
|
|
1957
|
+
for (let k = 0, c = parentCount(n); k < c; k++) {
|
|
1958
|
+
const p = t.parent(n, k);
|
|
1959
|
+
const d = indegree.get(p);
|
|
1960
|
+
if (!d) continue;
|
|
1961
|
+
indegree.set(p, d - 1);
|
|
1962
|
+
if (d - 1 === 1) put(p);
|
|
1963
|
+
}
|
|
1964
|
+
indegree.set(n, 0);
|
|
1965
|
+
out.push(n);
|
|
1966
|
+
}
|
|
1967
|
+
return out;
|
|
1968
|
+
};
|
|
1969
|
+
|
|
1970
|
+
/** get_revision_1's commits, in the order they come out */
|
|
1971
|
+
let candidates: AsyncIterable<number> | Iterable<number>;
|
|
1972
|
+
/** The streaming walk's queue, which rewriting parents walks on (rewrite_one_1) */
|
|
1973
|
+
let streamQueue: CommitQueue<number> | undefined;
|
|
1974
|
+
if (!limited && !output && !order) {
|
|
1975
|
+
streamQueue = queue;
|
|
765
1976
|
// get_revision_1, streaming
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
1977
|
+
const since = this.sinceTime;
|
|
1978
|
+
candidates = (async function* () {
|
|
1979
|
+
for (let n = queue.get(); n !== undefined; n = queue.get()) {
|
|
1980
|
+
// --since: older commits are dropped without walking their parents (max_age)
|
|
1981
|
+
if (since !== undefined && t.date(n) < since) {
|
|
1982
|
+
raw.delete(n);
|
|
1983
|
+
continue;
|
|
1984
|
+
}
|
|
1985
|
+
await processParents(n, queue);
|
|
1986
|
+
yield n;
|
|
771
1987
|
}
|
|
1988
|
+
})();
|
|
1989
|
+
} else {
|
|
1990
|
+
// limit_list
|
|
1991
|
+
const newlist: number[] = [];
|
|
1992
|
+
let date = Number.POSITIVE_INFINITY;
|
|
1993
|
+
let slop = SLOP;
|
|
1994
|
+
let interestingCache = -1;
|
|
1995
|
+
/** git's everybody_uninteresting */
|
|
1996
|
+
const everybodyUninteresting = (): boolean => {
|
|
1997
|
+
if (interestingCache >= 0 && !(t.flag(interestingCache) & UNINTERESTING)) return false;
|
|
1998
|
+
for (const n of queue.items()) {
|
|
1999
|
+
if (t.flag(n) & UNINTERESTING) continue;
|
|
2000
|
+
interestingCache = n;
|
|
2001
|
+
return false;
|
|
2002
|
+
}
|
|
2003
|
+
return true;
|
|
2004
|
+
};
|
|
2005
|
+
/** git's still_interesting */
|
|
2006
|
+
const stillInteresting = (): number => {
|
|
2007
|
+
const head = queue.peek();
|
|
2008
|
+
if (head === undefined) return 0;
|
|
2009
|
+
if (date <= t.date(head)) return SLOP;
|
|
2010
|
+
if (!everybodyUninteresting()) return SLOP;
|
|
2011
|
+
return slop - 1;
|
|
2012
|
+
};
|
|
2013
|
+
for (let n = queue.get(); n !== undefined; n = queue.get()) {
|
|
2014
|
+
// what is shown is read again at the end: a limited walk does not keep raw commits
|
|
2015
|
+
raw.delete(n);
|
|
2016
|
+
if (n === interestingCache) interestingCache = -1;
|
|
2017
|
+
if (this.sinceTime !== undefined && t.date(n) < this.sinceTime) t.mark(n, UNINTERESTING);
|
|
772
2018
|
await processParents(n, queue);
|
|
773
|
-
|
|
2019
|
+
if (t.flag(n) & UNINTERESTING) {
|
|
2020
|
+
markParentsUninteresting(n);
|
|
2021
|
+
slop = stillInteresting();
|
|
2022
|
+
if (slop) continue;
|
|
2023
|
+
break;
|
|
2024
|
+
}
|
|
2025
|
+
// -L: every commit is followed, --until hides it when shown (get_commit_action)
|
|
2026
|
+
if (this.untilTime !== undefined && t.date(n) > this.untilTime && !this.lineLog) continue;
|
|
2027
|
+
date = t.date(n);
|
|
2028
|
+
newlist.push(n);
|
|
2029
|
+
}
|
|
2030
|
+
if (this.cherryPick || this.cherryMark) {
|
|
2031
|
+
await this.cherryPickList(newlist, t, parse, pathspec ? this.pathspecItems() : undefined);
|
|
2032
|
+
}
|
|
2033
|
+
// limit_left_right
|
|
2034
|
+
if (this.leftOnly || this.rightOnly) {
|
|
2035
|
+
for (const n of newlist) {
|
|
2036
|
+
const left = !!(t.flag(n) & SYMMETRIC_LEFT);
|
|
2037
|
+
if (this.rightOnly ? left : !left) t.mark(n, SHOWN);
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
if (ancestryPath) limitToAncestry(ancestryBottoms, newlist);
|
|
2041
|
+
// commits made TREESAME by parents that became UNINTERESTING
|
|
2042
|
+
if (trackTreesame && dense) {
|
|
2043
|
+
for (const n of newlist) {
|
|
2044
|
+
if (!(t.flag(n) & (UNINTERESTING | TREESAME))) updateTreesame(n);
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
raw.clear();
|
|
2048
|
+
if (this.lineLog) {
|
|
2049
|
+
// -L sorts topologically (revs->topo_order), children before parents
|
|
2050
|
+
const sorted = await sortTopo(newlist, order ?? "topo");
|
|
2051
|
+
const lineOutput = output ?? { topo: true, rewrite: false, entries: [] };
|
|
2052
|
+
if (wantAncestry) {
|
|
2053
|
+
// want_ancestry (`--graph`, `--parents`, `--simplify-merges`,
|
|
2054
|
+
// `--simplify-by-decoration`): line_log_filter with its own parent rewriting, then
|
|
2055
|
+
// simplify_merges (which does nothing without prune: `-L` alone has none,
|
|
2056
|
+
// `--simplify-by-decoration` prunes), then get_commit_action and rewrite_parents
|
|
2057
|
+
const filtered = await this.lineLogFilter(t, sorted);
|
|
2058
|
+
const kept =
|
|
2059
|
+
simplifyMerges && prune ? await simplifyMergesOf(filtered.kept) : filtered.kept;
|
|
2060
|
+
await this.finishOutputWalk(lineOutput, t, kept, shown, relevant, parse, {
|
|
2061
|
+
ancestry: wantAncestry,
|
|
2062
|
+
rewrite,
|
|
2063
|
+
});
|
|
2064
|
+
for (const p of filtered.unwalked) {
|
|
2065
|
+
if (t.flag(p) & SEEN || !(await parse(p)) || !(await shown(p))) continue;
|
|
2066
|
+
lineOutput.unwalkedShown ??= new Set();
|
|
2067
|
+
lineOutput.unwalkedShown.add(t.idOf(p));
|
|
2068
|
+
}
|
|
2069
|
+
} else await this.finishLineLogWalk(lineOutput, t, sorted, shown);
|
|
2070
|
+
if (!output) {
|
|
2071
|
+
let count = 0;
|
|
2072
|
+
let toSkip = this.skip;
|
|
2073
|
+
for (const e of lineOutput.entries) {
|
|
2074
|
+
if (toSkip > 0) {
|
|
2075
|
+
toSkip--;
|
|
2076
|
+
continue;
|
|
2077
|
+
}
|
|
2078
|
+
yield { ...e.commit, id: e.id, parents: e.parents };
|
|
2079
|
+
if (this.maxCount !== undefined && ++count >= this.maxCount) break;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
return;
|
|
2083
|
+
}
|
|
2084
|
+
let sorted = output
|
|
2085
|
+
? output.topo
|
|
2086
|
+
? await sortTopo(newlist, order ?? "topo")
|
|
2087
|
+
: newlist
|
|
2088
|
+
: order
|
|
2089
|
+
? await sortTopo(newlist, order)
|
|
2090
|
+
: newlist;
|
|
2091
|
+
if (simplifyMerges && prune) sorted = await simplifyMergesOf(sorted);
|
|
2092
|
+
if (output) {
|
|
2093
|
+
await this.finishOutputWalk(output, t, sorted, shown, relevant, parse, {
|
|
2094
|
+
ancestry: wantAncestry,
|
|
2095
|
+
rewrite,
|
|
2096
|
+
});
|
|
2097
|
+
return;
|
|
2098
|
+
}
|
|
2099
|
+
candidates = sorted;
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
// get_revision_internal: --skip, -n, then (--boundary) the parents of the commits
|
|
2103
|
+
// shown that were not shown themselves
|
|
2104
|
+
const collectBoundary = this.boundary;
|
|
2105
|
+
/** SHOWN */
|
|
2106
|
+
const shownSet = new Set<number>();
|
|
2107
|
+
/** CHILD_SHOWN, and git's boundary_commits array in the order marked */
|
|
2108
|
+
const childShown = new Set<number>();
|
|
2109
|
+
const boundaryCommits: number[] = [];
|
|
2110
|
+
let count = 0;
|
|
2111
|
+
let skipped = 0;
|
|
2112
|
+
// git's -n 0 reads nothing more in a streaming walk; a limited walk is done before
|
|
2113
|
+
if (!none) {
|
|
2114
|
+
for await (const n of candidates) {
|
|
2115
|
+
const commit = await shown(n, wantAncestry);
|
|
774
2116
|
if (!commit) continue;
|
|
2117
|
+
if (wantAncestry && t.parsed(n)) {
|
|
2118
|
+
// the parents shown: as the walk holds them (simplified), rewritten past the
|
|
2119
|
+
// commits not shown (simplify_commit's rewrite_parents changes commit->parents)
|
|
2120
|
+
const held = t.parentList(n);
|
|
2121
|
+
if (rewrite) {
|
|
2122
|
+
commit.savedParents = held.map((p) => t.idOf(p));
|
|
2123
|
+
const rewritten = streamQueue
|
|
2124
|
+
? await rewriteStreaming(n, streamQueue)
|
|
2125
|
+
: rewriteParents(t, n, firstParentOnly, relevant);
|
|
2126
|
+
t.setParentList(n, rewritten);
|
|
2127
|
+
commit.parents = rewritten.map((p) => t.idOf(p));
|
|
2128
|
+
} else commit.parents = held.map((p) => t.idOf(p));
|
|
2129
|
+
}
|
|
775
2130
|
if (skipped < this.skip) {
|
|
776
2131
|
skipped++;
|
|
777
2132
|
continue;
|
|
778
2133
|
}
|
|
2134
|
+
shownSet.add(n);
|
|
2135
|
+
if (collectBoundary) {
|
|
2136
|
+
for (let k = 0, c = t.parentCount(n); k < c; k++) {
|
|
2137
|
+
const p = t.parent(n, k);
|
|
2138
|
+
if (shownSet.has(p) || childShown.has(p) || t.flag(p) & SHOWN) continue;
|
|
2139
|
+
childShown.add(p);
|
|
2140
|
+
boundaryCommits.push(p);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
779
2143
|
yield commit;
|
|
780
|
-
|
|
2144
|
+
// git log and rev-list free a shown commit's parents (cmd_log_walk, finish_commit):
|
|
2145
|
+
// a later rewrite passing through it finds none (not under --reverse, which reads
|
|
2146
|
+
// the whole walk first)
|
|
2147
|
+
if (rewrite && !this.reverse && !this.keepShownParents) t.setParentList(n, []);
|
|
2148
|
+
if (this.maxCount !== undefined && ++count >= this.maxCount) break;
|
|
781
2149
|
}
|
|
782
|
-
return;
|
|
783
2150
|
}
|
|
784
|
-
|
|
785
|
-
//
|
|
786
|
-
const
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
if (interestingCache >= 0 && !(t.flag(interestingCache) & UNINTERESTING)) return false;
|
|
793
|
-
for (const n of queue.items()) {
|
|
794
|
-
if (t.flag(n) & UNINTERESTING) continue;
|
|
795
|
-
interestingCache = n;
|
|
796
|
-
return false;
|
|
797
|
-
}
|
|
798
|
-
return true;
|
|
799
|
-
};
|
|
800
|
-
/** git's still_interesting */
|
|
801
|
-
const stillInteresting = (): number => {
|
|
802
|
-
const head = queue.peek();
|
|
803
|
-
if (head === undefined) return 0;
|
|
804
|
-
if (date <= t.date(head)) return SLOP;
|
|
805
|
-
if (!everybodyUninteresting()) return SLOP;
|
|
806
|
-
return slop - 1;
|
|
807
|
-
};
|
|
808
|
-
for (let n = queue.get(); n !== undefined; n = queue.get()) {
|
|
809
|
-
// what is shown is read again at the end: a limited walk does not keep raw commits
|
|
810
|
-
raw.delete(n);
|
|
811
|
-
if (n === interestingCache) interestingCache = -1;
|
|
812
|
-
if (this.sinceTime !== undefined && t.date(n) < this.sinceTime) t.mark(n, UNINTERESTING);
|
|
813
|
-
await processParents(n, queue);
|
|
814
|
-
if (t.flag(n) & UNINTERESTING) {
|
|
815
|
-
markParentsUninteresting(n);
|
|
816
|
-
slop = stillInteresting();
|
|
817
|
-
if (slop) continue;
|
|
818
|
-
break;
|
|
819
|
-
}
|
|
820
|
-
if (this.untilTime !== undefined && t.date(n) > this.untilTime) continue;
|
|
821
|
-
date = t.date(n);
|
|
822
|
-
newlist.push(n);
|
|
2151
|
+
if (!collectBoundary) return;
|
|
2152
|
+
// create_boundary_commit_list: each prepended (commit_list_insert), then sorted
|
|
2153
|
+
const boundaryList: number[] = [];
|
|
2154
|
+
const marked = new Set<number>();
|
|
2155
|
+
for (const n of boundaryCommits) {
|
|
2156
|
+
if (shownSet.has(n) || marked.has(n) || t.flag(n) & SHOWN) continue;
|
|
2157
|
+
marked.add(n);
|
|
2158
|
+
boundaryList.unshift(n);
|
|
823
2159
|
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
if (!(t.flag(n) & (UNINTERESTING | TREESAME))) updateTreesame(n);
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
raw.clear();
|
|
831
|
-
if (output) {
|
|
832
|
-
await this.finishOutputWalk(output, t, newlist, shown, relevant, parse);
|
|
833
|
-
return;
|
|
834
|
-
}
|
|
835
|
-
if (none) return;
|
|
836
|
-
for (const n of newlist) {
|
|
837
|
-
const commit = await shown(n);
|
|
2160
|
+
for (const n of await sortTopo(boundaryList, order)) {
|
|
2161
|
+
const id = t.idOf(n);
|
|
2162
|
+
const commit = await this.walkCommits.load(id);
|
|
838
2163
|
if (!commit) continue;
|
|
839
|
-
if (
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
2164
|
+
if (shallow.has(id)) commit.parents = [];
|
|
2165
|
+
const source = sources?.get(n);
|
|
2166
|
+
yield {
|
|
2167
|
+
...commit,
|
|
2168
|
+
id,
|
|
2169
|
+
boundary: true,
|
|
2170
|
+
...(source !== undefined ? { source } : {}),
|
|
2171
|
+
...sideOf(n),
|
|
2172
|
+
};
|
|
845
2173
|
}
|
|
846
2174
|
}
|
|
847
2175
|
|
|
@@ -854,104 +2182,317 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
854
2182
|
output: OutputWalk,
|
|
855
2183
|
t: RevTable,
|
|
856
2184
|
newlist: number[],
|
|
857
|
-
shown: (n: number,
|
|
2185
|
+
shown: (n: number, ancestry?: boolean) => Promise<LogResult | undefined>,
|
|
858
2186
|
relevant: (n: number) => boolean,
|
|
859
2187
|
parse: (n: number) => Promise<boolean>,
|
|
2188
|
+
mode: { ancestry: boolean; rewrite: boolean },
|
|
860
2189
|
): Promise<void> {
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
2190
|
+
const order = newlist;
|
|
2191
|
+
const firstParentOnly = this.firstParentOnly;
|
|
2192
|
+
/** Rewritten parents the walk never reached (only with `--first-parent`) */
|
|
2193
|
+
const unwalked = new Set<number>();
|
|
2194
|
+
for (const n of order) {
|
|
2195
|
+
const commit = await shown(n, mode.ancestry);
|
|
2196
|
+
if (!commit) continue;
|
|
2197
|
+
// the parents as the walk holds them (simplified), as git's commit->parents
|
|
2198
|
+
let parents = t.parsed(n) ? t.parentList(n).map((p) => t.idOf(p)) : commit.parents;
|
|
2199
|
+
let savedParents: ObjectId[] | undefined;
|
|
2200
|
+
if (mode.rewrite) {
|
|
2201
|
+
// the parents before rewriting, which `--full-diff` diffs against (save_parents)
|
|
2202
|
+
savedParents = parents;
|
|
2203
|
+
const rewritten = rewriteParents(t, n, firstParentOnly, relevant);
|
|
2204
|
+
for (const p of rewritten) if (!(t.flag(p) & SEEN)) unwalked.add(p);
|
|
2205
|
+
parents = rewritten.map((p) => t.idOf(p));
|
|
872
2206
|
}
|
|
873
|
-
const
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
2207
|
+
const { id, source, boundary: _boundary, left, patchSame, ...rest } = commit;
|
|
2208
|
+
// the parents git frees once the commit is shown (cmd_log_walk; --skip's are not)
|
|
2209
|
+
if (mode.rewrite && output.entries.length >= this.skip) t.setParentList(n, []);
|
|
2210
|
+
output.entries.push({
|
|
2211
|
+
id,
|
|
2212
|
+
commit: rest,
|
|
2213
|
+
parents,
|
|
2214
|
+
...(savedParents ? { savedParents } : {}),
|
|
2215
|
+
...(source !== undefined ? { source } : {}),
|
|
2216
|
+
...(left ? { left } : {}),
|
|
2217
|
+
...(patchSame ? { patchSame } : {}),
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
// graph.c's graph_is_interesting asks get_commit_action about a parent: one the walk
|
|
2221
|
+
// never reached has no TREESAME or SHOWN flag, so only the filters can hide it (with
|
|
2222
|
+
// `--first-parent` a merge whose first parent was rewritten away keeps a lane for it)
|
|
2223
|
+
if (unwalked.size > 0) {
|
|
2224
|
+
output.unwalkedShown = new Set();
|
|
2225
|
+
for (const p of unwalked) {
|
|
2226
|
+
if ((await parse(p)) && (await shown(p))) output.unwalkedShown.add(t.idOf(p));
|
|
887
2227
|
}
|
|
888
2228
|
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
/**
|
|
2232
|
+
* line-log.c's line_log_init: the one commit the log starts from (check_single_commit),
|
|
2233
|
+
* the `-L` ranges parsed against it, and the walk that follows them
|
|
2234
|
+
*/
|
|
2235
|
+
private async startLineLog(pending: PendingCommit[]): Promise<void> {
|
|
2236
|
+
let found: PendingCommit | undefined;
|
|
2237
|
+
for (const e of pending) {
|
|
2238
|
+
if (e.exclude) continue;
|
|
2239
|
+
const name = e.name ?? e.id;
|
|
2240
|
+
if (!(await this.readCommitHeader(e.id).catch(() => undefined))) {
|
|
2241
|
+
throw lineLogDeath(`Non commit ${name}?`);
|
|
901
2242
|
}
|
|
902
|
-
|
|
2243
|
+
if (found) {
|
|
2244
|
+
throw lineLogDeath(
|
|
2245
|
+
`More than one commit to dig from: ${name} and ${found.name ?? found.id}?`,
|
|
2246
|
+
);
|
|
2247
|
+
}
|
|
2248
|
+
found = e;
|
|
2249
|
+
}
|
|
2250
|
+
if (!found) throw lineLogDeath("No commit specified?");
|
|
2251
|
+
const host = this.lineLogHost();
|
|
2252
|
+
const tree = await host.treeOf(found.id);
|
|
2253
|
+
const drivers = new DiffCommand(this._workingCopy)
|
|
2254
|
+
.setOldTree(tree)
|
|
2255
|
+
.setNewTree(tree)
|
|
2256
|
+
.shareReadsOf(this)
|
|
2257
|
+
.setOptions(this.lineLogDiffOptions());
|
|
2258
|
+
const ranges = await parseLineRanges(this.lineRangeArgs, {
|
|
2259
|
+
blob: async (path) => {
|
|
2260
|
+
const e = await this.treeEntryAt(tree, path);
|
|
2261
|
+
if (!e) return undefined;
|
|
2262
|
+
// a submodule reads as its commit line (diff_populate_filespec)
|
|
2263
|
+
if ((e.mode & 0o170000) === 0o160000) return { ...e, data: gitlinkText(e.id) };
|
|
2264
|
+
const data = await this.readBlob(e.id);
|
|
2265
|
+
if (!data) throw lineLogDeath(`Cannot read blob ${e.id}`);
|
|
2266
|
+
return { ...e, data };
|
|
2267
|
+
},
|
|
2268
|
+
findFunction: async (path) => (await drivers.driverOf(path))?.findFunction,
|
|
2269
|
+
});
|
|
2270
|
+
this.lineLog = new LineLogWalk(host, this.compatibility, this.firstParentOnly);
|
|
2271
|
+
this.lineLog.start(found.id, ranges);
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
/** The diff options of `-L`'s diffs: the builtin drivers of the version followed */
|
|
2275
|
+
private lineLogDiffOptions(): DiffTextOptions {
|
|
2276
|
+
return {
|
|
2277
|
+
...this.diffOptions,
|
|
2278
|
+
driverCompatibility: this.diffOptions.driverCompatibility ?? this.compatibility,
|
|
2279
|
+
};
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
/** The entry at a path of a tree (its mode canonical), undefined when none */
|
|
2283
|
+
private async treeEntryAt(
|
|
2284
|
+
tree: ObjectId,
|
|
2285
|
+
path: string,
|
|
2286
|
+
): Promise<{ id: ObjectId; mode: number } | undefined> {
|
|
2287
|
+
const parts = path.split("/");
|
|
2288
|
+
let cur = tree;
|
|
2289
|
+
for (let i = 0; i < parts.length; i++) {
|
|
2290
|
+
const e = await this.entryOf(cur, encodeGitPath(parts[i] as string));
|
|
2291
|
+
if (!e) return undefined;
|
|
2292
|
+
if (i === parts.length - 1) return { id: e.id, mode: canonTreeMode(e.mode) };
|
|
2293
|
+
if (!isTreeMode(e.mode)) return undefined;
|
|
2294
|
+
cur = e.id;
|
|
2295
|
+
}
|
|
2296
|
+
return undefined;
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
/** What `-L`'s walk reads: trees, entries, blobs, and renames as queue_diffs finds them */
|
|
2300
|
+
private lineLogHost(): LineLogHost {
|
|
2301
|
+
const o = this.diffOptions;
|
|
2302
|
+
let detect =
|
|
2303
|
+
o.findRenames !== undefined
|
|
2304
|
+
? o.findRenames !== false
|
|
2305
|
+
: (renamesValue(configValue(this.workingCopy, "diff.renames")) ?? true) !== false;
|
|
2306
|
+
if (o.findCopies !== undefined && o.findCopies !== false) detect = true;
|
|
2307
|
+
const score =
|
|
2308
|
+
typeof o.findRenames === "string"
|
|
2309
|
+
? renameScoreOption(o.findRenames, "find-renames")
|
|
2310
|
+
: undefined;
|
|
2311
|
+
const limit = Number(configValue(this.workingCopy, "diff.renameLimit"));
|
|
2312
|
+
const renameLimit =
|
|
2313
|
+
Number.isFinite(limit) && configValue(this.workingCopy, "diff.renameLimit") !== undefined
|
|
2314
|
+
? limit
|
|
2315
|
+
: DEFAULT_RENAME_LIMIT;
|
|
2316
|
+
const blob = async (id: ObjectId): Promise<Uint8Array> => {
|
|
2317
|
+
const data = await this.readBlob(id);
|
|
2318
|
+
if (!data) throw lineLogDeath(`Cannot read blob ${id}`);
|
|
2319
|
+
return data;
|
|
2320
|
+
};
|
|
2321
|
+
return {
|
|
2322
|
+
treeOf: async (id) => {
|
|
2323
|
+
const header = await this.readCommitHeader(id, await this.objectReplacements());
|
|
2324
|
+
if (!header) throw new GitApiError(`could not parse commit ${id}`);
|
|
2325
|
+
return header.tree;
|
|
2326
|
+
},
|
|
2327
|
+
entry: (tree, path) => this.treeEntryAt(tree, path),
|
|
2328
|
+
blob,
|
|
2329
|
+
...(hasPickaxe(o) || o.diffFilter !== undefined
|
|
2330
|
+
? {
|
|
2331
|
+
diffcore: async (pairs: LineLogPair[]) => {
|
|
2332
|
+
const entries = new Map<DiffEntry, LineLogPair>();
|
|
2333
|
+
for (const pair of pairs) entries.set(lineLogEntry(pair), pair);
|
|
2334
|
+
const kept = await new DiffCommand(this._workingCopy)
|
|
2335
|
+
.shareReadsOf(this)
|
|
2336
|
+
.setOptions(this.lineLogDiffOptions())
|
|
2337
|
+
.filterQueue([...entries.keys()]);
|
|
2338
|
+
const out: LineLogPair[] = [];
|
|
2339
|
+
for (const e of kept) {
|
|
2340
|
+
const pair = entries.get(e) ?? pairs.find((p) => p.two.path === e.newPath);
|
|
2341
|
+
if (pair) out.push(pair);
|
|
2342
|
+
}
|
|
2343
|
+
return out;
|
|
2344
|
+
},
|
|
2345
|
+
}
|
|
2346
|
+
: {}),
|
|
2347
|
+
...(detect
|
|
2348
|
+
? {
|
|
2349
|
+
renames: async (
|
|
2350
|
+
parentTree: ObjectId,
|
|
2351
|
+
tree: ObjectId,
|
|
2352
|
+
created: { path: string; id: ObjectId; mode: number }[],
|
|
2353
|
+
) => {
|
|
2354
|
+
const before = await this.flatTree(parentTree);
|
|
2355
|
+
const after = await this.flatTree(tree);
|
|
2356
|
+
const sources = [...before]
|
|
2357
|
+
.filter(([path]) => !after.has(path))
|
|
2358
|
+
.map(([path, e]) => ({ path, mode: e.mode, id: e.id }));
|
|
2359
|
+
if (sources.length === 0) return [];
|
|
2360
|
+
const pairs = await detectRenames(
|
|
2361
|
+
sources,
|
|
2362
|
+
created.map((c) => ({ path: c.path, mode: c.mode, id: c.id })),
|
|
2363
|
+
{
|
|
2364
|
+
load: async (c) =>
|
|
2365
|
+
(c.mode & 0o170000) === 0o160000 ? gitlinkText(c.id) : blob(c.id),
|
|
2366
|
+
renameLimit,
|
|
2367
|
+
...(score !== undefined ? { minimumScore: score } : {}),
|
|
2368
|
+
},
|
|
2369
|
+
);
|
|
2370
|
+
const out: {
|
|
2371
|
+
from: { path: string; id: ObjectId; mode: number };
|
|
2372
|
+
to: string;
|
|
2373
|
+
score: number;
|
|
2374
|
+
}[] = [];
|
|
2375
|
+
for (const pair of pairs) {
|
|
2376
|
+
const from = before.get(pair.from);
|
|
2377
|
+
if (!from) continue;
|
|
2378
|
+
out.push({
|
|
2379
|
+
from: { path: pair.from, id: from.id, mode: canonTreeMode(from.mode) },
|
|
2380
|
+
to: pair.to,
|
|
2381
|
+
score: scorePercent(pair.score),
|
|
2382
|
+
});
|
|
2383
|
+
}
|
|
2384
|
+
return out;
|
|
2385
|
+
},
|
|
2386
|
+
}
|
|
2387
|
+
: {}),
|
|
903
2388
|
};
|
|
904
|
-
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
/**
|
|
2392
|
+
* The walk's commits under `-L` without parents rewritten, sorted topologically: each
|
|
2393
|
+
* followed in turn (git's simplify_commit), shown when its diff touched the ranges and the
|
|
2394
|
+
* other filters keep it, with the parents a merge kept (one when a parent took it all).
|
|
2395
|
+
*/
|
|
2396
|
+
private async finishLineLogWalk(
|
|
2397
|
+
output: OutputWalk,
|
|
2398
|
+
t: RevTable,
|
|
2399
|
+
order: number[],
|
|
2400
|
+
shown: (n: number, ancestry?: boolean) => Promise<LogResult | undefined>,
|
|
2401
|
+
): Promise<void> {
|
|
2402
|
+
const ll = this.lineLog as LineLogWalk;
|
|
2403
|
+
for (const n of order) {
|
|
2404
|
+
const id = t.idOf(n);
|
|
2405
|
+
if (!(await ll.process(id, lineLogParentIds(t, n)))) continue;
|
|
2406
|
+
const commit = await shown(n);
|
|
2407
|
+
if (!commit) continue;
|
|
2408
|
+
const { id: _id, source, boundary: _boundary, left, patchSame, ...rest } = commit;
|
|
2409
|
+
output.entries.push({
|
|
2410
|
+
id,
|
|
2411
|
+
commit: rest,
|
|
2412
|
+
parents: ll.parentsOf(id) ?? commit.parents,
|
|
2413
|
+
...(source !== undefined ? { source } : {}),
|
|
2414
|
+
...(left ? { left } : {}),
|
|
2415
|
+
...(patchSame ? { patchSame } : {}),
|
|
2416
|
+
});
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
/**
|
|
2421
|
+
* line-log.c's line_log_filter: every commit of the sorted list followed, those whose diff
|
|
2422
|
+
* touched no range marked TREESAME (a merge one parent took whole left with that parent),
|
|
2423
|
+
* the others kept with their parents rewritten past TREESAME commits
|
|
2424
|
+
* (line_log_rewrite_one); `unwalked` the parents rewritten to that the walk never reached
|
|
2425
|
+
*/
|
|
2426
|
+
private async lineLogFilter(
|
|
2427
|
+
t: RevTable,
|
|
2428
|
+
order: number[],
|
|
2429
|
+
): Promise<{ kept: number[]; unwalked: Set<number> }> {
|
|
2430
|
+
const ll = this.lineLog as LineLogWalk;
|
|
2431
|
+
const kept: number[] = [];
|
|
2432
|
+
for (const n of order) {
|
|
2433
|
+
const id = t.idOf(n);
|
|
2434
|
+
if (await ll.process(id, lineLogParentIds(t, n))) kept.push(n);
|
|
2435
|
+
else t.mark(n, TREESAME);
|
|
2436
|
+
const narrowed = ll.parentsOf(id);
|
|
2437
|
+
if (narrowed)
|
|
2438
|
+
t.setParentList(
|
|
2439
|
+
n,
|
|
2440
|
+
narrowed.map((p) => t.lookup(p)),
|
|
2441
|
+
);
|
|
2442
|
+
}
|
|
2443
|
+
/** line_log_rewrite_one */
|
|
905
2444
|
const rewriteOne = (start: number): number | undefined => {
|
|
906
2445
|
let p = start;
|
|
907
2446
|
for (;;) {
|
|
908
|
-
|
|
909
|
-
if (!(t.flag(p) & TREESAME)) return p;
|
|
910
|
-
if (
|
|
911
|
-
|
|
912
|
-
if (next === undefined) return p;
|
|
913
|
-
p = next;
|
|
2447
|
+
const parents = t.parsed(p) ? t.parentList(p) : [];
|
|
2448
|
+
if (parents.length > 1 || t.flag(p) & UNINTERESTING || !(t.flag(p) & TREESAME)) return p;
|
|
2449
|
+
if (parents.length === 0) return undefined;
|
|
2450
|
+
p = parents[0] as number;
|
|
914
2451
|
}
|
|
915
2452
|
};
|
|
916
|
-
const prune = this.paths.length > 0 || this.excludePaths.length > 0;
|
|
917
|
-
/** Rewritten parents the walk never reached (only with `--first-parent`) */
|
|
918
2453
|
const unwalked = new Set<number>();
|
|
919
|
-
for (const n of
|
|
920
|
-
const
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
savedParents = [];
|
|
927
|
-
for (let k = 0, c = t.parentCount(n); k < c; k++) savedParents.push(t.idOf(t.parent(n, k)));
|
|
928
|
-
const ids: ObjectId[] = [];
|
|
929
|
-
for (let k = 0, c = t.parentCount(n); k < c; k++) {
|
|
930
|
-
const p = rewriteOne(t.parent(n, k));
|
|
931
|
-
if (p === undefined) continue;
|
|
932
|
-
if (!(t.flag(p) & SEEN)) unwalked.add(p);
|
|
933
|
-
const id = t.idOf(p);
|
|
934
|
-
// remove_duplicate_parents
|
|
935
|
-
if (!ids.includes(id)) ids.push(id);
|
|
936
|
-
}
|
|
937
|
-
parents = ids;
|
|
2454
|
+
for (const n of kept) {
|
|
2455
|
+
const rewritten: number[] = [];
|
|
2456
|
+
for (const q of t.parentList(n)) {
|
|
2457
|
+
const p = rewriteOne(q);
|
|
2458
|
+
if (p === undefined) continue;
|
|
2459
|
+
if (!(t.flag(p) & SEEN)) unwalked.add(p);
|
|
2460
|
+
if (!rewritten.includes(p)) rewritten.push(p);
|
|
938
2461
|
}
|
|
939
|
-
|
|
940
|
-
output.entries.push({ id, commit: rest, parents, ...(savedParents ? { savedParents } : {}) });
|
|
2462
|
+
t.setParentList(n, rewritten);
|
|
941
2463
|
}
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
2464
|
+
return { kept, unwalked };
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
/**
|
|
2468
|
+
* setup_revisions' and cmd_log_init_finish's refusals of `-L`: the diff formats it cannot
|
|
2469
|
+
* show (2.43: anything but `-p` and `-s`), then a pathspec
|
|
2470
|
+
*/
|
|
2471
|
+
private checkLineLogOptions(options: LogOutputOptions): void {
|
|
2472
|
+
const o = options;
|
|
2473
|
+
if (this.compatibility === "2.43") {
|
|
2474
|
+
if (
|
|
2475
|
+
o.stat ||
|
|
2476
|
+
o.shortstat ||
|
|
2477
|
+
o.numstat ||
|
|
2478
|
+
o.nameOnly ||
|
|
2479
|
+
o.nameStatus ||
|
|
2480
|
+
o.summary ||
|
|
2481
|
+
o.check
|
|
2482
|
+
) {
|
|
2483
|
+
throw lineLogDeath("-L does not yet support diff formats besides -p and -s");
|
|
949
2484
|
}
|
|
2485
|
+
} else if (o.stat || o.shortstat || o.numstat || o.check || o.fullDiff) {
|
|
2486
|
+
throw lineLogDeath("-L does not yet support the requested diff format");
|
|
2487
|
+
}
|
|
2488
|
+
if (this.paths.length > 0 || this.excludePaths.length > 0) {
|
|
2489
|
+
throw lineLogDeath("-L<range>:<file> cannot be used with pathspec");
|
|
950
2490
|
}
|
|
951
2491
|
}
|
|
952
2492
|
|
|
953
2493
|
/**
|
|
954
|
-
* The log printed as `git log <options>` prints it to a pipe (no colors
|
|
2494
|
+
* The log printed as `git log <options>` prints it to a pipe (no pager; colors only when
|
|
2495
|
+
* `setDiffOptions({ color })` or `color.ui`/`color.diff` say `always`): the
|
|
955
2496
|
* walk set up by this command (start points, ranges, paths, `-n`, `--skip`, filters), each
|
|
956
2497
|
* commit in the format asked for, with the graph and the diffs asked for. See
|
|
957
2498
|
* {@link LogOutputOptions}.
|
|
@@ -969,44 +2510,99 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
969
2510
|
/** {@link callText} as bytes (messages and file contents that are not UTF-8 kept as they are). */
|
|
970
2511
|
async callBytes(options: LogOutputOptions = {}): Promise<Uint8Array> {
|
|
971
2512
|
// one operation for the worktree: its attributes files (diff drivers) and configuration
|
|
972
|
-
// are read once for every commit's diff, as git keeps its attribute stack
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
return this.printLog(options);
|
|
2513
|
+
// are read once for every commit's diff, as git keeps its attribute stack (a bare
|
|
2514
|
+
// repository's working copy has none)
|
|
2515
|
+
return this.inOneOperation(() => this.printLog(options));
|
|
976
2516
|
}
|
|
977
2517
|
|
|
978
2518
|
private async printLog(options: LogOutputOptions): Promise<Uint8Array> {
|
|
2519
|
+
const result = await this.printLogOutput(options);
|
|
2520
|
+
if (this.logConfig) await this.reportMailmapErrors(options, result.length > 0);
|
|
2521
|
+
return result;
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
private async printLogOutput(options: LogOutputOptions): Promise<Uint8Array> {
|
|
2525
|
+
const reverse = !!options.reverse || this.reverse;
|
|
2526
|
+
await this.checkReflogWalkOptions(options);
|
|
979
2527
|
// revision.c's setup_revisions: the graph cannot be reversed
|
|
980
|
-
if (options.graph &&
|
|
2528
|
+
if (options.graph && reverse) {
|
|
981
2529
|
throw new IncompatibleOptionsError(
|
|
982
2530
|
["--graph", "--reverse"],
|
|
983
2531
|
"options '--graph' and '--reverse' cannot be used together",
|
|
984
2532
|
);
|
|
985
2533
|
}
|
|
2534
|
+
// git log and git show read grep_config before anything else (a bad grep.patternType
|
|
2535
|
+
// dies there); the walk alone (rev-list, bisect's own walks) reads it only to grep
|
|
2536
|
+
if (this.logConfig) this.configuredPatternType();
|
|
2537
|
+
await this.preparePickaxe();
|
|
2538
|
+
// --use-mailmap/--no-mailmap: what --author/--committer match too
|
|
2539
|
+
if (options.mailmap !== undefined) this.useMailmap ??= options.mailmap;
|
|
2540
|
+
const colors = this.readColors();
|
|
986
2541
|
const host = this.outputHost(options);
|
|
987
2542
|
const paths = [...this.paths];
|
|
2543
|
+
// -L: the walk is sorted, its commits followed before the first is shown
|
|
2544
|
+
const lineLog = this.lineRangeArgs.length > 0;
|
|
988
2545
|
// the pathspec as git holds it: the excluded paths as `:(exclude)` elements, `.` when
|
|
989
2546
|
// every element excludes
|
|
990
2547
|
const pathspec = [...paths, ...this.excludePaths.map((p) => `:(exclude)${p}`)];
|
|
991
2548
|
if (paths.length === 0 && this.excludePaths.length > 0) pathspec.push(".");
|
|
992
|
-
const printer = new LogPrinter(
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
2549
|
+
const printer = new LogPrinter(
|
|
2550
|
+
host,
|
|
2551
|
+
{ ...options, diff: { ...options.diff, ...this.diffOptions } },
|
|
2552
|
+
{
|
|
2553
|
+
interesting: (id) => shownIds.has(id) || unwalkedShown.has(id),
|
|
2554
|
+
firstParentOnly: this.firstParentOnly,
|
|
2555
|
+
paths: pathspec,
|
|
2556
|
+
...this.revisionMarks(),
|
|
2557
|
+
...(colors ? { colors } : {}),
|
|
2558
|
+
...(lineLog ? { lineLog: this.compatibility } : {}),
|
|
2559
|
+
},
|
|
2560
|
+
);
|
|
2561
|
+
if (lineLog) this.checkLineLogOptions(options);
|
|
2562
|
+
const follow = printer.followsPath;
|
|
2563
|
+
const countsShown = !printer.alwaysShowHeader;
|
|
998
2564
|
const graph = !!options.graph;
|
|
999
|
-
const topo = graph ||
|
|
2565
|
+
const topo = graph || lineLog;
|
|
2566
|
+
const boundary = !!options.boundary || this.boundary;
|
|
2567
|
+
if (graph && boundary) {
|
|
2568
|
+
// graph.c draws boundary commits as `o` in columns of their own: not reproduced
|
|
2569
|
+
throw new NotImplementedError("git log --graph --boundary");
|
|
2570
|
+
}
|
|
2571
|
+
// the walk's order, sources and boundary for the output (it reverses the list itself)
|
|
2572
|
+
const saved = { order: this.order, reverse: this.reverse, boundary: this.boundary };
|
|
2573
|
+
const saveSource = this.source;
|
|
2574
|
+
if (options.authorDateOrder) this.order = "author-date";
|
|
2575
|
+
else if (options.dateOrder) this.order = "date";
|
|
2576
|
+
else if (options.topoOrder) this.order ??= "topo";
|
|
2577
|
+
this.reverse = false;
|
|
2578
|
+
this.boundary = boundary;
|
|
2579
|
+
if (options.source || printer.wantsSource) this.source = true;
|
|
1000
2580
|
const maxCount = this.maxCount;
|
|
1001
2581
|
const skip = this.skip;
|
|
1002
2582
|
const simplifyHistory = this.simplifyHistory;
|
|
1003
2583
|
if (printer.fullHistory) this.simplifyHistory = false;
|
|
2584
|
+
// --parents: rewritten parents (the header's ids, %P)
|
|
2585
|
+
if (options.parents) this.rewriteParents = true;
|
|
2586
|
+
// --simplify-by-decoration keeps the commits git log's decoration filter decorates
|
|
2587
|
+
this.decorationLoader = () =>
|
|
2588
|
+
host.decorations({
|
|
2589
|
+
decorate: "short",
|
|
2590
|
+
...(options.decorateRefs ? { decorateRefs: options.decorateRefs } : {}),
|
|
2591
|
+
...(options.decorateRefsExclude
|
|
2592
|
+
? { decorateRefsExclude: options.decorateRefsExclude }
|
|
2593
|
+
: {}),
|
|
2594
|
+
...(options.clearDecorations ? { clearDecorations: true } : {}),
|
|
2595
|
+
});
|
|
2596
|
+
this.keepShownParents = reverse;
|
|
1004
2597
|
// --follow walks every commit: its path changes as it goes
|
|
1005
2598
|
if (follow) this.paths = [];
|
|
1006
2599
|
const shownIds = new Set<ObjectId>();
|
|
1007
2600
|
const unwalkedShown = new Set<ObjectId>();
|
|
1008
2601
|
let entries: LogOutputEntry[];
|
|
1009
|
-
if (
|
|
2602
|
+
if (this.reflogWalkNames !== undefined) {
|
|
2603
|
+
entries = await this.reflogEntries(this.reflogWalkNames);
|
|
2604
|
+
for (const e of entries) shownIds.add(e.id);
|
|
2605
|
+
} else if (topo) {
|
|
1010
2606
|
this.outputWalk = { topo, rewrite: graph, entries: [] };
|
|
1011
2607
|
for await (const _ of await this.call()) {
|
|
1012
2608
|
// the output walk collects its commits
|
|
@@ -1016,23 +2612,50 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
1016
2612
|
this.outputWalk = undefined;
|
|
1017
2613
|
for (const e of entries) shownIds.add(e.id);
|
|
1018
2614
|
entries = entries.slice(skip);
|
|
1019
|
-
|
|
2615
|
+
// the commits shown count (--follow, pickaxe, --diff-filter): the print loop stops
|
|
2616
|
+
if (maxCount !== undefined && !countsShown) entries = entries.slice(0, Math.max(maxCount, 0));
|
|
1020
2617
|
if (maxCount !== undefined && maxCount <= 0) entries = [];
|
|
2618
|
+
} else if (!reverse) {
|
|
2619
|
+
// cmd_log_walk: each commit shown as the walk gives it; --follow, pickaxe and
|
|
2620
|
+
// --diff-filter count the commits shown, not those walked (log.c gives max_count back
|
|
2621
|
+
// for a commit log_tree_commit did not show), so the walk stops once enough are shown
|
|
2622
|
+
if (countsShown) this.maxCount = undefined;
|
|
2623
|
+
await printer.start();
|
|
2624
|
+
try {
|
|
2625
|
+
if (maxCount === undefined || maxCount > 0) {
|
|
2626
|
+
let shownCount = 0;
|
|
2627
|
+
for await (const c of await this.call()) {
|
|
2628
|
+
const entry = outputEntry(c);
|
|
2629
|
+
const shown = await printer.showCommit(entry, []);
|
|
2630
|
+
if (shown && countsShown && maxCount !== undefined && ++shownCount >= maxCount) break;
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
} finally {
|
|
2634
|
+
this.maxCount = maxCount;
|
|
2635
|
+
this.simplifyHistory = simplifyHistory;
|
|
2636
|
+
this.order = saved.order;
|
|
2637
|
+
this.reverse = saved.reverse;
|
|
2638
|
+
this.boundary = saved.boundary;
|
|
2639
|
+
this.source = saveSource;
|
|
2640
|
+
if (follow) this.paths = paths;
|
|
2641
|
+
}
|
|
2642
|
+
return printer.result();
|
|
1021
2643
|
} else {
|
|
1022
|
-
// --
|
|
1023
|
-
if (follow && !options.reverse) this.maxCount = undefined;
|
|
2644
|
+
// --reverse: the newest commits walked, reversed, then shown
|
|
1024
2645
|
entries = [];
|
|
1025
2646
|
for await (const c of await this.call()) {
|
|
1026
|
-
|
|
1027
|
-
entries.push({ id, commit, parents: c.parents });
|
|
2647
|
+
entries.push(outputEntry(c));
|
|
1028
2648
|
}
|
|
1029
|
-
if (follow) this.maxCount = maxCount;
|
|
1030
2649
|
}
|
|
1031
2650
|
this.simplifyHistory = simplifyHistory;
|
|
1032
|
-
|
|
2651
|
+
this.order = saved.order;
|
|
2652
|
+
this.reverse = saved.reverse;
|
|
2653
|
+
this.boundary = saved.boundary;
|
|
2654
|
+
this.source = saveSource;
|
|
2655
|
+
if (follow && reverse && maxCount !== undefined) {
|
|
1033
2656
|
entries = entries.slice(0, Math.max(maxCount, 0));
|
|
1034
2657
|
}
|
|
1035
|
-
if (
|
|
2658
|
+
if (reverse) entries.reverse();
|
|
1036
2659
|
await printer.start();
|
|
1037
2660
|
if (graph) {
|
|
1038
2661
|
const parentsOf = new Map(entries.map((e) => [e.id, e.parents]));
|
|
@@ -1041,7 +2664,7 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
1041
2664
|
let count = 0;
|
|
1042
2665
|
// -n 0: nothing is walked
|
|
1043
2666
|
if (maxCount !== undefined && maxCount <= 0) entries = [];
|
|
1044
|
-
const countShown =
|
|
2667
|
+
const countShown = countsShown && maxCount !== undefined && !reverse;
|
|
1045
2668
|
for (let k = 0; k < entries.length; k++) {
|
|
1046
2669
|
const e = entries[k] as LogOutputEntry;
|
|
1047
2670
|
const lookahead = entries.slice(k + 1, k + 3).map((x) => x.id);
|
|
@@ -1052,6 +2675,303 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
1052
2675
|
return printer.result();
|
|
1053
2676
|
}
|
|
1054
2677
|
|
|
2678
|
+
/**
|
|
2679
|
+
* The refs' decorations (log-tree.c's load_ref_decorations): with `logOptions`, git log's
|
|
2680
|
+
* decoration filter; without, every ref and HEAD (get_name_decoration's own load).
|
|
2681
|
+
*/
|
|
2682
|
+
private async refDecorations(
|
|
2683
|
+
logOptions?: LoadRefDecorationsOptions["logOptions"],
|
|
2684
|
+
): Promise<RefDecorations> {
|
|
2685
|
+
const replacements = await this.objectReplacements();
|
|
2686
|
+
const shallow = (await this.refsStore.getShallow?.().catch(() => undefined)) ?? [];
|
|
2687
|
+
const environment = hostEnvironmentOf(this._workingCopy);
|
|
2688
|
+
const objects = this._workingCopy.history?.objects;
|
|
2689
|
+
const tags = this.tagsStore;
|
|
2690
|
+
return loadRefDecorations({
|
|
2691
|
+
refs: this.refsStore,
|
|
2692
|
+
...(tags ? { tags } : {}),
|
|
2693
|
+
...(environment?.replaceRefBase !== undefined
|
|
2694
|
+
? { replaceRefBase: environment.replaceRefBase }
|
|
2695
|
+
: {}),
|
|
2696
|
+
useReplaceRefs: this.useReplaceRefs(),
|
|
2697
|
+
grafted: new Set([...(replacements?.grafts.keys() ?? []), ...shallow]),
|
|
2698
|
+
...(objects ? { hasObject: (id: ObjectId) => objects.has(id) } : {}),
|
|
2699
|
+
...(logOptions ? { logOptions } : {}),
|
|
2700
|
+
});
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
/** The mailmap, read once for the walk's filters and the output alike. */
|
|
2704
|
+
private loadedMailmap(): Promise<Mailmap> {
|
|
2705
|
+
this.mailmapLoad ??= this.readMailmap((line) => this.mailmapErrors.push(line));
|
|
2706
|
+
return this.mailmapLoad;
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2709
|
+
/**
|
|
2710
|
+
* git's `error:` lines of reading the mailmap (a `mailmap.blob` that is no blob), as git
|
|
2711
|
+
* log prints them: once when it reads the mailmap for the log (`log.mailmap`,
|
|
2712
|
+
* `--use-mailmap`), once more when a user format maps an identity (`%aN`, pretty.c's own
|
|
2713
|
+
* read) of a commit it shows.
|
|
2714
|
+
*/
|
|
2715
|
+
private async reportMailmapErrors(options: LogOutputOptions, shown: boolean): Promise<void> {
|
|
2716
|
+
const forLog =
|
|
2717
|
+
options.mailmap ?? this.useMailmap ?? configBool(this.workingCopy, "log.mailmap", true);
|
|
2718
|
+
const pretty = options.pretty ?? configValue(this.workingCopy, "format.pretty") ?? "";
|
|
2719
|
+
const user = /^t?format:/.test(pretty) || (pretty.includes("%") && !options.oneline);
|
|
2720
|
+
const forFormat = shown && user && /%[ac][NEL]/.test(pretty);
|
|
2721
|
+
const times = (forLog ? 1 : 0) + (forFormat ? 1 : 0);
|
|
2722
|
+
if (times === 0) return;
|
|
2723
|
+
await this.loadedMailmap();
|
|
2724
|
+
for (let k = 0; k < times; k++) this.outputWarnings.push(...this.mailmapErrors);
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
/**
|
|
2728
|
+
* `git show`'s output of objects one at a time (builtin/log.c's cmd_show without a walk):
|
|
2729
|
+
* one printer for every object, so commits, tags and trees share git's `shown_one`
|
|
2730
|
+
* separators. Used by {@link ShowCommand}; the paths and filters set on this command
|
|
2731
|
+
* decide which commits show, as revision.c's no-walk mode simplifies each one.
|
|
2732
|
+
*
|
|
2733
|
+
* @internal
|
|
2734
|
+
*/
|
|
2735
|
+
async showSession(options: LogOutputOptions): Promise<ShowSession> {
|
|
2736
|
+
this.checkCallable();
|
|
2737
|
+
this.setCallable(false);
|
|
2738
|
+
if (options.graph) {
|
|
2739
|
+
throw new IncompatibleOptionsError(
|
|
2740
|
+
["--no-walk", "--graph"],
|
|
2741
|
+
"fatal: options '--no-walk' and '--graph' cannot be used together",
|
|
2742
|
+
);
|
|
2743
|
+
}
|
|
2744
|
+
if (this.logConfig) this.configuredPatternType();
|
|
2745
|
+
await this.preparePickaxe();
|
|
2746
|
+
if (options.mailmap !== undefined) this.useMailmap ??= options.mailmap;
|
|
2747
|
+
readDiffSubmoduleConfig(this.workingCopy);
|
|
2748
|
+
const colors = this.readColors();
|
|
2749
|
+
this.activeFilter = await this.buildCommitFilter();
|
|
2750
|
+
const host = this.outputHost(options);
|
|
2751
|
+
const pathspec = [...this.paths, ...this.excludePaths.map((p) => `:(exclude)${p}`)];
|
|
2752
|
+
if (this.paths.length === 0 && this.excludePaths.length > 0) pathspec.push(".");
|
|
2753
|
+
const printer = new LogPrinter(
|
|
2754
|
+
host,
|
|
2755
|
+
{ ...options, diff: { ...options.diff, ...this.diffOptions } },
|
|
2756
|
+
{
|
|
2757
|
+
interesting: () => true,
|
|
2758
|
+
firstParentOnly: this.firstParentOnly,
|
|
2759
|
+
paths: pathspec,
|
|
2760
|
+
...(colors ? { colors } : {}),
|
|
2761
|
+
},
|
|
2762
|
+
);
|
|
2763
|
+
await printer.start();
|
|
2764
|
+
const shown = new Set<ObjectId>();
|
|
2765
|
+
const limited = pathspec.length > 0;
|
|
2766
|
+
const commit = async (id: ObjectId): Promise<boolean> => {
|
|
2767
|
+
// get_revision's SHOWN flag: a commit named again is not shown again
|
|
2768
|
+
if (shown.has(id)) return false;
|
|
2769
|
+
const loaded = await this.walkCommits.load(id);
|
|
2770
|
+
if (!loaded) throw new GitApiError(`fatal: bad object ${id}`);
|
|
2771
|
+
// try_to_simplify_commit, then get_commit_action: a commit TREESAME to a parent (a
|
|
2772
|
+
// root without the paths) is ignored
|
|
2773
|
+
if (limited && (await this.treesameForShow(id, loaded, printer.fullHistory))) return false;
|
|
2774
|
+
const filter = this.activeFilter;
|
|
2775
|
+
if (filter) {
|
|
2776
|
+
const view: FilteredCommit = {
|
|
2777
|
+
id,
|
|
2778
|
+
parentCount: loaded.parents.length,
|
|
2779
|
+
commitTime: loaded.committer.timestamp,
|
|
2780
|
+
raw: async () => this.rawCommit(id),
|
|
2781
|
+
commit: async () => loaded,
|
|
2782
|
+
};
|
|
2783
|
+
if (!(await filter.include(view))) return false;
|
|
2784
|
+
}
|
|
2785
|
+
shown.add(id);
|
|
2786
|
+
await printer.showCommit({ id, commit: loaded, parents: loaded.parents }, []);
|
|
2787
|
+
return true;
|
|
2788
|
+
};
|
|
2789
|
+
const run = <T>(fn: () => Promise<T>): Promise<T> => {
|
|
2790
|
+
const worktree = this.worktreeAccess;
|
|
2791
|
+
return worktree?.batch ? worktree.batch(fn) : fn();
|
|
2792
|
+
};
|
|
2793
|
+
return {
|
|
2794
|
+
commit: (id) => run(() => commit(id)),
|
|
2795
|
+
separate: () => printer.separateObject(),
|
|
2796
|
+
markShown: () => printer.markShown(),
|
|
2797
|
+
text: (text) => printer.writeText(text),
|
|
2798
|
+
bytes: (bytes) => printer.writeBytes(bytes),
|
|
2799
|
+
tagger: (ident) => printer.writeTagger(ident),
|
|
2800
|
+
result: () => printer.result(),
|
|
2801
|
+
commitColor: { set: colors?.diff.commit ?? "", reset: colors?.diff.reset ?? "" },
|
|
2802
|
+
};
|
|
2803
|
+
}
|
|
2804
|
+
|
|
2805
|
+
/**
|
|
2806
|
+
* revision.c's try_to_simplify_commit for a commit git shows without walking; without
|
|
2807
|
+
* `simplify_history` (`--full-history`, `-m`, `--remerge-diff`) a merge is TREESAME only
|
|
2808
|
+
* to every parent it looks at (update_treesame)
|
|
2809
|
+
*/
|
|
2810
|
+
private async treesameForShow(id: ObjectId, commit: Commit, full = false): Promise<boolean> {
|
|
2811
|
+
if (commit.parents.length === 0) return !(await this.pathsDiffer(undefined, commit.tree));
|
|
2812
|
+
const merge = commit.parents.length > 1 && !this.firstParentOnly;
|
|
2813
|
+
const all = full || !this.simplifyHistory;
|
|
2814
|
+
for (let k = 0; k < commit.parents.length; k++) {
|
|
2815
|
+
if (k === 1 && this.firstParentOnly) break;
|
|
2816
|
+
const parent = await this.walkCommits.load(commit.parents[k] as ObjectId);
|
|
2817
|
+
if (!parent) {
|
|
2818
|
+
throw new GitApiError(
|
|
2819
|
+
`fatal: cannot simplify commit ${id} (because of ${commit.parents[k]})`,
|
|
2820
|
+
);
|
|
2821
|
+
}
|
|
2822
|
+
const same = !(await this.pathsDiffer(parent.tree, commit.tree));
|
|
2823
|
+
if (merge && all) {
|
|
2824
|
+
if (!same) return false;
|
|
2825
|
+
} else if (same) return true;
|
|
2826
|
+
}
|
|
2827
|
+
return merge && all;
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2830
|
+
/**
|
|
2831
|
+
* setup_revisions' refusals of a reflog walk: a sorted walk (`--topo-order`, `--graph`
|
|
2832
|
+
* without generation numbers: git's `limited`), then `--graph`/`--reverse`, then
|
|
2833
|
+
* `--grep-reflog` without `-g`.
|
|
2834
|
+
*/
|
|
2835
|
+
private async checkReflogWalkOptions(options: LogOutputOptions): Promise<void> {
|
|
2836
|
+
const walking = this.reflogWalkNames !== undefined;
|
|
2837
|
+
if (walking) {
|
|
2838
|
+
const graph = !!options.graph;
|
|
2839
|
+
const reverse = !!options.reverse || this.reverse;
|
|
2840
|
+
if (reverse && this.compatibility === "2.43") {
|
|
2841
|
+
throw new IncompatibleOptionsError(
|
|
2842
|
+
["--reverse", "--walk-reflogs"],
|
|
2843
|
+
"options '--reverse' and '--walk-reflogs' cannot be used together",
|
|
2844
|
+
);
|
|
2845
|
+
}
|
|
2846
|
+
const sorted =
|
|
2847
|
+
graph ||
|
|
2848
|
+
this.order !== undefined ||
|
|
2849
|
+
!!options.topoOrder ||
|
|
2850
|
+
!!options.dateOrder ||
|
|
2851
|
+
!!options.authorDateOrder;
|
|
2852
|
+
// a sorted walk is limited unless the commit-graph gives generation numbers
|
|
2853
|
+
if (sorted && !(await this.commits.commitGraph?.get().catch(() => undefined))) {
|
|
2854
|
+
throw new GitApiError("cannot combine --walk-reflogs with history-limiting options");
|
|
2855
|
+
}
|
|
2856
|
+
const set = [
|
|
2857
|
+
...(graph ? ["--graph"] : []),
|
|
2858
|
+
...(reverse ? ["--reverse"] : []),
|
|
2859
|
+
"--walk-reflogs",
|
|
2860
|
+
];
|
|
2861
|
+
if (set.length > 1) {
|
|
2862
|
+
const quoted = set.map((o) => `'${o}'`);
|
|
2863
|
+
const list =
|
|
2864
|
+
quoted.length === 2
|
|
2865
|
+
? `${quoted[0]} and ${quoted[1]}`
|
|
2866
|
+
: `${quoted[0]}, ${quoted[1]}, and ${quoted[2]}`;
|
|
2867
|
+
throw new IncompatibleOptionsError(set, `options ${list} cannot be used together`);
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
if (!walking && this.grepReflogs.length > 0) {
|
|
2871
|
+
throw new GitApiError("the option '--grep-reflog' requires '--walk-reflogs'");
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
/**
|
|
2876
|
+
* The entries of a reflog walk (reflog-walk.c's next_reflog_entry over the names given,
|
|
2877
|
+
* HEAD without): each entry's new commit, filtered as get_revision_1 filters a reflog walk
|
|
2878
|
+
* (`--since`/`--until` against the entry's date, path limiting against the commit's parents,
|
|
2879
|
+
* get_commit_action), then skipped and counted.
|
|
2880
|
+
*/
|
|
2881
|
+
private async reflogEntries(names: readonly string[], claim = true): Promise<LogOutputEntry[]> {
|
|
2882
|
+
if (claim) {
|
|
2883
|
+
this.checkCallable();
|
|
2884
|
+
this.setCallable(false);
|
|
2885
|
+
readDiffSubmoduleConfig(this.workingCopy);
|
|
2886
|
+
}
|
|
2887
|
+
this.activeFilter = await this.buildCommitFilter();
|
|
2888
|
+
const resolver = this.revisionResolver();
|
|
2889
|
+
const refs = this.refsStore;
|
|
2890
|
+
const logs = await openReflogWalk(names.length > 0 ? names : ["HEAD"], {
|
|
2891
|
+
reflog: async (ref) => {
|
|
2892
|
+
const reader = await refs.getReflog?.(ref);
|
|
2893
|
+
return reader ? (await reader.getReverseEntries()).reverse() : undefined;
|
|
2894
|
+
},
|
|
2895
|
+
resolveRef: async (ref, reading) => {
|
|
2896
|
+
const value = await refs.get(ref).catch(() => undefined);
|
|
2897
|
+
if (!value) return undefined;
|
|
2898
|
+
if (!isSymbolicRef(value)) return reading && !value.objectId ? undefined : ref;
|
|
2899
|
+
let target = value.target;
|
|
2900
|
+
for (let i = 0; i < 10; i++) {
|
|
2901
|
+
const next = await refs.get(target).catch(() => undefined);
|
|
2902
|
+
if (!next || !isSymbolicRef(next)) {
|
|
2903
|
+
if (reading && !next) return undefined;
|
|
2904
|
+
return target;
|
|
2905
|
+
}
|
|
2906
|
+
target = next.target;
|
|
2907
|
+
}
|
|
2908
|
+
return undefined;
|
|
2909
|
+
},
|
|
2910
|
+
interpretBranchPrefix: (name) => resolver.interpretBranchPrefix(name),
|
|
2911
|
+
dwimLogRefs: (name) => resolver.dwimLogRefs(name),
|
|
2912
|
+
shortenRef: (ref) => shortenUnambiguousRef(refs, ref),
|
|
2913
|
+
now: () => resolver.currentTime(),
|
|
2914
|
+
});
|
|
2915
|
+
const out: LogOutputEntry[] = [];
|
|
2916
|
+
let skip = this.skip;
|
|
2917
|
+
const max = this.maxCount;
|
|
2918
|
+
if (max !== undefined && max <= 0) return out;
|
|
2919
|
+
const prune = this.paths.length > 0 || this.excludePaths.length > 0;
|
|
2920
|
+
const loadCommit = (id: ObjectId) => this.walkCommits.load(id).catch(() => undefined);
|
|
2921
|
+
for await (const step of walkReflogs(logs, loadCommit)) {
|
|
2922
|
+
const { id, commit } = step;
|
|
2923
|
+
if (this.sinceTime !== undefined && step.time < this.sinceTime) continue;
|
|
2924
|
+
if (this.untilTime !== undefined && step.time > this.untilTime) continue;
|
|
2925
|
+
const parents = commit.parents.length;
|
|
2926
|
+
if (this.revFilter === RevFilter.ONLY_MERGES && parents < 2) continue;
|
|
2927
|
+
if (this.revFilter === RevFilter.NO_MERGES && parents > 1) continue;
|
|
2928
|
+
if (this.authorPattern !== undefined && !this.matchesAuthor(commit)) continue;
|
|
2929
|
+
if (this.committerPattern !== undefined && !this.matchesCommitter(commit)) continue;
|
|
2930
|
+
const filter = this.activeFilter;
|
|
2931
|
+
if (filter) {
|
|
2932
|
+
const view: FilteredCommit = {
|
|
2933
|
+
id,
|
|
2934
|
+
parentCount: parents,
|
|
2935
|
+
commitTime: commit.committer.timestamp,
|
|
2936
|
+
raw: async () => this.rawCommit(id),
|
|
2937
|
+
commit: async () => commit,
|
|
2938
|
+
reflogMessage: step.reflog.message,
|
|
2939
|
+
};
|
|
2940
|
+
if (!(await filter.include(view))) continue;
|
|
2941
|
+
}
|
|
2942
|
+
if (prune && (await this.reflogCommitTreesame(commit))) continue;
|
|
2943
|
+
if (skip > 0) {
|
|
2944
|
+
skip--;
|
|
2945
|
+
continue;
|
|
2946
|
+
}
|
|
2947
|
+
out.push({ id, commit, parents: commit.parents, reflog: step.reflog });
|
|
2948
|
+
if (max !== undefined && out.length >= max) break;
|
|
2949
|
+
}
|
|
2950
|
+
return out;
|
|
2951
|
+
}
|
|
2952
|
+
|
|
2953
|
+
/**
|
|
2954
|
+
* try_to_simplify_commit for a commit of a reflog walk (every parent relevant): TREESAME
|
|
2955
|
+
* at the paths to a parent (to every parent under `--full-history`), a root commit to the
|
|
2956
|
+
* empty tree.
|
|
2957
|
+
*/
|
|
2958
|
+
private async reflogCommitTreesame(commit: Commit): Promise<boolean> {
|
|
2959
|
+
if (commit.parents.length === 0) return !(await this.pathsDiffer(undefined, commit.tree));
|
|
2960
|
+
let same = 0;
|
|
2961
|
+
let compared = 0;
|
|
2962
|
+
for (const parent of commit.parents) {
|
|
2963
|
+
if (compared === 1 && this.firstParentOnly) break;
|
|
2964
|
+
compared++;
|
|
2965
|
+
const p = await this.walkCommits.load(parent).catch(() => undefined);
|
|
2966
|
+
if (!p) throw new GitApiError(`cannot simplify commit ${parent}`);
|
|
2967
|
+
if (!(await this.pathsDiffer(p.tree, commit.tree))) {
|
|
2968
|
+
if (this.simplifyHistory) return true;
|
|
2969
|
+
same++;
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
return same === compared;
|
|
2973
|
+
}
|
|
2974
|
+
|
|
1055
2975
|
/** What the log printer reads of the repository. */
|
|
1056
2976
|
private outputHost(options: LogOutputOptions = {}): LogOutputHost {
|
|
1057
2977
|
const config = RemoteConfigStore.from(this._workingCopy);
|
|
@@ -1074,6 +2994,38 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
1074
2994
|
}
|
|
1075
2995
|
return tree;
|
|
1076
2996
|
};
|
|
2997
|
+
const runDiff = async (
|
|
2998
|
+
oldTree: ObjectId,
|
|
2999
|
+
newTree: ObjectId,
|
|
3000
|
+
formats: DiffOutputFormat[],
|
|
3001
|
+
options: { statWidth?: number; follow?: string; fullDiff?: boolean; abbrev?: number },
|
|
3002
|
+
prepare?: (diff: DiffCommand) => void,
|
|
3003
|
+
) => {
|
|
3004
|
+
// the trees themselves: a full id names its object, so no revision is looked up
|
|
3005
|
+
const diff = new DiffCommand(this._workingCopy);
|
|
3006
|
+
prepare?.(diff);
|
|
3007
|
+
diff
|
|
3008
|
+
.setOldTree(oldTree)
|
|
3009
|
+
.setNewTree(newTree)
|
|
3010
|
+
// log's diffcore_rotate starts at the first path after a missing one
|
|
3011
|
+
.setRotateStrict(false)
|
|
3012
|
+
.shareReadsOf(this);
|
|
3013
|
+
if (this.colorSettings) diff.setColorSettings(this.colorSettings);
|
|
3014
|
+
diff.setOptions({
|
|
3015
|
+
...this.diffOptions,
|
|
3016
|
+
...(options.statWidth !== undefined
|
|
3017
|
+
? { stat: { ...this.diffOptions.stat, width: options.statWidth } }
|
|
3018
|
+
: {}),
|
|
3019
|
+
...(options.abbrev !== undefined ? { abbrev: options.abbrev } : {}),
|
|
3020
|
+
});
|
|
3021
|
+
if (!options.fullDiff && options.follow === undefined) {
|
|
3022
|
+
const spec = [...this.paths, ...this.excludePaths.map((p) => `:(exclude)${p}`)];
|
|
3023
|
+
if (spec.length > 0) diff.setPathspec(spec);
|
|
3024
|
+
}
|
|
3025
|
+
const shown = await diff.callFormats(formats, options.follow);
|
|
3026
|
+
if (diff.checkFoundErrors) this.checkFailed = true;
|
|
3027
|
+
return shown;
|
|
3028
|
+
};
|
|
1077
3029
|
return {
|
|
1078
3030
|
config: (key) => config.value(key),
|
|
1079
3031
|
configAll: (key) => config.values(key),
|
|
@@ -1098,38 +3050,24 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
1098
3050
|
}
|
|
1099
3051
|
return short;
|
|
1100
3052
|
},
|
|
3053
|
+
signature: (id) => this.signatureOf(id),
|
|
3054
|
+
signatureLines: (entry) => this.signatureLines(entry),
|
|
1101
3055
|
rawCommit: async (id) => {
|
|
1102
3056
|
// the replacement's content, as git's commit buffer is (core.useReplaceRefs)
|
|
1103
3057
|
const replace = (await this.objectReplacements())?.replace;
|
|
1104
3058
|
const bytes = await this.readObjectBytes(replace?.size ? replacementOf(replace, id) : id);
|
|
1105
3059
|
return bytes ? decodeGitPath(bytes) : undefined;
|
|
1106
3060
|
},
|
|
1107
|
-
decorations:
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
return loadRefDecorations({
|
|
1114
|
-
refs: this.refsStore,
|
|
1115
|
-
...(tags ? { tags } : {}),
|
|
1116
|
-
...(environment?.replaceRefBase !== undefined
|
|
1117
|
-
? { replaceRefBase: environment.replaceRefBase }
|
|
3061
|
+
decorations: (options) =>
|
|
3062
|
+
this.refDecorations({
|
|
3063
|
+
decorate: options.decorate,
|
|
3064
|
+
...(options.decorateRefs ? { decorateRefs: options.decorateRefs } : {}),
|
|
3065
|
+
...(options.decorateRefsExclude
|
|
3066
|
+
? { decorateRefsExclude: options.decorateRefsExclude }
|
|
1118
3067
|
: {}),
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
logOptions: {
|
|
1123
|
-
decorate: options.decorate,
|
|
1124
|
-
...(options.decorateRefs ? { decorateRefs: options.decorateRefs } : {}),
|
|
1125
|
-
...(options.decorateRefsExclude
|
|
1126
|
-
? { decorateRefsExclude: options.decorateRefsExclude }
|
|
1127
|
-
: {}),
|
|
1128
|
-
...(options.clearDecorations ? { clearDecorations: true } : {}),
|
|
1129
|
-
config,
|
|
1130
|
-
},
|
|
1131
|
-
});
|
|
1132
|
-
},
|
|
3068
|
+
...(options.clearDecorations ? { clearDecorations: true } : {}),
|
|
3069
|
+
config,
|
|
3070
|
+
}),
|
|
1133
3071
|
notes: async (id) => {
|
|
1134
3072
|
notesTrees ??= this.loadNotes(config, options);
|
|
1135
3073
|
const out: { ref: string; text: string }[] = [];
|
|
@@ -1142,33 +3080,168 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
1142
3080
|
return out;
|
|
1143
3081
|
},
|
|
1144
3082
|
mailmap: () => {
|
|
1145
|
-
mailmap ??= this.
|
|
3083
|
+
mailmap ??= this.loadedMailmap();
|
|
1146
3084
|
return mailmap;
|
|
1147
3085
|
},
|
|
1148
|
-
diff: async (entry, parent, formats, options) =>
|
|
1149
|
-
|
|
3086
|
+
diff: async (entry, parent, formats, options) =>
|
|
3087
|
+
runDiff(
|
|
3088
|
+
parent ? await treeOf(parent) : this.objectFormat.emptyTreeId,
|
|
3089
|
+
entry.commit.tree,
|
|
3090
|
+
formats,
|
|
3091
|
+
options,
|
|
3092
|
+
),
|
|
3093
|
+
remergeDiff: async (entry, parents, formats, options) => {
|
|
3094
|
+
// log-tree.c's do_remerge_diff: the re-merge's objects live in a view of their own
|
|
3095
|
+
// (git's tmp_objdir), dropped after this merge
|
|
3096
|
+
const history = this._workingCopy.history;
|
|
3097
|
+
if (!history) throw new Error("WorkingCopy.history is required for commands");
|
|
3098
|
+
const view = remergeObjectsView(history);
|
|
3099
|
+
const remerge = new RemergeTreeCommand(this._workingCopy)
|
|
3100
|
+
.setObjectsView(view)
|
|
3101
|
+
.shareReadsOf(this)
|
|
3102
|
+
.setParents(parents[0], parents[1]);
|
|
3103
|
+
// git 2.43's cmd_log_walk freed the parents of every commit it had processed (2.44
|
|
3104
|
+
// keeps them under --remerge-diff), so its merge bases stop there (`--reverse`)
|
|
3105
|
+
if (
|
|
3106
|
+
this.compatibility === "2.43" &&
|
|
3107
|
+
this.reflogWalkNames === undefined &&
|
|
3108
|
+
options.processed?.size
|
|
3109
|
+
) {
|
|
3110
|
+
remerge.setParentlessCommits(options.processed);
|
|
3111
|
+
}
|
|
3112
|
+
const remerged = await remerge.call();
|
|
3113
|
+
return runDiff(remerged.treeId, entry.commit.tree, formats, options, (diff) =>
|
|
3114
|
+
diff.setObjectsView(view).setAdditionalHeaders(remerged.pathMessages),
|
|
3115
|
+
);
|
|
3116
|
+
},
|
|
3117
|
+
combinedDiff: (entry, options) => this.combinedDiff(entry, options),
|
|
3118
|
+
lineLogDiff: async (entry, formats, options) => {
|
|
3119
|
+
const lineLog = this.lineLog;
|
|
3120
|
+
if (!lineLog) return {};
|
|
3121
|
+
const tree = entry.commit.tree;
|
|
1150
3122
|
const diff = new DiffCommand(this._workingCopy)
|
|
1151
|
-
.setOldTree(
|
|
1152
|
-
.setNewTree(
|
|
1153
|
-
.
|
|
3123
|
+
.setOldTree(tree)
|
|
3124
|
+
.setNewTree(tree)
|
|
3125
|
+
.setRotateStrict(false)
|
|
3126
|
+
.shareReadsOf(this)
|
|
3127
|
+
.setQueue(lineLog.queuedPairs(entry.id));
|
|
3128
|
+
if (this.colorSettings) diff.setColorSettings(this.colorSettings);
|
|
1154
3129
|
diff.setOptions({
|
|
1155
|
-
...this.
|
|
1156
|
-
...(options.statWidth !== undefined
|
|
1157
|
-
? { stat: { ...this.diffOptions.stat, width: options.statWidth } }
|
|
1158
|
-
: {}),
|
|
3130
|
+
...this.lineLogDiffOptions(),
|
|
1159
3131
|
...(options.abbrev !== undefined ? { abbrev: options.abbrev } : {}),
|
|
1160
3132
|
});
|
|
1161
|
-
|
|
1162
|
-
const spec = [...this.paths, ...this.excludePaths.map((p) => `:(exclude)${p}`)];
|
|
1163
|
-
if (spec.length > 0) diff.setPathspec(spec);
|
|
1164
|
-
}
|
|
1165
|
-
return diff.callFormats(formats, options.follow);
|
|
3133
|
+
return diff.callFormats(formats);
|
|
1166
3134
|
},
|
|
1167
|
-
|
|
3135
|
+
lineLogHacky: async (entry, prefix, colors) =>
|
|
3136
|
+
this.lineLog ? this.lineLog.hackyDiff(entry.id, prefix, colors) : new Uint8Array(0),
|
|
1168
3137
|
};
|
|
1169
3138
|
}
|
|
1170
3139
|
|
|
1171
3140
|
private diffOptions: DiffTextOptions = {};
|
|
3141
|
+
/** `--check` found errors in a commit's diff (git's `check_failed`) */
|
|
3142
|
+
private checkFailed = false;
|
|
3143
|
+
|
|
3144
|
+
/**
|
|
3145
|
+
* The exit status `git log` ends with: 2 when `--check` ({@link LogOutputOptions.check})
|
|
3146
|
+
* found errors in the diffs shown, else 0 (cmd_log_walk)
|
|
3147
|
+
*/
|
|
3148
|
+
get exitCode(): number {
|
|
3149
|
+
return this.checkFailed ? 2 : 0;
|
|
3150
|
+
}
|
|
3151
|
+
|
|
3152
|
+
/** The colors {@link callBytes} prints with */
|
|
3153
|
+
private colorSettings?: DiffColorSettings;
|
|
3154
|
+
private readonly outputWarnings: string[] = [];
|
|
3155
|
+
/** The mailmap as read once ({@link loadedMailmap}), and git's errors of reading it */
|
|
3156
|
+
private mailmapLoad?: Promise<Mailmap>;
|
|
3157
|
+
private readonly mailmapErrors: string[] = [];
|
|
3158
|
+
|
|
3159
|
+
/**
|
|
3160
|
+
* What git prints on stderr while {@link callBytes} prints the log without dying: the
|
|
3161
|
+
* `log.graphColors` colors it cannot parse (`error: invalid color value: <c>`, then
|
|
3162
|
+
* `warning: ignored invalid color '<c>' in log.graphColors`)
|
|
3163
|
+
*/
|
|
3164
|
+
get warnings(): readonly string[] {
|
|
3165
|
+
return this.outputWarnings;
|
|
3166
|
+
}
|
|
3167
|
+
|
|
3168
|
+
/**
|
|
3169
|
+
* git_log_config (git_diff_ui_config): the colors, read once for every commit's diff; the
|
|
3170
|
+
* palettes of the log's own lines, undefined without color
|
|
3171
|
+
*/
|
|
3172
|
+
private readColors():
|
|
3173
|
+
| { diff: DiffColors; decorations: DecorationPalette; graph: readonly string[] }
|
|
3174
|
+
| undefined {
|
|
3175
|
+
this.colorSettings = readDiffColorSettings(
|
|
3176
|
+
this.workingCopy,
|
|
3177
|
+
this.diffOptions,
|
|
3178
|
+
this.diffOptions.uiConfig !== false,
|
|
3179
|
+
);
|
|
3180
|
+
const colors = this.colorSettings.colors;
|
|
3181
|
+
if (!colors) return undefined;
|
|
3182
|
+
// graph_read_config: `log.graphColors` (its invalid colors left out with git's warning)
|
|
3183
|
+
const configured = configValue(this.workingCopy, "log.graphColors");
|
|
3184
|
+
const compatibility = this.diffOptions.colorCompatibility ?? "2.56";
|
|
3185
|
+
const graph =
|
|
3186
|
+
configured === undefined
|
|
3187
|
+
? GRAPH_COLUMN_COLORS_ANSI
|
|
3188
|
+
: graphColumnColors(
|
|
3189
|
+
configured,
|
|
3190
|
+
(spec) => {
|
|
3191
|
+
const color = parseGitColor(spec, compatibility);
|
|
3192
|
+
// color_parse_mem's own error, before graph.c's warning
|
|
3193
|
+
if (color === undefined)
|
|
3194
|
+
this.outputWarnings.push(`error: invalid color value: ${spec}`);
|
|
3195
|
+
return color;
|
|
3196
|
+
},
|
|
3197
|
+
(message) => this.outputWarnings.push(message),
|
|
3198
|
+
);
|
|
3199
|
+
return {
|
|
3200
|
+
diff: colors,
|
|
3201
|
+
decorations: {
|
|
3202
|
+
...(this.colorSettings.decorationColors ?? DEFAULT_DECORATION_COLORS),
|
|
3203
|
+
commit: colors.commit,
|
|
3204
|
+
},
|
|
3205
|
+
graph,
|
|
3206
|
+
};
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
/**
|
|
3210
|
+
* The pickaxe options checked before anything is shown, as git parses them (empty `-S`/
|
|
3211
|
+
* `-G`, `--find-object` names resolved once, the combinations, the regex compiled); `-i`
|
|
3212
|
+
* (`setRegexpIgnoreCase`) folds `-S`/`-G` too, as revision.c's `--regexp-ignore-case`
|
|
3213
|
+
*/
|
|
3214
|
+
private async preparePickaxe(): Promise<void> {
|
|
3215
|
+
let o = this.diffOptions;
|
|
3216
|
+
if (!hasPickaxe(o)) return;
|
|
3217
|
+
if (this.regexpIgnoreCase && o.pickaxeIgnoreCase === undefined) {
|
|
3218
|
+
o = { ...o, pickaxeIgnoreCase: true };
|
|
3219
|
+
}
|
|
3220
|
+
checkPickaxeOptions(o);
|
|
3221
|
+
if (o.findObjects && o.findObjects.length > 0) {
|
|
3222
|
+
const ids: string[] = [];
|
|
3223
|
+
for (const name of o.findObjects) {
|
|
3224
|
+
const id = await this.revisionResolver()
|
|
3225
|
+
.resolve(name)
|
|
3226
|
+
.catch(() => undefined);
|
|
3227
|
+
if (id === undefined) {
|
|
3228
|
+
throw new InvalidArgumentError(
|
|
3229
|
+
"findObjects",
|
|
3230
|
+
name,
|
|
3231
|
+
`error: unable to resolve '${name}'`,
|
|
3232
|
+
).withExitCode(129);
|
|
3233
|
+
}
|
|
3234
|
+
ids.push(id);
|
|
3235
|
+
}
|
|
3236
|
+
o = { ...o, findObjects: ids };
|
|
3237
|
+
}
|
|
3238
|
+
DiffPickaxe.compile({
|
|
3239
|
+
...(o.pickaxeString !== undefined ? { string: o.pickaxeString } : {}),
|
|
3240
|
+
...(o.pickaxeGrep !== undefined ? { grep: o.pickaxeGrep } : {}),
|
|
3241
|
+
regex: o.pickaxeRegex ?? false,
|
|
3242
|
+
});
|
|
3243
|
+
this.diffOptions = o;
|
|
3244
|
+
}
|
|
1172
3245
|
|
|
1173
3246
|
/** `log` stores no objects: its abbreviations read each loose fan-out directory once */
|
|
1174
3247
|
protected override writesNoObjects(): boolean {
|
|
@@ -1182,6 +3255,81 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
1182
3255
|
return this;
|
|
1183
3256
|
}
|
|
1184
3257
|
|
|
3258
|
+
private readonly signatureChecks = new OrderedMap<ObjectId, Promise<SignatureCheck>>();
|
|
3259
|
+
private signatureCwd?: Promise<string | undefined>;
|
|
3260
|
+
|
|
3261
|
+
/** A commit's bytes as its buffer is read (the replacement's, core.useReplaceRefs) */
|
|
3262
|
+
private async commitBuffer(id: ObjectId): Promise<Uint8Array | undefined> {
|
|
3263
|
+
const replace = (await this.objectReplacements())?.replace;
|
|
3264
|
+
return this.readObjectBytes(replace?.size ? replacementOf(replace, id) : id);
|
|
3265
|
+
}
|
|
3266
|
+
|
|
3267
|
+
/** `check_commit_signature` of a commit, made once */
|
|
3268
|
+
private signatureOf(id: ObjectId): Promise<SignatureCheck> {
|
|
3269
|
+
let check = this.signatureChecks.get(id);
|
|
3270
|
+
if (!check) {
|
|
3271
|
+
check = (async () => {
|
|
3272
|
+
const bytes = await this.commitBuffer(id);
|
|
3273
|
+
if (!bytes) return { result: "N", trustLevel: "undefined", failed: true, messages: [] };
|
|
3274
|
+
this.signatureCwd ??= this.hostWorkingDir();
|
|
3275
|
+
const cwd = await this.signatureCwd;
|
|
3276
|
+
return verifyCommitBytes(this._workingCopy, bytes, {
|
|
3277
|
+
objectFormat: this.objectFormat,
|
|
3278
|
+
...(cwd !== undefined ? { cwd } : {}),
|
|
3279
|
+
});
|
|
3280
|
+
})();
|
|
3281
|
+
this.signatureChecks.set(id, check);
|
|
3282
|
+
if (this.signatureChecks.size > 1024) this.signatureChecks.deleteOldest();
|
|
3283
|
+
}
|
|
3284
|
+
return check;
|
|
3285
|
+
}
|
|
3286
|
+
|
|
3287
|
+
/** log-tree.c's `show_signature` and `show_mergetag` for one commit */
|
|
3288
|
+
private async signatureLines(
|
|
3289
|
+
entry: LogOutputEntry,
|
|
3290
|
+
): Promise<{ failed: boolean; text: string }[]> {
|
|
3291
|
+
const bytes = await this.commitBuffer(entry.id);
|
|
3292
|
+
if (!bytes) return [];
|
|
3293
|
+
this.signatureCwd ??= this.hostWorkingDir();
|
|
3294
|
+
const cwd = await this.signatureCwd;
|
|
3295
|
+
const out: { failed: boolean; text: string }[] = [];
|
|
3296
|
+
if (parseBufferSignedByHeader(bytes, this.objectFormat.signatureHeader)) {
|
|
3297
|
+
const check = await this.signatureOf(entry.id);
|
|
3298
|
+
out.push(
|
|
3299
|
+
check.failed && check.output === undefined
|
|
3300
|
+
? { failed: true, text: "No signature\n" }
|
|
3301
|
+
: { failed: check.failed, text: check.output ?? "" },
|
|
3302
|
+
);
|
|
3303
|
+
}
|
|
3304
|
+
const parents = entry.commit.parents;
|
|
3305
|
+
for (const tag of mergetagsOf(bytes)) {
|
|
3306
|
+
const header = parseMergetag(tag, this.objectFormat.hexLength);
|
|
3307
|
+
let text: string;
|
|
3308
|
+
if (!header) text = "malformed mergetag\n";
|
|
3309
|
+
else if (parents.length === 2 && header.object === parents[1])
|
|
3310
|
+
text = `merged tag '${header.tag}'\n`;
|
|
3311
|
+
else {
|
|
3312
|
+
const nth = parents.indexOf(header.object);
|
|
3313
|
+
text =
|
|
3314
|
+
nth < 0
|
|
3315
|
+
? `tag ${header.tag} names a non-parent ${header.object}\n`
|
|
3316
|
+
: `parent #${nth + 1}, tagged '${header.tag}'\n`;
|
|
3317
|
+
}
|
|
3318
|
+
let failed = true;
|
|
3319
|
+
const signed = parseSignature(tag);
|
|
3320
|
+
if (signed) {
|
|
3321
|
+
const check = await checkSignature(this._workingCopy, signed.payload, signed.signature, {
|
|
3322
|
+
payloadType: "tag",
|
|
3323
|
+
...(cwd !== undefined ? { cwd } : {}),
|
|
3324
|
+
});
|
|
3325
|
+
failed = check.failed;
|
|
3326
|
+
text += check.output ?? "No signature\n";
|
|
3327
|
+
}
|
|
3328
|
+
out.push({ failed, text });
|
|
3329
|
+
}
|
|
3330
|
+
return out;
|
|
3331
|
+
}
|
|
3332
|
+
|
|
1185
3333
|
/** An object's content as stored (undefined when missing) */
|
|
1186
3334
|
private async readObjectBytes(id: ObjectId): Promise<Uint8Array | undefined> {
|
|
1187
3335
|
const objects = this._workingCopy.history?.objects;
|
|
@@ -1226,6 +3374,44 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
1226
3374
|
return out;
|
|
1227
3375
|
}
|
|
1228
3376
|
|
|
3377
|
+
/**
|
|
3378
|
+
* The pickaxe of a combined diff: without rename detection `--find-object` keeps the paths
|
|
3379
|
+
* with the object in the merge or a parent (combined_objfind); with it, and for `-S`/`-G`,
|
|
3380
|
+
* find_paths_generic's way: a diff against each parent through diffcore (renames, pickaxe
|
|
3381
|
+
* and `--diff-filter`), keeping the paths every one of them still lists (intersect_paths)
|
|
3382
|
+
*/
|
|
3383
|
+
private async combinedPickaxe(
|
|
3384
|
+
entry: LogOutputEntry,
|
|
3385
|
+
paths: string[],
|
|
3386
|
+
idsOf: (path: string) => (ObjectId | undefined)[],
|
|
3387
|
+
): Promise<string[]> {
|
|
3388
|
+
const d = this.diffOptions;
|
|
3389
|
+
if (!hasPickaxe(d) || paths.length === 0) return paths;
|
|
3390
|
+
// need_generic_pathscan: rename detection (log's diff.renames, default on) or -S/-G
|
|
3391
|
+
const renames = configBool(this.workingCopy, "diff.renames", true);
|
|
3392
|
+
if (d.findObjects && d.findObjects.length > 0 && !renames) {
|
|
3393
|
+
const wanted = new Set(d.findObjects);
|
|
3394
|
+
return paths.filter((path) => idsOf(path).some((id) => id !== undefined && wanted.has(id)));
|
|
3395
|
+
}
|
|
3396
|
+
let kept = paths;
|
|
3397
|
+
for (const p of entry.parents) {
|
|
3398
|
+
const commit = await this.commits.load(p);
|
|
3399
|
+
const diff = new DiffCommand(this._workingCopy)
|
|
3400
|
+
.setOldTree(commit ? commit.tree : this.objectFormat.emptyTreeId)
|
|
3401
|
+
.setNewTree(entry.commit.tree)
|
|
3402
|
+
.shareReadsOf(this)
|
|
3403
|
+
.setRenames(renames)
|
|
3404
|
+
.setOptions(d);
|
|
3405
|
+
// the walk's pathspec: --pickaxe-all looks at the whole queue of each parent
|
|
3406
|
+
const spec = [...this.paths, ...this.excludePaths.map((x) => `:(exclude)${x}`)];
|
|
3407
|
+
if (spec.length > 0) diff.setPathspec(spec);
|
|
3408
|
+
const listed = new Set((await diff.call()).map((e) => e.newPath ?? e.oldPath));
|
|
3409
|
+
kept = kept.filter((path) => listed.has(path));
|
|
3410
|
+
if (kept.length === 0) break;
|
|
3411
|
+
}
|
|
3412
|
+
return kept;
|
|
3413
|
+
}
|
|
3414
|
+
|
|
1229
3415
|
/**
|
|
1230
3416
|
* combine-diff.c's diff_tree_combined for a merge: the paths that differ from every
|
|
1231
3417
|
* parent (within the pathspec), each as a combined diff of the trees.
|
|
@@ -1268,7 +3454,7 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
1268
3454
|
}
|
|
1269
3455
|
const differs = (a?: { mode: number; id: ObjectId }, b?: { mode: number; id: ObjectId }) =>
|
|
1270
3456
|
!a || !b ? a !== b : a.id !== b.id || a.mode !== b.mode;
|
|
1271
|
-
|
|
3457
|
+
let paths = [...all]
|
|
1272
3458
|
.filter((path) => items.length === 0 || matchPathspec(items, path, 0) > 0)
|
|
1273
3459
|
.filter((path) =>
|
|
1274
3460
|
parents.every(
|
|
@@ -1285,6 +3471,10 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
1285
3471
|
}
|
|
1286
3472
|
return ea.length - eb.length;
|
|
1287
3473
|
});
|
|
3474
|
+
paths = await this.combinedPickaxe(entry, paths, (path) => [
|
|
3475
|
+
result.get(path)?.id,
|
|
3476
|
+
...parents.map((m, k) => sideOf(m, k, path)?.id),
|
|
3477
|
+
]);
|
|
1288
3478
|
const sink = new ByteSink();
|
|
1289
3479
|
const quote =
|
|
1290
3480
|
parseGitBool(RemoteConfigStore.from(this._workingCopy).value("core.quotePath")) ?? true;
|
|
@@ -1368,6 +3558,7 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
1368
3558
|
abbreviate: (id) =>
|
|
1369
3559
|
id.slice(0, this.diffOptions.fullIndex ? id.length : (lengths.get(id) ?? 7)),
|
|
1370
3560
|
quotePath: quote,
|
|
3561
|
+
...(this.colorSettings?.colors ? { colors: this.colorSettings.colors } : {}),
|
|
1371
3562
|
},
|
|
1372
3563
|
);
|
|
1373
3564
|
}
|
|
@@ -1404,71 +3595,6 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
1404
3595
|
return out;
|
|
1405
3596
|
}
|
|
1406
3597
|
|
|
1407
|
-
/** mailmap.c's read_mailmap: `.mailmap` (not in a bare repository), `mailmap.blob`, `mailmap.file` */
|
|
1408
|
-
private async loadMailmap(config: RemoteConfigStore): Promise<Mailmap> {
|
|
1409
|
-
const map = new Mailmap();
|
|
1410
|
-
const worktree = this.worktreeAccess;
|
|
1411
|
-
const bare = parseGitBool(config.value("core.bare")) ?? !worktree;
|
|
1412
|
-
if (!bare && worktree) {
|
|
1413
|
-
try {
|
|
1414
|
-
const entry = await worktree.getEntry(".mailmap");
|
|
1415
|
-
if (entry && !entry.isDirectory && (entry.mode & 0o170000) !== 0o120000) {
|
|
1416
|
-
const chunks: Uint8Array[] = [];
|
|
1417
|
-
for await (const c of worktree.readContent(".mailmap")) chunks.push(c);
|
|
1418
|
-
map.read(decodeGitPath(concatBytes(chunks)));
|
|
1419
|
-
}
|
|
1420
|
-
} catch {
|
|
1421
|
-
// no .mailmap
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
const blobName = config.value("mailmap.blob") ?? (bare ? "HEAD:.mailmap" : undefined);
|
|
1425
|
-
if (blobName) {
|
|
1426
|
-
const id = await this.revisionResolver()
|
|
1427
|
-
.resolve(blobName)
|
|
1428
|
-
.catch(() => undefined);
|
|
1429
|
-
const bytes = id ? await this.readBlob(id) : undefined;
|
|
1430
|
-
if (bytes) map.read(decodeGitPath(bytes));
|
|
1431
|
-
}
|
|
1432
|
-
const file = config.value("mailmap.file");
|
|
1433
|
-
if (file) {
|
|
1434
|
-
const environment = hostEnvironmentOf(this._workingCopy);
|
|
1435
|
-
const path = expandUserPath(file, environment);
|
|
1436
|
-
const bytes = path !== undefined ? await this.readMailmapFile(path, environment) : undefined;
|
|
1437
|
-
if (bytes) map.read(decodeGitPath(bytes));
|
|
1438
|
-
}
|
|
1439
|
-
return map;
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
/**
|
|
1443
|
-
* `mailmap.file`, read as git reads it: through the host (a relative path from its current
|
|
1444
|
-
* directory). Without a host environment, a relative path is read from the worktree's top
|
|
1445
|
-
* (where git usually runs), and an absolute one inside the worktree through it as well.
|
|
1446
|
-
*/
|
|
1447
|
-
private async readMailmapFile(
|
|
1448
|
-
path: string,
|
|
1449
|
-
environment: ReturnType<typeof hostEnvironmentOf>,
|
|
1450
|
-
): Promise<Uint8Array | undefined> {
|
|
1451
|
-
if (environment) return environment.readFile(path).catch(() => undefined);
|
|
1452
|
-
const worktree = "worktree" in this._workingCopy ? this.worktreeAccess : undefined;
|
|
1453
|
-
if (!worktree) return undefined;
|
|
1454
|
-
let relative = path;
|
|
1455
|
-
if (path.startsWith("/")) {
|
|
1456
|
-
const top = (worktree as { hostPath?: string }).hostPath?.replace(/\/+$/, "");
|
|
1457
|
-
if (!top || !path.startsWith(`${top}/`)) return undefined;
|
|
1458
|
-
relative = path.slice(top.length + 1);
|
|
1459
|
-
}
|
|
1460
|
-
if (relative.split("/").includes("..")) return undefined;
|
|
1461
|
-
try {
|
|
1462
|
-
const entry = await worktree.getEntry(relative);
|
|
1463
|
-
if (!entry || entry.isDirectory) return undefined;
|
|
1464
|
-
const chunks: Uint8Array[] = [];
|
|
1465
|
-
for await (const c of worktree.readContent(relative)) chunks.push(c);
|
|
1466
|
-
return concatBytes(chunks);
|
|
1467
|
-
} catch {
|
|
1468
|
-
return undefined;
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
|
|
1472
3598
|
/**
|
|
1473
3599
|
* The tree, parents and date of a commit (git's parse_commit_buffer), from its raw bytes
|
|
1474
3600
|
* when the store gives them (kept in `raw` to be decoded whole if the commit is shown),
|
|
@@ -1519,11 +3645,66 @@ export class LogCommand extends GitCommand<AsyncIterable<LogResult>> {
|
|
|
1519
3645
|
* element's path components when all are plain paths (no wildcard, no magic, no trailing
|
|
1520
3646
|
* slash): those are compared by looking their entries up, without a tree diff.
|
|
1521
3647
|
*/
|
|
1522
|
-
|
|
3648
|
+
/** The walk's pathspec elements: the paths, the excluded ones, `.` when every one excludes */
|
|
3649
|
+
private pathspecItems(): PathspecItem[] {
|
|
1523
3650
|
const parse = (p: string) => parsePathspecItem(p, { attr: true });
|
|
1524
3651
|
const items: PathspecItem[] = this.paths.map(parse);
|
|
1525
3652
|
for (const p of this.excludePaths) items.push({ ...parse(p), exclude: true });
|
|
1526
3653
|
if (items.every((i) => i.exclude)) items.push(parse("."));
|
|
3654
|
+
return items;
|
|
3655
|
+
}
|
|
3656
|
+
|
|
3657
|
+
/**
|
|
3658
|
+
* revision.c's cherry_pick_list over the limited list: the patch-ids of the side with fewer
|
|
3659
|
+
* commits are added (header ids only, see {@link PatchIds}), each commit of the other side
|
|
3660
|
+
* looked up, and every match on either side marked PATCHSAME (`--cherry-mark`) or SHOWN
|
|
3661
|
+
* (`--cherry-pick`, hidden). The diffs are limited to the walk's paths, and compare a
|
|
3662
|
+
* commit with its parent as the walk has it (simplified), as git's do.
|
|
3663
|
+
*/
|
|
3664
|
+
private async cherryPickList(
|
|
3665
|
+
list: number[],
|
|
3666
|
+
t: RevTable,
|
|
3667
|
+
parse: (n: number) => Promise<boolean>,
|
|
3668
|
+
items: PathspecItem[] | undefined,
|
|
3669
|
+
): Promise<void> {
|
|
3670
|
+
let leftCount = 0;
|
|
3671
|
+
let rightCount = 0;
|
|
3672
|
+
for (const n of list) {
|
|
3673
|
+
if (t.flag(n) & SYMMETRIC_LEFT) leftCount++;
|
|
3674
|
+
else rightCount++;
|
|
3675
|
+
}
|
|
3676
|
+
if (!leftCount || !rightCount) return;
|
|
3677
|
+
const leftFirst = leftCount < rightCount;
|
|
3678
|
+
const ids = new PatchIds<number>({
|
|
3679
|
+
trees: this.trees,
|
|
3680
|
+
blobs: this.blobs,
|
|
3681
|
+
objectFormat: this.objectFormat,
|
|
3682
|
+
change: async (n) => {
|
|
3683
|
+
const count = t.parentCount(n);
|
|
3684
|
+
if (count > 1) return undefined;
|
|
3685
|
+
if (count === 0) return { tree: t.treeOf(n) };
|
|
3686
|
+
const p = t.parent(n, 0);
|
|
3687
|
+
if (!(await parse(p))) return undefined;
|
|
3688
|
+
return { parentTree: t.treeOf(p), tree: t.treeOf(n) };
|
|
3689
|
+
},
|
|
3690
|
+
...(items ? { paths: (path: string) => matchPathspec(items, path, 0) > 0 } : {}),
|
|
3691
|
+
});
|
|
3692
|
+
for (const n of list) {
|
|
3693
|
+
if (leftFirst !== !!(t.flag(n) & SYMMETRIC_LEFT)) continue;
|
|
3694
|
+
await ids.add(n);
|
|
3695
|
+
}
|
|
3696
|
+
const flag = this.cherryMark ? PATCHSAME : SHOWN;
|
|
3697
|
+
for (const n of list) {
|
|
3698
|
+
if (leftFirst === !!(t.flag(n) & SYMMETRIC_LEFT)) continue;
|
|
3699
|
+
const found = await ids.matches(n);
|
|
3700
|
+
if (found.length === 0) continue;
|
|
3701
|
+
t.mark(n, flag);
|
|
3702
|
+
for (const m of found) t.mark(m, flag);
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3706
|
+
private pathspec(): TreePathspec & { literal: Uint8Array[][] | undefined } {
|
|
3707
|
+
const items = this.pathspecItems();
|
|
1527
3708
|
const plain = items.every(
|
|
1528
3709
|
(i) =>
|
|
1529
3710
|
!i.exclude &&
|
|
@@ -1917,6 +4098,16 @@ const BOTTOM = 1 << 2;
|
|
|
1917
4098
|
const SEEN = 1 << 3;
|
|
1918
4099
|
const ADDED = 1 << 4;
|
|
1919
4100
|
const TREESAME = 1 << 5;
|
|
4101
|
+
/** The left side of `a...b` (passed from child to parent) */
|
|
4102
|
+
const SYMMETRIC_LEFT = 1 << 8;
|
|
4103
|
+
/** `--cherry-mark`: a commit whose change the other side has as well */
|
|
4104
|
+
const PATCHSAME = 1 << 9;
|
|
4105
|
+
/** Shown already, or hidden by `--cherry-pick`/`--left-only`/`--right-only` (git's SHOWN) */
|
|
4106
|
+
const SHOWN = 1 << 10;
|
|
4107
|
+
/** `--ancestry-path=<commit>`: an ancestor of a commit named (passed from child to parent) */
|
|
4108
|
+
const ANCESTRY_PATH = 1 << 11;
|
|
4109
|
+
/** `--show-pulls`: a merge that differs from its first parent at the paths */
|
|
4110
|
+
const PULL_MERGE = 1 << 12;
|
|
1920
4111
|
|
|
1921
4112
|
/** How many extra uninteresting commits limit_list looks at (git's SLOP). */
|
|
1922
4113
|
const SLOP = 5;
|
|
@@ -1932,7 +4123,7 @@ class RevTable {
|
|
|
1932
4123
|
/** commits held */
|
|
1933
4124
|
size = 0;
|
|
1934
4125
|
/** revision.c flags (UNINTERESTING, SEEN, ...) */
|
|
1935
|
-
flags = new
|
|
4126
|
+
flags = new Uint16Array(INITIAL_REVS);
|
|
1936
4127
|
/** committer dates (seconds) */
|
|
1937
4128
|
private dates = new Float64Array(INITIAL_REVS);
|
|
1938
4129
|
/** position in the commit-graph, -1 for a commit it does not have */
|
|
@@ -2066,6 +4257,21 @@ class RevTable {
|
|
|
2066
4257
|
return this.pool[(this.parentAt[n] as number) + k] as number;
|
|
2067
4258
|
}
|
|
2068
4259
|
|
|
4260
|
+
/** The parents of a parsed commit, as numbers. */
|
|
4261
|
+
parentList(n: number): number[] {
|
|
4262
|
+
const out: number[] = [];
|
|
4263
|
+
for (let k = 0, c = this.parentCount(n); k < c; k++) out.push(this.parent(n, k));
|
|
4264
|
+
return out;
|
|
4265
|
+
}
|
|
4266
|
+
|
|
4267
|
+
/** Replaces the parents of a parsed commit by `list`, no longer than they were. */
|
|
4268
|
+
setParentList(n: number, list: readonly number[]): void {
|
|
4269
|
+
if (list.length > this.parentCount(n)) throw new Error("parents cannot grow");
|
|
4270
|
+
const at = this.parentAt[n] as number;
|
|
4271
|
+
for (let k = 0; k < list.length; k++) this.pool[at + k] = list[k] as number;
|
|
4272
|
+
this.parents[n] = list.length;
|
|
4273
|
+
}
|
|
4274
|
+
|
|
2069
4275
|
/** Simplification keeps only parent `p` (git rewrites `commit->parents`). */
|
|
2070
4276
|
keepOnlyParent(n: number, p: number): void {
|
|
2071
4277
|
this.pool[this.parentAt[n] as number] = p;
|
|
@@ -2082,7 +4288,7 @@ class RevTable {
|
|
|
2082
4288
|
|
|
2083
4289
|
private grow(): void {
|
|
2084
4290
|
const size = this.flags.length * 2;
|
|
2085
|
-
const flags = new
|
|
4291
|
+
const flags = new Uint16Array(size);
|
|
2086
4292
|
flags.set(this.flags);
|
|
2087
4293
|
this.flags = flags;
|
|
2088
4294
|
const dates = new Float64Array(size);
|
|
@@ -2105,6 +4311,55 @@ const INITIAL_REVS = 1024;
|
|
|
2105
4311
|
/** `RevTable` flag: parsed from the commit-graph (its tree and Bloom filter are there). */
|
|
2106
4312
|
const GRAPH_PARSED = 1 << 6;
|
|
2107
4313
|
|
|
4314
|
+
/** revision.c's one_relevant_parent: the one parent a TREESAME commit simplifies to */
|
|
4315
|
+
function oneRelevantParent(
|
|
4316
|
+
t: RevTable,
|
|
4317
|
+
n: number,
|
|
4318
|
+
firstParentOnly: boolean,
|
|
4319
|
+
relevant: (n: number) => boolean,
|
|
4320
|
+
): number | undefined {
|
|
4321
|
+
const c = t.parentCount(n);
|
|
4322
|
+
if (c === 0) return undefined;
|
|
4323
|
+
if (firstParentOnly || c === 1) return t.parent(n, 0);
|
|
4324
|
+
let found: number | undefined;
|
|
4325
|
+
for (let k = 0; k < c; k++) {
|
|
4326
|
+
const p = t.parent(n, k);
|
|
4327
|
+
if (!relevant(p)) continue;
|
|
4328
|
+
if (found !== undefined) return undefined;
|
|
4329
|
+
found = p;
|
|
4330
|
+
}
|
|
4331
|
+
return found;
|
|
4332
|
+
}
|
|
4333
|
+
|
|
4334
|
+
/**
|
|
4335
|
+
* revision.c's rewrite_parents: n's parents, each replaced by the first commit shown on its
|
|
4336
|
+
* way down (rewrite_one), roots TREESAME dropped, duplicates removed.
|
|
4337
|
+
*/
|
|
4338
|
+
function rewriteParents(
|
|
4339
|
+
t: RevTable,
|
|
4340
|
+
n: number,
|
|
4341
|
+
firstParentOnly: boolean,
|
|
4342
|
+
relevant: (n: number) => boolean,
|
|
4343
|
+
): number[] {
|
|
4344
|
+
const out: number[] = [];
|
|
4345
|
+
for (let k = 0, c = t.parentCount(n); k < c; k++) {
|
|
4346
|
+
let p: number | undefined = t.parent(n, k);
|
|
4347
|
+
for (;;) {
|
|
4348
|
+
if (t.flag(p) & UNINTERESTING) break;
|
|
4349
|
+
if (!(t.flag(p) & TREESAME)) break;
|
|
4350
|
+
if (t.parentCount(p) === 0) {
|
|
4351
|
+
p = undefined;
|
|
4352
|
+
break;
|
|
4353
|
+
}
|
|
4354
|
+
const next = oneRelevantParent(t, p, firstParentOnly, relevant);
|
|
4355
|
+
if (next === undefined) break;
|
|
4356
|
+
p = next;
|
|
4357
|
+
}
|
|
4358
|
+
if (p !== undefined && !out.includes(p)) out.push(p);
|
|
4359
|
+
}
|
|
4360
|
+
return out;
|
|
4361
|
+
}
|
|
4362
|
+
|
|
2108
4363
|
/** A commit read whole, as the commit store decodes it; undefined if it does not parse. */
|
|
2109
4364
|
function decodeCommit(bytes: Uint8Array): Commit | undefined {
|
|
2110
4365
|
try {
|
|
@@ -2307,3 +4562,21 @@ function configAlgorithm(v: string | undefined): XdiffAlgorithm | undefined {
|
|
|
2307
4562
|
if (s === "default") return "myers";
|
|
2308
4563
|
return s === "myers" || s === "minimal" || s === "patience" || s === "histogram" ? s : undefined;
|
|
2309
4564
|
}
|
|
4565
|
+
|
|
4566
|
+
/** tag.c's `parse_tag_buffer` of a mergetag: the object tagged and the tag's name. */
|
|
4567
|
+
function parseMergetag(
|
|
4568
|
+
bytes: Uint8Array,
|
|
4569
|
+
hexLength: number,
|
|
4570
|
+
): { object: ObjectId; tag: string } | undefined {
|
|
4571
|
+
const text = decodeGitPath(bytes);
|
|
4572
|
+
if (bytes.length < hexLength + 24) return undefined;
|
|
4573
|
+
const object = new RegExp(`^object ([0-9a-f]{${hexLength}})\n`).exec(text);
|
|
4574
|
+
if (!object) return undefined;
|
|
4575
|
+
let rest = text.slice(object[0].length);
|
|
4576
|
+
if (!rest.startsWith("type ")) return undefined;
|
|
4577
|
+
const nl = rest.indexOf("\n");
|
|
4578
|
+
if (nl < 0) return undefined;
|
|
4579
|
+
rest = rest.slice(nl + 1);
|
|
4580
|
+
const tag = /^tag ([^\n]*)\n/.exec(rest);
|
|
4581
|
+
return { object: object[1] as ObjectId, tag: tag ? (tag[1] as string) : "(null)" };
|
|
4582
|
+
}
|