Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions pkgs/build-support/fetchgit/nix-prefetch-git
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ fetchSubmodules=
fetchLFS=
builder=
fetchTags=
fetchTagsCompat=
branchName=$NIX_PREFETCH_GIT_BRANCH_NAME

# ENV params
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -282,14 +278,14 @@ 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

# Name "$ref" to make `git describe` work reproducibly in `NIX_PREFETCH_GIT_CHECKOUT_HOOK`.
# Name tag "$ref" to make `git describe` work reproducibly in `NIX_PREFETCH_GIT_CHECKOUT_HOOK`.
# Name only when not leaving `.git` for compatibility purposes.
if [[ -n "$ref" ]] && [[ -z "$leaveDotGit" ]]; then
if [[ "$ref" =~ ^refs/tags/ ]] && [[ -z "$leaveDotGit" ]]; then
echo "refer to FETCH_HEAD as its original name $ref"
clean_git update-ref "$ref" FETCH_HEAD
fi
Expand Down
Loading