From 15364cb1db2649f27e759f58d0af7f27310304de Mon Sep 17 00:00:00 2001 From: Logan Glasson Date: Sun, 14 Mar 2021 18:17:23 +1300 Subject: [PATCH] nix-prefetch-git: fix checkout_ref() for "dumb http" repositories The checkout_ref() function was written against Git 1.6.5, just before "smart http" repositories were implemented in Git 1.6.6. In 1.6.5, the `--depth` parameter is ignored when fetching from a dumb http repository. From 1.6.6, this scenario causes a failure. This change updates the comment and falls back to fetching without `--depth`. --- pkgs/build-support/fetchgit/nix-prefetch-git | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index f2df9d9a86932..675ae992f3917 100755 --- a/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/pkgs/build-support/fetchgit/nix-prefetch-git @@ -182,8 +182,10 @@ checkout_ref(){ fi if test -n "$ref"; then - # --depth option is ignored on http repository. - clean_git fetch ${builder:+--progress} --depth 1 origin +"$ref" || return 1 + # --depth option fails on dumb http repositories. + clean_git fetch ${builder:+--progress} --depth 1 origin +"$ref" || + clean_git fetch ${builder:+--progress} origin +"$ref" || + return 1 clean_git checkout -b "$branchName" FETCH_HEAD || return 1 else return 1