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