diff options
author | obadz <obadz-git@obadz.com> | 2016-07-27 15:44:26 +0100 |
---|---|---|
committer | obadz <obadz-git@obadz.com> | 2016-07-27 15:47:08 +0100 |
commit | fee334f6725736fe63360f9342eaa2886ad1cb40 (patch) | |
tree | 034841fa78b6254fbfd89be935e6fcf83f7d1096 | |
parent | 54c46d18ea69789932c53b7e544a89707fc5fb43 (diff) |
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
-rw-r--r-- | lib/sources.nix | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/sources.nix b/lib/sources.nix index 8e58e4b6a9dd0..535b04523b572 100644 --- a/lib/sources.nix +++ b/lib/sources.nix @@ -55,10 +55,11 @@ rec { # packed-refs file, so we have to grep through it: else if lib.pathExists packedRefsName then - let packedRefs = lib.splitString "\n" (readFile packedRefsName); - matchRule = match ("^(.*) " + file + "$"); - matchedRefs = lib.flatten (lib.filter (m: ! (isNull m)) (map matchRule packedRefs)); - in lib.head matchedRefs + let fileContent = readFile packedRefsName; + matchRef = match ".*\n([^\n ]*) " + file + "\n.*" fileContent; + in if isNull matchRef + then throw ("Could not find " + file + " in " + packedRefsName) + else lib.head matchRef else throw ("Not a .git directory: " + path); in lib.flip readCommitFromFile "HEAD"; } |