nix icon indicating copy to clipboard operation
nix copied to clipboard

builtins.fetchGit fails with .gitmodules entries that aren't submodules

Open alyssais opened this issue 9 months ago • 2 comments

Describe the bug

In the situation where a git submodule used to exist, has been moved into the main repo, but not removed from .gitmodules, Nix is unable to fetchGit with submodules. git clone is able to handle this fine, because .gitmodules is not the source of truth for what submodules exist — it's only used as a lookup table for where to fetch unpopulated submodules. I think the right thing for Nix to do here is look through the git tree, and only fill in submodules that are actually submodules, ignoring other .gitmodules entries.

Steps To Reproduce

nix-repl> builtins.fetchGit { url = https://chromium.googlesource.com/chromiumos/platform/crosvm; ref = "release-R124-15823.B"; submodules = true; }
error:
       … while calling the 'fetchGit' builtin
         at «string»:1:1:
            1| builtins.fetchGit { url = https://chromium.googlesource.com/chromiumos/platform/crosvm; ref = "release-R124-15823.B"; submodules = true; }
             | ^

       … while fetching the input 'git+https://chromium.googlesource.com/chromiumos/platform/crosvm?ref=release-R124-15823.B&submodules=1'

       error: '«unknown»/third_party/vmm_vhost' is not a submodule

Expected behavior

Works.

nix-env --version output

nix-env (Nix) 2.22.0

Additional context

Add any other context about the problem here.

Priorities

Add :+1: to issues you find important.

alyssais avatar May 19 '24 18:05 alyssais