summaryrefslogtreecommitdiff
path: root/Git/Ref.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-12-13 00:24:19 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-12-13 00:24:19 -0400
commit94554782894ec6c26da3b46312d5d1d16d596458 (patch)
tree78746106bfb153945ccbfd2bbae536081c005e91 /Git/Ref.hs
parent55bd61d8c42aaf36a3c57f8444c493f6b045f4cd (diff)
finished where indentation changes
Diffstat (limited to 'Git/Ref.hs')
-rw-r--r--Git/Ref.hs70
1 files changed, 35 insertions, 35 deletions
diff --git a/Git/Ref.hs b/Git/Ref.hs
index 6fec46c22..02adf0547 100644
--- a/Git/Ref.hs
+++ b/Git/Ref.hs
@@ -21,10 +21,10 @@ describe = show . base
- Converts such a fully qualified ref into a base ref (eg: master). -}
base :: Ref -> Ref
base = Ref . remove "refs/heads/" . remove "refs/remotes/" . show
- where
- remove prefix s
- | prefix `isPrefixOf` s = drop (length prefix) s
- | otherwise = s
+ where
+ remove prefix s
+ | prefix `isPrefixOf` s = drop (length prefix) s
+ | otherwise = s
{- Given a directory such as "refs/remotes/origin", and a ref such as
- refs/heads/master, yields a version of that ref under the directory,
@@ -40,51 +40,51 @@ exists ref = runBool "show-ref"
{- Get the sha of a fully qualified git ref, if it exists. -}
sha :: Branch -> Repo -> IO (Maybe Sha)
sha branch repo = process <$> showref repo
- where
- showref = pipeReadStrict [Param "show-ref",
- Param "--hash", -- get the hash
- Param $ show branch]
- process [] = Nothing
- process s = Just $ Ref $ firstLine s
+ where
+ showref = pipeReadStrict [Param "show-ref",
+ Param "--hash", -- get the hash
+ Param $ show branch]
+ process [] = Nothing
+ process s = Just $ Ref $ firstLine s
{- List of (refs, branches) matching a given ref spec. -}
matching :: Ref -> Repo -> IO [(Ref, Branch)]
matching ref repo = map gen . lines <$>
pipeReadStrict [Param "show-ref", Param $ show ref] repo
- where
- gen l = let (r, b) = separate (== ' ') l in
- (Ref r, Ref b)
+ where
+ gen l = let (r, b) = separate (== ' ') l
+ in (Ref r, Ref b)
{- List of (refs, branches) matching a given ref spec.
- Duplicate refs are filtered out. -}
matchingUniq :: Ref -> Repo -> IO [(Ref, Branch)]
matchingUniq ref repo = nubBy uniqref <$> matching ref repo
- where
- uniqref (a, _) (b, _) = a == b
+ where
+ uniqref (a, _) (b, _) = a == b
{- Checks if a String is a legal git ref name.
-
- The rules for this are complex; see git-check-ref-format(1) -}
legal :: Bool -> String -> Bool
legal allowonelevel s = all (== False) illegal
- where
- illegal =
- [ any ("." `isPrefixOf`) pathbits
- , any (".lock" `isSuffixOf`) pathbits
- , not allowonelevel && length pathbits < 2
- , contains ".."
- , any (\c -> contains [c]) illegalchars
- , begins "/"
- , ends "/"
- , contains "//"
- , ends "."
- , contains "@{"
- , null s
- ]
- contains v = v `isInfixOf` s
- ends v = v `isSuffixOf` s
- begins v = v `isPrefixOf` s
+ where
+ illegal =
+ [ any ("." `isPrefixOf`) pathbits
+ , any (".lock" `isSuffixOf`) pathbits
+ , not allowonelevel && length pathbits < 2
+ , contains ".."
+ , any (\c -> contains [c]) illegalchars
+ , begins "/"
+ , ends "/"
+ , contains "//"
+ , ends "."
+ , contains "@{"
+ , null s
+ ]
+ contains v = v `isInfixOf` s
+ ends v = v `isSuffixOf` s
+ begins v = v `isPrefixOf` s
- pathbits = split "/" s
- illegalchars = " ~^:?*[\\" ++ controlchars
- controlchars = chr 0o177 : [chr 0 .. chr (0o40-1)]
+ pathbits = split "/" s
+ illegalchars = " ~^:?*[\\" ++ controlchars
+ controlchars = chr 0o177 : [chr 0 .. chr (0o40-1)]