╭ changed ───╮ │src/fork.zig│ ╰────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────╮ │237 │ │238 // execute a transaction that receives the push and materializes its revision│ │239 { │ │240 + var response = xit.net_server_receive_pack.Response.init(allocator); │ │241 + defer response.deinit(); │ │242 const DB = rp.Repo(.xit, repo_opts).DB; │ │243 const State = rp.Repo(.xit, repo_opts).State; │ │244 const Ctx = struct { │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────╮ │248 allocator: std.mem.Allocator, │ │249 reader: *std.Io.Reader, │ │250 writer: *std.Io.Writer, │ │251 + response: *xit.net_server_receive_pack.Response,│ │252 patch_id: [evt.event_id_size * 2]u8, │ │253 patch: evt.Patch.Record, │ │254 published: bool, │ ╰─────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │263 // receive the branch update │ │264 var moment = try DB.HashMap(.read_write).init(cursor.*); │ │265 const state = State(.read_write){ .core = ctx.core, .extra = .{ .moment = &moment } }; │ │263 - try xit.net_server_receive_pack.run(.xit, repo_opts, state, ctx.io, ctx.allocator, ctx.reader, ctx.writer, .{ .allowed_ref = ref_path }); │ │266 + try xit.net_server_receive_pack.run(.xit, repo_opts, state, ctx.io, ctx.allocator, ctx.reader, ctx.writer, .{ .allowed_ref = ref_path, .deferred_response = ctx.response });│ │267 + try evt.writeReceivedPatches(repo_opts, state, ctx.io, ctx.allocator, ctx.response, ctx.writer); │ │268 │ │269 // copy the target history needed to preserve the merge base │ │270 const source_oid = (try rf.readRecur(.xit, repo_opts, state.readOnly(), ctx.io, .{ .ref = ref })) orelse return error.CancelTransaction; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────╮ │382 .allocator = allocator,│ │383 .reader = reader, │ │384 .writer = writer, │ │385 + .response = &response, │ │386 .patch_id = id.*, │ │387 .patch = fork_patch, │ │388 .published = published,│ ╰────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────╮ │392 .timestamp = timestamp, │ │393 .newest = newest, │ │394 .revision_id_maybe = &revision_id_maybe, │ │390 - }) catch |err| switch (err) { │ │391 - error.CancelTransaction => {}, │ │392 - else => |other| return other, │ │395 + }) catch |err| { │ │396 + response.finish(writer, @errorName(err)) catch {}; │ │397 + if (err == error.CancelTransaction) return; │ │398 + return err; │ │399 }; │ │394 - try writer.flush(); │ │400 + try response.finish(writer, null); │ │401 } │ │402 │ │403 // best-effort update the published patch so it has the new revision│ ╰─────────────────────────────────────────────────────────────────────────────╯