anchor.diff:                   # https://github.com/NixOS/nix/issues/2147#issuecomment-659868795
                    refs = filter isRef (split "\n" fileContent);
                in if refs == []
  -                then throw ("Could not find " + file + " in " + packedRefsName)
  -                else lib.head (matchRef (lib.head refs))
  -
  -           else throw ("Not a .git directory: " + path);
  +                then { error = "Could not find " + file + " in " + packedRefsName; }
  +                else { value = lib.head (matchRef (lib.head refs)); }
  +
  +           else { error = "Not a .git directory: " + toString path; };
       in readCommitFromFile "HEAD";
   
     pathHasContext = builtins.hasContext or (lib.hasPrefix storeDir);
  
positive.code:            then
               let m   = match "^gitdir: (.*)$" (lib.fileContents path);
               in if m == null
                  then throw ("File contains no gitdir reference: " + path)
                  else
                    let gitDir      = absolutePath (dirOf path) (lib.head m);
                        commonDir'' = if pathIsRegularFile "${gitDir}/commondir"
  
negative.code:              let fileContent = lib.fileContents fileName;
                   matchRef    = match "^ref: (.*)$" fileContent;
               in if  matchRef == null
                  then { value = fileContent; }
                  else readCommitFromFile (lib.head matchRef) path
  
             else if pathIsRegularFile packedRefsName
  