avoid some read
This commit is contained in:
parent
28699c95a7
commit
4b3c4c0c2b
3 changed files with 9 additions and 4 deletions
|
@ -79,9 +79,10 @@ repoNotIgnored r = not . Git.configTrue <$> getConfig r "ignore" "false"
|
||||||
{- If a value is specified, it is used; otherwise the default is looked up
|
{- If a value is specified, it is used; otherwise the default is looked up
|
||||||
- in git config. forcenumcopies overrides everything. -}
|
- in git config. forcenumcopies overrides everything. -}
|
||||||
getNumCopies :: Maybe Int -> Annex Int
|
getNumCopies :: Maybe Int -> Annex Int
|
||||||
getNumCopies v =
|
getNumCopies v = perhaps (use v) =<< Annex.getState Annex.forcenumcopies
|
||||||
Annex.getState Annex.forcenumcopies >>= maybe (use v) (return . id)
|
|
||||||
where
|
where
|
||||||
use (Just n) = return n
|
use (Just n) = return n
|
||||||
use Nothing = read <$> fromRepo (Git.configGet config "1")
|
use Nothing = perhaps (return 1) =<<
|
||||||
|
readMaybe <$> fromRepo (Git.configGet config "1")
|
||||||
|
perhaps fallback = maybe fallback (return . id)
|
||||||
config = "annex.numcopies"
|
config = "annex.numcopies"
|
||||||
|
|
2
Git.hs
2
Git.hs
|
@ -345,7 +345,7 @@ urlPort :: Repo -> Maybe Integer
|
||||||
urlPort r =
|
urlPort r =
|
||||||
case urlAuthPart uriPort r of
|
case urlAuthPart uriPort r of
|
||||||
":" -> Nothing
|
":" -> Nothing
|
||||||
(':':p) -> Just (read p)
|
(':':p) -> readMaybe p
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
{- Hostname of an URL repo, including any username (ie, "user@host") -}
|
{- Hostname of an URL repo, including any username (ie, "user@host") -}
|
||||||
|
|
|
@ -22,3 +22,7 @@ init = Prelude.init
|
||||||
{- last too -}
|
{- last too -}
|
||||||
last :: [a] -> a
|
last :: [a] -> a
|
||||||
last = Prelude.last
|
last = Prelude.last
|
||||||
|
|
||||||
|
{- read should be avoided, as it throws an error -}
|
||||||
|
read :: Read a => String -> a
|
||||||
|
read = Prelude.read
|
||||||
|
|
Loading…
Reference in a new issue