@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.
Files changed (504) hide show
  1. package/dist/LICENSE +202 -0
  2. package/dist/access/private-refs.d.mts +27 -0
  3. package/dist/access/private-refs.mjs +173 -0
  4. package/dist/access.d.mts +2 -0
  5. package/dist/access.mjs +1 -0
  6. package/dist/auth/access-jwt.d.mts +21 -0
  7. package/dist/auth/access-jwt.mjs +102 -0
  8. package/dist/auth/acting.mjs +15 -0
  9. package/dist/auth/authorize.d.mts +5 -0
  10. package/dist/auth/authorize.mjs +292 -0
  11. package/dist/auth/credentials.mjs +57 -0
  12. package/dist/auth/fences.d.mts +5 -0
  13. package/dist/auth/fences.mjs +65 -0
  14. package/dist/auth/grants.mjs +61 -0
  15. package/dist/auth/helpers.d.mts +17 -0
  16. package/dist/auth/helpers.mjs +25 -0
  17. package/dist/auth/host-function.d.mts +4 -0
  18. package/dist/auth/host-function.mjs +69 -0
  19. package/dist/auth/identify.d.mts +6 -0
  20. package/dist/auth/identify.mjs +97 -0
  21. package/dist/auth/token-rows.mjs +100 -0
  22. package/dist/auth/token-text.mjs +66 -0
  23. package/dist/auth/tokens.d.mts +10 -0
  24. package/dist/auth/tokens.mjs +347 -0
  25. package/dist/auth.d.mts +7 -0
  26. package/dist/auth.mjs +6 -0
  27. package/dist/client/answer.mjs +141 -0
  28. package/dist/client/client.d.mts +23 -0
  29. package/dist/client/client.mjs +51 -0
  30. package/dist/client/git-http.mjs +201 -0
  31. package/dist/client/helper-node.mjs +19 -0
  32. package/dist/client/local.mjs +160 -0
  33. package/dist/client/negotiate.mjs +170 -0
  34. package/dist/client/push-upload.mjs +53 -0
  35. package/dist/client/remote-helper.mjs +129 -0
  36. package/dist/client/remote.mjs +398 -0
  37. package/dist/client/run-remote-helper.d.mts +35 -0
  38. package/dist/client/run-remote-helper.mjs +259 -0
  39. package/dist/client/scrub.d.mts +18 -0
  40. package/dist/client/scrub.mjs +38 -0
  41. package/dist/client/transport.d.mts +2 -0
  42. package/dist/client/transport.mjs +211 -0
  43. package/dist/contracts/access.d.mts +87 -0
  44. package/dist/contracts/actors.d.mts +144 -0
  45. package/dist/contracts/blobs.d.mts +38 -0
  46. package/dist/contracts/calls-spent.d.mts +11 -0
  47. package/dist/contracts/calls-spent.mjs +150 -0
  48. package/dist/contracts/client.d.mts +90 -0
  49. package/dist/contracts/commits.d.mts +126 -0
  50. package/dist/contracts/engine.d.mts +134 -0
  51. package/dist/contracts/events.d.mts +276 -0
  52. package/dist/contracts/files.d.mts +75 -0
  53. package/dist/contracts/forks.d.mts +78 -0
  54. package/dist/contracts/grants.d.mts +60 -0
  55. package/dist/contracts/handlers.d.mts +10 -0
  56. package/dist/contracts/ids.d.mts +15 -0
  57. package/dist/contracts/ids.mjs +15 -0
  58. package/dist/contracts/lfs.d.mts +27 -0
  59. package/dist/contracts/merges.d.mts +33 -0
  60. package/dist/contracts/objects.d.mts +645 -0
  61. package/dist/contracts/objects.mjs +54 -0
  62. package/dist/contracts/operations.d.mts +133 -0
  63. package/dist/contracts/promises.d.mts +63 -0
  64. package/dist/contracts/push-uploads.d.mts +44 -0
  65. package/dist/contracts/queue.d.mts +401 -0
  66. package/dist/contracts/refs.d.mts +95 -0
  67. package/dist/contracts/remote.d.mts +50 -0
  68. package/dist/contracts/repos.d.mts +153 -0
  69. package/dist/contracts/result.d.mts +126 -0
  70. package/dist/contracts/result.mjs +34 -0
  71. package/dist/contracts/rules.d.mts +159 -0
  72. package/dist/contracts/server.d.mts +245 -0
  73. package/dist/contracts/services.d.mts +36 -0
  74. package/dist/contracts/services.mjs +13 -0
  75. package/dist/contracts/signin.d.mts +126 -0
  76. package/dist/contracts/store.d.mts +41 -0
  77. package/dist/contracts/sync.d.mts +210 -0
  78. package/dist/contracts/sync.mjs +8 -0
  79. package/dist/contracts/tags.d.mts +50 -0
  80. package/dist/contracts/tags.mjs +6 -0
  81. package/dist/contracts/tokens.d.mts +87 -0
  82. package/dist/contracts/tokens.mjs +15 -0
  83. package/dist/contracts/topics.d.mts +174 -0
  84. package/dist/contracts/trees.d.mts +84 -0
  85. package/dist/contracts/work.d.mts +31 -0
  86. package/dist/core/access.d.mts +22 -0
  87. package/dist/core/access.mjs +262 -0
  88. package/dist/core/ancestry.mjs +235 -0
  89. package/dist/core/clock.mjs +18 -0
  90. package/dist/core/events/deliver.mjs +468 -0
  91. package/dist/core/events/stream.d.mts +19 -0
  92. package/dist/core/events/stream.mjs +290 -0
  93. package/dist/core/forks.mjs +1027 -0
  94. package/dist/core/hooks/post-receive.mjs +204 -0
  95. package/dist/core/hooks/pre-receive.d.mts +5 -0
  96. package/dist/core/hooks/pre-receive.mjs +34 -0
  97. package/dist/core/index-job.mjs +198 -0
  98. package/dist/core/names.mjs +30 -0
  99. package/dist/core/objects/blobs.mjs +60 -0
  100. package/dist/core/objects/commit-writes.mjs +185 -0
  101. package/dist/core/objects/commits.mjs +172 -0
  102. package/dist/core/objects/files.mjs +211 -0
  103. package/dist/core/objects/lines.mjs +42 -0
  104. package/dist/core/objects/merges.mjs +83 -0
  105. package/dist/core/objects/peel.mjs +166 -0
  106. package/dist/core/objects/reading.mjs +284 -0
  107. package/dist/core/objects/tags.mjs +96 -0
  108. package/dist/core/objects/tree-edits.mjs +266 -0
  109. package/dist/core/objects/trees.mjs +229 -0
  110. package/dist/core/objects/writing.mjs +266 -0
  111. package/dist/core/own-writes.mjs +94 -0
  112. package/dist/core/promise.mjs +46 -0
  113. package/dist/core/publish.mjs +142 -0
  114. package/dist/core/push-decide.mjs +206 -0
  115. package/dist/core/push.mjs +1069 -0
  116. package/dist/core/receipts.d.mts +7 -0
  117. package/dist/core/receipts.mjs +234 -0
  118. package/dist/core/ref-conflicts.mjs +27 -0
  119. package/dist/core/refs.mjs +359 -0
  120. package/dist/core/repack.mjs +521 -0
  121. package/dist/core/repos.mjs +752 -0
  122. package/dist/core/rules/changes.mjs +57 -0
  123. package/dist/core/rules/check.mjs +101 -0
  124. package/dist/core/rules/commit-changes.mjs +216 -0
  125. package/dist/core/rules/context.d.mts +9 -0
  126. package/dist/core/rules/context.mjs +120 -0
  127. package/dist/core/rules/define.d.mts +5 -0
  128. package/dist/core/rules/define.mjs +13 -0
  129. package/dist/core/rules/facts.mjs +13 -0
  130. package/dist/core/rules/fetch.d.mts +5 -0
  131. package/dist/core/rules/fetch.mjs +59 -0
  132. package/dist/core/rules/file-globs.mjs +55 -0
  133. package/dist/core/rules/files.mjs +142 -0
  134. package/dist/core/rules/patterns.mjs +23 -0
  135. package/dist/core/rules/protect.d.mts +9 -0
  136. package/dist/core/rules/protect.mjs +116 -0
  137. package/dist/core/seam.d.mts +24 -0
  138. package/dist/core/seam.mjs +41 -0
  139. package/dist/core/sight.mjs +99 -0
  140. package/dist/core/tokens.mjs +95 -0
  141. package/dist/core/view.d.mts +9 -0
  142. package/dist/core/view.mjs +221 -0
  143. package/dist/core/work.mjs +92 -0
  144. package/dist/effect.d.mts +20 -0
  145. package/dist/effect.mjs +18 -0
  146. package/dist/engine/allotted-xdiff.d.mts +4 -0
  147. package/dist/engine/allotted-xdiff.mjs +80 -0
  148. package/dist/engine/attribute-patterns.mjs +163 -0
  149. package/dist/engine/attributes.mjs +226 -0
  150. package/dist/engine/combined.mjs +653 -0
  151. package/dist/engine/commits.mjs +90 -0
  152. package/dist/engine/content.d.mts +4 -0
  153. package/dist/engine/content.mjs +221 -0
  154. package/dist/engine/diff.mjs +49 -0
  155. package/dist/engine/engine.d.mts +25 -0
  156. package/dist/engine/engine.mjs +49 -0
  157. package/dist/engine/failures.d.mts +4 -0
  158. package/dist/engine/failures.mjs +23 -0
  159. package/dist/engine/line-count.mjs +23 -0
  160. package/dist/engine/merge-base-walk.d.mts +2 -0
  161. package/dist/engine/merge-base-walk.mjs +265 -0
  162. package/dist/engine/merge-bases.mjs +27 -0
  163. package/dist/engine/merge-renames.mjs +165 -0
  164. package/dist/engine/merge.mjs +1125 -0
  165. package/dist/engine/parts.d.mts +8 -0
  166. package/dist/engine/parts.mjs +9 -0
  167. package/dist/engine/reads.d.mts +5 -0
  168. package/dist/engine/reads.mjs +105 -0
  169. package/dist/engine/walk.mjs +328 -0
  170. package/dist/engine/xdiff/NOTICE.md +63 -0
  171. package/dist/engine/xdiff/compiled.d.mts +7 -0
  172. package/dist/engine/xdiff/compiled.mjs +9 -0
  173. package/dist/engine/xdiff/embedded.mjs +4 -0
  174. package/dist/engine/xdiff/node.d.mts +7 -0
  175. package/dist/engine/xdiff/node.mjs +10 -0
  176. package/dist/engine/xdiff/upstream/LGPL-2.1 +511 -0
  177. package/dist/engine/xdiff/xdiff.wasm +0 -0
  178. package/dist/engine/xdiff.d.mts +34 -0
  179. package/dist/engine/xdiff.mjs +380 -0
  180. package/dist/engine.d.mts +3 -0
  181. package/dist/engine.mjs +3 -0
  182. package/dist/extend.d.mts +3 -0
  183. package/dist/extend.mjs +1 -0
  184. package/dist/http/answers.mjs +74 -0
  185. package/dist/http/bodies.mjs +143 -0
  186. package/dist/http/core-parts.mjs +252 -0
  187. package/dist/http/fetch-depth.mjs +26 -0
  188. package/dist/http/handler.mjs +94 -0
  189. package/dist/http/node.d.mts +70 -0
  190. package/dist/http/node.mjs +178 -0
  191. package/dist/http/paths.d.mts +9 -0
  192. package/dist/http/paths.mjs +118 -0
  193. package/dist/http/push-uploads.mjs +286 -0
  194. package/dist/http/receive-pack.mjs +235 -0
  195. package/dist/http/upload-pack.mjs +229 -0
  196. package/dist/index.d.mts +46 -0
  197. package/dist/index.mjs +16 -0
  198. package/dist/lfs/calls.mjs +16 -0
  199. package/dist/lfs/locks.mjs +161 -0
  200. package/dist/lfs/objects.mjs +370 -0
  201. package/dist/lfs/pointers.mjs +141 -0
  202. package/dist/lfs/repo.mjs +42 -0
  203. package/dist/lfs/rows.mjs +108 -0
  204. package/dist/lfs/service.mjs +34 -0
  205. package/dist/lfs/upkeep.mjs +162 -0
  206. package/dist/lfs/wire.mjs +102 -0
  207. package/dist/node.d.mts +3 -0
  208. package/dist/node.mjs +3 -0
  209. package/dist/protocol/bytes/buffers.d.mts +38 -0
  210. package/dist/protocol/bytes/buffers.mjs +62 -0
  211. package/dist/protocol/bytes/crc32.d.mts +4 -0
  212. package/dist/protocol/bytes/crc32.mjs +14 -0
  213. package/dist/protocol/bytes/deflate.d.mts +78 -0
  214. package/dist/protocol/bytes/deflate.mjs +175 -0
  215. package/dist/protocol/bytes/errors.d.mts +20 -0
  216. package/dist/protocol/bytes/errors.mjs +19 -0
  217. package/dist/protocol/bytes/hex.mjs +16 -0
  218. package/dist/protocol/bytes/hmac-sha256.mjs +91 -0
  219. package/dist/protocol/bytes/inflate.d.mts +40 -0
  220. package/dist/protocol/bytes/inflate.mjs +109 -0
  221. package/dist/protocol/bytes/joined.d.mts +2 -0
  222. package/dist/protocol/bytes/joined.mjs +25 -0
  223. package/dist/protocol/bytes/sha1-hasher.d.mts +20 -0
  224. package/dist/protocol/bytes/sha1-hasher.mjs +72 -0
  225. package/dist/protocol/bytes/sha1.d.mts +35 -0
  226. package/dist/protocol/bytes/sha1.mjs +409 -0
  227. package/dist/protocol/bytes/sha256.mjs +156 -0
  228. package/dist/protocol/bytes/streams.mjs +11 -0
  229. package/dist/protocol/bytes/text.mjs +19 -0
  230. package/dist/protocol/diff/diff-raw.d.mts +29 -0
  231. package/dist/protocol/diff/diff-raw.mjs +73 -0
  232. package/dist/protocol/diff/patch.mjs +92 -0
  233. package/dist/protocol/diff/paths.mjs +67 -0
  234. package/dist/protocol/diff/read.d.mts +62 -0
  235. package/dist/protocol/diff/read.mjs +342 -0
  236. package/dist/protocol/diff/rename-similarity.mjs +428 -0
  237. package/dist/protocol/diff/text.mjs +12 -0
  238. package/dist/protocol/diff/tree-diff.d.mts +41 -0
  239. package/dist/protocol/diff/tree-diff.mjs +607 -0
  240. package/dist/protocol/framing/band.d.mts +10 -0
  241. package/dist/protocol/framing/band.mjs +16 -0
  242. package/dist/protocol/framing/pkt-line.d.mts +48 -0
  243. package/dist/protocol/framing/pkt-line.mjs +92 -0
  244. package/dist/protocol/objects/checked-blobs.mjs +127 -0
  245. package/dist/protocol/objects/commit.d.mts +25 -0
  246. package/dist/protocol/objects/commit.mjs +138 -0
  247. package/dist/protocol/objects/fsck-gitmodules.mjs +296 -0
  248. package/dist/protocol/objects/fsck-names.mjs +189 -0
  249. package/dist/protocol/objects/fsck.mjs +297 -0
  250. package/dist/protocol/objects/headers.mjs +109 -0
  251. package/dist/protocol/objects/held.mjs +56 -0
  252. package/dist/protocol/objects/iconv.mjs +145 -0
  253. package/dist/protocol/objects/ident.mjs +111 -0
  254. package/dist/protocol/objects/lfs-pointer.d.mts +8 -0
  255. package/dist/protocol/objects/lfs-pointer.mjs +63 -0
  256. package/dist/protocol/objects/links-raw.mjs +89 -0
  257. package/dist/protocol/objects/object-rules.mjs +75 -0
  258. package/dist/protocol/objects/object.d.mts +16 -0
  259. package/dist/protocol/objects/object.mjs +29 -0
  260. package/dist/protocol/objects/tag.d.mts +21 -0
  261. package/dist/protocol/objects/tag.mjs +96 -0
  262. package/dist/protocol/objects/tree.d.mts +43 -0
  263. package/dist/protocol/objects/tree.mjs +162 -0
  264. package/dist/protocol/objects/utf8-verify.mjs +71 -0
  265. package/dist/protocol/packs/delta.d.mts +57 -0
  266. package/dist/protocol/packs/delta.mjs +229 -0
  267. package/dist/protocol/packs/graph.mjs +78 -0
  268. package/dist/protocol/packs/idx.d.mts +54 -0
  269. package/dist/protocol/packs/idx.mjs +274 -0
  270. package/dist/protocol/packs/indexer.d.mts +167 -0
  271. package/dist/protocol/packs/indexer.mjs +507 -0
  272. package/dist/protocol/packs/parts.d.mts +40 -0
  273. package/dist/protocol/packs/parts.mjs +89 -0
  274. package/dist/protocol/packs/pos.mjs +51 -0
  275. package/dist/protocol/packs/reader.d.mts +180 -0
  276. package/dist/protocol/packs/reader.mjs +414 -0
  277. package/dist/protocol/packs/rev.d.mts +32 -0
  278. package/dist/protocol/packs/rev.mjs +99 -0
  279. package/dist/protocol/packs/step.d.mts +10 -0
  280. package/dist/protocol/packs/step.mjs +12 -0
  281. package/dist/protocol/packs/write-error.d.mts +12 -0
  282. package/dist/protocol/packs/write-error.mjs +27 -0
  283. package/dist/protocol/packs/writer.d.mts +157 -0
  284. package/dist/protocol/packs/writer.mjs +353 -0
  285. package/dist/protocol/wire/advertisement.d.mts +72 -0
  286. package/dist/protocol/wire/advertisement.mjs +161 -0
  287. package/dist/protocol/wire/fetch.d.mts +155 -0
  288. package/dist/protocol/wire/fetch.mjs +458 -0
  289. package/dist/protocol/wire/lines.mjs +107 -0
  290. package/dist/protocol/wire/push-uploads.mjs +43 -0
  291. package/dist/protocol/wire/receive-pack.d.mts +71 -0
  292. package/dist/protocol/wire/receive-pack.mjs +157 -0
  293. package/dist/protocol/wire/report-status.d.mts +47 -0
  294. package/dist/protocol/wire/report-status.mjs +119 -0
  295. package/dist/protocol/wire/v2.d.mts +90 -0
  296. package/dist/protocol/wire/v2.mjs +185 -0
  297. package/dist/protocol.d.mts +31 -0
  298. package/dist/protocol.mjs +31 -0
  299. package/dist/queue/advance.mjs +1036 -0
  300. package/dist/queue/callers.mjs +134 -0
  301. package/dist/queue/calls.mjs +1154 -0
  302. package/dist/queue/commit.mjs +85 -0
  303. package/dist/queue/host.d.mts +15 -0
  304. package/dist/queue/host.mjs +88 -0
  305. package/dist/queue/ids.d.mts +5 -0
  306. package/dist/queue/ids.mjs +21 -0
  307. package/dist/queue/lanes.mjs +86 -0
  308. package/dist/queue/limits.mjs +99 -0
  309. package/dist/queue/pages.mjs +76 -0
  310. package/dist/queue/push-option.mjs +62 -0
  311. package/dist/queue/rows.mjs +206 -0
  312. package/dist/queue/schedule.mjs +132 -0
  313. package/dist/queue/search.mjs +315 -0
  314. package/dist/queue/state.mjs +325 -0
  315. package/dist/queue/steps.mjs +317 -0
  316. package/dist/remote-helper.d.mts +3 -0
  317. package/dist/remote-helper.mjs +3 -0
  318. package/dist/rest/api.d.mts +23 -0
  319. package/dist/rest/api.mjs +27 -0
  320. package/dist/rest/blobs.d.mts +58 -0
  321. package/dist/rest/blobs.mjs +41 -0
  322. package/dist/rest/caller.d.mts +102 -0
  323. package/dist/rest/caller.mjs +18 -0
  324. package/dist/rest/client.d.mts +18 -0
  325. package/dist/rest/client.mjs +587 -0
  326. package/dist/rest/commits.d.mts +435 -0
  327. package/dist/rest/commits.mjs +140 -0
  328. package/dist/rest/errors.d.mts +44 -0
  329. package/dist/rest/errors.mjs +186 -0
  330. package/dist/rest/events.d.mts +38 -0
  331. package/dist/rest/events.mjs +74 -0
  332. package/dist/rest/files.d.mts +179 -0
  333. package/dist/rest/files.mjs +92 -0
  334. package/dist/rest/forks.d.mts +205 -0
  335. package/dist/rest/forks.mjs +51 -0
  336. package/dist/rest/handler.d.mts +17 -0
  337. package/dist/rest/handler.mjs +106 -0
  338. package/dist/rest/handlers.d.mts +8 -0
  339. package/dist/rest/handlers.mjs +592 -0
  340. package/dist/rest/listen.d.mts +24 -0
  341. package/dist/rest/listen.mjs +142 -0
  342. package/dist/rest/me.d.mts +55 -0
  343. package/dist/rest/me.mjs +21 -0
  344. package/dist/rest/merges.d.mts +90 -0
  345. package/dist/rest/merges.mjs +39 -0
  346. package/dist/rest/paths.mjs +86 -0
  347. package/dist/rest/queue.d.mts +486 -0
  348. package/dist/rest/queue.mjs +228 -0
  349. package/dist/rest/refs.d.mts +232 -0
  350. package/dist/rest/refs.mjs +86 -0
  351. package/dist/rest/repos.d.mts +223 -0
  352. package/dist/rest/repos.mjs +93 -0
  353. package/dist/rest/tags.d.mts +153 -0
  354. package/dist/rest/tags.mjs +72 -0
  355. package/dist/rest/tokens.d.mts +297 -0
  356. package/dist/rest/tokens.mjs +88 -0
  357. package/dist/rest/topics.d.mts +257 -0
  358. package/dist/rest/topics.mjs +116 -0
  359. package/dist/rest/trees.d.mts +158 -0
  360. package/dist/rest/trees.mjs +118 -0
  361. package/dist/rest/wire.mjs +57 -0
  362. package/dist/rest/work.d.mts +107 -0
  363. package/dist/rest/work.mjs +77 -0
  364. package/dist/rest.d.mts +8 -0
  365. package/dist/rest.mjs +5 -0
  366. package/dist/server/extension.d.mts +14 -0
  367. package/dist/server/extension.mjs +85 -0
  368. package/dist/server/routes.d.mts +25 -0
  369. package/dist/server/routes.mjs +67 -0
  370. package/dist/server/server.d.mts +2 -0
  371. package/dist/server/server.mjs +439 -0
  372. package/dist/signin/codes.mjs +47 -0
  373. package/dist/signin/context.d.mts +9 -0
  374. package/dist/signin/context.mjs +121 -0
  375. package/dist/signin/device.mjs +122 -0
  376. package/dist/signin/forms.mjs +157 -0
  377. package/dist/signin/grants.d.mts +5 -0
  378. package/dist/signin/grants.mjs +257 -0
  379. package/dist/signin/route.mjs +68 -0
  380. package/dist/signin/web.mjs +125 -0
  381. package/dist/signin/wire.d.mts +42 -0
  382. package/dist/signin/wire.mjs +43 -0
  383. package/dist/storage/allotted.mjs +102 -0
  384. package/dist/storage/budget.mjs +96 -0
  385. package/dist/storage/calls.d.mts +18 -0
  386. package/dist/storage/calls.mjs +273 -0
  387. package/dist/storage/clean-up.mjs +124 -0
  388. package/dist/storage/distinct-ids.mjs +39 -0
  389. package/dist/storage/ewah.mjs +97 -0
  390. package/dist/storage/fetch.d.mts +13 -0
  391. package/dist/storage/fetch.mjs +792 -0
  392. package/dist/storage/fsck.mjs +77 -0
  393. package/dist/storage/held-memo.mjs +188 -0
  394. package/dist/storage/index-bitmaps.d.mts +4 -0
  395. package/dist/storage/index-bitmaps.mjs +654 -0
  396. package/dist/storage/index-build.d.mts +15 -0
  397. package/dist/storage/index-build.mjs +1433 -0
  398. package/dist/storage/index-fetch.d.mts +9 -0
  399. package/dist/storage/index-fetch.mjs +756 -0
  400. package/dist/storage/index-files.mjs +232 -0
  401. package/dist/storage/index-graph.d.mts +3 -0
  402. package/dist/storage/index-graph.mjs +1049 -0
  403. package/dist/storage/index-layers.mjs +317 -0
  404. package/dist/storage/index-reach.mjs +216 -0
  405. package/dist/storage/index-remap.d.mts +8 -0
  406. package/dist/storage/index-remap.mjs +592 -0
  407. package/dist/storage/layout.mjs +69 -0
  408. package/dist/storage/lfs-pointers.d.mts +21 -0
  409. package/dist/storage/lfs-pointers.mjs +175 -0
  410. package/dist/storage/link-join.mjs +106 -0
  411. package/dist/storage/links.mjs +105 -0
  412. package/dist/storage/loose.d.mts +15 -0
  413. package/dist/storage/loose.mjs +120 -0
  414. package/dist/storage/memory-budget.d.mts +8 -0
  415. package/dist/storage/memory-budget.mjs +546 -0
  416. package/dist/storage/merge.mjs +416 -0
  417. package/dist/storage/object-rows.d.mts +6 -0
  418. package/dist/storage/object-rows.mjs +211 -0
  419. package/dist/storage/pack-order.d.mts +8 -0
  420. package/dist/storage/pack-order.mjs +779 -0
  421. package/dist/storage/pack-ranges.d.mts +5 -0
  422. package/dist/storage/pack-ranges.mjs +284 -0
  423. package/dist/storage/pack-reads.d.mts +11 -0
  424. package/dist/storage/pack-reads.mjs +990 -0
  425. package/dist/storage/pack-receive.d.mts +11 -0
  426. package/dist/storage/pack-receive.mjs +449 -0
  427. package/dist/storage/packs.d.mts +56 -0
  428. package/dist/storage/packs.mjs +600 -0
  429. package/dist/storage/prune.mjs +506 -0
  430. package/dist/storage/push-allotment.mjs +109 -0
  431. package/dist/storage/push-uploads.mjs +151 -0
  432. package/dist/storage/pushed-commits.mjs +136 -0
  433. package/dist/storage/quarantine.mjs +98 -0
  434. package/dist/storage/raw-ids.mjs +44 -0
  435. package/dist/storage/ready.d.mts +19 -0
  436. package/dist/storage/ready.mjs +328 -0
  437. package/dist/storage/receive-links.mjs +297 -0
  438. package/dist/storage/repack-job.mjs +48 -0
  439. package/dist/storage/repack.d.mts +31 -0
  440. package/dist/storage/repack.mjs +182 -0
  441. package/dist/storage/roots.mjs +42 -0
  442. package/dist/storage/rows.d.mts +3 -0
  443. package/dist/storage/rows.mjs +71 -0
  444. package/dist/storage/shallow.d.mts +5 -0
  445. package/dist/storage/shallow.mjs +128 -0
  446. package/dist/storage/stream-whole.mjs +236 -0
  447. package/dist/storage/unpack.mjs +236 -0
  448. package/dist/storage/visible.mjs +137 -0
  449. package/dist/storage/walk.d.mts +7 -0
  450. package/dist/storage/walk.mjs +170 -0
  451. package/dist/storage/wants.mjs +362 -0
  452. package/dist/store/call-count.d.mts +47 -0
  453. package/dist/store/call-count.mjs +207 -0
  454. package/dist/store/catalogue.d.mts +7 -0
  455. package/dist/store/catalogue.mjs +643 -0
  456. package/dist/store/crossing.mjs +66 -0
  457. package/dist/store/cursor-seal.d.mts +2 -0
  458. package/dist/store/cursor-seal.mjs +85 -0
  459. package/dist/store/errors.d.mts +12 -0
  460. package/dist/store/errors.mjs +129 -0
  461. package/dist/store/git-store.mjs +75 -0
  462. package/dist/store/list-job.mjs +35 -0
  463. package/dist/store/outbox.d.mts +7 -0
  464. package/dist/store/outbox.mjs +295 -0
  465. package/dist/store/queue-jobs.mjs +43 -0
  466. package/dist/store/random.mjs +28 -0
  467. package/dist/store/records.d.mts +4 -0
  468. package/dist/store/records.mjs +192 -0
  469. package/dist/store/ref-rows.d.mts +4 -0
  470. package/dist/store/ref-rows.mjs +30 -0
  471. package/dist/store/repo-record.mjs +100 -0
  472. package/dist/store/reservations.mjs +82 -0
  473. package/dist/store/scopes.mjs +170 -0
  474. package/dist/store/settle.mjs +63 -0
  475. package/dist/store/topic-jobs.mjs +62 -0
  476. package/dist/sync/bound.d.mts +7 -0
  477. package/dist/sync/bound.mjs +29 -0
  478. package/dist/sync/github.d.mts +12 -0
  479. package/dist/sync/github.mjs +297 -0
  480. package/dist/sync/import.d.mts +8 -0
  481. package/dist/sync/import.mjs +154 -0
  482. package/dist/sync/jobs.d.mts +9 -0
  483. package/dist/sync/jobs.mjs +80 -0
  484. package/dist/sync/mirror.d.mts +9 -0
  485. package/dist/sync/mirror.mjs +227 -0
  486. package/dist/sync/publish.d.mts +5 -0
  487. package/dist/sync/publish.mjs +117 -0
  488. package/dist/sync/records.mjs +73 -0
  489. package/dist/sync/smart-http.d.mts +8 -0
  490. package/dist/sync/smart-http.mjs +23 -0
  491. package/dist/sync/step.mjs +334 -0
  492. package/dist/sync/tries.mjs +126 -0
  493. package/dist/sync.d.mts +8 -0
  494. package/dist/sync.mjs +8 -0
  495. package/dist/topics/advance.mjs +554 -0
  496. package/dist/topics/calls.mjs +346 -0
  497. package/dist/topics/directory.mjs +107 -0
  498. package/dist/topics/host.d.mts +11 -0
  499. package/dist/topics/host.mjs +71 -0
  500. package/dist/topics/members.mjs +177 -0
  501. package/dist/topics/rows.mjs +99 -0
  502. package/dist/topics/topic.mjs +126 -0
  503. package/package.json +88 -3
  504. package/README.md +0 -3
@@ -0,0 +1,607 @@
1
+ import { joinedBytes } from "../bytes/joined.mjs";
2
+ import "../objects/object.mjs";
3
+ import { compareEntries } from "../objects/tree.mjs";
4
+ import { isFolder, keyOf } from "./paths.mjs";
5
+ import { DiffError, DiffReader } from "./read.mjs";
6
+ import { copiedOf, maxScore, scoreOf, sizesAllow, spanKeysMost, spanSetBytes, spansOf } from "./rename-similarity.mjs";
7
+ import { isBinary } from "./text.mjs";
8
+ import * as Effect from "effect/Effect";
9
+ // src/protocol/diff/tree-diff.ts
10
+ /**
11
+ * Two trees' changes, as `git diff -r --find-renames` lists them: a walk of both trees in Git's
12
+ * order, a record for each path that changed, then renames paired from the paths one side
13
+ * deleted to the paths the other added.
14
+ *
15
+ * Written from Git's documentation for 2.53.0: `diff-format` (the raw format and its status
16
+ * letters), `diff-options` (`--numstat`, `-z`, `-M<n>`, `-l<num>`, `--no-rename-empty`),
17
+ * `gitdiffcore` (diffcore-rename, and its step that pairs files by name), `git-diff-tree`, and
18
+ * `git-config` (`core.bigFileThreshold`). The pairing follows JGit's
19
+ * `org.eclipse.jgit.diff.RenameDetector`, for the exact pass and which modes pair, and
20
+ * `SimilarityRenameDetector`, for the matrix of scores taken best first. Where the
21
+ * documentation and JGit leave Git's answer open, it was found by running Git 2.53.0 as a black
22
+ * box, and `engine/tree-diff.git.test.ts` holds each such answer to Git's bytes.
23
+ */
24
+ /** `diff.renameLimit`'s default. */
25
+ const defaultRenameLimit = 1e3;
26
+ const encoder = new TextEncoder();
27
+ const slash = new Uint8Array([47]);
28
+ /** What a tree entry is, as the raw format's `T` tells them apart: a file, a symlink or a gitlink. */
29
+ const kindOf = (mode) => kinds.get(mode) ?? "file";
30
+ const kinds = /* @__PURE__ */ new Map([["120000", "symlink"], ["160000", "gitlink"]]);
31
+ const sameKind = (a, b) => kindOf(a.mode) === kindOf(b.mode);
32
+ const objectOf = (entry) => ({
33
+ mode: entry.mode,
34
+ oid: entry.oid
35
+ });
36
+ const added = (path, entry) => ({
37
+ status: "A",
38
+ score: 0,
39
+ from: void 0,
40
+ path,
41
+ old: void 0,
42
+ new: objectOf(entry)
43
+ });
44
+ const deleted = (path, entry) => ({
45
+ status: "D",
46
+ score: 0,
47
+ from: void 0,
48
+ path,
49
+ old: objectOf(entry),
50
+ new: void 0
51
+ });
52
+ /** `slot`'s records, each subfolder's where its slot stands, in one list. */
53
+ const flattened = (slot, into) => {
54
+ const open = [{
55
+ slot,
56
+ at: 0
57
+ }];
58
+ for (let top = open.at(-1); top !== void 0; top = open.at(-1)) {
59
+ const item = top.slot.items[top.at];
60
+ if (item === void 0) {
61
+ open.pop();
62
+ continue;
63
+ }
64
+ top.at += 1;
65
+ if ("items" in item) open.push({
66
+ slot: item,
67
+ at: 0
68
+ });
69
+ else into.push(item);
70
+ }
71
+ return into;
72
+ };
73
+ /**
74
+ * The records from `base` to `head`, two trees or what peels to them, in Git's order: each
75
+ * folder's entries by name as bytes, a folder's name as if it ended in `/`, and a folder's
76
+ * changes where it stands. A path that's a file on one side and a folder on the other is two
77
+ * changes: the file's, and those of each path in the folder. A file that becomes a symlink or a
78
+ * gitlink, or any of the three another, is a type change, `T`; any other change at a path is
79
+ * `M`.
80
+ *
81
+ * The trees are walked a level at a time: each level's folders, on both sides, are read ahead in
82
+ * one `reader.prefetch`, and each folder's records go in a slot where it stands, so the list
83
+ * keeps Git's order. Without a batch, each tree is read on its own, in the same order.
84
+ */
85
+ const walkRecords = (reader, base, head) => Effect.gen(function* () {
86
+ const pathOf = (prefix, name) => prefix === void 0 ? Effect.succeed(name) : Effect.map(reader.charge(prefix.length + 1 + name.length), () => joinedBytes([
87
+ prefix,
88
+ slash,
89
+ name
90
+ ]));
91
+ const whole = (entries, prefix, side, slot, next) => Effect.gen(function* () {
92
+ for (const entry of entries) {
93
+ const path = yield* pathOf(prefix, entry.name);
94
+ if (isFolder(entry)) {
95
+ const below = { items: [] };
96
+ slot.items.push(below);
97
+ next.push({
98
+ whole: entry.oid,
99
+ side,
100
+ prefix: path,
101
+ slot: below
102
+ });
103
+ } else slot.items.push(side(path, entry));
104
+ }
105
+ });
106
+ const walk = (before, after, prefix, slot, next) => Effect.gen(function* () {
107
+ let x = 0;
108
+ let y = 0;
109
+ const below = (folder) => {
110
+ const child = { items: [] };
111
+ slot.items.push(child);
112
+ next.push({
113
+ ...folder,
114
+ slot: child
115
+ });
116
+ };
117
+ while (x < before.length || y < after.length) {
118
+ const old = before[x];
119
+ const now = after[y];
120
+ const order = old === void 0 ? 1 : now === void 0 ? -1 : compareEntries(old, now);
121
+ if (order < 0 && old !== void 0) {
122
+ const path = yield* pathOf(prefix, old.name);
123
+ x += 1;
124
+ if (isFolder(old)) below({
125
+ whole: old.oid,
126
+ side: deleted,
127
+ prefix: path
128
+ });
129
+ else slot.items.push(deleted(path, old));
130
+ continue;
131
+ }
132
+ if (order > 0 && now !== void 0) {
133
+ const path = yield* pathOf(prefix, now.name);
134
+ y += 1;
135
+ if (isFolder(now)) below({
136
+ whole: now.oid,
137
+ side: added,
138
+ prefix: path
139
+ });
140
+ else slot.items.push(added(path, now));
141
+ continue;
142
+ }
143
+ x += 1;
144
+ y += 1;
145
+ if (old === void 0 || now === void 0) continue;
146
+ if (old.oid === now.oid && old.mode === now.mode) continue;
147
+ const path = yield* pathOf(prefix, now.name);
148
+ if (isFolder(old)) {
149
+ below({
150
+ before: old.oid,
151
+ after: now.oid,
152
+ prefix: path
153
+ });
154
+ continue;
155
+ }
156
+ slot.items.push({
157
+ status: sameKind(old, now) ? "M" : "T",
158
+ score: 0,
159
+ from: void 0,
160
+ path,
161
+ old: objectOf(old),
162
+ new: objectOf(now)
163
+ });
164
+ }
165
+ });
166
+ const one = yield* reader.rootOf(base);
167
+ const two = head === base ? one : yield* reader.rootOf(head);
168
+ if (one.oid === two.oid) return [];
169
+ const root = { items: [] };
170
+ let level = [];
171
+ yield* walk(yield* reader.entriesOf(one, reader.limits.entries), yield* reader.entriesOf(two, reader.limits.entries), void 0, root, level);
172
+ while (level.length > 0) {
173
+ yield* reader.prefetch(level.flatMap((folder) => "whole" in folder ? [folder.whole] : [folder.before, folder.after]));
174
+ const next = [];
175
+ for (const folder of level) if ("whole" in folder) yield* whole(yield* reader.treeOf(folder.whole, reader.limits.entries), folder.prefix, folder.side, folder.slot, next);
176
+ else yield* walk(yield* reader.treeOf(folder.before, reader.limits.entries), yield* reader.treeOf(folder.after, reader.limits.entries), folder.prefix, folder.slot, next);
177
+ level = next;
178
+ }
179
+ return flattened(root, []);
180
+ }).pipe(Effect.ensuring(Effect.sync(() => reader.forgetTrees())));
181
+ const mebibyte = 1048576;
182
+ /**
183
+ * The most a diff that pairs renames keeps (Q615): its walk's records and the pass's own state for
184
+ * them, each charged `recordBytesOf`, the span sets it keeps, and the set it builds, charged
185
+ * `spanBuildBytesOf` before its blob is read. A set that doesn't fit stops inexact renames.
186
+ *
187
+ * No charge stops the walk or the exact pass, since every record is listed and exact renames
188
+ * always pair: `DiffLimits.entries` limits them, 71,000 tree entries by default. At 71,000 on
189
+ * Node v26.12.0 the walk held 47.0 MiB live at most, all in one tree, its decoded entries beside
190
+ * the records, and the pass 38.5, split between two, the exact pass indexing the smaller side's
191
+ * contents. At 97,800 in one tree the walk held 64.7, which samples taken at reads alone missed.
192
+ */
193
+ const diffKeptMost = 52.5 * mebibyte;
194
+ /**
195
+ * The most bytes of span sets a rename pass keeps within `diffKeptMost`, each set made once and
196
+ * charged its arrays' bytes and `spanSetOverheadBytes` (Q593, Q598).
197
+ */
198
+ const spanSetsKeptMost = 16 * mebibyte;
199
+ /**
200
+ * What a record holds that the rename pass doesn't take as a side, such as a modified file's,
201
+ * beside its path: on Node v26.12.0, 513 bytes walked with a 10-byte path, measured over 100,000
202
+ * records, rounded up (Q615).
203
+ */
204
+ const recordBytes = 640;
205
+ /**
206
+ * What a deleted or added record holds beside its path, walked and taken as a side by the rename
207
+ * pass at its fullest, with its names, its size and its four slots in the matrix: on Node
208
+ * v26.12.0, 755 bytes with a 10-byte path, measured over 100,000 records, rounded up (Q615). A
209
+ * source holds a place for its set too, 8 bytes more.
210
+ */
211
+ const sideRecordBytes = 896;
212
+ /** What each byte of a record's path adds to it, walked and in the pass: 1.5 to 2 measured. */
213
+ const pathByteBytes = 2;
214
+ /** What `record` is charged against `diffKeptMost`. */
215
+ const recordBytesOf = (record) => (record.status === "D" || record.status === "A" ? sideRecordBytes : recordBytes) + pathByteBytes * record.path.length;
216
+ /**
217
+ * What building one span set holds a span beyond its blob's bytes, at its most: on Node v26.12.0,
218
+ * 24.4 bytes measured at the span cap, rounded up (Q615).
219
+ */
220
+ const spanBuildBytes = 32;
221
+ /**
222
+ * What building the span set of a blob of `size` bytes holds at most, its bytes included: a span
223
+ * is at least a byte, and a build stops one span past the cap.
224
+ */
225
+ const spanBuildBytesOf = (size) => size + spanBuildBytes * Math.min(size, spanKeysMost + 1);
226
+ /** A record's path past its last `/`. */
227
+ const baseName = (path) => path.subarray(path.lastIndexOf(47) + 1);
228
+ const renamed = (source, target, score) => ({
229
+ status: "R",
230
+ score,
231
+ from: source.path,
232
+ path: target.path,
233
+ old: source.old,
234
+ new: target.new
235
+ });
236
+ const pairSide = (record, object, at) => ({
237
+ record,
238
+ object,
239
+ name: keyOf(baseName(record.path)),
240
+ at
241
+ });
242
+ /** How many free sources of a content the exact pass looks through for a destination's name. */
243
+ const exactWindow = 100;
244
+ /** The slots the matrix keeps for each destination's candidates, of which it takes one. */
245
+ const shortlist = 4;
246
+ /** Best first: the higher score, then a match by base name. Below 0 when `x` is better. */
247
+ const better = (x, y) => y.score - x.score || Number(y.named) - Number(x.named);
248
+ /** Whether a pair of `score` and `named` is better than `kept`, as `better` ranks them. */
249
+ const beats = (score, named, kept) => score > kept.score || score === kept.score && named && !kept.named;
250
+ /** Where the first of the worst slots is. */
251
+ const firstWorst = (slots) => slots.reduce((at, kept, here) => better(kept, slots[at] ?? kept) > 0 ? here : at, 0);
252
+ /** `sides` grouped by base name, each group in their order. */
253
+ const byNameOf = (sides) => {
254
+ const groups = /* @__PURE__ */ new Map();
255
+ for (const side of sides) {
256
+ const group = groups.get(side.name);
257
+ if (group === void 0) groups.set(side.name, [side]);
258
+ else group.push(side);
259
+ }
260
+ return groups;
261
+ };
262
+ /**
263
+ * `records` with renames paired: each from a path deleted to a path added, which then stand as
264
+ * one `R` record where the added path stood. Destinations pair in the order given, so the order
265
+ * breaks ties between equal matches, in three passes:
266
+ *
267
+ * 1. Exact: a destination takes a free source of the same content and kind, the one with its
268
+ * base name among the first 100 free, else the first.
269
+ * 2. By name: a destination whose base name no other destination left has, and only one source
270
+ * left has, pairs with it if they score at least halfway from the minimum to 100%.
271
+ * 3. By content, only while the sources left times the destinations left are within the rename
272
+ * limit squared. Each regular file destination has four slots, filled by the sources in their
273
+ * order, any score: a source that isn't a regular file, or whose size alone can't reach the
274
+ * minimum, as 0. Once they're full, a better source takes the place of the first of the
275
+ * worst. Then every destination's slots, in the destinations' order and each's slots in
276
+ * theirs, are taken best first, each that scores at least the minimum and pairing at most
277
+ * once, the order breaking ties. Better is the higher score, then a match by base name.
278
+ *
279
+ * At a minimum of 100%, only the first pass runs. Only sources `relevant` takes pair past the
280
+ * first pass, and an empty file is never a source when `empty` is false.
281
+ *
282
+ * Past the rename limit, the third pass doesn't run, as Git skips it, and the result says
283
+ * `rename-limit`. The second and third passes keep each blob's span set, made once, up to
284
+ * `spanSetsKeptMost` bytes of them, and within `diffKeptMost` with the records and the set being
285
+ * built: a set past either stops them, the pairs made so far standing, and the result says
286
+ * `memory-limit`, as it does when the records alone pass `diffKeptMost`, after the first pass.
287
+ * Git has no such bound, and would go on.
288
+ */
289
+ const pairRecords = (reader, records, options = {}) => Effect.gen(function* () {
290
+ const minimum = options.minimumScore || 3e4;
291
+ const limit = options.renameLimit ?? 1e3;
292
+ const relevant = options.relevant ?? (() => true);
293
+ let sources = [];
294
+ let targets = [];
295
+ for (const [at, record] of records.entries()) {
296
+ if (record.status === "D" && record.old !== void 0) {
297
+ if (options.empty === false && record.old.oid === "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391") continue;
298
+ sources.push(pairSide(record, record.old, at));
299
+ }
300
+ if (record.status === "A" && record.new !== void 0) targets.push(pairSide(record, record.new, at));
301
+ }
302
+ if (sources.length === 0 || targets.length === 0) return { records: [...records] };
303
+ const pairs = /* @__PURE__ */ new Map();
304
+ const taken = /* @__PURE__ */ new Set();
305
+ const pair = (source, target, score) => {
306
+ pairs.set(target.at, renamed(source.record, target.record, score));
307
+ taken.add(source.at);
308
+ };
309
+ const left = () => {
310
+ sources = sources.filter((source) => !taken.has(source.at));
311
+ targets = targets.filter((target) => !pairs.has(target.at));
312
+ };
313
+ const done = (skipped) => {
314
+ const placedRecords = placed(records, pairs, taken);
315
+ return skipped === void 0 ? { records: placedRecords } : {
316
+ records: placedRecords,
317
+ renamesSkipped: skipped
318
+ };
319
+ };
320
+ const byContent = /* @__PURE__ */ new Map();
321
+ const contentOf = (side) => `${side.object.oid} ${kindOf(side.object.mode)}`;
322
+ const wanted = targets.length < sources.length ? new Set(targets.map(contentOf)) : void 0;
323
+ for (const source of sources.toReversed()) {
324
+ const key = contentOf(source);
325
+ if (wanted !== void 0 && !wanted.has(key)) continue;
326
+ byContent.set(key, {
327
+ side: source,
328
+ next: byContent.get(key)
329
+ });
330
+ }
331
+ for (const target of targets) {
332
+ const key = contentOf(target);
333
+ const first = byContent.get(key);
334
+ if (first === void 0) continue;
335
+ let chosen = first;
336
+ let beforeChosen;
337
+ let link = first;
338
+ let beforeLink;
339
+ for (let seen = 0; link !== void 0 && seen < exactWindow; seen += 1) {
340
+ if (link.side.name === target.name) {
341
+ chosen = link;
342
+ beforeChosen = beforeLink;
343
+ break;
344
+ }
345
+ beforeLink = link;
346
+ link = link.next;
347
+ }
348
+ if (beforeChosen === void 0) byContent.set(key, chosen.next);
349
+ else beforeChosen.next = chosen.next;
350
+ pair(chosen.side, target, maxScore);
351
+ }
352
+ left();
353
+ sources = sources.filter((source) => relevant(source.record));
354
+ if (sources.length === 0 || targets.length === 0 || minimum >= 6e4) return done();
355
+ const keptMost = options.keptMost ?? 55050240;
356
+ const classesBytes = options.scoredAs === void 0 ? 0 : 80 * (sources.length + targets.length);
357
+ const recordsBytes = records.reduce((sum, record) => sum + recordBytesOf(record), 0) + classesBytes;
358
+ if (recordsBytes > keptMost) return done("memory-limit");
359
+ const sets = {
360
+ text: /* @__PURE__ */ new Map(),
361
+ binary: /* @__PURE__ */ new Map()
362
+ };
363
+ const { scoredAs } = options;
364
+ const classes = /* @__PURE__ */ new Map();
365
+ const textByBytes = /* @__PURE__ */ new Map();
366
+ let keptBytes = 0;
367
+ let full = false;
368
+ const classOf = (side) => {
369
+ if (scoredAs === void 0 || classes.has(side.at)) return Effect.succeed(classes.get(side.at));
370
+ return Effect.map(scoredAs(side.record.path), (scored) => {
371
+ classes.set(side.at, scored);
372
+ return scored;
373
+ });
374
+ };
375
+ const setsFor = (oid, scored) => {
376
+ if (scored !== void 0) return sets[scored];
377
+ if (scoredAs === void 0) return sets.binary.has(oid) ? sets.binary : sets.text;
378
+ const text = textByBytes.get(oid);
379
+ if (text === void 0) return void 0;
380
+ return text ? sets.text : sets.binary;
381
+ };
382
+ const spansFor = (side) => Effect.gen(function* () {
383
+ const { oid } = side.object;
384
+ const scored = yield* classOf(side);
385
+ const known = setsFor(oid, scored);
386
+ if (known?.has(oid)) return known.get(oid);
387
+ const blobBytes = yield* reader.sizeOf(oid);
388
+ const building = spanBuildBytesOf(blobBytes);
389
+ const reading = (sets.text.has(oid) || sets.binary.has(oid)) && known === void 0 ? blobBytes : building;
390
+ if (recordsBytes + keptBytes + reading > keptMost) {
391
+ full = true;
392
+ return;
393
+ }
394
+ const bytes = yield* reader.bytesOf(oid, "blob");
395
+ const text = scored === void 0 ? !isBinary(bytes) : scored === "text";
396
+ const set = text ? sets.text : sets.binary;
397
+ if (scoredAs !== void 0 && scored === void 0) textByBytes.set(oid, text);
398
+ if (set.has(oid)) return set.get(oid);
399
+ if (recordsBytes + keptBytes + building > keptMost) {
400
+ full = true;
401
+ return;
402
+ }
403
+ const made = spansOf(bytes, text);
404
+ const size = made === void 0 ? 0 : spanSetBytes(made) + 520;
405
+ if (keptBytes + size > 16777216 || recordsBytes + keptBytes + size > keptMost) {
406
+ full = true;
407
+ return;
408
+ }
409
+ keptBytes += size;
410
+ set.set(oid, made);
411
+ return made;
412
+ });
413
+ const scored = (source, target, least) => Effect.gen(function* () {
414
+ const one = yield* reader.sizeOf(source.object.oid);
415
+ const two = yield* reader.sizeOf(target.object.oid);
416
+ if (!sizesAllow(one, two, least)) return void 0;
417
+ const from = yield* spansFor(source);
418
+ const to = full ? void 0 : yield* spansFor(target);
419
+ if (from === void 0 || to === void 0) return void 0;
420
+ return scoreOf(copiedOf(from, to), one, two);
421
+ });
422
+ const isFile = (side) => kindOf(side.object.mode) === "file";
423
+ const byName = minimum + Math.floor((maxScore - minimum) / 2);
424
+ const sourceNames = byNameOf(sources);
425
+ for (const [name, sides] of byNameOf(targets)) {
426
+ const [target, ...others] = sides;
427
+ const [source, ...more] = sourceNames.get(name) ?? [];
428
+ if (target === void 0 || source === void 0 || others.length > 0 || more.length > 0) continue;
429
+ if (!isFile(source) || !isFile(target)) continue;
430
+ const score = yield* scored(source, target, byName);
431
+ if (full) return done("memory-limit");
432
+ if (score !== void 0 && score >= byName) pair(source, target, score);
433
+ }
434
+ left();
435
+ if (sources.length === 0 || targets.length === 0) return done();
436
+ if (limit !== 0 && sources.length * targets.length > limit * limit) return done("rename-limit");
437
+ if (options.pairsMost !== void 0 && sources.length * targets.length > options.pairsMost) return yield* new DiffError({
438
+ reason: "diff-limit",
439
+ message: `pairing renames compares ${sources.length * targets.length} pairs, past ${options.pairsMost}`
440
+ });
441
+ if (!sources.some(isFile) || !targets.some(isFile)) return done();
442
+ const matrix = [];
443
+ const sourceSizes = [];
444
+ const sourceSets = [];
445
+ for (const source of sources) {
446
+ sourceSizes.push(isFile(source) ? yield* reader.sizeOf(source.object.oid) : 0);
447
+ sourceSets.push(null);
448
+ }
449
+ for (const [t, target] of targets.entries()) {
450
+ if (!isFile(target)) continue;
451
+ const two = yield* reader.sizeOf(target.object.oid);
452
+ const slots = [];
453
+ let worst = 0;
454
+ let to = null;
455
+ for (const [s, source] of sources.entries()) {
456
+ const one = sourceSizes[s] ?? 0;
457
+ let score = 0;
458
+ if (isFile(source) && sizesAllow(one, two, minimum)) {
459
+ const found = sourceSets[s];
460
+ const from = found === null ? yield* spansFor(source) : found;
461
+ if (full) return done("memory-limit");
462
+ sourceSets[s] = from;
463
+ if (to === null) to = yield* spansFor(target);
464
+ if (full) return done("memory-limit");
465
+ score = from === void 0 || to === void 0 ? -1 : scoreOf(copiedOf(from, to), one, two);
466
+ }
467
+ const named = source.name === target.name;
468
+ const kept = slots[worst];
469
+ if (slots.length < shortlist) slots.push({
470
+ score,
471
+ named,
472
+ source: s,
473
+ target: t
474
+ });
475
+ else if (kept !== void 0 && beats(score, named, kept)) slots[worst] = {
476
+ score,
477
+ named,
478
+ source: s,
479
+ target: t
480
+ };
481
+ else continue;
482
+ if (slots.length === shortlist) worst = firstWorst(slots);
483
+ }
484
+ matrix.push(...slots);
485
+ }
486
+ matrix.sort(better);
487
+ for (const cell of matrix) {
488
+ const source = sources[cell.source];
489
+ const target = targets[cell.target];
490
+ if (source === void 0 || target === void 0 || cell.score < minimum) continue;
491
+ if (taken.has(source.at) || pairs.has(target.at)) continue;
492
+ pair(source, target, cell.score);
493
+ }
494
+ return done();
495
+ });
496
+ /** The records again, each paired destination as its rename and each paired source gone. */
497
+ const placed = (records, pairs, taken) => records.flatMap((record, at) => {
498
+ if (taken.has(at)) return [];
499
+ return [pairs.get(at) ?? record];
500
+ });
501
+ /** `core.bigFileThreshold`'s default: a file past it diffs as binary, as if marked so. */
502
+ const bigFileBytes = 536870912;
503
+ const empty = /* @__PURE__ */ new Uint8Array();
504
+ /** A side's bytes as a diff reads them, a gitlink's as Git writes one, or `big` past the threshold. */
505
+ const sideOf = (reader, side) => Effect.gen(function* () {
506
+ if (side === void 0) return empty;
507
+ if (side.mode === "160000") return encoder.encode(`Subproject commit ${side.oid}\n`);
508
+ if ((yield* reader.sizeOf(side.oid)) > 536870912) return "big";
509
+ return yield* reader.bytesOf(side.oid, "blob");
510
+ });
511
+ /**
512
+ * A record's sides, or `binary` where either is: past `bigFileBytes`, or holding a NUL in its
513
+ * first 8,000 bytes. Both sides are read, so a binary file diffs as binary even when its two
514
+ * sides are the same object, as numstat counts an exact rename's.
515
+ */
516
+ const sidesOf = (reader, record) => Effect.gen(function* () {
517
+ const one = yield* sideOf(reader, record.old);
518
+ const two = record.new !== void 0 && record.old !== void 0 && record.new.oid === record.old.oid && record.new.mode === record.old.mode ? one : yield* sideOf(reader, record.new);
519
+ if (one === "big" || two === "big" || isBinary(one) || isBinary(two)) return "binary";
520
+ return {
521
+ one,
522
+ two
523
+ };
524
+ });
525
+ /**
526
+ * A record's lines as numstat counts them: one diff of its two sides, a type change's too, or
527
+ * `binary`.
528
+ */
529
+ const lineCount = (reader, count, record) => Effect.gen(function* () {
530
+ const sides = yield* sidesOf(reader, record);
531
+ if (sides === "binary") return sides;
532
+ return yield* count(sides.one, sides.two);
533
+ });
534
+ /** A score out of `maxScore` as the percentage Git writes: rounded down. */
535
+ const percentOf = (score) => Math.floor(score * 100 / maxScore);
536
+ const strict = new TextDecoder("utf-8", {
537
+ fatal: true,
538
+ ignoreBOM: true
539
+ });
540
+ const lossy = new TextDecoder("utf-8", {
541
+ fatal: false,
542
+ ignoreBOM: true
543
+ });
544
+ /** A path's bytes as text, and whether the text is them exactly: it isn't where they aren't UTF-8. */
545
+ const pathText = (bytes) => {
546
+ try {
547
+ return {
548
+ text: strict.decode(bytes),
549
+ exact: true
550
+ };
551
+ } catch {
552
+ return {
553
+ text: lossy.decode(bytes),
554
+ exact: false
555
+ };
556
+ }
557
+ };
558
+ /** A record as the contracts give a change: paths as text, with their bytes where not UTF-8. */
559
+ function changeOf(record) {
560
+ const path = pathText(record.path);
561
+ const change = {
562
+ status: record.status,
563
+ path: path.text
564
+ };
565
+ if (!path.exact) change.pathBytes = record.path;
566
+ if (record.from !== void 0) {
567
+ const from = pathText(record.from);
568
+ change.from = from.text;
569
+ if (!from.exact) change.fromPathBytes = record.from;
570
+ }
571
+ if (record.status === "R") change.similarity = percentOf(record.score);
572
+ if (record.old !== void 0) change.old = record.old;
573
+ if (record.new !== void 0) change.new = record.new;
574
+ return change;
575
+ }
576
+ /** A change as a record again, its paths' bytes from `pathBytes` or their text. */
577
+ const recordOf = (change) => ({
578
+ status: change.status,
579
+ score: change.status === "R" ? Math.ceil((change.similarity ?? 100) * maxScore / 100) : 0,
580
+ from: change.from === void 0 ? void 0 : change.fromPathBytes ?? encoder.encode(change.from),
581
+ path: change.pathBytes ?? encoder.encode(change.path),
582
+ old: change.old,
583
+ new: change.new
584
+ });
585
+ /** `paired`'s records as changes. */
586
+ const changesOf = (paired) => {
587
+ const changes = paired.records.map(changeOf);
588
+ return paired.renamesSkipped === void 0 ? { changes } : {
589
+ changes,
590
+ renamesSkipped: paired.renamesSkipped
591
+ };
592
+ };
593
+ /** Two trees' changes, as `git diff --find-renames` lists them, or without renames when off. */
594
+ const walkTrees = (input) => Effect.gen(function* () {
595
+ const reader = new DiffReader(input.read, input.limits, input.tally, input.batch);
596
+ const walked = yield* walkRecords(reader, input.base, input.head);
597
+ if (input.renames === false) return { changes: walked.map(changeOf) };
598
+ return changesOf(yield* pairRecords(reader, walked));
599
+ });
600
+ /** Each change's lines, as numstat counts them, within one reader's limits. */
601
+ const countLines = (changes, read, count, limits, tally) => Effect.suspend(() => {
602
+ const reader = new DiffReader(read, limits, tally);
603
+ return Effect.forEach(changes, (change) => lineCount(reader, count, recordOf(change)));
604
+ });
605
+ /** Changes with renames paired among their deletions and additions, as `pairRecords` pairs them. */
606
+ const pairRenames = (changes, read, pairsMost) => Effect.suspend(() => Effect.map(pairRecords(new DiffReader(read), changes.map(recordOf), { pairsMost }), changesOf));
607
+ export { bigFileBytes, changeOf, countLines, defaultRenameLimit, diffKeptMost, lineCount, pairRecords, pairRenames, pathText, percentOf, recordBytesOf, sidesOf, spanBuildBytesOf, spanSetsKeptMost, walkRecords, walkTrees };
@@ -0,0 +1,10 @@
1
+ /** A side-band: 1 carries the payload, such as a pack or a report, 2 progress, 3 a fatal error. */
2
+ export type Band = 1 | 2 | 3;
3
+ /** The payload bytes one side-band line holds, past its band's byte. */
4
+ export declare const maxBandData: number;
5
+ /**
6
+ * Bytes on a side-band, in as many pkt-lines as they need: 1 carries the payload, 2 what Git
7
+ * prints after `remote:`, 3 an error that ends the answer. Each line holds the band's byte and at
8
+ * most 65,515 more, so no line can be too long. No bytes make no lines.
9
+ */
10
+ export declare function onBand(band: Band, payload: Uint8Array): Uint8Array<ArrayBuffer>;
@@ -0,0 +1,16 @@
1
+ import { joinedBytes } from "../bytes/joined.mjs";
2
+ import { dataPkt, maxPktData } from "./pkt-line.mjs";
3
+ // src/protocol/framing/band.ts
4
+ /** The payload bytes one side-band line holds, past its band's byte. */
5
+ const maxBandData = maxPktData - 1;
6
+ /**
7
+ * Bytes on a side-band, in as many pkt-lines as they need: 1 carries the payload, 2 what Git
8
+ * prints after `remote:`, 3 an error that ends the answer. Each line holds the band's byte and at
9
+ * most 65,515 more, so no line can be too long. No bytes make no lines.
10
+ */
11
+ function onBand(band, payload) {
12
+ const lines = [];
13
+ for (let at = 0; at < payload.length; at += maxBandData) lines.push(dataPkt(joinedBytes([new Uint8Array([band]), payload.subarray(at, at + maxBandData)])));
14
+ return joinedBytes(lines);
15
+ }
16
+ export { maxBandData, onBand };
@@ -0,0 +1,48 @@
1
+ import { WireEncodeError } from "../bytes/errors.mjs";
2
+ import * as Effect from "effect/Effect";
3
+ /**
4
+ * Git's pkt-line framing, as `gitprotocol-common` defines it: four hex digits giving the
5
+ * line's whole length, its own four bytes included, then the data. `0000` is a flush,
6
+ * ending a section; `0001` and `0002` are protocol v2's delimiter and response end. A line
7
+ * holds at most 65,516 bytes of data.
8
+ */
9
+ export declare const maxPktData = 65516;
10
+ export type Pkt = {
11
+ readonly kind: 'data';
12
+ readonly data: Uint8Array;
13
+ } | {
14
+ readonly kind: 'flush';
15
+ } | {
16
+ readonly kind: 'delim';
17
+ } | {
18
+ readonly kind: 'response-end';
19
+ };
20
+ export type PktRead = {
21
+ readonly kind: 'pkt';
22
+ readonly pkt: Pkt;
23
+ readonly next: number;
24
+ } | {
25
+ readonly kind: 'incomplete';
26
+ } | {
27
+ readonly kind: 'invalid';
28
+ readonly reason: string;
29
+ };
30
+ /**
31
+ * Reads one pkt-line from `bytes` at `offset`: `incomplete` while its length or data hasn't all
32
+ * come, and `invalid` for a length Git never writes. Its data is a view of `bytes`, not a copy.
33
+ */
34
+ export declare function readPkt(bytes: Uint8Array, offset: number): PktRead;
35
+ /** One data pkt-line; a body past `maxPktData` is refused. */
36
+ export declare const encodePkt: (body: Uint8Array) => Effect.Effect<Uint8Array<ArrayBuffer>, WireEncodeError>;
37
+ /** One data pkt-line holding text, such as `unpack ok\n`, as UTF-8. */
38
+ export declare const encodeTextPkt: (text: string) => Effect.Effect<Uint8Array<ArrayBuffer>, WireEncodeError>;
39
+ /** A flush, ending a section. */
40
+ export declare const flushPkt: Uint8Array;
41
+ /** Protocol v2's delimiter, between a command's capabilities and its arguments. */
42
+ export declare const delimPkt: Uint8Array;
43
+ /**
44
+ * A data line's text, without its trailing newline, which Git sends but doesn't require; or
45
+ * `undefined` when it isn't UTF-8. Git allows any bytes in a ref name, but a name that isn't
46
+ * UTF-8 can't be recorded as it is, so it's refused, never quietly changed.
47
+ */
48
+ export declare function pktText(data: Uint8Array): string | undefined;