╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ──────╮ │src/test/ui.zig│ ╰───────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │311 │ │312 // an off-chain stopping point must not hide its parent on this chain │ │313 const other = try repo.commitAtRef(io, allocator, .{ .message = "other", .parent_oids = &.{base} }, null, .{ .kind = .head, .name = "other" }); │ │315 - const off_chain = try Commits.init(kind, opts, &arena, &repo, io, allocator, null, handle, .object, last.commits[0].oid, content, &other, "", "");│ │314 + const off_chain = try Commits.init(kind, opts, &arena, &repo, io, allocator, null, handle, .object, last.commits[0].oid, false, &other, "", ""); │ │315 try std.testing.expectEqual(2, off_chain.commits.len); │ │316 try std.testing.expectEqualStrings(&base, off_chain.commits[1].oid); │ │317 } │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ─╮ │src/ui.zig│ ╰──────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │190 repo_new_user: Array(repo_route_max_len), │ │191 repo_auth: Array(repo_route_max_len), │ │192 fork_patch: ForkRoute, │ │193 - fork_diff: struct { fork: ForkRoute, start: usize = 0, path: Array(repo_route_max_len) = .{} },│ │193 + fork_diff: ForkDiffRoute, │ │194 fork_files: ForkFilesRoute, │ │195 fork_commits: ForkCommitsRoute, │ │196 fork_new_repo: ForkRoute, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │318 const patch_seg = "patch:"; │ │319 const discuss_seg = "discuss:"; │ │320 const comment_seg = "comment:"; │ │321 - // marks a files or commits route's trailing path: the value is the raw│ │321 + // marks a files or diff route's trailing path: the value is the raw │ │322 // remainder of the url, so it must come last │ │323 const path_seg = "path:"; │ │324 │ ╰────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────╮ │415 // a merge commit whose brought-in commits the page lists, resolved to an│ │416 // object and base on load. set alone. │ │417 merge: Array(ref_route_max_len) = .{}, │ │418 - // what the pane shows for the commit the log walks from. │ │419 - content: Content = .{ .diff = .{} }, │ │420 - │ │421 - // a diff window and the message are alternatives, so the window's │ │422 - // params can't be named alongside the message. │ │423 - pub const Content = union(enum) { │ │424 - diff: struct { │ │425 - // the hunk index the window starts at. │ │426 - start: usize = 0, │ │427 - // the file the diff is filtered to ("" = every file). │ │428 - path: Array(repo_route_max_len) = .{}, │ │429 - }, │ │430 - message, │ │431 - }; │ │418 + // the pane shows the whole message of the commit the log walks from. │ │419 + message: bool = false, │ │420 }; │ │421 │ │422 pub const RepoUndoRoute = struct { │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────╮ │460 pub const ForkCommitsRoute = struct { │ │461 fork: ForkRoute, │ │462 oid: Array(ref_route_max_len) = .{}, │ │475 - content: RepoCommitsRoute.Content = .{ .diff = .{} }, │ │463 + message: bool = false, │ │464 + }; │ │465 + │ │466 + pub const ForkDiffRoute = struct { │ │467 + fork: ForkRoute, │ │468 + // one commit's diff against `base_oid`, or the whole patch when unset │ │469 + oid: Array(ref_route_max_len) = .{}, │ │470 + base_oid: Array(ref_route_max_len) = .{}, │ │471 + start: usize = 0, │ │472 + path: Array(repo_route_max_len) = .{}, │ │473 }; │ │474 │ │475 // where the shared files and commits views are mounted. fork routes always│ ╰────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │503 }; │ │504 } │ │505 │ │509 - pub fn commitsRoute(self: RepoLocation, ref_or_oid: ?RefOrOid, value: []const u8, start: usize, path: []const u8, base_oid: []const u8) ?RoutablePage {│ │506 + pub fn commitsRoute(self: RepoLocation, ref_or_oid: ?RefOrOid, value: []const u8, base_oid: []const u8) ?RoutablePage { │ │507 return switch (self) { │ │511 - .repo => |repo_identity| repoCommitsRoute(repo_identity, ref_or_oid, value, start, path, base_oid), │ │508 + .repo => |repo_identity| repoCommitsRoute(repo_identity, ref_or_oid, value, base_oid), │ │509 .fork => |f| if (ref_or_oid == null or (ref_or_oid == .branch and std.mem.eql(u8, value, "patch"))) │ │513 - forkCommitsRoute(f.identity, f.id, "", start, path) │ │510 + forkCommitsRoute(f.identity, f.id, "") │ │511 else if (ref_or_oid == .object) │ │515 - forkCommitsRoute(f.identity, f.id, value, start, path) │ │512 + forkCommitsRoute(f.identity, f.id, value) │ │513 else │ │514 null, │ │515 }; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │516 } │ │517 │ │518 + // commit `oid`'s diff against `base_oid` (all zeros for a root commit) │ │519 + pub fn commitDiffRoute(self: RepoLocation, oid: []const u8, base_oid: []const u8) ?RoutablePage {│ │520 + return switch (self) { │ │521 + .repo => |repo_identity| repoDiffRoute(repo_identity, .object, oid, 0, "", base_oid), │ │522 + .fork => |f| forkDiffRoute(f.identity, f.id, oid, base_oid, 0, ""), │ │523 + }; │ │524 + } │ │525 + │ │526 // fork commits routes carry no base, so only a repo can list a merge's commits │ │527 pub fn commitsMergeRoute(self: RepoLocation, oid: []const u8) ?RoutablePage { │ │528 return switch (self) { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │551 return .{ .fork_patch = initForkRoute(identity, id) orelse return null }; │ │552 } │ │553 │ │549 - pub fn forkDiffRoute(identity: []const u8, id: []const u8, start: usize, path: []const u8) ?RoutablePage { │ │554 + // the whole patch's diff when `oid` is "", else that commit's against `base_oid` │ │555 + pub fn forkDiffRoute(identity: []const u8, id: []const u8, oid: []const u8, base_oid: []const u8, start: usize, path: []const u8) ?RoutablePage {│ │556 + if ((oid.len == 0) != (base_oid.len == 0)) return null; │ │557 return .{ .fork_diff = .{ │ │558 .fork = initForkRoute(identity, id) orelse return null, │ │559 + .oid = Array(ref_route_max_len).from(oid) orelse return null, │ │560 + .base_oid = Array(ref_route_max_len).from(base_oid) orelse return null, │ │561 .start = start, │ │562 .path = Array(repo_route_max_len).from(path) orelse return null, │ │563 } }; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │572 } }; │ │573 } │ │574 │ │566 - pub fn forkCommitsRoute(identity: []const u8, id: []const u8, oid: []const u8, start: usize, path: []const u8) ?RoutablePage {│ │575 + pub fn forkCommitsRoute(identity: []const u8, id: []const u8, oid: []const u8) ?RoutablePage { │ │576 return .{ .fork_commits = .{ │ │577 .fork = initForkRoute(identity, id) orelse return null, │ │578 .oid = Array(ref_route_max_len).from(oid) orelse return null, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────╮ │570 - .content = .{ .diff = .{ │ │571 - .start = start, │ │572 - .path = Array(repo_route_max_len).from(path) orelse return null,│ │573 - } }, │ │579 } }; │ │580 } │ │581 │ ╰─────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯