diff options
author | Atemu <atemu.main@gmail.com> | 2021-07-12 20:03:46 +0200 |
---|---|---|
committer | Atemu <atemu.main@gmail.com> | 2021-07-12 20:50:52 +0200 |
commit | 11df41199ba8a1497d8530dbf478ef10147a93bb (patch) | |
tree | 2248348f00c62fb59be25568d538afafc939875b /pkgs/build-support/fetchgit | |
parent | 45fc7d4a35c5343e58541a7847f6415654ccbb37 (diff) | |
download | nixpkgs-11df41199ba8a1497d8530dbf478ef10147a93bb.tar nixpkgs-11df41199ba8a1497d8530dbf478ef10147a93bb.tar.gz nixpkgs-11df41199ba8a1497d8530dbf478ef10147a93bb.tar.bz2 nixpkgs-11df41199ba8a1497d8530dbf478ef10147a93bb.tar.lz nixpkgs-11df41199ba8a1497d8530dbf478ef10147a93bb.tar.xz nixpkgs-11df41199ba8a1497d8530dbf478ef10147a93bb.tar.zst nixpkgs-11df41199ba8a1497d8530dbf478ef10147a93bb.zip |
nix-prefetch-git: don't fetch everything when given a hash
It's hugely inefficient as we can't use shallow cloning (--depth=1). This has been tested and adapted for quite a few hosts fetchgit is used on in Nixpkgs. For those where fetching the hash directly doesn't work (most notably git.savannah.gnu.org), we simply fall back to the old method.
Diffstat (limited to 'pkgs/build-support/fetchgit')
-rwxr-xr-x | pkgs/build-support/fetchgit/nix-prefetch-git | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index 661e0d674c5..8110d670e41 100755 --- a/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/pkgs/build-support/fetchgit/nix-prefetch-git @@ -140,7 +140,7 @@ url_to_name(){ fi } -# Fetch everything and checkout the right sha1 +# Fetch and checkout the right sha1 checkout_hash(){ local hash="$1" local ref="$2" @@ -149,6 +149,7 @@ checkout_hash(){ hash=$(hash_from_ref "$ref") fi + clean_git fetch ${builder:+--progress} --depth=1 origin "$hash" || \ clean_git fetch -t ${builder:+--progress} origin || return 1 local object_type=$(git cat-file -t "$hash") |