| ... | @@ -364,6 +364,21 @@ pub const Tree = struct { | ... | @@ -364,6 +364,21 @@ pub const Tree = struct { |
| 364 | return o; | 364 | return o; |
| 365 | } | 365 | } |
| 366 | | 366 | |
| | 367 | pub fn find(self: Tree, name: string) ?Object { |
| | 368 | for (self.children) |item| { |
| | 369 | if (std.ascii.eqlIgnoreCase(item.name, name)) { |
| | 370 | return item; |
| | 371 | } |
| | 372 | } |
| | 373 | return null; |
| | 374 | } |
| | 375 | |
| | 376 | pub fn findBlob(self: Tree, name: string) ?Object { |
| | 377 | const o = self.find(name) orelse return null; |
| | 378 | if (o.id != .blob) return null; |
| | 379 | return o; |
| | 380 | } |
| | 381 | |
| 367 | pub const Object = struct { | 382 | pub const Object = struct { |
| 368 | mode: Mode, | 383 | mode: Mode, |
| 369 | id: @This().Id, | 384 | id: @This().Id, |