╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ net.zig ──────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1345 try client_repo.addRemote(io, allocator, .{ .name = "origin", .value = remote_url }); 1346 try client_repo.addConfig(io, allocator, .{ .name = "branch.master.remote", .value = "origin" }); 1347 } 1348 1349 const is_ssh = switch (transport_def) { 1350 .file => false, 1351 .wire => |wire_kind| .ssh == wire_kind, 1352 }; 1353 1354 if (shell_out_to_git) { 1355 const ssh_cmd = (try sshCommand(true, allocator, temp_path, port)).?; 1356 defer allocator.free(ssh_cmd); 1357 const ssh_config_arg = try std.fmt.allocPrint(allocator, "core.sshCommand={s}", .{ssh_cmd}); 1358 defer allocator.free(ssh_config_arg); 1359 1360 { 1361 var process = try std.process.spawn(io, .{ 1362 .argv = if (is_ssh) 1363 &.{ "git", "-c", ssh_config_arg, "pull", "--quiet", "origin", "master" } 1364 else 1365 &.{ "git", "pull", "--quiet", "origin", "master" }, 1366 .cwd = .{ .path = client_path }, 1367 .stdin = .ignore, 1368 .stdout = .ignore, 1369 .stderr = .inherit, 1370 }); 1371 defer process.kill(io); 1372 const term = try process.wait(io); 1373 if (term != .exited or term.exited != 0) return error.GitCommandFailed; 1374 } 1375 1376 // make sure pull was successful 1377 { 1378 const oid_master = (try client_repo.readRef(io, .{ .kind = .head, .name = "master" })).?; 1379 try std.testing.expectEqualStrings(&commit1, &oid_master); 1380 } 1381 1382 // make another commit on the server 1383 const commit2 = try commitServer(&server_repo, io, allocator, .{ .files = &.{.{ .path = "extra.txt", .content = "extra content" }} }, .{ .message = "add extra file" }); 1384 1385 // fetch with ref-in-want (git uses want-ref in protocol v2 when fetching named refs) 1386 { 1387 var process = try std.process.spawn(io, .{ 1388 .argv = if (is_ssh) 1389 &.{ "git", "-c", ssh_config_arg, "fetch", "--quiet", "origin", "master" } 1390 else 1391 &.{ "git", "fetch", "--quiet", "origin", "master" }, 1392 .cwd = .{ .path = client_path }, 1393 .stdin = .ignore, 1394 .stdout = .ignore, 1395 .stderr = .inherit, 1396 }); 1397 defer process.kill(io); 1398 const term = try process.wait(io); 1399 if (term != .exited or term.exited != 0) return error.GitCommandFailed; 1400 } 1401 1402 // make sure fetch with want-ref was successful 1403 { 1404 const oid_remote_master = (try client_repo.readRef(io, .{ .kind = .{ .remote = "origin" }, .name = "master" })).?; 1405 try std.testing.expectEqualStrings(&commit2, &oid_remote_master); 1406 } 1407 } else { 1408 const refspecs = &.{ 1409 "+refs/heads/master:refs/heads/master", 1410 }; 1411 1412 const ssh_cmd_maybe = try sshCommand(is_ssh, allocator, temp_path, port); 1413 defer if (ssh_cmd_maybe) |ssh_cmd| allocator.free(ssh_cmd); 1414 1415 try client_repo.fetch( 1416 io, 1417 allocator, 1418 "origin", 1419 .{ .refspecs = refspecs, .wire = .{ .ssh = .{ 1420 .command = ssh_cmd_maybe, 1421 } } }, 1422 ); 1423 1424 // update the working dir 1425 try client_repo.restore(io, allocator, "."); 1426 } 1427 1428 // make sure fetch was successful 1429 { 1430 const oid_master = (try client_repo.readRef(io, .{ .kind = .head, .name = "master" })).?; 1431 try std.testing.expectEqualStrings(&commit1, &oid_master); 1432 } 1433 } 1434 1435 fn testPushLarge( 1436 comptime repo_kind: rp.RepoKind, 1437 comptime transport_def: net.TransportDefinition, 1438 comptime shell_out_to_git: bool, 1439 comptime hash_kind: hash.HashKind, 1440 comptime port: u16, 1441 io: std.Io, 1442 allocator: std.mem.Allocator, 1443 ) !void { 1444 // create the temp dir 1445 var temp = std.testing.tmpDir(.{}); 1446 defer temp.cleanup(); 1447 const temp_path = try temp.dir.realPathFileAlloc(io, ".", allocator); 1448 defer allocator.free(temp_path); 1449 1450 // init server 1451 var server_process = try runServer(io, allocator, temp_path, port); 1452 defer _ = server_process.kill(io); 1453 1454 // register the repo under admin and locate its on-disk directory 1455 const server_path = (try repoOnDiskPath(io, allocator, temp_path, "testrepo", true)).?; 1456 defer allocator.free(server_path); 1457 1458 var server_repo = try rp.Repo(.xit, .{ .hash = hash_kind, .is_test = true }).init(io, allocator, .{ .bare = true, .path = server_path }); 1459 defer server_repo.deinit(io, allocator); 1460 1461 // add config 1462 try server_repo.addConfig(io, allocator, .{ .name = "http.receivepack", .value = "true" }); 1463 1464 // export server repo 1465 { 1466 const export_file = try server_repo.core.repo_dir.createFile(io, "git-daemon-export-ok", .{}); 1467 defer export_file.close(io); 1468 } 1469 1470 const client_path = try std.fs.path.join(allocator, &.{ temp_path, "client" }); 1471 defer allocator.free(client_path); 1472 1473 var client_repo = try rp.Repo(repo_kind, .{ .hash = hash_kind, .is_test = true }).init(io, allocator, .{ .path = client_path }); 1474 defer client_repo.deinit(io, allocator); 1475 1476 var client_dir = try temp.dir.openDir(io, "client", .{}); 1477 defer client_dir.close(io); 1478 1479 { 1480 const hello_txt = try client_repo.core.work_dir.createFile(io, "hello.txt", .{ .truncate = true }); 1481 defer hello_txt.close(io); 1482 try hello_txt.writeStreamingAll(io, "hello, world!"); 1483 try client_repo.add(io, allocator, &.{"hello.txt"}); 1484 } 1485 1486 // copy files from current repo into client dir 1487 const cwd = std.Io.Dir.cwd(); 1488 for (&[_][]const u8{"src"}) |dir_name| { 1489 var src_repo_dir = try cwd.openDir(io, dir_name, .{ .iterate = true }); 1490 defer src_repo_dir.close(io); 1491 1492 var dest_repo_dir = try client_dir.createDirPathOpen(io, dir_name, .{}); 1493 defer dest_repo_dir.close(io); 1494 1495 try copyDir(io, src_repo_dir, dest_repo_dir); 1496 1497 try client_repo.add(io, allocator, &.{dir_name}); 1498 } 1499 1500 _ = try client_repo.commit(io, allocator, .{ .message = "let there be light" }); 1501 1502 // change the files so git will send them as delta objects 1503 for (&[_][]const u8{"src"}) |dir_name| { 1504 var dest_repo_dir = try client_dir.createDirPathOpen(io, dir_name, .{ .open_options = .{ .iterate = true } }); 1505 defer dest_repo_dir.close(io); 1506 1507 { 1508 var iter = dest_repo_dir.iterate(); 1509 while (try iter.next(io)) |entry| { 1510 switch (entry.kind) { 1511 .file => { 1512 const file = try dest_repo_dir.openFile(io, entry.name, .{ .mode = .read_write }); 1513 defer file.close(io); 1514 var writer = file.writer(io, &.{}); 1515 try writer.interface.writeAll("EDIT"); 1516 }, 1517 else => {}, 1518 } 1519 } 1520 } 1521 1522 try client_repo.add(io, allocator, &.{dir_name}); 1523 } 1524 1525 const commit2 = try client_repo.commit(io, allocator, .{ .message = "more stuff" }); 1526 1527 // add remote 1528 { 1529 const remote_url = try remoteUrl(transport_def, allocator, "testrepo", port); 1530 defer allocator.free(remote_url); 1531 1532 try client_repo.addRemote(io, allocator, .{ .name = "origin", .value = remote_url }); 1533 try client_repo.addConfig(io, allocator, .{ .name = "branch.master.remote", .value = "origin" }); 1534 } 1535 1536 const is_ssh = switch (transport_def) { 1537 .file => false, 1538 .wire => |wire_kind| .ssh == wire_kind, 1539 }; 1540 1541 if (shell_out_to_git) { 1542 const ssh_cmd = (try sshCommand(true, allocator, temp_path, port)).?; 1543 defer allocator.free(ssh_cmd); 1544 const ssh_config_arg = try std.fmt.allocPrint(allocator, "core.sshCommand={s}", .{ssh_cmd}); 1545 defer allocator.free(ssh_config_arg); 1546 1547 // shell out to git so it will send delta objects 1548 var process = try std.process.spawn(io, .{ 1549 .argv = if (is_ssh) 1550 &.{ "git", "-c", ssh_config_arg, "push", "--quiet", "origin", "master" } 1551 else 1552 &.{ "git", "push", "--quiet", "origin", "master" }, 1553 .cwd = .{ .path = client_path }, 1554 .stdin = .ignore, 1555 .stdout = .ignore, 1556 .stderr = .inherit, 1557 }); 1558 defer process.kill(io); 1559 const term = try process.wait(io); 1560 if (term != .exited or term.exited != 0) return error.GitCommandFailed; 1561 } else { 1562 const ssh_cmd_maybe = try sshCommand(is_ssh, allocator, temp_path, port); 1563 defer if (ssh_cmd_maybe) |ssh_cmd| allocator.free(ssh_cmd); 1564 1565 try client_repo.push( 1566 io, 1567 allocator, 1568 "origin", 1569 "master", 1570 false, 1571 .{ .wire = .{ .ssh = .{ 1572 .command = ssh_cmd_maybe, 1573 } } }, 1574 ); 1575 } 1576 1577 // make sure push was successful 1578 { 1579 const oid_master = (try server_repo.readRef(io, .{ .kind = .head, .name = "master" })).?; 1580 try std.testing.expectEqualStrings(&commit2, &oid_master); 1581 1582 try std.testing.expectError(error.FileNotFound, server_repo.core.work_dir.openFile(io, "hello.txt", .{})); 1583 } 1584 } 1585 1586 fn copyDir(io: std.Io, src_dir: std.Io.Dir, dest_dir: std.Io.Dir) !void { 1587 var iter = src_dir.iterate(); 1588 while (try iter.next(io)) |entry| { 1589 switch (entry.kind) { 1590 .file => try src_dir.copyFile(entry.name, dest_dir, entry.name, io, .{}), 1591 .directory => { 1592 try dest_dir.createDirPath(io, entry.name); 1593 var dest_entry_dir = try dest_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false }); 1594 defer dest_entry_dir.close(io); 1595 var src_entry_dir = try src_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false }); 1596 defer src_entry_dir.close(io); 1597 try copyDir(io, src_entry_dir, dest_entry_dir); 1598 }, 1599 else => {}, 1600 } 1601 } 1602 } 1603 1604 // the dev SSH public key matching the private key written by runServer 1605 const admin_ssh_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKeIs8mJqigBZ5y84J4COgnAJJ5bHPKy+lM2SliMXbYm radar@roark"; 1606 1607 // create the admin event repo with a user holding the dev SSH public key 1608 fn setupAdmin(io: std.Io, allocator: std.mem.Allocator, data_path: []const u8) !void { 1609 const admin_repo_path = try std.fs.path.join(allocator, &.{ data_path, "admin" }); 1610 defer allocator.free(admin_repo_path); 1611 1612 var repo = try rp.Repo(.xit, evt.admin_repo_opts).init(io, allocator, .{ .bare = true, .path = admin_repo_path }); 1613 defer repo.deinit(io, allocator); 1614 1615 try repo.addConfig(io, allocator, .{ .name = "user.name", .value = "haxy" }); 1616 try repo.addConfig(io, allocator, .{ .name = "user.email", .value = "admin@haxy" }); 1617 1618 var prng = std.Random.DefaultPrng.init(std.testing.random_seed); 1619 const user_id = evt.EventWithId.randomId(prng.random()); 1620 1621 var password_hash_buf: [evt.User.password_hash_max_len]u8 = undefined; 1622 const password_hash = try evt.User.hashPassword("password", &password_hash_buf, io); 1623 1624 try evt.consume(.admin, .xit, evt.admin_repo_opts, io, allocator, &repo, evt.events_ref, &[_]evt.EventWithId{.{ 1625 .id = std.fmt.bytesToHex(user_id, .lower), 1626 .author = .{ .name = "admin", .email = "admin@example.test" }, 1627 .event = .{ .user = .{ 1628 .name = "admin", 1629 .email = "admin@example.test", 1630 .password_hash = password_hash, 1631 .ssh_keys = admin_ssh_key, 1632 } }, 1633 }}); 1634 } 1635 1636 // resolve admin/<repo_name> to its on-disk directory under <data_dir>/repos via 1637 // the event store 1638 fn repoOnDiskPath( 1639 io: std.Io, 1640 allocator: std.mem.Allocator, 1641 data_path: []const u8, 1642 repo_name: []const u8, 1643 create: bool, 1644 ) !?[]u8 { 1645 const admin_repo_path = try std.fs.path.join(allocator, &.{ data_path, "admin" }); 1646 defer allocator.free(admin_repo_path); 1647 1648 const event_id_hex = (try evt.resolveOrCreateRepo( 1649 io, 1650 allocator, 1651 admin_repo_path, 1652 "admin", 1653 repo_name, 1654 if (create) .{ .read_access = .public } else null, 1655 )) orelse return null; 1656 return try std.fs.path.join(allocator, &.{ data_path, "repos", &event_id_hex }); 1657 } 1658 1659 // build the remote URL addressing admin/<repo_name> over the given transport 1660 fn remoteUrl( 1661 comptime transport_def: net.TransportDefinition, 1662 allocator: std.mem.Allocator, 1663 repo_name: []const u8, 1664 port: u16, 1665 ) ![]u8 { 1666 return switch (transport_def) { 1667 .file => unreachable, 1668 .wire => |wire_kind| switch (wire_kind) { 1669 .http => try std.fmt.allocPrint(allocator, "http://localhost:{}/admin/{s}", .{ port, repo_name }), 1670 .raw => try std.fmt.allocPrint(allocator, "git://localhost:{}/admin/{s}", .{ port, repo_name }), 1671 .ssh => try std.fmt.allocPrint(allocator, "git@localhost:admin/{s}", .{repo_name}), 1672 }, 1673 }; 1674 } 1675 1676 // the ssh command the haxy git client should invoke, or null when not using 1677 // ssh. haxy generates a fresh host key on every run, so accept the unknown host 1678 // and skip writing to known_hosts. 1679 fn sshCommand( 1680 is_ssh: bool, 1681 allocator: std.mem.Allocator, 1682 temp_path: []const u8, 1683 port: u16, 1684 ) !?[]u8 { 1685 if (!is_ssh) return null; 1686 1687 const priv_key_path = try std.fs.path.join(allocator, &.{ temp_path, "key" }); 1688 defer allocator.free(priv_key_path); 1689 1690 if (builtin.os.tag == .windows) std.mem.replaceScalar(u8, priv_key_path, '\\', '/'); 1691 const null_path = if (builtin.os.tag == .windows) "NUL" else "/dev/null"; 1692 return try std.fmt.allocPrint(allocator, "ssh -p {} -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile={s} -o LogLevel=ERROR -o IdentitiesOnly=yes -i \"{s}\"", .{ port + 1, null_path, priv_key_path }); 1693 } 1694 1695 const ServerFiles = union(enum) { 1696 files: []const struct { path: []const u8, content: []const u8 }, 1697 dirs: []const []const u8, 1698 }; 1699 1700 /// commit files without writing the server's index or worktree. 1701 fn commitServer(repo: anytype, io: std.Io, allocator: std.mem.Allocator, files: ServerFiles, metadata: xit.object.CommitMetadata(repo.self_repo_opts.hash)) ![xit.hash.hexLen(repo.self_repo_opts.hash)]u8 { 1702 const R = @TypeOf(repo.*); 1703 const opts = repo.self_repo_opts; 1704 const Index = xit.index.Index(.xit, opts); 1705 var result: [xit.hash.hexLen(opts.hash)]u8 = undefined; 1706 const Ctx = struct { 1707 core: *R.Core, 1708 io: std.Io, 1709 allocator: std.mem.Allocator, 1710 files: ServerFiles, 1711 metadata: xit.object.CommitMetadata(opts.hash), 1712 result: *[xit.hash.hexLen(opts.hash)]u8, 1713 1714 fn addFile(ctx: @This(), state: R.State(.read_write), index: *Index, path: []const u8, content: []const u8) !void { 1715 var reader = std.Io.Reader.fixed(content); 1716 var oid: [xit.hash.byteLen(opts.hash)]u8 = undefined; 1717 try xit.object.writeObject(.xit, opts, state, ctx.io, ctx.allocator, &reader, .{ .kind = .blob, .size = content.len }, &oid); 1718 const path_parts = try xit.fs.splitPath(ctx.allocator, path); 1719 defer ctx.allocator.free(path_parts); 1720 try index.addTreeEntryFile(&.{ .oid = oid, .mode = @bitCast(@as(u32, 0o100644)) }, path_parts, content.len, 0); 1721 } 1722 1723 fn addDir(ctx: @This(), state: R.State(.read_write), index: *Index, path: []const u8) anyerror!void { 1724 var dir = try std.Io.Dir.cwd().openDir(ctx.io, path, .{ .iterate = true }); 1725 defer dir.close(ctx.io); 1726 var entries = dir.iterate(); 1727 while (try entries.next(ctx.io)) |entry| { 1728 const child = try std.fs.path.join(ctx.allocator, &.{ path, entry.name }); 1729 defer ctx.allocator.free(child); 1730 switch (entry.kind) { 1731 .directory => try ctx.addDir(state, index, child), 1732 .file => { 1733 const content = try dir.readFileAlloc(ctx.io, entry.name, ctx.allocator, .unlimited); 1734 defer ctx.allocator.free(content); 1735 try ctx.addFile(state, index, child, content); 1736 }, 1737 else => {}, 1738 } 1739 } 1740 } 1741 1742 pub fn run(ctx: @This(), cursor: *R.DB.Cursor(.read_write)) !void { 1743 var moment = try R.DB.HashMap(.read_write).init(cursor.*); 1744 const state = R.State(.read_write){ .core = ctx.core, .extra = .{ .moment = &moment } }; 1745 const head_oid = try rf.readHeadRecurMaybe(.xit, opts, state.readOnly(), ctx.io); 1746 var index = if (head_oid) |oid| try Index.initFromCommit(state.readOnly(), ctx.io, ctx.allocator, &oid) else try Index.init(state.readOnly(), ctx.io, ctx.allocator); 1747 defer index.deinit(); 1748 switch (ctx.files) { 1749 .files => |updates| for (updates) |file| try ctx.addFile(state, &index, file.path, file.content), 1750 .dirs => |dirs| for (dirs) |dir| try ctx.addDir(state, &index, dir), 1751 } 1752 var tree = try xit.object.Tree.initFromIndex(.xit, opts, state, ctx.io, ctx.allocator, &index); 1753 defer tree.deinit(); 1754 var head_buffer: [rf.MAX_REF_CONTENT_SIZE]u8 = undefined; 1755 const head = try rf.readHead(.xit, opts, state.readOnly(), ctx.io, &head_buffer) orelse return error.HeadNotFound; 1756 ctx.result.* = try xit.object.writeCommit(.xit, opts, state, ctx.io, ctx.allocator, ctx.metadata, &tree, head.ref); 1757 try xit.undo.writeMessage(opts, state, .{ .commit = ctx.metadata }); 1758 } 1759 }; 1760 try repo.core.db_file.lock(io, .exclusive); 1761 defer repo.core.db_file.unlock(io); 1762 const history = try R.DB.ArrayList(.read_write).init(repo.core.db.rootCursor()); 1763 try history.appendContext(.{ .slot = try history.getSlot(-1) }, Ctx{ 1764 .core = &repo.core, 1765 .io = io, 1766 .allocator = allocator, 1767 .files = files, 1768 .metadata = metadata, 1769 .result = &result, 1770 }); 1771 return result; 1772 } 1773