Skip to content

Regression in Nix 2.31.0 with handling of git refs #14252

@joshuaspence

Description

@joshuaspence

Describe the bug

There is a regression in Nix 2.31.0 (caused by #13729) in how ?ref=x is handled, where x:

  1. Does not begin with refs/heads/ or refs/tags.
  2. Starts with an uppercase character.
  3. Contains a /.

Steps To Reproduce

$ nix run github:NixOS/nix?ref=refs/tags/2.31.0 -- eval --impure --expr 'builtins.fetchTree "git+https://github.com/joshuaspence/renovate-nix-test?ref=A/b"'
error:
       … while calling the 'fetchTree' builtin
         at «string»:1:1:
            1| builtins.fetchTree "git+https://github.com/joshuaspence/renovate-nix-test?ref=A/b"
             | ^

       error: invalid Git branch/tag name 'A/b'

Expected behavior

$ nix run github:NixOS/nix?ref=refs/tags/2.30.3 -- eval --impure --expr 'builtins.fetchTree "git+https://github.com/joshuaspence/renovate-nix-test?ref=A/b"'
{ lastModified = 1758840150; lastModifiedDate = "20250925224230"; narHash = "sha256-qYyrO6jtEOPxRmWJIutPcz/BOJZiUxIjFTvJsCCdBd8="; outPath = "/nix/store/2nr406sbalbkrvw30dyb3jwckxqmqrcv-source"; rev = "381789e95ded5d632c348bf288d8a01f5b034107"; revCount = 14; shortRev = "381789e"; submodules = false; }

Metadata

Additional context

This reproduces in Nix 2.32.0 as well.

$ nix run github:NixOS/nix?ref=refs/tags/2.32.0 -- eval --impure --expr 'builtins.fetchTree "git+https://github.com/joshuaspence/renovate-nix-test?ref=A/b"'
error:
       … while calling the 'fetchTree' builtin
         at «string»:1:1:
            1| builtins.fetchTree "git+https://github.com/joshuaspence/renovate-nix-test?ref=A/b"
             | ^

       error: invalid Git branch/tag name 'A/b'

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions