forked from mirrors/nixpkgs
lib/sources.nix@commitIdFromGitRepo: remove use of lib.splitString
lib.splitString was blowing up the stack in instances where the .git/packed-refs file was too large. We now use a regexp over the whole file instead. Closes #16570
This commit is contained in:
parent
54c46d18ea
commit
fee334f672
|
@ -55,10 +55,11 @@ rec {
|
||||||
# packed-refs file, so we have to grep through it:
|
# packed-refs file, so we have to grep through it:
|
||||||
else if lib.pathExists packedRefsName
|
else if lib.pathExists packedRefsName
|
||||||
then
|
then
|
||||||
let packedRefs = lib.splitString "\n" (readFile packedRefsName);
|
let fileContent = readFile packedRefsName;
|
||||||
matchRule = match ("^(.*) " + file + "$");
|
matchRef = match ".*\n([^\n ]*) " + file + "\n.*" fileContent;
|
||||||
matchedRefs = lib.flatten (lib.filter (m: ! (isNull m)) (map matchRule packedRefs));
|
in if isNull matchRef
|
||||||
in lib.head matchedRefs
|
then throw ("Could not find " + file + " in " + packedRefsName)
|
||||||
|
else lib.head matchRef
|
||||||
else throw ("Not a .git directory: " + path);
|
else throw ("Not a .git directory: " + path);
|
||||||
in lib.flip readCommitFromFile "HEAD";
|
in lib.flip readCommitFromFile "HEAD";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue