╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭───────────────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
3019 const head_oid_hex = (try rf.readRecur(repo_kind, repo_opts, state, io, .{ .ref = ref })) orelse return error.OidNotFound; 3020 var head_oid: [hash.byteLen(repo_opts.hash)]u8 = undefined; 3021 _ = try std.fmt.hexToBytes(&head_oid, &head_oid_hex); 3022 try walk_queue.append(.{ .bytes = &head_oid }); 3023 3024 while (walk_queue_index < try walk_queue.count()) { 3025 const oid = try readOidFromList(walk_queue.readOnly(), walk_queue_index); 3026 const oid_int = hash.bytesToInt(repo_opts.hash, &oid); 3027 3028 walk_queue_index += 1; 3029 3030 // if we've seen this object id, skip it 3031 if (null != try seen_object_ids.getCursor(oid_int)) { 3032 continue; 3033 } 3034 3035 try seen_object_ids.put(oid_int, .{ .bytes = &oid }); 3036 3037 var commit_object = try obj.Object(repo_kind, repo_opts).init(state, io, allocator, &std.fmt.bytesToHex(oid, .lower)); 3038 defer commit_object.deinit(); 3039 3040 // if this object id has already been consumed, skip it 3041 if (null != try consumed_object_ids.getCursor(oid_int)) { 3042 continue; 3043 } 3044 3045 if (self.newest_object_id == null) self.newest_object_id = oid; 3046 self.oldest_object_id = oid; 3047 3048 const parent_oids = commit_object.content.commit.metadata.parent_oids orelse return error.ParentOidsNotFound; 3049 var pending_parent_count: u64 = 0; 3050 for (parent_oids) |*parent_oid| { 3051 var parent_oid_bytes: [hash.byteLen(repo_opts.hash)]u8 = undefined; 3052 _ = try std.fmt.hexToBytes(&parent_oid_bytes, parent_oid); 3053 const parent_oid_int = hash.bytesToInt(repo_opts.hash, &parent_oid_bytes); 3054 3055 // if this object id has already been consumed, skip it 3056 if (null != try consumed_object_ids.getCursor(parent_oid_int)) { 3057 continue; 3058 } 3059 3060 // if this object id hasn't already been seen, add it to the walk queue 3061 if (null == try seen_object_ids.getCursor(parent_oid_int)) { 3062 try walk_queue.append(.{ .bytes = &parent_oid_bytes }); 3063 } 3064 3065 const children_cursor = try self.parent_to_children.putCursor(parent_oid_int); 3066 const children = try TempDB.HashSet(.read_write).init(children_cursor); 3067 try children.put(oid_int, .{ .bytes = &oid }); 3068 pending_parent_count += 1; 3069 } 3070 3071 if (pending_parent_count == 0) { 3072 try self.ready_queue.append(.{ .bytes = &oid }); 3073 } else { 3074 try self.child_to_pending_parents.put(oid_int, .{ .uint = pending_parent_count }); 3075 } 3076 } 3077 } 3078 3079 fn enqueueChildren(self: *CommitIterator(repo_kind, repo_opts), oid: *const [hash.byteLen(repo_opts.hash)]u8) !void { 3080 const oid_int = hash.bytesToInt(repo_opts.hash, oid); 3081 const children_cursor = try self.parent_to_children.getCursor(oid_int) orelse return; 3082 const children = try TempDB.HashSet(.read_only).init(children_cursor); 3083 var children_iter = try children.iterator(); 3084 3085 while (try children_iter.next()) |*child_cursor| { 3086 const kv_pair = try child_cursor.readKeyValuePair(); 3087 const child_oid_int = kv_pair.hash; 3088 const pending_parent_cursor = try self.child_to_pending_parents.getCursor(child_oid_int) orelse return error.CursorNotFound; 3089 const pending_parent_count = try pending_parent_cursor.readUint(); 3090 3091 if (pending_parent_count <= 1) { 3092 _ = try self.child_to_pending_parents.remove(child_oid_int); 3093 const child_oid = hash.intToBytes(hash.HashInt(repo_opts.hash), child_oid_int); 3094 try self.ready_queue.append(.{ .bytes = &child_oid }); 3095 } else { 3096 try self.child_to_pending_parents.put(child_oid_int, .{ .uint = pending_parent_count - 1 }); 3097 } 3098 } 3099 } 3100 3101 fn readOidFromList(list: TempDB.ArrayList(.read_only), index: u64) ![hash.byteLen(repo_opts.hash)]u8 { 3102 const oid_cursor = try list.getCursor(index) orelse return error.CursorNotFound; 3103 var oid: [hash.byteLen(repo_opts.hash)]u8 = undefined; 3104 _ = try oid_cursor.readBytes(&oid); 3105 return oid; 3106 } 3107 }; 3108 } 3109