| ... | @@ -278,23 +278,6 @@ pub fn getTreeDiffOnlyStat(alloc: std.mem.Allocator, dir: nfs.Dir, commitid: Com | ... | @@ -278,23 +278,6 @@ pub fn getTreeDiffOnlyStat(alloc: std.mem.Allocator, dir: nfs.Dir, commitid: Com |
| 278 | return result.stdout; | 278 | return result.stdout; |
| 279 | } | 279 | } |
| 280 | | 280 | |
| 281 | // TODO make this inspect .git manually | | |
| 282 | pub fn getTreeDiffOnlySummary(alloc: std.mem.Allocator, dir: nfs.Dir, commitid: CommitId, parentid: ?CommitId) !string { | | |
| 283 | const t = tracer.trace(@src(), "", .{}); | | |
| 284 | defer t.end(); | | |
| 285 | | | |
| 286 | if (parentid == null) { | | |
| 287 | // 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is a hardcode for the empty tree in git sha1 | | |
| 288 | // result of `printf | git hash-object -t tree --stdin` | | |
| 289 | const result = try root.child_process.run(alloc, dir, .ignore, .pipe, .ignore, 1024 * 1024 * 1024, &.{ "git", "diff-tree", "--summary", "4b825dc642cb6eb9a060e54bf8d69288fbee4904", commitid.id }); | | |
| 290 | std.debug.assert(result.term == .exited and result.term.exited == 0); | | |
| 291 | return result.stdout; | | |
| 292 | } | | |
| 293 | const result = try root.child_process.run(alloc, dir, .ignore, .pipe, .ignore, 1024 * 1024 * 1024, &.{ "git", "diff-tree", "--summary", parentid.?.id, commitid.id }); | | |
| 294 | std.debug.assert(result.term == .exited and result.term.exited == 0); | | |
| 295 | return result.stdout; | | |
| 296 | } | | |
| 297 | | | |
| 298 | // TODO make this inspect .git manually | 281 | // TODO make this inspect .git manually |
| 299 | pub fn getTreeDiffOnlyDiff(alloc: std.mem.Allocator, dir: nfs.Dir, commitid: CommitId, parentid: ?CommitId) !string { | 282 | pub fn getTreeDiffOnlyDiff(alloc: std.mem.Allocator, dir: nfs.Dir, commitid: CommitId, parentid: ?CommitId) !string { |
| 300 | const t = tracer.trace(@src(), "", .{}); | 283 | const t = tracer.trace(@src(), "", .{}); |
| ... | @@ -1519,6 +1502,48 @@ pub const Repository = struct { | ... | @@ -1519,6 +1502,48 @@ pub const Repository = struct { |
| 1519 | }; | 1502 | }; |
| 1520 | return diffFileIterator(r, writable, parentid, commitid, S); | 1503 | return diffFileIterator(r, writable, parentid, commitid, S); |
| 1521 | } | 1504 | } |
| | 1505 | |
| | 1506 | pub fn writeTreeDiffOnlySummary(r: *Repository, writable: anytype, commitid: CommitId, parentid: ?CommitId) !void { |
| | 1507 | const S = struct { |
| | 1508 | 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 { |
| | 1509 | _ = b_id; |
| | 1510 | _ = a_id; |
| | 1511 | switch (action) { |
| | 1512 | .A => { |
| | 1513 | if (p == null) { |
| | 1514 | try w.writevAll(&.{ " create mode ", &a_mode.intbytes(), " ", name, "\n" }); |
| | 1515 | return; |
| | 1516 | } |
| | 1517 | try w.writevAll(&.{ " create mode ", &a_mode.intbytes(), " " }); |
| | 1518 | try p.?.nprint(w); |
| | 1519 | try w.writevAll(&.{ "/", name, "\n" }); |
| | 1520 | }, |
| | 1521 | .D => { |
| | 1522 | if (p == null) { |
| | 1523 | try w.writevAll(&.{ " delete mode ", &b_mode.intbytes(), " ", name, "\n" }); |
| | 1524 | return; |
| | 1525 | } |
| | 1526 | try w.writevAll(&.{ " delete mode ", &b_mode.intbytes(), " " }); |
| | 1527 | try p.?.nprint(w); |
| | 1528 | try w.writevAll(&.{ "/", name, "\n" }); |
| | 1529 | }, |
| | 1530 | .M => { |
| | 1531 | if (!std.mem.eql(u8, &b_mode.intbytes(), &a_mode.intbytes())) { |
| | 1532 | if (p == null) { |
| | 1533 | try w.writevAll(&.{ " mode change ", &b_mode.intbytes(), " => ", &a_mode.intbytes(), " ", name, "\n" }); |
| | 1534 | return; |
| | 1535 | } |
| | 1536 | try w.writevAll(&.{ " mode change ", &b_mode.intbytes(), " => ", &a_mode.intbytes(), " " }); |
| | 1537 | try p.?.nprint(w); |
| | 1538 | try w.writevAll(&.{ "/", name, "\n" }); |
| | 1539 | } |
| | 1540 | }, |
| | 1541 | else => {}, |
| | 1542 | } |
| | 1543 | } |
| | 1544 | }; |
| | 1545 | return diffFileIterator(r, writable, parentid, commitid, S); |
| | 1546 | } |
| 1522 | }; | 1547 | }; |
| 1523 | | 1548 | |
| 1524 | const z = @cImport({ | 1549 | const z = @cImport({ |