╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ event.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1190 if (null != try seen_object_ids.getCursor(oid_int)) { 1191 continue; 1192 } 1193 1194 try seen_object_ids.put(oid_int, .{ .bytes = &oid }); 1195 1196 var commit_object = try obj.Object(repo_kind, repo_opts).init(state, io, allocator, &std.fmt.bytesToHex(oid, .lower)); 1197 defer commit_object.deinit(); 1198 1199 // if this object id has already been consumed, skip it 1200 if (null != try consumed_object_ids.getCursor(oid_int)) { 1201 continue; 1202 } 1203 1204 if (self.newest_object_id == null) self.newest_object_id = oid; 1205 self.oldest_object_id = oid; 1206 1207 const parent_oids = commit_object.content.commit.metadata.parent_oids orelse return error.ParentOidsNotFound; 1208 var pending_parent_count: u64 = 0; 1209 for (parent_oids) |*parent_oid| { 1210 var parent_oid_bytes: [hash.byteLen(repo_opts.hash)]u8 = undefined; 1211 _ = try std.fmt.hexToBytes(&parent_oid_bytes, parent_oid); 1212 const parent_oid_int = hash.bytesToInt(repo_opts.hash, &parent_oid_bytes); 1213 1214 // if this object id has already been consumed, skip it 1215 if (null != try consumed_object_ids.getCursor(parent_oid_int)) { 1216 continue; 1217 } 1218 1219 // if this object id hasn't already been seen, add it to the walk queue 1220 if (null == try seen_object_ids.getCursor(parent_oid_int)) { 1221 try walk_queue.append(.{ .bytes = &parent_oid_bytes }); 1222 } 1223 1224 const children_cursor = try self.parent_to_children.putCursor(parent_oid_int); 1225 const children = try DB.HashSet(.read_write).init(children_cursor); 1226 try children.put(oid_int, .{ .bytes = &oid }); 1227 pending_parent_count += 1; 1228 } 1229 1230 if (pending_parent_count == 0) { 1231 try self.ready_queue.append(.{ .bytes = &oid }); 1232 } else { 1233 try self.child_to_pending_parents.put(oid_int, .{ .uint = pending_parent_count }); 1234 } 1235 } 1236 } 1237 1238 fn enqueueChildren(self: *CommitIterator(repo_kind, repo_opts), oid: *const [hash.byteLen(repo_opts.hash)]u8) !void { 1239 const oid_int = hash.bytesToInt(repo_opts.hash, oid); 1240 const children_cursor = try self.parent_to_children.getCursor(oid_int) orelse return; 1241 const children = try DB.HashSet(.read_only).init(children_cursor); 1242 var children_iter = try children.iterator(); 1243 1244 while (try children_iter.next()) |*child_cursor| { 1245 const kv_pair = try child_cursor.readKeyValuePair(); 1246 const child_oid_int = kv_pair.hash; 1247 const pending_parent_cursor = try self.child_to_pending_parents.getCursor(child_oid_int) orelse return error.CursorNotFound; 1248 const pending_parent_count = try pending_parent_cursor.readUint(); 1249 1250 if (pending_parent_count <= 1) { 1251 _ = try self.child_to_pending_parents.remove(child_oid_int); 1252 const child_oid = hash.intToBytes(hash.HashInt(repo_opts.hash), child_oid_int); 1253 try self.ready_queue.append(.{ .bytes = &child_oid }); 1254 } else { 1255 try self.child_to_pending_parents.put(child_oid_int, .{ .uint = pending_parent_count - 1 }); 1256 } 1257 } 1258 } 1259 1260 fn readOidFromList(list: DB.ArrayList(.read_only), index: u64) ![hash.byteLen(repo_opts.hash)]u8 { 1261 const oid_cursor = try list.getCursor(index) orelse return error.CursorNotFound; 1262 var oid: [hash.byteLen(repo_opts.hash)]u8 = undefined; 1263 _ = try oid_cursor.readBytes(&oid); 1264 return oid; 1265 } 1266 }; 1267 } 1268