From 09030960d56e73f712bf9926985cfa5a86109c01 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Wed, 24 Dec 2025 08:29:09 +0800 Subject: [PATCH] nix-prefetch-git: restore the tag-related clone flags when leaving .git When leaveDotGit == true, restore the cloning behaviour before commit 7e085677f996 ("nix-prefetch-git: dont't fetch tags when deep clone unless leaving .git") to preserve the fragile hashes of .git sources. Clean up fetchTagsCompat, as fetchTagsCompat is no longer needed after restoring the old tag-fetching flags. --- pkgs/build-support/fetchgit/nix-prefetch-git | 22 ++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index 791afee46d03..d3788d9447ad 100755 --- a/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/pkgs/build-support/fetchgit/nix-prefetch-git @@ -12,7 +12,6 @@ fetchSubmodules= fetchLFS= builder= fetchTags= -fetchTagsCompat= branchName=$NIX_PREFETCH_GIT_BRANCH_NAME # ENV params @@ -117,13 +116,6 @@ for arg; do fi done -# `deepClone` used to effectively imply `fetchTags`. -# We avoid such behaviour to enhance the `postCheckout` reproducibility, -# while keeping the old behaviour for `.git` for backward compatibility purposes. -if [[ -n "$deepClone" ]] && [[ -z "$leaveDotGit" ]]; then - fetchTagsCompat=true -fi - if test -z "$url"; then usage fi @@ -188,11 +180,15 @@ checkout_hash(){ hash=$(hash_from_ref "$ref") fi - local -a fetchTagsArgs - if [[ -n "$fetchTags" ]]; then - fetchTagsArgs=(--tags) - else + local -a fetchTagsArgs=() + # Avoid fetching all tags at clone time when not leaving .git, + # but keep/restore the behaviour before + # commit 7e085677f996 ("nix-prefetch-git: dont't fetch tags when deep clone unless leaving .git") + # to preserve the fragile hashes of existing .git sources. + if [[ -z "$leaveDotGit" ]]; then fetchTagsArgs=(--no-tags) + elif [[ -n "$deepClone" ]]; then + fetchTagsArgs=(--tags) fi local -a fetchTargetArgs if [[ -n "$deepClone" ]]; then @@ -282,7 +278,7 @@ clone(){ # Fetch all tags if requested # The fetched tags are potentially non-reproducible, as tags are mutable parts of the Git tree. - if [[ -n "$fetchTags" ]] || [[ -n "$fetchTagsCompat" ]]; then + if [[ -n "$fetchTags" ]]; then echo "fetching all tags..." >&2 clean_git fetch origin 'refs/tags/*:refs/tags/*' || echo "warning: failed to fetch some tags" >&2 fi