@statewalker/vcs-commands 0.9.0 → 0.11.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.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 +41 -2
- package/dist/commands/am/am-command.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 +43 -1
- package/dist/commands/blame-command.d.ts.map +1 -1
- 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 +144 -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-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.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/cherry-pick-command.d.ts +10 -0
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +28 -0
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +9 -1
- 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 +54 -0
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +132 -5
- 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 +65 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fetch-multiple-command.d.ts.map +1 -1
- package/dist/commands/format-rev-command.d.ts +60 -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-ipc.d.ts +30 -0
- package/dist/commands/fsmonitor-ipc.d.ts.map +1 -0
- 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-hooks.d.ts +32 -0
- 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 +45 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +6 -5
- 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/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +26 -0
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +28 -1
- 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/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 +7 -0
- 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 +67 -5
- package/dist/commands/merge-drivers.d.ts.map +1 -1
- package/dist/commands/merge-support.d.ts +6 -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/mktag-command.d.ts +51 -0
- package/dist/commands/mktag-command.d.ts.map +1 -0
- 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/ort-merge.d.ts +24 -0
- package/dist/commands/ort-merge.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 +24 -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.map +1 -1
- package/dist/commands/push-command.d.ts +17 -2
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +108 -2
- 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/remote-object-info-command.d.ts +55 -0
- package/dist/commands/remote-object-info-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 +158 -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 -2
- package/dist/commands/reset-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 +3 -0
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/rev-parse-command.d.ts +5 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +10 -0
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +5 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +27 -1
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +18 -0
- package/dist/commands/sequencer-pick.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/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 +30 -2
- 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 +16 -2
- 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 +22 -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 +9 -1
- package/dist/commands/submodule-commands.d.ts.map +1 -1
- package/dist/commands/submodule-update-command.d.ts +27 -1
- package/dist/commands/submodule-update-command.d.ts.map +1 -1
- package/dist/commands/tag-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 +131 -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-CNvli5bl.js → commands-bQQ9OmCh.js} +52514 -44630
- package/dist/errors/command-errors.d.ts +33 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +39 -1
- package/dist/{fsck-CPeDh9fh.js → fsck-BHT9bUS-.js} +184 -143
- package/dist/git-command.d.ts +66 -4
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +532 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +3 -1
- package/dist/guarded-transport-command.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/maintenance-run-command-Cx2PlGV9.js +13544 -0
- package/dist/{remote-transport-CCmBadm-.js → remote-transport-BrQZfyHu.js} +1009 -10
- package/dist/results/cherry-pick-result.d.ts +6 -0
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/diff-entry.d.ts +10 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +49 -3
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/fetch-result.d.ts +12 -0
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/merge-result.d.ts +5 -0
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +5 -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-BDuEgdLU.js → results-CNHQnU5Y.js} +13707 -10608
- package/dist/transport-command.d.ts +79 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/commands/add-command.ts +3 -0
- package/src/commands/add-patch/patch-backend.ts +4 -1
- 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 +193 -22
- package/src/commands/apply/index.ts +1 -0
- 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 +118 -19
- 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 +895 -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-ref-format-command.ts +129 -0
- package/src/commands/checkout-command.ts +61 -22
- package/src/commands/checkout-index-command.ts +568 -0
- package/src/commands/checkout-paths.ts +7 -0
- package/src/commands/cherry-pick-command.ts +21 -1
- package/src/commands/clone-command.ts +249 -9
- package/src/commands/commit-command.ts +22 -4
- package/src/commands/config-command.ts +9 -0
- package/src/commands/daemon-access-hook.ts +78 -0
- package/src/commands/default-branch.ts +118 -1
- package/src/commands/diff-command.ts +592 -47
- 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 +312 -8
- package/src/commands/fetch-multiple-command.ts +4 -1
- package/src/commands/format-rev-command.ts +267 -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-ipc.ts +121 -0
- package/src/commands/fsmonitor-refresh.ts +320 -0
- package/src/commands/gc-command.ts +10 -0
- package/src/commands/git-hooks.ts +123 -6
- 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 +46 -0
- package/src/commands/init-command.ts +14 -0
- 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/local-transport.ts +252 -4
- package/src/commands/log-command.ts +104 -5
- package/src/commands/log-output.ts +66 -5
- 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 +708 -0
- package/src/commands/maintenance-run-command.ts +949 -0
- package/src/commands/merge-command.ts +78 -32
- package/src/commands/merge-config.ts +23 -1
- package/src/commands/merge-drivers.ts +109 -20
- package/src/commands/merge-support.ts +29 -5
- package/src/commands/merge-tree-command.ts +786 -0
- package/src/commands/mktag-command.ts +149 -0
- 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/ort-merge.ts +92 -25
- package/src/commands/patch-id-command.ts +65 -0
- package/src/commands/patch-id.ts +218 -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 +2 -0
- package/src/commands/push-command.ts +87 -5
- package/src/commands/rebase-command.ts +507 -19
- package/src/commands/refs-command.ts +274 -0
- package/src/commands/remote-object-info-command.ts +109 -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 +1066 -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 +75 -3
- package/src/commands/rev-filter/commit-grep.ts +7 -2
- package/src/commands/rev-list-command.ts +9 -0
- package/src/commands/rev-parse-command.ts +49 -5
- package/src/commands/revert-command.ts +21 -1
- package/src/commands/revision-range.ts +7 -2
- package/src/commands/revision-resolver.ts +97 -14
- package/src/commands/sequencer-pick.ts +47 -0
- package/src/commands/serve-repository.ts +65 -0
- package/src/commands/session-id.ts +31 -0
- package/src/commands/show-branch-command.ts +981 -0
- package/src/commands/show-command.ts +1 -1
- package/src/commands/show-ref-command.ts +439 -0
- package/src/commands/signature-check.ts +37 -5
- package/src/commands/signing.ts +176 -23
- package/src/commands/stash-apply-command.ts +3 -0
- package/src/commands/stash-export-command.ts +397 -0
- package/src/commands/status-command.ts +74 -8
- package/src/commands/stripspace-command.ts +118 -0
- package/src/commands/submodule-add-command.ts +40 -2
- package/src/commands/submodule-auth.ts +61 -6
- package/src/commands/submodule-commands.ts +12 -2
- package/src/commands/submodule-update-command.ts +47 -1
- package/src/commands/tag-command.ts +33 -11
- package/src/commands/textconv-cache.ts +143 -0
- package/src/commands/tree-restore.ts +14 -0
- package/src/commands/unpack-objects-command.ts +235 -0
- package/src/commands/update-index-command.ts +1148 -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/errors/command-errors.ts +45 -0
- package/src/git-command.ts +177 -3
- package/src/git.ts +808 -1
- package/src/guarded-transport-command.ts +6 -1
- package/src/results/cherry-pick-result.ts +6 -0
- package/src/results/diff-entry.ts +12 -0
- package/src/results/diff-formatter.ts +7 -4
- package/src/results/diff-output.ts +117 -11
- package/src/results/diff-pickaxe.ts +1 -1
- package/src/results/fetch-result.ts +12 -0
- package/src/results/merge-result.ts +5 -0
- package/src/results/push-result.ts +5 -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/transport-command.ts +182 -1
|
@@ -0,0 +1,949 @@
|
|
|
1
|
+
import type { FilesApi, History, ObjectId } from "@statewalker/vcs-core";
|
|
2
|
+
import { objectFormatOf, writePack } from "@statewalker/vcs-core";
|
|
3
|
+
import {
|
|
4
|
+
expireReflogs,
|
|
5
|
+
FileRawStorage,
|
|
6
|
+
geometricSplit,
|
|
7
|
+
multiPackIndexExpire,
|
|
8
|
+
multiPackIndexRepack,
|
|
9
|
+
multiPackIndexWrite,
|
|
10
|
+
packDeltaSearch,
|
|
11
|
+
parseExpiryDate,
|
|
12
|
+
prunePacked,
|
|
13
|
+
readPackWriteSettings,
|
|
14
|
+
readRepositoryFormat,
|
|
15
|
+
rerereGc,
|
|
16
|
+
rerereGcNeeded,
|
|
17
|
+
writeCommitGraph,
|
|
18
|
+
} from "@statewalker/vcs-store-files";
|
|
19
|
+
import { parseGitBool } from "@statewalker/vcs-utils/encoding";
|
|
20
|
+
import { atomicFilesOver } from "@statewalker/vcs-utils/files";
|
|
21
|
+
import { GitApiError } from "../errors/index.js";
|
|
22
|
+
import { GuardedTransportCommand } from "../guarded-transport-command.js";
|
|
23
|
+
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
24
|
+
import { FetchCommand, TagOption } from "./fetch-command.js";
|
|
25
|
+
import { GarbageCollectCommand } from "./gc-command.js";
|
|
26
|
+
import { hostEnvironmentOf } from "./git-ident.js";
|
|
27
|
+
import { objectsDirectoryDisplay } from "./object-store/objects-directory.js";
|
|
28
|
+
import { PlumbingError } from "./plumbing-command.js";
|
|
29
|
+
import { ReflogCommand } from "./reflog-command.js";
|
|
30
|
+
import { RepackCommand } from "./repack-command.js";
|
|
31
|
+
import { rerereGcLocation } from "./rerere.js";
|
|
32
|
+
import { WorktreePruneCommand } from "./worktree-prune-command.js";
|
|
33
|
+
|
|
34
|
+
/** git's maintenance tasks, in its task table's order (`tasks[]` of builtin/gc.c). */
|
|
35
|
+
export const MAINTENANCE_TASKS = [
|
|
36
|
+
"prefetch",
|
|
37
|
+
"loose-objects",
|
|
38
|
+
"incremental-repack",
|
|
39
|
+
"geometric-repack",
|
|
40
|
+
"gc",
|
|
41
|
+
"commit-graph",
|
|
42
|
+
"pack-refs",
|
|
43
|
+
"reflog-expire",
|
|
44
|
+
"worktree-prune",
|
|
45
|
+
"rerere-gc",
|
|
46
|
+
] as const;
|
|
47
|
+
|
|
48
|
+
export type MaintenanceTask = (typeof MAINTENANCE_TASKS)[number];
|
|
49
|
+
|
|
50
|
+
/** `--schedule=<frequency>` */
|
|
51
|
+
export type MaintenanceSchedule = "hourly" | "daily" | "weekly";
|
|
52
|
+
|
|
53
|
+
/** The tasks git 2.43 knows (the others are "not a valid task" there). */
|
|
54
|
+
const TASKS_243: readonly MaintenanceTask[] = [
|
|
55
|
+
"prefetch",
|
|
56
|
+
"loose-objects",
|
|
57
|
+
"incremental-repack",
|
|
58
|
+
"gc",
|
|
59
|
+
"commit-graph",
|
|
60
|
+
"pack-refs",
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
/** git's `enum schedule_priority`: none 0, weekly 1, daily 2, hourly 3. */
|
|
64
|
+
const PRIORITY: Record<MaintenanceSchedule, number> = { weekly: 1, daily: 2, hourly: 3 };
|
|
65
|
+
|
|
66
|
+
/** `MAINTENANCE_TYPE_SCHEDULED` and `MAINTENANCE_TYPE_MANUAL` */
|
|
67
|
+
const SCHEDULED = 1;
|
|
68
|
+
const MANUAL = 2;
|
|
69
|
+
|
|
70
|
+
type Strategy = Partial<Record<MaintenanceTask, { type: number; schedule: number }>>;
|
|
71
|
+
|
|
72
|
+
/** git 2.5x's maintenance strategies (`gc_strategy`, `incremental_strategy`, ...). */
|
|
73
|
+
const STRATEGIES: Record<string, Strategy> = {
|
|
74
|
+
gc: { gc: { type: MANUAL | SCHEDULED, schedule: 2 } },
|
|
75
|
+
incremental: {
|
|
76
|
+
"commit-graph": { type: SCHEDULED, schedule: 3 },
|
|
77
|
+
prefetch: { type: SCHEDULED, schedule: 3 },
|
|
78
|
+
"incremental-repack": { type: SCHEDULED, schedule: 2 },
|
|
79
|
+
"loose-objects": { type: SCHEDULED, schedule: 2 },
|
|
80
|
+
"pack-refs": { type: SCHEDULED, schedule: 1 },
|
|
81
|
+
gc: { type: MANUAL, schedule: 0 },
|
|
82
|
+
},
|
|
83
|
+
geometric: {
|
|
84
|
+
"commit-graph": { type: SCHEDULED | MANUAL, schedule: 3 },
|
|
85
|
+
"geometric-repack": { type: SCHEDULED | MANUAL, schedule: 2 },
|
|
86
|
+
"pack-refs": { type: SCHEDULED | MANUAL, schedule: 2 },
|
|
87
|
+
"rerere-gc": { type: SCHEDULED | MANUAL, schedule: 1 },
|
|
88
|
+
"reflog-expire": { type: SCHEDULED | MANUAL, schedule: 1 },
|
|
89
|
+
"worktree-prune": { type: SCHEDULED | MANUAL, schedule: 1 },
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** The tasks git 2.5x runs before detaching (`foreground`), and after (`background`). */
|
|
94
|
+
const FOREGROUND = new Set<MaintenanceTask>(["gc", "pack-refs", "reflog-expire"]);
|
|
95
|
+
const BACKGROUND = new Set<MaintenanceTask>([
|
|
96
|
+
"prefetch",
|
|
97
|
+
"loose-objects",
|
|
98
|
+
"incremental-repack",
|
|
99
|
+
"geometric-repack",
|
|
100
|
+
"gc",
|
|
101
|
+
"commit-graph",
|
|
102
|
+
"worktree-prune",
|
|
103
|
+
"rerere-gc",
|
|
104
|
+
]);
|
|
105
|
+
|
|
106
|
+
/** How `git maintenance run` ended. */
|
|
107
|
+
export interface MaintenanceRunResult {
|
|
108
|
+
/** git's exit status: 0, or 1 when a task failed */
|
|
109
|
+
exitCode: number;
|
|
110
|
+
/** git's stderr: warnings, the failing tasks' lines and `error: task '<t>' failed` */
|
|
111
|
+
stderr: string;
|
|
112
|
+
/**
|
|
113
|
+
* The tasks run, in order, as git's trace2 names their regions: `<task>` (2.5x adds
|
|
114
|
+
* `<task> foreground` for the part run before detaching: gc, pack-refs, reflog-expire)
|
|
115
|
+
*/
|
|
116
|
+
tasks: string[];
|
|
117
|
+
/** Whether another maintenance held `<objects>/maintenance.lock` (nothing was run) */
|
|
118
|
+
locked?: boolean;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** git's `git_config_int` over a value: k, m and g units; git dies on anything else. */
|
|
122
|
+
function configInt(store: RemoteConfigStore, key: string, fallback: number): number {
|
|
123
|
+
const value = store.value(key);
|
|
124
|
+
if (value === undefined) return fallback;
|
|
125
|
+
const m = /^\s*([-+]?(?:0x[0-9a-f]+|\d+))\s*([kmg]?)\s*$/i.exec(value);
|
|
126
|
+
if (!m) {
|
|
127
|
+
throw new PlumbingError(
|
|
128
|
+
`fatal: bad numeric config value '${value}' for '${key.toLowerCase()}': invalid unit`,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
const n = Number(m[1]);
|
|
132
|
+
const unit = (m[2] ?? "").toLowerCase();
|
|
133
|
+
return n * (unit === "k" ? 1024 : unit === "m" ? 1024 ** 2 : unit === "g" ? 1024 ** 3 : 1);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function configBool(store: RemoteConfigStore, key: string, fallback: boolean): boolean {
|
|
137
|
+
const value = store.value(key);
|
|
138
|
+
return value === undefined ? fallback : (parseGitBool(value) ?? fallback);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* `git maintenance run [--auto] [--task=<task>] [--schedule=<frequency>] [--[no-]quiet]`
|
|
143
|
+
* (builtin/gc.c `maintenance_run`) over a files repository: the tasks selected (`--task`, in
|
|
144
|
+
* the order given), else those the maintenance strategy and `maintenance.<task>.enabled` turn
|
|
145
|
+
* on (`maintenance.strategy`, default `geometric` in git 2.5x and the gc task alone in 2.43;
|
|
146
|
+
* with `--schedule` only the tasks whose `maintenance.<task>.schedule` is at least as frequent),
|
|
147
|
+
* each under `<objects>/maintenance.lock`. With `--auto` a task runs only when its condition
|
|
148
|
+
* holds (git's per-task thresholds: `maintenance.<task>.auto`, `gc.auto` for gc), and git 2.5x
|
|
149
|
+
* asks the pre-auto-gc hook once first.
|
|
150
|
+
*
|
|
151
|
+
* The tasks: prefetch (`git fetch <remote> --prefetch --prune --no-tags
|
|
152
|
+
* --no-write-fetch-head` for each remote), loose-objects (`prune-packed`, then the loose
|
|
153
|
+
* objects into a `loose-<id>.pack`), incremental-repack (`multi-pack-index write`, `expire`,
|
|
154
|
+
* `repack --batch-size`), geometric-repack (`repack --geometric` or an all-into-one repack with
|
|
155
|
+
* a midx), gc (`git gc`), commit-graph (`commit-graph write --split --reachable`), pack-refs
|
|
156
|
+
* (`pack-refs --all --prune`), reflog-expire (`reflog expire --all`), worktree-prune
|
|
157
|
+
* (`worktree prune --expire <gc.worktreePruneExpire>`) and rerere-gc (`rerere gc`); the last
|
|
158
|
+
* three and geometric-repack are git 2.5x's. git 2.43 (the hook runner's compatibility) runs
|
|
159
|
+
* selected tasks in the reverse of the order given, as its `compare_tasks_by_selection` sorts.
|
|
160
|
+
*
|
|
161
|
+
* `--detach` and `register`/`start`/`stop` (which schedule runs with the operating system)
|
|
162
|
+
* are left to the host: this command always runs in the foreground and quietly unless
|
|
163
|
+
* {@link setQuiet} says otherwise (git is quiet when stderr is no terminal).
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* // git maintenance run --task=commit-graph --task=loose-objects
|
|
168
|
+
* const { exitCode, tasks } = await git.maintenanceRun()
|
|
169
|
+
* .addTask("commit-graph").addTask("loose-objects").call();
|
|
170
|
+
*
|
|
171
|
+
* // git maintenance run --auto
|
|
172
|
+
* await git.maintenanceRun().setAuto(true).call();
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export class MaintenanceRunCommand extends GuardedTransportCommand<MaintenanceRunResult> {
|
|
176
|
+
private selected: string[] = [];
|
|
177
|
+
private auto = false;
|
|
178
|
+
private schedule?: string;
|
|
179
|
+
private quiet = true;
|
|
180
|
+
private stderrLines: string[] = [];
|
|
181
|
+
private ran: string[] = [];
|
|
182
|
+
|
|
183
|
+
/** `--task=<task>`: run this task (repeatable; a task named twice is git's usage error). */
|
|
184
|
+
addTask(task: MaintenanceTask | string): this {
|
|
185
|
+
this.checkCallable();
|
|
186
|
+
this.selected.push(task);
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** `--auto`: run each task only when its condition says the repository needs it. */
|
|
191
|
+
setAuto(auto: boolean): this {
|
|
192
|
+
this.checkCallable();
|
|
193
|
+
this.auto = auto;
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** `--schedule=<frequency>`: the tasks scheduled at least this often. */
|
|
198
|
+
setSchedule(schedule: MaintenanceSchedule | string): this {
|
|
199
|
+
this.checkCallable();
|
|
200
|
+
this.schedule = schedule;
|
|
201
|
+
return this;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** `--quiet` (default true, as git with stderr on no terminal) / `--no-quiet`. */
|
|
205
|
+
setQuiet(quiet: boolean): this {
|
|
206
|
+
this.checkCallable();
|
|
207
|
+
this.quiet = quiet;
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
private get v243(): boolean {
|
|
212
|
+
return this.hooks.compatibility === "2.43";
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
private error(line: string): void {
|
|
216
|
+
this.stderrLines.push(line);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Runs the tasks.
|
|
221
|
+
*
|
|
222
|
+
* @throws PlumbingError for git's usage errors (an unknown or repeated task: 129; `--auto`
|
|
223
|
+
* or `--task` with `--schedule`, an unknown schedule or strategy: 128)
|
|
224
|
+
*/
|
|
225
|
+
async call(): Promise<MaintenanceRunResult> {
|
|
226
|
+
this.checkCallable();
|
|
227
|
+
this.setCallable(false);
|
|
228
|
+
const known = this.v243 ? TASKS_243 : MAINTENANCE_TASKS;
|
|
229
|
+
const seen = new Set<string>();
|
|
230
|
+
for (const task of this.selected) {
|
|
231
|
+
const name = task.toLowerCase();
|
|
232
|
+
if (!known.includes(name as MaintenanceTask))
|
|
233
|
+
throw new PlumbingError(`error: '${task}' is not a valid task`, 129);
|
|
234
|
+
if (seen.has(name))
|
|
235
|
+
throw new PlumbingError(`error: task '${task}' cannot be selected multiple times`, 129);
|
|
236
|
+
seen.add(name);
|
|
237
|
+
}
|
|
238
|
+
let schedule = 0;
|
|
239
|
+
if (this.schedule !== undefined) {
|
|
240
|
+
schedule = PRIORITY[this.schedule.toLowerCase() as MaintenanceSchedule] ?? 0;
|
|
241
|
+
if (!schedule)
|
|
242
|
+
throw new PlumbingError(`fatal: unrecognized --schedule argument '${this.schedule}'`);
|
|
243
|
+
}
|
|
244
|
+
if (this.auto && schedule) {
|
|
245
|
+
throw new PlumbingError(
|
|
246
|
+
this.v243
|
|
247
|
+
? "fatal: use at most one of --auto and --schedule=<frequency>"
|
|
248
|
+
: "fatal: options '--auto' and '--schedule=' cannot be used together",
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
if (!this.v243 && seen.size > 0 && schedule)
|
|
252
|
+
throw new PlumbingError("fatal: options '--task=' and '--schedule=' cannot be used together");
|
|
253
|
+
|
|
254
|
+
const store = RemoteConfigStore.from(this.workingCopy);
|
|
255
|
+
const tasks = this.v243
|
|
256
|
+
? this.tasks243(store, [...seen] as MaintenanceTask[], schedule)
|
|
257
|
+
: this.tasks256(store, [...seen] as MaintenanceTask[], schedule);
|
|
258
|
+
|
|
259
|
+
const objects = await this.hooks.commonGitFile("objects");
|
|
260
|
+
const history = this.workingCopy.history as History | undefined;
|
|
261
|
+
if (!objects || !history?.objects || !history.packs)
|
|
262
|
+
throw new GitApiError("git maintenance needs a files repository");
|
|
263
|
+
const repo = {
|
|
264
|
+
files: objects.files,
|
|
265
|
+
objectsDir: objects.path,
|
|
266
|
+
gitDir: objects.path.replace(/\/?objects$/, "") || ".",
|
|
267
|
+
history: history as Repo["history"],
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
// maintenance_run_tasks: `<objects>/maintenance.lock`, held while the tasks run
|
|
271
|
+
const atomic = atomicFilesOver(repo.files, repo.objectsDir);
|
|
272
|
+
if (!(await atomic.createExclusive("maintenance.lock", new Uint8Array(0)))) {
|
|
273
|
+
if (!this.auto && !this.quiet) {
|
|
274
|
+
const display = await objectsDirectoryDisplay(this.hooks, this.workingCopy);
|
|
275
|
+
this.error(`warning: lock file '${display}/maintenance' exists, skipping maintenance`);
|
|
276
|
+
}
|
|
277
|
+
return { exitCode: 0, stderr: this.stderrText(), tasks: [], locked: true };
|
|
278
|
+
}
|
|
279
|
+
let result = 0;
|
|
280
|
+
try {
|
|
281
|
+
// the pre-auto-gc hook: asked once, before the first task whose condition holds (2.5x)
|
|
282
|
+
let hook: "undecided" | "run" | "skip" = "undecided";
|
|
283
|
+
const runPhase = async (foreground: boolean | undefined) => {
|
|
284
|
+
for (const task of tasks) {
|
|
285
|
+
if (foreground === true && !FOREGROUND.has(task)) continue;
|
|
286
|
+
if (foreground === false && !BACKGROUND.has(task)) continue;
|
|
287
|
+
if (this.auto) {
|
|
288
|
+
if (hook === "skip") continue;
|
|
289
|
+
if (!(await this.autoCondition(task, store, repo))) continue;
|
|
290
|
+
if (foreground !== undefined && hook === "undecided") {
|
|
291
|
+
const r = await this.hooks.run("pre-auto-gc");
|
|
292
|
+
hook = r && r.exitCode !== 0 ? "skip" : "run";
|
|
293
|
+
}
|
|
294
|
+
if (hook === "skip") continue;
|
|
295
|
+
}
|
|
296
|
+
this.ran.push(foreground ? `${task} foreground` : task);
|
|
297
|
+
if (await this.runTask(task, foreground, store, repo)) {
|
|
298
|
+
this.error(`error: task '${task}' failed`);
|
|
299
|
+
result = 1;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
if (this.v243) await runPhase(undefined);
|
|
304
|
+
else {
|
|
305
|
+
await runPhase(true);
|
|
306
|
+
await runPhase(false);
|
|
307
|
+
}
|
|
308
|
+
} finally {
|
|
309
|
+
await atomic.remove("maintenance.lock");
|
|
310
|
+
}
|
|
311
|
+
return { exitCode: result, stderr: this.stderrText(), tasks: this.ran };
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
private stderrText(): string {
|
|
315
|
+
return this.stderrLines.map((l) => `${l}\n`).join("");
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** git 2.43's task list: selected (in reverse), else the enabled ones in table order. */
|
|
319
|
+
private tasks243(
|
|
320
|
+
store: RemoteConfigStore,
|
|
321
|
+
selected: MaintenanceTask[],
|
|
322
|
+
schedule: number,
|
|
323
|
+
): MaintenanceTask[] {
|
|
324
|
+
const state = new Map<MaintenanceTask, { enabled: boolean; schedule: number }>();
|
|
325
|
+
for (const t of TASKS_243) state.set(t, { enabled: t === "gc", schedule: 0 });
|
|
326
|
+
if (schedule) {
|
|
327
|
+
// initialize_maintenance_strategy: only "incremental" means anything to 2.43
|
|
328
|
+
const strategy = store.value("maintenance.strategy");
|
|
329
|
+
if (strategy?.toLowerCase() === "incremental") {
|
|
330
|
+
for (const [t, s] of Object.entries(STRATEGIES.incremental as Strategy)) {
|
|
331
|
+
const st = state.get(t as MaintenanceTask) as { enabled: boolean; schedule: number };
|
|
332
|
+
if (t === "gc") st.schedule = 0;
|
|
333
|
+
else {
|
|
334
|
+
st.enabled = true;
|
|
335
|
+
st.schedule = s.schedule;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
for (const t of TASKS_243) {
|
|
341
|
+
const st = state.get(t) as { enabled: boolean; schedule: number };
|
|
342
|
+
const enabled = store.value(`maintenance.${t}.enabled`);
|
|
343
|
+
if (enabled !== undefined) st.enabled = parseGitBool(enabled) ?? st.enabled;
|
|
344
|
+
const sched = store.value(`maintenance.${t}.schedule`);
|
|
345
|
+
if (sched !== undefined)
|
|
346
|
+
st.schedule = PRIORITY[sched.toLowerCase() as MaintenanceSchedule] ?? 0;
|
|
347
|
+
}
|
|
348
|
+
const list =
|
|
349
|
+
selected.length > 0
|
|
350
|
+
? [...selected].reverse()
|
|
351
|
+
: TASKS_243.filter((t) => state.get(t)?.enabled);
|
|
352
|
+
return schedule ? list.filter((t) => (state.get(t)?.schedule ?? 0) >= schedule) : list;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** git 2.5x's `initialize_task_config`. */
|
|
356
|
+
private tasks256(
|
|
357
|
+
store: RemoteConfigStore,
|
|
358
|
+
selected: MaintenanceTask[],
|
|
359
|
+
schedule: number,
|
|
360
|
+
): MaintenanceTask[] {
|
|
361
|
+
if (selected.length > 0) return selected;
|
|
362
|
+
const type = schedule ? SCHEDULED : MANUAL;
|
|
363
|
+
let strategy: Strategy = schedule ? {} : (STRATEGIES.geometric as Strategy);
|
|
364
|
+
const name = store.value("maintenance.strategy");
|
|
365
|
+
if (name !== undefined) {
|
|
366
|
+
const s = STRATEGIES[name.toLowerCase()];
|
|
367
|
+
if (!s) throw new PlumbingError(`fatal: unknown maintenance strategy: '${name}'`);
|
|
368
|
+
strategy = s;
|
|
369
|
+
}
|
|
370
|
+
const out: MaintenanceTask[] = [];
|
|
371
|
+
for (const t of MAINTENANCE_TASKS) {
|
|
372
|
+
let taskType = strategy[t]?.type ?? 0;
|
|
373
|
+
let taskSchedule = strategy[t]?.schedule ?? 0;
|
|
374
|
+
const enabled = store.value(`maintenance.${t}.enabled`);
|
|
375
|
+
if (enabled !== undefined && parseGitBool(enabled) !== undefined)
|
|
376
|
+
taskType = parseGitBool(enabled) ? type : 0;
|
|
377
|
+
if (!(taskType & type)) continue;
|
|
378
|
+
if (schedule) {
|
|
379
|
+
const sched = store.value(`maintenance.${t}.schedule`);
|
|
380
|
+
if (sched !== undefined)
|
|
381
|
+
taskSchedule = PRIORITY[sched.toLowerCase() as MaintenanceSchedule] ?? 0;
|
|
382
|
+
if (taskSchedule < schedule) continue;
|
|
383
|
+
}
|
|
384
|
+
out.push(t);
|
|
385
|
+
}
|
|
386
|
+
return out;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// ---------------------------------------------------------------- auto conditions
|
|
390
|
+
|
|
391
|
+
private async autoCondition(
|
|
392
|
+
task: MaintenanceTask,
|
|
393
|
+
store: RemoteConfigStore,
|
|
394
|
+
repo: Repo,
|
|
395
|
+
): Promise<boolean> {
|
|
396
|
+
switch (task) {
|
|
397
|
+
case "prefetch":
|
|
398
|
+
return false;
|
|
399
|
+
case "loose-objects": {
|
|
400
|
+
const limit = configInt(store, "maintenance.loose-objects.auto", 100);
|
|
401
|
+
if (!limit) return false;
|
|
402
|
+
if (limit < 0) return true;
|
|
403
|
+
return (await this.looseObjectIds(repo, limit)).length >= limit;
|
|
404
|
+
}
|
|
405
|
+
case "incremental-repack": {
|
|
406
|
+
if (!configBool(store, "core.multiPackIndex", true)) return false;
|
|
407
|
+
const limit = configInt(store, "maintenance.incremental-repack.auto", 10);
|
|
408
|
+
if (!limit) return false;
|
|
409
|
+
if (limit < 0) return true;
|
|
410
|
+
const midx = await this.midxPackNames(repo);
|
|
411
|
+
let count = 0;
|
|
412
|
+
for (const p of await this.packFiles(repo)) if (!midx.has(p.name)) count++;
|
|
413
|
+
return count >= limit;
|
|
414
|
+
}
|
|
415
|
+
case "geometric-repack": {
|
|
416
|
+
const limit = configInt(store, "maintenance.geometric-repack.auto", 6700);
|
|
417
|
+
if (!limit) return false;
|
|
418
|
+
if (limit < 0) return true;
|
|
419
|
+
const factor = configInt(store, "maintenance.geometric-repack.splitFactor", 2);
|
|
420
|
+
if ((await this.geometry(repo, factor)).split > 0) return true;
|
|
421
|
+
return this.tooManyLoose(repo, limit);
|
|
422
|
+
}
|
|
423
|
+
case "gc":
|
|
424
|
+
return new GarbageCollectCommand(this.workingCopy).isAutoGcNeeded();
|
|
425
|
+
case "commit-graph":
|
|
426
|
+
return this.commitGraphNeeded(store, repo);
|
|
427
|
+
case "pack-refs": {
|
|
428
|
+
if (this.v243 || !this.refsStore.packRefs) return false;
|
|
429
|
+
return (await this.refsStore.packRefs([], { all: true, auto: true, checkOnly: true })) > 0;
|
|
430
|
+
}
|
|
431
|
+
case "reflog-expire": {
|
|
432
|
+
const limit = configInt(store, "maintenance.reflog-expire.auto", 100);
|
|
433
|
+
if (!limit) return false;
|
|
434
|
+
if (limit < 0) return true;
|
|
435
|
+
const environment = hostEnvironmentOf(this.workingCopy);
|
|
436
|
+
const r = await expireReflogs({
|
|
437
|
+
files: repo.files,
|
|
438
|
+
gitDir: repo.gitDir,
|
|
439
|
+
refs: repo.history.refs,
|
|
440
|
+
objects: repo.history.objects,
|
|
441
|
+
names: ["HEAD"],
|
|
442
|
+
dryRun: true,
|
|
443
|
+
compatibility: this.hooks.compatibility,
|
|
444
|
+
...(environment ? { environment } : {}),
|
|
445
|
+
});
|
|
446
|
+
return r.pruned >= limit;
|
|
447
|
+
}
|
|
448
|
+
case "worktree-prune": {
|
|
449
|
+
const limit = configInt(store, "maintenance.worktree-prune.auto", 1);
|
|
450
|
+
if (limit <= 0) return limit < 0;
|
|
451
|
+
const expire = store.value("gc.worktreePruneExpire") ?? "3.months.ago";
|
|
452
|
+
try {
|
|
453
|
+
parseExpiryDate(expire, Math.floor(Date.now() / 1000), "gc.worktreePruneExpire");
|
|
454
|
+
} catch {
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
if (!this.workingCopy.worktrees) return false;
|
|
458
|
+
const { pruned } = await new WorktreePruneCommand(this.workingCopy)
|
|
459
|
+
.setDryRun(true)
|
|
460
|
+
.setExpire(expire)
|
|
461
|
+
.call();
|
|
462
|
+
return pruned.filter((p) => !/duplicate/.test(p.reason)).length >= limit;
|
|
463
|
+
}
|
|
464
|
+
case "rerere-gc": {
|
|
465
|
+
const limit = configInt(store, "maintenance.rerere-gc.auto", 512);
|
|
466
|
+
if (!limit) return false;
|
|
467
|
+
if (limit < 0) return true;
|
|
468
|
+
const location = await rerereGcLocation(this.workingCopy);
|
|
469
|
+
if (!location) return false;
|
|
470
|
+
const environment = hostEnvironmentOf(this.workingCopy);
|
|
471
|
+
return rerereGcNeeded({ ...location, limit, ...(environment ? { environment } : {}) });
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/** The loose object ids, in fan-out order, at most `limit` (git's for_each_loose_file). */
|
|
477
|
+
private async looseObjectIds(repo: Repo, limit = Number.POSITIVE_INFINITY): Promise<ObjectId[]> {
|
|
478
|
+
const pattern = new RegExp(`^[0-9a-f]{${objectFormatOf(repo.history.objects).hexLength}}$`);
|
|
479
|
+
// for_each_loose_file_in_objdir: fan-out directories 00..ff, each in readdir order
|
|
480
|
+
// (which decides the objects a batch takes; sorted where the FilesApi cannot tell)
|
|
481
|
+
const posix = repo.files as FilesApi & {
|
|
482
|
+
listKinds?(path: string, o?: { readdirOrder?: boolean }): Promise<{ name: string }[]>;
|
|
483
|
+
};
|
|
484
|
+
const out: ObjectId[] = [];
|
|
485
|
+
for (let i = 0; i < 256; i++) {
|
|
486
|
+
const fan = i.toString(16).padStart(2, "0");
|
|
487
|
+
const dir = `${repo.objectsDir}/${fan}`;
|
|
488
|
+
let names: string[] = [];
|
|
489
|
+
try {
|
|
490
|
+
if (posix.listKinds) {
|
|
491
|
+
names = (await posix.listKinds(dir, { readdirOrder: true })).map((e) => e.name);
|
|
492
|
+
} else {
|
|
493
|
+
for await (const e of repo.files.list(dir)) names.push(e.name);
|
|
494
|
+
}
|
|
495
|
+
} catch {
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
for (const name of names) {
|
|
499
|
+
const key = fan + name;
|
|
500
|
+
if (!pattern.test(key)) continue;
|
|
501
|
+
out.push(key);
|
|
502
|
+
if (out.length >= limit) return out;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return out;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/** too_many_loose_objects: the `objects/17` estimate against the limit rounded up to 256. */
|
|
509
|
+
private async tooManyLoose(repo: Repo, limit: number): Promise<boolean> {
|
|
510
|
+
if (limit <= 0) return false;
|
|
511
|
+
const loose = new RegExp(`^[0-9a-f]{${objectFormatOf(repo.history.objects).hexLength - 2}}$`);
|
|
512
|
+
let n = 0;
|
|
513
|
+
try {
|
|
514
|
+
for await (const info of repo.files.list(`${repo.objectsDir}/17`))
|
|
515
|
+
if (loose.test(info.name)) n++;
|
|
516
|
+
} catch {
|
|
517
|
+
// nothing to count
|
|
518
|
+
}
|
|
519
|
+
return n * 256 > Math.ceil(limit / 256) * 256;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/** The packs of `objects/pack` (an `.idx` with its `.pack`), with size, keep and cruft. */
|
|
523
|
+
private async packFiles(repo: Repo): Promise<
|
|
524
|
+
{
|
|
525
|
+
name: string;
|
|
526
|
+
size: number;
|
|
527
|
+
mtime: number;
|
|
528
|
+
keep: boolean;
|
|
529
|
+
cruft: boolean;
|
|
530
|
+
promisor: boolean;
|
|
531
|
+
}[]
|
|
532
|
+
> {
|
|
533
|
+
const dir = `${repo.objectsDir}/pack`;
|
|
534
|
+
const names = new Set<string>();
|
|
535
|
+
try {
|
|
536
|
+
for await (const info of repo.files.list(dir)) names.add(info.name);
|
|
537
|
+
} catch {
|
|
538
|
+
return [];
|
|
539
|
+
}
|
|
540
|
+
const out = [];
|
|
541
|
+
for (const name of names) {
|
|
542
|
+
if (!name.endsWith(".idx")) continue;
|
|
543
|
+
const base = name.slice(0, -4);
|
|
544
|
+
if (!names.has(`${base}.pack`)) continue;
|
|
545
|
+
const st = await repo.files.stats(`${dir}/${base}.pack`);
|
|
546
|
+
out.push({
|
|
547
|
+
name: base,
|
|
548
|
+
size: st?.size ?? 0,
|
|
549
|
+
mtime: st?.lastModified ?? 0,
|
|
550
|
+
keep: names.has(`${base}.keep`),
|
|
551
|
+
cruft: names.has(`${base}.mtimes`),
|
|
552
|
+
promisor: names.has(`${base}.promisor`),
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
return out;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/** The base names of the packs the multi-pack-index covers (its PNAM chunk). */
|
|
559
|
+
private async midxPackNames(repo: Repo): Promise<Set<string>> {
|
|
560
|
+
const out = new Set<string>();
|
|
561
|
+
const bytes = await readFileBytes(repo.files, `${repo.objectsDir}/pack/multi-pack-index`);
|
|
562
|
+
if (bytes) for (const n of midxNames(bytes)) out.add(n.replace(/\.(idx|pack)$/, ""));
|
|
563
|
+
return out;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/** pack_geometry_init and split: the packs that are neither kept, cruft nor promisor. */
|
|
567
|
+
private async geometry(repo: Repo, factor: number): Promise<{ split: number; count: number }> {
|
|
568
|
+
await repo.history.packs?.refresh();
|
|
569
|
+
const packs = (await repo.history.packs?.packs()) ?? [];
|
|
570
|
+
const files = await this.packFiles(repo);
|
|
571
|
+
const byName = new Map(files.map((f) => [f.name, f]));
|
|
572
|
+
const counts: number[] = [];
|
|
573
|
+
for (const p of packs) {
|
|
574
|
+
const f = byName.get((p as { name?: string }).name ?? `pack-${p.packId}`);
|
|
575
|
+
if (!f || f.keep || f.cruft || f.promisor) continue;
|
|
576
|
+
counts.push(p.count);
|
|
577
|
+
}
|
|
578
|
+
counts.sort((a, b) => a - b);
|
|
579
|
+
return { split: geometricSplit(counts, factor), count: counts.length };
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/** should_write_commit_graph: commits the refs reach outside the graph, up to the limit. */
|
|
583
|
+
private async commitGraphNeeded(store: RemoteConfigStore, repo: Repo): Promise<boolean> {
|
|
584
|
+
const limit = configInt(store, "maintenance.commit-graph.auto", 100);
|
|
585
|
+
if (!limit) return false;
|
|
586
|
+
if (limit < 0) return true;
|
|
587
|
+
const graph = await repo.history.commitGraph?.get();
|
|
588
|
+
const inGraph = (id: ObjectId) => graph?.has(id) ?? false;
|
|
589
|
+
const resolver = this.revisionResolver();
|
|
590
|
+
const seen = new Set<ObjectId>();
|
|
591
|
+
let count = 0;
|
|
592
|
+
for await (const ref of repo.history.refs.list("refs/")) {
|
|
593
|
+
const resolved = await repo.history.refs.resolve(ref.name).catch(() => undefined);
|
|
594
|
+
if (!resolved?.objectId) continue;
|
|
595
|
+
const peeled = await resolver.peelTags(resolved.objectId).catch(() => undefined);
|
|
596
|
+
if (peeled?.type !== "commit") continue;
|
|
597
|
+
const tip = peeled.id;
|
|
598
|
+
// 2.43 counts a ref's own commit even when seen already (measured against git 2.43.0:
|
|
599
|
+
// a tip reached twice counts twice, and is then seen for the parent walks)
|
|
600
|
+
if (seen.has(tip) && !this.v243) continue;
|
|
601
|
+
seen.add(tip);
|
|
602
|
+
if (inGraph(tip)) continue;
|
|
603
|
+
if (++count >= limit) return true;
|
|
604
|
+
const stack: ObjectId[] = [tip];
|
|
605
|
+
while (stack.length > 0) {
|
|
606
|
+
const id = stack.pop() as ObjectId;
|
|
607
|
+
const parents = await repo.history.commits.getParents(id).catch(() => [] as ObjectId[]);
|
|
608
|
+
for (const parent of parents) {
|
|
609
|
+
if (inGraph(parent) || seen.has(parent)) continue;
|
|
610
|
+
seen.add(parent);
|
|
611
|
+
if (++count >= limit) return true;
|
|
612
|
+
stack.push(parent);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
return false;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// ---------------------------------------------------------------- tasks
|
|
620
|
+
|
|
621
|
+
/** Runs one task (its part of `foreground` in 2.5x); true when it failed. */
|
|
622
|
+
private async runTask(
|
|
623
|
+
task: MaintenanceTask,
|
|
624
|
+
foreground: boolean | undefined,
|
|
625
|
+
store: RemoteConfigStore,
|
|
626
|
+
repo: Repo,
|
|
627
|
+
): Promise<boolean> {
|
|
628
|
+
switch (task) {
|
|
629
|
+
case "prefetch":
|
|
630
|
+
return this.prefetch(store);
|
|
631
|
+
case "loose-objects":
|
|
632
|
+
return this.looseObjects(store, repo);
|
|
633
|
+
case "incremental-repack":
|
|
634
|
+
return this.incrementalRepack(store, repo);
|
|
635
|
+
case "geometric-repack":
|
|
636
|
+
return this.geometricRepack(store, repo);
|
|
637
|
+
case "gc":
|
|
638
|
+
// 2.5x's foreground part is the gc's pack-refs and reflog expiry, which the gc run
|
|
639
|
+
// in the background part does first as well (`gc --skip-foreground-tasks` after it)
|
|
640
|
+
if (foreground) return false;
|
|
641
|
+
return this.gc();
|
|
642
|
+
case "commit-graph":
|
|
643
|
+
return this.commitGraph(store, repo);
|
|
644
|
+
case "pack-refs":
|
|
645
|
+
return this.packRefs();
|
|
646
|
+
case "reflog-expire":
|
|
647
|
+
return this.reflogExpire();
|
|
648
|
+
case "worktree-prune":
|
|
649
|
+
return this.worktreePrune(store);
|
|
650
|
+
case "rerere-gc":
|
|
651
|
+
return this.rerereGc();
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/** maintenance_task_prefetch: `git fetch <remote> --prefetch ...` per remote, stopping at a failure. */
|
|
656
|
+
private async prefetch(store: RemoteConfigStore): Promise<boolean> {
|
|
657
|
+
// remote.c's skip_default_update: remote.<name>.skipDefaultUpdate / skipFetchAll, the last wins
|
|
658
|
+
const names = store.configuredNames().filter((name) => {
|
|
659
|
+
const value = store.lastValueOf([
|
|
660
|
+
`remote.${name}.skipDefaultUpdate`,
|
|
661
|
+
`remote.${name}.skipFetchAll`,
|
|
662
|
+
]);
|
|
663
|
+
return !(value !== undefined && parseGitBool(value) === true);
|
|
664
|
+
});
|
|
665
|
+
this.resolveAuth(
|
|
666
|
+
names.map((n) => store.remoteUrlOf(n)),
|
|
667
|
+
store.urlFor(store.remoteForBranch(undefined)),
|
|
668
|
+
);
|
|
669
|
+
for (const name of names) {
|
|
670
|
+
const fetch = this.configureChild(new FetchCommand(this._workingCopy));
|
|
671
|
+
fetch
|
|
672
|
+
.setRemote(name)
|
|
673
|
+
.setPrefetch(true)
|
|
674
|
+
.setRemoveDeletedRefs(true)
|
|
675
|
+
.setTagOpt(TagOption.NO_TAGS)
|
|
676
|
+
.setWriteFetchHead(false)
|
|
677
|
+
.setRecurseSubmodules(false)
|
|
678
|
+
.setWriteCommitGraph(false)
|
|
679
|
+
.setReflogAction(
|
|
680
|
+
`fetch ${name} --prefetch --prune --no-tags --no-write-fetch-head --recurse-submodules=no${this.quiet ? " --quiet" : ""}`,
|
|
681
|
+
);
|
|
682
|
+
if (this.quiet) fetch.setQuiet(true);
|
|
683
|
+
try {
|
|
684
|
+
const r = await fetch.call();
|
|
685
|
+
if ((r.errors?.length ?? 0) > 0) {
|
|
686
|
+
for (const line of r.errors ?? []) this.error(line);
|
|
687
|
+
this.error("error: failed to prefetch remotes");
|
|
688
|
+
return true;
|
|
689
|
+
}
|
|
690
|
+
} catch (e) {
|
|
691
|
+
if (!(e instanceof Error)) throw e;
|
|
692
|
+
for (const line of e.message.split("\n")) if (line) this.error(line);
|
|
693
|
+
this.error("error: failed to prefetch remotes");
|
|
694
|
+
return true;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
return false;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/** maintenance_task_loose_objects: prune-packed, then pack_loose. */
|
|
701
|
+
private async looseObjects(store: RemoteConfigStore, repo: Repo): Promise<boolean> {
|
|
702
|
+
const { history } = repo;
|
|
703
|
+
const packs = history.packs as NonNullable<History["packs"]>;
|
|
704
|
+
const storage = new FileRawStorage(repo.files, repo.objectsDir);
|
|
705
|
+
const format = objectFormatOf(history.objects);
|
|
706
|
+
const alternates = (await history.objects.alternates?.list()) ?? [];
|
|
707
|
+
await packs.refresh();
|
|
708
|
+
await prunePacked(storage, packs, format, alternates);
|
|
709
|
+
// pack_loose: at most maintenance.loose-objects.batchSize (2.5x; 0 unlimited) objects
|
|
710
|
+
let batch = 50000;
|
|
711
|
+
if (!this.v243) {
|
|
712
|
+
batch = configInt(store, "maintenance.loose-objects.batchSize", 50000);
|
|
713
|
+
if (batch === 0) batch = Number.POSITIVE_INFINITY;
|
|
714
|
+
}
|
|
715
|
+
const ids = await this.looseObjectIds(repo, batch);
|
|
716
|
+
if (ids.length === 0) return false;
|
|
717
|
+
const environment = hostEnvironmentOf(this.workingCopy);
|
|
718
|
+
const settings = await readPackWriteSettings(repo.files, repo.gitDir, {
|
|
719
|
+
...(environment ? { environment } : {}),
|
|
720
|
+
});
|
|
721
|
+
await packs.install(
|
|
722
|
+
writePack(history.objects, ids, {
|
|
723
|
+
packs,
|
|
724
|
+
reuseObjects: true,
|
|
725
|
+
reuseDeltas: true,
|
|
726
|
+
deltaSearch: packDeltaSearch(settings, undefined),
|
|
727
|
+
...(settings.compression !== undefined ? { compression: settings.compression } : {}),
|
|
728
|
+
}),
|
|
729
|
+
{ writeReverseIndex: settings.writeReverseIndex, namePrefix: "loose" },
|
|
730
|
+
);
|
|
731
|
+
await packs.refresh();
|
|
732
|
+
return false;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/** maintenance_task_incremental_repack: midx write, expire, then repack in a batch. */
|
|
736
|
+
private async incrementalRepack(store: RemoteConfigStore, repo: Repo): Promise<boolean> {
|
|
737
|
+
if (!configBool(store, "core.multiPackIndex", true)) {
|
|
738
|
+
this.error(
|
|
739
|
+
"warning: skipping incremental-repack task because core.multiPackIndex is disabled",
|
|
740
|
+
);
|
|
741
|
+
return false;
|
|
742
|
+
}
|
|
743
|
+
const environment = hostEnvironmentOf(this.workingCopy);
|
|
744
|
+
const common = {
|
|
745
|
+
files: repo.files,
|
|
746
|
+
gitDir: repo.gitDir,
|
|
747
|
+
compatibility: this.hooks.compatibility,
|
|
748
|
+
...(environment ? { environment } : {}),
|
|
749
|
+
};
|
|
750
|
+
const step = async (
|
|
751
|
+
run: () => Promise<{ exitCode: number; stderr: string[] }>,
|
|
752
|
+
failure: string,
|
|
753
|
+
) => {
|
|
754
|
+
const r = await run();
|
|
755
|
+
for (const line of r.stderr) this.error(line);
|
|
756
|
+
if (r.exitCode !== 0) {
|
|
757
|
+
this.error(`error: ${failure}`);
|
|
758
|
+
return true;
|
|
759
|
+
}
|
|
760
|
+
return false;
|
|
761
|
+
};
|
|
762
|
+
const refresh = async () => {
|
|
763
|
+
await repo.history.packs?.refresh();
|
|
764
|
+
};
|
|
765
|
+
if (await step(() => multiPackIndexWrite(common), "failed to write multi-pack-index"))
|
|
766
|
+
return true;
|
|
767
|
+
await refresh();
|
|
768
|
+
if (await step(() => multiPackIndexExpire(common), "'git multi-pack-index expire' failed"))
|
|
769
|
+
return true;
|
|
770
|
+
await refresh();
|
|
771
|
+
// get_auto_pack_size: one more than the second largest pack, at most 2 GiB
|
|
772
|
+
let max = 0;
|
|
773
|
+
let second = 0;
|
|
774
|
+
for (const p of await this.packFiles(repo)) {
|
|
775
|
+
if (p.size > max) {
|
|
776
|
+
second = max;
|
|
777
|
+
max = p.size;
|
|
778
|
+
} else if (p.size > second) second = p.size;
|
|
779
|
+
}
|
|
780
|
+
const batchSize = Math.min(second + 1, 2 ** 31 - 1);
|
|
781
|
+
if (
|
|
782
|
+
await step(
|
|
783
|
+
() => multiPackIndexRepack({ ...common, batchSize }),
|
|
784
|
+
"'git multi-pack-index repack' failed",
|
|
785
|
+
)
|
|
786
|
+
)
|
|
787
|
+
return true;
|
|
788
|
+
await refresh();
|
|
789
|
+
return false;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/** maintenance_task_geometric_repack (odb_source_files_optimize, ODB_OPTIMIZE_GEOMETRIC). */
|
|
793
|
+
private async geometricRepack(store: RemoteConfigStore, repo: Repo): Promise<boolean> {
|
|
794
|
+
// odb_source_files_optimize: nothing in a precious-objects repository
|
|
795
|
+
if ((await readRepositoryFormat(repo.files, repo.gitDir)).preciousObjects) return false;
|
|
796
|
+
const factor = configInt(store, "maintenance.geometric-repack.splitFactor", 2);
|
|
797
|
+
const { split, count } = await this.geometry(repo, factor);
|
|
798
|
+
const repack = new RepackCommand(this.workingCopy).shareHooksOf(this);
|
|
799
|
+
repack.setDeleteRedundant(true).setLocal(true).setQuiet(this.quiet);
|
|
800
|
+
if (split < count) repack.setGeometric(factor);
|
|
801
|
+
else this.repackAllOption(store, repack);
|
|
802
|
+
if (configBool(store, "core.multiPackIndex", true)) repack.setWriteMidx(true);
|
|
803
|
+
try {
|
|
804
|
+
await repack.call();
|
|
805
|
+
} catch (e) {
|
|
806
|
+
if (!(e instanceof Error)) throw e;
|
|
807
|
+
for (const line of e.message.split("\n")) if (line) this.error(line);
|
|
808
|
+
this.error("error: failed to run repack");
|
|
809
|
+
return true;
|
|
810
|
+
}
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/** add_repack_all_option: `-a` for `gc.pruneExpire=now`, else `--cruft` or `-A`. */
|
|
815
|
+
private repackAllOption(store: RemoteConfigStore, repack: RepackCommand): void {
|
|
816
|
+
const prune = store.value("gc.pruneExpire") ?? "2.weeks.ago";
|
|
817
|
+
const cruft = configBool(store, "gc.cruftPacks", true);
|
|
818
|
+
if (prune === "now") repack.setAll(true);
|
|
819
|
+
else if (cruft) {
|
|
820
|
+
repack.setCruft(true).setCruftExpiration(prune);
|
|
821
|
+
const max = store.value("gc.maxCruftSize");
|
|
822
|
+
if (max !== undefined) repack.setMaxCruftSize(configInt(store, "gc.maxCruftSize", 0));
|
|
823
|
+
} else repack.setLoosenUnreachable(true).setUnpackUnreachable(prune);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/** maintenance_task_gc: `git gc [--auto] --quiet`. */
|
|
827
|
+
private async gc(): Promise<boolean> {
|
|
828
|
+
const gc = new GarbageCollectCommand(this.workingCopy).shareHooksOf(this);
|
|
829
|
+
gc.setAuto(this.auto).setQuiet(this.quiet);
|
|
830
|
+
try {
|
|
831
|
+
const r = await gc.call();
|
|
832
|
+
for (const line of r.errors ?? []) this.error(line);
|
|
833
|
+
for (const line of r.warnings ?? []) this.error(`warning: ${line.replace(/^warning: /, "")}`);
|
|
834
|
+
} catch (e) {
|
|
835
|
+
if (!(e instanceof Error)) throw e;
|
|
836
|
+
for (const line of e.message.split("\n")) if (line) this.error(line);
|
|
837
|
+
return true;
|
|
838
|
+
}
|
|
839
|
+
return false;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/** maintenance_task_commit_graph: `commit-graph write --split --reachable`. */
|
|
843
|
+
private async commitGraph(store: RemoteConfigStore, repo: Repo): Promise<boolean> {
|
|
844
|
+
if (!configBool(store, "core.commitGraph", true)) return false;
|
|
845
|
+
const environment = hostEnvironmentOf(this.workingCopy);
|
|
846
|
+
try {
|
|
847
|
+
await writeCommitGraph({
|
|
848
|
+
files: repo.files,
|
|
849
|
+
gitDir: repo.gitDir,
|
|
850
|
+
objects: repo.history.objects,
|
|
851
|
+
refs: repo.history.refs,
|
|
852
|
+
commitGraph: repo.history.commitGraph,
|
|
853
|
+
split: true,
|
|
854
|
+
...(environment ? { environment } : {}),
|
|
855
|
+
});
|
|
856
|
+
repo.history.commitGraph?.invalidate();
|
|
857
|
+
} catch (e) {
|
|
858
|
+
if (!(e instanceof Error)) throw e;
|
|
859
|
+
this.error(`error: ${e.message}`);
|
|
860
|
+
this.error("error: failed to write commit-graph");
|
|
861
|
+
return true;
|
|
862
|
+
}
|
|
863
|
+
return false;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/** maintenance_task_pack_refs: `pack-refs --all --prune [--auto]`. */
|
|
867
|
+
private async packRefs(): Promise<boolean> {
|
|
868
|
+
if (!this.refsStore.packRefs) return false;
|
|
869
|
+
await this.refsStore.packRefs([], {
|
|
870
|
+
all: true,
|
|
871
|
+
deleteLoose: true,
|
|
872
|
+
...(this.auto ? { auto: true } : {}),
|
|
873
|
+
onError: (line) => this.error(line),
|
|
874
|
+
});
|
|
875
|
+
return false;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/** maintenance_task_reflog_expire: `reflog expire --all`. */
|
|
879
|
+
private async reflogExpire(): Promise<boolean> {
|
|
880
|
+
const r = await new ReflogCommand(this.workingCopy).setAll(true).callExpire();
|
|
881
|
+
for (const line of r.errors ?? []) this.error(line);
|
|
882
|
+
return r.status !== 0;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/** maintenance_task_worktree_prune: `worktree prune --expire <gc.worktreePruneExpire>`. */
|
|
886
|
+
private async worktreePrune(store: RemoteConfigStore): Promise<boolean> {
|
|
887
|
+
if (!this.workingCopy.worktrees) return false;
|
|
888
|
+
const expire = store.value("gc.worktreePruneExpire") ?? "3.months.ago";
|
|
889
|
+
await new WorktreePruneCommand(this.workingCopy).setExpire(expire).call();
|
|
890
|
+
return false;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/** maintenance_task_rerere_gc: `rerere gc`. */
|
|
894
|
+
private async rerereGc(): Promise<boolean> {
|
|
895
|
+
const location = await rerereGcLocation(this.workingCopy);
|
|
896
|
+
if (!location) return false;
|
|
897
|
+
const environment = hostEnvironmentOf(this.workingCopy);
|
|
898
|
+
await rerereGc({ ...location, ...(environment ? { environment } : {}) });
|
|
899
|
+
return false;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
interface Repo {
|
|
904
|
+
files: FilesApi;
|
|
905
|
+
objectsDir: string;
|
|
906
|
+
gitDir: string;
|
|
907
|
+
history: History & {
|
|
908
|
+
objects: NonNullable<History["objects"]>;
|
|
909
|
+
packs: NonNullable<History["packs"]>;
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
async function readFileBytes(files: FilesApi, path: string): Promise<Uint8Array | undefined> {
|
|
914
|
+
if ((await files.stats(path))?.kind !== "file") return undefined;
|
|
915
|
+
const parts: Uint8Array[] = [];
|
|
916
|
+
let n = 0;
|
|
917
|
+
for await (const c of files.read(path)) {
|
|
918
|
+
parts.push(c);
|
|
919
|
+
n += c.length;
|
|
920
|
+
}
|
|
921
|
+
const out = new Uint8Array(n);
|
|
922
|
+
let at = 0;
|
|
923
|
+
for (const p of parts) {
|
|
924
|
+
out.set(p, at);
|
|
925
|
+
at += p.length;
|
|
926
|
+
}
|
|
927
|
+
return out;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
/** The pack names of a multi-pack-index's PNAM chunk. */
|
|
931
|
+
function midxNames(bytes: Uint8Array): string[] {
|
|
932
|
+
if (bytes.length < 12) return [];
|
|
933
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
934
|
+
const chunks = bytes[6] as number;
|
|
935
|
+
for (let i = 0; i < chunks; i++) {
|
|
936
|
+
const at = 12 + i * 12;
|
|
937
|
+
if (at + 24 > bytes.length) return [];
|
|
938
|
+
const id = String.fromCharCode(...bytes.subarray(at, at + 4));
|
|
939
|
+
if (id !== "PNAM") continue;
|
|
940
|
+
const start = Number(view.getBigUint64(at + 4));
|
|
941
|
+
const end = Number(view.getBigUint64(at + 16));
|
|
942
|
+
if (start > end || end > bytes.length) return [];
|
|
943
|
+
return new TextDecoder()
|
|
944
|
+
.decode(bytes.subarray(start, end))
|
|
945
|
+
.split("\0")
|
|
946
|
+
.filter((n) => n.length > 0);
|
|
947
|
+
}
|
|
948
|
+
return [];
|
|
949
|
+
}
|