╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ event.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2421 2422 try seen_object_ids.put(oid_int, .{ .bytes = &oid }); 2423 2424 var commit_object = try obj.Object(repo_kind, repo_opts).init(state, io, allocator, &std.fmt.bytesToHex(oid, .lower)); 2425 defer commit_object.deinit(); 2426 2427 // if this object id has already been consumed, skip it 2428 if (null != try consumed_object_ids.getCursor(oid_int)) { 2429 continue; 2430 } 2431 2432 if (self.newest_object_id == null) self.newest_object_id = oid; 2433 self.oldest_object_id = oid; 2434 2435 const parent_oids = commit_object.content.commit.metadata.parent_oids orelse return error.ParentOidsNotFound; 2436 var pending_parent_count: u64 = 0; 2437 for (parent_oids) |*parent_oid| { 2438 var parent_oid_bytes: [hash.byteLen(repo_opts.hash)]u8 = undefined; 2439 _ = try std.fmt.hexToBytes(&parent_oid_bytes, parent_oid); 2440 const parent_oid_int = hash.bytesToInt(repo_opts.hash, &parent_oid_bytes); 2441 2442 // if this object id has already been consumed, skip it 2443 if (null != try consumed_object_ids.getCursor(parent_oid_int)) { 2444 continue; 2445 } 2446 2447 // if this object id hasn't already been seen, add it to the walk queue 2448 if (null == try seen_object_ids.getCursor(parent_oid_int)) { 2449 try walk_queue.append(.{ .bytes = &parent_oid_bytes }); 2450 } 2451 2452 const children_cursor = try self.parent_to_children.putCursor(parent_oid_int); 2453 const children = try TempDB.HashSet(.read_write).init(children_cursor); 2454 try children.put(oid_int, .{ .bytes = &oid }); 2455 pending_parent_count += 1; 2456 } 2457 2458 if (pending_parent_count == 0) { 2459 try self.ready_queue.append(.{ .bytes = &oid }); 2460 } else { 2461 try self.child_to_pending_parents.put(oid_int, .{ .uint = pending_parent_count }); 2462 } 2463 } 2464 } 2465 2466 fn enqueueChildren(self: *CommitIterator(repo_kind, repo_opts), oid: *const [hash.byteLen(repo_opts.hash)]u8) !void { 2467 const oid_int = hash.bytesToInt(repo_opts.hash, oid); 2468 const children_cursor = try self.parent_to_children.getCursor(oid_int) orelse return; 2469 const children = try TempDB.HashSet(.read_only).init(children_cursor); 2470 var children_iter = try children.iterator(); 2471 2472 while (try children_iter.next()) |*child_cursor| { 2473 const kv_pair = try child_cursor.readKeyValuePair(); 2474 const child_oid_int = kv_pair.hash; 2475 const pending_parent_cursor = try self.child_to_pending_parents.getCursor(child_oid_int) orelse return error.CursorNotFound; 2476 const pending_parent_count = try pending_parent_cursor.readUint(); 2477 2478 if (pending_parent_count <= 1) { 2479 _ = try self.child_to_pending_parents.remove(child_oid_int); 2480 const child_oid = hash.intToBytes(hash.HashInt(repo_opts.hash), child_oid_int); 2481 try self.ready_queue.append(.{ .bytes = &child_oid }); 2482 } else { 2483 try self.child_to_pending_parents.put(child_oid_int, .{ .uint = pending_parent_count - 1 }); 2484 } 2485 } 2486 } 2487 2488 fn readOidFromList(list: TempDB.ArrayList(.read_only), index: u64) ![hash.byteLen(repo_opts.hash)]u8 { 2489 const oid_cursor = try list.getCursor(index) orelse return error.CursorNotFound; 2490 var oid: [hash.byteLen(repo_opts.hash)]u8 = undefined; 2491 _ = try oid_cursor.readBytes(&oid); 2492 return oid; 2493 } 2494 }; 2495 } 2496