╭ changed ──────────────╮ │src/ui/Repo/Commits.zig│ ╰───────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │44 // didn't name one), so the page can canonicalize its url to it. │ │45 ref_or_oid: ui.RoutablePage.RefOrOid, │ │46 ref_or_oid_value: []const u8, │ │47 +// the file the top commit's diff is filtered to ("" = every file). │ │48 +path: []const u8 = "", │ │49 commits: []const Commit, │ │50 // the first oid of the next page, or null when this is the last page.│ │51 next_start: ?[]const u8, │ ╰──────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │71 requested_ref_or_oid: ?ui.RoutablePage.RefOrOid, │ │72 requested_value: []const u8, │ │73 start: usize, │ │74 + path: []const u8, │ │75 ) !Self { │ │76 const aa = arena.allocator(); │ │77 const hex_len = ui.ResolvedRefOrOid(repo_kind, repo_opts).hex_len;│ ╰──────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │81 // (NotFound -> 404); the default-branch path falls through to empty. │ │82 const resolved = (try ui.ResolvedRefOrOid(repo_kind, repo_opts).init(repo, io, aa, requested_ref_or_oid, requested_value)) orelse {│ │83 if (requested_ref_or_oid != null) return error.NotFound; │ │81 - return emptyResult(aa, identity, .branch, requested_value); │ │84 + return emptyResult(aa, identity, .branch, requested_value, path); │ │85 }; │ │86 var start_arr = [1][hex_len]u8{resolved.oid}; │ │87 const start_oids: []const [hex_len]u8 = start_arr[0..1]; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 94 var count: usize = 0; │ │ 95 var next_start: ?[]const u8 = null; │ │ 96 { │ │ 94 - var iter = repo.log(io, gpa, start_oids) catch return emptyResult(aa, identity, resolved.ref_or_oid, resolved.value); │ │ 97 + var iter = repo.log(io, gpa, start_oids) catch return emptyResult(aa, identity, resolved.ref_or_oid, resolved.value, path);│ │ 98 defer iter.deinit(); │ │ 99 while (try iter.next(gpa)) |commit_object| { │ │100 defer commit_object.deinit(); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │124 for (buf[0..count], oids[0..count], 0..) |*commit, oid, i| { │ │125 // the selected commit (the first, == start_oid) shows the window the │ │126 // url asks for; the rest show their first window. │ │127 + // the path filter only applies to the top commit (the walk root). │ │128 const window_start = if (i == 0) start else 0; │ │125 - const rendered = renderCommitDiff(repo_kind, repo_opts, io, gpa, aa, repo, oid, window_start, diff_page) catch │ │129 + const rendered = renderCommitDiff(repo_kind, repo_opts, io, gpa, aa, repo, oid, window_start, diff_page, if (i == 0) path else "") catch│ │130 RenderedDiff{ .hunks = &.{}, .has_prev = false, .has_more = false }; │ │131 commit.hunks = rendered.hunks; │ │132 commit.window_start = window_start; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │139 .identity = try aa.dupe(u8, identity), │ │140 .ref_or_oid = resolved.ref_or_oid, │ │141 .ref_or_oid_value = resolved.value, │ │142 + .path = try aa.dupe(u8, path), │ │143 .commits = try aa.dupe(Commit, buf[0..count]), │ │144 .next_start = next_start, │ │145 .header = try Header.init(aa, resolved.ref_or_oid, resolved.value),│ ╰────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │147 } │ │148 │ │149 // an empty listing pinned to a ref, for the wasm / no-repo / unresolved paths. │ │145 -pub fn emptyResult(aa: std.mem.Allocator, identity: []const u8, ref_or_oid: ui.RoutablePage.RefOrOid, value: []const u8) !Self { │ │150 +pub fn emptyResult(aa: std.mem.Allocator, identity: []const u8, ref_or_oid: ui.RoutablePage.RefOrOid, value: []const u8, path: []const u8) !Self {│ │151 return .{ │ │152 .identity = try aa.dupe(u8, identity), │ │153 .ref_or_oid = ref_or_oid, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────╮ │154 .ref_or_oid_value = try aa.dupe(u8, value), │ │155 + .path = try aa.dupe(u8, path), │ │156 .commits = &.{}, │ │157 .next_start = null, │ │158 .header = try Header.init(aa, ref_or_oid, value),│ ╰──────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────╮ │167 │ │168 // render the window [start, start+len) of a commit's diff against its first│ │169 // parent into `arena`-owned hunks. has_prev/has_more flag adjacent windows.│ │170 +// a non-empty `path` filters to that file, so the window indexes its hunks.│ │171 fn renderCommitDiff( │ │172 comptime repo_kind: rp.RepoKind, │ │173 comptime repo_opts: rp.RepoOpts(repo_kind), │ ╰─────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────╮ │178 oid: [xit.hash.hexLen(repo_opts.hash)]u8, │ │179 start: usize, │ │180 len: usize, │ │181 + path: []const u8, │ │182 ) !RenderedDiff { │ │183 const empty = RenderedDiff{ .hunks = &.{}, .has_prev = false, .has_more = false };│ │184 │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯