╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ event.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2763 2764 if (self.newest_object_id == null) self.newest_object_id = oid; 2765 self.oldest_object_id = oid; 2766 2767 const parent_oids = commit_object.content.commit.metadata.parent_oids orelse return error.ParentOidsNotFound; 2768 var pending_parent_count: u64 = 0; 2769 for (parent_oids) |*parent_oid| { 2770 var parent_oid_bytes: [hash.byteLen(repo_opts.hash)]u8 = undefined; 2771 _ = try std.fmt.hexToBytes(&parent_oid_bytes, parent_oid); 2772 const parent_oid_int = hash.bytesToInt(repo_opts.hash, &parent_oid_bytes); 2773 2774 // if this object id has already been consumed, skip it 2775 if (null != try consumed_object_ids.getCursor(parent_oid_int)) { 2776 continue; 2777 } 2778 2779 // if this object id hasn't already been seen, add it to the walk queue 2780 if (null == try seen_object_ids.getCursor(parent_oid_int)) { 2781 try walk_queue.append(.{ .bytes = &parent_oid_bytes }); 2782 } 2783 2784 const children_cursor = try self.parent_to_children.putCursor(parent_oid_int); 2785 const children = try TempDB.HashSet(.read_write).init(children_cursor); 2786 try children.put(oid_int, .{ .bytes = &oid }); 2787 pending_parent_count += 1; 2788 } 2789 2790 if (pending_parent_count == 0) { 2791 try self.ready_queue.append(.{ .bytes = &oid }); 2792 } else { 2793 try self.child_to_pending_parents.put(oid_int, .{ .uint = pending_parent_count }); 2794 } 2795 } 2796 } 2797 2798 fn enqueueChildren(self: *CommitIterator(repo_kind, repo_opts), oid: *const [hash.byteLen(repo_opts.hash)]u8) !void { 2799 const oid_int = hash.bytesToInt(repo_opts.hash, oid); 2800 const children_cursor = try self.parent_to_children.getCursor(oid_int) orelse return; 2801 const children = try TempDB.HashSet(.read_only).init(children_cursor); 2802 var children_iter = try children.iterator(); 2803 2804 while (try children_iter.next()) |*child_cursor| { 2805 const kv_pair = try child_cursor.readKeyValuePair(); 2806 const child_oid_int = kv_pair.hash; 2807 const pending_parent_cursor = try self.child_to_pending_parents.getCursor(child_oid_int) orelse return error.CursorNotFound; 2808 const pending_parent_count = try pending_parent_cursor.readUint(); 2809 2810 if (pending_parent_count <= 1) { 2811 _ = try self.child_to_pending_parents.remove(child_oid_int); 2812 const child_oid = hash.intToBytes(hash.HashInt(repo_opts.hash), child_oid_int); 2813 try self.ready_queue.append(.{ .bytes = &child_oid }); 2814 } else { 2815 try self.child_to_pending_parents.put(child_oid_int, .{ .uint = pending_parent_count - 1 }); 2816 } 2817 } 2818 } 2819 2820 fn readOidFromList(list: TempDB.ArrayList(.read_only), index: u64) ![hash.byteLen(repo_opts.hash)]u8 { 2821 const oid_cursor = try list.getCursor(index) orelse return error.CursorNotFound; 2822 var oid: [hash.byteLen(repo_opts.hash)]u8 = undefined; 2823 _ = try oid_cursor.readBytes(&oid); 2824 return oid; 2825 } 2826 }; 2827 } 2828