diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-03-17 21:34:38 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-03-17 22:35:29 +0100 |
commit | d1165d8791f559352ff6aa7348e1293b2873db1c (patch) | |
tree | 50137d50b7a7deda345c7fa1a13a4ba949783eb5 /tests | |
parent | 2a4e4f6a6e021481f0e92b7d3006345e68e77684 (diff) |
Require shallow clones to be requested explicitly
If you do a fetchTree on a Git repository, whether the result contains
a revCount attribute should not depend on whether that repository
happens to be a shallow clone or not. That would complicate caching a
lot and would be semantically messy. So applying fetchTree/fetchGit to
a shallow repository is now an error unless you pass the attribute
'shallow = true'. If 'shallow = true', we don't return revCount, even
if the repository is not actually shallow.
Note that Nix itself is not doing shallow clones at the moment. But it
could do so as an optimisation if the user specifies 'shallow = true'.
Issue #2988.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fetchGit.sh | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/fetchGit.sh b/tests/fetchGit.sh index 6e5a4750e..bca581438 100644 --- a/tests/fetchGit.sh +++ b/tests/fetchGit.sh @@ -148,8 +148,12 @@ NIX=$(command -v nix) path5=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = $repo; ref = \"dev\"; }).outPath") [[ $path3 = $path5 ]] -# Check that shallow clones work and don't return a revcount. +# Fetching a shallow repo shouldn't work by default, because we can't +# return a revCount. git clone --depth 1 file://$repo $TEST_ROOT/shallow -path6=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = $TEST_ROOT/shallow; ref = \"dev\"; }).outPath") +(! nix eval --impure --raw --expr "(builtins.fetchGit { url = $TEST_ROOT/shallow; ref = \"dev\"; }).outPath") + +# But you can request a shallow clone, which won't return a revCount. +path6=$(nix eval --impure --raw --expr "(builtins.fetchTree { type = \"git\"; url = \"file://$TEST_ROOT/shallow\"; ref = \"dev\"; shallow = true; }).outPath") [[ $path3 = $path6 ]] -[[ $(nix eval --impure --expr "(builtins.fetchTree { type = \"git\"; url = \"file://$TEST_ROOT/shallow\"; ref = \"dev\"; }).revCount or 123") == 123 ]] +[[ $(nix eval --impure --expr "(builtins.fetchTree { type = \"git\"; url = \"file://$TEST_ROOT/shallow\"; ref = \"dev\"; shallow = true; }).revCount or 123") == 123 ]] |