╭ changed ──────────────╮ │src/ui/Repo/Commits.zig│ ╰───────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │53 sub_header: SubHeader, │ │54 │ │55 const Self = @This(); │ │56 - │ │57 -pub fn init( │ │58 - arena: *std.heap.ArenaAllocator, │ │59 - session: *ui.Session, │ │60 - source_maybe: ?ui.RepoSource, │ │61 - identity: []const u8, │ │62 - requested_ref_or_oid: ?ui.RoutablePage.RefOrOid, │ │63 - requested_value: []const u8, │ │64 - // the hunk index the selected commit's (the first one, the walk root) diff │ │65 - // window starts at; 0 is the first window. moved by "next"/"previous". │ │66 - after: usize, │ │67 -) !Self { │ │68 - const aa = arena.allocator(); │ │56 │ │70 - // no filesystem (wasm) or nowhere to look: empty listing. the wasm path │ │71 - // never calls init anyway — it rebuilds from the serialized snapshot. │ │72 - const io = session.io orelse return emptyResult(aa, identity, requested_ref_or_oid orelse .branch, requested_value); │ │73 - const source = source_maybe orelse return emptyResult(aa, identity, requested_ref_or_oid orelse .branch, requested_value); │ │74 - │ │75 - // walk the log with the arena's backing allocator (transient; the commits │ │76 - // we keep are duped into the page arena so they outlive it). AnyRepo opens │ │77 - // both sha1 and sha256 repos. │ │78 - const gpa = arena.child_allocator; │ │79 - switch (source.repo_kind) { │ │80 - inline else => |repo_kind| { │ │81 - 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);│ │82 - defer any_repo.deinit(io, gpa); │ │83 - │ │84 - return switch (any_repo) { │ │85 - inline else => |*repo| collect(repo_kind, repo.self_repo_opts, arena, repo, io, gpa, identity, requested_ref_or_oid, requested_value, after), │ │86 - }; │ │87 - }, │ │88 - } │ │89 -} │ │90 - │ │57 // walk the log for an opened repo. generic over the repo's backend and hash │ │58 // kind so the oid buffers and diff types it threads through match the repo's │ │93 -// opts. │ │94 -fn collect( │ │59 +// opts. `after` is the hunk index the selected commit's (the first one, the │ │60 +// walk root) diff window starts at; 0 is the first window, moved by │ │61 +// "next"/"previous". walks with the arena's backing allocator (transient; the │ │62 +// commits we keep are duped into the page arena so they outlive it). │ │63 +pub fn init( │ │64 comptime repo_kind: rp.RepoKind, │ │65 comptime repo_opts: rp.RepoOpts(repo_kind), │ │66 arena: *std.heap.ArenaAllocator, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │144 } │ │145 │ │146 // an empty listing pinned to a ref, for the wasm / no-repo / unresolved paths. │ │178 -fn emptyResult(aa: std.mem.Allocator, identity: []const u8, ref_or_oid: ui.RoutablePage.RefOrOid, value: []const u8) !Self { │ │147 +pub fn emptyResult(aa: std.mem.Allocator, identity: []const u8, ref_or_oid: ui.RoutablePage.RefOrOid, value: []const u8) !Self {│ │148 return .{ │ │149 .identity = try aa.dupe(u8, identity), │ │150 .ref_or_oid = ref_or_oid, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯