╭ changed ───────────────╮ │src/test/event/patch.zig│ ╰────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │296 try std.testing.expectEqualStrings(&tip, &(try repo.readRef(io, evt.events_ref) orelse return error.NotFound)); │ │297 │ │298 // retain the exact merge diff after its original commits are collected │ │299 - const diff_route = (try ui.Repo.Patches.diffRoute(allocator, "", .{ .id = &id_hex, .record = merged })) orelse return error.BadRoute;│ │299 + const diff_route = (try ui.Repo.Patches.diffRoute("", .{ .id = &id_hex, .record = merged })) orelse return error.BadRoute; │ │300 const diff_before = try ui.Repo.Diff.init(.xit, opts, &arena, &repo, io, allocator, diff_route.repo_diff); │ │301 try std.testing.expectEqual(1, diff_before.window.hunks.len); │ │302 try std.testing.expectEqualStrings("base.txt", diff_before.window.hunks[0].path orelse return error.MissingPath); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ──────────────╮ │src/ui/Repo/Patches.zig│ ╰───────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │273 return ui.RoutablePage.repoCommitsRoute(identity, .object, entry.revision_oid, 0, "", entry.base_oid) orelse error.RouteTooLong; │ │274 } │ │275 │ │276 -pub fn diffRoute(allocator: std.mem.Allocator, identity: []const u8, entry: PatchWithId) !?ui.RoutablePage { │ │277 - // merged patches show what actually landed, including conflict resolutions │ │278 - if (entry.record.event.status == .merged) { │ │279 - return ui.RoutablePage.repoPatchRevDiffRoute(identity, &entry.record.event.status.merged.patchrev_id, 0, "") orelse error.RouteTooLong;│ │280 - } │ │281 - const route = (try commitsRoute(allocator, identity, entry)) orelse return null; │ │282 - return switch (route) { │ │283 - .fork_commits => ui.RoutablePage.forkDiffRoute(identity, entry.id, 0, ""), │ │284 - .repo_commits => |c| ui.RoutablePage.repoDiffRoute(identity, c.ref_or_oid, c.value.slice(), 0, "", c.base_oid.slice()), │ │285 - else => unreachable, │ │286 - } orelse error.RouteTooLong; │ │276 +pub fn diffRoute(identity: []const u8, entry: PatchWithId) !?ui.RoutablePage { │ │277 + const patch = entry.record.event; │ │278 + const revision_id = switch (patch.status) { │ │279 + // merged patches show what actually landed, including conflict resolutions │ │280 + .merged => |merged| merged.patchrev_id, │ │281 + .open, .closed => blk: { │ │282 + if (entry.fork_exists) return ui.RoutablePage.forkDiffRoute(identity, entry.id, 0, "") orelse error.RouteTooLong; │ │283 + if (patch.source_branch == null) return null; │ │284 + break :blk (patch.revision orelse return null).id; │ │285 + }, │ │286 + }; │ │287 + return ui.RoutablePage.repoPatchRevDiffRoute(identity, &revision_id, 0, "") orelse error.RouteTooLong; │ │288 } │ │289 │ │290 pub fn draftsRoute(identity: []const u8) ?ui.RoutablePage { │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ───────────────╮ │src/ui/widget/thread.zig│ ╰────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │533 const pa = self.session.page_arena.allocator(); │ │534 │ │535 if (supports_forks and self.session.data.current_page.parent() != .fork) { │ │536 - if (try Data.diffRoute(pa, self.data.identity, entry)) |route| { │ │536 + if (try Data.diffRoute(self.data.identity, entry)) |route| { │ │537 try addToolButton(allocator, row, "view diff", "", try std.fmt.allocPrint(pa, "a:{s}", .{try route.toUrl(self.session.page_arena)}));│ │538 } │ │539 if (try Data.commitsRoute(pa, self.data.identity, entry)) |route| { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯