╭ changed ────────────╮ │src/ui/Repo/Files.zig│ ╰─────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 67 │ │ 68 const Self = @This(); │ │ 69 │ │ 70 -pub fn init( │ │ 71 - arena: *std.heap.ArenaAllocator, │ │ 72 - session: *ui.Session, │ │ 73 - source_maybe: ?ui.RepoSource, │ │ 74 - identity: []const u8, │ │ 75 - requested_ref_or_oid: ?ui.RoutablePage.RefOrOid, │ │ 76 - requested_value: []const u8, │ │ 77 - path: []const u8, │ │ 78 - // the line offset the selected file's content window starts at (0 = first). │ │ 79 - after: usize, │ │ 80 -) !Self { │ │ 81 - const aa = arena.allocator(); │ │ 82 - │ │ 83 - // no filesystem (wasm) or nowhere to look: empty listing pinned to whatever │ │ 84 - // ref the route asked for. the wasm path never calls init anyway — it │ │ 85 - // rebuilds from the serialized snapshot. │ │ 86 - const io = session.io orelse return emptyResult(aa, identity, requested_ref_or_oid orelse .branch, requested_value, path); │ │ 87 - const source = source_maybe orelse return emptyResult(aa, identity, requested_ref_or_oid orelse .branch, requested_value, path); │ │ 88 - │ │ 89 - // open + read the committed file list with the arena's backing allocator │ │ 90 - // (transient; freed before init returns); the listing is built into the │ │ 91 - // page arena so it outlives them. AnyRepo opens both sha1 and sha256 repos. │ │ 92 - const gpa = arena.child_allocator; │ │ 93 - switch (source.repo_kind) { │ │ 94 - inline else => |repo_kind| { │ │ 95 - var any_repo = rp.AnyRepo(repo_kind, .{}).open(io, gpa, .{ .path = source.path }) catch return emptyResult(aa, identity, requested_ref_or_oid orelse .branch, requested_value, path);│ │ 96 - defer any_repo.deinit(io, gpa); │ │ 97 - │ │ 98 - return switch (any_repo) { │ │ 99 - inline else => |*repo| listing(repo_kind, repo.self_repo_opts, arena, repo, io, gpa, identity, requested_ref_or_oid, requested_value, path, after), │ │100 - }; │ │101 - }, │ │102 - } │ │103 -} │ │104 - │ │ 70 // build the listing for an opened repo. generic over the repo's backend and │ │ 71 // hash kind so the tree/diff types it threads through match the repo's opts. │ │107 -fn listing( │ │ 72 +// reads with the arena's backing allocator (transient); the listing is built │ │ 73 +// into the page arena so it outlives the repo handle. │ │ 74 +pub fn init( │ │ 75 comptime repo_kind: rp.RepoKind, │ │ 76 comptime repo_opts: rp.RepoOpts(repo_kind), │ │ 77 arena: *std.heap.ArenaAllocator, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │221 } │ │222 │ │223 // an empty listing pinned to a ref, for the wasm / no-repo / unresolved paths. │ │257 -fn emptyResult(aa: std.mem.Allocator, identity: []const u8, ref_or_oid: ui.RoutablePage.RefOrOid, ref_or_oid_value: []const u8, dir: []const u8) !Self { │ │224 +pub fn emptyResult(aa: std.mem.Allocator, identity: []const u8, ref_or_oid: ui.RoutablePage.RefOrOid, ref_or_oid_value: []const u8, dir: []const u8) !Self {│ │225 return .{ │ │226 .identity = try aa.dupe(u8, identity), │ │227 .ref_or_oid = ref_or_oid, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯