Commits

Stefan Saasen committed 8499dd5

Filter non tags/heads from the initial ref advertisement when creating the negotiation request

  • Participants
  • Parent commits f080de1

Comments (0)

Files changed (1)

File src/Git/Remote.hs

 --
 -- FIXME - filter heads/tags
 createNegotiationRequest :: [String] -> [PacketLine] -> String
-createNegotiationRequest capabilities = concatMap (++ "") . nub . map (pktLine . (++ "\n")) . foldl' (\acc e -> if null acc then first acc e else additional acc e) [] . wants . filter filterPeeledTags
+createNegotiationRequest capabilities = concatMap (++ "") . nub . map (pktLine . (++ "\n")) . foldl' (\acc e -> if null acc then first acc e else additional acc e) [] . wants . filter filterPeeledTags . filter filterRefs
                     where wants              = mapMaybe toObjId
                           first acc obj      = acc ++ ["want " ++ obj ++ " " ++ unwords capabilities]
                           additional acc obj = acc ++ ["want " ++ obj]
                           filterPeeledTags   = not . isSuffixOf "^{}" . C.unpack . ref
+                          filterRefs line    = let r = C.unpack $ ref line
+                                                   predicates = map ($ r) [isPrefixOf "refs/tags/", isPrefixOf "refs/heads/"]
+                                               in any id predicates
 
 data Remote = Remote {
     getHost         :: String