@amalgm/live 0.2.81-preview.45708334404 → 0.2.81-preview.45793205987

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 (343) hide show
  1. package/dist/apply/plans.d.ts.map +1 -1
  2. package/dist/apply/plans.js +3 -1
  3. package/dist/apply/plans.js.map +1 -1
  4. package/dist/apply/showing.d.ts +2 -1
  5. package/dist/apply/showing.d.ts.map +1 -1
  6. package/dist/apply/showing.js +5 -2
  7. package/dist/apply/showing.js.map +1 -1
  8. package/dist/clash/bodmas.d.ts +3 -0
  9. package/dist/clash/bodmas.d.ts.map +1 -1
  10. package/dist/clash/bodmas.js +14 -6
  11. package/dist/clash/bodmas.js.map +1 -1
  12. package/dist/{sharing/command-input.d.ts → commands/input.d.ts} +9 -5
  13. package/dist/commands/input.d.ts.map +1 -0
  14. package/dist/{sharing/command-input.js → commands/input.js} +14 -4
  15. package/dist/commands/input.js.map +1 -0
  16. package/dist/commands/mcp.d.ts +30 -0
  17. package/dist/commands/mcp.d.ts.map +1 -0
  18. package/dist/commands/mcp.js +12 -0
  19. package/dist/commands/mcp.js.map +1 -0
  20. package/dist/detection/batch.d.ts +4 -0
  21. package/dist/detection/batch.d.ts.map +1 -1
  22. package/dist/detection/batch.js +4 -2
  23. package/dist/detection/batch.js.map +1 -1
  24. package/dist/detection/record-order.d.ts +9 -0
  25. package/dist/detection/record-order.d.ts.map +1 -1
  26. package/dist/detection/record-order.js +31 -4
  27. package/dist/detection/record-order.js.map +1 -1
  28. package/dist/detection/record-proposal.d.ts.map +1 -1
  29. package/dist/detection/record-proposal.js +9 -3
  30. package/dist/detection/record-proposal.js.map +1 -1
  31. package/dist/detection/removals.d.ts +2 -0
  32. package/dist/detection/removals.d.ts.map +1 -1
  33. package/dist/detection/removals.js +2 -0
  34. package/dist/detection/removals.js.map +1 -1
  35. package/dist/drive/drive.d.ts +2 -1
  36. package/dist/drive/drive.d.ts.map +1 -1
  37. package/dist/drive/drive.js +2 -1
  38. package/dist/drive/drive.js.map +1 -1
  39. package/dist/drive/listing.d.ts.map +1 -1
  40. package/dist/drive/listing.js +3 -3
  41. package/dist/drive/listing.js.map +1 -1
  42. package/dist/drive/where.d.ts +3 -0
  43. package/dist/drive/where.d.ts.map +1 -1
  44. package/dist/drive/where.js +8 -3
  45. package/dist/drive/where.js.map +1 -1
  46. package/dist/entities/cloud.d.ts.map +1 -1
  47. package/dist/entities/cloud.js +3 -3
  48. package/dist/entities/cloud.js.map +1 -1
  49. package/dist/entities/rules.d.ts +14 -2
  50. package/dist/entities/rules.d.ts.map +1 -1
  51. package/dist/entities/rules.js +17 -5
  52. package/dist/entities/rules.js.map +1 -1
  53. package/dist/files/accepted-files.d.ts.map +1 -1
  54. package/dist/files/accepted-files.js +7 -3
  55. package/dist/files/accepted-files.js.map +1 -1
  56. package/dist/files/commands.d.ts +4 -1
  57. package/dist/files/commands.d.ts.map +1 -1
  58. package/dist/files/commands.js.map +1 -1
  59. package/dist/files/plans.d.ts +2 -0
  60. package/dist/files/plans.d.ts.map +1 -1
  61. package/dist/files/plans.js +5 -4
  62. package/dist/files/plans.js.map +1 -1
  63. package/dist/files/usage.d.ts +12 -1
  64. package/dist/files/usage.d.ts.map +1 -1
  65. package/dist/files/usage.js +48 -5
  66. package/dist/files/usage.js.map +1 -1
  67. package/dist/git/holds.d.ts +105 -0
  68. package/dist/git/holds.d.ts.map +1 -0
  69. package/dist/git/holds.js +103 -0
  70. package/dist/git/holds.js.map +1 -0
  71. package/dist/git/index.d.ts +4 -1
  72. package/dist/git/index.d.ts.map +1 -1
  73. package/dist/git/index.js +4 -1
  74. package/dist/git/index.js.map +1 -1
  75. package/dist/git/parts.d.ts +41 -0
  76. package/dist/git/parts.d.ts.map +1 -0
  77. package/dist/git/parts.js +119 -0
  78. package/dist/git/parts.js.map +1 -0
  79. package/dist/git/places.d.ts +33 -0
  80. package/dist/git/places.d.ts.map +1 -0
  81. package/dist/git/places.js +36 -0
  82. package/dist/git/places.js.map +1 -0
  83. package/dist/git/restore.d.ts +35 -0
  84. package/dist/git/restore.d.ts.map +1 -0
  85. package/dist/git/restore.js +110 -0
  86. package/dist/git/restore.js.map +1 -0
  87. package/dist/git/tag.d.ts +57 -24
  88. package/dist/git/tag.d.ts.map +1 -1
  89. package/dist/git/tag.js +141 -31
  90. package/dist/git/tag.js.map +1 -1
  91. package/dist/git/turns.d.ts +6 -4
  92. package/dist/git/turns.d.ts.map +1 -1
  93. package/dist/git/turns.js +6 -4
  94. package/dist/git/turns.js.map +1 -1
  95. package/dist/history/history.d.ts +2 -4
  96. package/dist/history/history.d.ts.map +1 -1
  97. package/dist/history/history.js +28 -11
  98. package/dist/history/history.js.map +1 -1
  99. package/dist/history/identity.d.ts +29 -0
  100. package/dist/history/identity.d.ts.map +1 -0
  101. package/dist/history/identity.js +39 -0
  102. package/dist/history/identity.js.map +1 -0
  103. package/dist/history/index.d.ts +9 -6
  104. package/dist/history/index.d.ts.map +1 -1
  105. package/dist/history/index.js +6 -5
  106. package/dist/history/index.js.map +1 -1
  107. package/dist/history/rule.d.ts +22 -31
  108. package/dist/history/rule.d.ts.map +1 -1
  109. package/dist/history/rule.js +28 -67
  110. package/dist/history/rule.js.map +1 -1
  111. package/dist/history/runs.d.ts +35 -0
  112. package/dist/history/runs.d.ts.map +1 -0
  113. package/dist/history/runs.js +29 -0
  114. package/dist/history/runs.js.map +1 -0
  115. package/dist/history/types.d.ts +19 -17
  116. package/dist/history/types.d.ts.map +1 -1
  117. package/dist/history/types.js +5 -4
  118. package/dist/history/types.js.map +1 -1
  119. package/dist/history/version.d.ts +4 -1
  120. package/dist/history/version.d.ts.map +1 -1
  121. package/dist/history/version.js +8 -1
  122. package/dist/history/version.js.map +1 -1
  123. package/dist/records/rail.d.ts +3 -0
  124. package/dist/records/rail.d.ts.map +1 -1
  125. package/dist/records/rail.js +5 -0
  126. package/dist/records/rail.js.map +1 -1
  127. package/dist/records/send-line.d.ts +5 -0
  128. package/dist/records/send-line.d.ts.map +1 -1
  129. package/dist/records/send-line.js +14 -0
  130. package/dist/records/send-line.js.map +1 -1
  131. package/dist/sharing/commands.d.ts +3 -8
  132. package/dist/sharing/commands.d.ts.map +1 -1
  133. package/dist/sharing/commands.js +1 -1
  134. package/dist/sharing/commands.js.map +1 -1
  135. package/dist/sharing/index.d.ts +3 -2
  136. package/dist/sharing/index.d.ts.map +1 -1
  137. package/dist/sharing/index.js.map +1 -1
  138. package/dist/sharing/mcp.d.ts +3 -20
  139. package/dist/sharing/mcp.d.ts.map +1 -1
  140. package/dist/sharing/mcp.js +4 -9
  141. package/dist/sharing/mcp.js.map +1 -1
  142. package/dist/versions/admit.d.ts +15 -0
  143. package/dist/versions/admit.d.ts.map +1 -0
  144. package/dist/versions/admit.js +33 -0
  145. package/dist/versions/admit.js.map +1 -0
  146. package/dist/versions/api.d.ts +11 -0
  147. package/dist/versions/api.d.ts.map +1 -0
  148. package/dist/versions/api.js +102 -0
  149. package/dist/versions/api.js.map +1 -0
  150. package/dist/versions/cli-text.d.ts +8 -0
  151. package/dist/versions/cli-text.d.ts.map +1 -0
  152. package/dist/versions/cli-text.js +68 -0
  153. package/dist/versions/cli-text.js.map +1 -0
  154. package/dist/versions/cli.d.ts +20 -0
  155. package/dist/versions/cli.d.ts.map +1 -0
  156. package/dist/versions/cli.js +122 -0
  157. package/dist/versions/cli.js.map +1 -0
  158. package/dist/versions/commands.d.ts +44 -0
  159. package/dist/versions/commands.d.ts.map +1 -0
  160. package/dist/versions/commands.js +87 -0
  161. package/dist/versions/commands.js.map +1 -0
  162. package/dist/versions/content.d.ts +10 -0
  163. package/dist/versions/content.d.ts.map +1 -0
  164. package/dist/versions/content.js +29 -0
  165. package/dist/versions/content.js.map +1 -0
  166. package/dist/versions/dates.d.ts +29 -0
  167. package/dist/versions/dates.d.ts.map +1 -0
  168. package/dist/versions/dates.js +119 -0
  169. package/dist/versions/dates.js.map +1 -0
  170. package/dist/versions/deliver.d.ts +35 -0
  171. package/dist/versions/deliver.d.ts.map +1 -0
  172. package/dist/versions/deliver.js +37 -0
  173. package/dist/versions/deliver.js.map +1 -0
  174. package/dist/versions/errors.d.ts +18 -0
  175. package/dist/versions/errors.d.ts.map +1 -0
  176. package/dist/versions/errors.js +30 -0
  177. package/dist/versions/errors.js.map +1 -0
  178. package/dist/versions/index.d.ts +24 -0
  179. package/dist/versions/index.d.ts.map +1 -0
  180. package/dist/versions/index.js +15 -0
  181. package/dist/versions/index.js.map +1 -0
  182. package/dist/versions/line.d.ts +21 -0
  183. package/dist/versions/line.d.ts.map +1 -0
  184. package/dist/versions/line.js +97 -0
  185. package/dist/versions/line.js.map +1 -0
  186. package/dist/versions/list.d.ts +7 -0
  187. package/dist/versions/list.d.ts.map +1 -0
  188. package/dist/versions/list.js +12 -0
  189. package/dist/versions/list.js.map +1 -0
  190. package/dist/versions/mcp.d.ts +12 -0
  191. package/dist/versions/mcp.d.ts.map +1 -0
  192. package/dist/versions/mcp.js +36 -0
  193. package/dist/versions/mcp.js.map +1 -0
  194. package/dist/versions/ports.d.ts +81 -0
  195. package/dist/versions/ports.d.ts.map +1 -0
  196. package/dist/versions/ports.js +6 -0
  197. package/dist/versions/ports.js.map +1 -0
  198. package/dist/versions/read.d.ts +23 -0
  199. package/dist/versions/read.d.ts.map +1 -0
  200. package/dist/versions/read.js +60 -0
  201. package/dist/versions/read.js.map +1 -0
  202. package/dist/versions/restore.d.ts +11 -0
  203. package/dist/versions/restore.d.ts.map +1 -0
  204. package/dist/versions/restore.js +37 -0
  205. package/dist/versions/restore.js.map +1 -0
  206. package/dist/versions/services.d.ts +12 -0
  207. package/dist/versions/services.d.ts.map +1 -0
  208. package/dist/versions/services.js +14 -0
  209. package/dist/versions/services.js.map +1 -0
  210. package/dist/versions/show.d.ts +7 -0
  211. package/dist/versions/show.d.ts.map +1 -0
  212. package/dist/versions/show.js +15 -0
  213. package/dist/versions/show.js.map +1 -0
  214. package/dist/versions/types.d.ts +84 -0
  215. package/dist/versions/types.d.ts.map +1 -0
  216. package/dist/versions/types.js +7 -0
  217. package/dist/versions/types.js.map +1 -0
  218. package/dist/versions/versions.d.ts +15 -0
  219. package/dist/versions/versions.d.ts.map +1 -0
  220. package/dist/versions/versions.js +15 -0
  221. package/dist/versions/versions.js.map +1 -0
  222. package/dist-cjs/apply/plans.js +3 -1
  223. package/dist-cjs/apply/plans.js.map +1 -1
  224. package/dist-cjs/apply/showing.js +5 -2
  225. package/dist-cjs/apply/showing.js.map +1 -1
  226. package/dist-cjs/clash/bodmas.js +15 -5
  227. package/dist-cjs/clash/bodmas.js.map +1 -1
  228. package/dist-cjs/{sharing/command-input.js → commands/input.js} +14 -3
  229. package/dist-cjs/commands/input.js.map +1 -0
  230. package/dist-cjs/commands/mcp.js +15 -0
  231. package/dist-cjs/commands/mcp.js.map +1 -0
  232. package/dist-cjs/detection/batch.js +3 -1
  233. package/dist-cjs/detection/batch.js.map +1 -1
  234. package/dist-cjs/detection/record-order.js +31 -4
  235. package/dist-cjs/detection/record-order.js.map +1 -1
  236. package/dist-cjs/detection/record-proposal.js +9 -3
  237. package/dist-cjs/detection/record-proposal.js.map +1 -1
  238. package/dist-cjs/detection/removals.js +2 -0
  239. package/dist-cjs/detection/removals.js.map +1 -1
  240. package/dist-cjs/drive/drive.js +2 -1
  241. package/dist-cjs/drive/drive.js.map +1 -1
  242. package/dist-cjs/drive/listing.js +2 -2
  243. package/dist-cjs/drive/listing.js.map +1 -1
  244. package/dist-cjs/drive/where.js +8 -2
  245. package/dist-cjs/drive/where.js.map +1 -1
  246. package/dist-cjs/entities/cloud.js +2 -2
  247. package/dist-cjs/entities/cloud.js.map +1 -1
  248. package/dist-cjs/entities/rules.js +19 -5
  249. package/dist-cjs/entities/rules.js.map +1 -1
  250. package/dist-cjs/files/accepted-files.js +7 -3
  251. package/dist-cjs/files/accepted-files.js.map +1 -1
  252. package/dist-cjs/files/commands.js.map +1 -1
  253. package/dist-cjs/files/plans.js +5 -4
  254. package/dist-cjs/files/plans.js.map +1 -1
  255. package/dist-cjs/files/usage.js +48 -5
  256. package/dist-cjs/files/usage.js.map +1 -1
  257. package/dist-cjs/git/holds.js +110 -0
  258. package/dist-cjs/git/holds.js.map +1 -0
  259. package/dist-cjs/git/index.js +9 -2
  260. package/dist-cjs/git/index.js.map +1 -1
  261. package/dist-cjs/git/parts.js +127 -0
  262. package/dist-cjs/git/parts.js.map +1 -0
  263. package/dist-cjs/git/places.js +39 -0
  264. package/dist-cjs/git/places.js.map +1 -0
  265. package/dist-cjs/git/restore.js +113 -0
  266. package/dist-cjs/git/restore.js.map +1 -0
  267. package/dist-cjs/git/tag.js +144 -32
  268. package/dist-cjs/git/tag.js.map +1 -1
  269. package/dist-cjs/git/turns.js +6 -4
  270. package/dist-cjs/git/turns.js.map +1 -1
  271. package/dist-cjs/history/history.js +27 -10
  272. package/dist-cjs/history/history.js.map +1 -1
  273. package/dist-cjs/history/identity.js +43 -0
  274. package/dist-cjs/history/identity.js.map +1 -0
  275. package/dist-cjs/history/index.js +9 -9
  276. package/dist-cjs/history/index.js.map +1 -1
  277. package/dist-cjs/history/rule.js +28 -69
  278. package/dist-cjs/history/rule.js.map +1 -1
  279. package/dist-cjs/history/runs.js +33 -0
  280. package/dist-cjs/history/runs.js.map +1 -0
  281. package/dist-cjs/history/types.js +5 -4
  282. package/dist-cjs/history/types.js.map +1 -1
  283. package/dist-cjs/history/version.js +8 -1
  284. package/dist-cjs/history/version.js.map +1 -1
  285. package/dist-cjs/records/rail.js +5 -0
  286. package/dist-cjs/records/rail.js.map +1 -1
  287. package/dist-cjs/records/send-line.js +14 -0
  288. package/dist-cjs/records/send-line.js.map +1 -1
  289. package/dist-cjs/sharing/commands.js +15 -15
  290. package/dist-cjs/sharing/commands.js.map +1 -1
  291. package/dist-cjs/sharing/index.js.map +1 -1
  292. package/dist-cjs/sharing/mcp.js +4 -9
  293. package/dist-cjs/sharing/mcp.js.map +1 -1
  294. package/dist-cjs/versions/admit.js +36 -0
  295. package/dist-cjs/versions/admit.js.map +1 -0
  296. package/dist-cjs/versions/api.js +106 -0
  297. package/dist-cjs/versions/api.js.map +1 -0
  298. package/dist-cjs/versions/cli-text.js +72 -0
  299. package/dist-cjs/versions/cli-text.js.map +1 -0
  300. package/dist-cjs/versions/cli.js +126 -0
  301. package/dist-cjs/versions/cli.js.map +1 -0
  302. package/dist-cjs/versions/commands.js +93 -0
  303. package/dist-cjs/versions/commands.js.map +1 -0
  304. package/dist-cjs/versions/content.js +32 -0
  305. package/dist-cjs/versions/content.js.map +1 -0
  306. package/dist-cjs/versions/dates.js +125 -0
  307. package/dist-cjs/versions/dates.js.map +1 -0
  308. package/dist-cjs/versions/deliver.js +41 -0
  309. package/dist-cjs/versions/deliver.js.map +1 -0
  310. package/dist-cjs/versions/errors.js +35 -0
  311. package/dist-cjs/versions/errors.js.map +1 -0
  312. package/dist-cjs/versions/index.js +37 -0
  313. package/dist-cjs/versions/index.js.map +1 -0
  314. package/dist-cjs/versions/line.js +100 -0
  315. package/dist-cjs/versions/line.js.map +1 -0
  316. package/dist-cjs/versions/list.js +15 -0
  317. package/dist-cjs/versions/list.js.map +1 -0
  318. package/dist-cjs/versions/mcp.js +39 -0
  319. package/dist-cjs/versions/mcp.js.map +1 -0
  320. package/dist-cjs/versions/ports.js +7 -0
  321. package/dist-cjs/versions/ports.js.map +1 -0
  322. package/dist-cjs/versions/read.js +66 -0
  323. package/dist-cjs/versions/read.js.map +1 -0
  324. package/dist-cjs/versions/restore.js +40 -0
  325. package/dist-cjs/versions/restore.js.map +1 -0
  326. package/dist-cjs/versions/services.js +17 -0
  327. package/dist-cjs/versions/services.js.map +1 -0
  328. package/dist-cjs/versions/show.js +18 -0
  329. package/dist-cjs/versions/show.js.map +1 -0
  330. package/dist-cjs/versions/types.js +8 -0
  331. package/dist-cjs/versions/types.js.map +1 -0
  332. package/dist-cjs/versions/versions.js +18 -0
  333. package/dist-cjs/versions/versions.js.map +1 -0
  334. package/package.json +16 -4
  335. package/dist/git/commands.d.ts +0 -3
  336. package/dist/git/commands.d.ts.map +0 -1
  337. package/dist/git/commands.js +0 -35
  338. package/dist/git/commands.js.map +0 -1
  339. package/dist/sharing/command-input.d.ts.map +0 -1
  340. package/dist/sharing/command-input.js.map +0 -1
  341. package/dist-cjs/git/commands.js +0 -39
  342. package/dist-cjs/git/commands.js.map +0 -1
  343. package/dist-cjs/sharing/command-input.js.map +0 -1
@@ -0,0 +1,105 @@
1
+ /**
2
+ * The line between a project's Git and its uncommitted work.
3
+ *
4
+ * A file's record states its bytes only while they differ from what its
5
+ * project's index holds at its path (unstaged or untracked work); otherwise
6
+ * the project's record states them, since its package carries every blob the
7
+ * index names. Detect decides this, here, for every file under a
8
+ * project; Send and Receive carry what it decided, and the project's play
9
+ * writes its checkout (`places.ts`).
10
+ *
11
+ * Git's index is the warm map: every path with its blob and mode. Detect's
12
+ * own proof of a file's bytes adds the file's literal blob id, read in the
13
+ * same pass that hashes it, so judging a file is a lookup and a commit of a
14
+ * thousand files reads none of them. Git's clean answer and its stat data are
15
+ * never trusted: only literal bytes count.
16
+ */
17
+ import type { CloudEntityRecord } from '../entities/cloud.js';
18
+ import type { PortableFileMode, Sha256Hex } from '../entities/types.js';
19
+ /** One stage-0 index entry, as Git's index states it. */
20
+ export interface GitIndexEntry {
21
+ /** The blob id, in the repository's object format. */
22
+ readonly oid: string;
23
+ /** Git's entry mode: 0o100644, 0o100755, 0o120000, 0o160000. */
24
+ readonly mode: number;
25
+ readonly skipWorktree: boolean;
26
+ readonly intentToAdd: boolean;
27
+ }
28
+ /** One reading of a project: its stage-0 entries by checkout-relative path,
29
+ * and whether its objects are a promisor remote's (a partial clone). */
30
+ export interface GitHolding {
31
+ readonly entries: ReadonlyMap<string, GitIndexEntry>;
32
+ readonly promisor: boolean;
33
+ }
34
+ /** What Detect proved of one file in the read that hashed it: its literal
35
+ * Git blob id in the project's object format, and its mode as this disk
36
+ * shows it. */
37
+ export interface GitHeldProof {
38
+ readonly gitBlob: string | null;
39
+ readonly fileMode: PortableFileMode | null;
40
+ }
41
+ /** What a Git's file shows: a blob at a mode. */
42
+ export interface GitPlace {
43
+ readonly oid: string;
44
+ readonly fileMode: PortableFileMode;
45
+ }
46
+ /** What a checkout writes for one index entry: an ordinary stage-0 file it
47
+ * checks out, else nothing. A link or a submodule is never Git's file. */
48
+ export declare function gitPlace(entry: GitIndexEntry | undefined): GitPlace | null;
49
+ /**
50
+ * Whether the project's Git holds the file at `path`: its index entry is an
51
+ * ordinary stage-0 file Git checks out, and the file's literal bytes and
52
+ * shown mode are the entry's. Links, and every file of a partial clone, are
53
+ * always the file's own.
54
+ */
55
+ export declare function gitHolds(holding: GitHolding, path: string, proof: GitHeldProof): boolean;
56
+ /**
57
+ * The record of a file Git holds: no payload and no size, since the project's
58
+ * record states its bytes. Its type and mode are what the disk shows, as for
59
+ * every file: a switch that turns a Git's file binary or executable states
60
+ * that on its row, byte-free.
61
+ */
62
+ export declare function heldResult(observed: CloudEntityRecord, sha256Hex: Sha256Hex): CloudEntityRecord;
63
+ /**
64
+ * The record of a file Git holds that is gone from its checkout: absent, an
65
+ * uncommitted change like an edit (`fileAbsent`). It keeps its UUID, place
66
+ * and type, and states no bytes and no mode, so it shows nowhere; Git keeps
67
+ * its copy, so it never enters Trash. The file that comes back at its
68
+ * address is the same entity.
69
+ */
70
+ export declare function absentResult(row: CloudEntityRecord, sha256Hex: Sha256Hex): CloudEntityRecord;
71
+ /** Whose facts a held file's judgment rests on. */
72
+ export interface GitHeldOwnership {
73
+ /** Its row is the result of this computer's own newest record of it. */
74
+ readonly row: boolean;
75
+ /** Its project's state is this computer's: the result of its own newest
76
+ * record, or the record this capture makes. */
77
+ readonly project: boolean;
78
+ /** A record states its row: one accepted or still to send. A row only a
79
+ * graph head holds (Register, Add) has no record an echo could join. */
80
+ readonly line: boolean;
81
+ }
82
+ /**
83
+ * How a file that Git now holds states it. A computer states only what it
84
+ * changed; an accepted record it has not played yet is Apply's.
85
+ *
86
+ * - `echo`: its bytes and every other fact still equal its row's, and the
87
+ * row is this computer's own (a commit here). Only ownership moved: an
88
+ * echo that joins the row and plays nothing onto anything else, so another
89
+ * computer's edit accepted between stands as that file's own. A row no
90
+ * record states has nothing on its line to join, so its commit is a
91
+ * `change`.
92
+ * - `kept`: the same, with the row another computer's. Nothing changed
93
+ * here: the file reads as its row states, with no record; the computer
94
+ * whose row it is states the echo.
95
+ * - `apply`: under a project whose state is another computer's, no row, or
96
+ * a Git's row (no bytes) the file no longer reads as. That computer's play
97
+ * placed the file, and the file's own record, which follows its
98
+ * project's, finds it standing: Detect leaves it to Apply.
99
+ * - `change`: anything else is a change made here (a reset, a restore, a
100
+ * stash, a new file): an ordinary change, and the later one wins. A file
101
+ * coming back over an absent row is always one: an absent row shows
102
+ * nowhere, so no Apply placed it.
103
+ */
104
+ export declare function heldStatement(base: CloudEntityRecord | null, observed: CloudEntityRecord, own: GitHeldOwnership): 'echo' | 'kept' | 'apply' | 'change';
105
+ //# sourceMappingURL=holds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holds.d.ts","sourceRoot":"","sources":["../../src/git/holds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAExE,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC5B,sDAAsD;IACtD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAED;wEACwE;AACxE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACrD,QAAQ,CAAC,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
2
+ * The line between a project's Git and its uncommitted work.
3
+ *
4
+ * A file's record states its bytes only while they differ from what its
5
+ * project's index holds at its path (unstaged or untracked work); otherwise
6
+ * the project's record states them, since its package carries every blob the
7
+ * index names. Detect decides this, here, for every file under a
8
+ * project; Send and Receive carry what it decided, and the project's play
9
+ * writes its checkout (`places.ts`).
10
+ *
11
+ * Git's index is the warm map: every path with its blob and mode. Detect's
12
+ * own proof of a file's bytes adds the file's literal blob id, read in the
13
+ * same pass that hashes it, so judging a file is a lookup and a commit of a
14
+ * thousand files reads none of them. Git's clean answer and its stat data are
15
+ * never trusted: only literal bytes count.
16
+ */
17
+ import { canonicalVersion, fileAbsent } from '../entities/rules.js';
18
+ const REGULAR = new Map([[0o100644, 0o644], [0o100755, 0o755]]);
19
+ /** What a checkout writes for one index entry: an ordinary stage-0 file it
20
+ * checks out, else nothing. A link or a submodule is never Git's file. */
21
+ export function gitPlace(entry) {
22
+ if (entry === undefined || entry.skipWorktree || entry.intentToAdd)
23
+ return null;
24
+ const fileMode = REGULAR.get(entry.mode);
25
+ return fileMode === undefined ? null : { oid: entry.oid, fileMode };
26
+ }
27
+ /**
28
+ * Whether the project's Git holds the file at `path`: its index entry is an
29
+ * ordinary stage-0 file Git checks out, and the file's literal bytes and
30
+ * shown mode are the entry's. Links, and every file of a partial clone, are
31
+ * always the file's own.
32
+ */
33
+ export function gitHolds(holding, path, proof) {
34
+ if (holding.promisor)
35
+ return false;
36
+ const place = gitPlace(holding.entries.get(path));
37
+ return place !== null && proof.fileMode === place.fileMode && proof.gitBlob === place.oid;
38
+ }
39
+ const FILES = new Set(['file.text', 'file.binary']);
40
+ /**
41
+ * The record of a file Git holds: no payload and no size, since the project's
42
+ * record states its bytes. Its type and mode are what the disk shows, as for
43
+ * every file: a switch that turns a Git's file binary or executable states
44
+ * that on its row, byte-free.
45
+ */
46
+ export function heldResult(observed, sha256Hex) {
47
+ if (!FILES.has(observed.type))
48
+ throw new Error(`Git holds only ordinary files, not a ${observed.type}`);
49
+ const held = { ...observed, payloadVersion: null, size: null };
50
+ return { ...held, version: canonicalVersion(held, sha256Hex) };
51
+ }
52
+ /**
53
+ * The record of a file Git holds that is gone from its checkout: absent, an
54
+ * uncommitted change like an edit (`fileAbsent`). It keeps its UUID, place
55
+ * and type, and states no bytes and no mode, so it shows nowhere; Git keeps
56
+ * its copy, so it never enters Trash. The file that comes back at its
57
+ * address is the same entity.
58
+ */
59
+ export function absentResult(row, sha256Hex) {
60
+ if (!FILES.has(row.type))
61
+ throw new Error(`Git holds only ordinary files, not a ${row.type}`);
62
+ const absent = { ...row, payloadVersion: null, size: null, fileMode: null, mtime: null };
63
+ return { ...absent, version: canonicalVersion(absent, sha256Hex) };
64
+ }
65
+ /**
66
+ * How a file that Git now holds states it. A computer states only what it
67
+ * changed; an accepted record it has not played yet is Apply's.
68
+ *
69
+ * - `echo`: its bytes and every other fact still equal its row's, and the
70
+ * row is this computer's own (a commit here). Only ownership moved: an
71
+ * echo that joins the row and plays nothing onto anything else, so another
72
+ * computer's edit accepted between stands as that file's own. A row no
73
+ * record states has nothing on its line to join, so its commit is a
74
+ * `change`.
75
+ * - `kept`: the same, with the row another computer's. Nothing changed
76
+ * here: the file reads as its row states, with no record; the computer
77
+ * whose row it is states the echo.
78
+ * - `apply`: under a project whose state is another computer's, no row, or
79
+ * a Git's row (no bytes) the file no longer reads as. That computer's play
80
+ * placed the file, and the file's own record, which follows its
81
+ * project's, finds it standing: Detect leaves it to Apply.
82
+ * - `change`: anything else is a change made here (a reset, a restore, a
83
+ * stash, a new file): an ordinary change, and the later one wins. A file
84
+ * coming back over an absent row is always one: an absent row shows
85
+ * nowhere, so no Apply placed it.
86
+ */
87
+ export function heldStatement(base, observed, own) {
88
+ if (base !== null && fileAbsent(base))
89
+ return 'change';
90
+ if (base === null || (base.payloadVersion === null && !own.project))
91
+ return own.project ? 'change' : 'apply';
92
+ const equal = base.payloadVersion !== null && FILES.has(base.type)
93
+ && base.status === 'active' && observed.status === 'active'
94
+ && base.parentUUID === observed.parentUUID && base.name === observed.name
95
+ && base.type === observed.type && base.payloadVersion === observed.payloadVersion
96
+ && base.fileMode === observed.fileMode;
97
+ if (!equal)
98
+ return 'change';
99
+ if (!own.row)
100
+ return 'kept';
101
+ return own.line ? 'echo' : 'change';
102
+ }
103
+ //# sourceMappingURL=holds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holds.js","sourceRoot":"","sources":["../../src/git/holds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAkCpE,MAAM,OAAO,GAAG,IAAI,GAAG,CAA2B,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAE1F;0EAC0E;AAC1E,MAAM,UAAU,QAAQ,CAAC,KAAgC;IACvD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IAChF,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC;AACtE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAmB,EAAE,IAAY,EAAE,KAAmB;IAC7E,IAAI,OAAO,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IACnC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ,IAAI,KAA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ACvD,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;IAC7G,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,KAAK,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;WAC7D,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,QAAQ;WACxD,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI;WACtE,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,QAAQ,CAAC,cAAc;WAC9E,IAAI,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,CAAC;IACzC,IAAI,CAAC,KAAK;QAAE,OAAO,QAAQ,CAAC;IAC5B,IAAI,CAAC,GAAG,CAAC,GAAG;QAAE,OAAO,MAAM,CAAC;IAC5B,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;AACtC,CAAC"}
@@ -5,7 +5,10 @@ export * from './artifact.js';
5
5
  export * from './chain.js';
6
6
  export * from './plan.js';
7
7
  export * from './play.js';
8
- export * from './commands.js';
9
8
  export * from './tag.js';
10
9
  export * from './turns.js';
10
+ export * from './holds.js';
11
+ export * from './places.js';
12
+ export { GIT_PARTS, gitPartBlobs, gitParts, gitPartsChanged, type GitPart } from './parts.js';
13
+ export * from './restore.js';
11
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/git/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/git/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAC9F,cAAc,cAAc,CAAC"}
package/dist/git/index.js CHANGED
@@ -5,7 +5,10 @@ export * from './artifact.js';
5
5
  export * from './chain.js';
6
6
  export * from './plan.js';
7
7
  export * from './play.js';
8
- export * from './commands.js';
9
8
  export * from './tag.js';
10
9
  export * from './turns.js';
10
+ export * from './holds.js';
11
+ export * from './places.js';
12
+ export { GIT_PARTS, gitPartBlobs, gitParts, gitPartsChanged } from './parts.js';
13
+ export * from './restore.js';
11
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/git/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/git/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAgB,MAAM,YAAY,CAAC;AAC9F,cAAc,cAAc,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * A repository's five parts: what a person changes in Git's own state,
3
+ * each one digest. A version of a repository starts exactly when one of
4
+ * them changes; housekeeping (pack-refs, fetch, gc, a reflog growing, the
5
+ * index re-stamped) changes none.
6
+ *
7
+ * - refs: HEAD and every ref, loose or packed, but the remote-tracking and
8
+ * prefetched ones a fetch moves, and the stash, which is its own part.
9
+ * - stash: the stash's entries, newest last.
10
+ * - staged: what the index means, never its stat data.
11
+ * - operation: an unfinished merge, cherry-pick, revert, rebase or bisect.
12
+ * - settings: configuration, hooks, and the info files Git reads.
13
+ *
14
+ * Every part reads the Git directory as this checkout's Git reads it. A
15
+ * ref is named by the blob ID of its one line, packed or loose alike, so
16
+ * `git pack-refs` changes nothing; only `packed-refs`, the stash's reflog
17
+ * and `config` need bytes, and the rest follow from the state, since a
18
+ * file's blob ID is its bytes. A fetch of branches changes no part; a tag it
19
+ * follows does. `config` is read without the tag (tag.ts): the tag is ours,
20
+ * never the person's, so putting it on or back is no version.
21
+ */
22
+ import type { Sha256Hex } from '../entities/types.js';
23
+ import { type GitState } from './state.js';
24
+ export declare const GIT_PARTS: readonly ["refs", "stash", "staged", "operation", "settings"];
25
+ export type GitPart = typeof GIT_PARTS[number];
26
+ export declare const GIT_PACKED_REFS = "packed-refs";
27
+ /** HEAD and every ref but those a fetch moves: what a restore puts back. */
28
+ export declare const gitOwnRef: (name: string) => boolean;
29
+ /** The files besides refs and the index that a restore puts back. */
30
+ export declare const gitOwnFile: (path: string) => boolean;
31
+ /** The blobs whose bytes the parts read, at most three: `packed-refs`, the
32
+ * stash's reflog and `config`. A host hands these to `gitParts`. */
33
+ export declare const gitPartBlobs: (state: GitState) => string[];
34
+ /**
35
+ * The five parts' digests joined by `.`, in GIT_PARTS order. `bytes` answers
36
+ * each blob `gitPartBlobs` names; a host that cannot must throw, never guess.
37
+ */
38
+ export declare function gitParts(state: GitState, bytes: (oid: string) => Uint8Array, sha256: Sha256Hex): string;
39
+ /** The parts that differ between two `gitParts` answers. */
40
+ export declare function gitPartsChanged(before: string, after: string): GitPart[];
41
+ //# sourceMappingURL=parts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../../src/git/parts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,EAA6B,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtE,eAAO,MAAM,SAAS,+DAAgE,CAAC;AACvF,MAAM,MAAM,OAAO,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;AAS/C,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C,4EAA4E;AAC5E,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,OAC6B,CAAC;AACvE,qEAAqE;AACrE,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,OAAwE,CAAC;AAmBnH;oEACoE;AACpE,eAAO,MAAM,YAAY,GAAI,OAAO,QAAQ,KAAG,MAAM,EAEpB,CAAC;AAqClC;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,UAAU,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAWvG;AAED,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,EAAE,CAGxE"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * A repository's five parts: what a person changes in Git's own state,
3
+ * each one digest. A version of a repository starts exactly when one of
4
+ * them changes; housekeeping (pack-refs, fetch, gc, a reflog growing, the
5
+ * index re-stamped) changes none.
6
+ *
7
+ * - refs: HEAD and every ref, loose or packed, but the remote-tracking and
8
+ * prefetched ones a fetch moves, and the stash, which is its own part.
9
+ * - stash: the stash's entries, newest last.
10
+ * - staged: what the index means, never its stat data.
11
+ * - operation: an unfinished merge, cherry-pick, revert, rebase or bisect.
12
+ * - settings: configuration, hooks, and the info files Git reads.
13
+ *
14
+ * Every part reads the Git directory as this checkout's Git reads it. A
15
+ * ref is named by the blob ID of its one line, packed or loose alike, so
16
+ * `git pack-refs` changes nothing; only `packed-refs`, the stash's reflog
17
+ * and `config` need bytes, and the rest follow from the state, since a
18
+ * file's blob ID is its bytes. A fetch of branches changes no part; a tag it
19
+ * follows does. `config` is read without the tag (tag.ts): the tag is ours,
20
+ * never the person's, so putting it on or back is no version.
21
+ */
22
+ import { utf8Decode, utf8Encode } from '../entities/bytes.js';
23
+ import { gitBlobId } from './artifact.js';
24
+ import { gitPackedRefs } from './refs.js';
25
+ import { gitConfigUntagged } from './tag.js';
26
+ import { gitSelfHeld } from './state.js';
27
+ import { compareGitText } from './text.js';
28
+ export const GIT_PARTS = ['refs', 'stash', 'staged', 'operation', 'settings'];
29
+ const OPERATION = /^(MERGE_(HEAD|MSG|MODE|AUTOSTASH)|AUTO_MERGE|CHERRY_PICK_HEAD|REVERT_HEAD|REBASE_HEAD|SQUASH_MSG|BISECT_[A-Z_]+|(rebase-merge|rebase-apply|sequencer)\/.+)$/;
30
+ const SETTINGS = /^(config|config\.worktree|hooks(\/.+)?|info\/(exclude|attributes|sparse-checkout)|description)$/;
31
+ const FETCHED = /^refs\/(remotes|prefetch)\//;
32
+ /** What Git keeps per worktree; everything else a worktree shares. */
33
+ const PER_WORKTREE = /^(HEAD|config\.worktree|info\/sparse-checkout|refs\/(bisect|worktree|rewritten)\/.+)$/;
34
+ const STASH = 'logs/refs/stash';
35
+ const CONFIG = 'config';
36
+ export const GIT_PACKED_REFS = 'packed-refs';
37
+ /** HEAD and every ref but those a fetch moves: what a restore puts back. */
38
+ export const gitOwnRef = (name) => (name === 'HEAD' || name.startsWith('refs/')) && !FETCHED.test(name);
39
+ /** The files besides refs and the index that a restore puts back. */
40
+ export const gitOwnFile = (path) => path === STASH || OPERATION.test(path) || SETTINGS.test(path);
41
+ const isRef = (name) => gitOwnRef(name) && name !== 'refs/stash';
42
+ /** The Git directory's files as this checkout's Git reads them, by path: a
43
+ * self-held worktree's own files stand under its home in its storage, and
44
+ * its storage's are the shared rest. */
45
+ function view(state) {
46
+ const own = gitSelfHeld(state.home) ? `${state.home.path}/` : null;
47
+ const files = new Map();
48
+ for (const file of state.files) {
49
+ if (file.oid === null)
50
+ continue;
51
+ if (own === null)
52
+ files.set(file.path, file);
53
+ else if (file.path.startsWith(own))
54
+ files.set(file.path.slice(own.length), file);
55
+ else if (!file.path.startsWith('worktrees/') && !PER_WORKTREE.test(file.path)
56
+ && !OPERATION.test(file.path))
57
+ files.set(file.path, file);
58
+ }
59
+ return files;
60
+ }
61
+ /** The blobs whose bytes the parts read, at most three: `packed-refs`, the
62
+ * stash's reflog and `config`. A host hands these to `gitParts`. */
63
+ export const gitPartBlobs = (state) => [...view(state)].filter(([path]) => path === GIT_PACKED_REFS || path === STASH || path === CONFIG)
64
+ .map(([, file]) => file.oid);
65
+ const lines = (files, matches) => [...files].filter(([path]) => matches(path)).sort(([left], [right]) => compareGitText(left, right))
66
+ .map(([path, file]) => `${path} ${file.mode} ${file.oid}\n`).join('');
67
+ function refs(files, text, sha256) {
68
+ if ([...files.keys()].some(path => path.startsWith('reftable/'))) {
69
+ return lines(files, path => path.startsWith('reftable/'));
70
+ }
71
+ const named = new Map();
72
+ const packed = files.get(GIT_PACKED_REFS);
73
+ for (const [name, oid] of packed ? gitPackedRefs(text(packed)) : []) {
74
+ if (isRef(name))
75
+ named.set(name, gitBlobId(utf8Encode(`${oid}\n`), sha256));
76
+ }
77
+ for (const [path, file] of files)
78
+ if (isRef(path))
79
+ named.set(path, file.oid);
80
+ return [...named].sort(([left], [right]) => compareGitText(left, right))
81
+ .map(([name, line]) => `${name} ${line}\n`).join('');
82
+ }
83
+ function stash(files, text) {
84
+ const log = files.get(STASH);
85
+ return log === undefined ? '' : text(log).split('\n').filter(line => line !== '')
86
+ .map(line => `${line.split(' ', 2)[1]}\n`).join('');
87
+ }
88
+ /** The settings' files, `config` named by the blob ID of its text without
89
+ * the tag. */
90
+ function settings(files, text, sha256) {
91
+ const config = files.get(CONFIG);
92
+ const read = new Map(files);
93
+ if (config !== undefined) {
94
+ read.set(CONFIG, { ...config, oid: gitBlobId(utf8Encode(gitConfigUntagged(text(config))), sha256) });
95
+ }
96
+ return lines(read, path => SETTINGS.test(path));
97
+ }
98
+ /**
99
+ * The five parts' digests joined by `.`, in GIT_PARTS order. `bytes` answers
100
+ * each blob `gitPartBlobs` names; a host that cannot must throw, never guess.
101
+ */
102
+ export function gitParts(state, bytes, sha256) {
103
+ const files = view(state);
104
+ const text = (file) => utf8Decode(bytes(file.oid));
105
+ const documents = {
106
+ refs: refs(files, text, sha256),
107
+ stash: stash(files, text),
108
+ staged: state.index?.meaning ?? '',
109
+ operation: lines(files, path => OPERATION.test(path)),
110
+ settings: settings(files, text, sha256),
111
+ };
112
+ return GIT_PARTS.map(part => sha256(utf8Encode(`amalgm.git-part.v1 ${part}\n${documents[part]}`))).join('.');
113
+ }
114
+ /** The parts that differ between two `gitParts` answers. */
115
+ export function gitPartsChanged(before, after) {
116
+ const was = before.split('.'), now = after.split('.');
117
+ return GIT_PARTS.filter((_, at) => was[at] !== now[at]);
118
+ }
119
+ //# sourceMappingURL=parts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parts.js","sourceRoot":"","sources":["../../src/git/parts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,WAAW,EAA+B,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,CAAU,CAAC;AAGvF,MAAM,SAAS,GAAG,6JAA6J,CAAC;AAChL,MAAM,QAAQ,GAAG,iGAAiG,CAAC;AACnH,MAAM,OAAO,GAAG,6BAA6B,CAAC;AAC9C,sEAAsE;AACtE,MAAM,YAAY,GAAG,uFAAuF,CAAC;AAC7G,MAAM,KAAK,GAAG,iBAAiB,CAAC;AAChC,MAAM,MAAM,GAAG,QAAQ,CAAC;AACxB,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAE7C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAY,EAAW,EAAE,CACjD,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CA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C,SAAS,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrD,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC;KACxC,CAAC;IACF,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,sBAAsB,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/G,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,KAAa;IAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtD,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * What a project's play writes in its checkout (`holds.ts`).
3
+ *
4
+ * A project's record writes its checkout, as a checkout does: the play
5
+ * places and removes exactly what its new index changes. Every path whose
6
+ * checked-out place under the index before the play differs from its place
7
+ * under the index after it is written: the literal blob and mode the new
8
+ * index names, or nothing where it has nothing Git checks out. The work is
9
+ * the index's difference, never the checkout's size, and it never depends on
10
+ * which rows a receiver already holds, so a file new in the index stands
11
+ * once the play does, whatever order its own record arrives in.
12
+ *
13
+ * The host leaves a path alone whose file states its own bytes (its own
14
+ * record places it), one with unsent local work, one whose disk no longer
15
+ * shows the place before the play (a person's, which Detect records), and
16
+ * one another member of the play's window places. A file the new index
17
+ * leaves out is absent, on disk and in what is shared: no Trash follows.
18
+ */
19
+ import { type GitIndexEntry, type GitPlace } from './holds.js';
20
+ /** One checkout path the play moves: the blob and mode to write, or null to
21
+ * remove the file. */
22
+ export interface GitPlacement {
23
+ readonly path: string;
24
+ readonly place: GitPlace | null;
25
+ }
26
+ /**
27
+ * The checkout paths a repository's play moves: each whose place under the
28
+ * index before the play differs from its place under the index after it,
29
+ * before's paths first, then the paths only after names. A path whose entry
30
+ * the play leaves alone is not touched.
31
+ */
32
+ export declare function gitPlacements(before: ReadonlyMap<string, GitIndexEntry>, after: ReadonlyMap<string, GitIndexEntry>): GitPlacement[];
33
+ //# sourceMappingURL=places.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"places.d.ts","sourceRoot":"","sources":["../../src/git/places.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAY,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEzE;sBACsB;AACtB,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACjC;AAKD;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,GACxC,YAAY,EAAE,CAOhB"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * What a project's play writes in its checkout (`holds.ts`).
3
+ *
4
+ * A project's record writes its checkout, as a checkout does: the play
5
+ * places and removes exactly what its new index changes. Every path whose
6
+ * checked-out place under the index before the play differs from its place
7
+ * under the index after it is written: the literal blob and mode the new
8
+ * index names, or nothing where it has nothing Git checks out. The work is
9
+ * the index's difference, never the checkout's size, and it never depends on
10
+ * which rows a receiver already holds, so a file new in the index stands
11
+ * once the play does, whatever order its own record arrives in.
12
+ *
13
+ * The host leaves a path alone whose file states its own bytes (its own
14
+ * record places it), one with unsent local work, one whose disk no longer
15
+ * shows the place before the play (a person's, which Detect records), and
16
+ * one another member of the play's window places. A file the new index
17
+ * leaves out is absent, on disk and in what is shared: no Trash follows.
18
+ */
19
+ import { gitPlace } from './holds.js';
20
+ const samePlace = (left, right) => left === null ? right === null : right !== null && left.oid === right.oid && left.fileMode === right.fileMode;
21
+ /**
22
+ * The checkout paths a repository's play moves: each whose place under the
23
+ * index before the play differs from its place under the index after it,
24
+ * before's paths first, then the paths only after names. A path whose entry
25
+ * the play leaves alone is not touched.
26
+ */
27
+ export function gitPlacements(before, after) {
28
+ const moved = [];
29
+ for (const path of new Set([...before.keys(), ...after.keys()])) {
30
+ const place = gitPlace(after.get(path));
31
+ if (!samePlace(gitPlace(before.get(path)), place))
32
+ moved.push({ path, place });
33
+ }
34
+ return moved;
35
+ }
36
+ //# sourceMappingURL=places.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"places.js","sourceRoot":"","sources":["../../src/git/places.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAqC,MAAM,YAAY,CAAC;AASzE,MAAM,SAAS,GAAG,CAAC,IAAqB,EAAE,KAAsB,EAAW,EAAE,CAC3E,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ,CAAC;AAEhH;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,MAA0C,EAC1C,KAAyC;IAEzC,MAAM,KAAK,GAAmB,EAAE,CAAC;IACjC,KAAK,MAAM,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QAChE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QACxC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Restoring a repository version: Git's own state put back as it stood,
3
+ * and nothing else. Branches, tags, HEAD, the stash, what is staged, an
4
+ * unfinished operation and the settings become the version's; the working
5
+ * files, the reflogs, the remote-tracking refs and every file no part reads
6
+ * stay as they stand here, but the reflog of a ref the restore removes, and
7
+ * anything here standing where the version's entries go. So the goal's five
8
+ * parts are the version's (parts.ts), and Detect records the restore as an
9
+ * ordinary change.
10
+ *
11
+ * Each of the version's refs is written loose, and `packed-refs` keeps only
12
+ * the refs a restore leaves, so a ref here that the version lacks goes.
13
+ *
14
+ * The goal's `config` is the version's, and the version may predate the
15
+ * tag (tag.ts). The host writes the goal as our Git, holding this
16
+ * computer's turn, and leaves the tag as it stood here before the turn
17
+ * ends; the settings part never reads the tag, so this is still the
18
+ * version's settings.
19
+ */
20
+ import { type Checked } from '../contracts/validate.js';
21
+ import type { Sha256Hex } from '../entities/types.js';
22
+ import { type GitState } from './state.js';
23
+ export interface GitRestoreGoal {
24
+ readonly state: GitState;
25
+ /** Bytes the goal names that neither state holds, by blob ID. */
26
+ readonly blobs: ReadonlyMap<string, Uint8Array>;
27
+ }
28
+ /**
29
+ * The state that puts `then`'s Git state back over `here`. `bytes` answers
30
+ * each state's `packed-refs`. Refused when either state is in a form a
31
+ * restore cannot write: in byte form, in reftable, or a self-held worktree,
32
+ * whose storage is shared with checkouts no restore should move.
33
+ */
34
+ export declare function gitRestoreGoal(here: GitState, then: GitState, bytes: (oid: string) => Uint8Array, sha256: Sha256Hex): Checked<GitRestoreGoal>;
35
+ //# sourceMappingURL=restore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restore.d.ts","sourceRoot":"","sources":["../../src/git/restore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,EAA0D,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGnG,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACjD;AAOD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,UAAU,EAAE,MAAM,EAAE,SAAS,GACpF,OAAO,CAAC,cAAc,CAAC,CAiEzB"}