optimize away 3 stats

This commit is contained in:
Joey Hess 2012-01-14 11:28:49 -04:00
parent ff5703ce77
commit 1f66af2b53

View file

@ -239,14 +239,15 @@ seekUp want dir = do
isRepoTop :: FilePath -> IO Bool isRepoTop :: FilePath -> IO Bool
isRepoTop dir = do isRepoTop dir = do
r <- isRepo r <- isRepo
b <- isBareRepo if r
return (r || b) then return r
else isBareRepo
where where
isRepo = gitSignature ".git" ".git/config" isRepo = gitSignature (".git" </> "config")
isBareRepo = gitSignature "objects" "config" isBareRepo = (&&)
gitSignature subdir file = liftM2 (&&) <$> doesDirectoryExist (dir </> "objects")
(doesDirectoryExist (dir ++ "/" ++ subdir)) <*> gitSignature "config"
(doesFileExist (dir ++ "/" ++ file)) gitSignature file = doesFileExist (dir </> file)
newFrom :: RepoLocation -> IO Repo newFrom :: RepoLocation -> IO Repo
newFrom l = return Repo newFrom l = return Repo