authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-15 12:15:32 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-15 12:15:32 -07:00
logef8d303fd2efa79c645bdf221edbb1a0087271ca
treef0e6facbc6bf3eaa17ec6bc40bfb7ed5f8c42bbe
parent62f291be2c039c9292a01e1c50984fd19f8b92ba
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

break diffFileIterator out of writeTreeDiffOnlyRaw


1 files changed, 20 insertions(+), 16 deletions(-)

git.zig+20-16
......@@ -1305,18 +1305,7 @@ pub const Repository = struct {
13051305 return try arena.dupe(CommitId, result.values());
13061306 }
13071307
1308 pub fn writeTreeDiffOnlyRaw(r: *Repository, writable: anytype, commitid: CommitId, parentid: ?CommitId) !void {
1309 const S = struct {
1310 fn item(w: anytype, b_mode: Tree.Object.Mode, a_mode: Tree.Object.Mode, b_id: Id, a_id: Id, action: TreeDiff.Action, p: ?*const PathListNode, name: []const u8) !void {
1311 if (p == null) {
1312 try w.writevAll(&.{ ":", &b_mode.intbytes(), " ", &a_mode.intbytes(), " ", b_id, " ", a_id, " ", @tagName(action), "\t", name, "\n" });
1313 return;
1314 }
1315 try w.writevAll(&.{ ":", &b_mode.intbytes(), " ", &a_mode.intbytes(), " ", b_id, " ", a_id, " ", @tagName(action), "\t" });
1316 try p.?.nprint(w);
1317 try w.writevAll(&.{ "/", name, "\n" });
1318 }
1319 };
1308 pub fn diffFileIterator(r: *Repository, writable: anytype, commitid_from: ?CommitId, commitid_to: CommitId, S: type) !void {
13201309 const A = struct {
13211310 fn item(w: anytype, mode: Tree.Object.Mode, id: Id, p: ?*const PathListNode, name: []const u8) !void {
13221311 try S.item(w, .none, mode, &@splat('0'), id, .A, p, name);
......@@ -1503,18 +1492,33 @@ pub const Repository = struct {
15031492 }
15041493 }
15051494 };
1506 if (parentid == null) {
1507 const commitidx = try r.getCommitA(r.gpa, commitid.id);
1495 if (commitid_from == null) {
1496 const commitidx = try r.getCommitA(r.gpa, commitid_to.id);
15081497 const commit = commitidx.reify(r);
15091498 try A.dir(r, writable, commit.tree.id, null, 0);
15101499 return;
15111500 }
1512 const before_commitidx = try r.getCommitA(r.gpa, parentid.?.id);
1501 const before_commitidx = try r.getCommitA(r.gpa, commitid_from.?.id);
15131502 const before_commit = before_commitidx.reify(r);
1514 const after_commitidx = try r.getCommitA(r.gpa, commitid.id);
1503 const after_commitidx = try r.getCommitA(r.gpa, commitid_to.id);
15151504 const after_commit = after_commitidx.reify(r);
15161505 try M.dir(r, writable, before_commit.tree.id, after_commit.tree.id, null);
15171506 }
1507
1508 pub fn writeTreeDiffOnlyRaw(r: *Repository, writable: anytype, commitid: CommitId, parentid: ?CommitId) !void {
1509 const S = struct {
1510 fn item(w: anytype, b_mode: Tree.Object.Mode, a_mode: Tree.Object.Mode, b_id: Id, a_id: Id, action: TreeDiff.Action, p: ?*const PathListNode, name: []const u8) !void {
1511 if (p == null) {
1512 try w.writevAll(&.{ ":", &b_mode.intbytes(), " ", &a_mode.intbytes(), " ", b_id, " ", a_id, " ", @tagName(action), "\t", name, "\n" });
1513 return;
1514 }
1515 try w.writevAll(&.{ ":", &b_mode.intbytes(), " ", &a_mode.intbytes(), " ", b_id, " ", a_id, " ", @tagName(action), "\t" });
1516 try p.?.nprint(w);
1517 try w.writevAll(&.{ "/", name, "\n" });
1518 }
1519 };
1520 return diffFileIterator(r, writable, parentid, commitid, S);
1521 }
15181522};
15191523
15201524const z = @cImport({