diff --git a/README.md b/README.md index 77a191bca6a1624db37b587de7869b31284d24f6..d993a7d302a26466b7d42eb9aa5c0a031b78d219 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![loc](https://sloc.xyz/github/nektro/zig-git) [![license](https://img.shields.io/github/license/nektro/zig-git.svg)](https://github.com/nektro/zig-git/blob/master/LICENSE) [![nektro @ github sponsors](https://img.shields.io/badge/sponsors-nektro-purple?logo=github)](https://github.com/sponsors/nektro) -[![Zig](https://img.shields.io/badge/Zig-0.15-f7a41d)](https://ziglang.org/) +[![Zig](https://img.shields.io/badge/Zig-0.16-f7a41d)](https://ziglang.org/) [![Zigmod](https://img.shields.io/badge/Zigmod-latest-f7a41d)](https://github.com/nektro/zigmod) Inspect into the depths of your .git folder purely from Zig. diff --git a/git.zig b/git.zig index 41085628ce4222870a99ac0c1e727d4fb097c5ff..e18dc55e251254ce21953a9cee94db9b8132e51f 100644 --- a/git.zig +++ b/git.zig @@ -74,7 +74,7 @@ pub fn version(alloc: std.mem.Allocator) !string { defer alloc.free(result.stdout); defer alloc.free(result.stderr); std.debug.assert(result.term == .exited and result.term.exited == 0); - return try alloc.dupe(u8, extras.trimPrefixEnsure(std.mem.trimRight(u8, result.stdout, "\n"), "git version ").?); + return try alloc.dupe(u8, extras.trimPrefixEnsure(std.mem.trimEnd(u8, result.stdout, "\n"), "git version ").?); } /// Returns the result of running `git rev-parse HEAD` @@ -84,7 +84,7 @@ pub fn getHEAD(alloc: std.mem.Allocator, dir: nfs.Dir) !?CommitId { const t = tracer.trace(@src(), "", .{}); defer t.end(); - const h = std.mem.trimRight(u8, try dir.readFileAlloc(alloc, "HEAD", 1024), "\n"); + const h = std.mem.trimEnd(u8, try dir.readFileAlloc(alloc, "HEAD", 1024), "\n"); if (std.mem.startsWith(u8, h, "ref:")) { blk: { @@ -95,7 +95,7 @@ pub fn getHEAD(alloc: std.mem.Allocator, dir: nfs.Dir) !?CommitId { error.ENOENT => break :blk, else => |e| return e, }; - return ensureObjId(CommitId, std.mem.trimRight(u8, reffile, "\n")); + return ensureObjId(CommitId, std.mem.trimEnd(u8, reffile, "\n")); } blk: { const pckedrfs = dir.readFileAlloc(alloc, "packed-refs", 1024 * 1024 * 1024) catch |err| switch (err) { @@ -143,7 +143,7 @@ pub fn revList(alloc: std.mem.Allocator, dir: nfs.Dir, comptime count: u31, from sub_path, }); std.debug.assert(result.term == .exited and result.term.exited == 0); - return std.mem.trimRight(u8, result.stdout, "\n"); + return std.mem.trimEnd(u8, result.stdout, "\n"); } // TODO make this inspect .git/objects manually @@ -156,7 +156,7 @@ pub fn revListAll(alloc: std.mem.Allocator, dir: nfs.Dir, from: CommitId, sub_pa const result = try root.child_process.run(alloc, dir, .ignore, .pipe, .pipe, 1024 * 50, &.{ "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"); + return std.mem.trimEnd(u8, result.stdout, "\n"); } pub fn parseCommit(alloc: std.mem.Allocator, commitfile: string) !Commit { @@ -1583,26 +1583,16 @@ fn MultiArrayList(T: type) type { const info = @typeInfo(T).@"struct"; pub const Items = blk: { - var fields: [info.fields.len]std.builtin.Type.StructField = undefined; + var names: [info.fields.len][]const u8 = undefined; + var types: [info.fields.len]type = undefined; + var attrs: [info.fields.len]std.builtin.Type.StructField.Attributes = undefined; for (info.fields, 0..) |f, i| { const empty_slice: []f.type = &[_]f.type{}; - fields[i] = .{ - .name = f.name, - .type = []f.type, - .default_value_ptr = @ptrCast(&empty_slice), - .is_comptime = false, - .alignment = @alignOf(f.type), - }; + names[i] = f.name; + types[i] = f.type; + attrs[i] = .{ .default_value_ptr = @ptrCast(&empty_slice) }; } - const _fields = fields; - break :blk @Type(.{ - .@"struct" = .{ - .layout = .auto, - .fields = &_fields, - .decls = &.{}, - .is_tuple = false, - }, - }); + break :blk @Struct(.auto, null, &names, &types, &attrs); }; pub fn deinit(self: *const Self, gpa: std.mem.Allocator) void {