@statewalker/vcs-commands 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commands/add-command.d.ts +32 -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 +2 -0
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-modes.d.ts +6 -2
- package/dist/commands/add-patch/patch-modes.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-session.d.ts +4 -0
- package/dist/commands/add-patch/patch-session.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +88 -2
- package/dist/commands/am/am-command.d.ts.map +1 -1
- 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-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/archive/archive-command.d.ts +169 -0
- package/dist/commands/archive/archive-command.d.ts.map +1 -0
- package/dist/commands/archive/archive-entry.d.ts +60 -0
- package/dist/commands/archive/archive-entry.d.ts.map +1 -0
- package/dist/commands/archive/index.d.ts +8 -0
- package/dist/commands/archive/index.d.ts.map +1 -0
- package/dist/commands/archive/remote-archive-command.d.ts +56 -0
- package/dist/commands/archive/remote-archive-command.d.ts.map +1 -0
- package/dist/commands/archive/tar-archive.d.ts +31 -0
- package/dist/commands/archive/tar-archive.d.ts.map +1 -0
- package/dist/commands/archive/tar-commit-id.d.ts +13 -0
- package/dist/commands/archive/tar-commit-id.d.ts.map +1 -0
- package/dist/commands/archive/upload-archive-writer.d.ts +48 -0
- package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -0
- package/dist/commands/archive/zip-archive.d.ts +42 -0
- package/dist/commands/archive/zip-archive.d.ts.map +1 -0
- package/dist/commands/attributes-source.d.ts +10 -0
- package/dist/commands/attributes-source.d.ts.map +1 -1
- package/dist/commands/blame-command.d.ts +345 -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/bundle/bundle-create-command.d.ts +67 -0
- package/dist/commands/bundle/bundle-create-command.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-format.d.ts +89 -0
- package/dist/commands/bundle/bundle-format.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-list.d.ts +92 -0
- package/dist/commands/bundle/bundle-list.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts +81 -0
- package/dist/commands/bundle/bundle-read-commands.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-support.d.ts +32 -0
- package/dist/commands/bundle/bundle-support.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-transport.d.ts +38 -0
- package/dist/commands/bundle/bundle-transport.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts +43 -0
- package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-uri.d.ts +55 -0
- package/dist/commands/bundle/bundle-uri.d.ts.map +1 -0
- package/dist/commands/bundle/bundle-verify.d.ts +63 -0
- package/dist/commands/bundle/bundle-verify.d.ts.map +1 -0
- package/dist/commands/bundle/index.d.ts +14 -0
- package/dist/commands/bundle/index.d.ts.map +1 -0
- package/dist/commands/cat-file/batch-format.d.ts +58 -0
- package/dist/commands/cat-file/batch-format.d.ts.map +1 -0
- package/dist/commands/cat-file/cat-file-command.d.ts +135 -0
- package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -0
- package/dist/commands/cat-file/index.d.ts +3 -0
- package/dist/commands/cat-file/index.d.ts.map +1 -0
- package/dist/commands/check-attr-command.d.ts +66 -0
- package/dist/commands/check-attr-command.d.ts.map +1 -0
- package/dist/commands/check-ignore-command.d.ts +58 -0
- package/dist/commands/check-ignore-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/check-ref-format-command.d.ts +60 -0
- package/dist/commands/check-ref-format-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +7 -0
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-index-command.d.ts +96 -0
- package/dist/commands/checkout-index-command.d.ts.map +1 -0
- 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 +33 -1
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +32 -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 +135 -2
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +59 -3
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/config-command.d.ts +2 -0
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/daemon-access-hook.d.ts +36 -0
- package/dist/commands/daemon-access-hook.d.ts.map +1 -0
- package/dist/commands/default-branch.d.ts +42 -0
- package/dist/commands/default-branch.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-command.d.ts +249 -10
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/diff-external.d.ts +43 -0
- package/dist/commands/diff-external.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts +27 -0
- package/dist/commands/diff-plumbing/diff-pairs-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts +129 -0
- package/dist/commands/diff-plumbing/diff-plumbing-command.d.ts.map +1 -0
- package/dist/commands/diff-plumbing/index.d.ts +3 -0
- package/dist/commands/diff-plumbing/index.d.ts.map +1 -0
- package/dist/commands/diff-textconv.d.ts +5 -1
- package/dist/commands/diff-textconv.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-export-command.d.ts +135 -0
- package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-import-command.d.ts +182 -0
- package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts +64 -0
- package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -0
- package/dist/commands/fast-export/index.d.ts +4 -0
- package/dist/commands/fast-export/index.d.ts.map +1 -0
- package/dist/commands/fetch-command.d.ts +125 -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/format-patch-command.d.ts +28 -2
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/format-rev-command.d.ts +58 -0
- package/dist/commands/format-rev-command.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-msg-ids.d.ts +18 -3
- package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -1
- package/dist/commands/fsmonitor-refresh.d.ts +69 -0
- package/dist/commands/fsmonitor-refresh.d.ts.map +1 -0
- package/dist/commands/gc-command.d.ts +5 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +77 -4
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +47 -1
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/git-paths.d.ts +26 -0
- package/dist/commands/git-paths.d.ts.map +1 -0
- package/dist/commands/grep/grep-command.d.ts +2 -1
- package/dist/commands/grep/grep-command.d.ts.map +1 -1
- package/dist/commands/history-command.d.ts +156 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/http-config.d.ts +38 -0
- package/dist/commands/http-config.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +12 -1
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index-host.d.ts.map +1 -1
- package/dist/commands/index.d.ts +56 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +6 -3
- package/dist/commands/init-command.d.ts +89 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/last-modified-command.d.ts +102 -0
- package/dist/commands/last-modified-command.d.ts.map +1 -0
- package/dist/commands/lfs/go-url.d.ts +43 -0
- package/dist/commands/lfs/go-url.d.ts.map +1 -0
- package/dist/commands/lfs/index.d.ts +3 -0
- package/dist/commands/lfs/index.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-config.d.ts +174 -0
- package/dist/commands/lfs/lfs-config.d.ts.map +1 -0
- package/dist/commands/lfs/lfs-endpoint-command.d.ts +83 -0
- package/dist/commands/lfs/lfs-endpoint-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.map +1 -1
- package/dist/commands/log-command.d.ts +261 -6
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +4 -2
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +88 -2
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-files-command.d.ts +153 -0
- package/dist/commands/ls-files-command.d.ts.map +1 -0
- package/dist/commands/ls-remote-command.d.ts +5 -0
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/ls-tree-command.d.ts +105 -0
- package/dist/commands/ls-tree-command.d.ts.map +1 -0
- package/dist/commands/mailmap.d.ts +24 -1
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/maintenance-run-command.d.ts +122 -0
- package/dist/commands/maintenance-run-command.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +58 -1
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-config.d.ts +7 -0
- package/dist/commands/merge-config.d.ts.map +1 -1
- package/dist/commands/merge-drivers.d.ts +69 -5
- 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 +16 -0
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/merge-tree-command.d.ts +122 -0
- package/dist/commands/merge-tree-command.d.ts.map +1 -0
- package/dist/commands/message-cleanup.d.ts +2 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -1
- package/dist/commands/mktag-command.d.ts +51 -0
- package/dist/commands/mktag-command.d.ts.map +1 -0
- 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 +110 -22
- package/dist/commands/name-rev.d.ts.map +1 -1
- package/dist/commands/object-store/count-objects-command.d.ts +58 -0
- package/dist/commands/object-store/count-objects-command.d.ts.map +1 -0
- package/dist/commands/object-store/index.d.ts +5 -0
- package/dist/commands/object-store/index.d.ts.map +1 -0
- package/dist/commands/object-store/objects-directory.d.ts +12 -0
- package/dist/commands/object-store/objects-directory.d.ts.map +1 -0
- package/dist/commands/object-store/prune-command.d.ts +38 -0
- package/dist/commands/object-store/prune-command.d.ts.map +1 -0
- package/dist/commands/object-store/show-index-command.d.ts +23 -0
- package/dist/commands/object-store/show-index-command.d.ts.map +1 -0
- 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 +40 -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-command.d.ts +30 -0
- package/dist/commands/patch-id-command.d.ts.map +1 -0
- package/dist/commands/patch-id.d.ts +82 -0
- package/dist/commands/patch-id.d.ts.map +1 -1
- package/dist/commands/plumbing-command.d.ts +66 -0
- package/dist/commands/plumbing-command.d.ts.map +1 -0
- package/dist/commands/plumbing-input.d.ts +38 -0
- package/dist/commands/plumbing-input.d.ts.map +1 -0
- package/dist/commands/promisor-remote-reply.d.ts +35 -0
- package/dist/commands/promisor-remote-reply.d.ts.map +1 -0
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +182 -38
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +82 -2
- 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 +14 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +129 -4
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/refs-command.d.ts +81 -0
- package/dist/commands/refs-command.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 +41 -0
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-object-info-command.d.ts +55 -0
- package/dist/commands/remote-object-info-command.d.ts.map +1 -0
- 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 +40 -3
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/repack-command.d.ts +115 -0
- package/dist/commands/repack-command.d.ts.map +1 -0
- package/dist/commands/replace-command.d.ts +143 -0
- package/dist/commands/replace-command.d.ts.map +1 -0
- package/dist/commands/replay-command.d.ts +117 -0
- package/dist/commands/replay-command.d.ts.map +1 -0
- package/dist/commands/repo-command.d.ts +136 -0
- package/dist/commands/repo-command.d.ts.map +1 -0
- package/dist/commands/request-pull-command.d.ts +82 -0
- package/dist/commands/request-pull-command.d.ts.map +1 -0
- package/dist/commands/rerere-command.d.ts +36 -0
- package/dist/commands/rerere-command.d.ts.map +1 -0
- package/dist/commands/rerere.d.ts +102 -0
- package/dist/commands/rerere.d.ts.map +1 -0
- package/dist/commands/reset-command.d.ts +19 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +7 -0
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-filter/commit-grep.d.ts +3 -1
- package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -1
- package/dist/commands/rev-list-command.d.ts +78 -3
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/rev-parse-command.d.ts +9 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +32 -1
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +7 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +12 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +120 -1
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +10 -1
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +23 -1
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/session-id.d.ts +18 -0
- package/dist/commands/session-id.d.ts.map +1 -0
- 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-branch-command.d.ts +59 -0
- package/dist/commands/show-branch-command.d.ts.map +1 -0
- package/dist/commands/show-ref-command.d.ts +112 -0
- package/dist/commands/show-ref-command.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +9 -2
- package/dist/commands/signature-check.d.ts.map +1 -1
- package/dist/commands/signing.d.ts +22 -1
- package/dist/commands/signing.d.ts.map +1 -1
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-export-command.d.ts +115 -0
- package/dist/commands/stash-export-command.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +33 -3
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/stripspace-command.d.ts +44 -0
- package/dist/commands/stripspace-command.d.ts.map +1 -0
- package/dist/commands/submodule-add-command.d.ts +10 -1
- package/dist/commands/submodule-add-command.d.ts.map +1 -1
- package/dist/commands/submodule-auth.d.ts +3 -1
- package/dist/commands/submodule-auth.d.ts.map +1 -1
- package/dist/commands/submodule-commands.d.ts +99 -3
- package/dist/commands/submodule-commands.d.ts.map +1 -1
- 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 +8 -0
- package/dist/commands/submodule-model.d.ts.map +1 -1
- 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 +21 -1
- package/dist/commands/submodule-update-command.d.ts.map +1 -1
- 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/textconv-cache.d.ts +58 -0
- package/dist/commands/textconv-cache.d.ts.map +1 -0
- package/dist/commands/tree-restore.d.ts +5 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/unpack-objects-command.d.ts +47 -0
- package/dist/commands/unpack-objects-command.d.ts.map +1 -0
- package/dist/commands/update-index-command.d.ts +110 -0
- package/dist/commands/update-index-command.d.ts.map +1 -0
- package/dist/commands/uri-protocols.d.ts +13 -0
- package/dist/commands/uri-protocols.d.ts.map +1 -0
- package/dist/commands/url-parse-command.d.ts +30 -0
- package/dist/commands/url-parse-command.d.ts.map +1 -0
- package/dist/commands/var-command.d.ts +42 -0
- package/dist/commands/var-command.d.ts.map +1 -0
- package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/{commands-ISM52N0n.js → commands-Mlo1dxQN.js} +56133 -70269
- package/dist/errors/command-errors.d.ts +58 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +67 -1
- package/dist/fsck-CrhVMNIH.js +5179 -0
- package/dist/git-command.d.ts +89 -3
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +628 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +84 -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 +7 -5
- package/dist/maintenance-run-command-Bw21HEkH.js +13539 -0
- package/dist/remote-transport-Bu4PGSMD.js +2605 -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/cherry-pick-result.d.ts +6 -0
- package/dist/results/cherry-pick-result.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/diff-dirstat.d.ts +36 -0
- package/dist/results/diff-dirstat.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +20 -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 +67 -3
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/fetch-result.d.ts +24 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +2 -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 +13 -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 +10 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +7 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +6 -0
- package/dist/results/revert-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +5 -0
- package/dist/results/stash-result.d.ts.map +1 -1
- package/dist/results/status-result.d.ts +1 -1
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-ERo9vELd.js +49673 -0
- package/dist/transport-command.d.ts +93 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/commands/add-command.ts +118 -0
- package/src/commands/add-patch/add-patch.ts +8 -0
- package/src/commands/add-patch/patch-backend.ts +24 -3
- package/src/commands/add-patch/patch-modes.ts +26 -2
- package/src/commands/add-patch/patch-session.ts +6 -0
- package/src/commands/am/am-command.ts +301 -12
- package/src/commands/apply/apply-command.ts +52 -9
- package/src/commands/apply/apply-parse.ts +10 -0
- package/src/commands/apply/index.ts +9 -1
- package/src/commands/archive/archive-command.ts +1148 -0
- package/src/commands/archive/archive-entry.ts +93 -0
- package/src/commands/archive/index.ts +7 -0
- package/src/commands/archive/remote-archive-command.ts +140 -0
- package/src/commands/archive/tar-archive.ts +207 -0
- package/src/commands/archive/tar-commit-id.ts +72 -0
- package/src/commands/archive/upload-archive-writer.ts +213 -0
- package/src/commands/archive/zip-archive.ts +317 -0
- package/src/commands/attributes-source.ts +26 -12
- package/src/commands/blame-command.ts +1551 -53
- package/src/commands/blame-ignore.ts +307 -0
- package/src/commands/bundle/bundle-create-command.ts +405 -0
- package/src/commands/bundle/bundle-format.ts +228 -0
- package/src/commands/bundle/bundle-list.ts +276 -0
- package/src/commands/bundle/bundle-read-commands.ts +157 -0
- package/src/commands/bundle/bundle-support.ts +85 -0
- package/src/commands/bundle/bundle-transport.ts +107 -0
- package/src/commands/bundle/bundle-uri-host.ts +204 -0
- package/src/commands/bundle/bundle-uri.ts +236 -0
- package/src/commands/bundle/bundle-verify.ts +152 -0
- package/src/commands/bundle/index.ts +14 -0
- package/src/commands/cat-file/batch-format.ts +193 -0
- package/src/commands/cat-file/cat-file-command.ts +857 -0
- package/src/commands/cat-file/index.ts +2 -0
- package/src/commands/check-attr-command.ts +333 -0
- package/src/commands/check-ignore-command.ts +261 -0
- package/src/commands/check-mailmap-command.ts +129 -0
- package/src/commands/check-ref-format-command.ts +129 -0
- package/src/commands/checkout-command.ts +131 -28
- package/src/commands/checkout-index-command.ts +568 -0
- package/src/commands/checkout-paths.ts +35 -0
- package/src/commands/cherry-command.ts +187 -0
- package/src/commands/cherry-pick-command.ts +63 -2
- package/src/commands/clean-command.ts +92 -12
- package/src/commands/clean-interactive.ts +522 -0
- package/src/commands/clone-command.ts +803 -50
- package/src/commands/commit-command.ts +202 -51
- package/src/commands/config-command.ts +9 -0
- package/src/commands/daemon-access-hook.ts +78 -0
- package/src/commands/default-branch.ts +99 -1
- package/src/commands/describe-command.ts +341 -254
- package/src/commands/diff-command.ts +1186 -99
- package/src/commands/diff-external.ts +131 -0
- package/src/commands/diff-plumbing/diff-pairs-command.ts +193 -0
- package/src/commands/diff-plumbing/diff-plumbing-command.ts +424 -0
- package/src/commands/diff-plumbing/index.ts +2 -0
- package/src/commands/diff-textconv.ts +5 -1
- package/src/commands/fast-export/fast-export-command.ts +911 -0
- package/src/commands/fast-export/fast-import-command.ts +1553 -0
- package/src/commands/fast-export/fast-stream-support.ts +162 -0
- package/src/commands/fast-export/index.ts +3 -0
- package/src/commands/fetch-command.ts +665 -14
- package/src/commands/fetch-multiple-command.ts +668 -0
- package/src/commands/format-patch-command.ts +189 -77
- package/src/commands/format-rev-command.ts +251 -0
- package/src/commands/fsck/fsck-command.ts +47 -20
- package/src/commands/fsck/fsck-msg-ids.ts +19 -3
- package/src/commands/fsck/fsck-pack.ts +2 -2
- package/src/commands/fsmonitor-refresh.ts +315 -0
- package/src/commands/gc-command.ts +10 -0
- package/src/commands/git-describe.ts +456 -217
- package/src/commands/git-hooks.ts +165 -9
- package/src/commands/git-paths.ts +136 -0
- package/src/commands/grep/grep-command.ts +38 -15
- package/src/commands/history-command.ts +617 -0
- package/src/commands/http-config.ts +139 -0
- package/src/commands/index-adder.ts +37 -3
- package/src/commands/index-host.ts +6 -1
- package/src/commands/index.ts +62 -0
- package/src/commands/init-command.ts +617 -49
- package/src/commands/last-modified-command.ts +804 -0
- package/src/commands/lfs/go-url.ts +370 -0
- package/src/commands/lfs/index.ts +2 -0
- package/src/commands/lfs/lfs-config.ts +738 -0
- package/src/commands/lfs/lfs-endpoint-command.ts +180 -0
- package/src/commands/line-log.ts +931 -0
- package/src/commands/local-transport.ts +252 -4
- package/src/commands/log-command.ts +1518 -182
- package/src/commands/log-graph.ts +6 -3
- package/src/commands/log-output.ts +228 -15
- package/src/commands/ls-files-command.ts +1177 -0
- package/src/commands/ls-remote-command.ts +6 -0
- package/src/commands/ls-tree-command.ts +684 -0
- package/src/commands/mailmap.ts +41 -5
- package/src/commands/maintenance-run-command.ts +949 -0
- package/src/commands/merge-command.ts +351 -47
- package/src/commands/merge-config.ts +23 -1
- package/src/commands/merge-drivers.ts +112 -20
- package/src/commands/merge-strategy-options.ts +224 -0
- package/src/commands/merge-support.ts +130 -26
- package/src/commands/merge-tree-command.ts +786 -0
- package/src/commands/message-cleanup.ts +1 -1
- package/src/commands/mktag-command.ts +149 -0
- package/src/commands/name-rev-command.ts +184 -0
- package/src/commands/name-rev.ts +700 -109
- package/src/commands/object-store/count-objects-command.ts +404 -0
- package/src/commands/object-store/index.ts +4 -0
- package/src/commands/object-store/objects-directory.ts +24 -0
- package/src/commands/object-store/prune-command.ts +129 -0
- package/src/commands/object-store/show-index-command.ts +151 -0
- package/src/commands/octopus-merge.ts +35 -11
- package/src/commands/ort-merge.ts +124 -23
- package/src/commands/ort-recursive.ts +40 -2
- package/src/commands/patch-id-command.ts +65 -0
- package/src/commands/patch-id.ts +327 -0
- package/src/commands/plumbing-command.ts +141 -0
- package/src/commands/plumbing-input.ts +87 -0
- package/src/commands/promisor-remote-reply.ts +276 -0
- package/src/commands/promisor-remote.ts +25 -2
- package/src/commands/pull-command.ts +720 -224
- package/src/commands/push-command.ts +440 -8
- 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 +74 -3
- package/src/commands/rebase-command.ts +647 -83
- package/src/commands/refs-command.ts +274 -0
- package/src/commands/remerge-diff.ts +241 -0
- package/src/commands/remote-command.ts +98 -10
- package/src/commands/remote-object-info-command.ts +109 -0
- package/src/commands/remote-show-command.ts +836 -0
- package/src/commands/remote-transport.ts +116 -1
- package/src/commands/repack-command.ts +383 -0
- package/src/commands/replace-command.ts +816 -0
- package/src/commands/replay-command.ts +674 -0
- package/src/commands/repo-command.ts +967 -0
- package/src/commands/request-pull-command.ts +356 -0
- package/src/commands/rerere-command.ts +179 -0
- package/src/commands/rerere.ts +925 -0
- package/src/commands/reset-command.ts +78 -3
- package/src/commands/restore-command.ts +15 -0
- package/src/commands/rev-filter/commit-grep.ts +7 -2
- package/src/commands/rev-list-command.ts +196 -11
- package/src/commands/rev-parse-command.ts +62 -4
- package/src/commands/revert-command.ts +62 -2
- package/src/commands/revision-range.ts +10 -3
- package/src/commands/revision-resolver.ts +44 -3
- package/src/commands/sequencer-pick.ts +370 -29
- package/src/commands/sequencer-support.ts +164 -2
- package/src/commands/serve-repository.ts +65 -0
- package/src/commands/session-id.ts +31 -0
- package/src/commands/shortlog-command.ts +354 -0
- package/src/commands/shortlog.ts +361 -0
- package/src/commands/show-branch-command.ts +981 -0
- package/src/commands/show-command.ts +3 -2
- package/src/commands/show-ref-command.ts +439 -0
- package/src/commands/signature-check.ts +37 -5
- package/src/commands/signing.ts +122 -16
- package/src/commands/stash-apply-command.ts +3 -0
- package/src/commands/stash-export-command.ts +397 -0
- package/src/commands/status-command.ts +158 -31
- package/src/commands/status-format.ts +1 -1
- package/src/commands/stripspace-command.ts +118 -0
- package/src/commands/submodule-add-command.ts +22 -1
- package/src/commands/submodule-auth.ts +61 -6
- package/src/commands/submodule-commands.ts +333 -5
- package/src/commands/submodule-fetch.ts +789 -0
- package/src/commands/submodule-model.ts +9 -1
- package/src/commands/submodule-unpack.ts +265 -0
- package/src/commands/submodule-update-command.ts +68 -5
- package/src/commands/subtree-shift.ts +215 -0
- package/src/commands/switch-command.ts +9 -0
- package/src/commands/textconv-cache.ts +143 -0
- package/src/commands/tree-restore.ts +20 -1
- package/src/commands/unpack-objects-command.ts +235 -0
- package/src/commands/update-index-command.ts +1016 -0
- package/src/commands/uri-protocols.ts +13 -0
- package/src/commands/url-parse-command.ts +67 -0
- package/src/commands/var-command.ts +219 -0
- package/src/commands/worktree-overwrite-checks.ts +5 -0
- package/src/errors/command-errors.ts +80 -0
- package/src/git-command.ts +218 -2
- package/src/git.ts +1033 -80
- package/src/guarded-transport-command.ts +176 -0
- package/src/index.ts +1 -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/cherry-pick-result.ts +6 -0
- package/src/results/clone-result.ts +6 -0
- package/src/results/diff-dirstat.ts +117 -0
- package/src/results/diff-entry.ts +24 -0
- package/src/results/diff-formatter.ts +8 -4
- package/src/results/diff-output.ts +239 -8
- package/src/results/diff-pickaxe.ts +1 -1
- package/src/results/fetch-result.ts +24 -1
- package/src/results/index.ts +2 -0
- package/src/results/init-result.ts +10 -1
- package/src/results/line-range-hunks.ts +126 -0
- package/src/results/merge-result.ts +14 -0
- package/src/results/pull-result.ts +7 -0
- package/src/results/push-result.ts +10 -0
- package/src/results/rebase-result.ts +7 -0
- package/src/results/revert-result.ts +6 -0
- package/src/results/stash-result.ts +6 -0
- package/src/results/status-result.ts +2 -2
- package/src/transport-command.ts +216 -4
- package/dist/fsck-DLRpbwTj.js +0 -13405
- package/dist/results-TB2IJ64h.js +0 -4700
|
@@ -12,9 +12,10 @@ import {
|
|
|
12
12
|
parseGitBool,
|
|
13
13
|
type XdiffAlgorithm,
|
|
14
14
|
} from "@statewalker/vcs-utils";
|
|
15
|
-
import { compareGitPaths, decodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
15
|
+
import { compareGitPaths, decodeGitPath, encodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
16
16
|
import {
|
|
17
17
|
type AttributesIndex,
|
|
18
|
+
basicStatMatches,
|
|
18
19
|
collectChunks,
|
|
19
20
|
compareWithWorktree,
|
|
20
21
|
expandUserPath,
|
|
@@ -36,14 +37,27 @@ import {
|
|
|
36
37
|
import { GitCommand } from "../git-command.js";
|
|
37
38
|
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
38
39
|
import {
|
|
40
|
+
type BreakScores,
|
|
41
|
+
countChanges,
|
|
39
42
|
DEFAULT_RENAME_LIMIT,
|
|
40
43
|
detectRenames,
|
|
41
44
|
findFollowSource,
|
|
45
|
+
parseBreakRewrites,
|
|
46
|
+
renameScoreOption,
|
|
42
47
|
scorePercent,
|
|
48
|
+
shouldBreak,
|
|
49
|
+
spanCounts,
|
|
43
50
|
} from "../rename/index.js";
|
|
44
51
|
import { writeCombinedDiff } from "../results/combined-diff.js";
|
|
45
52
|
import { conflictMarkerSizeOf, writePairCheck } from "../results/diff-check.js";
|
|
46
53
|
import { MovedLineBuffer } from "../results/diff-color.js";
|
|
54
|
+
import {
|
|
55
|
+
DEFAULT_DIRSTAT,
|
|
56
|
+
type DirstatFile,
|
|
57
|
+
type DirstatParams,
|
|
58
|
+
formatDirstat,
|
|
59
|
+
parseDirstatParams,
|
|
60
|
+
} from "../results/diff-dirstat.js";
|
|
47
61
|
import { ChangeType, type DiffEntry } from "../results/diff-entry.js";
|
|
48
62
|
import { diffEntryToPair } from "../results/diff-formatter.js";
|
|
49
63
|
import { orderByPatterns, parseOrderFile } from "../results/diff-order.js";
|
|
@@ -54,15 +68,19 @@ import {
|
|
|
54
68
|
type DiffDriver,
|
|
55
69
|
type DiffFilePair,
|
|
56
70
|
type DiffOutputOptions,
|
|
71
|
+
type DiffSideSpec,
|
|
57
72
|
type DiffstatFile,
|
|
58
73
|
type DiffstatOptions,
|
|
59
74
|
diffDriverOf,
|
|
75
|
+
externalDiffMetainfo,
|
|
60
76
|
formatNameOnly,
|
|
61
77
|
formatNameStatus,
|
|
62
78
|
formatNumstat,
|
|
79
|
+
formatRawPair,
|
|
63
80
|
formatShortstat,
|
|
64
81
|
formatStat,
|
|
65
82
|
formatSummary,
|
|
83
|
+
writeHeaderOnlyPatch,
|
|
66
84
|
writePairPatch,
|
|
67
85
|
} from "../results/diff-output.js";
|
|
68
86
|
import { DiffPickaxe } from "../results/diff-pickaxe.js";
|
|
@@ -81,8 +99,20 @@ import {
|
|
|
81
99
|
readDiffColorSettings,
|
|
82
100
|
whitespaceRuleError,
|
|
83
101
|
} from "./diff-color-config.js";
|
|
84
|
-
import {
|
|
85
|
-
|
|
102
|
+
import {
|
|
103
|
+
ExternalDiffDiedError,
|
|
104
|
+
type ExternalDiffProgram,
|
|
105
|
+
ExternalDiffTempFiles,
|
|
106
|
+
externalDiffProgramOf,
|
|
107
|
+
} from "./diff-external.js";
|
|
108
|
+
import { type TextconvRequest, type TextconvRunner, textconvRunnerOf } from "./diff-textconv.js";
|
|
109
|
+
import {
|
|
110
|
+
DO_MATCH_DIRECTORY,
|
|
111
|
+
DO_MATCH_LEADING_PATHSPEC,
|
|
112
|
+
matchPathspec,
|
|
113
|
+
type PathspecItem,
|
|
114
|
+
parsePathspecItem,
|
|
115
|
+
} from "./pathspec.js";
|
|
86
116
|
import { PathspecAttributes } from "./pathspec-attributes.js";
|
|
87
117
|
import { revisionMergeBases } from "./rev-parse-command.js";
|
|
88
118
|
import { readSubmoduleDirt, type SubmoduleDirt } from "./status-command.js";
|
|
@@ -98,6 +128,7 @@ import {
|
|
|
98
128
|
showSubmoduleDiffSummary,
|
|
99
129
|
submoduleHeader,
|
|
100
130
|
} from "./submodule-summary.js";
|
|
131
|
+
import { TextconvCaches } from "./textconv-cache.js";
|
|
101
132
|
|
|
102
133
|
/** An index without in-tree attributes files: the attribute stack of a diff of two trees. */
|
|
103
134
|
const WITHOUT_INDEX_ATTRIBUTES: { direction: "checkin"; index: AttributesIndex } = {
|
|
@@ -110,7 +141,7 @@ const WITHOUT_INDEX_ATTRIBUTES: { direction: "checkin"; index: AttributesIndex }
|
|
|
110
141
|
* The outputs whose diff git prefetches (diffcore_std's `output_formats_to_prefetch`: the
|
|
111
142
|
* diffstat kinds, the patch, `--dirstat`)
|
|
112
143
|
*/
|
|
113
|
-
const PREFETCH_FORMATS = new Set<string>(["patch", "stat", "numstat", "shortstat"]);
|
|
144
|
+
const PREFETCH_FORMATS = new Set<string>(["patch", "stat", "numstat", "shortstat", "dirstat"]);
|
|
114
145
|
|
|
115
146
|
/**
|
|
116
147
|
* The repository blobs of a diff's pairs (git's `diff_add_if_missing`: each side whose id is
|
|
@@ -138,6 +169,11 @@ function prefetchIds(entries: readonly DiffEntry[]): ObjectId[] {
|
|
|
138
169
|
}
|
|
139
170
|
|
|
140
171
|
export type DiffOutputFormat =
|
|
172
|
+
/**
|
|
173
|
+
* `--raw` (diff.c's `diff_flush_raw`): `:<old mode> <new mode> <old id> <new id> <status>`,
|
|
174
|
+
* a tab and the path(s); ids abbreviated unless {@link DiffTextOptions.rawFullIds}
|
|
175
|
+
*/
|
|
176
|
+
| "raw"
|
|
141
177
|
| "patch"
|
|
142
178
|
| "stat"
|
|
143
179
|
| "numstat"
|
|
@@ -145,6 +181,11 @@ export type DiffOutputFormat =
|
|
|
145
181
|
| "summary"
|
|
146
182
|
| "name-only"
|
|
147
183
|
| "name-status"
|
|
184
|
+
/**
|
|
185
|
+
* `--dirstat`: the share of the change each directory holds (see
|
|
186
|
+
* {@link DiffTextOptions.dirstat}, `diff.dirstat`)
|
|
187
|
+
*/
|
|
188
|
+
| "dirstat"
|
|
148
189
|
/**
|
|
149
190
|
* `--check`: the whitespace errors and leftover conflict markers the change adds (see
|
|
150
191
|
* {@link writePairCheck}); it turns the other formats off, and {@link DiffCommand.exitCode}
|
|
@@ -164,6 +205,7 @@ export interface DiffTextOptions
|
|
|
164
205
|
| "wsHighlight"
|
|
165
206
|
| "whitespaceRule"
|
|
166
207
|
| "defaultWordRegex"
|
|
208
|
+
| "anchors"
|
|
167
209
|
>,
|
|
168
210
|
DiffColorOptions {
|
|
169
211
|
/**
|
|
@@ -188,6 +230,16 @@ export interface DiffTextOptions
|
|
|
188
230
|
abbrev?: number;
|
|
189
231
|
/** `--stat=...` widths (default width 80, as git without a terminal) */
|
|
190
232
|
stat?: DiffstatOptions;
|
|
233
|
+
/**
|
|
234
|
+
* `-z`: the `raw`, `name-only`, `name-status` and `numstat` outputs end each field with a
|
|
235
|
+
* NUL instead of a tab or a newline, paths unquoted; the separator before a patch is a NUL
|
|
236
|
+
*/
|
|
237
|
+
nullTerminated?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* The `raw` output's ids in full, as the plumbing commands print them (`opt->abbrev = 0`)
|
|
240
|
+
* unless `--abbrev` is given ({@link abbrev}); default false (`git diff --raw` abbreviates)
|
|
241
|
+
*/
|
|
242
|
+
rawFullIds?: boolean;
|
|
191
243
|
/**
|
|
192
244
|
* Score renames counting a last line without a newline, as git 2.50 and later (default
|
|
193
245
|
* true); false scores them as older git
|
|
@@ -240,6 +292,15 @@ export interface DiffTextOptions
|
|
|
240
292
|
* `installTextconvRunner`, without one no textconv applies
|
|
241
293
|
*/
|
|
242
294
|
textconv?: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* `--ext-diff` / `--no-ext-diff`: run external diff programs (`GIT_EXTERNAL_DIFF`,
|
|
297
|
+
* `diff.external`, `diff.<driver>.command`) instead of the builtin patch. Default false;
|
|
298
|
+
* `Git.diff()` (porcelain `git diff`) turns it on, as git, while `git log`/`show` and the
|
|
299
|
+
* plumbing diffs need it asked. The programs run through the host's `hookRunner`, their
|
|
300
|
+
* sides written in its `tempDirectory` through `hostFilesOf`; without those the builtin
|
|
301
|
+
* patch is shown. See `diff-external.ts`.
|
|
302
|
+
*/
|
|
303
|
+
extDiff?: boolean;
|
|
243
304
|
/**
|
|
244
305
|
* `-R`: the two sides swapped (an addition shows as a deletion, the new side first), their
|
|
245
306
|
* prefixes with them (`diff --git b/f a/f`). Combined diffs of conflicted paths are not swapped.
|
|
@@ -314,6 +375,39 @@ export interface DiffTextOptions
|
|
|
314
375
|
pickaxeAll?: boolean;
|
|
315
376
|
/** `-i` / `--regexp-ignore-case` of `-S`/`-G` (ASCII case folded) */
|
|
316
377
|
pickaxeIgnoreCase?: boolean;
|
|
378
|
+
/**
|
|
379
|
+
* `-M[<n>]` / `--find-renames[=<n>]`: detect renames, at least this similar (git's
|
|
380
|
+
* syntax: `90%`, `9` and `.9` alike; `true` the default 50%); `false` is `--no-renames`.
|
|
381
|
+
* Wins over {@link DiffCommand.setRenames} and `diff.renames`. Trailing text throws git's
|
|
382
|
+
* `error: invalid argument to find-renames` (exit 129).
|
|
383
|
+
*/
|
|
384
|
+
findRenames?: boolean | string;
|
|
385
|
+
/**
|
|
386
|
+
* `-C[<n>]` / `--find-copies[=<n>]`: renames and copies, from the modified paths too (the
|
|
387
|
+
* threshold as {@link findRenames}). With `diff.renames=copies` and nothing else asking,
|
|
388
|
+
* git's second `-C` is found: copies are then found harder.
|
|
389
|
+
*/
|
|
390
|
+
findCopies?: boolean | string;
|
|
391
|
+
/** `--find-copies-harder` (or `-C -C`): unchanged paths are copy sources too */
|
|
392
|
+
findCopiesHarder?: boolean;
|
|
393
|
+
/**
|
|
394
|
+
* `-B[<n>][/<m>]` / `--break-rewrites`: modifications that changed at least `<n>` (default
|
|
395
|
+
* 50%) are broken into a deletion and a creation for rename detection, and merged back
|
|
396
|
+
* unless they removed at least `<m>` (default 60%) of the old content, shown then as a
|
|
397
|
+
* complete rewrite (`dissimilarity index`, `M<score>`)
|
|
398
|
+
*/
|
|
399
|
+
breakRewrites?: boolean | string;
|
|
400
|
+
/**
|
|
401
|
+
* `--dirstat=<params>` for the `dirstat` format: comma-separated `changes`, `lines`,
|
|
402
|
+
* `files`, `cumulative`, `noncumulative` and a cut-off percentage (default `diff.dirstat`,
|
|
403
|
+
* else `changes,noncumulative,3`)
|
|
404
|
+
*/
|
|
405
|
+
dirstat?: string;
|
|
406
|
+
/**
|
|
407
|
+
* `--anchored=<text>`: the patience diff, lines starting with one of these texts kept
|
|
408
|
+
* unchanged where they are unique on both sides
|
|
409
|
+
*/
|
|
410
|
+
anchored?: readonly string[];
|
|
317
411
|
}
|
|
318
412
|
|
|
319
413
|
/** Whether options ask for a pickaxe (git's `DIFF_PICKAXE_KINDS_MASK`) */
|
|
@@ -415,8 +509,11 @@ function statusOf(entry: DiffEntry): string {
|
|
|
415
509
|
/** diffcore_apply_filter over the queue */
|
|
416
510
|
function applyDiffFilter(entries: DiffEntry[], filter: Set<string> | undefined): DiffEntry[] {
|
|
417
511
|
if (!filter) return entries;
|
|
418
|
-
// match_filter: a modification with a score is a broken pair (-B),
|
|
419
|
-
const matches = (e: DiffEntry) =>
|
|
512
|
+
// match_filter: a modification with a score is a broken pair (-B), filtered as `B`
|
|
513
|
+
const matches = (e: DiffEntry) => {
|
|
514
|
+
const status = statusOf(e);
|
|
515
|
+
return status === "M" && e.score ? filter.has("B") : filter.has(status);
|
|
516
|
+
};
|
|
420
517
|
if (filter.has("*")) return entries.some(matches) ? entries : [];
|
|
421
518
|
return entries.filter(matches);
|
|
422
519
|
}
|
|
@@ -467,6 +564,9 @@ function reverseEntry(entry: DiffEntry): DiffEntry {
|
|
|
467
564
|
if (entry.readNew) out.readOld = entry.readNew;
|
|
468
565
|
if (entry.readOld) out.readNew = entry.readOld;
|
|
469
566
|
if (entry.score !== undefined) out.score = entry.score;
|
|
567
|
+
if (entry.lineRanges) out.lineRanges = entry.lineRanges;
|
|
568
|
+
if (entry.newIdNull || entry.newIdUnknown) out.oldIdNull = true;
|
|
569
|
+
if (entry.oldIdNull) out.newIdNull = true;
|
|
470
570
|
return out;
|
|
471
571
|
}
|
|
472
572
|
|
|
@@ -500,6 +600,36 @@ interface Side {
|
|
|
500
600
|
* side holds (`show_modified`), and no exact rename pairs with it.
|
|
501
601
|
*/
|
|
502
602
|
unknownId?: boolean;
|
|
603
|
+
/**
|
|
604
|
+
* Plumbing (`diff-files`, `diff-index`): a file whose stat differs from its entry, which
|
|
605
|
+
* git takes as changed without hashing it (`ie_match_stat`): its raw id is the null id
|
|
606
|
+
*/
|
|
607
|
+
rawNull?: boolean;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/** What {@link DiffCommand.setQueue} runs over a queue given */
|
|
611
|
+
export interface PresetQueueOptions {
|
|
612
|
+
/**
|
|
613
|
+
* Run diffcore's rename and break detection over it as over a comparison's queue
|
|
614
|
+
* (`diffcore_std`), with `-M`/`-C`/`-B` as the text options give them (no `diff.renames`)
|
|
615
|
+
*/
|
|
616
|
+
diffcore?: boolean;
|
|
617
|
+
/**
|
|
618
|
+
* `--find-copies-harder`'s sources besides the queue's: every file of the old side (the
|
|
619
|
+
* old tree, the index of `diff-files`)
|
|
620
|
+
*/
|
|
621
|
+
copySources?: () => Promise<Map<string, { mode: number; id: ObjectId }>>;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/** diffcore's settings of one run (see `DiffCommand.diffcoreSettings`) */
|
|
625
|
+
interface DiffcoreSettings {
|
|
626
|
+
detect: false | "renames" | "copies";
|
|
627
|
+
/** The rename/copy threshold (git's `rename_score`), default 50% */
|
|
628
|
+
score?: number;
|
|
629
|
+
/** `--find-copies-harder` */
|
|
630
|
+
harder: boolean;
|
|
631
|
+
/** `-B` */
|
|
632
|
+
breaks?: BreakScores;
|
|
503
633
|
}
|
|
504
634
|
|
|
505
635
|
/** An index entry, of any stage */
|
|
@@ -525,6 +655,9 @@ function submoduleIgnoreValue(
|
|
|
525
655
|
|
|
526
656
|
const S_IFMT = 0o170000;
|
|
527
657
|
const GITLINK = 0o160000;
|
|
658
|
+
const SYMLINK = 0o120000;
|
|
659
|
+
/** A mode as git's `%06o` prints it */
|
|
660
|
+
const octal6 = (mode: number) => mode.toString(8).padStart(6, "0");
|
|
528
661
|
const encoder = new TextEncoder();
|
|
529
662
|
|
|
530
663
|
/** The chunks as one array. */
|
|
@@ -562,8 +695,12 @@ function abbrevOption(value: number | undefined): number | undefined {
|
|
|
562
695
|
return Math.min(40, Math.max(4, Math.trunc(value)));
|
|
563
696
|
}
|
|
564
697
|
|
|
565
|
-
/**
|
|
566
|
-
|
|
698
|
+
/**
|
|
699
|
+
* `diff.renames` as git_config_rename reads it: `copies`/`copy` detect copies too.
|
|
700
|
+
*
|
|
701
|
+
* @internal
|
|
702
|
+
*/
|
|
703
|
+
export function renamesValue(value: string | undefined): boolean | "copies" | undefined {
|
|
567
704
|
if (value === undefined) return undefined;
|
|
568
705
|
const v = value.trim().toLowerCase();
|
|
569
706
|
if (v === "copies" || v === "copy") return "copies";
|
|
@@ -684,6 +821,10 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
684
821
|
private changesFound = false;
|
|
685
822
|
/** git's `check_failed`: `--check` found an error in the last call */
|
|
686
823
|
private checkFailed = false;
|
|
824
|
+
/** git's `diff_path_counter`: the external diff calls made so far */
|
|
825
|
+
private externalCounter = 0;
|
|
826
|
+
/** What external diff programs wrote on stderr in the last call */
|
|
827
|
+
private externalStderr: Uint8Array[] = [];
|
|
687
828
|
/** The revisions given resolved (ranges, `--merge-base`) */
|
|
688
829
|
private sidesResolved = false;
|
|
689
830
|
/** The compiled pickaxe (`-S`, `-G`, `--find-object`), once the options are checked */
|
|
@@ -766,8 +907,10 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
766
907
|
}
|
|
767
908
|
|
|
768
909
|
/**
|
|
769
|
-
* Show intent-to-add entries
|
|
770
|
-
*
|
|
910
|
+
* Show intent-to-add entries as the empty files they name, as plumbing's
|
|
911
|
+
* `diff-index --cached` and `diff-files` do (porcelain `git diff` sets
|
|
912
|
+
* `ita_invisible_in_index`): in a `--cached` comparison on the index side, against the
|
|
913
|
+
* worktree as the old side (`git add -e`'s diff).
|
|
771
914
|
*
|
|
772
915
|
* @internal
|
|
773
916
|
*/
|
|
@@ -870,6 +1013,18 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
870
1013
|
return this.configWarnings;
|
|
871
1014
|
}
|
|
872
1015
|
|
|
1016
|
+
/** What the external diff programs of the last call wrote on stderr (git passes it through) */
|
|
1017
|
+
get programStderr(): Uint8Array {
|
|
1018
|
+
const total = this.externalStderr.reduce((n, c) => n + c.length, 0);
|
|
1019
|
+
const out = new Uint8Array(total);
|
|
1020
|
+
let at = 0;
|
|
1021
|
+
for (const chunk of this.externalStderr) {
|
|
1022
|
+
out.set(chunk, at);
|
|
1023
|
+
at += chunk.length;
|
|
1024
|
+
}
|
|
1025
|
+
return out;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
873
1028
|
/**
|
|
874
1029
|
* git_diff_ui_config, which `git diff` (and log, show) runs before any option is read:
|
|
875
1030
|
* `diff.submodule`, its warnings, and the failure of a variable without a value.
|
|
@@ -884,6 +1039,86 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
884
1039
|
const { format, warnings } = readDiffSubmoduleConfig(this.workingCopy);
|
|
885
1040
|
this.configuredSubmoduleFormat = format;
|
|
886
1041
|
this.configWarnings.splice(0, this.configWarnings.length, ...warnings);
|
|
1042
|
+
// git_diff_ui_config: a diff.dirstat with errors is warned about, the rest applied
|
|
1043
|
+
const dirstat = this.config.value("diff.dirstat");
|
|
1044
|
+
this.configuredDirstat = { ...DEFAULT_DIRSTAT };
|
|
1045
|
+
if (dirstat !== undefined) {
|
|
1046
|
+
const errors = parseDirstatParams(dirstat, this.configuredDirstat);
|
|
1047
|
+
if (errors.length > 0) {
|
|
1048
|
+
this.configWarnings.push(
|
|
1049
|
+
`warning: Found errors in 'diff.dirstat' config variable:\n${errors.join("\n")}\n`,
|
|
1050
|
+
);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
/** `diff.dirstat`'s parameters (git's defaults without it) */
|
|
1056
|
+
private configuredDirstat?: DirstatParams;
|
|
1057
|
+
|
|
1058
|
+
/** The dirstat's parameters: `diff.dirstat`, then {@link DiffTextOptions.dirstat} */
|
|
1059
|
+
private dirstatParams(): DirstatParams {
|
|
1060
|
+
const params = { ...(this.configuredDirstat ?? DEFAULT_DIRSTAT) };
|
|
1061
|
+
const text = this.textOptions.dirstat;
|
|
1062
|
+
if (text !== undefined) {
|
|
1063
|
+
const errors = parseDirstatParams(text, params);
|
|
1064
|
+
if (errors.length > 0) {
|
|
1065
|
+
throw new GitApiError(
|
|
1066
|
+
`fatal: Failed to parse --dirstat/-X option parameter:\n${errors.join("\n")}\n`,
|
|
1067
|
+
).withExitCode(128);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
return params;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
/** show_dirstat (or show_dirstat_by_line): the dirstat of the pairs */
|
|
1074
|
+
private async writeDirstat(
|
|
1075
|
+
sink: ByteSink,
|
|
1076
|
+
pairs: DiffFilePair[],
|
|
1077
|
+
unmerged: Set<DiffFilePair>,
|
|
1078
|
+
options: DiffOutputOptions,
|
|
1079
|
+
params: DirstatParams,
|
|
1080
|
+
): Promise<void> {
|
|
1081
|
+
const files: DirstatFile[] = [];
|
|
1082
|
+
if (params.byLine) {
|
|
1083
|
+
for (const pair of pairs) {
|
|
1084
|
+
if (unmerged.has(pair)) {
|
|
1085
|
+
files.push({ name: pair.new?.path ?? pair.old?.path ?? "", changed: 0 });
|
|
1086
|
+
continue;
|
|
1087
|
+
}
|
|
1088
|
+
for (const f of await computeDiffstat([pair], options)) {
|
|
1089
|
+
const damage = f.added + f.deleted;
|
|
1090
|
+
// binary files count bytes: 64 of them a line
|
|
1091
|
+
files.push({ name: f.name, changed: f.isBinary ? Math.ceil(damage / 64) : damage });
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
} else {
|
|
1095
|
+
const countLastSpan = this.textOptions.renameCountLastSpan;
|
|
1096
|
+
for (const pair of pairs) {
|
|
1097
|
+
if (unmerged.has(pair)) continue;
|
|
1098
|
+
const { old: one, new: two } = pair;
|
|
1099
|
+
const name = two?.path ?? one?.path ?? "";
|
|
1100
|
+
let damage: number;
|
|
1101
|
+
if (one && two && one.idValid !== false && two.idValid !== false && one.id === two.id) {
|
|
1102
|
+
damage = 0;
|
|
1103
|
+
} else if (params.byFile) damage = 1;
|
|
1104
|
+
else {
|
|
1105
|
+
if (one && two) {
|
|
1106
|
+
const a = await one.read();
|
|
1107
|
+
const b = await two.read();
|
|
1108
|
+
const { copied, added } = countChanges(
|
|
1109
|
+
spanCounts(a, { countLastSpan }),
|
|
1110
|
+
spanCounts(b, { countLastSpan }),
|
|
1111
|
+
);
|
|
1112
|
+
damage = a.length - copied + added;
|
|
1113
|
+
} else if (one) damage = (await one.read()).length;
|
|
1114
|
+
else if (two) damage = (await two.read()).length;
|
|
1115
|
+
else continue;
|
|
1116
|
+
if (!damage) damage = 1;
|
|
1117
|
+
}
|
|
1118
|
+
files.push({ name, changed: damage });
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
sink.text(formatDirstat(files, params));
|
|
887
1122
|
}
|
|
888
1123
|
|
|
889
1124
|
/**
|
|
@@ -952,6 +1187,101 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
952
1187
|
return this;
|
|
953
1188
|
}
|
|
954
1189
|
|
|
1190
|
+
/**
|
|
1191
|
+
* The queue {@link callFormats} prints instead of comparing the trees: pairs a caller found
|
|
1192
|
+
* itself (`git log -L` queues each commit's pairs with their line ranges, line-log.c's
|
|
1193
|
+
* `line_log_queue_pairs`). diffcore's later stages (pickaxe, order, `--diff-filter`) still
|
|
1194
|
+
* apply.
|
|
1195
|
+
*
|
|
1196
|
+
* @internal
|
|
1197
|
+
*/
|
|
1198
|
+
setQueue(entries: DiffEntry[], options: PresetQueueOptions = {}): this {
|
|
1199
|
+
this.checkCallable();
|
|
1200
|
+
this.presetQueue = entries;
|
|
1201
|
+
this.presetQueueOptions = options;
|
|
1202
|
+
return this;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
private presetQueue?: DiffEntry[];
|
|
1206
|
+
private presetQueueOptions: PresetQueueOptions = {};
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* How a comparison of trees walks them (tree-diff.c): `recursive` lists the blobs below the
|
|
1210
|
+
* subtrees that differ (`-r`, the porcelain's default), `flat` the differing entries of the
|
|
1211
|
+
* top tree, subtrees as entries of mode 040000 (plumbing's default without `-r`), and
|
|
1212
|
+
* `show-trees` the blobs and the subtrees on the way to them (`-t`)
|
|
1213
|
+
*
|
|
1214
|
+
* @internal
|
|
1215
|
+
*/
|
|
1216
|
+
setTreeWalk(walk: "recursive" | "flat" | "show-trees"): this {
|
|
1217
|
+
this.checkCallable();
|
|
1218
|
+
this.treeWalk = walk;
|
|
1219
|
+
return this;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
private treeWalk: "recursive" | "flat" | "show-trees" = "recursive";
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* Compare the worktree as the plumbing commands do (`diff-files`, `diff-index` without
|
|
1226
|
+
* `--cached`): no refresh, a file whose stat differs from its entry is a change even when
|
|
1227
|
+
* its content is the same, and its raw id is the null id (not hashed); an unmerged path's
|
|
1228
|
+
* raw line gives the worktree file's mode
|
|
1229
|
+
*
|
|
1230
|
+
* @internal
|
|
1231
|
+
*/
|
|
1232
|
+
setPlumbingWorktree(plumbing: boolean): this {
|
|
1233
|
+
this.checkCallable();
|
|
1234
|
+
this.plumbingWorktree = plumbing;
|
|
1235
|
+
return this;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
private plumbingWorktree = false;
|
|
1239
|
+
|
|
1240
|
+
/** The sides an unmerged path's raw line shows (diff_unmerge's pair), by path */
|
|
1241
|
+
private readonly unmergedRaw = new Map<
|
|
1242
|
+
string,
|
|
1243
|
+
{ oldMode?: number; oldId?: ObjectId; newMode?: number }
|
|
1244
|
+
>();
|
|
1245
|
+
|
|
1246
|
+
/** {@link setQueue}'s diffcore run, when asked */
|
|
1247
|
+
private async presetDiffcore(entries: DiffEntry[]): Promise<DiffEntry[]> {
|
|
1248
|
+
const options = this.presetQueueOptions;
|
|
1249
|
+
if (!options.diffcore) return entries;
|
|
1250
|
+
const core = this.diffcoreSettings(false);
|
|
1251
|
+
if (this.textOptions.diffFilter !== undefined) parseDiffFilter(this.textOptions.diffFilter);
|
|
1252
|
+
if (!core.breaks && !core.detect) return entries;
|
|
1253
|
+
const queue = [...entries];
|
|
1254
|
+
const sources = options.copySources;
|
|
1255
|
+
await this.diffcore(queue, core, async () => {
|
|
1256
|
+
const out = new Map<string, Side>();
|
|
1257
|
+
if (sources) for (const [path, side] of await sources()) out.set(path, side);
|
|
1258
|
+
return out;
|
|
1259
|
+
});
|
|
1260
|
+
return queue;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* diffcore's filtering stages over a queue a caller found (the pickaxe, `-O`,
|
|
1265
|
+
* `--diff-filter`): git 2.43's `git log -L` runs them on the pairs it follows renames with
|
|
1266
|
+
*
|
|
1267
|
+
* @internal
|
|
1268
|
+
*/
|
|
1269
|
+
async filterQueue(entries: DiffEntry[]): Promise<DiffEntry[]> {
|
|
1270
|
+
await this.preparePickaxe();
|
|
1271
|
+
return this.selected(entries);
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* The diff driver of a path as a diff of two trees finds it (the worktree's attributes,
|
|
1276
|
+
* `diff.<driver>.*`, the builtin drivers): `git log -L :<funcname>:<file>` finds functions
|
|
1277
|
+
* by its funcname pattern (line-range.c's `userdiff_find_by_path`)
|
|
1278
|
+
*
|
|
1279
|
+
* @internal
|
|
1280
|
+
*/
|
|
1281
|
+
async driverOf(path: string): Promise<DiffDriver | undefined> {
|
|
1282
|
+
return this.outputOptions().driver?.(path);
|
|
1283
|
+
}
|
|
1284
|
+
|
|
955
1285
|
/**
|
|
956
1286
|
* Detect renames (`-M`, `--no-renames`). Default: off for `call()` (each path as added and
|
|
957
1287
|
* deleted), `diff.renames` (default on) for `callText()`.
|
|
@@ -974,6 +1304,52 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
974
1304
|
return true;
|
|
975
1305
|
}
|
|
976
1306
|
|
|
1307
|
+
/** diff.c's `additional_path_headers` (see {@link setAdditionalHeaders}) */
|
|
1308
|
+
private additionalHeaders?: Map<string, readonly string[]>;
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* diff.c's `additional_path_headers` (`--remerge-diff`'s `remerge CONFLICT` lines), by path:
|
|
1312
|
+
* the paths within the pathspec keep theirs (log-tree.c's setup_additional_headers). A
|
|
1313
|
+
* pair's headers follow its rename lines; a path with headers and no change is shown as a
|
|
1314
|
+
* `diff --git` line with its headers alone, unless a pickaxe or a `--diff-filter` without
|
|
1315
|
+
* `U` is given (`include_conflict_headers`).
|
|
1316
|
+
*/
|
|
1317
|
+
setAdditionalHeaders(headers: ReadonlyMap<string, readonly string[]>): this {
|
|
1318
|
+
this.checkCallable();
|
|
1319
|
+
this.additionalHeaders = new Map(headers);
|
|
1320
|
+
return this;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/** The additional headers within the pathspec, undefined for none */
|
|
1324
|
+
private headersInPathspec(): Map<string, readonly string[]> | undefined {
|
|
1325
|
+
const all = this.additionalHeaders;
|
|
1326
|
+
if (!all || all.size === 0) return undefined;
|
|
1327
|
+
if (!this.pathspecItems) return all;
|
|
1328
|
+
const out = new Map<string, readonly string[]>();
|
|
1329
|
+
for (const [path, headers] of all) {
|
|
1330
|
+
if (matchPathspec(this.pathspecItems, path, 0) > 0) out.set(path, headers);
|
|
1331
|
+
}
|
|
1332
|
+
return out.size > 0 ? out : undefined;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
/**
|
|
1336
|
+
* diff.c's `include_conflict_headers`: headers present, no pickaxe, and no `--diff-filter`
|
|
1337
|
+
* or one that keeps `U`
|
|
1338
|
+
*/
|
|
1339
|
+
private includesConflictHeaders(headers: Map<string, readonly string[]> | undefined): boolean {
|
|
1340
|
+
if (!headers || hasPickaxe(this.textOptions)) return false;
|
|
1341
|
+
const filter = this.textOptions.diffFilter;
|
|
1342
|
+
if (filter === undefined) return true;
|
|
1343
|
+
// diff_opt_diff_filter: a lowercase letter starts from every status, each letter then
|
|
1344
|
+
// adds (uppercase) or removes (lowercase) its own
|
|
1345
|
+
let keepsU = /[a-z]/.test(filter);
|
|
1346
|
+
for (const c of filter) {
|
|
1347
|
+
if (c === "U") keepsU = true;
|
|
1348
|
+
else if (c === "u") keepsU = false;
|
|
1349
|
+
}
|
|
1350
|
+
return keepsU;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
977
1353
|
/** Text output options: context, algorithm, whitespace, `--stat` widths, ... */
|
|
978
1354
|
setOptions(options: DiffTextOptions): this {
|
|
979
1355
|
this.checkCallable();
|
|
@@ -991,7 +1367,13 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
991
1367
|
this.setCallable(false);
|
|
992
1368
|
this.dirtyThisCall = this.dirtySubmodules ?? true;
|
|
993
1369
|
const run = async () => {
|
|
994
|
-
|
|
1370
|
+
let entries: DiffEntry[];
|
|
1371
|
+
if (this.presetQueue) {
|
|
1372
|
+
await this.preparePickaxe();
|
|
1373
|
+
entries = await this.presetDiffcore(this.presetQueue);
|
|
1374
|
+
} else {
|
|
1375
|
+
entries = (await this.collect(this.renames ?? false, false, this.pickaxeReads)).entries;
|
|
1376
|
+
}
|
|
995
1377
|
// diffcore_pickaxe, diffcore_apply_filter (the entries stay in path order, unswapped)
|
|
996
1378
|
const picked = await this.picked(entries);
|
|
997
1379
|
const filter = this.textOptions.diffFilter;
|
|
@@ -1034,7 +1416,13 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1034
1416
|
PREFETCH_FORMATS.has(format) || this.pickaxeReads,
|
|
1035
1417
|
);
|
|
1036
1418
|
const sink = new ByteSink();
|
|
1037
|
-
|
|
1419
|
+
try {
|
|
1420
|
+
await this.writeFormats(sink, [format], collected);
|
|
1421
|
+
} catch (error) {
|
|
1422
|
+
// what git wrote on stdout before an external diff made it die
|
|
1423
|
+
if (error instanceof ExternalDiffDiedError) error.output = sink.bytes();
|
|
1424
|
+
throw error;
|
|
1425
|
+
}
|
|
1038
1426
|
return sink.bytes();
|
|
1039
1427
|
});
|
|
1040
1428
|
}
|
|
@@ -1050,7 +1438,12 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1050
1438
|
const fromContents = this.fromContents;
|
|
1051
1439
|
const early = this.textOptions.diffFilter === undefined && !fromContents;
|
|
1052
1440
|
const detect = !early && (this.textOptions.quietDetectsRenames ?? false);
|
|
1053
|
-
const collected = await this.collect(
|
|
1441
|
+
const collected = await this.collect(
|
|
1442
|
+
detect ? renames : false,
|
|
1443
|
+
false,
|
|
1444
|
+
this.pickaxeReads,
|
|
1445
|
+
!early,
|
|
1446
|
+
);
|
|
1054
1447
|
// diff_can_quit_early: the walk stopped at the first change, which a pickaxe (git 2.43,
|
|
1055
1448
|
// whose quiet diff does not look at contents) may then drop
|
|
1056
1449
|
const queue = early && this.pickaxe ? collected.entries.slice(0, 1) : collected.entries;
|
|
@@ -1060,14 +1453,14 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1060
1453
|
this.changesFound = false;
|
|
1061
1454
|
const options = this.outputOptions();
|
|
1062
1455
|
Object.assign(options, this.prefixes());
|
|
1456
|
+
this.resetExternal();
|
|
1063
1457
|
for (const entry of entries) {
|
|
1064
1458
|
if (entry.unmerged) {
|
|
1065
1459
|
this.changesFound = true;
|
|
1066
1460
|
break;
|
|
1067
1461
|
}
|
|
1068
|
-
const
|
|
1069
|
-
await
|
|
1070
|
-
if (scratch.length > 0) {
|
|
1462
|
+
const pair = this.withTextconvInputs(diffEntryToPair(entry, this.blobs), entry);
|
|
1463
|
+
if (await this.patchOf(new ByteSink(), pair, options, entries.length, true)) {
|
|
1071
1464
|
this.changesFound = true;
|
|
1072
1465
|
break;
|
|
1073
1466
|
}
|
|
@@ -1138,10 +1531,13 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1138
1531
|
let followPath = follow;
|
|
1139
1532
|
let followChange: ChangeType.RENAME | ChangeType.COPY | undefined;
|
|
1140
1533
|
let collected: { entries: DiffEntry[]; combined: CombinedEntry[] };
|
|
1141
|
-
if (
|
|
1534
|
+
if (this.presetQueue) {
|
|
1535
|
+
await this.preparePickaxe();
|
|
1536
|
+
collected = { entries: await this.presetDiffcore(this.presetQueue), combined: [] };
|
|
1537
|
+
} else if (follow !== undefined) {
|
|
1142
1538
|
const spec = this.pathspecItems;
|
|
1143
1539
|
this.pathspecItems = [parsePathspecItem(`:(literal)${follow}`)];
|
|
1144
|
-
collected = await this.collect(false, false);
|
|
1540
|
+
collected = await this.collect(false, false, false, false);
|
|
1145
1541
|
const only = collected.entries[0];
|
|
1146
1542
|
if (collected.entries.length === 1 && only?.changeType === ChangeType.ADD) {
|
|
1147
1543
|
this.pathspecItems = spec;
|
|
@@ -1163,11 +1559,15 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1163
1559
|
...(followPath !== undefined ? { followPath } : {}),
|
|
1164
1560
|
...(followChange !== undefined ? { followChange } : {}),
|
|
1165
1561
|
};
|
|
1166
|
-
|
|
1562
|
+
// diff_queue_is_empty: headers to include count as a change
|
|
1563
|
+
const headers = this.headersInPathspec();
|
|
1564
|
+
const withHeaders = this.includesConflictHeaders(headers);
|
|
1565
|
+
if (collected.entries.length === 0 && collected.combined.length === 0 && !withHeaders)
|
|
1566
|
+
return followed;
|
|
1167
1567
|
const sink = new ByteSink();
|
|
1168
|
-
const queued = await this.writeFormats(sink, formats, collected);
|
|
1568
|
+
const queued = await this.writeFormats(sink, formats, collected, headers);
|
|
1169
1569
|
// diffcore_std left nothing (`--diff-filter`, `--skip-to`): no diff, as an empty one
|
|
1170
|
-
if (queued === 0 && collected.combined.length === 0) return followed;
|
|
1570
|
+
if (queued === 0 && collected.combined.length === 0 && !withHeaders) return followed;
|
|
1171
1571
|
return { bytes: sink.bytes(), ...followed };
|
|
1172
1572
|
});
|
|
1173
1573
|
}
|
|
@@ -1221,6 +1621,7 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1221
1621
|
sink: ByteSink,
|
|
1222
1622
|
formats: DiffOutputFormat[],
|
|
1223
1623
|
collected: { entries: DiffEntry[]; combined: CombinedEntry[] },
|
|
1624
|
+
headers?: Map<string, readonly string[]>,
|
|
1224
1625
|
): Promise<number> {
|
|
1225
1626
|
const config = this.config;
|
|
1226
1627
|
const { combined } = collected;
|
|
@@ -1228,6 +1629,7 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1228
1629
|
// diffcore_std's has_changes; with diff_from_contents, what the outputs show (below)
|
|
1229
1630
|
const fromContents = this.fromContents;
|
|
1230
1631
|
this.changesFound = !fromContents && entries.length > 0;
|
|
1632
|
+
this.resetExternal();
|
|
1231
1633
|
const options = this.outputOptions();
|
|
1232
1634
|
Object.assign(options, this.prefixes());
|
|
1233
1635
|
if (this.textOptions.reverse) {
|
|
@@ -1241,6 +1643,8 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1241
1643
|
const unmerged = new Set<DiffFilePair>();
|
|
1242
1644
|
/** The pairs with their full paths, for what git does not shorten (`--summary`) */
|
|
1243
1645
|
const fullPairs = new Map<DiffFilePair, DiffFilePair>();
|
|
1646
|
+
/** The entry of each pair (an unmerged path's sides, for the raw output) */
|
|
1647
|
+
const entryOfPair = new Map<DiffFilePair, DiffEntry>();
|
|
1244
1648
|
const prefix = this.relativePrefix;
|
|
1245
1649
|
for (const entry of entries) {
|
|
1246
1650
|
// an unmerged path: only its name is printed
|
|
@@ -1281,17 +1685,21 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1281
1685
|
: {}),
|
|
1282
1686
|
};
|
|
1283
1687
|
fullPairs.set(shown, pair);
|
|
1688
|
+
entryOfPair.set(shown, entry);
|
|
1284
1689
|
if (entry.unmerged) unmerged.add(shown);
|
|
1285
1690
|
pairs.push(shown);
|
|
1286
1691
|
}
|
|
1287
1692
|
const full = (pair: DiffFilePair) => fullPairs.get(pair) ?? pair;
|
|
1288
1693
|
const quote = options.quotePath;
|
|
1694
|
+
const z = this.textOptions.nullTerminated === true;
|
|
1289
1695
|
const order: DiffOutputFormat[] = [
|
|
1696
|
+
"raw",
|
|
1290
1697
|
"name-only",
|
|
1291
1698
|
"name-status",
|
|
1292
1699
|
"numstat",
|
|
1293
1700
|
"stat",
|
|
1294
1701
|
"shortstat",
|
|
1702
|
+
"dirstat",
|
|
1295
1703
|
"summary",
|
|
1296
1704
|
"patch",
|
|
1297
1705
|
];
|
|
@@ -1310,8 +1718,9 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1310
1718
|
}
|
|
1311
1719
|
for (const c of combined) await this.writeCombined(sink, c, options, combinedLengths);
|
|
1312
1720
|
}
|
|
1313
|
-
// diff_flush of an empty queue prints nothing
|
|
1314
|
-
if (pairs.length === 0) return 0;
|
|
1721
|
+
// diff_flush of an empty queue prints nothing (unless headers are to be shown)
|
|
1722
|
+
if (pairs.length === 0 && !headers) return 0;
|
|
1723
|
+
if (headers) options.additionalHeaders = (name) => headers.get(name);
|
|
1315
1724
|
// diff_setup_done: --check turns the other formats off
|
|
1316
1725
|
if (formats.includes("check")) {
|
|
1317
1726
|
const check = { conflictMarkerSize: this.conflictMarkerSizeOf() };
|
|
@@ -1336,7 +1745,8 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1336
1745
|
for (const format of order) {
|
|
1337
1746
|
if (!formats.includes(format)) continue;
|
|
1338
1747
|
if (format === "patch" && separator) {
|
|
1339
|
-
|
|
1748
|
+
// DIFF_SYMBOL_SEPARATOR: the line termination (a NUL under -z)
|
|
1749
|
+
sink.text(z ? "\0" : "\n");
|
|
1340
1750
|
// attach the patch instead of inlining it
|
|
1341
1751
|
if (this.textOptions.statSep) sink.text(this.textOptions.statSep);
|
|
1342
1752
|
}
|
|
@@ -1350,6 +1760,13 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1350
1760
|
}
|
|
1351
1761
|
continue;
|
|
1352
1762
|
}
|
|
1763
|
+
if (format === "dirstat") {
|
|
1764
|
+
const params = this.dirstatParams();
|
|
1765
|
+
await this.writeDirstat(sink, pairs, unmerged, options, params);
|
|
1766
|
+
// only the dirstat by lines comes with the diffstat's separator
|
|
1767
|
+
if (params.byLine) separator = true;
|
|
1768
|
+
continue;
|
|
1769
|
+
}
|
|
1353
1770
|
separator = true;
|
|
1354
1771
|
switch (format) {
|
|
1355
1772
|
case "patch": {
|
|
@@ -1371,16 +1788,41 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1371
1788
|
options.abbrevLengths = await this.idAbbreviator().lengths(ids, options.abbrev);
|
|
1372
1789
|
}
|
|
1373
1790
|
// diff_flush_patch_all_file_pairs: moved lines are looked for over every pair
|
|
1791
|
+
// (diff_setup_done: not with an external diff program)
|
|
1374
1792
|
const moved = this.colorSettings;
|
|
1375
1793
|
const out =
|
|
1376
|
-
moved?.colors && moved.colorMoved !== "no"
|
|
1794
|
+
moved?.colors && moved.colorMoved !== "no" && !this.externalProgram()
|
|
1377
1795
|
? new MovedLineBuffer(moved.colorMoved, moved.colorMovedWs)
|
|
1378
1796
|
: sink;
|
|
1379
|
-
for (const pair of pairs) {
|
|
1797
|
+
for (const pair of this.withHeaderOnlyPairs(pairs, full, headers)) {
|
|
1380
1798
|
const before = out.length;
|
|
1381
|
-
if (
|
|
1382
|
-
|
|
1383
|
-
|
|
1799
|
+
if (typeof pair === "string") {
|
|
1800
|
+
if (this.includesConflictHeaders(headers)) {
|
|
1801
|
+
writeHeaderOnlyPatch(out, pair, headers?.get(pair) ?? [], options);
|
|
1802
|
+
}
|
|
1803
|
+
} else {
|
|
1804
|
+
const isUnmerged = unmerged.has(pair);
|
|
1805
|
+
const external = await this.externalDiffFor(pair, options, isUnmerged);
|
|
1806
|
+
if (external) {
|
|
1807
|
+
// run_external_diff's found_changes, by the program's exit code
|
|
1808
|
+
if (
|
|
1809
|
+
await this.runExternalDiff(
|
|
1810
|
+
out,
|
|
1811
|
+
external,
|
|
1812
|
+
pair,
|
|
1813
|
+
options,
|
|
1814
|
+
pairs.length,
|
|
1815
|
+
false,
|
|
1816
|
+
isUnmerged,
|
|
1817
|
+
)
|
|
1818
|
+
) {
|
|
1819
|
+
this.changesFound = true;
|
|
1820
|
+
}
|
|
1821
|
+
continue;
|
|
1822
|
+
}
|
|
1823
|
+
if (isUnmerged) out.text(`* Unmerged path ${pair.new?.path ?? pair.old?.path}\n`);
|
|
1824
|
+
else await writePairPatch(out, pair, options);
|
|
1825
|
+
}
|
|
1384
1826
|
// builtin_diff's found_changes: the pair showed something
|
|
1385
1827
|
if (out.length > before) this.changesFound = true;
|
|
1386
1828
|
}
|
|
@@ -1389,11 +1831,45 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1389
1831
|
}
|
|
1390
1832
|
break;
|
|
1391
1833
|
}
|
|
1834
|
+
case "raw": {
|
|
1835
|
+
// flush_one_pair: --name-status wins over --raw (diff_flush_raw prints the
|
|
1836
|
+
// status alone), and --raw over --name-only
|
|
1837
|
+
// diff_setup_done: the name formats and --check turn --raw off
|
|
1838
|
+
if (formats.some((f) => f === "name-status" || f === "name-only" || f === "check")) {
|
|
1839
|
+
continue;
|
|
1840
|
+
}
|
|
1841
|
+
if (pairs.length > 0) this.changesFound = true;
|
|
1842
|
+
const abbreviate = await this.rawAbbreviator(pairs);
|
|
1843
|
+
const raw = {
|
|
1844
|
+
quotePath: quote,
|
|
1845
|
+
nullTerminated: z,
|
|
1846
|
+
abbreviate,
|
|
1847
|
+
nullId: this.objectFormat.nullId,
|
|
1848
|
+
};
|
|
1849
|
+
for (const pair of pairs) {
|
|
1850
|
+
const entry = entryOfPair.get(pair);
|
|
1851
|
+
if (unmerged.has(pair) && entry) {
|
|
1852
|
+
// diff_unmerge: the null ids, the sides' modes as the comparison knew them
|
|
1853
|
+
const path = entry.newPath ?? entry.oldPath ?? "";
|
|
1854
|
+
const side = (mode: number | undefined, id: string | undefined) =>
|
|
1855
|
+
contentSide(path, mode ?? 0, id ?? this.objectFormat.nullId, async () => NO_BYTES);
|
|
1856
|
+
const u: DiffFilePair = {
|
|
1857
|
+
status: "M",
|
|
1858
|
+
old: side(entry.oldMode, entry.oldId),
|
|
1859
|
+
new: side(entry.newMode, undefined),
|
|
1860
|
+
};
|
|
1861
|
+
sink.text(formatRawPair(u, raw, "U"));
|
|
1862
|
+
} else sink.text(formatRawPair(pair, raw));
|
|
1863
|
+
}
|
|
1864
|
+
break;
|
|
1865
|
+
}
|
|
1392
1866
|
case "name-only": {
|
|
1393
1867
|
const names = await this.shownNames(pairs, unmerged, options);
|
|
1394
1868
|
// flush_one_pair: found_changes for each name listed
|
|
1395
1869
|
if (names.length > 0) this.changesFound = true;
|
|
1396
|
-
|
|
1870
|
+
if (z) {
|
|
1871
|
+
for (const p of names) sink.text(`${p.new?.path ?? p.old?.path ?? ""}\0`);
|
|
1872
|
+
} else sink.text(formatNameOnly(names, { quotePath: quote }));
|
|
1397
1873
|
break;
|
|
1398
1874
|
}
|
|
1399
1875
|
case "name-status": {
|
|
@@ -1401,7 +1877,15 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1401
1877
|
// flush_one_pair: found_changes for each name listed
|
|
1402
1878
|
if (names.length > 0) this.changesFound = true;
|
|
1403
1879
|
for (const pair of names) {
|
|
1404
|
-
if (
|
|
1880
|
+
if (z) {
|
|
1881
|
+
const raw = {
|
|
1882
|
+
nullTerminated: true,
|
|
1883
|
+
nameStatus: true,
|
|
1884
|
+
abbreviate: (id: string) => id,
|
|
1885
|
+
nullId: this.objectFormat.nullId,
|
|
1886
|
+
};
|
|
1887
|
+
sink.text(formatRawPair(pair, raw, unmerged.has(pair) ? "U" : undefined));
|
|
1888
|
+
} else if (unmerged.has(pair)) {
|
|
1405
1889
|
sink.text(`U\t${quotePath(pair.new?.path ?? pair.old?.path ?? "", quote)}\n`);
|
|
1406
1890
|
} else sink.text(formatNameStatus([pair], { quotePath: quote }));
|
|
1407
1891
|
}
|
|
@@ -1441,6 +1925,51 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1441
1925
|
return pairs.length;
|
|
1442
1926
|
}
|
|
1443
1927
|
|
|
1928
|
+
/**
|
|
1929
|
+
* The raw output's ids: full under {@link DiffTextOptions.rawFullIds} without `--abbrev`,
|
|
1930
|
+
* else each abbreviated as git's `diff_aligned_abbrev` (unique, at least `--abbrev` digits)
|
|
1931
|
+
*/
|
|
1932
|
+
private async rawAbbreviator(pairs: DiffFilePair[]): Promise<(id: string) => string> {
|
|
1933
|
+
const o = this.textOptions;
|
|
1934
|
+
if (o.rawFullIds && o.abbrev === undefined) return (id) => id;
|
|
1935
|
+
const nullId = this.objectFormat.nullId;
|
|
1936
|
+
const ids = new Set<string>([nullId]);
|
|
1937
|
+
for (const p of pairs) {
|
|
1938
|
+
if (p.old && !p.old.rawNullId) ids.add(p.old.id);
|
|
1939
|
+
if (p.new && !p.new.rawNullId) ids.add(p.new.id);
|
|
1940
|
+
}
|
|
1941
|
+
const min = abbrevOption(o.abbrev);
|
|
1942
|
+
if (min !== undefined && min >= this.objectFormat.hexLength) return (id) => id;
|
|
1943
|
+
const lengths = await this.idAbbreviator().lengths(ids, min);
|
|
1944
|
+
return (id) => id.slice(0, lengths.get(id) ?? min ?? 7);
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
/**
|
|
1948
|
+
* create_filepairs_for_header_only_notifications: the pairs, and the paths with headers
|
|
1949
|
+
* none of them names first (as strings), sorted by first name (diffcore_fix_diff_index)
|
|
1950
|
+
*/
|
|
1951
|
+
private withHeaderOnlyPairs(
|
|
1952
|
+
pairs: DiffFilePair[],
|
|
1953
|
+
full: (pair: DiffFilePair) => DiffFilePair,
|
|
1954
|
+
headers: Map<string, readonly string[]> | undefined,
|
|
1955
|
+
): (DiffFilePair | string)[] {
|
|
1956
|
+
if (!headers) return pairs;
|
|
1957
|
+
const nameOf = (pair: DiffFilePair) => {
|
|
1958
|
+
const f = full(pair);
|
|
1959
|
+
return f.old?.path ?? f.new?.path ?? "";
|
|
1960
|
+
};
|
|
1961
|
+
const present = new Set(pairs.map(nameOf));
|
|
1962
|
+
const out: { name: string; item: DiffFilePair | string }[] = pairs.map((pair) => ({
|
|
1963
|
+
name: nameOf(pair),
|
|
1964
|
+
item: pair,
|
|
1965
|
+
}));
|
|
1966
|
+
for (const path of headers.keys()) {
|
|
1967
|
+
if (!present.has(path)) out.push({ name: path, item: path });
|
|
1968
|
+
}
|
|
1969
|
+
out.sort((a, b) => compareBytes(a.name, b.name));
|
|
1970
|
+
return out.map((e) => e.item);
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1444
1973
|
/**
|
|
1445
1974
|
* builtin_diff's submodule branch: `--submodule=log` (show_submodule_diff_summary) or
|
|
1446
1975
|
* `--submodule=diff` (show_submodule_inline_diff) for a pair of submodules (or a submodule
|
|
@@ -1606,12 +2135,17 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1606
2135
|
* the path's `diff.<driver>.textconv` over the blob as checkout writes it, or undefined
|
|
1607
2136
|
* when no textconv applies (not a regular file, no driver, no command or no runner
|
|
1608
2137
|
* installed, `textconv: false`). The attributes are the worktree's alone (git show reads
|
|
1609
|
-
* no index).
|
|
2138
|
+
* no index). With the blob's `id`, the driver's textconv cache applies
|
|
2139
|
+
* (`diff.<driver>.cachetextconv`). `worktreeFile`: `read` gives a file as it lies in the
|
|
2140
|
+
* worktree (blame's working-tree file, `--contents <file>`), converted as it is, never
|
|
2141
|
+
* smudged nor cached (git's prepare_temp_file reuses the file; its object id is unknown).
|
|
1610
2142
|
*/
|
|
1611
2143
|
async textconvBlob(
|
|
1612
2144
|
path: string,
|
|
1613
2145
|
mode: number,
|
|
1614
2146
|
read: () => Promise<Uint8Array>,
|
|
2147
|
+
id?: string,
|
|
2148
|
+
options: { worktreeFile?: boolean } = {},
|
|
1615
2149
|
): Promise<Uint8Array | undefined> {
|
|
1616
2150
|
if ((mode & S_IFMT) !== 0o100000) return undefined;
|
|
1617
2151
|
const runner =
|
|
@@ -1630,13 +2164,29 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1630
2164
|
const driver = diffDriverOf(attrs?.get("diff"), (key) => this.config.value(key));
|
|
1631
2165
|
const command = driver?.textconvCommand;
|
|
1632
2166
|
if (!driver || command === undefined) return undefined;
|
|
1633
|
-
return
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
2167
|
+
return this.runTextconv(
|
|
2168
|
+
runner,
|
|
2169
|
+
{
|
|
2170
|
+
driver: driver.name ?? "",
|
|
2171
|
+
command,
|
|
2172
|
+
path,
|
|
2173
|
+
content: options.worktreeFile ? await read() : await this.smudged(path, mode, read),
|
|
2174
|
+
cache: driver.cacheTextconv ?? false,
|
|
2175
|
+
},
|
|
2176
|
+
options.worktreeFile ? undefined : id,
|
|
2177
|
+
);
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
/** The textconv caches of this command (git's per-process caches) */
|
|
2181
|
+
private textconvCaches = new TextconvCaches(() => this.notesContext());
|
|
2182
|
+
|
|
2183
|
+
/** diff.c's fill_textconv: the runner's output, through the driver's notes cache */
|
|
2184
|
+
private runTextconv(
|
|
2185
|
+
runner: TextconvRunner,
|
|
2186
|
+
request: TextconvRequest,
|
|
2187
|
+
id: string | undefined,
|
|
2188
|
+
): Promise<Uint8Array> {
|
|
2189
|
+
return this.textconvCaches.run(runner, request, id);
|
|
1640
2190
|
}
|
|
1641
2191
|
|
|
1642
2192
|
/** A blob's content as checkout writes it to the worktree (the worktree's smudge filter) */
|
|
@@ -1670,13 +2220,200 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1670
2220
|
shown.push(pair);
|
|
1671
2221
|
continue;
|
|
1672
2222
|
}
|
|
1673
|
-
|
|
1674
|
-
await writePairPatch(scratch, pair, options);
|
|
1675
|
-
if (scratch.length > 0) shown.push(pair);
|
|
2223
|
+
if (await this.patchOf(new ByteSink(), pair, options, pairs.length, true)) shown.push(pair);
|
|
1676
2224
|
}
|
|
1677
2225
|
return shown;
|
|
1678
2226
|
}
|
|
1679
2227
|
|
|
2228
|
+
/** The host environment the working copy's configuration was opened with */
|
|
2229
|
+
private get hostEnvironment(): GitHostEnvironment | undefined {
|
|
2230
|
+
return (this.workingCopy.config as { environment?: GitHostEnvironment })?.environment;
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
/** diff_setup_done: the external diff calls of a new output start from 1 */
|
|
2234
|
+
private resetExternal(): void {
|
|
2235
|
+
this.externalCounter = 0;
|
|
2236
|
+
this.externalStderr = [];
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
/**
|
|
2240
|
+
* diff.c's `external_diff()` where external diffs are allowed (`--ext-diff`, porcelain
|
|
2241
|
+
* `git diff`): `GIT_EXTERNAL_DIFF`, else `diff.external` of the UI configuration
|
|
2242
|
+
*/
|
|
2243
|
+
private externalProgram(): ExternalDiffProgram | undefined {
|
|
2244
|
+
if (!this.textOptions.extDiff) return undefined;
|
|
2245
|
+
const config = this.config;
|
|
2246
|
+
return externalDiffProgramOf(
|
|
2247
|
+
this.hostEnvironment,
|
|
2248
|
+
this.textOptions.uiConfig === false ? undefined : (key) => config.value(key),
|
|
2249
|
+
);
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
/**
|
|
2253
|
+
* The program run_diff_cmd runs for a pair, if any: the pair's `diff.<driver>.command`
|
|
2254
|
+
* (attributes of its first path), else {@link externalProgram}; none without a runner to
|
|
2255
|
+
* run it or a place to write its files. `split`: a change between a file and a symbolic
|
|
2256
|
+
* link that only a driver's program takes (run_diff splits it in two when no
|
|
2257
|
+
* `GIT_EXTERNAL_DIFF`/`diff.external` is set).
|
|
2258
|
+
*/
|
|
2259
|
+
private async externalDiffFor(
|
|
2260
|
+
pair: DiffFilePair,
|
|
2261
|
+
options: DiffOutputOptions,
|
|
2262
|
+
unmerged: boolean,
|
|
2263
|
+
): Promise<(ExternalDiffProgram & { split: boolean }) | undefined> {
|
|
2264
|
+
if (!this.textOptions.extDiff) return undefined;
|
|
2265
|
+
const environment = this.hostEnvironment;
|
|
2266
|
+
if (!environment?.hookRunner || !environment.hostFilesOf) return undefined;
|
|
2267
|
+
const { old: one, new: two } = pair;
|
|
2268
|
+
if ((one && (one.mode & S_IFMT) === 0o040000) || (two && (two.mode & S_IFMT) === 0o040000)) {
|
|
2269
|
+
return undefined;
|
|
2270
|
+
}
|
|
2271
|
+
const global = this.externalProgram();
|
|
2272
|
+
const split =
|
|
2273
|
+
!global && !unmerged && !!one && !!two && (one.mode & S_IFMT) !== (two.mode & S_IFMT);
|
|
2274
|
+
const side = one ?? two;
|
|
2275
|
+
const attrPath = side?.attrPath ?? side?.path;
|
|
2276
|
+
const driver = attrPath ? await options.driver?.(attrPath) : undefined;
|
|
2277
|
+
if (driver?.externalCommand !== undefined) {
|
|
2278
|
+
return {
|
|
2279
|
+
command: driver.externalCommand,
|
|
2280
|
+
trustExitCode: driver.trustExitCode ?? false,
|
|
2281
|
+
split,
|
|
2282
|
+
};
|
|
2283
|
+
}
|
|
2284
|
+
return global && { ...global, split: false };
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
/**
|
|
2288
|
+
* A pair's patch, through its external program or the builtin one: whether it shows a
|
|
2289
|
+
* change (git's `found_changes`). `quiet`: nothing is written (diff_flush_patch_quietly).
|
|
2290
|
+
*/
|
|
2291
|
+
private async patchOf(
|
|
2292
|
+
out: ByteSink,
|
|
2293
|
+
pair: DiffFilePair,
|
|
2294
|
+
options: DiffOutputOptions,
|
|
2295
|
+
total: number,
|
|
2296
|
+
quiet: boolean,
|
|
2297
|
+
): Promise<boolean> {
|
|
2298
|
+
const external = await this.externalDiffFor(pair, options, false);
|
|
2299
|
+
if (external) return this.runExternalDiff(out, external, pair, options, total, quiet);
|
|
2300
|
+
const before = out.length;
|
|
2301
|
+
await writePairPatch(out, pair, options);
|
|
2302
|
+
return out.length > before;
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
/**
|
|
2306
|
+
* diff.c's run_external_diff for a pair (both halves of a split one): the program's stdout
|
|
2307
|
+
* into `out` (nothing when `quiet`), its stderr kept; whether the pair counts as changed.
|
|
2308
|
+
* Without `trustExitCode` a quiet check does not run the program and counts a change.
|
|
2309
|
+
*
|
|
2310
|
+
* @throws ExternalDiffDiedError on an exit code git does not accept
|
|
2311
|
+
*/
|
|
2312
|
+
private async runExternalDiff(
|
|
2313
|
+
out: ByteSink,
|
|
2314
|
+
program: ExternalDiffProgram & { split: boolean },
|
|
2315
|
+
pair: DiffFilePair,
|
|
2316
|
+
options: DiffOutputOptions,
|
|
2317
|
+
total: number,
|
|
2318
|
+
quiet: boolean,
|
|
2319
|
+
unmerged = false,
|
|
2320
|
+
): Promise<boolean> {
|
|
2321
|
+
if (!program.trustExitCode && quiet) return true;
|
|
2322
|
+
const { old: one, new: two } = pair;
|
|
2323
|
+
const name = one?.path ?? two?.path ?? "";
|
|
2324
|
+
// a split pair: the old side against nothing, then nothing against the new side
|
|
2325
|
+
const calls: Array<[DiffSideSpec | undefined, DiffSideSpec | undefined]> = program.split
|
|
2326
|
+
? [
|
|
2327
|
+
[one, undefined],
|
|
2328
|
+
[undefined, two],
|
|
2329
|
+
]
|
|
2330
|
+
: [[one, two]];
|
|
2331
|
+
let found = false;
|
|
2332
|
+
for (const [a, b] of calls) {
|
|
2333
|
+
const temps = new ExternalDiffTempFiles(this.hostEnvironment ?? {});
|
|
2334
|
+
try {
|
|
2335
|
+
const args = [name];
|
|
2336
|
+
// an unmerged path: its name alone
|
|
2337
|
+
if (!unmerged) {
|
|
2338
|
+
args.push(...(await this.externalSide(a, temps)), ...(await this.externalSide(b, temps)));
|
|
2339
|
+
const otherPath = two?.path ?? name;
|
|
2340
|
+
if (!program.split && otherPath !== name) {
|
|
2341
|
+
args.push(otherPath);
|
|
2342
|
+
const xfrm = externalDiffMetainfo(pair, options);
|
|
2343
|
+
if (xfrm !== undefined) args.push(xfrm);
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
const env = {
|
|
2347
|
+
GIT_DIFF_PATH_COUNTER: String(++this.externalCounter),
|
|
2348
|
+
GIT_DIFF_PATH_TOTAL: String(total),
|
|
2349
|
+
};
|
|
2350
|
+
const ran = await this.hooks.runProgram("external-diff", program.command, args, env);
|
|
2351
|
+
if (!ran) throw new ExternalDiffDiedError(name);
|
|
2352
|
+
if (!quiet && ran.stdout.length > 0) out.push(ran.stdout);
|
|
2353
|
+
if (ran.stderr.length > 0) this.externalStderr.push(ran.stderr);
|
|
2354
|
+
if (ran.exitCode === 0) {
|
|
2355
|
+
if (!program.trustExitCode) found = true;
|
|
2356
|
+
} else if (program.trustExitCode && ran.exitCode === 1) found = true;
|
|
2357
|
+
else throw new ExternalDiffDiedError(name);
|
|
2358
|
+
} finally {
|
|
2359
|
+
await temps.removeAll();
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
return found;
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
/**
|
|
2366
|
+
* prepare_temp_file: the three arguments naming one side. An absent side is `/dev/null . .`;
|
|
2367
|
+
* the worktree's file is passed by its path from the top (the null id when the comparison
|
|
2368
|
+
* did not hash it, a symbolic link's target in a temporary file); a stored side whose
|
|
2369
|
+
* index entry the worktree's file still matches is passed as that file
|
|
2370
|
+
* (`reuse_worktree_file`, only when the diff reads the index); any other side is a
|
|
2371
|
+
* temporary file of its content as checkout writes it.
|
|
2372
|
+
*/
|
|
2373
|
+
private async externalSide(
|
|
2374
|
+
side: DiffSideSpec | undefined,
|
|
2375
|
+
temps: ExternalDiffTempFiles,
|
|
2376
|
+
): Promise<string[]> {
|
|
2377
|
+
if (!side) return ["/dev/null", ".", "."];
|
|
2378
|
+
const nullId = this.objectFormat.nullId;
|
|
2379
|
+
const path = side.attrPath ?? side.path;
|
|
2380
|
+
const mode = octal6(side.mode);
|
|
2381
|
+
const gitlink = (side.mode & S_IFMT) === GITLINK;
|
|
2382
|
+
const fromWorktree = side.idValid === false;
|
|
2383
|
+
const worktree = this.worktreeIfAny;
|
|
2384
|
+
if (!gitlink && worktree && (fromWorktree || (await this.reusesWorktreeFile(path, side)))) {
|
|
2385
|
+
const current = await worktree.getEntry(path);
|
|
2386
|
+
if (!current || current.isDirectory) return ["/dev/null", ".", "."];
|
|
2387
|
+
if ((current.mode & S_IFMT) !== SYMLINK) return [path, fromWorktree ? nullId : side.id, mode];
|
|
2388
|
+
const target = await collectChunks(worktree.readContent(path));
|
|
2389
|
+
return [
|
|
2390
|
+
await temps.write(path, target),
|
|
2391
|
+
fromWorktree ? nullId : side.id,
|
|
2392
|
+
fromWorktree ? octal6(SYMLINK) : mode,
|
|
2393
|
+
];
|
|
2394
|
+
}
|
|
2395
|
+
const content = gitlink ? await side.read() : await (side.readTextconvInput ?? side.read)();
|
|
2396
|
+
return [await temps.write(path, content), side.id, mode];
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
/** reuse_worktree_file: the index's entry of `path` holds the side and its file matches it */
|
|
2400
|
+
private async reusesWorktreeFile(path: string, side: DiffSideSpec): Promise<boolean> {
|
|
2401
|
+
// a diff of two trees reads no index (`istate->cache` empty)
|
|
2402
|
+
if (this.newTree !== undefined || !this.worktreeIfAny) return false;
|
|
2403
|
+
const entry = await this.staging.getEntry(path);
|
|
2404
|
+
if (!entry || entry.stage !== 0 || entry.objectId !== side.id) return false;
|
|
2405
|
+
if ((entry.mode & S_IFMT) !== 0o100000) return false;
|
|
2406
|
+
if (entry.assumeValid || entry.skipWorktree) return false;
|
|
2407
|
+
const worktree = this.worktreeIfAny;
|
|
2408
|
+
const current = await worktree.getEntry(path);
|
|
2409
|
+
if (!current) return false;
|
|
2410
|
+
// ie_match_stat: the stat data, and the content of a racily clean entry
|
|
2411
|
+
const trust = worktreeModeTrust(this.workingCopy, worktree);
|
|
2412
|
+
const indexTime = this.staging.getUpdateTime();
|
|
2413
|
+
const compared = await compareWithWorktree(worktree, entry, { trust, indexTime }, current);
|
|
2414
|
+
return compared.kind === undefined;
|
|
2415
|
+
}
|
|
2416
|
+
|
|
1680
2417
|
private get config(): RemoteConfigStore {
|
|
1681
2418
|
return RemoteConfigStore.from(this.workingCopy);
|
|
1682
2419
|
}
|
|
@@ -1812,7 +2549,8 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1812
2549
|
const cache = found.cacheTextconv ?? false;
|
|
1813
2550
|
return {
|
|
1814
2551
|
...found,
|
|
1815
|
-
textconv: (content, path) =>
|
|
2552
|
+
textconv: (content, path, id) =>
|
|
2553
|
+
this.runTextconv(runner, { driver: name, command, path, content, cache }, id),
|
|
1816
2554
|
};
|
|
1817
2555
|
};
|
|
1818
2556
|
const driver = filter?.attributes
|
|
@@ -1839,6 +2577,7 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1839
2577
|
ignoreConfigNoPrefix: _ignoreConfigNoPrefix,
|
|
1840
2578
|
orderFile: _orderFile,
|
|
1841
2579
|
textconv: _textconv,
|
|
2580
|
+
extDiff: _extDiff,
|
|
1842
2581
|
abbrev: _abbrev,
|
|
1843
2582
|
diffFilter: _diffFilter,
|
|
1844
2583
|
relative: _relative,
|
|
@@ -1859,6 +2598,12 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1859
2598
|
wsErrorHighlight: _wsErrorHighlight,
|
|
1860
2599
|
colorCompatibility: _colorCompatibility,
|
|
1861
2600
|
driverCompatibility: _driverCompatibility,
|
|
2601
|
+
findRenames: _findRenames,
|
|
2602
|
+
findCopies: _findCopies,
|
|
2603
|
+
findCopiesHarder: _findCopiesHarder,
|
|
2604
|
+
breakRewrites: _breakRewrites,
|
|
2605
|
+
dirstat: _dirstat,
|
|
2606
|
+
anchored,
|
|
1862
2607
|
...text
|
|
1863
2608
|
} = this.textOptions;
|
|
1864
2609
|
const colorSettings = this.colorSettings;
|
|
@@ -1869,6 +2614,7 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1869
2614
|
: {};
|
|
1870
2615
|
const ignoreRegex = this.ignoreRegex();
|
|
1871
2616
|
const abbrev = abbrevOption(this.textOptions.abbrev);
|
|
2617
|
+
const diffOpts = this.hostEnvironment?.diffVariables?.GIT_DIFF_OPTS;
|
|
1872
2618
|
return {
|
|
1873
2619
|
context: intValue(get("diff.context")) ?? 3,
|
|
1874
2620
|
interHunkContext: intValue(get("diff.interHunkContext")) ?? 0,
|
|
@@ -1878,7 +2624,13 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1878
2624
|
: {}),
|
|
1879
2625
|
...text,
|
|
1880
2626
|
...(abbrev !== undefined ? { abbrev } : {}),
|
|
1881
|
-
algorithm:
|
|
2627
|
+
algorithm:
|
|
2628
|
+
anchored && anchored.length > 0
|
|
2629
|
+
? "patience"
|
|
2630
|
+
: (text.algorithm ?? algorithmValue(get("diff.algorithm")) ?? "myers"),
|
|
2631
|
+
...(anchored && anchored.length > 0
|
|
2632
|
+
? { anchors: anchored.map((a) => encodeGitPath(a)) }
|
|
2633
|
+
: {}),
|
|
1882
2634
|
indentHeuristic: text.indentHeuristic ?? boolValue(get("diff.indentHeuristic")) ?? true,
|
|
1883
2635
|
...(driver ? { driver } : {}),
|
|
1884
2636
|
...(ignoreRegex.length > 0 ? { ignoreRegex } : {}),
|
|
@@ -1887,6 +2639,7 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
1887
2639
|
? { defaultWordRegex: get("diff.wordRegex") as string }
|
|
1888
2640
|
: {}),
|
|
1889
2641
|
whitespaceRule,
|
|
2642
|
+
...(diffOpts !== undefined ? { diffOpts } : {}),
|
|
1890
2643
|
};
|
|
1891
2644
|
}
|
|
1892
2645
|
|
|
@@ -2073,8 +2826,12 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2073
2826
|
renames: boolean | "copies",
|
|
2074
2827
|
patch = false,
|
|
2075
2828
|
prefetch = false,
|
|
2829
|
+
diffcore = true,
|
|
2076
2830
|
): Promise<{ entries: DiffEntry[]; combined: CombinedEntry[] }> {
|
|
2077
2831
|
// option parsing fails before anything is read
|
|
2832
|
+
const core = diffcore
|
|
2833
|
+
? this.diffcoreSettings(renames)
|
|
2834
|
+
: { detect: false as const, harder: false };
|
|
2078
2835
|
if (this.textOptions.diffFilter !== undefined) parseDiffFilter(this.textOptions.diffFilter);
|
|
2079
2836
|
this.ignoreRegex();
|
|
2080
2837
|
await this.preparePickaxe();
|
|
@@ -2113,7 +2870,9 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2113
2870
|
const unmerged = new Map<string, DiffEntry[]>();
|
|
2114
2871
|
const combined: CombinedEntry[] = [];
|
|
2115
2872
|
if (this.newTree) {
|
|
2116
|
-
if (this.pickaxe && !this.pickaxe.readsContent) this.
|
|
2873
|
+
if ((this.pickaxe && !this.pickaxe.readsContent) || this.treeWalk === "show-trees") {
|
|
2874
|
+
this.treeSides = new Map();
|
|
2875
|
+
}
|
|
2117
2876
|
[oldSide, newSide] = await this.treePairSides(
|
|
2118
2877
|
this.oldTree ?? "HEAD",
|
|
2119
2878
|
this.oldTree === undefined,
|
|
@@ -2123,7 +2882,12 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2123
2882
|
oldSide = await this.treeSide(this.oldTree ?? "HEAD", this.oldTree === undefined);
|
|
2124
2883
|
const index = await this.indexSide();
|
|
2125
2884
|
newSide = index.sides;
|
|
2126
|
-
for (const path of index.unmerged.keys())
|
|
2885
|
+
for (const path of index.unmerged.keys()) {
|
|
2886
|
+
unmerged.set(path, []);
|
|
2887
|
+
// diff_unmerge's raw line: the tree's side, nothing for the index
|
|
2888
|
+
const side = oldSide.get(path);
|
|
2889
|
+
if (side) this.unmergedRaw.set(path, { oldMode: side.mode, oldId: side.id });
|
|
2890
|
+
}
|
|
2127
2891
|
} else if (worktree) {
|
|
2128
2892
|
const run = async () => {
|
|
2129
2893
|
if (this.oldTree) {
|
|
@@ -2144,6 +2908,12 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2144
2908
|
continue;
|
|
2145
2909
|
}
|
|
2146
2910
|
unmerged.set(path, ours ? await this.againstStage(ours, wt.compare) : []);
|
|
2911
|
+
if (this.plumbingWorktree) {
|
|
2912
|
+
// run_diff_files: the unmerged line gives the worktree file's mode
|
|
2913
|
+
const lowest = ours ?? stages.get(1) ?? stages.get(3);
|
|
2914
|
+
const file = lowest ? await wt.compare(lowest) : undefined;
|
|
2915
|
+
if (file) this.unmergedRaw.set(path, { newMode: file.mode });
|
|
2916
|
+
}
|
|
2147
2917
|
}
|
|
2148
2918
|
return [indexSides, wt.sides] as const;
|
|
2149
2919
|
};
|
|
@@ -2175,7 +2945,24 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2175
2945
|
// diffcore_std: an output that reads the blobs fetches a partial clone's absent ones in
|
|
2176
2946
|
// one batch first (diff_queued_diff_prefetch), before rename detection
|
|
2177
2947
|
if (prefetch) await this.blobs.prefetch?.(prefetchIds(entries));
|
|
2178
|
-
if (
|
|
2948
|
+
if (core.breaks || core.detect) {
|
|
2949
|
+
const oldFiles = async (): Promise<Map<string, Side>> => {
|
|
2950
|
+
if (this.newTree || this.cached || this.oldTree || !worktree) {
|
|
2951
|
+
return this.newTree
|
|
2952
|
+
? this.treeSide(this.oldTree ?? "HEAD", this.oldTree === undefined)
|
|
2953
|
+
: oldSide;
|
|
2954
|
+
}
|
|
2955
|
+
// diff-files: the index's entries
|
|
2956
|
+
const out = new Map<string, Side>();
|
|
2957
|
+
for await (const entry of this.staging.entries()) {
|
|
2958
|
+
if (entry.stage === 0 && !entry.intentToAdd) {
|
|
2959
|
+
out.set(entry.path, { mode: entry.mode, id: entry.objectId });
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
return out;
|
|
2963
|
+
};
|
|
2964
|
+
await this.diffcore(entries, core, oldFiles);
|
|
2965
|
+
}
|
|
2179
2966
|
return { entries: this.withTreeEntries(entries, oldSide, newSide), combined };
|
|
2180
2967
|
}
|
|
2181
2968
|
|
|
@@ -2196,6 +2983,7 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2196
2983
|
sides.get(oldSide) ?? new Map(),
|
|
2197
2984
|
sides.get(newSide) ?? new Map(),
|
|
2198
2985
|
new Map(),
|
|
2986
|
+
this.treeWalk === "show-trees",
|
|
2199
2987
|
);
|
|
2200
2988
|
if (trees.length === 0) return entries;
|
|
2201
2989
|
const keyOf = (e: DiffEntry) => e.newPath ?? e.oldPath ?? "";
|
|
@@ -2384,7 +3172,10 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2384
3172
|
},
|
|
2385
3173
|
];
|
|
2386
3174
|
}
|
|
2387
|
-
|
|
3175
|
+
const statDirty = side.rawNull && this.plumbingWorktree;
|
|
3176
|
+
if (side.id === stage.objectId && side.mode === stage.mode && !side.dirty && !statDirty) {
|
|
3177
|
+
return [];
|
|
3178
|
+
}
|
|
2388
3179
|
return [
|
|
2389
3180
|
{
|
|
2390
3181
|
changeType: ChangeType.MODIFY,
|
|
@@ -2397,6 +3188,7 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2397
3188
|
...(side.read ? { readNew: side.read } : {}),
|
|
2398
3189
|
...(side.dirty ? { newDirtySubmodule: true } : {}),
|
|
2399
3190
|
...(side.dirt ? { newSubmoduleDirt: side.dirt } : {}),
|
|
3191
|
+
...(side.rawNull ? { newIdNull: true } : {}),
|
|
2400
3192
|
},
|
|
2401
3193
|
];
|
|
2402
3194
|
}
|
|
@@ -2407,12 +3199,15 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2407
3199
|
return typeof relative === "string" && relative !== "" ? relative : undefined;
|
|
2408
3200
|
}
|
|
2409
3201
|
|
|
2410
|
-
private matches(path: string): boolean {
|
|
3202
|
+
private matches(path: string, tree = false): boolean {
|
|
2411
3203
|
if (this.pathFilter && !path.startsWith(this.pathFilter)) return false;
|
|
2412
3204
|
// diff_queue_addremove / diff_change / diff_unmerge: outside the prefix, nothing is queued
|
|
2413
3205
|
const prefix = this.relativePrefix;
|
|
2414
3206
|
if (prefix !== undefined && !path.startsWith(prefix)) return false;
|
|
2415
|
-
|
|
3207
|
+
// tree_entry_interesting: a subtree shown (`-t`, without `-r`) is one the pathspec
|
|
3208
|
+
// matches or leads to
|
|
3209
|
+
const flags = tree ? DO_MATCH_DIRECTORY | DO_MATCH_LEADING_PATHSPEC : 0;
|
|
3210
|
+
return !this.pathspecItems || matchPathspec(this.pathspecItems, path, flags) > 0;
|
|
2416
3211
|
}
|
|
2417
3212
|
|
|
2418
3213
|
/**
|
|
@@ -2423,24 +3218,36 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2423
3218
|
oldSide: Map<string, Side>,
|
|
2424
3219
|
newSide: Map<string, Side>,
|
|
2425
3220
|
unmerged: Map<string, DiffEntry[]>,
|
|
3221
|
+
trees = false,
|
|
2426
3222
|
): DiffEntry[] {
|
|
2427
3223
|
const paths = new Set<string>([...oldSide.keys(), ...newSide.keys(), ...unmerged.keys()]);
|
|
2428
|
-
|
|
3224
|
+
// a subtree listed as an entry (`flat`) is keyed `<path>/`: it sorts as tree-diff.c
|
|
3225
|
+
// walks it and pairs with no blob of its name
|
|
3226
|
+
const sorted = [...paths]
|
|
3227
|
+
.filter((p) =>
|
|
3228
|
+
p.endsWith("/") ? this.matches(p.slice(0, -1), true) : this.matches(p, trees),
|
|
3229
|
+
)
|
|
3230
|
+
.sort(compareBytes);
|
|
2429
3231
|
const entries: DiffEntry[] = [];
|
|
2430
|
-
for (const
|
|
2431
|
-
const
|
|
3232
|
+
for (const key of sorted) {
|
|
3233
|
+
const path = key.endsWith("/") ? key.slice(0, -1) : key;
|
|
3234
|
+
const extra = unmerged.get(key);
|
|
2432
3235
|
if (extra) {
|
|
3236
|
+
const raw = this.unmergedRaw.get(path);
|
|
2433
3237
|
entries.push({
|
|
2434
3238
|
changeType: ChangeType.MODIFY,
|
|
2435
3239
|
oldPath: path,
|
|
2436
3240
|
newPath: path,
|
|
2437
3241
|
unmerged: true,
|
|
3242
|
+
...(raw?.oldMode !== undefined ? { oldMode: raw.oldMode as FileModeValue } : {}),
|
|
3243
|
+
...(raw?.oldId !== undefined ? { oldId: raw.oldId } : {}),
|
|
3244
|
+
...(raw?.newMode !== undefined ? { newMode: raw.newMode as FileModeValue } : {}),
|
|
2438
3245
|
});
|
|
2439
3246
|
entries.push(...extra);
|
|
2440
3247
|
continue;
|
|
2441
3248
|
}
|
|
2442
|
-
const a = oldSide.get(
|
|
2443
|
-
const b = newSide.get(
|
|
3249
|
+
const a = oldSide.get(key);
|
|
3250
|
+
const b = newSide.get(key);
|
|
2444
3251
|
if (a && !b) {
|
|
2445
3252
|
entries.push({
|
|
2446
3253
|
changeType: ChangeType.DELETE,
|
|
@@ -2458,8 +3265,17 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2458
3265
|
...(b.dirty ? { newDirtySubmodule: true } : {}),
|
|
2459
3266
|
...(b.dirt ? { newSubmoduleDirt: b.dirt } : {}),
|
|
2460
3267
|
...(b.unknownId ? { newIdUnknown: true } : {}),
|
|
3268
|
+
...(b.rawNull ? { newIdNull: true } : {}),
|
|
2461
3269
|
});
|
|
2462
|
-
} else if (
|
|
3270
|
+
} else if (
|
|
3271
|
+
a &&
|
|
3272
|
+
b &&
|
|
3273
|
+
(a.id !== b.id ||
|
|
3274
|
+
a.mode !== b.mode ||
|
|
3275
|
+
b.dirty ||
|
|
3276
|
+
b.unknownId ||
|
|
3277
|
+
(b.rawNull && this.plumbingWorktree))
|
|
3278
|
+
) {
|
|
2463
3279
|
// show_modified: a side of the null id differs from any (`M sub` even where the
|
|
2464
3280
|
// submodule is back at the tree's commit)
|
|
2465
3281
|
entries.push({
|
|
@@ -2474,6 +3290,7 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2474
3290
|
...(b.dirty ? { newDirtySubmodule: true } : {}),
|
|
2475
3291
|
...(b.dirt ? { newSubmoduleDirt: b.dirt } : {}),
|
|
2476
3292
|
...(b.unknownId ? { newIdUnknown: true } : {}),
|
|
3293
|
+
...(b.rawNull ? { newIdNull: true } : {}),
|
|
2477
3294
|
});
|
|
2478
3295
|
}
|
|
2479
3296
|
}
|
|
@@ -2481,51 +3298,264 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2481
3298
|
}
|
|
2482
3299
|
|
|
2483
3300
|
/**
|
|
2484
|
-
*
|
|
2485
|
-
* `
|
|
3301
|
+
* diffcore's settings of a run: rename or copy detection (`renames` as configured or set,
|
|
3302
|
+
* then `-M`/`-C`), its threshold, `--find-copies-harder`, `-B`; option errors are thrown here
|
|
2486
3303
|
*/
|
|
2487
|
-
private
|
|
3304
|
+
private diffcoreSettings(renames: boolean | "copies"): DiffcoreSettings {
|
|
3305
|
+
const o = this.textOptions;
|
|
3306
|
+
let detect: DiffcoreSettings["detect"] =
|
|
3307
|
+
renames === "copies" ? "copies" : renames ? "renames" : false;
|
|
3308
|
+
let score: number | undefined;
|
|
3309
|
+
let harder = o.findCopiesHarder === true;
|
|
3310
|
+
if (o.findRenames !== undefined) {
|
|
3311
|
+
if (o.findRenames === false) detect = false;
|
|
3312
|
+
else {
|
|
3313
|
+
detect = "renames";
|
|
3314
|
+
score = renameScoreOption(o.findRenames, "find-renames");
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
if (o.findCopies !== undefined && o.findCopies !== false) {
|
|
3318
|
+
// diff_opt_find_copies: a second -C (copies already on, from diff.renames) finds harder
|
|
3319
|
+
if (detect === "copies" && o.findRenames === undefined) harder = true;
|
|
3320
|
+
detect = "copies";
|
|
3321
|
+
score = renameScoreOption(o.findCopies, "find-copies") ?? score;
|
|
3322
|
+
}
|
|
3323
|
+
const breaks =
|
|
3324
|
+
o.breakRewrites !== undefined && o.breakRewrites !== false
|
|
3325
|
+
? parseBreakRewrites(o.breakRewrites)
|
|
3326
|
+
: undefined;
|
|
3327
|
+
return {
|
|
3328
|
+
detect,
|
|
3329
|
+
harder: detect === "copies" && harder,
|
|
3330
|
+
...(score !== undefined ? { score } : {}),
|
|
3331
|
+
...(breaks ? { breaks } : {}),
|
|
3332
|
+
};
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3335
|
+
/**
|
|
3336
|
+
* diffcore_std's pair stages: `diffcore_break` (`-B`), `diffcore_rename` (renames, copies,
|
|
3337
|
+
* `--find-copies-harder`), `diffcore_merge_broken`, then `diff_resolve_rename_copy`. The
|
|
3338
|
+
* entries are changed in place, in git's queue order.
|
|
3339
|
+
*/
|
|
3340
|
+
private async diffcore(
|
|
3341
|
+
entries: DiffEntry[],
|
|
3342
|
+
core: DiffcoreSettings,
|
|
3343
|
+
oldFiles: () => Promise<Map<string, Side>>,
|
|
3344
|
+
): Promise<void> {
|
|
3345
|
+
const readBlob = async (id: ObjectId) => collectChunks((await this.blobs.load(id)) ?? []);
|
|
3346
|
+
const countLastSpan = this.textOptions.renameCountLastSpan;
|
|
3347
|
+
/** git's diff_filepair extras: a broken half's score, a renamed creation's source */
|
|
3348
|
+
const broken = new Map<DiffEntry, number>();
|
|
3349
|
+
const source = new Map<DiffEntry, { path: string; breakScore?: number }>();
|
|
3350
|
+
const uses = new Map<string, number>();
|
|
3351
|
+
|
|
3352
|
+
if (core.breaks) {
|
|
3353
|
+
const { breakScore, mergeScore } = core.breaks;
|
|
3354
|
+
const out: DiffEntry[] = [];
|
|
3355
|
+
for (const e of entries) {
|
|
3356
|
+
const blobMode = (m: number | undefined) =>
|
|
3357
|
+
m !== undefined && m !== 0 && m !== GITLINK && (m & 0o170000) !== 0o040000;
|
|
3358
|
+
if (
|
|
3359
|
+
e.changeType !== ChangeType.MODIFY ||
|
|
3360
|
+
e.unmerged ||
|
|
3361
|
+
!blobMode(e.oldMode) ||
|
|
3362
|
+
!blobMode(e.newMode) ||
|
|
3363
|
+
e.oldId === undefined
|
|
3364
|
+
) {
|
|
3365
|
+
out.push(e);
|
|
3366
|
+
continue;
|
|
3367
|
+
}
|
|
3368
|
+
const oldContent = () => (e.readOld ? e.readOld() : readBlob(e.oldId as ObjectId));
|
|
3369
|
+
const newContent = () => (e.readNew ? e.readNew() : readBlob(e.newId as ObjectId));
|
|
3370
|
+
const sideOf = async (mode: number, read: () => Promise<Uint8Array>) => {
|
|
3371
|
+
const content = await read();
|
|
3372
|
+
return {
|
|
3373
|
+
mode,
|
|
3374
|
+
size: content.length,
|
|
3375
|
+
spans: async () => spanCounts(content, { countLastSpan }),
|
|
3376
|
+
};
|
|
3377
|
+
};
|
|
3378
|
+
const same = !e.readOld && !e.readNew && !e.newIdUnknown && e.oldId === e.newId;
|
|
3379
|
+
const verdict = await shouldBreak(
|
|
3380
|
+
await sideOf(e.oldMode as number, oldContent),
|
|
3381
|
+
await sideOf(e.newMode as number, newContent),
|
|
3382
|
+
breakScore,
|
|
3383
|
+
same,
|
|
3384
|
+
);
|
|
3385
|
+
if (!verdict.broken) {
|
|
3386
|
+
out.push(e);
|
|
3387
|
+
continue;
|
|
3388
|
+
}
|
|
3389
|
+
const score = verdict.mergeScore < mergeScore ? 0 : verdict.mergeScore;
|
|
3390
|
+
const del: DiffEntry = {
|
|
3391
|
+
changeType: ChangeType.DELETE,
|
|
3392
|
+
oldPath: e.oldPath,
|
|
3393
|
+
oldId: e.oldId,
|
|
3394
|
+
oldMode: e.oldMode,
|
|
3395
|
+
...(e.readOld ? { readOld: e.readOld } : {}),
|
|
3396
|
+
};
|
|
3397
|
+
const add: DiffEntry = {
|
|
3398
|
+
changeType: ChangeType.ADD,
|
|
3399
|
+
newPath: e.newPath,
|
|
3400
|
+
newId: e.newId,
|
|
3401
|
+
newMode: e.newMode,
|
|
3402
|
+
...(e.readNew ? { readNew: e.readNew } : {}),
|
|
3403
|
+
};
|
|
3404
|
+
broken.set(del, score);
|
|
3405
|
+
broken.set(add, score);
|
|
3406
|
+
out.push(del, add);
|
|
3407
|
+
}
|
|
3408
|
+
entries.splice(0, entries.length, ...out);
|
|
3409
|
+
}
|
|
3410
|
+
|
|
3411
|
+
if (core.detect) await this.detectRenames(entries, core, oldFiles, broken, source, uses);
|
|
3412
|
+
|
|
3413
|
+
if (core.breaks) {
|
|
3414
|
+
// diffcore_merge_broken: halves that both survived are one modification again
|
|
3415
|
+
const onePath = (e: DiffEntry) =>
|
|
3416
|
+
source.get(e)?.path ?? (e.changeType === ChangeType.ADD ? e.newPath : e.oldPath);
|
|
3417
|
+
const twoPath = (e: DiffEntry) =>
|
|
3418
|
+
e.changeType === ChangeType.DELETE ? e.oldPath : e.newPath;
|
|
3419
|
+
const samePath = (e: DiffEntry) => broken.has(e) && onePath(e) === twoPath(e);
|
|
3420
|
+
const out: DiffEntry[] = [];
|
|
3421
|
+
const merged = new Set<DiffEntry>();
|
|
3422
|
+
for (let i = 0; i < entries.length; i++) {
|
|
3423
|
+
const p = entries[i] as DiffEntry;
|
|
3424
|
+
if (merged.has(p)) continue;
|
|
3425
|
+
if (samePath(p)) {
|
|
3426
|
+
let peer: DiffEntry | undefined;
|
|
3427
|
+
for (let j = i + 1; j < entries.length; j++) {
|
|
3428
|
+
const pp = entries[j] as DiffEntry;
|
|
3429
|
+
if (!merged.has(pp) && samePath(pp) && onePath(p) === twoPath(pp)) {
|
|
3430
|
+
peer = pp;
|
|
3431
|
+
break;
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
if (peer) {
|
|
3435
|
+
merged.add(peer);
|
|
3436
|
+
const d = p.changeType === ChangeType.DELETE ? p : peer;
|
|
3437
|
+
const c = d === p ? peer : p;
|
|
3438
|
+
const score = broken.get(p) ?? 0;
|
|
3439
|
+
out.push({
|
|
3440
|
+
changeType: ChangeType.MODIFY,
|
|
3441
|
+
oldPath: d.oldPath,
|
|
3442
|
+
newPath: c.newPath,
|
|
3443
|
+
oldId: d.oldId,
|
|
3444
|
+
newId: c.newId,
|
|
3445
|
+
oldMode: d.oldMode,
|
|
3446
|
+
newMode: c.newMode,
|
|
3447
|
+
...(d.readOld ? { readOld: d.readOld } : {}),
|
|
3448
|
+
...(c.readNew ? { readNew: c.readNew } : {}),
|
|
3449
|
+
...(score ? { score: scorePercent(score) } : {}),
|
|
3450
|
+
});
|
|
3451
|
+
const from = d.oldPath ?? "";
|
|
3452
|
+
uses.set(from, (uses.get(from) ?? 0) + 1);
|
|
3453
|
+
continue;
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
out.push(p);
|
|
3457
|
+
}
|
|
3458
|
+
entries.splice(0, entries.length, ...out);
|
|
3459
|
+
}
|
|
3460
|
+
|
|
3461
|
+
// diff_resolve_rename_copy: in queue order, each renamed pair takes one use of its source
|
|
3462
|
+
for (const e of entries) {
|
|
3463
|
+
const from = source.get(e);
|
|
3464
|
+
if (!from) continue;
|
|
3465
|
+
if (from.path === e.newPath) {
|
|
3466
|
+
// a rename joined a broken pair again: a modification (a rewrite with its score)
|
|
3467
|
+
e.changeType = ChangeType.MODIFY;
|
|
3468
|
+
if (from.breakScore) e.score = scorePercent(from.breakScore);
|
|
3469
|
+
else delete e.score;
|
|
3470
|
+
continue;
|
|
3471
|
+
}
|
|
3472
|
+
const left = (uses.get(from.path) ?? 0) - 1;
|
|
3473
|
+
uses.set(from.path, left);
|
|
3474
|
+
e.changeType = left > 0 ? ChangeType.COPY : ChangeType.RENAME;
|
|
3475
|
+
}
|
|
3476
|
+
}
|
|
3477
|
+
|
|
3478
|
+
/**
|
|
3479
|
+
* git's `diffcore_rename` over the queue: deleted paths (broken deletions too) as sources,
|
|
3480
|
+
* with copies the modified paths (and, harder, the unmodified ones) as sources that stay,
|
|
3481
|
+
* created paths as destinations. A destination paired becomes a rename (resolved into a
|
|
3482
|
+
* copy or a rename by {@link diffcore}); a deletion its rename takes is dropped.
|
|
3483
|
+
*/
|
|
3484
|
+
private async detectRenames(
|
|
3485
|
+
entries: DiffEntry[],
|
|
3486
|
+
core: DiffcoreSettings,
|
|
3487
|
+
oldFiles: () => Promise<Map<string, Side>>,
|
|
3488
|
+
broken: Map<DiffEntry, number>,
|
|
3489
|
+
source: Map<DiffEntry, { path: string; breakScore?: number }>,
|
|
3490
|
+
uses: Map<string, number>,
|
|
3491
|
+
): Promise<void> {
|
|
3492
|
+
const copies = core.detect === "copies";
|
|
2488
3493
|
const sources = entries.filter(
|
|
2489
3494
|
(e) =>
|
|
2490
|
-
e.changeType === ChangeType.DELETE ||
|
|
3495
|
+
(e.changeType === ChangeType.DELETE && !e.unmerged) ||
|
|
2491
3496
|
(copies && e.changeType === ChangeType.MODIFY && !e.unmerged),
|
|
2492
3497
|
);
|
|
2493
3498
|
// a submodule of git's null id (diff-index of a moved one) matches no source exactly,
|
|
2494
3499
|
// and gitlinks pair only exactly
|
|
2495
3500
|
const destinations = entries.filter((e) => e.changeType === ChangeType.ADD && !e.newIdUnknown);
|
|
3501
|
+
// --find-copies-harder: every unchanged path of the old side is a source too
|
|
3502
|
+
const unmodified: DiffEntry[] = [];
|
|
3503
|
+
if (copies && core.harder && destinations.length > 0) {
|
|
3504
|
+
const listed = new Set(entries.map((e) => e.oldPath ?? e.newPath));
|
|
3505
|
+
for (const [path, side] of await oldFiles()) {
|
|
3506
|
+
if (listed.has(path) || !this.matches(path)) continue;
|
|
3507
|
+
unmodified.push({
|
|
3508
|
+
changeType: ChangeType.MODIFY,
|
|
3509
|
+
oldPath: path,
|
|
3510
|
+
newPath: path,
|
|
3511
|
+
oldId: side.id,
|
|
3512
|
+
newId: side.id,
|
|
3513
|
+
oldMode: side.mode as FileModeValue,
|
|
3514
|
+
newMode: side.mode as FileModeValue,
|
|
3515
|
+
});
|
|
3516
|
+
}
|
|
3517
|
+
sources.push(...unmodified);
|
|
3518
|
+
}
|
|
3519
|
+
for (const e of sources) {
|
|
3520
|
+
const kept = e.changeType === ChangeType.MODIFY || (broken.has(e) && !broken.get(e));
|
|
3521
|
+
uses.set(e.oldPath ?? "", kept ? 1 : 0);
|
|
3522
|
+
}
|
|
2496
3523
|
if (sources.length === 0 || destinations.length === 0) return;
|
|
2497
3524
|
const byPath = new Map<string, DiffEntry>();
|
|
2498
3525
|
for (const e of sources) byPath.set(`s:${e.oldPath}`, e);
|
|
2499
3526
|
for (const e of destinations) byPath.set(`d:${e.newPath}`, e);
|
|
2500
|
-
const
|
|
2501
|
-
const chunks: Uint8Array[] = [];
|
|
2502
|
-
let size = 0;
|
|
2503
|
-
for await (const c of (await this.blobs.load(id)) ?? []) {
|
|
2504
|
-
chunks.push(c);
|
|
2505
|
-
size += c.length;
|
|
2506
|
-
}
|
|
2507
|
-
const out = new Uint8Array(size);
|
|
2508
|
-
let at = 0;
|
|
2509
|
-
for (const c of chunks) {
|
|
2510
|
-
out.set(c, at);
|
|
2511
|
-
at += c.length;
|
|
2512
|
-
}
|
|
2513
|
-
return out;
|
|
2514
|
-
};
|
|
3527
|
+
const unmodifiedSet = new Set(unmodified);
|
|
2515
3528
|
const limit =
|
|
2516
3529
|
this.renameLimit ?? intValue(this.config.value("diff.renameLimit")) ?? DEFAULT_RENAME_LIMIT;
|
|
3530
|
+
let needed = 0;
|
|
3531
|
+
let degraded = false;
|
|
2517
3532
|
const pairs = await detectRenames(
|
|
2518
|
-
sources.map((e) =>
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
3533
|
+
sources.map((e) => {
|
|
3534
|
+
const kept = e.changeType === ChangeType.MODIFY || (broken.has(e) && !broken.get(e));
|
|
3535
|
+
return {
|
|
3536
|
+
path: e.oldPath ?? "",
|
|
3537
|
+
mode: e.oldMode ?? 0,
|
|
3538
|
+
id: e.oldId ?? "",
|
|
3539
|
+
...(kept ? { kept: true } : {}),
|
|
3540
|
+
...(unmodifiedSet.has(e) ? { unmodified: true } : {}),
|
|
3541
|
+
};
|
|
3542
|
+
}),
|
|
2524
3543
|
destinations.map((e) => ({ path: e.newPath ?? "", mode: e.newMode ?? 0, id: e.newId ?? "" })),
|
|
2525
3544
|
{
|
|
2526
3545
|
renameLimit: limit,
|
|
2527
3546
|
countLastSpan: this.textOptions.renameCountLastSpan,
|
|
2528
3547
|
copies,
|
|
3548
|
+
breakMode: sources.some((e) => broken.has(e)),
|
|
3549
|
+
...(core.score !== undefined ? { minimumScore: core.score } : {}),
|
|
3550
|
+
onRenameLimit: (n) => {
|
|
3551
|
+
needed = n;
|
|
3552
|
+
},
|
|
3553
|
+
onDegraded: () => {
|
|
3554
|
+
degraded = true;
|
|
3555
|
+
},
|
|
3556
|
+
onUses: (counted) => {
|
|
3557
|
+
for (const [path, n] of counted) uses.set(path, n);
|
|
3558
|
+
},
|
|
2529
3559
|
// a partial clone's absent blobs, fetched in one batch (a worktree file is no blob)
|
|
2530
3560
|
prefetch: async (wanted) => {
|
|
2531
3561
|
const ids: ObjectId[] = [];
|
|
@@ -2548,27 +3578,51 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2548
3578
|
load: async (c, role) => {
|
|
2549
3579
|
const e = byPath.get(`${role === "source" ? "s" : "d"}:${c.path}`);
|
|
2550
3580
|
if (role === "destination" && e?.readNew) return e.readNew();
|
|
2551
|
-
return
|
|
3581
|
+
return collectChunks((await this.blobs.load(c.id)) ?? []);
|
|
2552
3582
|
},
|
|
2553
3583
|
},
|
|
2554
3584
|
);
|
|
2555
|
-
|
|
3585
|
+
// diff_warn_rename_limit
|
|
3586
|
+
if (degraded) {
|
|
3587
|
+
this.configWarnings.push(
|
|
3588
|
+
"warning: only found copies from modified paths due to too many files.",
|
|
3589
|
+
);
|
|
3590
|
+
} else if (needed) {
|
|
3591
|
+
this.configWarnings.push(
|
|
3592
|
+
"warning: exhaustive rename detection was skipped due to too many files.",
|
|
3593
|
+
);
|
|
3594
|
+
}
|
|
3595
|
+
if (needed) {
|
|
3596
|
+
this.configWarnings.push(
|
|
3597
|
+
`warning: you may want to set your diff.renameLimit variable to at least ${needed} and retry the command.`,
|
|
3598
|
+
);
|
|
3599
|
+
}
|
|
3600
|
+
const renamedHalves = new Set<string>();
|
|
2556
3601
|
for (const pair of pairs) {
|
|
2557
3602
|
const src = byPath.get(`s:${pair.from}`);
|
|
2558
3603
|
const dst = byPath.get(`d:${pair.to}`);
|
|
2559
3604
|
if (!src || !dst) continue;
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
3605
|
+
const breakScore = broken.get(src);
|
|
3606
|
+
source.set(dst, {
|
|
3607
|
+
path: pair.from,
|
|
3608
|
+
...(breakScore !== undefined ? { breakScore } : {}),
|
|
3609
|
+
});
|
|
3610
|
+
if (broken.has(dst)) renamedHalves.add(dst.newPath ?? "");
|
|
3611
|
+
dst.changeType = ChangeType.RENAME;
|
|
2563
3612
|
dst.oldPath = src.oldPath;
|
|
2564
3613
|
dst.oldId = src.oldId;
|
|
2565
3614
|
dst.oldMode = src.oldMode;
|
|
2566
|
-
dst.
|
|
2567
|
-
|
|
2568
|
-
if (drop.size > 0) {
|
|
2569
|
-
const kept = entries.filter((e) => !drop.has(e));
|
|
2570
|
-
entries.splice(0, entries.length, ...kept);
|
|
3615
|
+
if (src.readOld) dst.readOld = src.readOld;
|
|
3616
|
+
dst.score = scorePercent(pair.from === pair.to ? (breakScore ?? 0) : pair.score);
|
|
2571
3617
|
}
|
|
3618
|
+
// the deletions a rename or copy takes away: a broken one when its own creation was
|
|
3619
|
+
// paired, any other once used
|
|
3620
|
+
const kept = entries.filter((e) => {
|
|
3621
|
+
if (e.changeType !== ChangeType.DELETE || e.unmerged) return true;
|
|
3622
|
+
if (broken.has(e)) return !renamedHalves.has(e.oldPath ?? "");
|
|
3623
|
+
return !(uses.get(e.oldPath ?? "") ?? 0);
|
|
3624
|
+
});
|
|
3625
|
+
entries.splice(0, entries.length, ...kept);
|
|
2572
3626
|
}
|
|
2573
3627
|
|
|
2574
3628
|
/**
|
|
@@ -2671,6 +3725,11 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2671
3725
|
// them (100664 is 100644)
|
|
2672
3726
|
if (xe.id === ye.id && xe.mode === ye.mode) continue;
|
|
2673
3727
|
const path = prefix ? `${prefix}/${xe.name}` : xe.name;
|
|
3728
|
+
if (isTreeMode(xe.mode) && isTreeMode(ye.mode) && this.treeWalk === "flat") {
|
|
3729
|
+
oldSide.set(`${path}/`, { mode: xe.mode, id: xe.id });
|
|
3730
|
+
newSide.set(`${path}/`, { mode: ye.mode, id: ye.id });
|
|
3731
|
+
continue;
|
|
3732
|
+
}
|
|
2674
3733
|
if (isTreeMode(xe.mode) && isTreeMode(ye.mode)) {
|
|
2675
3734
|
this.addTreeSide(path, xe.mode, xe.id, oldSide);
|
|
2676
3735
|
this.addTreeSide(path, ye.mode, ye.id, newSide);
|
|
@@ -2714,7 +3773,10 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2714
3773
|
} else {
|
|
2715
3774
|
if (!x.sameAs(y)) {
|
|
2716
3775
|
const path = pathOf(x.name());
|
|
2717
|
-
if (x.isTree && y.isTree) {
|
|
3776
|
+
if (x.isTree && y.isTree && this.treeWalk === "flat") {
|
|
3777
|
+
oldSide.set(`${path}/`, { mode: x.mode, id: x.id() });
|
|
3778
|
+
newSide.set(`${path}/`, { mode: y.mode, id: y.id() });
|
|
3779
|
+
} else if (x.isTree && y.isTree) {
|
|
2718
3780
|
this.addTreeSide(path, x.mode, x.id(), oldSide);
|
|
2719
3781
|
this.addTreeSide(path, y.mode, y.id(), newSide);
|
|
2720
3782
|
await this.diffRawTrees(x.id(), y.id(), path, oldSide, newSide);
|
|
@@ -2735,7 +3797,9 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2735
3797
|
path: string,
|
|
2736
3798
|
side: Map<string, Side>,
|
|
2737
3799
|
): Promise<void> {
|
|
2738
|
-
if (c.isTree) {
|
|
3800
|
+
if (c.isTree && this.treeWalk === "flat") {
|
|
3801
|
+
side.set(`${path}/`, { mode: c.mode, id: c.id() });
|
|
3802
|
+
} else if (c.isTree) {
|
|
2739
3803
|
this.addTreeSide(path, c.mode, c.id(), side);
|
|
2740
3804
|
await this.collectTreeEntries(c.id(), path, side);
|
|
2741
3805
|
} else side.set(path, { mode: c.mode, id: c.id() });
|
|
@@ -2743,7 +3807,9 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2743
3807
|
|
|
2744
3808
|
/** A tree entry on one side: a blob as itself, a subtree as its blobs */
|
|
2745
3809
|
private async addSide(e: TreeEntry, path: string, side: Map<string, Side>): Promise<void> {
|
|
2746
|
-
if (isTreeMode(e.mode)) {
|
|
3810
|
+
if (isTreeMode(e.mode) && this.treeWalk === "flat") {
|
|
3811
|
+
side.set(`${path}/`, { mode: e.mode, id: e.id });
|
|
3812
|
+
} else if (isTreeMode(e.mode)) {
|
|
2747
3813
|
this.addTreeSide(path, e.mode, e.id, side);
|
|
2748
3814
|
await this.collectTreeEntries(e.id, path, side);
|
|
2749
3815
|
} else side.set(path, { mode: e.mode, id: e.id });
|
|
@@ -2851,16 +3917,31 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2851
3917
|
const content = encoder.encode(`Subproject commit ${id}-dirty\n`);
|
|
2852
3918
|
return { mode, id, dirty, dirt, ...unknown, read: async () => content };
|
|
2853
3919
|
}
|
|
2854
|
-
if (!result.kind && !entry.intentToAdd) return indexSide;
|
|
2855
3920
|
const path = entry.path;
|
|
3921
|
+
// plumbing's ie_match_stat: a stat that differs is a change, the file not hashed
|
|
3922
|
+
// (a racily clean entry's content is compared)
|
|
3923
|
+
const statDirty =
|
|
3924
|
+
this.plumbingWorktree &&
|
|
3925
|
+
!entry.intentToAdd &&
|
|
3926
|
+
!result.kind &&
|
|
3927
|
+
result.hashedId !== undefined &&
|
|
3928
|
+
!!result.worktreeEntry &&
|
|
3929
|
+
!basicStatMatches(entry, result.worktreeEntry, trust);
|
|
3930
|
+
if (!result.kind && !entry.intentToAdd && !statDirty) return indexSide;
|
|
2856
3931
|
const id = result.hashedId ?? (await worktree.computeHash(path));
|
|
2857
|
-
|
|
3932
|
+
// run_diff_files / run_diff_index: the worktree side is not hashed (its raw id is the
|
|
3933
|
+
// null id), porcelain included; only the porcelain's intent-to-add entry, shown as a
|
|
3934
|
+
// new file, gets its content's id
|
|
3935
|
+
const rawNull = this.plumbingWorktree || !entry.intentToAdd;
|
|
3936
|
+
if (!entry.intentToAdd && id === entry.objectId && mode === entry.mode && !statDirty) {
|
|
3937
|
+
return indexSide;
|
|
3938
|
+
}
|
|
2858
3939
|
let content: Promise<Uint8Array> | undefined;
|
|
2859
3940
|
const read = () => {
|
|
2860
3941
|
content ??= readCleanContent(worktree, path);
|
|
2861
3942
|
return content;
|
|
2862
3943
|
};
|
|
2863
|
-
return { mode, id, read };
|
|
3944
|
+
return { mode, id, read, ...(rawNull ? { rawNull: true } : {}) };
|
|
2864
3945
|
};
|
|
2865
3946
|
const compare: WorktreeCompare = (entry) => compareWith(entry);
|
|
2866
3947
|
// the stat pass: the files of the stage-0 entries compared, stat'ed a chunk at a time
|
|
@@ -2886,10 +3967,16 @@ export class DiffCommand extends GitCommand<DiffEntry[]> {
|
|
|
2886
3967
|
}
|
|
2887
3968
|
if (!this.matches(entry.path)) continue;
|
|
2888
3969
|
const side = await compareWith(entry, current);
|
|
2889
|
-
if (changedOnly && !entry.intentToAdd) {
|
|
3970
|
+
if (changedOnly && (!entry.intentToAdd || this.intentToAddVisible)) {
|
|
2890
3971
|
// diff-files: an entry its file still holds is no change on either side, left out
|
|
2891
3972
|
// of both (the index side is the entry, as `indexSide` gives it)
|
|
2892
|
-
if (
|
|
3973
|
+
if (
|
|
3974
|
+
side &&
|
|
3975
|
+
side.id === entry.objectId &&
|
|
3976
|
+
side.mode === entry.mode &&
|
|
3977
|
+
!side.dirty &&
|
|
3978
|
+
!(side.rawNull && this.plumbingWorktree)
|
|
3979
|
+
) {
|
|
2893
3980
|
continue;
|
|
2894
3981
|
}
|
|
2895
3982
|
changedOnly.set(entry.path, { mode: entry.mode, id: entry.objectId });
|