1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 03:56:01 +01:00
This commit is contained in:
Jörg Thalheim 2025-11-06 22:51:16 +01:00 committed by GitHub
commit aaf513bbd3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View file

@ -184,8 +184,10 @@ std::pair<FlakeRef, std::string> parsePathFlakeRefWithFragment(
parsedURL.query.insert_or_assign("dir", subdir); parsedURL.query.insert_or_assign("dir", subdir);
} }
if (pathExists(flakeRoot + "/.git/shallow")) if (!parsedURL.query.count("shallow")) {
parsedURL.query.insert_or_assign("shallow", "1"); // We assume shallow by default, so we don't need to compute the revCount, which is an expensive operation.
parsedURL.query.insert_or_assign("shallow", "1");
}
return fromParsedURL(fetchSettings, std::move(parsedURL), isFlake); return fromParsedURL(fetchSettings, std::move(parsedURL), isFlake);
} }

View file

@ -65,3 +65,8 @@ fi
# Verify that we can shallow fetch the worktree # Verify that we can shallow fetch the worktree
git -C "$TEST_ROOT/shallow-worktree" rev-list --count HEAD >/dev/null git -C "$TEST_ROOT/shallow-worktree" rev-list --count HEAD >/dev/null
nix eval --impure --raw --expr "(builtins.fetchGit { url = \"file://$TEST_ROOT/shallow-worktree\"; shallow = true; }).rev" nix eval --impure --raw --expr "(builtins.fetchGit { url = \"file://$TEST_ROOT/shallow-worktree\"; shallow = true; }).rev"
# Normal flake operation work because they use shallow by default
pushd "$TEST_ROOT/shallow-worktree"
nix flake metadata
popd