about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-11-21T18·12+0100
committerEelco Dolstra <edolstra@gmail.com>2017-11-21T18·34+0100
commitd7da6c9ea9459a2fa17c3e409120c5cdfde6afdc (patch)
tree26676469ead12a6581c2301d395283129dd64f0d /src
parent6cdaa858d03b9c24f54f8157026cebaa02d9ac8a (diff)
fetchGit/fetchMercurial: Fix directory inclusion check
E.g. the existence of .gitignore would cause .git to be included.
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/primops/fetchGit.cc5
-rw-r--r--src/libexpr/primops/fetchMercurial.cc5
2 files changed, 6 insertions, 4 deletions
diff --git a/src/libexpr/primops/fetchGit.cc b/src/libexpr/primops/fetchGit.cc
index bca68ed72091..fd3e84c292c3 100644
--- a/src/libexpr/primops/fetchGit.cc
+++ b/src/libexpr/primops/fetchGit.cc
@@ -56,8 +56,9 @@ GitInfo exportGit(ref<Store> 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 7def7103bf3d..a317476c5829 100644
--- a/src/libexpr/primops/fetchMercurial.cc
+++ b/src/libexpr/primops/fetchMercurial.cc
@@ -52,8 +52,9 @@ HgInfo exportMercurial(ref<Store> 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);