Skip to content

fetchGit regression in read-only mode #10040

@infinisil

Description

@infinisil

Describe the bug

fetchGit in read-only mode fails starting version 2.20.

Steps To Reproduce

❯ cd $(mktemp -d)
❯ git init
Initialized empty Git repository in /tmp/tmp.4OVTSSw0qw/.git/
❯ echo $RANDOM > file
❯ git add file
❯ git commit --allow-empty-message --message ""
[main (root-commit) e6cc350] 
 1 file changed, 1 insertion(+)
 create mode 100644 file
❯ nix-instantiate --eval -E 'builtins.fetchGit ./.'
error:
       … while calling the 'fetchGit' builtin
         at «string»:1:1:
            1| builtins.fetchGit ./.
             | ^

       error: path '/nix/store/2mph3l2j090y9nvjxb17fdw5wkdvh6z9-source' is not valid

Expected behavior

The same as 2.19:

❯ nix-instantiate --eval -E 'builtins.fetchGit ./.'
{ lastModified = 1708369413; lastModifiedDate = "20240219190333"; narHash = "sha256-cXK7rwPAHhUlmfVWbfldKqwMORil5JJRwGfyNRUPwIc="; outPath = "/nix/store/2mph3l2j090y9nvjxb17fdw5wkdvh6z9-source"; rev = "e6cc3500a0bc2bbc3d13937d752a8cad5f5a35bf"; revCount = 1; shortRev = "e6cc350"; submodules = false; }

nix-env --version output

nix-env (Nix) 2.21.0pre20240216_60936f2

Additional context

This was detected in NixOS/nixpkgs#285264 using the lib.fileset test suite.

This issue is sponsored by Antithesis

Priorities

Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugregressionSomething doesn't work anymore
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions