╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ event.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2099 2100 if (self.newest_object_id == null) self.newest_object_id = oid; 2101 self.oldest_object_id = oid; 2102 2103 const parent_oids = commit_object.content.commit.metadata.parent_oids orelse return error.ParentOidsNotFound; 2104 var pending_parent_count: u64 = 0; 2105 for (parent_oids) |*parent_oid| { 2106 var parent_oid_bytes: [hash.byteLen(repo_opts.hash)]u8 = undefined; 2107 _ = try std.fmt.hexToBytes(&parent_oid_bytes, parent_oid); 2108 const parent_oid_int = hash.bytesToInt(repo_opts.hash, &parent_oid_bytes); 2109 2110 // if this object id has already been consumed, skip it 2111 if (null != try consumed_object_ids.getCursor(parent_oid_int)) { 2112 continue; 2113 } 2114 2115 // if this object id hasn't already been seen, add it to the walk queue 2116 if (null == try seen_object_ids.getCursor(parent_oid_int)) { 2117 try walk_queue.append(.{ .bytes = &parent_oid_bytes }); 2118 } 2119 2120 const children_cursor = try self.parent_to_children.putCursor(parent_oid_int); 2121 const children = try TempDB.HashSet(.read_write).init(children_cursor); 2122 try children.put(oid_int, .{ .bytes = &oid }); 2123 pending_parent_count += 1; 2124 } 2125 2126 if (pending_parent_count == 0) { 2127 try self.ready_queue.append(.{ .bytes = &oid }); 2128 } else { 2129 try self.child_to_pending_parents.put(oid_int, .{ .uint = pending_parent_count }); 2130 } 2131 } 2132 } 2133 2134 fn enqueueChildren(self: *CommitIterator(repo_kind, repo_opts), oid: *const [hash.byteLen(repo_opts.hash)]u8) !void { 2135 const oid_int = hash.bytesToInt(repo_opts.hash, oid); 2136 const children_cursor = try self.parent_to_children.getCursor(oid_int) orelse return; 2137 const children = try TempDB.HashSet(.read_only).init(children_cursor); 2138 var children_iter = try children.iterator(); 2139 2140 while (try children_iter.next()) |*child_cursor| { 2141 const kv_pair = try child_cursor.readKeyValuePair(); 2142 const child_oid_int = kv_pair.hash; 2143 const pending_parent_cursor = try self.child_to_pending_parents.getCursor(child_oid_int) orelse return error.CursorNotFound; 2144 const pending_parent_count = try pending_parent_cursor.readUint(); 2145 2146 if (pending_parent_count <= 1) { 2147 _ = try self.child_to_pending_parents.remove(child_oid_int); 2148 const child_oid = hash.intToBytes(hash.HashInt(repo_opts.hash), child_oid_int); 2149 try self.ready_queue.append(.{ .bytes = &child_oid }); 2150 } else { 2151 try self.child_to_pending_parents.put(child_oid_int, .{ .uint = pending_parent_count - 1 }); 2152 } 2153 } 2154 } 2155 2156 fn readOidFromList(list: TempDB.ArrayList(.read_only), index: u64) ![hash.byteLen(repo_opts.hash)]u8 { 2157 const oid_cursor = try list.getCursor(index) orelse return error.CursorNotFound; 2158 var oid: [hash.byteLen(repo_opts.hash)]u8 = undefined; 2159 _ = try oid_cursor.readBytes(&oid); 2160 return oid; 2161 } 2162 }; 2163 } 2164