╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ find.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
311 // build a file's key: its lowercased basename, a separator, then its full path. 312 fn fileKey(allocator: std.mem.Allocator, key: *std.ArrayList(u8), path: []const u8) !void { 313 const slash = std.mem.lastIndexOfScalar(u8, path, '/'); 314 const base = if (slash) |i| path[i + 1 ..] else path; 315 key.clearRetainingCapacity(); 316 try key.ensureTotalCapacity(allocator, base.len + 1 + path.len); 317 for (base) |char| key.appendAssumeCapacity(std.ascii.toLower(char)); 318 key.appendAssumeCapacity(0); 319 key.appendSliceAssumeCapacity(path); 320 } 321 322 // the blob oid a tree entry is indexed under, or null for a submodule: its oid 323 // is a commit in another repo, not a file here. 324 fn indexedOid(comptime hash_kind: hash.HashKind, tree_entry: *const tr.TreeEntry(hash_kind)) ?[]const u8 { 325 if (tree_entry.mode.content.object_type == .gitlink) return null; 326 return &tree_entry.oid; 327 } 328 329 fn parseOid(comptime hash_kind: hash.HashKind, value: []const u8) ![hash.byteLen(hash_kind)]u8 { 330 const len = comptime hash.byteLen(hash_kind); 331 if (value.len != len) return error.InvalidFileIndex; 332 return value[0..len].*; 333 } 334