╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ event.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1846 try seen_object_ids.put(oid_int, .{ .bytes = &oid }); 1847 1848 var commit_object = try obj.Object(repo_kind, repo_opts).init(state, io, allocator, &std.fmt.bytesToHex(oid, .lower)); 1849 defer commit_object.deinit(); 1850 1851 // if this object id has already been consumed, skip it 1852 if (null != try consumed_object_ids.getCursor(oid_int)) { 1853 continue; 1854 } 1855 1856 if (self.newest_object_id == null) self.newest_object_id = oid; 1857 self.oldest_object_id = oid; 1858 1859 const parent_oids = commit_object.content.commit.metadata.parent_oids orelse return error.ParentOidsNotFound; 1860 var pending_parent_count: u64 = 0; 1861 for (parent_oids) |*parent_oid| { 1862 var parent_oid_bytes: [hash.byteLen(repo_opts.hash)]u8 = undefined; 1863 _ = try std.fmt.hexToBytes(&parent_oid_bytes, parent_oid); 1864 const parent_oid_int = hash.bytesToInt(repo_opts.hash, &parent_oid_bytes); 1865 1866 // if this object id has already been consumed, skip it 1867 if (null != try consumed_object_ids.getCursor(parent_oid_int)) { 1868 continue; 1869 } 1870 1871 // if this object id hasn't already been seen, add it to the walk queue 1872 if (null == try seen_object_ids.getCursor(parent_oid_int)) { 1873 try walk_queue.append(.{ .bytes = &parent_oid_bytes }); 1874 } 1875 1876 const children_cursor = try self.parent_to_children.putCursor(parent_oid_int); 1877 const children = try DB.HashSet(.read_write).init(children_cursor); 1878 try children.put(oid_int, .{ .bytes = &oid }); 1879 pending_parent_count += 1; 1880 } 1881 1882 if (pending_parent_count == 0) { 1883 try self.ready_queue.append(.{ .bytes = &oid }); 1884 } else { 1885 try self.child_to_pending_parents.put(oid_int, .{ .uint = pending_parent_count }); 1886 } 1887 } 1888 } 1889 1890 fn enqueueChildren(self: *CommitIterator(repo_kind, repo_opts), oid: *const [hash.byteLen(repo_opts.hash)]u8) !void { 1891 const oid_int = hash.bytesToInt(repo_opts.hash, oid); 1892 const children_cursor = try self.parent_to_children.getCursor(oid_int) orelse return; 1893 const children = try DB.HashSet(.read_only).init(children_cursor); 1894 var children_iter = try children.iterator(); 1895 1896 while (try children_iter.next()) |*child_cursor| { 1897 const kv_pair = try child_cursor.readKeyValuePair(); 1898 const child_oid_int = kv_pair.hash; 1899 const pending_parent_cursor = try self.child_to_pending_parents.getCursor(child_oid_int) orelse return error.CursorNotFound; 1900 const pending_parent_count = try pending_parent_cursor.readUint(); 1901 1902 if (pending_parent_count <= 1) { 1903 _ = try self.child_to_pending_parents.remove(child_oid_int); 1904 const child_oid = hash.intToBytes(hash.HashInt(repo_opts.hash), child_oid_int); 1905 try self.ready_queue.append(.{ .bytes = &child_oid }); 1906 } else { 1907 try self.child_to_pending_parents.put(child_oid_int, .{ .uint = pending_parent_count - 1 }); 1908 } 1909 } 1910 } 1911 1912 fn readOidFromList(list: DB.ArrayList(.read_only), index: u64) ![hash.byteLen(repo_opts.hash)]u8 { 1913 const oid_cursor = try list.getCursor(index) orelse return error.CursorNotFound; 1914 var oid: [hash.byteLen(repo_opts.hash)]u8 = undefined; 1915 _ = try oid_cursor.readBytes(&oid); 1916 return oid; 1917 } 1918 }; 1919 } 1920