fix: avoid infinite recursion while searching for path

In `findGitIgnores`, to find the parent path, we do `path + "/.."`. This means that, for each iteration, the path name grows:

1. `/nix/store/1234-example/a/b/`
2. `/nix/store/1234-example/a/b/..`
3. `/nix/store/1234-example/a/b/../..`
4. etc.

Thus, checking if path is not equal to `/` will always return `true`.

With this fix, it will instead check that the path exists. If the path goes higher than `/`, it will not exist, thus fixing the false positive.

@moduon MT-83
This commit is contained in:
Jairo Llopis 2022-04-05 13:58:56 +01:00 committed by adisbladis
parent 0dd8ba714a
commit 1daf54da67

View file

@ -180,7 +180,7 @@ let
hasGitIgnore = builtins.pathExists gitIgnore; hasGitIgnore = builtins.pathExists gitIgnore;
gitIgnores = if hasGitIgnore then [ gitIgnore ] else [ ]; gitIgnores = if hasGitIgnore then [ gitIgnore ] else [ ];
in in
lib.optionals (builtins.toString path != "/" && ! isGitRoot) (findGitIgnores parent) ++ gitIgnores; lib.optionals (builtins.pathExists path && ! isGitRoot) (findGitIgnores parent) ++ gitIgnores;
/* /*
Provides a source filtering mechanism that: Provides a source filtering mechanism that: