╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ event.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2064 2065 walk_queue_index += 1; 2066 2067 // if we've seen this object id, skip it 2068 if (null != try seen_object_ids.getCursor(oid_int)) { 2069 continue; 2070 } 2071 2072 try seen_object_ids.put(oid_int, .{ .bytes = &oid }); 2073 2074 var commit_object = try obj.Object(repo_kind, repo_opts).init(state, io, allocator, &std.fmt.bytesToHex(oid, .lower)); 2075 defer commit_object.deinit(); 2076 2077 // if this object id has already been consumed, skip it 2078 if (null != try consumed_object_ids.getCursor(oid_int)) { 2079 continue; 2080 } 2081 2082 if (self.newest_object_id == null) self.newest_object_id = oid; 2083 self.oldest_object_id = oid; 2084 2085 const parent_oids = commit_object.content.commit.metadata.parent_oids orelse return error.ParentOidsNotFound; 2086 var pending_parent_count: u64 = 0; 2087 for (parent_oids) |*parent_oid| { 2088 var parent_oid_bytes: [hash.byteLen(repo_opts.hash)]u8 = undefined; 2089 _ = try std.fmt.hexToBytes(&parent_oid_bytes, parent_oid); 2090 const parent_oid_int = hash.bytesToInt(repo_opts.hash, &parent_oid_bytes); 2091 2092 // if this object id has already been consumed, skip it 2093 if (null != try consumed_object_ids.getCursor(parent_oid_int)) { 2094 continue; 2095 } 2096 2097 // if this object id hasn't already been seen, add it to the walk queue 2098 if (null == try seen_object_ids.getCursor(parent_oid_int)) { 2099 try walk_queue.append(.{ .bytes = &parent_oid_bytes }); 2100 } 2101 2102 const children_cursor = try self.parent_to_children.putCursor(parent_oid_int); 2103 const children = try DB.HashSet(.read_write).init(children_cursor); 2104 try children.put(oid_int, .{ .bytes = &oid }); 2105 pending_parent_count += 1; 2106 } 2107 2108 if (pending_parent_count == 0) { 2109 try self.ready_queue.append(.{ .bytes = &oid }); 2110 } else { 2111 try self.child_to_pending_parents.put(oid_int, .{ .uint = pending_parent_count }); 2112 } 2113 } 2114 } 2115 2116 fn enqueueChildren(self: *CommitIterator(repo_kind, repo_opts), oid: *const [hash.byteLen(repo_opts.hash)]u8) !void { 2117 const oid_int = hash.bytesToInt(repo_opts.hash, oid); 2118 const children_cursor = try self.parent_to_children.getCursor(oid_int) orelse return; 2119 const children = try DB.HashSet(.read_only).init(children_cursor); 2120 var children_iter = try children.iterator(); 2121 2122 while (try children_iter.next()) |*child_cursor| { 2123 const kv_pair = try child_cursor.readKeyValuePair(); 2124 const child_oid_int = kv_pair.hash; 2125 const pending_parent_cursor = try self.child_to_pending_parents.getCursor(child_oid_int) orelse return error.CursorNotFound; 2126 const pending_parent_count = try pending_parent_cursor.readUint(); 2127 2128 if (pending_parent_count <= 1) { 2129 _ = try self.child_to_pending_parents.remove(child_oid_int); 2130 const child_oid = hash.intToBytes(hash.HashInt(repo_opts.hash), child_oid_int); 2131 try self.ready_queue.append(.{ .bytes = &child_oid }); 2132 } else { 2133 try self.child_to_pending_parents.put(child_oid_int, .{ .uint = pending_parent_count - 1 }); 2134 } 2135 } 2136 } 2137 2138 fn readOidFromList(list: DB.ArrayList(.read_only), index: u64) ![hash.byteLen(repo_opts.hash)]u8 { 2139 const oid_cursor = try list.getCursor(index) orelse return error.CursorNotFound; 2140 var oid: [hash.byteLen(repo_opts.hash)]u8 = undefined; 2141 _ = try oid_cursor.readBytes(&oid); 2142 return oid; 2143 } 2144 }; 2145 } 2146