authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-10 16:43:48 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-10 16:43:48 -07:00
log3d408725231b4c6b45ccc9ba5a050d4a5ab1a3b7
tree939bf692ed3f2d5558e1ae26f3f5728d239b63c5
parent5b41631eadbbb03bbf81e53fe4c64cf233db9180
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

add Tree.Object.Mode.intbytes()

reconstructs the 6 byte string used in cat-file etc

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

git.zig+15
......@@ -1416,6 +1416,21 @@ pub const Tree = struct {
14161416 if (self.perm_other != other.perm_other) return false;
14171417 return true;
14181418 }
1419
1420 pub fn intbytes(self: Mode) [6]u8 {
1421 var b: [6]u8 = @splat('-');
1422 @memcpy(b[0..3], switch (self.type) {
1423 .file => "100",
1424 .directory => "040",
1425 .submodule => "160",
1426 .symlink => "120",
1427 .none => "000",
1428 });
1429 b[3] = @as(u8, @as(u3, @bitCast(self.perm_user))) + '0';
1430 b[4] = @as(u8, @as(u3, @bitCast(self.perm_group))) + '0';
1431 b[5] = @as(u8, @as(u3, @bitCast(self.perm_other))) + '0';
1432 return b;
1433 }
14191434 };
14201435
14211436 pub const Type = enum(u8) {