NixOS/nix

Git submodule directories disappear in dirty directories

Open

#6247 aperta il 13 mar 2022

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)C++ (1293 fork)batch import
buggood first issue

Metriche repository

Star
 (9803 star)
Metriche merge PR
 (Merge medio 7g 11h) (83 PR mergiate in 30 g)

Descrizione

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

Guida contributor