refactor: do not log git rev-parse errors

This commit is contained in:
CJ van den Berg 2025-12-17 22:10:20 +01:00
parent 4d1eaa767b
commit 18983c00b4
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -264,13 +264,13 @@ pub fn rev_parse(context_: usize, rev: []const u8, file_path: []const u8) Error!
try arg.writer.print("{s}", .{rev}) try arg.writer.print("{s}", .{rev})
else else
try arg.writer.print("{s}:{s}", .{ rev, file_path }); try arg.writer.print("{s}:{s}", .{ rev, file_path });
try git_err(context_, .{ "rev-parse", arg.written() }, struct { try git(context_, .{ "rev-parse", arg.written() }, struct {
fn result(context: usize, parent: tp.pid_ref, output: []const u8) void { fn result(context: usize, parent: tp.pid_ref, output: []const u8) void {
var it = std.mem.splitScalar(u8, output, '\n'); var it = std.mem.splitScalar(u8, output, '\n');
while (it.next()) |value| if (value.len > 0) while (it.next()) |value| if (value.len > 0)
parent.send(.{ module_name, context, tag, value }) catch {}; parent.send(.{ module_name, context, tag, value }) catch {};
} }
}.result, log_err, exit_null(tag)); }.result, exit_null(tag));
} }
pub fn cat_file(context_: usize, object: []const u8) Error!void { pub fn cat_file(context_: usize, object: []const u8) Error!void {
@ -310,8 +310,10 @@ fn git_err(
) Error!void { ) Error!void {
const cbor = @import("cbor"); const cbor = @import("cbor");
const git_binary = get_git() orelse return error.GitNotFound; const git_binary = get_git() orelse return error.GitNotFound;
var buf: std.Io.Writer.Allocating = .init(allocator); var buf: std.Io.Writer.Allocating = .init(allocator);
defer buf.deinit(); defer buf.deinit();
const writer = &buf.writer; const writer = &buf.writer;
switch (@typeInfo(@TypeOf(cmd))) { switch (@typeInfo(@TypeOf(cmd))) {
.@"struct" => |info| if (info.is_tuple) { .@"struct" => |info| if (info.is_tuple) {