@ref0/git 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE +202 -0
- package/dist/access/private-refs.d.mts +27 -0
- package/dist/access/private-refs.mjs +173 -0
- package/dist/access.d.mts +2 -0
- package/dist/access.mjs +1 -0
- package/dist/auth/access-jwt.d.mts +21 -0
- package/dist/auth/access-jwt.mjs +102 -0
- package/dist/auth/acting.mjs +15 -0
- package/dist/auth/authorize.d.mts +5 -0
- package/dist/auth/authorize.mjs +292 -0
- package/dist/auth/credentials.mjs +57 -0
- package/dist/auth/fences.d.mts +5 -0
- package/dist/auth/fences.mjs +65 -0
- package/dist/auth/grants.mjs +61 -0
- package/dist/auth/helpers.d.mts +17 -0
- package/dist/auth/helpers.mjs +25 -0
- package/dist/auth/host-function.d.mts +4 -0
- package/dist/auth/host-function.mjs +69 -0
- package/dist/auth/identify.d.mts +6 -0
- package/dist/auth/identify.mjs +97 -0
- package/dist/auth/token-rows.mjs +100 -0
- package/dist/auth/token-text.mjs +66 -0
- package/dist/auth/tokens.d.mts +10 -0
- package/dist/auth/tokens.mjs +347 -0
- package/dist/auth.d.mts +7 -0
- package/dist/auth.mjs +6 -0
- package/dist/client/answer.mjs +141 -0
- package/dist/client/client.d.mts +23 -0
- package/dist/client/client.mjs +51 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +160 -0
- package/dist/client/negotiate.mjs +170 -0
- package/dist/client/push-upload.mjs +53 -0
- package/dist/client/remote-helper.mjs +129 -0
- package/dist/client/remote.mjs +398 -0
- package/dist/client/run-remote-helper.d.mts +35 -0
- package/dist/client/run-remote-helper.mjs +259 -0
- package/dist/client/scrub.d.mts +18 -0
- package/dist/client/scrub.mjs +38 -0
- package/dist/client/transport.d.mts +2 -0
- package/dist/client/transport.mjs +211 -0
- package/dist/contracts/access.d.mts +87 -0
- package/dist/contracts/actors.d.mts +144 -0
- package/dist/contracts/blobs.d.mts +38 -0
- package/dist/contracts/calls-spent.d.mts +11 -0
- package/dist/contracts/calls-spent.mjs +150 -0
- package/dist/contracts/client.d.mts +90 -0
- package/dist/contracts/commits.d.mts +126 -0
- package/dist/contracts/engine.d.mts +134 -0
- package/dist/contracts/events.d.mts +276 -0
- package/dist/contracts/files.d.mts +75 -0
- package/dist/contracts/forks.d.mts +78 -0
- package/dist/contracts/grants.d.mts +60 -0
- package/dist/contracts/handlers.d.mts +10 -0
- package/dist/contracts/ids.d.mts +15 -0
- package/dist/contracts/ids.mjs +15 -0
- package/dist/contracts/lfs.d.mts +27 -0
- package/dist/contracts/merges.d.mts +33 -0
- package/dist/contracts/objects.d.mts +645 -0
- package/dist/contracts/objects.mjs +54 -0
- package/dist/contracts/operations.d.mts +133 -0
- package/dist/contracts/promises.d.mts +63 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +401 -0
- package/dist/contracts/refs.d.mts +95 -0
- package/dist/contracts/remote.d.mts +50 -0
- package/dist/contracts/repos.d.mts +153 -0
- package/dist/contracts/result.d.mts +126 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +245 -0
- package/dist/contracts/services.d.mts +36 -0
- package/dist/contracts/services.mjs +13 -0
- package/dist/contracts/signin.d.mts +126 -0
- package/dist/contracts/store.d.mts +41 -0
- package/dist/contracts/sync.d.mts +210 -0
- package/dist/contracts/sync.mjs +8 -0
- package/dist/contracts/tags.d.mts +50 -0
- package/dist/contracts/tags.mjs +6 -0
- package/dist/contracts/tokens.d.mts +87 -0
- package/dist/contracts/tokens.mjs +15 -0
- package/dist/contracts/topics.d.mts +174 -0
- package/dist/contracts/trees.d.mts +84 -0
- package/dist/contracts/work.d.mts +31 -0
- package/dist/core/access.d.mts +22 -0
- package/dist/core/access.mjs +262 -0
- package/dist/core/ancestry.mjs +235 -0
- package/dist/core/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +468 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +290 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +204 -0
- package/dist/core/hooks/pre-receive.d.mts +5 -0
- package/dist/core/hooks/pre-receive.mjs +34 -0
- package/dist/core/index-job.mjs +198 -0
- package/dist/core/names.mjs +30 -0
- package/dist/core/objects/blobs.mjs +60 -0
- package/dist/core/objects/commit-writes.mjs +185 -0
- package/dist/core/objects/commits.mjs +172 -0
- package/dist/core/objects/files.mjs +211 -0
- package/dist/core/objects/lines.mjs +42 -0
- package/dist/core/objects/merges.mjs +83 -0
- package/dist/core/objects/peel.mjs +166 -0
- package/dist/core/objects/reading.mjs +284 -0
- package/dist/core/objects/tags.mjs +96 -0
- package/dist/core/objects/tree-edits.mjs +266 -0
- package/dist/core/objects/trees.mjs +229 -0
- package/dist/core/objects/writing.mjs +266 -0
- package/dist/core/own-writes.mjs +94 -0
- package/dist/core/promise.mjs +46 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1069 -0
- package/dist/core/receipts.d.mts +7 -0
- package/dist/core/receipts.mjs +234 -0
- package/dist/core/ref-conflicts.mjs +27 -0
- package/dist/core/refs.mjs +359 -0
- package/dist/core/repack.mjs +521 -0
- package/dist/core/repos.mjs +752 -0
- package/dist/core/rules/changes.mjs +57 -0
- package/dist/core/rules/check.mjs +101 -0
- package/dist/core/rules/commit-changes.mjs +216 -0
- package/dist/core/rules/context.d.mts +9 -0
- package/dist/core/rules/context.mjs +120 -0
- package/dist/core/rules/define.d.mts +5 -0
- package/dist/core/rules/define.mjs +13 -0
- package/dist/core/rules/facts.mjs +13 -0
- package/dist/core/rules/fetch.d.mts +5 -0
- package/dist/core/rules/fetch.mjs +59 -0
- package/dist/core/rules/file-globs.mjs +55 -0
- package/dist/core/rules/files.mjs +142 -0
- package/dist/core/rules/patterns.mjs +23 -0
- package/dist/core/rules/protect.d.mts +9 -0
- package/dist/core/rules/protect.mjs +116 -0
- package/dist/core/seam.d.mts +24 -0
- package/dist/core/seam.mjs +41 -0
- package/dist/core/sight.mjs +99 -0
- package/dist/core/tokens.mjs +95 -0
- package/dist/core/view.d.mts +9 -0
- package/dist/core/view.mjs +221 -0
- package/dist/core/work.mjs +92 -0
- package/dist/effect.d.mts +20 -0
- package/dist/effect.mjs +18 -0
- package/dist/engine/allotted-xdiff.d.mts +4 -0
- package/dist/engine/allotted-xdiff.mjs +80 -0
- package/dist/engine/attribute-patterns.mjs +163 -0
- package/dist/engine/attributes.mjs +226 -0
- package/dist/engine/combined.mjs +653 -0
- package/dist/engine/commits.mjs +90 -0
- package/dist/engine/content.d.mts +4 -0
- package/dist/engine/content.mjs +221 -0
- package/dist/engine/diff.mjs +49 -0
- package/dist/engine/engine.d.mts +25 -0
- package/dist/engine/engine.mjs +49 -0
- package/dist/engine/failures.d.mts +4 -0
- package/dist/engine/failures.mjs +23 -0
- package/dist/engine/line-count.mjs +23 -0
- package/dist/engine/merge-base-walk.d.mts +2 -0
- package/dist/engine/merge-base-walk.mjs +265 -0
- package/dist/engine/merge-bases.mjs +27 -0
- package/dist/engine/merge-renames.mjs +165 -0
- package/dist/engine/merge.mjs +1125 -0
- package/dist/engine/parts.d.mts +8 -0
- package/dist/engine/parts.mjs +9 -0
- package/dist/engine/reads.d.mts +5 -0
- package/dist/engine/reads.mjs +105 -0
- package/dist/engine/walk.mjs +328 -0
- package/dist/engine/xdiff/NOTICE.md +63 -0
- package/dist/engine/xdiff/compiled.d.mts +7 -0
- package/dist/engine/xdiff/compiled.mjs +9 -0
- package/dist/engine/xdiff/embedded.mjs +4 -0
- package/dist/engine/xdiff/node.d.mts +7 -0
- package/dist/engine/xdiff/node.mjs +10 -0
- package/dist/engine/xdiff/upstream/LGPL-2.1 +511 -0
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine/xdiff.d.mts +34 -0
- package/dist/engine/xdiff.mjs +380 -0
- package/dist/engine.d.mts +3 -0
- package/dist/engine.mjs +3 -0
- package/dist/extend.d.mts +3 -0
- package/dist/extend.mjs +1 -0
- package/dist/http/answers.mjs +74 -0
- package/dist/http/bodies.mjs +143 -0
- package/dist/http/core-parts.mjs +252 -0
- package/dist/http/fetch-depth.mjs +26 -0
- package/dist/http/handler.mjs +94 -0
- package/dist/http/node.d.mts +70 -0
- package/dist/http/node.mjs +178 -0
- package/dist/http/paths.d.mts +9 -0
- package/dist/http/paths.mjs +118 -0
- package/dist/http/push-uploads.mjs +286 -0
- package/dist/http/receive-pack.mjs +235 -0
- package/dist/http/upload-pack.mjs +229 -0
- package/dist/index.d.mts +46 -0
- package/dist/index.mjs +16 -0
- package/dist/lfs/calls.mjs +16 -0
- package/dist/lfs/locks.mjs +161 -0
- package/dist/lfs/objects.mjs +370 -0
- package/dist/lfs/pointers.mjs +141 -0
- package/dist/lfs/repo.mjs +42 -0
- package/dist/lfs/rows.mjs +108 -0
- package/dist/lfs/service.mjs +34 -0
- package/dist/lfs/upkeep.mjs +162 -0
- package/dist/lfs/wire.mjs +102 -0
- package/dist/node.d.mts +3 -0
- package/dist/node.mjs +3 -0
- package/dist/protocol/bytes/buffers.d.mts +38 -0
- package/dist/protocol/bytes/buffers.mjs +62 -0
- package/dist/protocol/bytes/crc32.d.mts +4 -0
- package/dist/protocol/bytes/crc32.mjs +14 -0
- package/dist/protocol/bytes/deflate.d.mts +78 -0
- package/dist/protocol/bytes/deflate.mjs +175 -0
- package/dist/protocol/bytes/errors.d.mts +20 -0
- package/dist/protocol/bytes/errors.mjs +19 -0
- package/dist/protocol/bytes/hex.mjs +16 -0
- package/dist/protocol/bytes/hmac-sha256.mjs +91 -0
- package/dist/protocol/bytes/inflate.d.mts +40 -0
- package/dist/protocol/bytes/inflate.mjs +109 -0
- package/dist/protocol/bytes/joined.d.mts +2 -0
- package/dist/protocol/bytes/joined.mjs +25 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +20 -0
- package/dist/protocol/bytes/sha1-hasher.mjs +72 -0
- package/dist/protocol/bytes/sha1.d.mts +35 -0
- package/dist/protocol/bytes/sha1.mjs +409 -0
- package/dist/protocol/bytes/sha256.mjs +156 -0
- package/dist/protocol/bytes/streams.mjs +11 -0
- package/dist/protocol/bytes/text.mjs +19 -0
- package/dist/protocol/diff/diff-raw.d.mts +29 -0
- package/dist/protocol/diff/diff-raw.mjs +73 -0
- package/dist/protocol/diff/patch.mjs +92 -0
- package/dist/protocol/diff/paths.mjs +67 -0
- package/dist/protocol/diff/read.d.mts +62 -0
- package/dist/protocol/diff/read.mjs +342 -0
- package/dist/protocol/diff/rename-similarity.mjs +428 -0
- package/dist/protocol/diff/text.mjs +12 -0
- package/dist/protocol/diff/tree-diff.d.mts +41 -0
- package/dist/protocol/diff/tree-diff.mjs +607 -0
- package/dist/protocol/framing/band.d.mts +10 -0
- package/dist/protocol/framing/band.mjs +16 -0
- package/dist/protocol/framing/pkt-line.d.mts +48 -0
- package/dist/protocol/framing/pkt-line.mjs +92 -0
- package/dist/protocol/objects/checked-blobs.mjs +127 -0
- package/dist/protocol/objects/commit.d.mts +25 -0
- package/dist/protocol/objects/commit.mjs +138 -0
- package/dist/protocol/objects/fsck-gitmodules.mjs +296 -0
- package/dist/protocol/objects/fsck-names.mjs +189 -0
- package/dist/protocol/objects/fsck.mjs +297 -0
- package/dist/protocol/objects/headers.mjs +109 -0
- package/dist/protocol/objects/held.mjs +56 -0
- package/dist/protocol/objects/iconv.mjs +145 -0
- package/dist/protocol/objects/ident.mjs +111 -0
- package/dist/protocol/objects/lfs-pointer.d.mts +8 -0
- package/dist/protocol/objects/lfs-pointer.mjs +63 -0
- package/dist/protocol/objects/links-raw.mjs +89 -0
- package/dist/protocol/objects/object-rules.mjs +75 -0
- package/dist/protocol/objects/object.d.mts +16 -0
- package/dist/protocol/objects/object.mjs +29 -0
- package/dist/protocol/objects/tag.d.mts +21 -0
- package/dist/protocol/objects/tag.mjs +96 -0
- package/dist/protocol/objects/tree.d.mts +43 -0
- package/dist/protocol/objects/tree.mjs +162 -0
- package/dist/protocol/objects/utf8-verify.mjs +71 -0
- package/dist/protocol/packs/delta.d.mts +57 -0
- package/dist/protocol/packs/delta.mjs +229 -0
- package/dist/protocol/packs/graph.mjs +78 -0
- package/dist/protocol/packs/idx.d.mts +54 -0
- package/dist/protocol/packs/idx.mjs +274 -0
- package/dist/protocol/packs/indexer.d.mts +167 -0
- package/dist/protocol/packs/indexer.mjs +507 -0
- package/dist/protocol/packs/parts.d.mts +40 -0
- package/dist/protocol/packs/parts.mjs +89 -0
- package/dist/protocol/packs/pos.mjs +51 -0
- package/dist/protocol/packs/reader.d.mts +180 -0
- package/dist/protocol/packs/reader.mjs +414 -0
- package/dist/protocol/packs/rev.d.mts +32 -0
- package/dist/protocol/packs/rev.mjs +99 -0
- package/dist/protocol/packs/step.d.mts +10 -0
- package/dist/protocol/packs/step.mjs +12 -0
- package/dist/protocol/packs/write-error.d.mts +12 -0
- package/dist/protocol/packs/write-error.mjs +27 -0
- package/dist/protocol/packs/writer.d.mts +157 -0
- package/dist/protocol/packs/writer.mjs +353 -0
- package/dist/protocol/wire/advertisement.d.mts +72 -0
- package/dist/protocol/wire/advertisement.mjs +161 -0
- package/dist/protocol/wire/fetch.d.mts +155 -0
- package/dist/protocol/wire/fetch.mjs +458 -0
- package/dist/protocol/wire/lines.mjs +107 -0
- package/dist/protocol/wire/push-uploads.mjs +43 -0
- package/dist/protocol/wire/receive-pack.d.mts +71 -0
- package/dist/protocol/wire/receive-pack.mjs +157 -0
- package/dist/protocol/wire/report-status.d.mts +47 -0
- package/dist/protocol/wire/report-status.mjs +119 -0
- package/dist/protocol/wire/v2.d.mts +90 -0
- package/dist/protocol/wire/v2.mjs +185 -0
- package/dist/protocol.d.mts +31 -0
- package/dist/protocol.mjs +31 -0
- package/dist/queue/advance.mjs +1036 -0
- package/dist/queue/callers.mjs +134 -0
- package/dist/queue/calls.mjs +1154 -0
- package/dist/queue/commit.mjs +85 -0
- package/dist/queue/host.d.mts +15 -0
- package/dist/queue/host.mjs +88 -0
- package/dist/queue/ids.d.mts +5 -0
- package/dist/queue/ids.mjs +21 -0
- package/dist/queue/lanes.mjs +86 -0
- package/dist/queue/limits.mjs +99 -0
- package/dist/queue/pages.mjs +76 -0
- package/dist/queue/push-option.mjs +62 -0
- package/dist/queue/rows.mjs +206 -0
- package/dist/queue/schedule.mjs +132 -0
- package/dist/queue/search.mjs +315 -0
- package/dist/queue/state.mjs +325 -0
- package/dist/queue/steps.mjs +317 -0
- package/dist/remote-helper.d.mts +3 -0
- package/dist/remote-helper.mjs +3 -0
- package/dist/rest/api.d.mts +23 -0
- package/dist/rest/api.mjs +27 -0
- package/dist/rest/blobs.d.mts +58 -0
- package/dist/rest/blobs.mjs +41 -0
- package/dist/rest/caller.d.mts +102 -0
- package/dist/rest/caller.mjs +18 -0
- package/dist/rest/client.d.mts +18 -0
- package/dist/rest/client.mjs +587 -0
- package/dist/rest/commits.d.mts +435 -0
- package/dist/rest/commits.mjs +140 -0
- package/dist/rest/errors.d.mts +44 -0
- package/dist/rest/errors.mjs +186 -0
- package/dist/rest/events.d.mts +38 -0
- package/dist/rest/events.mjs +74 -0
- package/dist/rest/files.d.mts +179 -0
- package/dist/rest/files.mjs +92 -0
- package/dist/rest/forks.d.mts +205 -0
- package/dist/rest/forks.mjs +51 -0
- package/dist/rest/handler.d.mts +17 -0
- package/dist/rest/handler.mjs +106 -0
- package/dist/rest/handlers.d.mts +8 -0
- package/dist/rest/handlers.mjs +592 -0
- package/dist/rest/listen.d.mts +24 -0
- package/dist/rest/listen.mjs +142 -0
- package/dist/rest/me.d.mts +55 -0
- package/dist/rest/me.mjs +21 -0
- package/dist/rest/merges.d.mts +90 -0
- package/dist/rest/merges.mjs +39 -0
- package/dist/rest/paths.mjs +86 -0
- package/dist/rest/queue.d.mts +486 -0
- package/dist/rest/queue.mjs +228 -0
- package/dist/rest/refs.d.mts +232 -0
- package/dist/rest/refs.mjs +86 -0
- package/dist/rest/repos.d.mts +223 -0
- package/dist/rest/repos.mjs +93 -0
- package/dist/rest/tags.d.mts +153 -0
- package/dist/rest/tags.mjs +72 -0
- package/dist/rest/tokens.d.mts +297 -0
- package/dist/rest/tokens.mjs +88 -0
- package/dist/rest/topics.d.mts +257 -0
- package/dist/rest/topics.mjs +116 -0
- package/dist/rest/trees.d.mts +158 -0
- package/dist/rest/trees.mjs +118 -0
- package/dist/rest/wire.mjs +57 -0
- package/dist/rest/work.d.mts +107 -0
- package/dist/rest/work.mjs +77 -0
- package/dist/rest.d.mts +8 -0
- package/dist/rest.mjs +5 -0
- package/dist/server/extension.d.mts +14 -0
- package/dist/server/extension.mjs +85 -0
- package/dist/server/routes.d.mts +25 -0
- package/dist/server/routes.mjs +67 -0
- package/dist/server/server.d.mts +2 -0
- package/dist/server/server.mjs +439 -0
- package/dist/signin/codes.mjs +47 -0
- package/dist/signin/context.d.mts +9 -0
- package/dist/signin/context.mjs +121 -0
- package/dist/signin/device.mjs +122 -0
- package/dist/signin/forms.mjs +157 -0
- package/dist/signin/grants.d.mts +5 -0
- package/dist/signin/grants.mjs +257 -0
- package/dist/signin/route.mjs +68 -0
- package/dist/signin/web.mjs +125 -0
- package/dist/signin/wire.d.mts +42 -0
- package/dist/signin/wire.mjs +43 -0
- package/dist/storage/allotted.mjs +102 -0
- package/dist/storage/budget.mjs +96 -0
- package/dist/storage/calls.d.mts +18 -0
- package/dist/storage/calls.mjs +273 -0
- package/dist/storage/clean-up.mjs +124 -0
- package/dist/storage/distinct-ids.mjs +39 -0
- package/dist/storage/ewah.mjs +97 -0
- package/dist/storage/fetch.d.mts +13 -0
- package/dist/storage/fetch.mjs +792 -0
- package/dist/storage/fsck.mjs +77 -0
- package/dist/storage/held-memo.mjs +188 -0
- package/dist/storage/index-bitmaps.d.mts +4 -0
- package/dist/storage/index-bitmaps.mjs +654 -0
- package/dist/storage/index-build.d.mts +15 -0
- package/dist/storage/index-build.mjs +1433 -0
- package/dist/storage/index-fetch.d.mts +9 -0
- package/dist/storage/index-fetch.mjs +756 -0
- package/dist/storage/index-files.mjs +232 -0
- package/dist/storage/index-graph.d.mts +3 -0
- package/dist/storage/index-graph.mjs +1049 -0
- package/dist/storage/index-layers.mjs +317 -0
- package/dist/storage/index-reach.mjs +216 -0
- package/dist/storage/index-remap.d.mts +8 -0
- package/dist/storage/index-remap.mjs +592 -0
- package/dist/storage/layout.mjs +69 -0
- package/dist/storage/lfs-pointers.d.mts +21 -0
- package/dist/storage/lfs-pointers.mjs +175 -0
- package/dist/storage/link-join.mjs +106 -0
- package/dist/storage/links.mjs +105 -0
- package/dist/storage/loose.d.mts +15 -0
- package/dist/storage/loose.mjs +120 -0
- package/dist/storage/memory-budget.d.mts +8 -0
- package/dist/storage/memory-budget.mjs +546 -0
- package/dist/storage/merge.mjs +416 -0
- package/dist/storage/object-rows.d.mts +6 -0
- package/dist/storage/object-rows.mjs +211 -0
- package/dist/storage/pack-order.d.mts +8 -0
- package/dist/storage/pack-order.mjs +779 -0
- package/dist/storage/pack-ranges.d.mts +5 -0
- package/dist/storage/pack-ranges.mjs +284 -0
- package/dist/storage/pack-reads.d.mts +11 -0
- package/dist/storage/pack-reads.mjs +990 -0
- package/dist/storage/pack-receive.d.mts +11 -0
- package/dist/storage/pack-receive.mjs +449 -0
- package/dist/storage/packs.d.mts +56 -0
- package/dist/storage/packs.mjs +600 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +151 -0
- package/dist/storage/pushed-commits.mjs +136 -0
- package/dist/storage/quarantine.mjs +98 -0
- package/dist/storage/raw-ids.mjs +44 -0
- package/dist/storage/ready.d.mts +19 -0
- package/dist/storage/ready.mjs +328 -0
- package/dist/storage/receive-links.mjs +297 -0
- package/dist/storage/repack-job.mjs +48 -0
- package/dist/storage/repack.d.mts +31 -0
- package/dist/storage/repack.mjs +182 -0
- package/dist/storage/roots.mjs +42 -0
- package/dist/storage/rows.d.mts +3 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/shallow.d.mts +5 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +236 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +7 -0
- package/dist/storage/walk.mjs +170 -0
- package/dist/storage/wants.mjs +362 -0
- package/dist/store/call-count.d.mts +47 -0
- package/dist/store/call-count.mjs +207 -0
- package/dist/store/catalogue.d.mts +7 -0
- package/dist/store/catalogue.mjs +643 -0
- package/dist/store/crossing.mjs +66 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +85 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +129 -0
- package/dist/store/git-store.mjs +75 -0
- package/dist/store/list-job.mjs +35 -0
- package/dist/store/outbox.d.mts +7 -0
- package/dist/store/outbox.mjs +295 -0
- package/dist/store/queue-jobs.mjs +43 -0
- package/dist/store/random.mjs +28 -0
- package/dist/store/records.d.mts +4 -0
- package/dist/store/records.mjs +192 -0
- package/dist/store/ref-rows.d.mts +4 -0
- package/dist/store/ref-rows.mjs +30 -0
- package/dist/store/repo-record.mjs +100 -0
- package/dist/store/reservations.mjs +82 -0
- package/dist/store/scopes.mjs +170 -0
- package/dist/store/settle.mjs +63 -0
- package/dist/store/topic-jobs.mjs +62 -0
- package/dist/sync/bound.d.mts +7 -0
- package/dist/sync/bound.mjs +29 -0
- package/dist/sync/github.d.mts +12 -0
- package/dist/sync/github.mjs +297 -0
- package/dist/sync/import.d.mts +8 -0
- package/dist/sync/import.mjs +154 -0
- package/dist/sync/jobs.d.mts +9 -0
- package/dist/sync/jobs.mjs +80 -0
- package/dist/sync/mirror.d.mts +9 -0
- package/dist/sync/mirror.mjs +227 -0
- package/dist/sync/publish.d.mts +5 -0
- package/dist/sync/publish.mjs +117 -0
- package/dist/sync/records.mjs +73 -0
- package/dist/sync/smart-http.d.mts +8 -0
- package/dist/sync/smart-http.mjs +23 -0
- package/dist/sync/step.mjs +334 -0
- package/dist/sync/tries.mjs +126 -0
- package/dist/sync.d.mts +8 -0
- package/dist/sync.mjs +8 -0
- package/dist/topics/advance.mjs +554 -0
- package/dist/topics/calls.mjs +346 -0
- package/dist/topics/directory.mjs +107 -0
- package/dist/topics/host.d.mts +11 -0
- package/dist/topics/host.mjs +71 -0
- package/dist/topics/members.mjs +177 -0
- package/dist/topics/rows.mjs +99 -0
- package/dist/topics/topic.mjs +126 -0
- package/package.json +88 -3
- package/README.md +0 -3
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { deflateWhole } from "../protocol/bytes/deflate.mjs";
|
|
2
|
+
import { nativeSha1Hasher } from "../protocol/bytes/sha1-hasher.mjs";
|
|
3
|
+
import { entryHeader } from "../protocol/packs/writer.mjs";
|
|
4
|
+
import { gitError, thrownError } from "../store/errors.mjs";
|
|
5
|
+
import { callsAhead } from "./fetch.mjs";
|
|
6
|
+
import { repoScope } from "../store/scopes.mjs";
|
|
7
|
+
import { bucketCall } from "./calls.mjs";
|
|
8
|
+
import { noCall, runIn } from "../store/crossing.mjs";
|
|
9
|
+
import { objectCollections, packFiles } from "./layout.mjs";
|
|
10
|
+
import { eachPageAt, objectOfRow } from "./object-rows.mjs";
|
|
11
|
+
import { rowsBytes } from "./repack.mjs";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as Hex from "effect/encoding/Hex";
|
|
14
|
+
// src/storage/stream-whole.ts
|
|
15
|
+
/**
|
|
16
|
+
* The most object rows a streamed clone writes whole after the packs. Past it the clone builds, as
|
|
17
|
+
* it did before: a prune pass folds the rows into its pack.
|
|
18
|
+
*/
|
|
19
|
+
const wholeRowsMost = 1e3;
|
|
20
|
+
/** A stored pack's header, `PACK`, its version and its count, before its entries. */
|
|
21
|
+
const headerBytes = 12;
|
|
22
|
+
/** A pack's trailer, the SHA-1 of every byte before it. */
|
|
23
|
+
const trailerBytes = 20;
|
|
24
|
+
/** A PACK's header: `PACK`, version 2, and `count`, four bytes big-endian. */
|
|
25
|
+
const packHeader = (count) => {
|
|
26
|
+
const bytes = new Uint8Array(headerBytes);
|
|
27
|
+
bytes.set([
|
|
28
|
+
80,
|
|
29
|
+
65,
|
|
30
|
+
67,
|
|
31
|
+
75
|
|
32
|
+
]);
|
|
33
|
+
const view = new DataView(bytes.buffer);
|
|
34
|
+
view.setUint32(4, 2);
|
|
35
|
+
view.setUint32(8, count);
|
|
36
|
+
return bytes;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Whether two of `packs`, or a row and a pack, or two rows, hold the same object: a merge of the
|
|
40
|
+
* packs' sorted `.idx` tables, then each row looked up in them. Git's `index-pack` takes no object
|
|
41
|
+
* twice, so a clone over a duplicate builds instead.
|
|
42
|
+
*/
|
|
43
|
+
const duplicated = (packs, rows) => {
|
|
44
|
+
const ranks = packs.map(() => 0);
|
|
45
|
+
let last;
|
|
46
|
+
for (;;) {
|
|
47
|
+
let least = -1;
|
|
48
|
+
let oid;
|
|
49
|
+
for (const [at, { index }] of packs.entries()) {
|
|
50
|
+
const rank = ranks[at] ?? index.count;
|
|
51
|
+
if (rank >= index.count) continue;
|
|
52
|
+
const next = index.oidAt(rank);
|
|
53
|
+
if (oid === void 0 || next < oid) {
|
|
54
|
+
oid = next;
|
|
55
|
+
least = at;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (oid === void 0) break;
|
|
59
|
+
if (oid === last) return true;
|
|
60
|
+
last = oid;
|
|
61
|
+
ranks[least] = (ranks[least] ?? 0) + 1;
|
|
62
|
+
}
|
|
63
|
+
const seen = /* @__PURE__ */ new Set();
|
|
64
|
+
for (const { oid } of rows) {
|
|
65
|
+
if (seen.has(oid) || packs.some(({ index }) => index.find(oid) !== void 0)) return true;
|
|
66
|
+
seen.add(oid);
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* What a whole clone of `listed` streams, read at its version: its packs but the cruft ones, each
|
|
72
|
+
* index loaded, and its object rows, read a page at a time so no answer passes the store's. Its
|
|
73
|
+
* packs' bytes and its rows' count toward `limits.bytes`, as a plan's would. `undefined` when the
|
|
74
|
+
* repo moved since `listed` was read, when it holds more rows than `wholeRowsMost`, when the clone
|
|
75
|
+
* is past `limits`, or when an object is stored twice: then the clone builds, as before. Refused
|
|
76
|
+
* by `tooManyCalls` when the calls it made, through `store` and `bucket`, and a ranged get a pack
|
|
77
|
+
* still to come pass `calls`, checked before each index load and once loaded, so it stops before
|
|
78
|
+
* the stream's first byte. Each page of rows is charged before it's kept, its values and the
|
|
79
|
+
* objects decoded from them, so the rows it holds are within the fetch's allotment.
|
|
80
|
+
*/
|
|
81
|
+
const wholePlan = Effect.fnUntraced(function* (store, bucket, indexes, listed, input, calls, charge = () => Effect.void) {
|
|
82
|
+
const snapshot = yield* store.read({
|
|
83
|
+
scope: repoScope(listed.repo),
|
|
84
|
+
reads: [{ collection: objectCollections.cruft }]
|
|
85
|
+
});
|
|
86
|
+
if (snapshot.version !== listed.version) return void 0;
|
|
87
|
+
const objectRows = [];
|
|
88
|
+
if (!(yield* eachPageAt(store, listed.repo, listed.version, (page) => {
|
|
89
|
+
objectRows.push(...page);
|
|
90
|
+
if (objectRows.length > 1e3) return Effect.succeed(false);
|
|
91
|
+
return Effect.as(charge(2 * rowsBytes(page)), true);
|
|
92
|
+
}))) return void 0;
|
|
93
|
+
const cruft = new Set((snapshot.results[0] ?? []).map(({ id }) => id));
|
|
94
|
+
const kept = listed.packs.filter(({ id }) => !cruft.has(id));
|
|
95
|
+
const rows = yield* Effect.forEach(objectRows, (row) => objectOfRow(row));
|
|
96
|
+
const objects = kept.reduce((sum, pack) => sum + pack.objects, rows.length);
|
|
97
|
+
const packBytes = kept.reduce((sum, pack) => sum + pack.bytes, 0);
|
|
98
|
+
const bytes = rows.reduce((sum, row) => sum + row.bytes.byteLength, packBytes);
|
|
99
|
+
const { limits } = input;
|
|
100
|
+
if (objects > limits.objects || bytes > limits.bytes) return void 0;
|
|
101
|
+
const gets = callsAhead(calls, {
|
|
102
|
+
bucket: kept.length,
|
|
103
|
+
store: 0
|
|
104
|
+
}, true);
|
|
105
|
+
const packs = yield* Effect.forEach(kept, (pack) => Effect.andThen(gets, indexes.load(bucket, pack)));
|
|
106
|
+
yield* gets;
|
|
107
|
+
if (duplicated(packs, rows)) return void 0;
|
|
108
|
+
return {
|
|
109
|
+
packs,
|
|
110
|
+
rows,
|
|
111
|
+
objects
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
const changed = (pack) => gitError("DATA_LOSS", `Pack ${pack.pack.id}'s bytes aren't those its index lists`);
|
|
115
|
+
const gone = (pack) => gitError("DATA_LOSS", `Pack ${pack.pack.id} was listed when this clone began, and isn't now`);
|
|
116
|
+
/**
|
|
117
|
+
* One stored pack's entries: one ranged get from its header's end to its trailer, each piece
|
|
118
|
+
* hashed with the header it was stored under and checked against its index's checksum before the
|
|
119
|
+
* last piece is handed on. A pack whose bytes changed ends the clone with `DATA_LOSS` and no
|
|
120
|
+
* trailer, so Git keeps no clone of it, as the planned writer's CRC-32 check does.
|
|
121
|
+
*/
|
|
122
|
+
async function* packEntries(bucket, pack, signal, count) {
|
|
123
|
+
const length = pack.pack.bytes - headerBytes - trailerBytes;
|
|
124
|
+
const hash = nativeSha1Hasher();
|
|
125
|
+
await runIn(hash.write(packHeader(pack.index.count)), noCall);
|
|
126
|
+
const opening = bucketCall((fiber) => bucket.read(packFiles(pack.pack.id).pack, {
|
|
127
|
+
offset: headerBytes,
|
|
128
|
+
length
|
|
129
|
+
}, { signal: fiber }));
|
|
130
|
+
const stream = await runIn(Effect.mapError(opening, thrownError), count, signal);
|
|
131
|
+
if (stream === void 0) throw gone(pack);
|
|
132
|
+
const reader = stream.getReader();
|
|
133
|
+
const onAbort = () => void reader.cancel(signal?.reason).catch(() => void 0);
|
|
134
|
+
if (signal?.aborted === true) onAbort();
|
|
135
|
+
signal?.throwIfAborted();
|
|
136
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
137
|
+
let held;
|
|
138
|
+
let read = 0;
|
|
139
|
+
let done = false;
|
|
140
|
+
try {
|
|
141
|
+
for (;;) {
|
|
142
|
+
const next = await reader.read();
|
|
143
|
+
if (next.done) break;
|
|
144
|
+
read += next.value.byteLength;
|
|
145
|
+
await runIn(hash.write(next.value), noCall);
|
|
146
|
+
if (held !== void 0) yield held;
|
|
147
|
+
held = next.value;
|
|
148
|
+
}
|
|
149
|
+
done = true;
|
|
150
|
+
} finally {
|
|
151
|
+
signal?.removeEventListener("abort", onAbort);
|
|
152
|
+
if (!done) await reader.cancel(signal?.reason).catch(() => void 0);
|
|
153
|
+
}
|
|
154
|
+
signal?.throwIfAborted();
|
|
155
|
+
const digest = Hex.encode(await runIn(hash.digest, noCall));
|
|
156
|
+
if (read !== length || digest !== pack.index.packChecksum) throw changed(pack);
|
|
157
|
+
if (held !== void 0) yield held;
|
|
158
|
+
}
|
|
159
|
+
/** A whole object's entry: its header, then its bytes deflated. */
|
|
160
|
+
const wholeEntry = Effect.fnUntraced(function* (object) {
|
|
161
|
+
const body = yield* deflateWhole(object.bytes);
|
|
162
|
+
const header = entryHeader(object.type, object.bytes.byteLength);
|
|
163
|
+
const entry = new Uint8Array(header.byteLength + body.byteLength);
|
|
164
|
+
entry.set(header);
|
|
165
|
+
entry.set(body, header.byteLength);
|
|
166
|
+
return entry;
|
|
167
|
+
});
|
|
168
|
+
/** The clone's pieces: the header, each pack's entries, each row's object, then the trailer. */
|
|
169
|
+
async function* wholePieces(bucket, plan, signal, hash, count) {
|
|
170
|
+
const sent = async function* (pieces) {
|
|
171
|
+
for await (const piece of pieces) {
|
|
172
|
+
await runIn(hash.write(piece), noCall);
|
|
173
|
+
yield piece;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
yield* sent([packHeader(plan.objects)]);
|
|
177
|
+
for (const pack of plan.packs) {
|
|
178
|
+
signal?.throwIfAborted();
|
|
179
|
+
yield* sent(packEntries(bucket, pack, signal, count));
|
|
180
|
+
}
|
|
181
|
+
for (const row of plan.rows) {
|
|
182
|
+
signal?.throwIfAborted();
|
|
183
|
+
yield* sent([await runIn(wholeEntry(row), noCall)]);
|
|
184
|
+
}
|
|
185
|
+
signal?.throwIfAborted();
|
|
186
|
+
yield await runIn(hash.digest, noCall);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* `plan`'s pack as one stream: a header counting every object, each pack's entries by one ranged
|
|
190
|
+
* get, the rows' objects written whole, and a SHA-1 of the bytes sent. A stored pack is never thin,
|
|
191
|
+
* since a receive refuses one, so each delta's base moves with it: an `OFS_DELTA`'s by its offset
|
|
192
|
+
* in the pack's entries, a `REF_DELTA`'s by its ID. Cancelled, or its call's `signal` aborted, it
|
|
193
|
+
* cancels the bucket's read first: the pieces' `return` waits on a read that may never come. Its
|
|
194
|
+
* reads count into `count`, the clone's request's, if any.
|
|
195
|
+
*/
|
|
196
|
+
const wholeStream = (bucket, plan, signal, done = () => {}, count) => {
|
|
197
|
+
const stop = new AbortController();
|
|
198
|
+
const aborted = () => stop.abort(signal?.reason);
|
|
199
|
+
if (signal?.aborted === true) aborted();
|
|
200
|
+
else signal?.addEventListener("abort", aborted, { once: true });
|
|
201
|
+
const pieces = wholePieces(bucket, plan, stop.signal, nativeSha1Hasher(), count);
|
|
202
|
+
let over = false;
|
|
203
|
+
const ended = () => {
|
|
204
|
+
signal?.removeEventListener("abort", aborted);
|
|
205
|
+
if (over) return;
|
|
206
|
+
over = true;
|
|
207
|
+
done();
|
|
208
|
+
};
|
|
209
|
+
return new ReadableStream({
|
|
210
|
+
pull: async (controller) => {
|
|
211
|
+
let next;
|
|
212
|
+
try {
|
|
213
|
+
next = await pieces.next();
|
|
214
|
+
} finally {
|
|
215
|
+
if (next === void 0) ended();
|
|
216
|
+
}
|
|
217
|
+
if (next.done === true) {
|
|
218
|
+
ended();
|
|
219
|
+
controller.close();
|
|
220
|
+
} else controller.enqueue(next.value);
|
|
221
|
+
},
|
|
222
|
+
cancel: async (reason) => {
|
|
223
|
+
ended();
|
|
224
|
+
stop.abort(reason);
|
|
225
|
+
await pieces.return(void 0);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
/** The whole clone's answer, its stream ended by the call's signal and the fetch's deadline. */
|
|
230
|
+
const wholeAnswer = (plan, pack) => ({
|
|
231
|
+
shallow: [],
|
|
232
|
+
unshallow: [],
|
|
233
|
+
objects: plan.objects,
|
|
234
|
+
pack
|
|
235
|
+
});
|
|
236
|
+
export { wholeAnswer, wholePlan, wholeRowsMost, wholeStream };
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { BufferError, BufferMeter } from "../protocol/bytes/buffers.mjs";
|
|
2
|
+
import { joinedBytes } from "../protocol/bytes/joined.mjs";
|
|
3
|
+
import { nativeSha1Hasher } from "../protocol/bytes/sha1-hasher.mjs";
|
|
4
|
+
import { fsckObject } from "../protocol/objects/fsck.mjs";
|
|
5
|
+
import { objectId } from "../protocol/objects/object.mjs";
|
|
6
|
+
import { appliedDelta } from "../protocol/packs/delta.mjs";
|
|
7
|
+
import { PackError, PackTransportError, boundedSource, readPack } from "../protocol/packs/reader.mjs";
|
|
8
|
+
import { gitError } from "../store/errors.mjs";
|
|
9
|
+
import { checkedFilesRefused, checkedOverflow, fsckRefusal, receiveChecked } from "./fsck.mjs";
|
|
10
|
+
import { linksOf, mistyped, shallowLinks, shallowRoot } from "./links.mjs";
|
|
11
|
+
import { objectRow, rowValueBytes } from "./object-rows.mjs";
|
|
12
|
+
import { limits } from "@ref0/infra";
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
|
+
import * as Result from "effect/Result";
|
|
15
|
+
// src/storage/unpack.ts
|
|
16
|
+
/** One commit's size as JSON, as every store holds it: a push's rows and its refs share it. */
|
|
17
|
+
const commitBytes = 8388608;
|
|
18
|
+
/** What the reader may hold besides the entries it hands on: its inflater and buffers. */
|
|
19
|
+
const readerBytes = 1048576;
|
|
20
|
+
const tooLarge = (bytes, most) => gitError("RESOURCE_EXHAUSTED", `push takes ${bytes.toLocaleString("en-US")} bytes as rows; one commit holds ${most.toLocaleString("en-US")}`, {
|
|
21
|
+
hint: "Use packs() storage, or push fewer objects at a time",
|
|
22
|
+
context: { reason: "too-large" }
|
|
23
|
+
});
|
|
24
|
+
/** A push whose objects, resolved whole, pass a commit before their rows are made: as `tooLarge`. */
|
|
25
|
+
const resolvedTooLarge = (bytes, most) => gitError("RESOURCE_EXHAUSTED", `push's objects take more than ${bytes.toLocaleString("en-US")} bytes whole; one commit holds ${most.toLocaleString("en-US")}`, {
|
|
26
|
+
hint: "Use packs() storage, or push fewer objects at a time",
|
|
27
|
+
context: { reason: "too-large" }
|
|
28
|
+
});
|
|
29
|
+
/** An object whose row passes one row's 1 MiB: `RESOURCE_EXHAUSTED`, reason `object-too-large`. */
|
|
30
|
+
const rowTooLarge = (oid, bytes) => gitError("RESOURCE_EXHAUSTED", `object ${oid} takes ${bytes.toLocaleString("en-US")} bytes as a row; one row holds ${limits.valueBytes.toLocaleString("en-US")}`, {
|
|
31
|
+
hint: "Use packs() storage, which keeps a large object in the bucket",
|
|
32
|
+
context: { reason: "object-too-large" }
|
|
33
|
+
});
|
|
34
|
+
const malformedPack = (message) => gitError("INVALID_ARGUMENT", `The pack is malformed: ${message}`, { hint: "Push again" });
|
|
35
|
+
/** No pack or retry carries one object past what the storage takes, so the hint is to drop it. */
|
|
36
|
+
const objectPastHint = "Remove the file from history, or track it with Git LFS";
|
|
37
|
+
/** The reader's failures as Git's: a malformed pack, one too large, or a broken body. */
|
|
38
|
+
const readFailure = (error) => {
|
|
39
|
+
if (error instanceof PackError) return error.fault === "too big" ? gitError("RESOURCE_EXHAUSTED", error.message, {
|
|
40
|
+
hint: objectPastHint,
|
|
41
|
+
context: { reason: "object-too-large" }
|
|
42
|
+
}) : malformedPack(error.message);
|
|
43
|
+
if (error instanceof BufferError) return gitError("RESOURCE_EXHAUSTED", error.message, { context: { reason: "too-large" } });
|
|
44
|
+
if (error instanceof PackTransportError) return gitError("UNAVAILABLE", "The push's body broke off", {
|
|
45
|
+
cause: error.cause,
|
|
46
|
+
hint: "Push again"
|
|
47
|
+
});
|
|
48
|
+
return error;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Every entry of the pack, read whole, within `most` inflated bytes in all; a pack whose header
|
|
52
|
+
* counts more than `objects` entries is refused before its first.
|
|
53
|
+
*/
|
|
54
|
+
const readEntries = (input, most) => Effect.gen(function* () {
|
|
55
|
+
const entries = [];
|
|
56
|
+
let current;
|
|
57
|
+
let pieces = [];
|
|
58
|
+
let held = 0;
|
|
59
|
+
const sink = {
|
|
60
|
+
begin: ({ count }) => count > input.limits.objects ? Effect.fail(input.tooMany(count)) : Effect.void,
|
|
61
|
+
entry: (entry) => Effect.sync(() => {
|
|
62
|
+
current = entry;
|
|
63
|
+
pieces = [];
|
|
64
|
+
}),
|
|
65
|
+
data: (bytes) => {
|
|
66
|
+
held += bytes.byteLength;
|
|
67
|
+
if (held > most) return Effect.fail(tooLarge(held, most));
|
|
68
|
+
pieces.push(bytes.slice());
|
|
69
|
+
return Effect.void;
|
|
70
|
+
},
|
|
71
|
+
entryEnd: () => Effect.sync(() => {
|
|
72
|
+
if (current !== void 0) entries.push({
|
|
73
|
+
entry: current,
|
|
74
|
+
data: joinedBytes(pieces)
|
|
75
|
+
});
|
|
76
|
+
current = void 0;
|
|
77
|
+
pieces = [];
|
|
78
|
+
})
|
|
79
|
+
};
|
|
80
|
+
const meter = new BufferMeter(readerBytes);
|
|
81
|
+
const source = boundedSource(input.receive.pack, /* @__PURE__ */ new Uint8Array(0), meter);
|
|
82
|
+
return {
|
|
83
|
+
entries,
|
|
84
|
+
bytes: (yield* readPack(source, nativeSha1Hasher(), sink, {
|
|
85
|
+
objectBytes: most,
|
|
86
|
+
deltaBytes: most
|
|
87
|
+
}, meter).pipe(Effect.mapError(readFailure), Effect.ensuring(source.cancel))).bytes
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
/** Where a delta waits: its base's offset in the pack, or its base's ID. */
|
|
91
|
+
const waitKey = (entry) => {
|
|
92
|
+
if (entry.base === void 0) return void 0;
|
|
93
|
+
return entry.base.kind === "offset" ? `o:${entry.base.offset}` : `r:${entry.base.oid}`;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Each entry as a whole object: a whole entry hashed, a delta applied to its base, an earlier
|
|
97
|
+
* entry by offset, one by ID in the pack, or one the repo holds. A delta left without its base
|
|
98
|
+
* refuses the pack, and so do objects past `most` bytes in all, as each delta's is made.
|
|
99
|
+
*/
|
|
100
|
+
const resolve = Effect.fnUntraced(function* (input, entries, most) {
|
|
101
|
+
const objects = /* @__PURE__ */ new Map();
|
|
102
|
+
const waiting = /* @__PURE__ */ new Map();
|
|
103
|
+
const ready = [];
|
|
104
|
+
let unresolved = 0;
|
|
105
|
+
let made = 0;
|
|
106
|
+
for (const each of entries) {
|
|
107
|
+
const key = waitKey(each.entry);
|
|
108
|
+
if (key === void 0) {
|
|
109
|
+
const type = each.entry.kind;
|
|
110
|
+
const bytes = new Uint8Array(each.data);
|
|
111
|
+
made += bytes.byteLength;
|
|
112
|
+
ready.push({
|
|
113
|
+
offset: each.entry.offset,
|
|
114
|
+
object: {
|
|
115
|
+
oid: yield* objectId({
|
|
116
|
+
type,
|
|
117
|
+
bytes
|
|
118
|
+
}),
|
|
119
|
+
type,
|
|
120
|
+
bytes
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
waiting.set(key, [...waiting.get(key) ?? [], each]);
|
|
125
|
+
unresolved += 1;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const settle = Effect.fnUntraced(function* () {
|
|
129
|
+
for (let next = ready.pop(); next !== void 0; next = ready.pop()) {
|
|
130
|
+
const { offset, object } = next;
|
|
131
|
+
if (offset !== void 0) objects.set(object.oid, object);
|
|
132
|
+
const keys = offset === void 0 ? [`r:${object.oid}`] : [`o:${offset}`, `r:${object.oid}`];
|
|
133
|
+
for (const key of keys) {
|
|
134
|
+
for (const delta of waiting.get(key) ?? []) {
|
|
135
|
+
const applied = appliedDelta(object.bytes, delta.data, most);
|
|
136
|
+
if (Result.isFailure(applied)) return yield* Effect.fail(malformedPack(`the delta at ${delta.entry.offset}: ${applied.failure.message}`));
|
|
137
|
+
const bytes = applied.success;
|
|
138
|
+
made += bytes.byteLength;
|
|
139
|
+
if (made > most) return yield* Effect.fail(resolvedTooLarge(made, most));
|
|
140
|
+
const type = object.type;
|
|
141
|
+
const whole = new Uint8Array(bytes);
|
|
142
|
+
ready.push({
|
|
143
|
+
offset: delta.entry.offset,
|
|
144
|
+
object: {
|
|
145
|
+
oid: yield* objectId({
|
|
146
|
+
type,
|
|
147
|
+
bytes: whole
|
|
148
|
+
}),
|
|
149
|
+
type,
|
|
150
|
+
bytes: whole
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
unresolved -= 1;
|
|
154
|
+
}
|
|
155
|
+
waiting.delete(key);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
yield* settle();
|
|
160
|
+
const outside = [...waiting.keys()].flatMap((key) => key.startsWith("r:") ? [key.slice(2)] : []);
|
|
161
|
+
const bases = outside.length === 0 ? /* @__PURE__ */ new Map() : yield* input.held(outside);
|
|
162
|
+
for (const base of bases.values()) ready.push({
|
|
163
|
+
offset: void 0,
|
|
164
|
+
object: base
|
|
165
|
+
});
|
|
166
|
+
yield* settle();
|
|
167
|
+
if (unresolved > 0) return yield* Effect.fail(gitError("INVALID_ARGUMENT", `pack has ${unresolved} unresolved deltas`, { hint: "Push again, with every object the pack needs" }));
|
|
168
|
+
return objects;
|
|
169
|
+
});
|
|
170
|
+
/**
|
|
171
|
+
* `INVALID_ARGUMENT` for the first object Git 2.53's fsck refuses a push for: one of the pack's
|
|
172
|
+
* own, or a `.gitmodules` or `.gitattributes` one of its trees names, in the pack or the repo.
|
|
173
|
+
*/
|
|
174
|
+
const fscked = Effect.fnUntraced(function* (input, objects) {
|
|
175
|
+
const checked = receiveChecked();
|
|
176
|
+
for (const object of objects.values()) {
|
|
177
|
+
const fault = fsckObject(object, checked);
|
|
178
|
+
if (fault !== void 0) return yield* Effect.fail(fsckRefusal(object.oid, fault));
|
|
179
|
+
const overflow = checkedOverflow(checked);
|
|
180
|
+
if (overflow !== void 0) return yield* Effect.fail(overflow);
|
|
181
|
+
}
|
|
182
|
+
yield* checkedFilesRefused(checked, (oid) => Effect.succeed(objects.get(oid)), input.held);
|
|
183
|
+
});
|
|
184
|
+
/**
|
|
185
|
+
* `INVALID_ARGUMENT` unless every object the pack's own name is in it or the repo, of the type its
|
|
186
|
+
* link says, and `shallowRoot` when a shallow client's commit names parents neither holds. A
|
|
187
|
+
* partial pack may leave out both.
|
|
188
|
+
*/
|
|
189
|
+
const connected = Effect.fnUntraced(function* (input, objects) {
|
|
190
|
+
if (input.receive.partial === true) return;
|
|
191
|
+
const shallow = new Set(input.receive.shallow);
|
|
192
|
+
const links = [];
|
|
193
|
+
const parents = [];
|
|
194
|
+
for (const object of objects.values()) {
|
|
195
|
+
const split = shallowLinks(object, yield* Effect.fromResult(linksOf(object)), shallow);
|
|
196
|
+
for (const link of split.needed) links.push(link);
|
|
197
|
+
for (const parent of split.parents) parents.push(parent);
|
|
198
|
+
}
|
|
199
|
+
const outside = (link) => link.oid !== "4b825dc642cb6eb9a060e54bf8d69288fbee4904" && !objects.has(link.oid);
|
|
200
|
+
const asked = new Set([...links, ...parents].flatMap((link) => outside(link) ? [link.oid] : []));
|
|
201
|
+
const held = asked.size === 0 ? /* @__PURE__ */ new Map() : yield* input.held([...asked]);
|
|
202
|
+
const missing = links.find((link) => outside(link) && !held.has(link.oid));
|
|
203
|
+
if (missing !== void 0) return yield* Effect.fail(gitError("INVALID_ARGUMENT", "missing necessary objects", { hint: `Push ${missing.oid} and every object it needs` }));
|
|
204
|
+
if (parents.some((link) => outside(link) && !held.has(link.oid))) return yield* Effect.fail(shallowRoot());
|
|
205
|
+
const typeOf = (oid) => oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904" ? "tree" : (objects.get(oid) ?? held.get(oid))?.type;
|
|
206
|
+
const wrong = mistyped([...links, ...parents], typeOf);
|
|
207
|
+
if (wrong !== void 0) return yield* Effect.fail(wrong);
|
|
208
|
+
});
|
|
209
|
+
/**
|
|
210
|
+
* A received pack as rows, one per object, for its push's commit: each entry read and resolved,
|
|
211
|
+
* each object checked as Git's fsck checks it and parsed, and every object they name present, of
|
|
212
|
+
* the type its link says. Refused whole, before any row, past `limits` or for an object whose row
|
|
213
|
+
* passes 1 MiB, for a malformed or unresolved pack, an object fsck refuses, or a missing or
|
|
214
|
+
* mistyped object.
|
|
215
|
+
*/
|
|
216
|
+
const unpackObjects = Effect.fnUntraced(function* (input) {
|
|
217
|
+
const { receive, limits: limits$1 } = input;
|
|
218
|
+
if (receive.objects > limits$1.objects) return yield* Effect.fail(input.tooMany(receive.objects));
|
|
219
|
+
const { entries, bytes } = yield* readEntries(input, limits$1.bytes);
|
|
220
|
+
const objects = yield* resolve(input, entries, limits$1.bytes);
|
|
221
|
+
yield* fscked(input, objects);
|
|
222
|
+
yield* connected(input, objects);
|
|
223
|
+
const rows = [...objects.values()].map(objectRow);
|
|
224
|
+
for (const row of rows) {
|
|
225
|
+
const valueBytes = rowValueBytes(row.value);
|
|
226
|
+
if (valueBytes > limits.valueBytes) return yield* Effect.fail(rowTooLarge(row.id, valueBytes));
|
|
227
|
+
}
|
|
228
|
+
const rowBytes = rows.reduce((sum, row) => sum + JSON.stringify(row).length, 0);
|
|
229
|
+
if (rowBytes > limits$1.bytes) return yield* Effect.fail(tooLarge(rowBytes, limits$1.bytes));
|
|
230
|
+
return {
|
|
231
|
+
objects: [...objects.values()],
|
|
232
|
+
rows,
|
|
233
|
+
bytes
|
|
234
|
+
};
|
|
235
|
+
});
|
|
236
|
+
export { commitBytes, malformedPack, readFailure, rowTooLarge, unpackObjects };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { gitError, resultCall } from "../store/errors.mjs";
|
|
2
|
+
import { answerTo, effectObjects, handedCall, scopedReader, walkObjects } from "./calls.mjs";
|
|
3
|
+
import { onward, stepsOf, wantWalkMost } from "./wants.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Semaphore from "effect/Semaphore";
|
|
6
|
+
// src/storage/visible.ts
|
|
7
|
+
/**
|
|
8
|
+
* Private branches' objects (#596, piece 2): what one caller may read of a repo, the objects the
|
|
9
|
+
* refs it sees reach, and the objects narrowed to them, so a hidden object answers as one the
|
|
10
|
+
* repo lacks on every surface that takes an object ID.
|
|
11
|
+
*
|
|
12
|
+
* Until the reachability index answers it (#596 piece 1), a set is a walk from its tips, kept
|
|
13
|
+
* for the set's life: each `has` reads on from where the last stopped, only as far as its IDs
|
|
14
|
+
* need, and every ID the walk has passed answers with no read. Past `most` objects it's
|
|
15
|
+
* `RESOURCE_EXHAUSTED`, never a yes, so it fails closed.
|
|
16
|
+
*/
|
|
17
|
+
/** How many objects a set's walk reads at once, a frontier at a time. */
|
|
18
|
+
const walkBatch = 64;
|
|
19
|
+
/** A set's refusal past its walk's bound: it can't tell, so it answers no object. */
|
|
20
|
+
const visibleTooLong = (most) => gitError("RESOURCE_EXHAUSTED", `Checking what you can read passed ${most} objects: read a branch or tag by name instead`, {
|
|
21
|
+
hint: "Read a branch or tag by name",
|
|
22
|
+
context: { reason: "walk-limit" }
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* The objects `input.tips` reach in `listed`, read through `objects`, the repo's whole objects.
|
|
26
|
+
* Nothing is read until the set is first asked. Its walk's state is the set's own: it lives with
|
|
27
|
+
* one request's view, for one caller, and is never shared across callers.
|
|
28
|
+
*/
|
|
29
|
+
const walkedVisible = (objects, listed, input, walk = {}) => {
|
|
30
|
+
const { most = wantWalkMost, commits = false } = walk;
|
|
31
|
+
const tips = new Set(input.tips);
|
|
32
|
+
const passed = new Set(tips);
|
|
33
|
+
let frontier = [...tips];
|
|
34
|
+
let reads = 0;
|
|
35
|
+
let exhausted = false;
|
|
36
|
+
const turn = Semaphore.makeUnsafe(1).withPermits(1);
|
|
37
|
+
/** Reads on from the frontier until every one of `left` is passed or the walk ends. */
|
|
38
|
+
const walkFor = Effect.fnUntraced(function* (walk, left, signal) {
|
|
39
|
+
const call = signal === void 0 ? {} : { signal };
|
|
40
|
+
while (left.size > 0 && frontier.length > 0) {
|
|
41
|
+
const batch = frontier.slice(0, walkBatch);
|
|
42
|
+
exhausted ||= reads + batch.length > most;
|
|
43
|
+
if (exhausted) return yield* Effect.fail(visibleTooLong(most));
|
|
44
|
+
frontier = frontier.slice(walkBatch);
|
|
45
|
+
reads += batch.length;
|
|
46
|
+
const read = (oid) => walk.read(listed, {
|
|
47
|
+
oid,
|
|
48
|
+
...call
|
|
49
|
+
});
|
|
50
|
+
const found = yield* Effect.forEach(batch, read, { concurrency: 16 });
|
|
51
|
+
for (const object of found) {
|
|
52
|
+
if (object === void 0) continue;
|
|
53
|
+
const steps = yield* stepsOf(object, !commits);
|
|
54
|
+
for (const oid of onward(steps)) {
|
|
55
|
+
if (passed.has(oid)) continue;
|
|
56
|
+
passed.add(oid);
|
|
57
|
+
left.delete(oid);
|
|
58
|
+
frontier.push(oid);
|
|
59
|
+
}
|
|
60
|
+
for (const oid of steps.reached) {
|
|
61
|
+
passed.add(oid);
|
|
62
|
+
left.delete(oid);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const hasEffect = (oids, signal) => turn(Effect.gen(function* () {
|
|
68
|
+
const asked = [...new Set(oids)];
|
|
69
|
+
const unknown = asked.filter((oid) => !passed.has(oid));
|
|
70
|
+
if (unknown.length > 0) {
|
|
71
|
+
const call = signal === void 0 ? {} : { signal };
|
|
72
|
+
yield* Effect.scoped(Effect.gen(function* () {
|
|
73
|
+
const walk = yield* walkObjects(objects);
|
|
74
|
+
const held = yield* walk.headers(listed, {
|
|
75
|
+
oids: unknown,
|
|
76
|
+
...call
|
|
77
|
+
});
|
|
78
|
+
yield* walkFor(walk, new Set(unknown.filter((oid) => held.has(oid))), signal);
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
return new Set(asked.filter((oid) => passed.has(oid)));
|
|
82
|
+
}));
|
|
83
|
+
return { has: (oids, call) => answerTo(hasEffect(oids, call?.signal), call) };
|
|
84
|
+
};
|
|
85
|
+
/** `set`'s answers as a `packReader`'s `visible`, its ask aborted when the read is interrupted. */
|
|
86
|
+
const visibleOf = (set) => (oids) => oids.length === 0 ? Effect.succeed(/* @__PURE__ */ new Set()) : handedCall({}, (call, signal) => set.has(oids, {
|
|
87
|
+
...call,
|
|
88
|
+
signal
|
|
89
|
+
}));
|
|
90
|
+
/** An object the set doesn't hold, refused by a fetch as one no ref the caller reads reaches. */
|
|
91
|
+
const notReachable = (oid) => gitError("NOT_FOUND", `${oid} isn't reachable from a ref you can read`, {
|
|
92
|
+
hint: "Fetch a branch or tag by name",
|
|
93
|
+
context: { oid }
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* `input` narrowed to what `visible` holds: a want it doesn't is refused as no ref the caller
|
|
97
|
+
* reads reaching it, and a have or a shallow it doesn't is left out before the plan, so neither
|
|
98
|
+
* an ACK nor the pack's size tells of a hidden one. The rest of the plan reads whole: whatever
|
|
99
|
+
* visible wants reach is visible too.
|
|
100
|
+
*/
|
|
101
|
+
const seenFetch = Effect.fnUntraced(function* (input, visible) {
|
|
102
|
+
const { request } = input;
|
|
103
|
+
const kept = yield* visible([
|
|
104
|
+
...request.wants,
|
|
105
|
+
...request.haves,
|
|
106
|
+
...request.shallows
|
|
107
|
+
]);
|
|
108
|
+
const hidden = request.wants.find((want) => !kept.has(want));
|
|
109
|
+
if (hidden !== void 0) return yield* Effect.fail(notReachable(hidden));
|
|
110
|
+
return {
|
|
111
|
+
...input,
|
|
112
|
+
request: {
|
|
113
|
+
...request,
|
|
114
|
+
haves: request.haves.filter((oid) => kept.has(oid)),
|
|
115
|
+
shallows: request.shallows.filter((oid) => kept.has(oid))
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* `set`, and every object in `own`'s packs: a push's own received packs, which the caller sent,
|
|
121
|
+
* read alone, so after its receive a push reads what it brought beside what its refs reach.
|
|
122
|
+
*/
|
|
123
|
+
const withPushed = (set, objects, own) => {
|
|
124
|
+
const hasEffect = (oids, signal) => Effect.scoped(Effect.gen(function* () {
|
|
125
|
+
const call = signal === void 0 ? {} : { signal };
|
|
126
|
+
const reader = yield* scopedReader(effectObjects(objects), own, { listedOnly: true });
|
|
127
|
+
const brought = yield* resultCall(() => reader.headers({
|
|
128
|
+
oids,
|
|
129
|
+
...call
|
|
130
|
+
}));
|
|
131
|
+
const rest = oids.filter((oid) => !brought.has(oid));
|
|
132
|
+
const seen = rest.length === 0 ? /* @__PURE__ */ new Set() : yield* handedCall(call, (at) => set.has(rest, at));
|
|
133
|
+
return /* @__PURE__ */ new Set([...brought.keys(), ...seen]);
|
|
134
|
+
}));
|
|
135
|
+
return { has: (oids, call) => answerTo(hasEffect(oids, call?.signal), call) };
|
|
136
|
+
};
|
|
137
|
+
export { notReachable, seenFetch, visibleOf, walkedVisible, withPushed };
|