NixOS/nix

Git submodule directories disappear in dirty directories

Open

#6,247 opened on 2022年3月13日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)C++ (1,293 forks)batch import
buggood first issue

Repository metrics

Stars
 (9,803 stars)
PR merge metrics
 (平均マージ 7d 11h) (30d で 83 merged PRs)

説明

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

コントリビューターガイド