╭ changed ──────╮ │src/ui/Repo.zig│ ╰───────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────╮ │2 const evt = @import("../event.zig");│ │3 const ui = @import("../ui.zig"); │ │4 const xit = @import("xit"); │ │5 +const rp = xit.repo; │ │6 const xitui = xit.xitui; │ │7 const wgt = xitui.widget; │ │8 const layout = xitui.layout; │ ╰───────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │155 } │ │156 } │ │157 │ │157 - // build files and commits first so their resolved ref (the default branch │ │158 - // when the route named none) can canonicalize each tab's mirror url to the │ │159 - // explicit ref it's viewing rather than leaving it bare. both resolve the │ │160 - // same requested ref, so they end up viewing the same one. │ │161 - const files = try Files.init(arena, session, source, rf.identity, requested_ref_or_oid, requested_ref_value, files_dir, files_after); │ │162 - const commits = try Commits.init(arena, session, source, rf.identity, requested_ref_or_oid, requested_ref_value, commits_after); │ │158 + // open the on-disk repo once and read every tab's data from it. files and │ │159 + // commits resolve the same requested ref (the default branch when the │ │160 + // route named none), so they end up viewing the same one and either's │ │161 + // resolved ref can canonicalize the tab mirror urls below. no filesystem │ │162 + // (wasm), nowhere to look, or a failed open: empty tabs. │ │163 + const files, const commits, const refs, const issues = blk: { │ │164 + read: { │ │165 + const io = session.io orelse break :read; │ │166 + const src = source orelse break :read; │ │167 + const gpa = arena.child_allocator; │ │168 + switch (src.repo_kind) { │ │169 + inline else => |repo_kind| { │ │170 + var any_repo = rp.AnyRepo(repo_kind, .{}).open(io, gpa, .{ .path = src.path }) catch break :read; │ │171 + defer any_repo.deinit(io, gpa); │ │172 + switch (any_repo) { │ │173 + inline else => |*opened| break :blk .{ │ │174 + try Files.init(repo_kind, opened.self_repo_opts, arena, opened, io, gpa, rf.identity, requested_ref_or_oid, requested_ref_value, files_dir, files_after),│ │175 + try Commits.init(repo_kind, opened.self_repo_opts, arena, opened, io, gpa, rf.identity, requested_ref_or_oid, requested_ref_value, commits_after), │ │176 + try Refs.init(repo_kind, opened.self_repo_opts, arena, opened, io, gpa, rf.identity, refs_kind, refs_after), │ │177 + try Issues.init(repo_kind, opened.self_repo_opts, arena, opened, rf.identity, issues_tag, issues_selected), │ │178 + }, │ │179 + } │ │180 + }, │ │181 + } │ │182 + } │ │183 + const aa = arena.allocator(); │ │184 + break :blk .{ │ │185 + try Files.emptyResult(aa, rf.identity, requested_ref_or_oid orelse .branch, requested_ref_value, files_dir), │ │186 + try Commits.emptyResult(aa, rf.identity, requested_ref_or_oid orelse .branch, requested_ref_value), │ │187 + try Refs.emptyResult(arena, rf.identity, refs_kind, refs_after), │ │188 + try Issues.emptyResult(aa, rf.identity, issues_tag, issues_selected), │ │189 + }; │ │190 + }; │ │191 │ │192 // each tab mirror carries this page's route for that tab; tabs not targeted │ │193 // by the incoming route fall back to their root/first-page route. the files │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │207 .repo = repo, │ │208 .files = files, │ │209 .commits = commits, │ │182 - .refs = try Refs.init(arena, session, source, rf.identity, refs_kind, refs_after), │ │183 - .issues = try Issues.init(arena, session, source, rf.identity, issues_tag, issues_selected),│ │210 + .refs = refs, │ │211 + .issues = issues, │ │212 .settings = Settings.init(), │ │213 .auth = Auth.init(), │ │214 .quit = Quit.init(), │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯