authorgravatar for techatrix@mailbox.orgTechatrix <techatrix@mailbox.org> 2026-06-23 17:48:27+02:00
committergravatar for techatrix@mailbox.orgTechatrix <techatrix@mailbox.org> 2026-07-03 19:33:58+02:00
log59451cce931230af873a6f789d9178cea70d73ea
tree6eee8d9d1e3618a96be30e73def3451ef8c49ec6
parentca8f037b34d642bfa5aff1047d36032efebe5284
signaturebadge-check Signed by SSH key SHA256:HYC3SjXQcAt6uwv9pu/6OoVQ2rUH8rb5zKiUHSe9uxk

std.Build.Cache: skip over prefixes that are the cwd

Any of the added cache prefixes may be the cwd itself. Skip them like the null prefix.

1 files changed, 3 insertions(+), 5 deletions(-)

lib/std/Build/Cache.zig+3-5
......@@ -90,10 +90,8 @@ fn findPrefix(cache: *const Cache, file_path: []const u8) !PrefixedPath {
9090fn findPrefixResolved(cache: *const Cache, resolved_path: []u8) !PrefixedPath {
9191 const gpa = cache.gpa;
9292 const cwd = cache.cwd;
93 const prefixes_slice = cache.prefixes();
94 var i: u8 = 1; // Start at 1 to skip over checking the null prefix.
95 while (i < prefixes_slice.len) : (i += 1) {
96 const p = prefixes_slice[i].path.?;
93 for (cache.prefixes(), 0..) |prefix, i| {
94 const p = prefix.path orelse continue;
9795 const sub_path = getPrefixSubpath(gpa, cwd, p, resolved_path) catch |err| switch (err) {
9896 error.NotASubPath => continue,
9997 else => |e| return e,
......@@ -101,7 +99,7 @@ fn findPrefixResolved(cache: *const Cache, resolved_path: []u8) !PrefixedPath {
10199 // Free the resolved path since we're not going to return it
102100 gpa.free(resolved_path);
103101 return .{
104 .prefix = i,
102 .prefix = @intCast(i),
105103 .sub_path = sub_path,
106104 };
107105 }