╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ patch.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
374 if (update.old_oid.len != hash.hexLen(repo_opts.hash) or 375 update.new_oid.len != hash.hexLen(repo_opts.hash)) return error.InvalidOid; 376 var old_oid: [hash.hexLen(repo_opts.hash)]u8 = undefined; 377 var new_oid: [hash.hexLen(repo_opts.hash)]u8 = undefined; 378 @memcpy(&old_oid, update.old_oid); 379 @memcpy(&new_oid, update.new_oid); 380 if (std.mem.allEqual(u8, &new_oid, '0')) continue; 381 382 var commits = try obj.ObjectIterator(.xit, repo_opts).init(state.readOnly(), io, arena.allocator(), .{ .kind = .commit }); 383 defer commits.deinit(); 384 if (!std.mem.allEqual(u8, &old_oid, '0')) try commits.exclude(&old_oid); 385 try commits.include(&new_oid); 386 var revision_key_buffer: [rf.MAX_REF_CONTENT_SIZE + 1 + hash.hexLen(repo_opts.hash)]u8 = undefined; 387 while (try commits.next(arena.allocator())) |commit| { 388 defer commit.deinit(); 389 const key = try std.fmt.bufPrint(&revision_key_buffer, "{s}\x00{s}", .{ update.ref_name, &commit.oid }); 390 const ids_cursor = try revisions.getCursor(hash.hashInt(repo_opts.hash, key)) orelse continue; 391 const ids = try DB.CountedHashSet(.read_only).init(ids_cursor); 392 var ids_iter = try ids.iterator(); 393 while (try ids_iter.next()) |cursor| { 394 const pair = try cursor.readKeyValuePair(); 395 var patch_id: [evt.event_id_size]u8 = undefined; 396 if ((try pair.key_cursor.readBytes(&patch_id)).len != patch_id.len) return error.InvalidPatch; 397 const patch_hex = std.fmt.bytesToHex(patch_id, .lower); 398 importMerged(repo_opts, state, db, moment, io, allocator, repo_root_path, &patch_id) catch |err| { 399 serve_common.logError(io, error_writer, "failed to mark patch {s} as merged: {s}\n", .{ &patch_hex, @errorName(err) }); 400 continue; 401 }; 402 } 403 } 404 } 405 } 406