Skip to content

fetchGit { ref = "HEAD"; } regression #13948

@hxtmdev

Description

@hxtmdev

Describe the bug

nix-build -E 'fetchGit { url = "https://github.com/NixOS/nixpkgs.git"; ref = "HEAD"; }' is broken by ee9fa0d

Steps To Reproduce

nix-build -E 'fetchGit { url = "https://github.com/NixOS/nixpkgs.git"; ref = "HEAD"; }'

observe error: resolving Git reference 'HEAD': revspec 'HEAD' not found

Expected behavior

fetchGit success, i.e. the tree

Metadata

nix-env (Nix) 2.31.1

Additional context

tazjin/nixery#174 (comment)

can be fixed by

--- a/src/libfetchers/git.cc
+++ b/src/libfetchers/git.cc
@@ -652,7 +652,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);

but I'm not sure if that goes against the spirit of #12386

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions