NixOS/nix

Git submodule directories disappear in dirty directories

Open

#6 247 ouverte le 13 mars 2022

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)C++ (1 293 forks)batch import
buggood first issue

Métriques du dépôt

Stars
 (9 803 stars)
Métriques de merge PR
 (Merge moyen 7j 11h) (83 PRs mergées en 30 j)

Description

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

Guide contributeur