commitIdFromGitRepo: fix stackoverflow if many branches are used.
If many branches are created than builtins.match stack overflows because of a bug in libstdc++: see https://github.com/NixOS/nix/issues/2147
This commit is contained in:
parent
3829979d8d
commit
d7e89fa661
|
@ -145,10 +145,14 @@ rec {
|
||||||
# packed-refs file, so we have to grep through it:
|
# packed-refs file, so we have to grep through it:
|
||||||
then
|
then
|
||||||
let fileContent = readFile packedRefsName;
|
let fileContent = readFile packedRefsName;
|
||||||
matchRef = match (".*\n([^\n ]*) " + file + "\n.*") fileContent;
|
matchRef = builtins.match "([a-z0-9]+) ${file}";
|
||||||
in if matchRef == null
|
isRef = s: builtins.isString s && (matchRef s) != null;
|
||||||
|
# there is a bug in libstdc++ leading to stackoverflow for long strings:
|
||||||
|
# https://github.com/NixOS/nix/issues/2147#issuecomment-659868795
|
||||||
|
refs = builtins.filter isRef (builtins.split "\n" fileContent);
|
||||||
|
in if refs == []
|
||||||
then throw ("Could not find " + file + " in " + packedRefsName)
|
then throw ("Could not find " + file + " in " + packedRefsName)
|
||||||
else lib.head matchRef
|
else lib.head (matchRef (lib.head refs))
|
||||||
|
|
||||||
else throw ("Not a .git directory: " + path);
|
else throw ("Not a .git directory: " + path);
|
||||||
in readCommitFromFile "HEAD";
|
in readCommitFromFile "HEAD";
|
||||||
|
|
Loading…
Reference in New Issue