| ... | @@ -65,6 +65,26 @@ pub fn getObjectSize(alloc: std.mem.Allocator, dir: std.fs.Dir, obj: Id) !u64 { | ... | @@ -65,6 +65,26 @@ pub fn getObjectSize(alloc: std.mem.Allocator, dir: std.fs.Dir, obj: Id) !u64 { |
| 65 | return try std.fmt.parseInt(u64, std.mem.trimRight(u8, result.stdout, "\n"), 10); | 65 | return try std.fmt.parseInt(u64, std.mem.trimRight(u8, result.stdout, "\n"), 10); |
| 66 | } | 66 | } |
| 67 | | 67 | |
| | 68 | // TODO make this inspect .git/objects manually |
| | 69 | // TODO make a version of this that accepts an array of sub_paths and searches all of them at once, so as to not lose spot in history when searching for many old paths |
| | 70 | // https://git-scm.com/book/en/v2/Git-Internals-Git-Objects |
| | 71 | // https://git-scm.com/book/en/v2/Git-Internals-Packfiles |
| | 72 | pub fn revList(alloc: std.mem.Allocator, dir: std.fs.Dir, comptime count: u31, from: CommitId, sub_path: string) !string { |
| | 73 | const result = try std.ChildProcess.exec(.{ |
| | 74 | .allocator = alloc, |
| | 75 | .cwd_dir = dir, |
| | 76 | .argv = &.{ |
| | 77 | "git", |
| | 78 | "rev-list", |
| | 79 | "-" ++ std.fmt.comptimePrint("{d}", .{count}), |
| | 80 | from.id, |
| | 81 | "--", |
| | 82 | sub_path, |
| | 83 | }, |
| | 84 | }); |
| | 85 | return std.mem.trimRight(u8, result.stdout, "\n"); |
| | 86 | } |
| | 87 | |
| 68 | pub fn parseCommit(alloc: std.mem.Allocator, commitfile: string) !Commit { | 88 | pub fn parseCommit(alloc: std.mem.Allocator, commitfile: string) !Commit { |
| 69 | var iter = std.mem.split(u8, commitfile, "\n"); | 89 | var iter = std.mem.split(u8, commitfile, "\n"); |
| 70 | var result: Commit = undefined; | 90 | var result: Commit = undefined; |