diff --git a/Cabal/Distribution/Simple/Program/Builtin.hs b/Cabal/Distribution/Simple/Program/Builtin.hs index 7d39e229ee0..01996596e65 100644 --- a/Cabal/Distribution/Simple/Program/Builtin.hs +++ b/Cabal/Distribution/Simple/Program/Builtin.hs @@ -200,8 +200,13 @@ gitProgram = (simpleProgram "git") { programFindVersion = findProgramVersion "--version" $ \str -> -- Invoking "git --version" gives a string like --- "git version 2.7.4 (Apple Git-66)" - case words str of - (_:_:version:_) -> version + let split cs = case break (=='.') cs of + (chunk,[]) -> chunk : [] + (chunk,_:rest) -> chunk : split rest + join [s] = s + join (s:ss) = s ++ ('.' : join ss) + in case words str of + (_:_:version:_) -> join . take 3 $ split version _ -> "" }