From 1564c8f9d90017ef446815d8aadbf28aaf5a5e81 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 1 Apr 2025 18:37:21 +0200 Subject: [PATCH] Fix missing file error messages from 'import' --- src/libutil/mounted-source-accessor.cc | 6 ++++++ tests/functional/flakes/source-paths.sh | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/libutil/mounted-source-accessor.cc b/src/libutil/mounted-source-accessor.cc index e1442d686..c21a71047 100644 --- a/src/libutil/mounted-source-accessor.cc +++ b/src/libutil/mounted-source-accessor.cc @@ -23,6 +23,12 @@ struct MountedSourceAccessorImpl : MountedSourceAccessor return accessor->readFile(subpath); } + Stat lstat(const CanonPath & path) override + { + auto [accessor, subpath] = resolve(path); + return accessor->lstat(subpath); + } + std::optional maybeLstat(const CanonPath & path) override { auto [accessor, subpath] = resolve(path); diff --git a/tests/functional/flakes/source-paths.sh b/tests/functional/flakes/source-paths.sh index 10b834bc8..e82d27c81 100644 --- a/tests/functional/flakes/source-paths.sh +++ b/tests/functional/flakes/source-paths.sh @@ -14,6 +14,8 @@ cat > "$repo/flake.nix" < "$repo/foo" +echo 123 > "$repo/foo" expectStderr 1 nix eval "$repo#z" | grepQuiet "error: File 'foo' in the repository \"$repo\" is not tracked by Git." +expectStderr 1 nix eval "$repo#a" | grepQuiet "error: File 'foo' in the repository \"$repo\" is not tracked by Git." git -C "$repo" add "$repo/foo" -[[ $(nix eval --raw "$repo#z") = foo ]] +[[ $(nix eval --raw "$repo#z") = 123 ]] + +expectStderr 1 nix eval "$repo#b" | grepQuiet "error: path '/dir' does not exist in Git repository \"$repo\"" + +mkdir -p $repo/dir +echo 456 > $repo/dir/default.nix + +expectStderr 1 nix eval "$repo#b" | grepQuiet "error: File 'dir' in the repository \"$repo\" is not tracked by Git." + +git -C "$repo" add "$repo/dir/default.nix" + +[[ $(nix eval "$repo#b") = 456 ]]