╭ changed ────╮ │build.zig.zon│ ╰─────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 3 .version = "0.0.0", │ │ 4 .dependencies = .{ │ │ 5 .xit = .{ │ │ 6 - .url = "git+https://github.com/xit-vcs/xit#c931aec1a03a452effa66b004f58315daf33ce72",│ │ 7 - .hash = "xit-0.0.0-Ub3nDAhnHQAyQ64doxEd2l6VQptCPDcotfvwLpBH2_05", │ │ 6 + .url = "git+https://github.com/xit-vcs/xit#6ea65e22dec91c6dac11d80d33e80eb36a98cd05",│ │ 7 + .hash = "xit-0.0.0-Ub3nDGJnHQBaQSGjTO_HX9ijNpYMR4eYJPE89-6aS-dy", │ │ 8 }, │ │ 9 }, │ │10 .paths = .{ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ─╮ │src/ui.zig│ ╰──────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────╮ │2551 repo_branches: struct { │ │2552 failure: BranchesFailure, │ │2553 name: []const u8, │ │2554 + // whether it came from the default branch form, not the protect form│ │2555 + default: bool = false, │ │2556 }, │ │2557 assignment: struct { │ │2558 failure: AssignmentFailure, │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ──────╮ │src/ui/Repo.zig│ ╰───────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │321 const identity = try arena.allocator().dupe(u8, repo_identity.identity); │ │322 // only the repo's creator may delete it, never a granted owner │ │323 const creator = if (session.userId()) |user_id| std.mem.eql(u8, &user_id, &owner_id) else false;│ │324 + // the branch HEAD names, which the branches tab shows as the default │ │325 + var head_buffer: [xit.ref.MAX_REF_CONTENT_SIZE]u8 = undefined; │ │326 + const default_branch = if (opened.head(io, &head_buffer)) |head| switch (head) { │ │327 + .ref => |ref| ref.name, │ │328 + .oid => "", │ │329 + } else |_| ""; │ │330 settings = .{ │ │331 .identity = identity, │ │332 .name = repo.event.name, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │343 else => .settings, │ │344 }, │ │345 .members = try Members.init(io, gpa, arena, session.haxy_moment orelse return error.NoMoment, session.users_dir orelse return error.NoMoment, repo_identity.identity, &owner_id, &repo_id, members_route.start, if (members_route.confirm) |action| .{ .action = action, .name = members_route.user.slice() } else null),│ │340 - .branches = try Branches.init(arena, repo_identity.identity, repo.event), │ │346 + .branches = try Branches.init(arena, repo_identity.identity, repo.event, default_branch), │ │347 .delete = if (creator) .{ .target = .{ .repo = identity } } else null, │ │348 }; │ │349 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ───────────────╮ │src/ui/Repo/Branches.zig│ ╰────────────────────────╯ ╭─────────────────────────────────────────────╮ │ 5 const inp = @import("../input.zig"); │ │ 6 const Comment = @import("./Comment.zig");│ │ 7 const xit = @import("xit"); │ │ 8 +const rp = xit.repo; │ │ 9 const xitui = xit.xitui; │ │10 const wgt = xitui.widget; │ │11 const layout = xitui.layout; │ ╰─────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────╮ │15 │ │16 const wasm = builtin.target.cpu.arch == .wasm32; │ │17 │ │17 -// the repo's protected branches, which only its owners see │ │18 +// the repo's default and protected branches, which only its owners see│ │19 identity: []const u8, │ │20 +// the branch HEAD names ("" when detached) │ │21 +default_branch: []const u8, │ │22 names: []const []const u8, │ │23 │ │24 const Self = @This(); │ ╰───────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │25 │ │23 -pub const Action = enum { protect, unprotect }; │ │26 +pub const Action = enum { default, protect, unprotect }; │ │27 │ │25 -pub fn init(arena: *std.heap.ArenaAllocator, identity: []const u8, repo: evt.Repo) !Self { │ │28 +pub fn init(arena: *std.heap.ArenaAllocator, identity: []const u8, repo: evt.Repo, default_branch: []const u8) !Self {│ │29 const aa = arena.allocator(); │ │30 return .{ │ │31 .identity = try aa.dupe(u8, identity), │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────╮ │32 + .default_branch = try aa.dupe(u8, default_branch),│ │33 .names = try repo.protectedBranchNames(aa), │ │34 }; │ │35 } │ ╰──────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────╮ │36 │ │33 -// protect or unprotect `branch` in the repo `identity` names as `actor`, one│ │34 -// of its owners. returns why a protect wrote nothing, or null once written │ │37 +// make `branch` the default, or protect or unprotect it, in the repo │ │38 +// `identity` names as `actor`, one of its owners. returns why nothing was │ │39 +// written, or null once written │ │40 pub fn perform( │ │41 io: std.Io, │ │42 allocator: std.mem.Allocator, │ ╰─────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │58 break :blk found.event_id; │ │59 }; │ │60 │ │56 - // only an existing branch can be protected, and its row links to it, so │ │57 - // its encoded name must fit in a route │ │58 - if (action == .protect) { │ │61 + // only an existing branch can be the default or protected, and a protected │ │62 + // branch's row links to it, so its encoded name must fit in a route │ │63 + if (action != .unprotect) { │ │64 if ((try ui.urlEncodeRef(arena.allocator(), branch)).len > ui.RoutablePage.ref_route_max_len) return .too_long;│ │65 const path = try evt.repoPath(allocator, users_dir, &owner_id, &repo_id); │ │66 defer allocator.free(path); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯