| ... | ... | @@ -261,6 +261,93 @@ pub fn getTreeDiff(alloc: std.mem.Allocator, dir: nfs.Dir, commitid: CommitId, p |
| 261 | 261 | return std.mem.trim(u8, result.stdout, "\n"); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | // TODO make this inspect .git manually |
| 265 | pub fn getTreeDiffOnlyRaw(alloc: std.mem.Allocator, dir: nfs.Dir, commitid: CommitId, parentid: ?CommitId) !string { |
| 266 | const t = tracer.trace(@src(), "", .{}); |
| 267 | defer t.end(); |
| 268 | |
| 269 | if (parentid == null) { |
| 270 | // 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is a hardcode for the empty tree in git sha1 |
| 271 | // result of `printf | git hash-object -t tree --stdin` |
| 272 | const result = try root.child_process.run(alloc, dir, .ignore, .pipe, .ignore, 1024 * 1024 * 1024, &.{ "git", "diff-tree", "--raw", "-r", "4b825dc642cb6eb9a060e54bf8d69288fbee4904", commitid.id }); |
| 273 | std.debug.assert(result.term == .exited and result.term.exited == 0); |
| 274 | return std.mem.trim(u8, result.stdout, "\n"); |
| 275 | } |
| 276 | const result = try root.child_process.run(alloc, dir, .ignore, .pipe, .ignore, 1024 * 1024 * 1024, &.{ "git", "diff-tree", "--raw", "-r", parentid.?.id, commitid.id }); |
| 277 | std.debug.assert(result.term == .exited and result.term.exited == 0); |
| 278 | return std.mem.trim(u8, result.stdout, "\n"); |
| 279 | } |
| 280 | |
| 281 | // TODO make this inspect .git manually |
| 282 | pub fn getTreeDiffOnlyStat(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", "--stat", "4b825dc642cb6eb9a060e54bf8d69288fbee4904", commitid.id }); |
| 290 | std.debug.assert(result.term == .exited and result.term.exited == 0); |
| 291 | return std.mem.trim(u8, result.stdout, "\n"); |
| 292 | } |
| 293 | const result = try root.child_process.run(alloc, dir, .ignore, .pipe, .ignore, 1024 * 1024 * 1024, &.{ "git", "diff-tree", "--stat", parentid.?.id, commitid.id }); |
| 294 | std.debug.assert(result.term == .exited and result.term.exited == 0); |
| 295 | return std.mem.trim(u8, result.stdout, "\n"); |
| 296 | } |
| 297 | |
| 298 | // TODO make this inspect .git manually |
| 299 | pub fn getTreeDiffOnlySummary(alloc: std.mem.Allocator, dir: nfs.Dir, commitid: CommitId, parentid: ?CommitId) !string { |
| 300 | const t = tracer.trace(@src(), "", .{}); |
| 301 | defer t.end(); |
| 302 | |
| 303 | if (parentid == null) { |
| 304 | // 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is a hardcode for the empty tree in git sha1 |
| 305 | // result of `printf | git hash-object -t tree --stdin` |
| 306 | const result = try root.child_process.run(alloc, dir, .ignore, .pipe, .ignore, 1024 * 1024 * 1024, &.{ "git", "diff-tree", "--summary", "4b825dc642cb6eb9a060e54bf8d69288fbee4904", commitid.id }); |
| 307 | std.debug.assert(result.term == .exited and result.term.exited == 0); |
| 308 | return std.mem.trim(u8, result.stdout, "\n"); |
| 309 | } |
| 310 | const result = try root.child_process.run(alloc, dir, .ignore, .pipe, .ignore, 1024 * 1024 * 1024, &.{ "git", "diff-tree", "--summary", parentid.?.id, commitid.id }); |
| 311 | std.debug.assert(result.term == .exited and result.term.exited == 0); |
| 312 | return std.mem.trim(u8, result.stdout, "\n"); |
| 313 | } |
| 314 | |
| 315 | // TODO make this inspect .git manually |
| 316 | pub fn getTreeDiffOnlyDiff(alloc: std.mem.Allocator, dir: nfs.Dir, commitid: CommitId, parentid: ?CommitId) !string { |
| 317 | const t = tracer.trace(@src(), "", .{}); |
| 318 | defer t.end(); |
| 319 | |
| 320 | if (parentid == null) { |
| 321 | // 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is a hardcode for the empty tree in git sha1 |
| 322 | // result of `printf | git hash-object -t tree --stdin` |
| 323 | const result = try root.child_process.run(alloc, dir, .ignore, .pipe, .ignore, 1024 * 1024 * 1024, &.{ "git", "diff-tree", "--patch", "--full-index", "--patience", "4b825dc642cb6eb9a060e54bf8d69288fbee4904", commitid.id }); |
| 324 | if (!(result.term == .exited and result.term.exited == 0)) std.log.err("{s}", .{result.stderr}); |
| 325 | std.debug.assert(result.term == .exited and result.term.exited == 0); |
| 326 | return std.mem.trim(u8, result.stdout, "\n"); |
| 327 | } |
| 328 | const result = try root.child_process.run(alloc, dir, .ignore, .pipe, .ignore, 1024 * 1024 * 1024, &.{ "git", "diff-tree", "--patch", "--full-index", "--patience", parentid.?.id, commitid.id }); |
| 329 | if (!(result.term == .exited and result.term.exited == 0)) std.log.err("{s}", .{result.stderr}); |
| 330 | std.debug.assert(result.term == .exited and result.term.exited == 0); |
| 331 | return std.mem.trim(u8, result.stdout, "\n"); |
| 332 | } |
| 333 | |
| 334 | // TODO make this inspect .git manually |
| 335 | pub fn getFormatPatch(alloc: std.mem.Allocator, dir: nfs.Dir, commitid: CommitId, parentid: ?CommitId) !string { |
| 336 | const t = tracer.trace(@src(), "", .{}); |
| 337 | defer t.end(); |
| 338 | |
| 339 | if (parentid == null) { |
| 340 | const result = try root.child_process.run(alloc, dir, .ignore, .pipe, .pipe, 1024 * 1024 * 1024, &.{ "git", "format-patch", "--stdout", "--full-index", "--patience", "--root", commitid.id }); |
| 341 | if (!(result.term == .exited and result.term.exited == 0)) std.log.err("{s}", .{result.stderr}); |
| 342 | std.debug.assert(result.term == .exited and result.term.exited == 0); |
| 343 | return std.mem.trim(u8, result.stdout, "\n"); |
| 344 | } |
| 345 | const result = try root.child_process.run(alloc, dir, .ignore, .pipe, .pipe, 1024 * 1024 * 1024, &.{ "git", "format-patch", "--stdout", "--full-index", "--patience", parentid.?.id ++ "..." ++ commitid.id }); |
| 346 | if (!(result.term == .exited and result.term.exited == 0)) std.log.err("{s}", .{result.stderr}); |
| 347 | std.debug.assert(result.term == .exited and result.term.exited == 0); |
| 348 | return std.mem.trim(u8, result.stdout, "\n"); |
| 349 | } |
| 350 | |
| 264 | 351 | // TODO make this inspect .git manually |
| 265 | 352 | // TODO make this return a Reader when we implement it ourselves |
| 266 | 353 | pub fn getTreeDiffPath(alloc: std.mem.Allocator, dir: nfs.Dir, commitid: CommitId, parentid: ?CommitId, path: []const u8) !string { |