@@ -55,10 +55,11 @@ rec {
5555 # packed-refs file, so we have to grep through it:
5656 else if lib.pathExists packedRefsName
5757 then
58− let packedRefs = lib.splitString "\n" (readFile packedRefsName);
59− matchRule = match ("^(.*) " + file + "$");
60− matchedRefs = lib.flatten (lib.filter (m: ! (isNull m)) (map matchRule packedRefs));
61− in lib.head matchedRefs
58+ let fileContent = readFile packedRefsName;
59+ matchRef = match ".*\n([^\n ]*) " + file + "\n.*" fileContent;
60+ in if isNull matchRef
61+ then throw ("Could not find " + file + " in " + packedRefsName)
62+ else lib.head matchRef
6263 else throw ("Not a .git directory: " + path);
6364 in lib.flip readCommitFromFile "HEAD";
6465}