From 35ae2d7ac795395291d0cd95646ac138a48c8762 Mon Sep 17 00:00:00 2001 From: Lue Date: Tue, 31 Jan 2023 12:56:25 +0000 Subject: [PATCH] gpu-dawn: fix git error when fetching Dawn source Previously, when the gpu-dawn SDK attempted to fetch Dawn sources, Git failed with this error: ``` fatal: ambiguous argument 'generated-*': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]' ``` This caused the whole build to fail as the gpu-dawn SDK is unable to check out the intended revision of the generated Dawn sources. This commit fixes the issue by using `git checkout --force` instead of `git reset --hard`, which works because you can checkout to a detached commit hash (used by DirectXShaderCompiler, for example) as well as an actual branch. The alternative would be to do `git reset --hard origin/generated-*` rather than `git reset --hard generated-*`, but that would require modifying Wrench unlike this solution. --- libs/gpu-dawn/sdk.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/gpu-dawn/sdk.zig b/libs/gpu-dawn/sdk.zig index 88816ad4..c1a735c5 100644 --- a/libs/gpu-dawn/sdk.zig +++ b/libs/gpu-dawn/sdk.zig @@ -145,7 +145,7 @@ pub fn Sdk(comptime deps: anytype) type { if (!std.mem.eql(u8, current_revision, revision)) { // Reset to the desired revision exec(allocator, &[_][]const u8{ "git", "fetch" }, dir) catch |err| std.debug.print("warning: failed to 'git fetch' in {s}: {s}\n", .{ dir, @errorName(err) }); - try exec(allocator, &[_][]const u8{ "git", "reset", "--quiet", "--hard", revision }, dir); + try exec(allocator, &[_][]const u8{ "git", "checkout", "--quiet", "--force", revision }, dir); try exec(allocator, &[_][]const u8{ "git", "submodule", "update", "--init", "--recursive" }, dir); } return; @@ -154,7 +154,7 @@ pub fn Sdk(comptime deps: anytype) type { std.log.info("cloning required dependency..\ngit clone {s} {s}..\n", .{ clone_url, dir }); try exec(allocator, &[_][]const u8{ "git", "clone", "-c", "core.longpaths=true", clone_url, dir }, sdkPath("/")); - try exec(allocator, &[_][]const u8{ "git", "reset", "--quiet", "--hard", revision }, dir); + try exec(allocator, &[_][]const u8{ "git", "checkout", "--quiet", "--force", revision }, dir); try exec(allocator, &[_][]const u8{ "git", "submodule", "update", "--init", "--recursive" }, dir); return; },