on iko/ghcjs-patch-master help sign in
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 <evantroostenberghe@hubspot.com>

commitf1bb3aa2f20e57f6405898bd997e367504a1d14b authorEwout <e@ewout.name> dateFri 13 May 2022, 10:00 (4 years ago) parentaa6d7a8
1 file changed+5−1
lib/clean-git.nix+5−1
lib/clean-git.nix+5−1
@@ -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