@ref0/git 0.0.0 → 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 +86 -5
|
@@ -0,0 +1,1125 @@
|
|
|
1
|
+
import { joinedBytes } from "../protocol/bytes/joined.mjs";
|
|
2
|
+
import { streamOf } from "../protocol/bytes/streams.mjs";
|
|
3
|
+
import { bytesOf, keyOf } from "../protocol/diff/paths.mjs";
|
|
4
|
+
import { DiffReader } from "../protocol/diff/read.mjs";
|
|
5
|
+
import { isTreeMode, objectId } from "../protocol/objects/object.mjs";
|
|
6
|
+
import { compareEntries, treeBytes } from "../protocol/objects/tree.mjs";
|
|
7
|
+
import { attributesFor, parseAttributes, parsedBytes, pathAttributesOf, refusedAttribute } from "./attributes.mjs";
|
|
8
|
+
import { defaultContentConfig, markerSizeOf, mergeContent } from "./content.mjs";
|
|
9
|
+
import { ancestry, namedCommit } from "./commits.mjs";
|
|
10
|
+
import { fail, fromDiff, fromMissing, gitError } from "./failures.mjs";
|
|
11
|
+
import { mergeBasesOf } from "./merge-base-walk.mjs";
|
|
12
|
+
import { folderRenamesOf, foldersAbove, movedBy, otherOf, renamesOf } from "./merge-renames.mjs";
|
|
13
|
+
import { limitsOf, readThrough, stepDeadline, timed, within } from "./reads.mjs";
|
|
14
|
+
import { XdiffDefect } from "./xdiff.mjs";
|
|
15
|
+
import * as Effect from "effect/Effect";
|
|
16
|
+
import * as Scope from "effect/Scope";
|
|
17
|
+
// src/engine/merge.ts
|
|
18
|
+
/**
|
|
19
|
+
* Three trees merged as Git 2.53.0's `merge-tree --write-tree --merge-base=<base> <ours> <theirs>`
|
|
20
|
+
* merges them, merge-ort's defaults throughout. Each path takes the side that changed it; a file
|
|
21
|
+
* both sides changed merges its content through xdiff, as merge-ort's default text driver does;
|
|
22
|
+
* and a folder merges path by path, written anew. A merge with a conflict answers no tree:
|
|
23
|
+
* `FAILED_PRECONDITION`, with the paths Git lists, where Git moves a file a folder is in the way
|
|
24
|
+
* of to `<path>~<side>`, named as it was.
|
|
25
|
+
*
|
|
26
|
+
* A merge runs in four steps:
|
|
27
|
+
*
|
|
28
|
+
* 1. **Collect** every path's three files, the base's, ours and theirs, through the folders both
|
|
29
|
+
* sides changed. A folder a side changed alone is taken whole, empty folders in it too, unless
|
|
30
|
+
* a rename may reach into it; read, a folder left empty disappears.
|
|
31
|
+
* 2. **Renames:** each side's file renames, as `renames.ts` finds them, from the files the base
|
|
32
|
+
* has and the side hasn't. Past exact matches, only the sources the merge can use: one the
|
|
33
|
+
* other side changed or deleted, or one below a folder the side removed and the other added
|
|
34
|
+
* to, which a directory rename may move. A side with such a source has every folder it changed
|
|
35
|
+
* read, so the merge collects again before it pairs.
|
|
36
|
+
* 3. **Resolve:** a rename into a folder the other side renamed moves with that folder first,
|
|
37
|
+
* conflicting where it lands. Then a rename takes the other side's changes to its
|
|
38
|
+
* destination, merged there. Both sides renaming one file alike merges cleanly; apart,
|
|
39
|
+
* rename/rename, it conflicts at the source and both destinations. A rename the other side
|
|
40
|
+
* deleted the source of conflicts there, and so does one the other side added another file at
|
|
41
|
+
* the destination of; the same file there merges cleanly. A folder renamed on one side moves
|
|
42
|
+
* what the other side added in it, conflicting where it lands, as `merge.directoryRenames`'
|
|
43
|
+
* default does; two paths moving to one, or a folder split between others, conflict with no
|
|
44
|
+
* path.
|
|
45
|
+
* 4. **Build** the merged trees from the paths, a file a folder stays at conflicting.
|
|
46
|
+
*
|
|
47
|
+
* Without a base, two commits merge over their merge bases, as `merge-tree --write-tree <ours>
|
|
48
|
+
* <theirs>` merges them: one base's tree, or a virtual base for several, and none for unrelated
|
|
49
|
+
* histories, which Git refuses. The virtual base merges the bases oldest first, each merge a commit
|
|
50
|
+
* of its two parents whose own bases a virtual base merges one deeper. Inside it, every conflict
|
|
51
|
+
* resolves: a text conflict to its markers, two longer each depth and labelled `Temporary merge
|
|
52
|
+
* branch 1` and `2`; anything else to the base's file, or none; a file a folder stays at moves to
|
|
53
|
+
* `<path>~<label>`, or `_0` and on after it. A rename/delete keeps the base's file at the
|
|
54
|
+
* destination, a rename/rename merges at both, and a file added beside a rename merges with it
|
|
55
|
+
* two-way. Directory renames stay off there, and `.gitattributes` are the outer merge's. A
|
|
56
|
+
* conflict there that isn't measured against git 2.53.0 refuses: `unsupported-virtual-base`.
|
|
57
|
+
*
|
|
58
|
+
* A file both sides changed merges with the attributes ours's `.gitattributes` give it, as `git
|
|
59
|
+
* merge` reads its worktree's and `git --attr-source=<ours> merge-tree` reads ours: `merge=union`,
|
|
60
|
+
* `merge=binary`, `-merge` and `binary` run as Git runs them. Where either side's give it a merge
|
|
61
|
+
* driver a client configures, or what `merge.renormalize` runs, `ident`, a `filter` or an
|
|
62
|
+
* encoding, the merge refuses: `FAILED_PRECONDITION`, naming the attribute and the path. Git
|
|
63
|
+
* converts no line ending in a merge without `merge.renormalize`, so neither does this. A rename's
|
|
64
|
+
* score reads ours's `diff` for each side's path too: set scores it as text, unset as binary.
|
|
65
|
+
*/
|
|
66
|
+
/** How a rename scores a path by its `diff` state: any other by its bytes. */
|
|
67
|
+
const scoredByDiff = {
|
|
68
|
+
set: "text",
|
|
69
|
+
unset: "binary"
|
|
70
|
+
};
|
|
71
|
+
/** A mode's kind, as `S_IFMT` reads it: a file, executable or not, a symlink, or a gitlink. */
|
|
72
|
+
const kindOf = (mode) => mode === "100755" ? "100644" : mode;
|
|
73
|
+
const same = (x, y) => x !== void 0 && y !== void 0 && x.mode === y.mode && x.oid === y.oid;
|
|
74
|
+
/** The same entry, or no entry on either side. */
|
|
75
|
+
const alike = (x, y) => x === void 0 ? y === void 0 : same(x, y);
|
|
76
|
+
/** Bits of the sides holding an entry `is` holds for: the base 1, ours 2 and theirs 4. */
|
|
77
|
+
const maskOf = (three, is) => three.reduce((mask, entry, at) => entry !== void 0 && is(entry) ? mask | 1 << at : mask, 0);
|
|
78
|
+
const isFolder = (entry) => isTreeMode(entry.mode);
|
|
79
|
+
/** The base a two files' merge reads: none where it's no file of their kind, a two-way merge. */
|
|
80
|
+
const baseOf = (base, ours) => base !== void 0 && kindOf(base.mode) === kindOf(ours.mode) ? base : void 0;
|
|
81
|
+
/** An entry that isn't a folder, or none. */
|
|
82
|
+
const fileOf = (entry) => entry !== void 0 && !isFolder(entry) ? entry : void 0;
|
|
83
|
+
/** The labels Git's markers carry inside a virtual base, at every depth. */
|
|
84
|
+
const temporary = {
|
|
85
|
+
ours: "Temporary merge branch 1",
|
|
86
|
+
theirs: "Temporary merge branch 2"
|
|
87
|
+
};
|
|
88
|
+
/** A side's label, followed by a path when `at` names one. */
|
|
89
|
+
const labelled = (label, at) => at === void 0 ? new TextEncoder().encode(label) : joinedBytes([new TextEncoder().encode(`${label}:`), bytesOf(at)]);
|
|
90
|
+
const bySide = () => ({
|
|
91
|
+
1: /* @__PURE__ */ new Set(),
|
|
92
|
+
2: /* @__PURE__ */ new Set()
|
|
93
|
+
});
|
|
94
|
+
/**
|
|
95
|
+
* One merge's state: its reader, what it collected, the paths that conflict and the objects it
|
|
96
|
+
* made, and the trees read and contents merged.
|
|
97
|
+
*/
|
|
98
|
+
var TreeMerge = class {
|
|
99
|
+
/** Every path a side has a file at, collected. */
|
|
100
|
+
files = /* @__PURE__ */ new Map();
|
|
101
|
+
/** Entries taken whole, unread: a side's folder, or a file where the other side's folder was. */
|
|
102
|
+
whole = /* @__PURE__ */ new Map();
|
|
103
|
+
/** The base's folders each side removed. */
|
|
104
|
+
removed = bySide();
|
|
105
|
+
/** The folders each side removed and the other side added a file in: a directory rename's. */
|
|
106
|
+
moving = bySide();
|
|
107
|
+
/** The folders Git's merge reads a side's files in late, after the rest: see `defer`. */
|
|
108
|
+
late = bySide();
|
|
109
|
+
conflicts = /* @__PURE__ */ new Set();
|
|
110
|
+
/** The conflicts that keep no file: a folder written at one takes the path, and Git lists it no more. */
|
|
111
|
+
fileless = /* @__PURE__ */ new Set();
|
|
112
|
+
/** Whether a conflict lists no path: a directory rename Git can't place. */
|
|
113
|
+
unplaced = false;
|
|
114
|
+
/** The paths inside a virtual base that files a folder stays at moved to. */
|
|
115
|
+
besides = /* @__PURE__ */ new Set();
|
|
116
|
+
made = /* @__PURE__ */ new Map();
|
|
117
|
+
/** The sides whose folders, changed alone, the merge reads, as Git reads them for renames. */
|
|
118
|
+
reads = /* @__PURE__ */ new Set();
|
|
119
|
+
#trees = /* @__PURE__ */ new Map();
|
|
120
|
+
#contents = /* @__PURE__ */ new Map();
|
|
121
|
+
#attributes = /* @__PURE__ */ new Map();
|
|
122
|
+
reader;
|
|
123
|
+
xdiff;
|
|
124
|
+
deadline;
|
|
125
|
+
known;
|
|
126
|
+
renamesSkipped;
|
|
127
|
+
/** The roots' entries: the base's, ours and theirs. */
|
|
128
|
+
roots;
|
|
129
|
+
/** The names the sides' markers carry. */
|
|
130
|
+
labels;
|
|
131
|
+
/** 0 for the merge asked for, and one more inside each virtual base. */
|
|
132
|
+
depth;
|
|
133
|
+
/** The roots whose `.gitattributes` the merge reads: the outer merge's, at every depth. */
|
|
134
|
+
attributeRoots;
|
|
135
|
+
constructor(call, roots, labels, depth, attributeRoots) {
|
|
136
|
+
this.roots = roots;
|
|
137
|
+
this.labels = labels;
|
|
138
|
+
this.depth = depth;
|
|
139
|
+
this.attributeRoots = attributeRoots;
|
|
140
|
+
this.reader = call.reader;
|
|
141
|
+
this.xdiff = call.xdiff;
|
|
142
|
+
this.deadline = call.deadline;
|
|
143
|
+
this.known = call.known;
|
|
144
|
+
this.renamesSkipped = call.renamesSkipped;
|
|
145
|
+
}
|
|
146
|
+
/** A pause in synchronous work: past the deadline it fails, and otherwise lets a timer run. */
|
|
147
|
+
get checkpoint() {
|
|
148
|
+
return Effect.andThen(Effect.yieldNow, within(this.deadline));
|
|
149
|
+
}
|
|
150
|
+
/** The collection again from its start, reading the folders of `sides`. */
|
|
151
|
+
readFoldersOf(sides) {
|
|
152
|
+
this.reads = sides;
|
|
153
|
+
this.files = /* @__PURE__ */ new Map();
|
|
154
|
+
this.whole = /* @__PURE__ */ new Map();
|
|
155
|
+
this.removed = bySide();
|
|
156
|
+
this.moving = bySide();
|
|
157
|
+
this.late = bySide();
|
|
158
|
+
}
|
|
159
|
+
/** An object the merge made, its bytes charged to the call. */
|
|
160
|
+
write(type, bytes) {
|
|
161
|
+
return Effect.gen({ self: this }, function* () {
|
|
162
|
+
yield* Effect.mapError(this.reader.charge(bytes.length), fromDiff("diff-limit"));
|
|
163
|
+
const oid = yield* objectId({
|
|
164
|
+
type,
|
|
165
|
+
bytes
|
|
166
|
+
});
|
|
167
|
+
this.made.set(oid, {
|
|
168
|
+
type,
|
|
169
|
+
bytes
|
|
170
|
+
});
|
|
171
|
+
this.known.set(oid, {
|
|
172
|
+
type,
|
|
173
|
+
bytes
|
|
174
|
+
});
|
|
175
|
+
return oid;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/** A folder's entries, or none where a side has no folder here. */
|
|
179
|
+
entries(entry) {
|
|
180
|
+
if (entry === void 0 || !isFolder(entry)) return Effect.succeed([]);
|
|
181
|
+
const read = this.#trees.get(entry.oid);
|
|
182
|
+
if (read !== void 0) return Effect.succeed(read);
|
|
183
|
+
return Effect.mapError(this.reader.treeOf(entry.oid), fromDiff("diff-limit")).pipe(Effect.map((entries) => {
|
|
184
|
+
this.#trees.set(entry.oid, entries);
|
|
185
|
+
return entries;
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Three folders' entries collected, at `prefix`, a folder's key and `/` or none at the root.
|
|
190
|
+
* Below a folder a directory rename might move, `moved`, every folder is read.
|
|
191
|
+
*/
|
|
192
|
+
folder(prefix, sides, moved) {
|
|
193
|
+
return Effect.gen({ self: this }, function* () {
|
|
194
|
+
const byName = /* @__PURE__ */ new Map();
|
|
195
|
+
for (const [at, entries] of sides.entries()) for (const entry of entries) {
|
|
196
|
+
const key = keyOf(entry.name);
|
|
197
|
+
const three = byName.get(key) ?? [
|
|
198
|
+
void 0,
|
|
199
|
+
void 0,
|
|
200
|
+
void 0
|
|
201
|
+
];
|
|
202
|
+
if (three[at] !== void 0) {
|
|
203
|
+
const path = new TextDecoder().decode(bytesOf(prefix + key));
|
|
204
|
+
return yield* fail("DATA_LOSS", `A tree names ${path} twice`);
|
|
205
|
+
}
|
|
206
|
+
three[at] = entry;
|
|
207
|
+
byName.set(key, three);
|
|
208
|
+
}
|
|
209
|
+
for (const [name, three] of byName) yield* this.path(prefix + name, three, moved);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* One path's three entries collected. Its files are kept whatever they hold. Where a folder is
|
|
214
|
+
* among them, a side as the base had it, or without it as the base was, takes the other side's
|
|
215
|
+
* entry whole, an empty folder too, unless renames read that side: its folders' files, and the
|
|
216
|
+
* base's it deleted, may be renames' destinations and sources.
|
|
217
|
+
*/
|
|
218
|
+
path(key, three, moved) {
|
|
219
|
+
return Effect.gen({ self: this }, function* () {
|
|
220
|
+
const [base, ours, theirs] = three;
|
|
221
|
+
const folders = maskOf(three, isFolder);
|
|
222
|
+
const files = maskOf(three, (entry) => !isFolder(entry));
|
|
223
|
+
const whole = (side) => alike(base, three[side]) || !moved && !this.reads.has(side);
|
|
224
|
+
if (!moved) this.defer(key, three);
|
|
225
|
+
const taken = folders === 0 ? void 0 : alike(base, ours) && whole(2) ? { entry: theirs } : alike(base, theirs) && whole(1) ? { entry: ours } : void 0;
|
|
226
|
+
if (taken !== void 0) {
|
|
227
|
+
if (taken.entry !== void 0) this.whole.set(key, taken.entry);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (folders !== 0) {
|
|
231
|
+
for (const side of [1, 2]) if ((folders & 1) !== 0 && (folders & 1 << side) === 0) this.removed[side].add(key);
|
|
232
|
+
const below = [
|
|
233
|
+
yield* this.entries(base),
|
|
234
|
+
yield* this.entries(ours),
|
|
235
|
+
yield* this.entries(theirs)
|
|
236
|
+
];
|
|
237
|
+
const movable = this.movable(key, three, below);
|
|
238
|
+
yield* this.folder(`${key}/`, below, moved || movable);
|
|
239
|
+
}
|
|
240
|
+
if (files !== 0) this.files.set(key, [
|
|
241
|
+
fileOf(base),
|
|
242
|
+
fileOf(ours),
|
|
243
|
+
fileOf(theirs)
|
|
244
|
+
]);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Where Git's merge reads a side's folder late, after every other path, which orders its
|
|
249
|
+
* renames: the side has a folder here that isn't the base's, the other side has the base's
|
|
250
|
+
* entry, and no folder above is read late already. Below a folder a directory rename might
|
|
251
|
+
* move, nothing is read late.
|
|
252
|
+
*/
|
|
253
|
+
defer(key, three) {
|
|
254
|
+
for (const side of [1, 2]) {
|
|
255
|
+
const mine = three[side];
|
|
256
|
+
if (!(mine !== void 0 && isFolder(mine) && !alike(three[0], mine)) || !alike(three[0], three[otherOf(side)])) continue;
|
|
257
|
+
if (foldersAbove(key).some((folder) => this.late[side].has(folder))) continue;
|
|
258
|
+
this.late[side].add(key);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Whether a directory rename might move this folder: the base's, which one side removed and the
|
|
263
|
+
* other added a file in. It's then the removing side's to rename. Inside a virtual base, none
|
|
264
|
+
* does: Git detects no directory rename there.
|
|
265
|
+
*/
|
|
266
|
+
movable(key, three, below) {
|
|
267
|
+
if (this.depth > 0) return false;
|
|
268
|
+
const [base] = three;
|
|
269
|
+
const kept = [1, 2].filter((side) => {
|
|
270
|
+
const entry = three[side];
|
|
271
|
+
return entry !== void 0 && isFolder(entry);
|
|
272
|
+
});
|
|
273
|
+
const [side] = kept;
|
|
274
|
+
if (base === void 0 || !isFolder(base) || side === void 0 || kept.length > 1) return false;
|
|
275
|
+
const baseFiles = new Set(below[0].flatMap((entry) => isFolder(entry) ? [] : [keyOf(entry.name)]));
|
|
276
|
+
const added = below[side].some((entry) => !isFolder(entry) && !baseFiles.has(keyOf(entry.name)));
|
|
277
|
+
if (added) this.moving[otherOf(side)].add(key);
|
|
278
|
+
return added;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Whether `side`'s rename of the base's file at `key` matters to the merge: the other side
|
|
282
|
+
* changed or deleted it, or it's below a folder a directory rename may move.
|
|
283
|
+
*/
|
|
284
|
+
relevant(side, key) {
|
|
285
|
+
const three = this.files.get(key);
|
|
286
|
+
if (three === void 0) return false;
|
|
287
|
+
if (!same(three[otherOf(side)], three[0])) return true;
|
|
288
|
+
return foldersAbove(key).some((folder) => this.moving[side].has(folder));
|
|
289
|
+
}
|
|
290
|
+
/** The sides with a rename source that matters: their folders are read for its destination. */
|
|
291
|
+
renaming() {
|
|
292
|
+
const sides = /* @__PURE__ */ new Set();
|
|
293
|
+
for (const [key, three] of this.files) {
|
|
294
|
+
if (three[0] === void 0) continue;
|
|
295
|
+
for (const side of [1, 2]) if (three[side] === void 0 && this.relevant(side, key)) sides.add(side);
|
|
296
|
+
}
|
|
297
|
+
return sides;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Every collected path resolved, its renames and directory renames applied: the files of the
|
|
301
|
+
* merged tree, each path's that conflicts marked.
|
|
302
|
+
*/
|
|
303
|
+
resolve() {
|
|
304
|
+
return Effect.gen({ self: this }, function* () {
|
|
305
|
+
const items = /* @__PURE__ */ new Map();
|
|
306
|
+
for (const [key, three] of this.files) {
|
|
307
|
+
const added = [1, 2].filter((side) => three[side] !== void 0);
|
|
308
|
+
const newOn = three[0] === void 0 && added.length === 1 ? added[0] : void 0;
|
|
309
|
+
items.set(key, {
|
|
310
|
+
at: key,
|
|
311
|
+
three: [...three],
|
|
312
|
+
newOn,
|
|
313
|
+
conflict: false
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
const renamed = (side) => Effect.gen({ self: this }, function* () {
|
|
317
|
+
const found = yield* Effect.mapError(renamesOf(this.reader, this.files, side, (key) => this.relevant(side, key), this.late[side], (key) => this.scoredAs(key)), fromDiff("diff-limit"));
|
|
318
|
+
if (found.renamesSkipped !== void 0) this.renamesSkipped.add(found.renamesSkipped);
|
|
319
|
+
return found.renames;
|
|
320
|
+
});
|
|
321
|
+
const found = {
|
|
322
|
+
1: yield* renamed(1),
|
|
323
|
+
2: yield* renamed(2)
|
|
324
|
+
};
|
|
325
|
+
const folderRenames = (side) => this.depth > 0 ? {
|
|
326
|
+
renames: /* @__PURE__ */ new Map(),
|
|
327
|
+
split: false
|
|
328
|
+
} : folderRenamesOf(found[side], this.removed[side], this.moving[side]);
|
|
329
|
+
const folders = {
|
|
330
|
+
1: folderRenames(1),
|
|
331
|
+
2: folderRenames(2)
|
|
332
|
+
};
|
|
333
|
+
const renames = yield* this.relocated(items, found, folders);
|
|
334
|
+
yield* this.renamed(items, renames);
|
|
335
|
+
yield* this.moved(items, folders);
|
|
336
|
+
const byAt = /* @__PURE__ */ new Map();
|
|
337
|
+
for (const item of items.values()) byAt.set(item.at, [...byAt.get(item.at) ?? [], item]);
|
|
338
|
+
const out = /* @__PURE__ */ new Map();
|
|
339
|
+
for (const [at, landed] of byAt) {
|
|
340
|
+
const [item] = landed;
|
|
341
|
+
if (item === void 0) continue;
|
|
342
|
+
if (landed.length > 1 || item.conflict) {
|
|
343
|
+
const kept = landed.flatMap(({ three }) => [three[1], three[2]]).find(Boolean);
|
|
344
|
+
this.conflicts.add(at);
|
|
345
|
+
if (kept !== void 0) out.set(at, kept);
|
|
346
|
+
else this.fileless.add(at);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
const marks = item.named === void 0 ? void 0 : {
|
|
350
|
+
...item.named,
|
|
351
|
+
longer: 0
|
|
352
|
+
};
|
|
353
|
+
const resolved = yield* this.file(at, item.three, marks);
|
|
354
|
+
if (!resolved.clean) this.conflicts.add(at);
|
|
355
|
+
if (resolved.entry !== void 0) out.set(at, resolved.entry);
|
|
356
|
+
else if (!resolved.clean) this.fileless.add(at);
|
|
357
|
+
}
|
|
358
|
+
return out;
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
/** Each side's file renames applied: the other side's source moved to the destination. */
|
|
362
|
+
renamed(items, renames) {
|
|
363
|
+
return Effect.gen({ self: this }, function* () {
|
|
364
|
+
const both = /* @__PURE__ */ new Set();
|
|
365
|
+
for (const side of [1, 2]) {
|
|
366
|
+
const other = otherOf(side);
|
|
367
|
+
for (const [source, destination] of renames[side]) {
|
|
368
|
+
const from = items.get(source);
|
|
369
|
+
const to = items.get(destination);
|
|
370
|
+
if (from === void 0 || to === void 0 || both.has(source)) continue;
|
|
371
|
+
const elsewhere = renames[other].get(source);
|
|
372
|
+
if (elsewhere === destination) {
|
|
373
|
+
both.add(source);
|
|
374
|
+
to.three[0] = from.three[0];
|
|
375
|
+
items.delete(source);
|
|
376
|
+
} else if (elsewhere !== void 0 && this.depth > 0) {
|
|
377
|
+
both.add(source);
|
|
378
|
+
const destinations = side === 1 ? {
|
|
379
|
+
1: destination,
|
|
380
|
+
2: elsewhere
|
|
381
|
+
} : {
|
|
382
|
+
1: elsewhere,
|
|
383
|
+
2: destination
|
|
384
|
+
};
|
|
385
|
+
yield* this.apart(items, source, destinations);
|
|
386
|
+
} else if (elsewhere !== void 0) {
|
|
387
|
+
both.add(source);
|
|
388
|
+
for (const key of [
|
|
389
|
+
source,
|
|
390
|
+
destination,
|
|
391
|
+
elsewhere
|
|
392
|
+
]) {
|
|
393
|
+
const item = items.get(key);
|
|
394
|
+
if (item !== void 0) item.conflict = true;
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
397
|
+
const [base] = from.three;
|
|
398
|
+
const kept = from.three[other];
|
|
399
|
+
const retyped = kept !== void 0 && base !== void 0 && kindOf(kept.mode) !== kindOf(base.mode);
|
|
400
|
+
const left = retyped ? void 0 : kept;
|
|
401
|
+
const moved = to.three[side];
|
|
402
|
+
const paired = side === 1 ? [
|
|
403
|
+
base,
|
|
404
|
+
moved,
|
|
405
|
+
left
|
|
406
|
+
] : [
|
|
407
|
+
base,
|
|
408
|
+
left,
|
|
409
|
+
moved
|
|
410
|
+
];
|
|
411
|
+
const added = to.three[other];
|
|
412
|
+
const asRenamed = same(added, moved);
|
|
413
|
+
const asBoth = asRenamed && side === 2;
|
|
414
|
+
const named = side === 1 ? {
|
|
415
|
+
ours: destination,
|
|
416
|
+
theirs: source
|
|
417
|
+
} : {
|
|
418
|
+
ours: source,
|
|
419
|
+
theirs: destination
|
|
420
|
+
};
|
|
421
|
+
const merged = added !== void 0 && left !== void 0 && !asBoth ? yield* this.file(source, paired, {
|
|
422
|
+
...named,
|
|
423
|
+
longer: 1
|
|
424
|
+
}) : void 0;
|
|
425
|
+
let taken;
|
|
426
|
+
if (merged?.marked !== void 0) {
|
|
427
|
+
if (asRenamed && merged.entry !== void 0) taken = {
|
|
428
|
+
...merged.entry,
|
|
429
|
+
oid: yield* this.write("blob", merged.marked)
|
|
430
|
+
};
|
|
431
|
+
} else if (merged !== void 0) {
|
|
432
|
+
if (same(added, merged.entry)) taken = added;
|
|
433
|
+
else if (asRenamed && merged.clean) taken = merged.entry;
|
|
434
|
+
}
|
|
435
|
+
const conflicted = left === void 0 || added !== void 0 && !asBoth && taken === void 0;
|
|
436
|
+
const own = merged?.clean === true ? merged.entry : void 0;
|
|
437
|
+
if (this.depth > 0 && conflicted) {
|
|
438
|
+
const renamedFile = own ?? moved;
|
|
439
|
+
if (added === void 0) to.three = [
|
|
440
|
+
base,
|
|
441
|
+
base,
|
|
442
|
+
base
|
|
443
|
+
];
|
|
444
|
+
else to.three = side === 1 ? [
|
|
445
|
+
void 0,
|
|
446
|
+
renamedFile,
|
|
447
|
+
added
|
|
448
|
+
] : [
|
|
449
|
+
void 0,
|
|
450
|
+
added,
|
|
451
|
+
renamedFile
|
|
452
|
+
];
|
|
453
|
+
} else {
|
|
454
|
+
if (conflicted) to.conflict = true;
|
|
455
|
+
to.three = added === void 0 ? paired : taken !== void 0 ? [
|
|
456
|
+
base,
|
|
457
|
+
taken,
|
|
458
|
+
taken
|
|
459
|
+
] : [
|
|
460
|
+
base,
|
|
461
|
+
to.three[1],
|
|
462
|
+
to.three[2]
|
|
463
|
+
];
|
|
464
|
+
if (added === void 0) to.named = named;
|
|
465
|
+
}
|
|
466
|
+
if (!retyped) items.delete(source);
|
|
467
|
+
else from.three = other === 1 ? [
|
|
468
|
+
void 0,
|
|
469
|
+
kept,
|
|
470
|
+
void 0
|
|
471
|
+
] : [
|
|
472
|
+
void 0,
|
|
473
|
+
void 0,
|
|
474
|
+
kept
|
|
475
|
+
];
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* A rename/rename inside a virtual base: the base's file merged with each side's renamed one, at
|
|
483
|
+
* both destinations, its markers naming them and one longer, and the source gone; a file the
|
|
484
|
+
* other side added at a destination merges two-way with it there. Measured against git 2.53.0;
|
|
485
|
+
* another file at the source isn't, and conflicts.
|
|
486
|
+
*/
|
|
487
|
+
apart(items, source, destinations) {
|
|
488
|
+
return Effect.gen({ self: this }, function* () {
|
|
489
|
+
const from = items.get(source);
|
|
490
|
+
const one = items.get(destinations[1]);
|
|
491
|
+
const two = items.get(destinations[2]);
|
|
492
|
+
if (from === void 0 || one === void 0 || two === void 0) return;
|
|
493
|
+
const [base, oursThere, theirsThere] = from.three;
|
|
494
|
+
const [, ours, besideOurs] = one.three;
|
|
495
|
+
const [, besideTheirs, theirs] = two.three;
|
|
496
|
+
const alone = [
|
|
497
|
+
oursThere,
|
|
498
|
+
theirsThere,
|
|
499
|
+
one.three[0],
|
|
500
|
+
two.three[0]
|
|
501
|
+
];
|
|
502
|
+
const merged = base !== void 0 && ours !== void 0 && theirs !== void 0 && alone.every((entry) => entry === void 0) && kindOf(ours.mode) === kindOf(theirs.mode) ? yield* this.file(source, [
|
|
503
|
+
base,
|
|
504
|
+
ours,
|
|
505
|
+
theirs
|
|
506
|
+
], {
|
|
507
|
+
ours: destinations[1],
|
|
508
|
+
theirs: destinations[2],
|
|
509
|
+
longer: 1
|
|
510
|
+
}) : void 0;
|
|
511
|
+
if (merged?.clean !== true || merged.entry === void 0) {
|
|
512
|
+
for (const item of [
|
|
513
|
+
from,
|
|
514
|
+
one,
|
|
515
|
+
two
|
|
516
|
+
]) item.conflict = true;
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
one.three = [
|
|
520
|
+
void 0,
|
|
521
|
+
merged.entry,
|
|
522
|
+
besideOurs ?? merged.entry
|
|
523
|
+
];
|
|
524
|
+
two.three = [
|
|
525
|
+
void 0,
|
|
526
|
+
besideTheirs ?? merged.entry,
|
|
527
|
+
merged.entry
|
|
528
|
+
];
|
|
529
|
+
items.delete(source);
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Each side's file renames whose destination is below a folder the other side renamed, moved
|
|
534
|
+
* there before they're paired, as Git's "file location" conflict moves them: the file lands at
|
|
535
|
+
* its new place, conflicting there, and a path the other side's rename takes away takes the
|
|
536
|
+
* conflict with it. A rename moved back to its source is none, unless it's theirs's and ours
|
|
537
|
+
* renamed the source too, which Git pairs as rename/rename: measured against git 2.53.0. A rename
|
|
538
|
+
* whose new place is taken, in the way in its side's tree, or another of its side's renames' new
|
|
539
|
+
* place too, stays, and leaves no path placed.
|
|
540
|
+
*/
|
|
541
|
+
relocated(items, found, folders) {
|
|
542
|
+
return Effect.gen({ self: this }, function* () {
|
|
543
|
+
const renames = {
|
|
544
|
+
1: new Map(found[1]),
|
|
545
|
+
2: new Map(found[2])
|
|
546
|
+
};
|
|
547
|
+
const moves = [];
|
|
548
|
+
const movers = /* @__PURE__ */ new Map();
|
|
549
|
+
for (const side of [1, 2]) {
|
|
550
|
+
const other = otherOf(side);
|
|
551
|
+
for (const [source, destination] of found[side]) {
|
|
552
|
+
const to = movedBy(destination, folders[other], folders[side]);
|
|
553
|
+
if (to === void 0 || items.get(destination)?.three[side] === void 0) continue;
|
|
554
|
+
moves.push({
|
|
555
|
+
side,
|
|
556
|
+
source,
|
|
557
|
+
destination,
|
|
558
|
+
to
|
|
559
|
+
});
|
|
560
|
+
movers.set(`${side} ${to}`, (movers.get(`${side} ${to}`) ?? 0) + 1);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
for (const { side, source, destination, to } of moves) {
|
|
564
|
+
const from = items.get(destination);
|
|
565
|
+
const file = from?.three[side];
|
|
566
|
+
if (from === void 0 || file === void 0) continue;
|
|
567
|
+
if ((movers.get(`${side} ${to}`) ?? 0) > 1) {
|
|
568
|
+
this.unplaced = true;
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
const empty = {
|
|
572
|
+
at: to,
|
|
573
|
+
three: [
|
|
574
|
+
void 0,
|
|
575
|
+
void 0,
|
|
576
|
+
void 0
|
|
577
|
+
],
|
|
578
|
+
newOn: void 0,
|
|
579
|
+
conflict: false
|
|
580
|
+
};
|
|
581
|
+
const target = items.get(to) ?? empty;
|
|
582
|
+
if (target.three[side] !== void 0 || (yield* this.entryAt(side, to)) !== void 0) {
|
|
583
|
+
this.unplaced = true;
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
from.three[side] = void 0;
|
|
587
|
+
if (from.three.every((entry) => entry === void 0)) items.delete(destination);
|
|
588
|
+
target.three[side] = file;
|
|
589
|
+
items.set(to, {
|
|
590
|
+
...target,
|
|
591
|
+
newOn: void 0,
|
|
592
|
+
conflict: true
|
|
593
|
+
});
|
|
594
|
+
if (to !== source || side === 2 && found[1].has(source)) renames[side].set(source, to);
|
|
595
|
+
else renames[side].delete(source);
|
|
596
|
+
}
|
|
597
|
+
return renames;
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Each side's directory renames applied to the paths the other side added below them: moved,
|
|
602
|
+
* and conflicting where they land. Several moving to one path stay, and so does a folder split,
|
|
603
|
+
* or a path whose new place holds a file or a folder in the tree of the side that added it.
|
|
604
|
+
*/
|
|
605
|
+
moved(items, folders) {
|
|
606
|
+
return Effect.gen({ self: this }, function* () {
|
|
607
|
+
const landing = /* @__PURE__ */ new Map();
|
|
608
|
+
for (const side of [1, 2]) {
|
|
609
|
+
const mine = folders[side];
|
|
610
|
+
const theirs = folders[otherOf(side)];
|
|
611
|
+
if (mine.split) this.unplaced = true;
|
|
612
|
+
for (const item of items.values()) {
|
|
613
|
+
const to = item.newOn === otherOf(side) ? movedBy(item.at, mine, theirs) : void 0;
|
|
614
|
+
if (to !== void 0) landing.set(to, [...landing.get(to) ?? [], item]);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
for (const [to, movers] of landing) {
|
|
618
|
+
const [item] = movers;
|
|
619
|
+
if (item === void 0) continue;
|
|
620
|
+
const inTheWay = item.newOn !== void 0 && (yield* this.entryAt(item.newOn, to)) !== void 0;
|
|
621
|
+
if (movers.length > 1 || inTheWay) this.unplaced = true;
|
|
622
|
+
else {
|
|
623
|
+
item.at = to;
|
|
624
|
+
item.conflict = true;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* A path's files merged, a folder on a side read as no file. Inside a virtual base, what
|
|
631
|
+
* conflicts takes the base's file, or none, as Git's does: a modify/delete, or files of two
|
|
632
|
+
* kinds. Measured against git 2.53.0.
|
|
633
|
+
*/
|
|
634
|
+
file(at, three, marks) {
|
|
635
|
+
const [base, ours, theirs] = three;
|
|
636
|
+
const inside = this.depth > 0;
|
|
637
|
+
if (same(ours, theirs)) return Effect.succeed({
|
|
638
|
+
entry: ours,
|
|
639
|
+
clean: true
|
|
640
|
+
});
|
|
641
|
+
if (alike(base, ours)) return Effect.succeed({
|
|
642
|
+
entry: theirs,
|
|
643
|
+
clean: true
|
|
644
|
+
});
|
|
645
|
+
if (alike(base, theirs)) return Effect.succeed({
|
|
646
|
+
entry: ours,
|
|
647
|
+
clean: true
|
|
648
|
+
});
|
|
649
|
+
if (ours !== void 0 && theirs !== void 0) {
|
|
650
|
+
if (kindOf(ours.mode) !== kindOf(theirs.mode)) return Effect.succeed(inside ? {
|
|
651
|
+
entry: base,
|
|
652
|
+
clean: true
|
|
653
|
+
} : {
|
|
654
|
+
entry: void 0,
|
|
655
|
+
clean: false
|
|
656
|
+
});
|
|
657
|
+
return this.content(at, base, ours, theirs, marks);
|
|
658
|
+
}
|
|
659
|
+
const left = ours ?? theirs;
|
|
660
|
+
if (inside) return Effect.succeed({
|
|
661
|
+
entry: left === void 0 ? void 0 : base,
|
|
662
|
+
clean: true
|
|
663
|
+
});
|
|
664
|
+
return Effect.succeed({
|
|
665
|
+
entry: left,
|
|
666
|
+
clean: left === void 0
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Two files of one kind merged over the base's: their mode, then their content. A text
|
|
671
|
+
* conflict's markers name `marks`'s paths, if given. Inside a virtual base, a text conflict is
|
|
672
|
+
* its markers, and a mode conflict takes ours's; a symlink or a gitlink both sides changed takes
|
|
673
|
+
* the base's entry, or none.
|
|
674
|
+
*/
|
|
675
|
+
content(at, base, ours, theirs, marks) {
|
|
676
|
+
return Effect.gen({ self: this }, function* () {
|
|
677
|
+
const inside = this.depth > 0;
|
|
678
|
+
const baseMode = base?.mode;
|
|
679
|
+
const modeClean = inside || ours.mode === theirs.mode || ours.mode === baseMode || theirs.mode === baseMode;
|
|
680
|
+
const mode = ours.mode === theirs.mode || ours.mode === baseMode ? theirs.mode : ours.mode;
|
|
681
|
+
const entry = (oid, clean) => ({
|
|
682
|
+
entry: {
|
|
683
|
+
mode,
|
|
684
|
+
name: ours.name,
|
|
685
|
+
oid
|
|
686
|
+
},
|
|
687
|
+
clean: clean && modeClean
|
|
688
|
+
});
|
|
689
|
+
if (ours.oid === theirs.oid || ours.oid === base?.oid) return entry(theirs.oid, true);
|
|
690
|
+
if (theirs.oid === base?.oid) return entry(ours.oid, true);
|
|
691
|
+
if (kindOf(ours.mode) !== "100644") return inside ? {
|
|
692
|
+
entry: base,
|
|
693
|
+
clean: true
|
|
694
|
+
} : entry(ours.oid, false);
|
|
695
|
+
const attributes = yield* this.attributesOf(at);
|
|
696
|
+
const over = baseOf(base, ours);
|
|
697
|
+
const { merge } = attributes;
|
|
698
|
+
const driver = merge.state === "value" ? merge.value : merge.state;
|
|
699
|
+
const size = markerSizeOf(attributes) + 2 * this.depth + (marks?.longer ?? 0);
|
|
700
|
+
const labels = inside || marks !== void 0 ? this.labelsOf(size, marks, inside) : void 0;
|
|
701
|
+
const named = marks === void 0 ? "" : `\0${marks.ours}\0${marks.theirs}`;
|
|
702
|
+
const key = `${driver} ${size} ${over?.oid ?? ""} ${ours.oid} ${theirs.oid}${named}`;
|
|
703
|
+
const content = this.#contents.get(key) ?? (yield* this.merged(at, over, ours, theirs, attributes, labels));
|
|
704
|
+
this.#contents.set(key, content);
|
|
705
|
+
if (content.kind === "conflict" && inside) return entry(yield* this.write("blob", content.bytes), true);
|
|
706
|
+
if (content.kind === "conflict") {
|
|
707
|
+
const kept = entry(ours.oid, false);
|
|
708
|
+
return content.reason === "text" ? {
|
|
709
|
+
...kept,
|
|
710
|
+
marked: content.bytes
|
|
711
|
+
} : kept;
|
|
712
|
+
}
|
|
713
|
+
this.made.set(content.oid, {
|
|
714
|
+
type: "blob",
|
|
715
|
+
bytes: content.bytes
|
|
716
|
+
});
|
|
717
|
+
return entry(content.oid, true);
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* The attributes a file both sides changed merges with: ours's, once neither side's give it what
|
|
722
|
+
* the engine doesn't run.
|
|
723
|
+
*/
|
|
724
|
+
attributesOf(at) {
|
|
725
|
+
return Effect.gen({ self: this }, function* () {
|
|
726
|
+
const given = {
|
|
727
|
+
1: yield* this.attributesAt(at, 1),
|
|
728
|
+
2: yield* this.attributesAt(at, 2)
|
|
729
|
+
};
|
|
730
|
+
for (const side of [1, 2]) {
|
|
731
|
+
const refused = refusedAttribute(given[side]);
|
|
732
|
+
if (refused === void 0) continue;
|
|
733
|
+
const path = new TextDecoder().decode(bytesOf(at));
|
|
734
|
+
return yield* fail("FAILED_PRECONDITION", `${path} merges with ${refused} in ${side === 1 ? "ours" : "theirs"}'s .gitattributes, which the merge doesn't run`, {
|
|
735
|
+
context: {
|
|
736
|
+
reason: "unsupported-attribute",
|
|
737
|
+
attribute: refused,
|
|
738
|
+
paths: [path],
|
|
739
|
+
total: 1
|
|
740
|
+
},
|
|
741
|
+
hint: "Merge it with Git, where the driver or filter is configured"
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
return given[1];
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* How a rename scores the file at `key`, by the `diff` ours's `.gitattributes` give it, as Git
|
|
749
|
+
* 2.53.0's merge reads it with `--attr-source=<ours>`: set as text, unset, as `binary` unsets
|
|
750
|
+
* it, as binary, and a driver's name or none by its bytes, since a driver's `binary` is client
|
|
751
|
+
* config.
|
|
752
|
+
*/
|
|
753
|
+
scoredAs(key) {
|
|
754
|
+
return Effect.map(this.attributesAt(key, 1), ({ diff }) => scoredByDiff[diff.state]);
|
|
755
|
+
}
|
|
756
|
+
/** `side`'s entry at `key`, a file or a folder, read down from its root. */
|
|
757
|
+
entryAt(side, key) {
|
|
758
|
+
return Effect.gen({ self: this }, function* () {
|
|
759
|
+
const names = key.split("/");
|
|
760
|
+
let entries = this.roots[side];
|
|
761
|
+
for (const name of names.slice(0, -1)) {
|
|
762
|
+
const folder = entries.find((entry) => isFolder(entry) && keyOf(entry.name) === name);
|
|
763
|
+
if (folder === void 0) return void 0;
|
|
764
|
+
entries = yield* this.entries(folder);
|
|
765
|
+
}
|
|
766
|
+
return entries.find((entry) => keyOf(entry.name) === names.at(-1));
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* The attributes `side`'s `.gitattributes` give the file at `key`, from each folder above it:
|
|
771
|
+
* the outer merge's side's, inside a virtual base too, as Git reads its one attribute source.
|
|
772
|
+
*/
|
|
773
|
+
attributesAt(key, side) {
|
|
774
|
+
return Effect.gen({ self: this }, function* () {
|
|
775
|
+
const names = key.split("/");
|
|
776
|
+
const files = [];
|
|
777
|
+
let entries = this.attributeRoots[side];
|
|
778
|
+
for (let depth = 0; depth < names.length; depth += 1) {
|
|
779
|
+
const folder = names.slice(0, depth).join("/");
|
|
780
|
+
const found = entries.find((entry) => !isFolder(entry) && entry.mode !== "160000" && keyOf(entry.name) === ".gitattributes");
|
|
781
|
+
if (found !== void 0) files.push({
|
|
782
|
+
folder,
|
|
783
|
+
file: yield* this.attributesFile(found.oid)
|
|
784
|
+
});
|
|
785
|
+
const below = entries.find((entry) => isFolder(entry) && keyOf(entry.name) === names[depth]);
|
|
786
|
+
if (below === void 0 || depth === names.length - 1) break;
|
|
787
|
+
entries = yield* this.entries(below);
|
|
788
|
+
}
|
|
789
|
+
return pathAttributesOf(yield* attributesFor(files, key, this.checkpoint));
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
/** A `.gitattributes` blob, read once, and what reading it holds charged before it's read. */
|
|
793
|
+
attributesFile(oid) {
|
|
794
|
+
const read = this.#attributes.get(oid);
|
|
795
|
+
if (read !== void 0) return Effect.succeed(read);
|
|
796
|
+
return Effect.gen({ self: this }, function* () {
|
|
797
|
+
const bytes = yield* Effect.mapError(this.reader.bytesOf(oid, "blob"), fromDiff("diff-limit"));
|
|
798
|
+
yield* Effect.mapError(this.reader.charge(parsedBytes(bytes)), fromDiff("diff-limit"));
|
|
799
|
+
const file = parseAttributes(bytes);
|
|
800
|
+
this.#attributes.set(oid, file);
|
|
801
|
+
return file;
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
/** The markers' labels: `size` long, each side's label, `marks` its path, if any, after it. */
|
|
805
|
+
labelsOf(size, marks, virtual) {
|
|
806
|
+
return {
|
|
807
|
+
size,
|
|
808
|
+
ours: labelled(this.labels.ours, marks?.ours),
|
|
809
|
+
theirs: labelled(this.labels.theirs, marks?.theirs),
|
|
810
|
+
virtual
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
/** Two files' content merged through xdiff over the base's, if it's a file of their kind. */
|
|
814
|
+
merged(at, base, ours, theirs, attributes, labels) {
|
|
815
|
+
return Effect.gen({ self: this }, function* () {
|
|
816
|
+
const read = (oid) => Effect.mapError(this.reader.bytesOf(oid, "blob"), fromDiff("diff-limit"));
|
|
817
|
+
const sides = {
|
|
818
|
+
base: base === void 0 ? void 0 : yield* read(base.oid),
|
|
819
|
+
ours: yield* read(ours.oid),
|
|
820
|
+
theirs: yield* read(theirs.oid)
|
|
821
|
+
};
|
|
822
|
+
const merged = yield* Effect.flatMap(this.xdiff, (xdiff) => mergeContent(xdiff, sides, attributes, defaultContentConfig, labels)).pipe(Effect.catchIf((error) => error instanceof XdiffDefect, Effect.die));
|
|
823
|
+
if (merged.kind === "refused") {
|
|
824
|
+
const shown = new TextDecoder().decode(bytesOf(at));
|
|
825
|
+
return yield* Effect.fail(gitError("RESOURCE_EXHAUSTED", `${shown} is too large to merge: ${merged.why}`, { context: { reason: "too-large" } }));
|
|
826
|
+
}
|
|
827
|
+
if (merged.kind === "conflict") return {
|
|
828
|
+
kind: "conflict",
|
|
829
|
+
reason: merged.reason,
|
|
830
|
+
bytes: Uint8Array.from(merged.bytes)
|
|
831
|
+
};
|
|
832
|
+
const bytes = Uint8Array.from(merged.bytes);
|
|
833
|
+
return {
|
|
834
|
+
kind: "clean",
|
|
835
|
+
oid: yield* this.write("blob", bytes),
|
|
836
|
+
bytes
|
|
837
|
+
};
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
/** The merged root's entries, from the merged files and the entries taken whole. */
|
|
841
|
+
build(files) {
|
|
842
|
+
const root = {
|
|
843
|
+
entry: void 0,
|
|
844
|
+
below: /* @__PURE__ */ new Map()
|
|
845
|
+
};
|
|
846
|
+
for (const [key, entry] of [...this.whole, ...files]) {
|
|
847
|
+
let node = root;
|
|
848
|
+
for (const name of key.split("/")) {
|
|
849
|
+
const next = node.below.get(name) ?? {
|
|
850
|
+
entry: void 0,
|
|
851
|
+
below: /* @__PURE__ */ new Map()
|
|
852
|
+
};
|
|
853
|
+
node.below.set(name, next);
|
|
854
|
+
node = next;
|
|
855
|
+
}
|
|
856
|
+
node.entry = entry;
|
|
857
|
+
}
|
|
858
|
+
return this.tree("", root);
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* A node's entries written: a folder with something below it, a file where no folder stays, and
|
|
862
|
+
* a file a folder stays at a conflict, moved beside it inside a virtual base. A folder taken
|
|
863
|
+
* whole that more lands in is read.
|
|
864
|
+
*/
|
|
865
|
+
tree(prefix, node) {
|
|
866
|
+
return Effect.gen({ self: this }, function* () {
|
|
867
|
+
const out = [];
|
|
868
|
+
for (const [name, child] of node.below) {
|
|
869
|
+
const key = prefix + name;
|
|
870
|
+
const bytes = bytesOf(name);
|
|
871
|
+
if (child.entry !== void 0 && isFolder(child.entry) && child.below.size > 0) {
|
|
872
|
+
for (const inside of yield* this.entries(child.entry)) {
|
|
873
|
+
const named = keyOf(inside.name);
|
|
874
|
+
if (!child.below.has(named)) child.below.set(named, {
|
|
875
|
+
entry: inside,
|
|
876
|
+
below: /* @__PURE__ */ new Map()
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
child.entry = void 0;
|
|
880
|
+
}
|
|
881
|
+
const below = child.below.size > 0 ? yield* this.tree(`${key}/`, child) : [];
|
|
882
|
+
if (below.length > 0) {
|
|
883
|
+
out.push({
|
|
884
|
+
mode: "040000",
|
|
885
|
+
name: bytes,
|
|
886
|
+
oid: yield* this.write("tree", treeBytes(below))
|
|
887
|
+
});
|
|
888
|
+
const beside = child.entry !== void 0 && this.depth > 0 ? yield* this.beside(key, name, node.below, child.entry) : void 0;
|
|
889
|
+
if (beside !== void 0) out.push(beside);
|
|
890
|
+
else if (child.entry !== void 0) this.conflicts.add(key);
|
|
891
|
+
else if (this.fileless.has(key)) this.conflicts.delete(key);
|
|
892
|
+
} else if (child.entry !== void 0) out.push({
|
|
893
|
+
mode: child.entry.mode,
|
|
894
|
+
name: bytes,
|
|
895
|
+
oid: child.entry.oid
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
return out;
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Inside a virtual base, a file a folder stays at, moved beside it to `<name>~<label>`, the label
|
|
903
|
+
* of the side whose file it is, or `_0`, `_1` and on after it where a name is taken: in any of
|
|
904
|
+
* the three trees, the merge, or by a file moved before. Measured against git 2.53.0; a file
|
|
905
|
+
* both sides or neither have there isn't, and conflicts.
|
|
906
|
+
*/
|
|
907
|
+
beside(key, name, siblings, entry) {
|
|
908
|
+
return Effect.gen({ self: this }, function* () {
|
|
909
|
+
const sides = [];
|
|
910
|
+
for (const side of [1, 2]) {
|
|
911
|
+
const found = yield* this.entryAt(side, key);
|
|
912
|
+
if (found !== void 0 && !isFolder(found)) sides.push(side);
|
|
913
|
+
}
|
|
914
|
+
const [side] = sides;
|
|
915
|
+
if (side === void 0 || sides.length > 1) return void 0;
|
|
916
|
+
const prefix = key.slice(0, key.length - name.length);
|
|
917
|
+
const named = `${name}~${side === 1 ? this.labels.ours : this.labels.theirs}`;
|
|
918
|
+
let moved = named;
|
|
919
|
+
for (let at = 0; yield* this.taken(prefix, moved, siblings); at += 1) moved = `${named}_${at}`;
|
|
920
|
+
this.besides.add(prefix + moved);
|
|
921
|
+
return {
|
|
922
|
+
mode: entry.mode,
|
|
923
|
+
name: bytesOf(moved),
|
|
924
|
+
oid: entry.oid
|
|
925
|
+
};
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
/** Whether `name` in the folder at `prefix` is in any of the three trees, or the merge's. */
|
|
929
|
+
taken(prefix, name, siblings) {
|
|
930
|
+
return Effect.gen({ self: this }, function* () {
|
|
931
|
+
if (siblings.has(name) || this.besides.has(prefix + name)) return true;
|
|
932
|
+
for (const slot of [
|
|
933
|
+
0,
|
|
934
|
+
1,
|
|
935
|
+
2
|
|
936
|
+
]) if ((yield* this.entryAt(slot, prefix + name)) !== void 0) return true;
|
|
937
|
+
return false;
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
/** The objects a merge made, each read as a stream of its bytes, as often as it's iterated. */
|
|
942
|
+
const writesOf = (made) => ({ async *[Symbol.asyncIterator]() {
|
|
943
|
+
for (const [oid, { type, bytes }] of made) yield {
|
|
944
|
+
oid,
|
|
945
|
+
type,
|
|
946
|
+
size: bytes.length,
|
|
947
|
+
bytes: streamOf(bytes)
|
|
948
|
+
};
|
|
949
|
+
} });
|
|
950
|
+
/** `read`, though an object the call's merges made is read from them. */
|
|
951
|
+
const knownFirst = (known, read) => (oid) => {
|
|
952
|
+
const made = known.get(oid);
|
|
953
|
+
return made === void 0 ? read(oid) : Effect.succeed({
|
|
954
|
+
oid,
|
|
955
|
+
type: made.type,
|
|
956
|
+
size: made.bytes.length,
|
|
957
|
+
bytes: streamOf(made.bytes)
|
|
958
|
+
});
|
|
959
|
+
};
|
|
960
|
+
/** Paths as bytes, sorted as Git sorts them and named as text. */
|
|
961
|
+
const shownPaths = (paths) => [...paths].sort((x, y) => compareEntries({
|
|
962
|
+
mode: "100644",
|
|
963
|
+
name: x
|
|
964
|
+
}, {
|
|
965
|
+
mode: "100644",
|
|
966
|
+
name: y
|
|
967
|
+
})).map((path) => new TextDecoder().decode(path));
|
|
968
|
+
/** Three roots merged at `depth`: the merge, its conflicts kept, and its root's entries. */
|
|
969
|
+
const mergeAt = (call, roots, labels, depth, attributeRoots) => Effect.gen(function* () {
|
|
970
|
+
const merge = new TreeMerge(call, roots, labels, depth, attributeRoots);
|
|
971
|
+
yield* merge.folder("", roots, false);
|
|
972
|
+
const renaming = merge.renaming();
|
|
973
|
+
if (renaming.size > 0) {
|
|
974
|
+
merge.readFoldersOf(renaming);
|
|
975
|
+
yield* merge.folder("", roots, false);
|
|
976
|
+
}
|
|
977
|
+
return {
|
|
978
|
+
merge,
|
|
979
|
+
entries: yield* merge.build(yield* merge.resolve())
|
|
980
|
+
};
|
|
981
|
+
});
|
|
982
|
+
/** A commit's root entries, or a tree's, or what a tag peels to. */
|
|
983
|
+
const rootOf = (call, oid) => Effect.mapError(call.reader.treeOf(oid), fromDiff("diff-limit"));
|
|
984
|
+
/**
|
|
985
|
+
* The commits a virtual base's merge base walks: the ones read, and each virtual base's merge, a
|
|
986
|
+
* commit of its two parents with no time, as Git's is.
|
|
987
|
+
*/
|
|
988
|
+
var VirtualCommits = class {
|
|
989
|
+
#made = /* @__PURE__ */ new Map();
|
|
990
|
+
walked;
|
|
991
|
+
constructor(walked) {
|
|
992
|
+
this.walked = walked;
|
|
993
|
+
}
|
|
994
|
+
commits = (oid) => this.walked.get(oid) ?? this.#made.get(oid);
|
|
995
|
+
/** A merge of `one` and `two`, named apart from every object ID. */
|
|
996
|
+
merged(one, two) {
|
|
997
|
+
const generation = 1 + Math.max(this.commits(one)?.generation ?? 0, this.commits(two)?.generation ?? 0);
|
|
998
|
+
const id = `virtual ${this.#made.size + 1}`;
|
|
999
|
+
this.#made.set(id, {
|
|
1000
|
+
parents: [one, two],
|
|
1001
|
+
time: 0,
|
|
1002
|
+
generation
|
|
1003
|
+
});
|
|
1004
|
+
return id;
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
1007
|
+
/**
|
|
1008
|
+
* The virtual base of merge bases, `bases` newest first, as merge-ort builds it at `depth`: the
|
|
1009
|
+
* oldest merged with each newer one in turn, over their own merge bases, the empty tree, one's
|
|
1010
|
+
* tree, or a virtual base one deeper. A conflict Git's virtual base keeps no file for, which this
|
|
1011
|
+
* doesn't build as Git does, refuses.
|
|
1012
|
+
*/
|
|
1013
|
+
const virtualBase = (call, walk, bases, depth, attributeRoots) => Effect.gen(function* () {
|
|
1014
|
+
const [first, ...rest] = [...bases].reverse();
|
|
1015
|
+
if (first === void 0) return [];
|
|
1016
|
+
let merged = {
|
|
1017
|
+
id: first,
|
|
1018
|
+
root: yield* rootOf(call, first)
|
|
1019
|
+
};
|
|
1020
|
+
for (const next of rest) {
|
|
1021
|
+
const inner = yield* Effect.mapError(mergeBasesOf(walk.commits, merged.id, [next]), fromMissing);
|
|
1022
|
+
const [only] = inner;
|
|
1023
|
+
const roots = [
|
|
1024
|
+
inner.length > 1 ? yield* virtualBase(call, walk, inner, depth + 1, attributeRoots) : only === void 0 ? [] : yield* rootOf(call, only),
|
|
1025
|
+
merged.root,
|
|
1026
|
+
yield* rootOf(call, next)
|
|
1027
|
+
];
|
|
1028
|
+
const { merge, entries } = yield* mergeAt(call, roots, temporary, depth, attributeRoots);
|
|
1029
|
+
if (merge.conflicts.size > 0 || merge.unplaced) {
|
|
1030
|
+
const paths = shownPaths([...merge.conflicts].map(bytesOf));
|
|
1031
|
+
return yield* fail("FAILED_PRECONDITION", `The merge bases' virtual base conflicts in ${paths.length} paths in a way the engine doesn't merge as Git does`, {
|
|
1032
|
+
context: {
|
|
1033
|
+
reason: "unsupported-virtual-base",
|
|
1034
|
+
paths: paths.slice(0, 100),
|
|
1035
|
+
total: paths.length
|
|
1036
|
+
},
|
|
1037
|
+
hint: "Merge it with Git, or name one of the merge bases as the base"
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
merged = {
|
|
1041
|
+
id: walk.merged(merged.id, next),
|
|
1042
|
+
root: entries
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
return merged.root;
|
|
1046
|
+
});
|
|
1047
|
+
/**
|
|
1048
|
+
* The base the two commits merge over without one given: their merge base's root, or the
|
|
1049
|
+
* virtual base of several. Unrelated histories, which Git refuses, fail.
|
|
1050
|
+
*/
|
|
1051
|
+
const basesRoot = (call, input, attributeRoots) => Effect.gen(function* () {
|
|
1052
|
+
const ours = yield* namedCommit(call.reader, input.ours);
|
|
1053
|
+
const theirs = yield* namedCommit(call.reader, input.theirs);
|
|
1054
|
+
const walk = new VirtualCommits(yield* ancestry(call.reader, [ours, theirs]));
|
|
1055
|
+
const bases = yield* Effect.mapError(mergeBasesOf(walk.commits, ours.oid, [theirs.oid]), fromMissing);
|
|
1056
|
+
const [only] = bases;
|
|
1057
|
+
if (only === void 0) return yield* fail("FAILED_PRECONDITION", `${input.ours} and ${input.theirs} share no history`, {
|
|
1058
|
+
context: { reason: "unrelated-histories" },
|
|
1059
|
+
hint: "Name the empty tree as the base to merge them, as `--allow-unrelated-histories` does"
|
|
1060
|
+
});
|
|
1061
|
+
if (bases.length === 1) return yield* rootOf(call, only);
|
|
1062
|
+
return yield* virtualBase(call, walk, bases, 1, attributeRoots);
|
|
1063
|
+
});
|
|
1064
|
+
/**
|
|
1065
|
+
* `base`, `ours` and `theirs`, each a tree or what peels to one, merged: a tree, or a conflict.
|
|
1066
|
+
* Without `base`, two commits merge over their merge bases. `load` gives xdiff for the merge's
|
|
1067
|
+
* scope, loaded once the first file's content merges. A `step` of a longer call reads within that
|
|
1068
|
+
* call's tally and deadline.
|
|
1069
|
+
*/
|
|
1070
|
+
const mergeTrees = (read, input, load, step) => Effect.scoped(Effect.gen(function* () {
|
|
1071
|
+
const limits = yield* limitsOf(input.limits);
|
|
1072
|
+
const scope = yield* Effect.scope;
|
|
1073
|
+
const xdiff = yield* Effect.cached(Effect.provideService(load, Scope.Scope, scope));
|
|
1074
|
+
const deadline = yield* stepDeadline(limits.milliseconds, "diff-limit", step);
|
|
1075
|
+
const run = Effect.gen(function* () {
|
|
1076
|
+
const known = /* @__PURE__ */ new Map();
|
|
1077
|
+
const call = {
|
|
1078
|
+
reader: new DiffReader(knownFirst(known, readThrough(read, deadline)), limits.reads, step?.tally),
|
|
1079
|
+
xdiff,
|
|
1080
|
+
deadline,
|
|
1081
|
+
known,
|
|
1082
|
+
renamesSkipped: /* @__PURE__ */ new Set()
|
|
1083
|
+
};
|
|
1084
|
+
const ours = yield* rootOf(call, input.ours);
|
|
1085
|
+
const theirs = yield* rootOf(call, input.theirs);
|
|
1086
|
+
const attributeRoots = [
|
|
1087
|
+
[],
|
|
1088
|
+
ours,
|
|
1089
|
+
theirs
|
|
1090
|
+
];
|
|
1091
|
+
const roots = [
|
|
1092
|
+
input.base === void 0 ? yield* basesRoot(call, input, attributeRoots) : yield* rootOf(call, input.base),
|
|
1093
|
+
ours,
|
|
1094
|
+
theirs
|
|
1095
|
+
];
|
|
1096
|
+
const labels = input.labels ?? {
|
|
1097
|
+
ours: input.ours,
|
|
1098
|
+
theirs: input.theirs
|
|
1099
|
+
};
|
|
1100
|
+
const { merge, entries } = yield* mergeAt(call, roots, labels, 0, roots);
|
|
1101
|
+
if (merge.conflicts.size > 0 || merge.unplaced) {
|
|
1102
|
+
const paths = shownPaths([...merge.conflicts].map(bytesOf));
|
|
1103
|
+
return yield* fail("FAILED_PRECONDITION", paths.length > 0 ? `The merge conflicts in ${paths.length} paths` : "The merge conflicts where a directory rename can't place its files", {
|
|
1104
|
+
context: {
|
|
1105
|
+
reason: "merge-conflict",
|
|
1106
|
+
paths: paths.slice(0, 100),
|
|
1107
|
+
total: paths.length
|
|
1108
|
+
},
|
|
1109
|
+
hint: "Resolve the conflicts, then merge the resolution"
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
const tree = yield* merge.write("tree", treeBytes(entries));
|
|
1113
|
+
const [renamesSkipped] = call.renamesSkipped;
|
|
1114
|
+
return renamesSkipped === void 0 ? {
|
|
1115
|
+
tree,
|
|
1116
|
+
objects: writesOf(merge.made)
|
|
1117
|
+
} : {
|
|
1118
|
+
tree,
|
|
1119
|
+
objects: writesOf(merge.made),
|
|
1120
|
+
renamesSkipped
|
|
1121
|
+
};
|
|
1122
|
+
});
|
|
1123
|
+
return yield* timed(run, deadline);
|
|
1124
|
+
}));
|
|
1125
|
+
export { mergeTrees };
|