summaryrefslogtreecommitdiff
path: root/lib/fileset/tests.sh
diff options
context:
space:
mode:
authoribbem <ibbem@ibbem.net>2024-01-30 17:55:30 +0100
committeribbem <ibbem@ibbem.net>2024-02-01 00:01:26 +0100
commit6558e891777932e8066080e89bdc773e6127e1e7 (patch)
treeeee8933729d7cacb8202b8c63ef489016bcd3bb7 /lib/fileset/tests.sh
parentMerge pull request #275493 from chitochi/guile-chickadee (diff)
downloadnixpkgs-6558e891777932e8066080e89bdc773e6127e1e7.tar.gz
lib.fileset.gitTracked: Allow clones of shallow repositories
The only reason shallow clones are not the default in `builtins.fetchGit` is that `revCount` can't be provided when cloning a shallow repository. However, `revCount` isn't used or exposed by `lib.fileset`. Hence, allowing cloning shallow repositories makes `gitTracked` more general without any drawbacks. Co-authored-by: Silvan Mosberger <github@infinisil.com>
Diffstat (limited to 'lib/fileset/tests.sh')
-rwxr-xr-xlib/fileset/tests.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/fileset/tests.sh b/lib/fileset/tests.sh
index e809aef6935a..af8338eb7855 100755
--- a/lib/fileset/tests.sh
+++ b/lib/fileset/tests.sh
@@ -1439,6 +1439,19 @@ if [[ -n "$fetchGitSupportsSubmodules" ]]; then
fi
rm -rf -- *
+# shallow = true is not supported on all Nix versions
+# and older versions don't support shallow clones at all
+if [[ "$(nix-instantiate --eval --expr "$prefixExpression (versionAtLeast builtins.nixVersion _fetchGitShallowMinver)")" == true ]]; then
+ createGitRepo full
+ # Extra commit such that there's a commit that won't be in the shallow clone
+ git -C full commit --allow-empty -q -m extra
+ git clone -q --depth 1 "file://${PWD}/full" shallow
+ cd shallow
+ checkGitTracked
+ cd ..
+ rm -rf -- *
+fi
+
# Go through all stages of Git files
# See https://www.git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository