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