summary refs log tree commit diff
path: root/lib/sources.nix
diff options
context:
space:
mode:
authorobadz <obadz-git@obadz.com>2016-07-27 15:44:26 +0100
committerobadz <obadz-git@obadz.com>2016-07-27 15:47:08 +0100
commitfee334f6725736fe63360f9342eaa2886ad1cb40 (patch)
tree034841fa78b6254fbfd89be935e6fcf83f7d1096 /lib/sources.nix
parent54c46d18ea69789932c53b7e544a89707fc5fb43 (diff)
downloadnixpkgs-fee334f6725736fe63360f9342eaa2886ad1cb40.tar
nixpkgs-fee334f6725736fe63360f9342eaa2886ad1cb40.tar.gz
nixpkgs-fee334f6725736fe63360f9342eaa2886ad1cb40.tar.bz2
nixpkgs-fee334f6725736fe63360f9342eaa2886ad1cb40.tar.lz
nixpkgs-fee334f6725736fe63360f9342eaa2886ad1cb40.tar.xz
nixpkgs-fee334f6725736fe63360f9342eaa2886ad1cb40.tar.zst
nixpkgs-fee334f6725736fe63360f9342eaa2886ad1cb40.zip
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
Diffstat (limited to 'lib/sources.nix')
-rw-r--r--lib/sources.nix9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/sources.nix b/lib/sources.nix
index 8e58e4b6a9d..535b04523b5 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";
 }