╭ changed ──────────────╮ │src/ui/Repo/Commits.zig│ ╰───────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────╮ │61 // whether the viewed ref has a commit index, so the search box shows and a│ │62 // search: route resolves. travels in the page json for the wasm view. │ │63 search_available: bool = false, │ │64 +// an object view or a base-bounded list searches the default branch: that │ │65 +// branch's url-encoded name, when it is indexed │ │66 +default_branch: []const u8 = "", │ │67 │ │68 const Self = @This(); │ │69 │ ╰───────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │151 var count: usize = 0; │ │152 var next_start: ?[]const u8 = null; │ │153 var search_available = false; │ │154 + var default_branch: []const u8 = ""; │ │155 var searched = false; │ │156 │ │153 - // the index covers a repository's branch and tag tips, so a fork or an │ │154 - // object view gets no search box and refuses a search: url. nor does a list │ │155 - // bounded by a base, whose version also covers the commits before it. │ │157 + // the index covers a repository's branch and tag tips, so a fork gets no │ │158 + // search box and refuses a search: url. an object view or a list bounded by │ │159 + // a base, whose version would also cover the commits before it, searches │ │160 + // the default branch instead. │ │161 if (comptime repo_kind == .xit) index: { │ │157 - if (location != .repo or resolved.ref_or_oid == .object or base_oid.len != 0) break :index; │ │162 + if (location != .repo) break :index; │ │163 + if (resolved.ref_or_oid == .object or base_oid.len != 0) { │ │164 + var head_buffer: [xit.ref.MAX_REF_CONTENT_SIZE]u8 = undefined; │ │165 + const branch = switch (repo.head(io, &head_buffer) catch break :index) { │ │166 + .ref => |ref| ref.name, │ │167 + .oid => break :index, │ │168 + }; │ │169 + const tip = (try repo.readRef(io, .{ .kind = .head, .name = branch })) orelse break :index;│ │170 + if (try srch_cmmt.lookup(repo_opts, moment, &tip) == null) break :index; │ │171 + search_available = true; │ │172 + default_branch = try ui.urlEncodeRef(aa, branch); │ │173 + break :index; │ │174 + } │ │175 const index = (try srch_cmmt.lookup(repo_opts, moment, &resolved.oid)) orelse break :index; │ │176 search_available = true; │ │177 const text = query orelse break :index; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────╮ │250 .content = try pageContent(aa, content),│ │251 .search = query, │ │252 .search_available = search_available, │ │253 + .default_branch = default_branch, │ │254 }; │ │255 } │ │256 │ ╰─────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │805 // empty query leaves the results for the plain log. │ │806 fn submit(self: *View, text: []const u8) !void { │ │807 if (text.len == 0 and self.data.search == null) return; │ │790 - const route = self.data.location.commitsRoute(self.data.ref_or_oid, self.data.ref_or_oid_value, 0, "", self.data.base_oid) orelse return;│ │791 - try self.session.navigate(route.withSearch(text) orelse return); │ │808 + // an object view or a base-bounded list searches the default branch, so the url says so │ │809 + const route = if (self.data.default_branch.len != 0) │ │810 + self.data.location.commitsRoute(.branch, self.data.default_branch, 0, "", "") │ │811 + else │ │812 + self.data.location.commitsRoute(self.data.ref_or_oid, self.data.ref_or_oid_value, 0, "", self.data.base_oid); │ │813 + try self.session.navigate((route orelse return).withSearch(text) orelse return); │ │814 } │ │815 │ │816 fn listInput(self: *View, key: Key, root_focus: *Focus) !void { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯