| ... | @@ -1305,18 +1305,7 @@ pub const Repository = struct { | ... | @@ -1305,18 +1305,7 @@ pub const Repository = struct { |
| 1305 | return try arena.dupe(CommitId, result.values()); | 1305 | return try arena.dupe(CommitId, result.values()); |
| 1306 | } | 1306 | } |
| 1307 | | 1307 | |
| 1308 | pub fn writeTreeDiffOnlyRaw(r: *Repository, writable: anytype, commitid: CommitId, parentid: ?CommitId) !void { | 1308 | pub fn diffFileIterator(r: *Repository, writable: anytype, commitid_from: ?CommitId, commitid_to: CommitId, S: type) !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 | }; | | |
| 1320 | const A = struct { | 1309 | const A = struct { |
| 1321 | fn item(w: anytype, mode: Tree.Object.Mode, id: Id, p: ?*const PathListNode, name: []const u8) !void { | 1310 | fn item(w: anytype, mode: Tree.Object.Mode, id: Id, p: ?*const PathListNode, name: []const u8) !void { |
| 1322 | try S.item(w, .none, mode, &@splat('0'), id, .A, p, name); | 1311 | try S.item(w, .none, mode, &@splat('0'), id, .A, p, name); |
| ... | @@ -1503,18 +1492,33 @@ pub const Repository = struct { | ... | @@ -1503,18 +1492,33 @@ pub const Repository = struct { |
| 1503 | } | 1492 | } |
| 1504 | } | 1493 | } |
| 1505 | }; | 1494 | }; |
| 1506 | if (parentid == null) { | 1495 | if (commitid_from == null) { |
| 1507 | const commitidx = try r.getCommitA(r.gpa, commitid.id); | 1496 | const commitidx = try r.getCommitA(r.gpa, commitid_to.id); |
| 1508 | const commit = commitidx.reify(r); | 1497 | const commit = commitidx.reify(r); |
| 1509 | try A.dir(r, writable, commit.tree.id, null, 0); | 1498 | try A.dir(r, writable, commit.tree.id, null, 0); |
| 1510 | return; | 1499 | return; |
| 1511 | } | 1500 | } |
| 1512 | const before_commitidx = try r.getCommitA(r.gpa, parentid.?.id); | 1501 | const before_commitidx = try r.getCommitA(r.gpa, commitid_from.?.id); |
| 1513 | const before_commit = before_commitidx.reify(r); | 1502 | 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); |
| 1515 | const after_commit = after_commitidx.reify(r); | 1504 | const after_commit = after_commitidx.reify(r); |
| 1516 | try M.dir(r, writable, before_commit.tree.id, after_commit.tree.id, null); | 1505 | try M.dir(r, writable, before_commit.tree.id, after_commit.tree.id, null); |
| 1517 | } | 1506 | } |
| | 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 | } |
| 1518 | }; | 1522 | }; |
| 1519 | | 1523 | |
| 1520 | const z = @cImport({ | 1524 | const z = @cImport({ |