authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-08-24 21:08:47 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-12-17 18:31:47 -08:00
log73aeaf86db7d1ee7ab39f053ccc846f3954ecd3a
tree0810b1a82d911f8bd7d73e16ffd733cc89b8e4d4
parente3fb67f40f18132e1553024aaa8efaa306f2cb13

switch to nfs over std.fs


4 files changed, 48 insertions(+), 30 deletions(-)

git.zig+23-19
...@@ -4,6 +4,7 @@ const top = @This();...@@ -4,6 +4,7 @@ const top = @This();
4const time = @import("time");4const time = @import("time");
5const extras = @import("extras");5const extras = @import("extras");
6const tracer = @import("tracer");6const tracer = @import("tracer");
7const nfs = @import("nfs");
78
8// 40 is length of sha1 hash9// 40 is length of sha1 hash
9pub const Id = *const [40]u8;10pub const Id = *const [40]u8;
...@@ -55,7 +56,7 @@ pub fn version(alloc: std.mem.Allocator) !string {...@@ -55,7 +56,7 @@ pub fn version(alloc: std.mem.Allocator) !string {
55/// Returns the result of running `git rev-parse HEAD`56/// Returns the result of running `git rev-parse HEAD`
56/// dir must already be pointing at the .git folder57/// dir must already be pointing at the .git folder
57// TODO this doesnt handle when there are 0 commits58// TODO this doesnt handle when there are 0 commits
58pub fn getHEAD(alloc: std.mem.Allocator, dir: std.fs.Dir) !?CommitId {59pub fn getHEAD(alloc: std.mem.Allocator, dir: nfs.Dir) !?CommitId {
59 const t = tracer.trace(@src(), "", .{});60 const t = tracer.trace(@src(), "", .{});
60 defer t.end();61 defer t.end();
6162
...@@ -63,7 +64,10 @@ pub fn getHEAD(alloc: std.mem.Allocator, dir: std.fs.Dir) !?CommitId {...@@ -63,7 +64,10 @@ pub fn getHEAD(alloc: std.mem.Allocator, dir: std.fs.Dir) !?CommitId {
6364
64 if (std.mem.startsWith(u8, h, "ref:")) {65 if (std.mem.startsWith(u8, h, "ref:")) {
65 blk: {66 blk: {
66 const reffile = dir.readFileAlloc(alloc, h[5..], 1024) catch |err| switch (err) {67 var buf: [std.fs.max_path_bytes]u8 = undefined;
68 @memcpy((&buf).ptr, h[5..]);
69 buf[h[5..].len] = 0;
70 const reffile = dir.readFileAlloc(alloc, buf[0..h[5..].len :0], 1024) catch |err| switch (err) {
67 error.FileNotFound => break :blk,71 error.FileNotFound => break :blk,
68 else => |e| return e,72 else => |e| return e,
69 };73 };
...@@ -101,13 +105,13 @@ fn ensureObjId(comptime T: type, input: string) T {...@@ -101,13 +105,13 @@ fn ensureObjId(comptime T: type, input: string) T {
101// TODO make this return a Reader when we implement it ourselves105// TODO make this return a Reader when we implement it ourselves
102// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects106// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects
103// https://git-scm.com/book/en/v2/Git-Internals-Packfiles107// https://git-scm.com/book/en/v2/Git-Internals-Packfiles
104pub fn getObject(alloc: std.mem.Allocator, dir: std.fs.Dir, obj: Id) !string {108pub fn getObject(alloc: std.mem.Allocator, dir: nfs.Dir, obj: Id) !string {
105 const t = tracer.trace(@src(), " {s}", .{obj});109 const t = tracer.trace(@src(), " {s}", .{obj});
106 defer t.end();110 defer t.end();
107111
108 const result = try std.process.Child.run(.{112 const result = try std.process.Child.run(.{
109 .allocator = alloc,113 .allocator = alloc,
110 .cwd_dir = dir,114 .cwd_dir = dir.to_std(),
111 .argv = &.{ "git", "cat-file", "-p", obj },115 .argv = &.{ "git", "cat-file", "-p", obj },
112 .max_output_bytes = 1024 * 1024 * 1024,116 .max_output_bytes = 1024 * 1024 * 1024,
113 });117 });
...@@ -118,13 +122,13 @@ pub fn getObject(alloc: std.mem.Allocator, dir: std.fs.Dir, obj: Id) !string {...@@ -118,13 +122,13 @@ pub fn getObject(alloc: std.mem.Allocator, dir: std.fs.Dir, obj: Id) !string {
118// TODO make this inspect .git/objects manually122// TODO make this inspect .git/objects manually
119// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects123// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects
120// https://git-scm.com/book/en/v2/Git-Internals-Packfiles124// https://git-scm.com/book/en/v2/Git-Internals-Packfiles
121pub fn getObjectSize(alloc: std.mem.Allocator, dir: std.fs.Dir, obj: Id) !u64 {125pub fn getObjectSize(alloc: std.mem.Allocator, dir: nfs.Dir, obj: Id) !u64 {
122 const t = tracer.trace(@src(), " {s}", .{obj});126 const t = tracer.trace(@src(), " {s}", .{obj});
123 defer t.end();127 defer t.end();
124128
125 const result = try std.process.Child.run(.{129 const result = try std.process.Child.run(.{
126 .allocator = alloc,130 .allocator = alloc,
127 .cwd_dir = dir,131 .cwd_dir = dir.to_std(),
128 .argv = &.{ "git", "cat-file", "-s", obj },132 .argv = &.{ "git", "cat-file", "-s", obj },
129 });133 });
130 extras.assertLog(result.term == .Exited and result.term.Exited == 0, "{s}", .{result.stderr});134 extras.assertLog(result.term == .Exited and result.term.Exited == 0, "{s}", .{result.stderr});
...@@ -134,13 +138,13 @@ pub fn getObjectSize(alloc: std.mem.Allocator, dir: std.fs.Dir, obj: Id) !u64 {...@@ -134,13 +138,13 @@ pub fn getObjectSize(alloc: std.mem.Allocator, dir: std.fs.Dir, obj: Id) !u64 {
134// TODO make this inspect .git manually138// TODO make this inspect .git manually
135// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects139// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects
136// https://git-scm.com/book/en/v2/Git-Internals-Packfiles140// https://git-scm.com/book/en/v2/Git-Internals-Packfiles
137pub fn isType(alloc: std.mem.Allocator, dir: std.fs.Dir, maybeobj: Id, typ: Tree.Object.Id.Tag) !bool {141pub fn isType(alloc: std.mem.Allocator, dir: nfs.Dir, maybeobj: Id, typ: Tree.Object.Id.Tag) !bool {
138 const t = tracer.trace(@src(), " {s} = {s} ?", .{ maybeobj, @tagName(typ) });142 const t = tracer.trace(@src(), " {s} = {s} ?", .{ maybeobj, @tagName(typ) });
139 defer t.end();143 defer t.end();
140144
141 const result = try std.process.Child.run(.{145 const result = try std.process.Child.run(.{
142 .allocator = alloc,146 .allocator = alloc,
143 .cwd_dir = dir,147 .cwd_dir = dir.to_std(),
144 .argv = &.{ "git", "cat-file", "-t", maybeobj },148 .argv = &.{ "git", "cat-file", "-t", maybeobj },
145 });149 });
146 std.debug.assert(result.term == .Exited and result.term.Exited == 0);150 std.debug.assert(result.term == .Exited and result.term.Exited == 0);
...@@ -151,13 +155,13 @@ pub fn isType(alloc: std.mem.Allocator, dir: std.fs.Dir, maybeobj: Id, typ: Tree...@@ -151,13 +155,13 @@ pub fn isType(alloc: std.mem.Allocator, dir: std.fs.Dir, maybeobj: Id, typ: Tree
151// TODO make this inspect .git manually155// TODO make this inspect .git manually
152// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects156// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects
153// https://git-scm.com/book/en/v2/Git-Internals-Packfiles157// https://git-scm.com/book/en/v2/Git-Internals-Packfiles
154pub fn getType(alloc: std.mem.Allocator, dir: std.fs.Dir, obj: Id) !Tree.Object.Id.Tag {158pub fn getType(alloc: std.mem.Allocator, dir: nfs.Dir, obj: Id) !Tree.Object.Id.Tag {
155 const t = tracer.trace(@src(), " {s}", .{obj});159 const t = tracer.trace(@src(), " {s}", .{obj});
156 defer t.end();160 defer t.end();
157161
158 const result = try std.process.Child.run(.{162 const result = try std.process.Child.run(.{
159 .allocator = alloc,163 .allocator = alloc,
160 .cwd_dir = dir,164 .cwd_dir = dir.to_std(),
161 .argv = &.{ "git", "cat-file", "-t", obj },165 .argv = &.{ "git", "cat-file", "-t", obj },
162 });166 });
163 std.debug.assert(result.term == .Exited and result.term.Exited == 0);167 std.debug.assert(result.term == .Exited and result.term.Exited == 0);
...@@ -169,13 +173,13 @@ pub fn getType(alloc: std.mem.Allocator, dir: std.fs.Dir, obj: Id) !Tree.Object....@@ -169,13 +173,13 @@ pub fn getType(alloc: std.mem.Allocator, dir: std.fs.Dir, obj: Id) !Tree.Object.
169// 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 paths173// 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
170// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects174// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects
171// https://git-scm.com/book/en/v2/Git-Internals-Packfiles175// https://git-scm.com/book/en/v2/Git-Internals-Packfiles
172pub fn revList(alloc: std.mem.Allocator, dir: std.fs.Dir, comptime count: u31, from: CommitId, sub_path: string) !string {176pub fn revList(alloc: std.mem.Allocator, dir: nfs.Dir, comptime count: u31, from: CommitId, sub_path: string) !string {
173 const t = tracer.trace(@src(), "({d}) {s} -- {s}", .{ count, from.id, sub_path });177 const t = tracer.trace(@src(), "({d}) {s} -- {s}", .{ count, from.id, sub_path });
174 defer t.end();178 defer t.end();
175179
176 const result = try std.process.Child.run(.{180 const result = try std.process.Child.run(.{
177 .allocator = alloc,181 .allocator = alloc,
178 .cwd_dir = dir,182 .cwd_dir = dir.to_std(),
179 .argv = &.{183 .argv = &.{
180 "git",184 "git",
181 "rev-list",185 "rev-list",
...@@ -412,14 +416,14 @@ pub const Tree = struct {...@@ -412,14 +416,14 @@ pub const Tree = struct {
412416
413// TODO make this inspect .git manually417// TODO make this inspect .git manually
414// TODO make this return a Reader when we implement it ourselves418// TODO make this return a Reader when we implement it ourselves
415pub fn getTreeDiff(alloc: std.mem.Allocator, dir: std.fs.Dir, commitid: CommitId, parentid: ?CommitId) !string {419pub fn getTreeDiff(alloc: std.mem.Allocator, dir: nfs.Dir, commitid: CommitId, parentid: ?CommitId) !string {
416 const t = tracer.trace(@src(), "", .{});420 const t = tracer.trace(@src(), "", .{});
417 defer t.end();421 defer t.end();
418422
419 if (parentid == null) {423 if (parentid == null) {
420 const result = try std.process.Child.run(.{424 const result = try std.process.Child.run(.{
421 .allocator = alloc,425 .allocator = alloc,
422 .cwd_dir = dir,426 .cwd_dir = dir.to_std(),
423 // 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is a hardcode for the empty tree in git sha1427 // 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is a hardcode for the empty tree in git sha1
424 // result of `printf | git hash-object -t tree --stdin`428 // result of `printf | git hash-object -t tree --stdin`
425 .argv = &.{ "git", "diff-tree", "-p", "--raw", "4b825dc642cb6eb9a060e54bf8d69288fbee4904", commitid.id },429 .argv = &.{ "git", "diff-tree", "-p", "--raw", "4b825dc642cb6eb9a060e54bf8d69288fbee4904", commitid.id },
...@@ -430,7 +434,7 @@ pub fn getTreeDiff(alloc: std.mem.Allocator, dir: std.fs.Dir, commitid: CommitId...@@ -430,7 +434,7 @@ pub fn getTreeDiff(alloc: std.mem.Allocator, dir: std.fs.Dir, commitid: CommitId
430 }434 }
431 const result = try std.process.Child.run(.{435 const result = try std.process.Child.run(.{
432 .allocator = alloc,436 .allocator = alloc,
433 .cwd_dir = dir,437 .cwd_dir = dir.to_std(),
434 .argv = &.{ "git", "diff-tree", "-p", "--raw", parentid.?.id, commitid.id },438 .argv = &.{ "git", "diff-tree", "-p", "--raw", parentid.?.id, commitid.id },
435 .max_output_bytes = 1024 * 1024 * 1024,439 .max_output_bytes = 1024 * 1024 * 1024,
436 });440 });
...@@ -681,13 +685,13 @@ pub const TreeDiff = struct {...@@ -681,13 +685,13 @@ pub const TreeDiff = struct {
681 };685 };
682};686};
683687
684pub fn getBranches(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const Ref {688pub fn getBranches(alloc: std.mem.Allocator, dir: nfs.Dir) ![]const Ref {
685 const t = tracer.trace(@src(), "", .{});689 const t = tracer.trace(@src(), "", .{});
686 defer t.end();690 defer t.end();
687691
688 const result = try std.process.Child.run(.{692 const result = try std.process.Child.run(.{
689 .allocator = alloc,693 .allocator = alloc,
690 .cwd_dir = dir,694 .cwd_dir = dir.to_std(),
691 .argv = &.{ "git", "show-ref", "--heads" },695 .argv = &.{ "git", "show-ref", "--heads" },
692 .max_output_bytes = 1024 * 1024 * 1024,696 .max_output_bytes = 1024 * 1024 * 1024,
693 });697 });
...@@ -707,7 +711,7 @@ pub fn getBranches(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const Ref {...@@ -707,7 +711,7 @@ pub fn getBranches(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const Ref {
707 return list.toOwnedSlice();711 return list.toOwnedSlice();
708}712}
709713
710pub fn getTags(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const Ref {714pub fn getTags(alloc: std.mem.Allocator, dir: nfs.Dir) ![]const Ref {
711 const t = tracer.trace(@src(), "", .{});715 const t = tracer.trace(@src(), "", .{});
712 defer t.end();716 defer t.end();
713717
...@@ -717,7 +721,7 @@ pub fn getTags(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const Ref {...@@ -717,7 +721,7 @@ pub fn getTags(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const Ref {
717 // 7dfd3948a9095f0253bfba60fed52895ffbf84bb refs/tags/15.3.2721 // 7dfd3948a9095f0253bfba60fed52895ffbf84bb refs/tags/15.3.2
718 const result = try std.process.Child.run(.{722 const result = try std.process.Child.run(.{
719 .allocator = alloc,723 .allocator = alloc,
720 .cwd_dir = dir,724 .cwd_dir = dir.to_std(),
721 .argv = &.{ "git", "show-ref", "--tags", "--dereference" },725 .argv = &.{ "git", "show-ref", "--tags", "--dereference" },
722 .max_output_bytes = 1024 * 1024 * 1024,726 .max_output_bytes = 1024 * 1024 * 1024,
723 });727 });
licenses.txt+11
...@@ -1,7 +1,18 @@...@@ -1,7 +1,18 @@
1MIT:1MIT:
2= https://spdx.org/licenses/MIT2= https://spdx.org/licenses/MIT
3- This3- This
4- git https://github.com/nektro/zig-errno
4- git https://github.com/nektro/zig-expect5- git https://github.com/nektro/zig-expect
5- git https://github.com/nektro/zig-extras6- git https://github.com/nektro/zig-extras
7- git https://github.com/nektro/zig-libc
8- git https://github.com/nektro/zig-sys-libc
6- git https://github.com/nektro/zig-time9- git https://github.com/nektro/zig-time
7- git https://github.com/nektro/zig-tracer10- git https://github.com/nektro/zig-tracer
11
12MPL-2.0:
13= https://spdx.org/licenses/MPL-2.0
14- git https://github.com/nektro/zig-nfs
15- git https://github.com/nektro/zig-nio
16
17Unspecified:
18- system_lib c
test.zig+12-11
...@@ -2,6 +2,7 @@ const std = @import("std");...@@ -2,6 +2,7 @@ const std = @import("std");
2const git = @import("git");2const git = @import("git");
3const extras = @import("extras");3const extras = @import("extras");
4const expect = @import("expect").expect;4const expect = @import("expect").expect;
5const nfs = @import("nfs");
56
6test {7test {
7 _ = &git.version;8 _ = &git.version;
...@@ -14,7 +15,7 @@ test {...@@ -14,7 +15,7 @@ test {
14 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);15 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
15 defer arena.deinit();16 defer arena.deinit();
16 const alloc = arena.allocator();17 const alloc = arena.allocator();
17 var git_dir = try std.fs.cwd().openDir(".git", .{});18 const git_dir = try nfs.cwd().openDir(".git", .{});
18 defer git_dir.close();19 defer git_dir.close();
19 const branch_refs = try git.getBranches(alloc, git_dir);20 const branch_refs = try git.getBranches(alloc, git_dir);
20 const branch_names = try extras.mapBy(alloc, branch_refs, .label);21 const branch_names = try extras.mapBy(alloc, branch_refs, .label);
...@@ -25,7 +26,7 @@ test {...@@ -25,7 +26,7 @@ test {
25 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);26 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
26 defer arena.deinit();27 defer arena.deinit();
27 const alloc = arena.allocator();28 const alloc = arena.allocator();
28 var git_dir = try std.fs.cwd().openDir(".git", .{});29 const git_dir = try nfs.cwd().openDir(".git", .{});
29 defer git_dir.close();30 defer git_dir.close();
30 try expect(try git.getObject(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e")).toEqualString(31 try expect(try git.getObject(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e")).toEqualString(
31 \\tree 5403fecad0fde9120535321f222a061abc2849d932 \\tree 5403fecad0fde9120535321f222a061abc2849d9
...@@ -42,7 +43,7 @@ test {...@@ -42,7 +43,7 @@ test {
42 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);43 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
43 defer arena.deinit();44 defer arena.deinit();
44 const alloc = arena.allocator();45 const alloc = arena.allocator();
45 var git_dir = try std.fs.cwd().openDir(".git", .{});46 const git_dir = try nfs.cwd().openDir(".git", .{});
46 defer git_dir.close();47 defer git_dir.close();
47 try expect(try git.getObjectSize(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e")).toEqual(229);48 try expect(try git.getObjectSize(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e")).toEqual(229);
48 try expect(try git.getObjectSize(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e")).toEqual(45 + 47 + 55 + 58 + 0 + 18 + 6);49 try expect(try git.getObjectSize(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e")).toEqual(45 + 47 + 55 + 58 + 0 + 18 + 6);
...@@ -52,7 +53,7 @@ test {...@@ -52,7 +53,7 @@ test {
52 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);53 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
53 defer arena.deinit();54 defer arena.deinit();
54 const alloc = arena.allocator();55 const alloc = arena.allocator();
55 var git_dir = try std.fs.cwd().openDir(".git", .{});56 const git_dir = try nfs.cwd().openDir(".git", .{});
56 defer git_dir.close();57 defer git_dir.close();
57 try expect(try git.isType(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e", .blob)).toEqual(false);58 try expect(try git.isType(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e", .blob)).toEqual(false);
58 try expect(try git.isType(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e", .tree)).toEqual(false);59 try expect(try git.isType(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e", .tree)).toEqual(false);
...@@ -64,7 +65,7 @@ test {...@@ -64,7 +65,7 @@ test {
64 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);65 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
65 defer arena.deinit();66 defer arena.deinit();
66 const alloc = arena.allocator();67 const alloc = arena.allocator();
67 var git_dir = try std.fs.cwd().openDir(".git", .{});68 const git_dir = try nfs.cwd().openDir(".git", .{});
68 defer git_dir.close();69 defer git_dir.close();
69 try expect(try git.getType(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e")).toEqual(.commit);70 try expect(try git.getType(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e")).toEqual(.commit);
70}71}
...@@ -73,7 +74,7 @@ test {...@@ -73,7 +74,7 @@ test {
73 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);74 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
74 defer arena.deinit();75 defer arena.deinit();
75 const alloc = arena.allocator();76 const alloc = arena.allocator();
76 var git_dir = try std.fs.cwd().openDir(".git", .{});77 const git_dir = try nfs.cwd().openDir(".git", .{});
77 defer git_dir.close();78 defer git_dir.close();
78 const c = try git.parseCommit(alloc, try git.getObject(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e"));79 const c = try git.parseCommit(alloc, try git.getObject(alloc, git_dir, "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e"));
79 try expect(c.tree.id).toEqualString("5403fecad0fde9120535321f222a061abc2849d9");80 try expect(c.tree.id).toEqualString("5403fecad0fde9120535321f222a061abc2849d9");
...@@ -95,7 +96,7 @@ test {...@@ -95,7 +96,7 @@ test {
95 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);96 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
96 defer arena.deinit();97 defer arena.deinit();
97 const alloc = arena.allocator();98 const alloc = arena.allocator();
98 var git_dir = try std.fs.cwd().openDir(".git", .{});99 const git_dir = try nfs.cwd().openDir(".git", .{});
99 defer git_dir.close();100 defer git_dir.close();
100 try expect(try git.getObject(alloc, git_dir, "5403fecad0fde9120535321f222a061abc2849d9")).toEqualString(101 try expect(try git.getObject(alloc, git_dir, "5403fecad0fde9120535321f222a061abc2849d9")).toEqualString(
101 // zig fmt: off102 // zig fmt: off
...@@ -113,7 +114,7 @@ test {...@@ -113,7 +114,7 @@ test {
113 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);114 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
114 defer arena.deinit();115 defer arena.deinit();
115 const alloc = arena.allocator();116 const alloc = arena.allocator();
116 var git_dir = try std.fs.cwd().openDir(".git", .{});117 const git_dir = try nfs.cwd().openDir(".git", .{});
117 defer git_dir.close();118 defer git_dir.close();
118 const t = try git.parseTree(alloc, try git.getObject(alloc, git_dir, "5403fecad0fde9120535321f222a061abc2849d9"));119 const t = try git.parseTree(alloc, try git.getObject(alloc, git_dir, "5403fecad0fde9120535321f222a061abc2849d9"));
119 // TODO: test fields when we upgrade to 0.14 and have decl literals120 // TODO: test fields when we upgrade to 0.14 and have decl literals
...@@ -137,7 +138,7 @@ test {...@@ -137,7 +138,7 @@ test {
137 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);138 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
138 defer arena.deinit();139 defer arena.deinit();
139 const alloc = arena.allocator();140 const alloc = arena.allocator();
140 var git_dir = try std.fs.cwd().openDir(".git", .{});141 const git_dir = try nfs.cwd().openDir(".git", .{});
141 defer git_dir.close();142 defer git_dir.close();
142 try expect(try git.getTreeDiff(alloc, git_dir, .{ .id = "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e" }, .{ .id = "c39f57f6bb01664a7146ddbfc3debe76ec135f44" })).toEqualString(143 try expect(try git.getTreeDiff(alloc, git_dir, .{ .id = "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e" }, .{ .id = "c39f57f6bb01664a7146ddbfc3debe76ec135f44" })).toEqualString(
143 // zig fmt: off144 // zig fmt: off
...@@ -171,7 +172,7 @@ test {...@@ -171,7 +172,7 @@ test {
171 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);172 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
172 defer arena.deinit();173 defer arena.deinit();
173 const alloc = arena.allocator();174 const alloc = arena.allocator();
174 var git_dir = try std.fs.cwd().openDir(".git", .{});175 const git_dir = try nfs.cwd().openDir(".git", .{});
175 defer git_dir.close();176 defer git_dir.close();
176 const t = try git.parseTreeDiffMeta(try git.getTreeDiff(alloc, git_dir, .{ .id = "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e" }, .{ .id = "c39f57f6bb01664a7146ddbfc3debe76ec135f44" }));177 const t = try git.parseTreeDiffMeta(try git.getTreeDiff(alloc, git_dir, .{ .id = "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e" }, .{ .id = "c39f57f6bb01664a7146ddbfc3debe76ec135f44" }));
177 try expect(t.files_changed).toEqual(1);178 try expect(t.files_changed).toEqual(1);
...@@ -183,7 +184,7 @@ test {...@@ -183,7 +184,7 @@ test {
183 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);184 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
184 defer arena.deinit();185 defer arena.deinit();
185 const alloc = arena.allocator();186 const alloc = arena.allocator();
186 var git_dir = try std.fs.cwd().openDir(".git", .{});187 const git_dir = try nfs.cwd().openDir(".git", .{});
187 defer git_dir.close();188 defer git_dir.close();
188 const t = try git.parseTreeDiff(alloc, try git.getTreeDiff(alloc, git_dir, .{ .id = "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e" }, .{ .id = "c39f57f6bb01664a7146ddbfc3debe76ec135f44" }));189 const t = try git.parseTreeDiff(alloc, try git.getTreeDiff(alloc, git_dir, .{ .id = "a542da41f1f0c59fdd0e1527cf5ff9de3f6a0c8e" }, .{ .id = "c39f57f6bb01664a7146ddbfc3debe76ec135f44" }));
189 _ = t; // TODO: test fields when we upgrade to 0.14 and have decl literals190 _ = t; // TODO: test fields when we upgrade to 0.14 and have decl literals
zig.mod+2
...@@ -7,6 +7,8 @@ dependencies:...@@ -7,6 +7,8 @@ dependencies:
7 - src: git https://github.com/nektro/zig-time7 - src: git https://github.com/nektro/zig-time
8 - src: git https://github.com/nektro/zig-extras8 - src: git https://github.com/nektro/zig-extras
9 - src: git https://github.com/nektro/zig-tracer9 - src: git https://github.com/nektro/zig-tracer
10 - src: git https://github.com/nektro/zig-nfs
10root_dependencies:11root_dependencies:
11 - src: git https://github.com/nektro/zig-extras12 - src: git https://github.com/nektro/zig-extras
12 - src: git https://github.com/nektro/zig-expect13 - src: git https://github.com/nektro/zig-expect
14 - src: git https://github.com/nektro/zig-nfs