diff --git a/git.zig b/git.zig index 7252630939b76ddbf78186fe888a58c87f0f3109..d2f24bf04f8856b8a8faaa304681e57870e553ea 100644 --- a/git.zig +++ b/git.zig @@ -193,6 +193,23 @@ pub fn revList(alloc: std.mem.Allocator, dir: nfs.Dir, comptime count: u31, from return std.mem.trimRight(u8, result.stdout, "\n"); } +// TODO make this inspect .git/objects manually +// 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 +// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects +// https://git-scm.com/book/en/v2/Git-Internals-Packfiles +pub fn revListAll(alloc: std.mem.Allocator, dir: nfs.Dir, from: CommitId, sub_path: string) !string { + const t = tracer.trace(@src(), " {s} -- {s}", .{ from.id, sub_path }); + defer t.end(); + + const result = try std.process.Child.run(.{ + .allocator = alloc, + .cwd_dir = dir.to_std(), + .argv = &.{ "git", "rev-list", from.id, "--", sub_path }, + }); + std.debug.assert(result.term == .Exited and result.term.Exited == 0); + return std.mem.trimRight(u8, result.stdout, "\n"); +} + pub fn parseCommit(alloc: std.mem.Allocator, commitfile: string) !Commit { const t = tracer.trace(@src(), "", .{}); defer t.end();