| ... | @@ -299,11 +299,22 @@ pub const Tree = struct { | ... | @@ -299,11 +299,22 @@ pub const Tree = struct { |
| 299 | | 299 | |
| 300 | // TODO make this inspect .git manually | 300 | // TODO make this inspect .git manually |
| 301 | // TODO make this return a Reader when we implement it ourselves | 301 | // TODO make this return a Reader when we implement it ourselves |
| 302 | pub fn getTreeDiff(alloc: std.mem.Allocator, dir: std.fs.Dir, commitid: CommitId, parentid: CommitId) !string { | 302 | pub fn getTreeDiff(alloc: std.mem.Allocator, dir: std.fs.Dir, commitid: CommitId, parentid: ?CommitId) !string { |
| | 303 | if (parentid == null) { |
| | 304 | const result = try std.ChildProcess.exec(.{ |
| | 305 | .allocator = alloc, |
| | 306 | .cwd_dir = dir, |
| | 307 | // 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is a hardcode for the empty tree in git sha1 |
| | 308 | // result of `printf | git hash-object -t tree --stdin` |
| | 309 | .argv = &.{ "git", "diff-tree", "-p", "--raw", "4b825dc642cb6eb9a060e54bf8d69288fbee4904", commitid.id }, |
| | 310 | .max_output_bytes = 1024 * 1024 * 1024, |
| | 311 | }); |
| | 312 | return std.mem.trim(u8, result.stdout, "\n"); |
| | 313 | } |
| 303 | const result = try std.ChildProcess.exec(.{ | 314 | const result = try std.ChildProcess.exec(.{ |
| 304 | .allocator = alloc, | 315 | .allocator = alloc, |
| 305 | .cwd_dir = dir, | 316 | .cwd_dir = dir, |
| 306 | .argv = &.{ "git", "diff-tree", "-p", "--raw", parentid.id, commitid.id }, | 317 | .argv = &.{ "git", "diff-tree", "-p", "--raw", parentid.?.id, commitid.id }, |
| 307 | .max_output_bytes = 1024 * 1024 * 1024, | 318 | .max_output_bytes = 1024 * 1024 * 1024, |
| 308 | }); | 319 | }); |
| 309 | return std.mem.trim(u8, result.stdout, "\n"); | 320 | return std.mem.trim(u8, result.stdout, "\n"); |