aboutsummaryrefslogtreecommitdiff
path: root/Git.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-09-20 23:24:48 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-09-20 23:24:48 -0400
commit9f6b7935ddb3d5dcbe0b4b784dc8acd7288ddba6 (patch)
tree8b87227689a603d09ad9fdfd010b2a3b648c1a2f /Git.hs
parent9d26192350b9c7b0402720f6f29c99c24748f364 (diff)
go go gadget hlint
Diffstat (limited to 'Git.hs')
-rw-r--r--Git.hs13
1 files changed, 6 insertions, 7 deletions
diff --git a/Git.hs b/Git.hs
index cd6cdfbfd..86a8c7695 100644
--- a/Git.hs
+++ b/Git.hs
@@ -62,7 +62,7 @@ module Git (
prop_idempotent_deencode
) where
-import Control.Monad (unless, when)
+import Control.Monad (unless, when, liftM2)
import Control.Applicative
import System.Directory
import System.FilePath
@@ -425,7 +425,7 @@ getSha :: String -> IO String -> IO String
getSha subcommand a = do
t <- a
let t' = if last t == '\n'
- then take (length t - 1) t
+ then init t
else t
when (length t' /= shaSize) $
error $ "failed to read sha from git " ++ subcommand ++ " (" ++ t' ++ ")"
@@ -576,7 +576,7 @@ decodeGitFile f@(c:s)
| otherwise = f
where
e = '\\'
- middle = take (length s - 1) s
+ middle = init s
unescape (b, []) = b
-- look for escapes starting with '\'
unescape (b, v) = b ++ beginning ++ unescape (decode rest)
@@ -702,7 +702,6 @@ isRepoTop dir = do
where
isRepo = gitSignature ".git" ".git/config"
isBareRepo = gitSignature "objects" "config"
- gitSignature subdir file = do
- s <- (doesDirectoryExist (dir ++ "/" ++ subdir))
- f <- (doesFileExist (dir ++ "/" ++ file))
- return (s && f)
+ gitSignature subdir file = liftM2 (&&)
+ (doesDirectoryExist (dir ++ "/" ++ subdir))
+ (doesFileExist (dir ++ "/" ++ file))