NixOS/nix

Git submodule directories disappear in dirty directories

Open

#6.247 geöffnet am 13. März 2022

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)C++ (1.293 Forks)batch import
buggood first issue

Repository-Metriken

Stars
 (9.803 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 7T 11h) (83 gemergte PRs in 30 T)

Beschreibung

When fetching source from a git+file:// URL, the resulting source directory will be missing the empty git submodule directories when the directory is dirty, but will have them when the directory was clean.

To reproduce, create an empty git repository with a submodule:

mkdir /tmp/test
cd /tmp/test
git init .
git submodule add https://github.com/rmccue/test-repository
git commit -m "X" -a

The Nix source directory will contain an empty directory for the submodule, as expected from normal git clone type behavior:

$ ls  $(nix eval --impure --raw --expr '(builtins.fetchTree "git+file:///tmp/test").outPath')
test-repository

Making the repository dirty however will change the result:

touch foo
git add foo
$ ls  $(nix eval --impure --raw --expr '(builtins.fetchTree "git+file:///tmp/test").outPath')
warning: Git tree '/tmp/test' is dirty
foo

Only the dirty file foo is now listed, the test-repository directory is no longer present. The expected behavior would be that the empty submodule directories exist in both cases and doesn't disappear depending on the dirty-status of the directory.

Adding ?submodules=1" to the URL will make it checkout the full submodule in both cases.

$ nix-env --version
nix-env (Nix) 2.7.0pre20220221_caf5172

Contributor Guide