Skip to content

Commit f1bb3aa

Browse files
authored
Fix cleanGit when src is a git submodule. (#1469)
Suppose you have a repository with a submodule checked out in the subdirectory `smod`. `cleanGit { src = ./smod; }` would return the following error: error: getting status of '/.git/modules/smod': No such file or directory `smod/.git` is a file that contains a reference to the git module repo. gitdir: ../.git/modules/smod This is the same as a worktree (in fact, isWorktree = true here), but it's a relative path instead of an absolute path. Co-authored-by: Ewout Van Troostenberghe <[email protected]>
1 parent aa6d7a8 commit f1bb3aa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/clean-git.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,13 @@ then
6565
first_line = head git_content;
6666
prefix = "gitdir: ";
6767
ok = length git_content == 1 && lib.hasPrefix prefix first_line;
68+
raw_path = remove_prefix prefix first_line;
6869
in
6970
if ok
70-
then /. + remove_prefix prefix first_line
71+
then
72+
if lib.hasPrefix "/" raw_path
73+
then /. + raw_path
74+
else /. + builtins.toPath (origSrcSubDir + "/" + raw_path)
7175
else abort "gitSource.nix: Cannot parse ${origSrcSubDir + "/.git"}";
7276
}));
7377

0 commit comments

Comments
 (0)