diff options
author | Joey Hess <joey@kitenet.net> | 2011-05-15 02:49:43 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-05-15 03:38:08 -0400 |
commit | cad0e1c8b7eb21f8dceca8dd9fa3bc1d1aa7eabd (patch) | |
tree | b6be12dc1cc83a35ca7d89a862d85e6d71c38572 /GitRepo.hs | |
parent | efa7f544050c0d5be6bc1b0fc0125278e475c213 (diff) |
simplified a bunch of Maybe handling
Diffstat (limited to 'GitRepo.hs')
-rw-r--r-- | GitRepo.hs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/GitRepo.hs b/GitRepo.hs index 49024abe0..b20ff7db3 100644 --- a/GitRepo.hs +++ b/GitRepo.hs @@ -122,9 +122,8 @@ repoFromUrl url | startswith "file://" url = repoFromAbsPath $ uriPath u | otherwise = return $ newFrom $ Url u where - u = case (parseURI url) of - Just v -> v - Nothing -> error $ "bad url " ++ url + u = maybe bad id $ parseURI url + bad = error $ "bad url " ++ url {- Creates a repo that has an unknown location. -} repoFromUnknown :: Repo @@ -264,9 +263,7 @@ workTreeFile repo@(Repo { location = Dir d }) file = do absrepo = case (absNormPath "/" d) of Just f -> addTrailingPathSeparator f Nothing -> error $ "bad repo" ++ repoDescribe repo - absfile c = case (secureAbsNormPath c file) of - Just f -> f - Nothing -> file + absfile c = maybe file id $ secureAbsNormPath c file inrepo f = absrepo `isPrefixOf` f workTreeFile repo _ = assertLocal repo $ error "internal" @@ -352,9 +349,7 @@ reap :: IO () reap = do -- throws an exception when there are no child processes r <- catch (getAnyProcessStatus False True) (\_ -> return Nothing) - case r of - Nothing -> return () - Just _ -> reap + maybe (return ()) (const reap) r {- Scans for files that are checked into git at the specified locations. -} inRepo :: Repo -> [FilePath] -> IO [FilePath] |