diff --git a/git.zig b/git.zig index 54986adf0da12a41592583d782abbfdabc657f80..5d0f186a32607830a6cd7a59430a57c2dcce8432 100644 --- a/git.zig +++ b/git.zig @@ -1416,6 +1416,21 @@ pub const Tree = struct { if (self.perm_other != other.perm_other) return false; return true; } + + pub fn intbytes(self: Mode) [6]u8 { + var b: [6]u8 = @splat('-'); + @memcpy(b[0..3], switch (self.type) { + .file => "100", + .directory => "040", + .submodule => "160", + .symlink => "120", + .none => "000", + }); + b[3] = @as(u8, @as(u3, @bitCast(self.perm_user))) + '0'; + b[4] = @as(u8, @as(u3, @bitCast(self.perm_group))) + '0'; + b[5] = @as(u8, @as(u3, @bitCast(self.perm_other))) + '0'; + return b; + } }; pub const Type = enum(u8) {