From d7da6c9ea9459a2fa17c3e409120c5cdfde6afdc Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 21 Nov 2017 19:12:47 +0100 Subject: fetchGit/fetchMercurial: Fix directory inclusion check E.g. the existence of .gitignore would cause .git to be included. --- src/libexpr/primops/fetchGit.cc | 5 +++-- src/libexpr/primops/fetchMercurial.cc | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/libexpr') diff --git a/src/libexpr/primops/fetchGit.cc b/src/libexpr/primops/fetchGit.cc index bca68ed72..fd3e84c29 100644 --- a/src/libexpr/primops/fetchGit.cc +++ b/src/libexpr/primops/fetchGit.cc @@ -56,8 +56,9 @@ GitInfo exportGit(ref store, const std::string & uri, auto st = lstat(p); if (S_ISDIR(st.st_mode)) { - auto i = files.lower_bound(file); - return i != files.end() && hasPrefix(*i, file); + auto prefix = file + "/"; + auto i = files.lower_bound(prefix); + return i != files.end() && hasPrefix(*i, prefix); } return files.count(file); diff --git a/src/libexpr/primops/fetchMercurial.cc b/src/libexpr/primops/fetchMercurial.cc index 7def7103b..a317476c5 100644 --- a/src/libexpr/primops/fetchMercurial.cc +++ b/src/libexpr/primops/fetchMercurial.cc @@ -52,8 +52,9 @@ HgInfo exportMercurial(ref store, const std::string & uri, auto st = lstat(p); if (S_ISDIR(st.st_mode)) { - auto i = files.lower_bound(file); - return i != files.end() && hasPrefix(*i, file); + auto prefix = file + "/"; + auto i = files.lower_bound(prefix); + return i != files.end() && hasPrefix(*i, prefix); } return files.count(file); -- cgit v1.2.3