From ee6ac38848277d80c62fa5c2734ada1b5edc8680 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 3 Nov 2017 13:48:02 +0100 Subject: fetchGit/fetchMercurial: Filter out directories with untracked files --- src/libexpr/primops/fetchMercurial.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/libexpr/primops/fetchMercurial.cc') diff --git a/src/libexpr/primops/fetchMercurial.cc b/src/libexpr/primops/fetchMercurial.cc index 2a423f61bb89..7def7103bf3d 100644 --- a/src/libexpr/primops/fetchMercurial.cc +++ b/src/libexpr/primops/fetchMercurial.cc @@ -47,11 +47,15 @@ HgInfo exportMercurial(ref store, const std::string & uri, PathFilter filter = [&](const Path & p) -> bool { assert(hasPrefix(p, uri)); - auto st = lstat(p); std::string file(p, uri.size() + 1); - if (file == ".hg") return false; - // FIXME: filter out directories with no tracked files. - if (S_ISDIR(st.st_mode)) return true; + + auto st = lstat(p); + + if (S_ISDIR(st.st_mode)) { + auto i = files.lower_bound(file); + return i != files.end() && hasPrefix(*i, file); + } + return files.count(file); }; -- cgit 1.4.1