Skip to content

Git submodule directories disappear in dirty directories #6247

@Grumbel

Description

@Grumbel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions