fetchGit/fetchMercurial: Fix directory inclusion check
E.g. the existence of .gitignore would cause .git to be included.
This commit is contained in:
parent
6cdaa858d0
commit
d7da6c9ea9
4 changed files with 12 additions and 6 deletions
|
@ -56,8 +56,9 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
|
||||||
auto st = lstat(p);
|
auto st = lstat(p);
|
||||||
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
auto i = files.lower_bound(file);
|
auto prefix = file + "/";
|
||||||
return i != files.end() && hasPrefix(*i, file);
|
auto i = files.lower_bound(prefix);
|
||||||
|
return i != files.end() && hasPrefix(*i, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
return files.count(file);
|
return files.count(file);
|
||||||
|
|
|
@ -52,8 +52,9 @@ HgInfo exportMercurial(ref<Store> store, const std::string & uri,
|
||||||
auto st = lstat(p);
|
auto st = lstat(p);
|
||||||
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
auto i = files.lower_bound(file);
|
auto prefix = file + "/";
|
||||||
return i != files.end() && hasPrefix(*i, file);
|
auto i = files.lower_bound(prefix);
|
||||||
|
return i != files.end() && hasPrefix(*i, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
return files.count(file);
|
return files.count(file);
|
||||||
|
|
|
@ -16,7 +16,8 @@ git -C $repo config user.email "foobar@example.com"
|
||||||
git -C $repo config user.name "Foobar"
|
git -C $repo config user.name "Foobar"
|
||||||
|
|
||||||
echo utrecht > $repo/hello
|
echo utrecht > $repo/hello
|
||||||
git -C $repo add hello
|
touch $repo/.gitignore
|
||||||
|
git -C $repo add hello .gitignore
|
||||||
git -C $repo commit -m 'Bla1'
|
git -C $repo commit -m 'Bla1'
|
||||||
rev1=$(git -C $repo rev-parse HEAD)
|
rev1=$(git -C $repo rev-parse HEAD)
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ path2=$(nix eval --raw "(builtins.fetchGit $repo).outPath")
|
||||||
[ ! -e $path2/hello ]
|
[ ! -e $path2/hello ]
|
||||||
[ ! -e $path2/bar ]
|
[ ! -e $path2/bar ]
|
||||||
[ ! -e $path2/dir2/bar ]
|
[ ! -e $path2/dir2/bar ]
|
||||||
|
[ ! -e $path2/.git ]
|
||||||
[[ $(cat $path2/dir1/foo) = foo ]]
|
[[ $(cat $path2/dir1/foo) = foo ]]
|
||||||
|
|
||||||
[[ $(nix eval --raw "(builtins.fetchGit $repo).rev") = 0000000000000000000000000000000000000000 ]]
|
[[ $(nix eval --raw "(builtins.fetchGit $repo).rev") = 0000000000000000000000000000000000000000 ]]
|
||||||
|
|
|
@ -16,7 +16,8 @@ echo '[ui]' >> $repo/.hg/hgrc
|
||||||
echo 'username = Foobar <foobar@example.org>' >> $repo/.hg/hgrc
|
echo 'username = Foobar <foobar@example.org>' >> $repo/.hg/hgrc
|
||||||
|
|
||||||
echo utrecht > $repo/hello
|
echo utrecht > $repo/hello
|
||||||
hg add --cwd $repo hello
|
touch $repo/.hgignore
|
||||||
|
hg add --cwd $repo hello .hgignore
|
||||||
hg commit --cwd $repo -m 'Bla1'
|
hg commit --cwd $repo -m 'Bla1'
|
||||||
rev1=$(hg log --cwd $repo -r tip --template '{node}')
|
rev1=$(hg log --cwd $repo -r tip --template '{node}')
|
||||||
|
|
||||||
|
@ -69,6 +70,7 @@ path2=$(nix eval --raw "(builtins.fetchMercurial $repo).outPath")
|
||||||
[ ! -e $path2/hello ]
|
[ ! -e $path2/hello ]
|
||||||
[ ! -e $path2/bar ]
|
[ ! -e $path2/bar ]
|
||||||
[ ! -e $path2/dir2/bar ]
|
[ ! -e $path2/dir2/bar ]
|
||||||
|
[ ! -e $path2/.hg ]
|
||||||
[[ $(cat $path2/dir1/foo) = foo ]]
|
[[ $(cat $path2/dir1/foo) = foo ]]
|
||||||
|
|
||||||
[[ $(nix eval --raw "(builtins.fetchMercurial $repo).rev") = 0000000000000000000000000000000000000000 ]]
|
[[ $(nix eval --raw "(builtins.fetchMercurial $repo).rev") = 0000000000000000000000000000000000000000 ]]
|
||||||
|
|
Loading…
Reference in a new issue