authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-03-11 00:49:20 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-03-11 00:49:20 -07:00
logdcd7368ee7c34ea36b15ca05de65ebceb30b303e
tree9e3c3648805133fd369249b76411bd1d7fa5a226
parent72921adaa32363c30808cae95593d0e8a7013057
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

add revListAll


1 files changed, 17 insertions(+), 0 deletions(-)

git.zig+17
......@@ -193,6 +193,23 @@ pub fn revList(alloc: std.mem.Allocator, dir: nfs.Dir, comptime count: u31, from
193193 return std.mem.trimRight(u8, result.stdout, "\n");
194194}
195195
196// TODO make this inspect .git/objects manually
197// 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
198// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects
199// https://git-scm.com/book/en/v2/Git-Internals-Packfiles
200pub fn revListAll(alloc: std.mem.Allocator, dir: nfs.Dir, from: CommitId, sub_path: string) !string {
201 const t = tracer.trace(@src(), " {s} -- {s}", .{ from.id, sub_path });
202 defer t.end();
203
204 const result = try std.process.Child.run(.{
205 .allocator = alloc,
206 .cwd_dir = dir.to_std(),
207 .argv = &.{ "git", "rev-list", from.id, "--", sub_path },
208 });
209 std.debug.assert(result.term == .Exited and result.term.Exited == 0);
210 return std.mem.trimRight(u8, result.stdout, "\n");
211}
212
196213pub fn parseCommit(alloc: std.mem.Allocator, commitfile: string) !Commit {
197214 const t = tracer.trace(@src(), "", .{});
198215 defer t.end();