diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc index c8311c17f..5c518e037 100644 --- a/src/libfetchers/git.cc +++ b/src/libfetchers/git.cc @@ -682,7 +682,7 @@ struct GitInputScheme : InputScheme auto fetchRef = getAllRefsAttr(input) ? "refs/*:refs/*" : input.getRev() ? input.getRev()->gitRev() : ref.compare(0, 5, "refs/") == 0 ? fmt("%1%:%1%", ref) - : ref == "HEAD" ? ref + : ref == "HEAD" ? "HEAD:HEAD" : fmt("%1%:%1%", "refs/heads/" + ref); repo->fetch(repoUrl.to_string(), fetchRef, shallow); diff --git a/tests/functional/fetchGit.sh b/tests/functional/fetchGit.sh index be8b5cb34..e3135328f 100755 --- a/tests/functional/fetchGit.sh +++ b/tests/functional/fetchGit.sh @@ -228,6 +228,10 @@ path8=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = \"file://$rep rev4=$(git -C "$repo" rev-parse HEAD) rev4_nix=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = \"file://$repo\"; ref = \"HEAD\"; }).rev") [[ $rev4 = "$rev4_nix" ]] +export _NIX_FORCE_HTTP=1 +rev4_nix=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = \"file://$repo\"; ref = \"HEAD\"; }).rev") +[[ $rev4 = "$rev4_nix" ]] +unset _NIX_FORCE_HTTP # The name argument should be handled path9=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = \"file://$repo\"; ref = \"HEAD\"; name = \"foo\"; }).outPath")