╭ changed ───╮ │src/find.zig│ ╰────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │ 7 const tr = xit.tree; │ │ 8 const obj = xit.object; │ │ 9 const fs = xit.fs; │ │10 -const serve_common = @import("serve_common.zig"); │ │10 const progress = @import("./progress.zig"); │ │11 │ │12 // the repo moment key holding one file map per branch tip. it sits outside the│ ╰───────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │13 // haxy moment because pushes change it and events never do. each entry is │ │14 // keyed by its branch name's hash: its value is the branch's file map, and its│ │16 -// key slot holds the root tree oid that map covers rather than the name. │ │15 +// key slot holds the raw tip commit oid that map covers rather than the name. │ │16 const index_key = "haxy/branch->file-name+path->oid"; │ │17 │ │18 // what a search returns: the matching files and whether the cap cut the list │ ╰───────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────╮ │30 } │ │31 │ │32 // `branch`'s file index, or null when it has none or its entry is stale: one│ │34 -// that doesn't cover `tree_oid`, the branch tip's root tree. │ │33 +// that doesn't cover `oid`, the branch's tip. │ │34 pub fn lookup( │ │35 comptime repo_opts: rp.RepoOpts(.xit), │ │36 moment: rp.Repo(.xit, repo_opts).DB.HashMap(.read_only), │ ╰─────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │37 branch: []const u8, │ │39 - tree_oid: *const [hash.hexLen(repo_opts.hash)]u8, │ │38 + oid: *const [hash.hexLen(repo_opts.hash)]u8, │ │39 ) !?rp.Repo(.xit, repo_opts).DB.SortedMap(.read_only) { │ │40 const DB = rp.Repo(.xit, repo_opts).DB; │ │41 const index_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, index_key)) orelse return null;│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │42 const index = try DB.HashMap(.read_only).init(index_cursor); │ │43 const pair = try index.getKeyValuePair(hash.hashInt(repo_opts.hash, branch)) orelse return null;│ │45 - const entry_tree = try readTree(repo_opts, pair.key_cursor); │ │46 - if (!std.mem.eql(u8, &entry_tree, tree_oid)) return null; │ │44 + const entry_oid = try readOid(repo_opts, pair.key_cursor); │ │45 + if (!std.mem.eql(u8, &entry_oid, oid)) return null; │ │46 return try DB.SortedMap(.read_only).init(pair.value_cursor); │ │47 } │ │48 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────╮ │88 } │ │89 │ │90 // peel an oid to the root tree it names, following commits and tags.│ │92 -pub fn rootTreeOid( │ │91 +fn rootTreeOid( │ │92 comptime repo_opts: rp.RepoOpts(.xit), │ │93 state: rp.Repo(.xit, repo_opts).State(.read_only), │ │94 io: std.Io, │ ╰─────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │148 } │ │149 │ │150 // reconcile them inside the caller's transaction, so the index lands with the│ │152 -// push that invalidated it. every branch is reconciled, since an up-to-date │ │151 +// change that invalidated it. every branch is reconciled, since an up-to-date│ │152 // one costs a ref read and an oid compare. reports whether anything was │ │153 // written, so a caller that owns an otherwise empty transaction can cancel it│ │154 pub fn refreshInTransaction( │ ╰───────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────╮ │162 const Repo = rp.Repo(.xit, repo_opts); │ │163 const DB = Repo.DB; │ │164 const HashInt = hash.HashInt(repo_opts.hash); │ │166 - const Tree = [hash.hexLen(repo_opts.hash)]u8; │ │165 + const Oid = [hash.hexLen(repo_opts.hash)]u8; │ │166 │ │168 - // an entry in the index: the root tree it covers and its file map│ │167 + // an entry in the index: the tip it covers and its file map │ │168 const Entry = struct { │ │170 - tree: Tree, │ │169 + oid: Oid, │ │170 files: xit.xitdb.Slot, │ │171 │ │172 fn init(pair: DB.KeyValuePairCursor(.read_only)) !@This() { │ ╰───────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │174 - return .{ .tree = try readTree(repo_opts, pair.key_cursor), .files = pair.value_cursor.slot() };│ │173 + return .{ .oid = try readOid(repo_opts, pair.key_cursor), .files = pair.value_cursor.slot() }; │ │174 } │ │175 }; │ │176 // what one branch needs written │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │177 const Work = struct { │ │178 branch_hash: HashInt, │ │180 - // the tip's root tree (null = the branch is gone, so its entry goes)│ │181 - tree: ?Tree, │ │179 + // the tip (null = the branch is gone, so its entry goes) │ │180 + oid: ?Oid, │ │181 // the entry the branch has now │ │182 own: ?Entry, │ │183 }; │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯