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 dir = do
r <- isRepo
b <- isBareRepo
return (r || b)
if r
then return r
else isBareRepo
where
isRepo = gitSignature ".git" ".git/config"
isBareRepo = gitSignature "objects" "config"
gitSignature subdir file = liftM2 (&&)
(doesDirectoryExist (dir ++ "/" ++ subdir))
(doesFileExist (dir ++ "/" ++ file))
isRepo = gitSignature (".git" </> "config")
isBareRepo = (&&)
<$> doesDirectoryExist (dir </> "objects")
<*> gitSignature "config"
gitSignature file = doesFileExist (dir </> file)
newFrom :: RepoLocation -> IO Repo
newFrom l = return Repo