enable LambdaCase and convert around 10% of places that could use it

Needs ghc 7.6.1, so minimum base version increased slightly. All builds
are well above this version of ghc, and debian oldstable is as well.

Code that could use lambdacase can be found by running:
git grep -B 1 'case ' | less
and searching in less for "<-"

This commit was sponsored by andrea rota.
This commit is contained in:
Joey Hess 2017-11-15 16:55:38 -04:00
parent 5e6c3ba30c
commit 187b3e7780
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
13 changed files with 119 additions and 166 deletions

View file

@ -80,9 +80,8 @@ adjustTreeItem UnlockAdjustment = ifSymlink adjustToPointer noAdjust
adjustTreeItem LockAdjustment = ifSymlink noAdjust adjustToSymlink adjustTreeItem LockAdjustment = ifSymlink noAdjust adjustToSymlink
adjustTreeItem FixAdjustment = ifSymlink adjustToSymlink noAdjust adjustTreeItem FixAdjustment = ifSymlink adjustToSymlink noAdjust
adjustTreeItem UnFixAdjustment = ifSymlink (adjustToSymlink' gitAnnexLinkCanonical) noAdjust adjustTreeItem UnFixAdjustment = ifSymlink (adjustToSymlink' gitAnnexLinkCanonical) noAdjust
adjustTreeItem HideMissingAdjustment = \ti@(TreeItem _ _ s) -> do adjustTreeItem HideMissingAdjustment = \ti@(TreeItem _ _ s) ->
mk <- catKey s catKey s >>= \case
case mk of
Just k -> ifM (inAnnex k) Just k -> ifM (inAnnex k)
( return (Just ti) ( return (Just ti)
, return Nothing , return Nothing
@ -99,29 +98,25 @@ noAdjust :: TreeItem -> Annex (Maybe TreeItem)
noAdjust = return . Just noAdjust = return . Just
adjustToPointer :: TreeItem -> Annex (Maybe TreeItem) adjustToPointer :: TreeItem -> Annex (Maybe TreeItem)
adjustToPointer ti@(TreeItem f _m s) = do adjustToPointer ti@(TreeItem f _m s) = catKey s >>= \case
mk <- catKey s Just k -> do
case mk of Database.Keys.addAssociatedFile k f
Just k -> do Just . TreeItem f (fromBlobType FileBlob)
Database.Keys.addAssociatedFile k f <$> hashPointerFile k
Just . TreeItem f (fromBlobType FileBlob) Nothing -> return (Just ti)
<$> hashPointerFile k
Nothing -> return (Just ti)
adjustToSymlink :: TreeItem -> Annex (Maybe TreeItem) adjustToSymlink :: TreeItem -> Annex (Maybe TreeItem)
adjustToSymlink = adjustToSymlink' gitAnnexLink adjustToSymlink = adjustToSymlink' gitAnnexLink
adjustToSymlink' :: (FilePath -> Key -> Git.Repo -> GitConfig -> IO FilePath) -> TreeItem -> Annex (Maybe TreeItem) adjustToSymlink' :: (FilePath -> Key -> Git.Repo -> GitConfig -> IO FilePath) -> TreeItem -> Annex (Maybe TreeItem)
adjustToSymlink' gitannexlink ti@(TreeItem f _m s) = do adjustToSymlink' gitannexlink ti@(TreeItem f _m s) = catKey s >>= \case
mk <- catKey s Just k -> do
case mk of absf <- inRepo $ \r -> absPath $
Just k -> do fromTopFilePath f r
absf <- inRepo $ \r -> absPath $ linktarget <- calcRepo $ gitannexlink absf k
fromTopFilePath f r Just . TreeItem f (fromBlobType SymlinkBlob)
linktarget <- calcRepo $ gitannexlink absf k <$> hashSymlink linktarget
Just . TreeItem f (fromBlobType SymlinkBlob) Nothing -> return (Just ti)
<$> hashSymlink linktarget
Nothing -> return (Just ti)
type OrigBranch = Branch type OrigBranch = Branch
newtype AdjBranch = AdjBranch { adjBranch :: Branch } newtype AdjBranch = AdjBranch { adjBranch :: Branch }
@ -438,11 +433,9 @@ updateAdjustedBranch tomerge (origbranch, adj) mergeconfig canresolvemerge commi
return True return True
reparent _ _ Nothing = return False reparent _ _ Nothing = return False
getcurrentcommit = do getcurrentcommit = inRepo Git.Branch.currentUnsafe >>= \case
v <- inRepo Git.Branch.currentUnsafe Nothing -> return Nothing
case v of Just c -> catCommit c
Nothing -> return Nothing
Just c -> catCommit c
{- Check for any commits present on the adjusted branch that have not yet {- Check for any commits present on the adjusted branch that have not yet
- been propigated to the basis branch, and propigate them to the basis - been propigated to the basis branch, and propigate them to the basis
@ -463,23 +456,19 @@ propigateAdjustedCommits'
-> Adjustment -> Adjustment
-> CommitsPrevented -> CommitsPrevented
-> Annex (Maybe Sha, Annex ()) -> Annex (Maybe Sha, Annex ())
propigateAdjustedCommits' origbranch adj _commitsprevented = do propigateAdjustedCommits' origbranch adj _commitsprevented =
ov <- inRepo $ Git.Ref.sha basis inRepo (Git.Ref.sha basis) >>= \case
case ov of Just origsha -> catCommit currbranch >>= \case
Just origsha -> do Just currcommit ->
cv <- catCommit currbranch newcommits >>= go origsha False >>= \case
case cv of Left e -> do
Just currcommit -> do warning e
v <- newcommits >>= go origsha False return (Nothing, return ())
case v of Right newparent -> return
Left e -> do ( Just newparent
warning e , rebase currcommit newparent
return (Nothing, return ()) )
Right newparent -> return Nothing -> return (Nothing, return ())
( Just newparent
, rebase currcommit newparent
)
Nothing -> return (Nothing, return ())
Nothing -> return (Nothing, return ()) Nothing -> return (Nothing, return ())
where where
(BasisBranch basis) = basisBranch adjbranch (BasisBranch basis) = basisBranch adjbranch
@ -492,18 +481,16 @@ propigateAdjustedCommits' origbranch adj _commitsprevented = do
setBasisBranch (BasisBranch basis) parent setBasisBranch (BasisBranch basis) parent
inRepo $ Git.Branch.update' origbranch parent inRepo $ Git.Branch.update' origbranch parent
return (Right parent) return (Right parent)
go parent pastadjcommit (sha:l) = do go parent pastadjcommit (sha:l) = catCommit sha >>= \case
mc <- catCommit sha Just c
case mc of | commitMessage c == adjustedBranchCommitMessage ->
Just c go parent True l
| commitMessage c == adjustedBranchCommitMessage -> | pastadjcommit ->
go parent True l reverseAdjustedCommit parent adj (sha, c) origbranch
| pastadjcommit -> do >>= \case
v <- reverseAdjustedCommit parent adj (sha, c) origbranch
case v of
Left e -> return (Left e) Left e -> return (Left e)
Right commit -> go commit pastadjcommit l Right commit -> go commit pastadjcommit l
_ -> go parent pastadjcommit l _ -> go parent pastadjcommit l
rebase currcommit newparent = do rebase currcommit newparent = do
-- Reuse the current adjusted tree, and reparent it -- Reuse the current adjusted tree, and reparent it
-- on top of the newparent. -- on top of the newparent.

View file

@ -217,9 +217,8 @@ resolveMerge' unstagedmap (Just us) them inoverlay u = do
makepointer key dest destmode = do makepointer key dest destmode = do
unless inoverlay $ unless inoverlay $
unlessM (reuseOldFile unstagedmap key file dest) $ do unlessM (reuseOldFile unstagedmap key file dest) $
r <- linkFromAnnex key dest destmode linkFromAnnex key dest destmode >>= \case
case r of
LinkAnnexFailed -> liftIO $ LinkAnnexFailed -> liftIO $
writePointerFile dest key destmode writePointerFile dest key destmode
_ -> noop _ -> noop

View file

@ -446,18 +446,16 @@ stageJournal jl = withIndex $ do
[genstream dir h jh jlogh] [genstream dir h jh jlogh]
return $ cleanup dir jlogh jlogf return $ cleanup dir jlogh jlogf
where where
genstream dir h jh jlogh streamer = do genstream dir h jh jlogh streamer = readDirectory jh >>= \case
v <- readDirectory jh Nothing -> return ()
case v of Just file -> do
Nothing -> return () unless (dirCruft file) $ do
Just file -> do let path = dir </> file
unless (dirCruft file) $ do sha <- Git.HashObject.hashFile h path
let path = dir </> file hPutStrLn jlogh file
sha <- Git.HashObject.hashFile h path streamer $ Git.UpdateIndex.updateIndexLine
hPutStrLn jlogh file sha FileBlob (asTopFilePath $ fileJournal file)
streamer $ Git.UpdateIndex.updateIndexLine genstream dir h jh jlogh streamer
sha FileBlob (asTopFilePath $ fileJournal file)
genstream dir h jh jlogh streamer
-- Clean up the staged files, as listed in the temp log file. -- Clean up the staged files, as listed in the temp log file.
-- The temp file is used to avoid needing to buffer all the -- The temp file is used to avoid needing to buffer all the
-- filenames in memory. -- filenames in memory.

View file

@ -39,31 +39,26 @@ data ChangedRefsHandle = ChangedRefsHandle DirWatcherHandle (TBMChan Git.Sha)
-- When possible, coalesce ref writes that occur closely together -- When possible, coalesce ref writes that occur closely together
-- in time. Delay up to 0.05 seconds to get more ref writes. -- in time. Delay up to 0.05 seconds to get more ref writes.
waitChangedRefs :: ChangedRefsHandle -> IO ChangedRefs waitChangedRefs :: ChangedRefsHandle -> IO ChangedRefs
waitChangedRefs (ChangedRefsHandle _ chan) = do waitChangedRefs (ChangedRefsHandle _ chan) =
v <- atomically $ readTBMChan chan atomically (readTBMChan chan) >>= \case
case v of
Nothing -> return $ ChangedRefs [] Nothing -> return $ ChangedRefs []
Just r -> do Just r -> do
threadDelay 50000 threadDelay 50000
rs <- atomically $ loop [] rs <- atomically $ loop []
return $ ChangedRefs (r:rs) return $ ChangedRefs (r:rs)
where where
loop rs = do loop rs = tryReadTBMChan chan >>= \case
v <- tryReadTBMChan chan Just (Just r) -> loop (r:rs)
case v of _ -> return rs
Just (Just r) -> loop (r:rs)
_ -> return rs
-- | Remove any changes that might be buffered in the channel, -- | Remove any changes that might be buffered in the channel,
-- without waiting for any new changes. -- without waiting for any new changes.
drainChangedRefs :: ChangedRefsHandle -> IO () drainChangedRefs :: ChangedRefsHandle -> IO ()
drainChangedRefs (ChangedRefsHandle _ chan) = atomically go drainChangedRefs (ChangedRefsHandle _ chan) = atomically go
where where
go = do go = tryReadTBMChan chan >>= \case
v <- tryReadTBMChan chan Just (Just _) -> go
case v of _ -> return ()
Just (Just _) -> go
_ -> return ()
stopWatchingChangedRefs :: ChangedRefsHandle -> IO () stopWatchingChangedRefs :: ChangedRefsHandle -> IO ()
stopWatchingChangedRefs h@(ChangedRefsHandle wh chan) = do stopWatchingChangedRefs h@(ChangedRefsHandle wh chan) = do

View file

@ -149,30 +149,25 @@ inAnnexSafe key = inAnnex' (fromMaybe True) (Just False) go key
( checkOr is_unlocked lockfile ( checkOr is_unlocked lockfile
, return is_missing , return is_missing
) )
checkOr d lockfile = do checkOr d lockfile = checkLocked lockfile >>= return . \case
v <- checkLocked lockfile Nothing -> d
return $ case v of Just True -> is_locked
Nothing -> d Just False -> is_unlocked
Just True -> is_locked
Just False -> is_unlocked
#else #else
checkindirect f = liftIO $ ifM (doesFileExist f) checkindirect f = liftIO $ ifM (doesFileExist f)
( do ( lockShared f >>= \case
v <- lockShared f Nothing -> return is_locked
case v of Just lockhandle -> do
Nothing -> return is_locked dropLock lockhandle
Just lockhandle -> do return is_unlocked
dropLock lockhandle
return is_unlocked
, return is_missing , return is_missing
) )
{- In Windows, see if we can take a shared lock. If so, {- In Windows, see if we can take a shared lock. If so,
- remove the lock file to clean up after ourselves. -} - remove the lock file to clean up after ourselves. -}
checkdirect contentfile lockfile = checkdirect contentfile lockfile =
ifM (liftIO $ doesFileExist contentfile) ifM (liftIO $ doesFileExist contentfile)
( modifyContent lockfile $ liftIO $ do ( modifyContent lockfile $ liftIO $
v <- lockShared lockfile lockShared >>= \case
case v of
Nothing -> return is_locked Nothing -> return is_locked
Just lockhandle -> do Just lockhandle -> do
dropLock lockhandle dropLock lockhandle
@ -428,8 +423,7 @@ checkDiskSpace' need destdir key alreadythere samefilesystem = ifM (Annex.getSta
inprogress <- if samefilesystem inprogress <- if samefilesystem
then sizeOfDownloadsInProgress (/= key) then sizeOfDownloadsInProgress (/= key)
else pure 0 else pure 0
free <- liftIO . getDiskFree =<< dir dir >>= liftIO . getDiskFree >>= \case
case free of
Just have -> do Just have -> do
reserve <- annexDiskReserve <$> Annex.getGitConfig reserve <- annexDiskReserve <$> Annex.getGitConfig
let delta = need + reserve - have - alreadythere + inprogress let delta = need + reserve - have - alreadythere + inprogress
@ -581,9 +575,8 @@ data FromTo = From | To
-} -}
linkAnnex :: FromTo -> Key -> FilePath -> Maybe InodeCache -> FilePath -> Maybe FileMode -> Annex LinkAnnexResult linkAnnex :: FromTo -> Key -> FilePath -> Maybe InodeCache -> FilePath -> Maybe FileMode -> Annex LinkAnnexResult
linkAnnex _ _ _ Nothing _ _ = return LinkAnnexFailed linkAnnex _ _ _ Nothing _ _ = return LinkAnnexFailed
linkAnnex fromto key src (Just srcic) dest destmode = do linkAnnex fromto key src (Just srcic) dest destmode =
mdestic <- withTSDelta (liftIO . genInodeCache dest) withTSDelta (liftIO . genInodeCache dest) >>= \case
case mdestic of
Just destic -> do Just destic -> do
cs <- Database.Keys.getInodeCaches key cs <- Database.Keys.getInodeCaches key
if null cs if null cs
@ -602,17 +595,15 @@ linkAnnex fromto key src (Just srcic) dest destmode = do
failed = do failed = do
Database.Keys.addInodeCaches key [srcic] Database.Keys.addInodeCaches key [srcic]
return LinkAnnexFailed return LinkAnnexFailed
checksrcunchanged = do checksrcunchanged = withTSDelta (liftIO . genInodeCache src) >>= \case
mcache <- withTSDelta (liftIO . genInodeCache src) Just srcic' | compareStrong srcic srcic' -> do
case mcache of destic <- withTSDelta (liftIO . genInodeCache dest)
Just srcic' | compareStrong srcic srcic' -> do Database.Keys.addInodeCaches key $
destic <- withTSDelta (liftIO . genInodeCache dest) catMaybes [destic, Just srcic]
Database.Keys.addInodeCaches key $ return LinkAnnexOk
catMaybes [destic, Just srcic] _ -> do
return LinkAnnexOk liftIO $ nukeFile dest
_ -> do failed
liftIO $ nukeFile dest
failed
{- Hard links or copies src to dest, which must not already exists. {- Hard links or copies src to dest, which must not already exists.
- -

View file

@ -111,9 +111,8 @@ preCommitDirect = do
withkey (DiffTree.srcsha diff) (DiffTree.srcmode diff) removeAssociatedFile withkey (DiffTree.srcsha diff) (DiffTree.srcmode diff) removeAssociatedFile
withkey (DiffTree.dstsha diff) (DiffTree.dstmode diff) addAssociatedFile withkey (DiffTree.dstsha diff) (DiffTree.dstmode diff) addAssociatedFile
where where
withkey sha _mode a = when (sha /= nullSha) $ do withkey sha _mode a = when (sha /= nullSha) $
k <- catKey sha catKey sha >>= \case
case k of
Nothing -> noop Nothing -> noop
Just key -> void $ a key $ Just key -> void $ a key $
makeabs $ DiffTree.file diff makeabs $ DiffTree.file diff
@ -427,14 +426,12 @@ setDirect wantdirect = do
then moveconfig coreworktree indirectworktree then moveconfig coreworktree indirectworktree
else moveconfig indirectworktree coreworktree else moveconfig indirectworktree coreworktree
setConfig (ConfigKey Git.Config.coreBare) val setConfig (ConfigKey Git.Config.coreBare) val
moveconfig src dest = do moveconfig src dest = getConfigMaybe src >>= \case
v <- getConfigMaybe src Nothing -> noop
case v of Just wt -> do
Nothing -> noop unsetConfig src
Just wt -> do setConfig dest wt
unsetConfig src reloadConfig
setConfig dest wt
reloadConfig
{- Since direct mode sets core.bare=true, incoming pushes could change {- Since direct mode sets core.bare=true, incoming pushes could change
- the currently checked out branch. To avoid this problem, HEAD - the currently checked out branch. To avoid this problem, HEAD
@ -474,8 +471,7 @@ switchHEADBack = maybe noop switch =<< inRepo Git.Branch.currentUnsafe
where where
switch currhead = do switch currhead = do
let orighead = fromDirectBranch currhead let orighead = fromDirectBranch currhead
v <- inRepo $ Git.Ref.sha currhead inRepo (Git.Ref.sha currhead) >>= \case
case v of
Just headsha Just headsha
| orighead /= currhead -> do | orighead /= currhead -> do
inRepo $ Git.Branch.update "leaving direct mode" orighead headsha inRepo $ Git.Branch.update "leaving direct mode" orighead headsha

View file

@ -133,12 +133,10 @@ mkLargeFilesParser = do
#ifdef WITH_MAGICMIME #ifdef WITH_MAGICMIME
magicmime <- liftIO $ catchMaybeIO $ do magicmime <- liftIO $ catchMaybeIO $ do
m <- magicOpen [MagicMimeType] m <- magicOpen [MagicMimeType]
liftIO $ do liftIO $ getEnv "GIT_ANNEX_DIR" >>= \case
md <- getEnv "GIT_ANNEX_DIR" Nothing -> magicLoadDefault m
case md of Just d -> magicLoad m
Nothing -> magicLoadDefault m (d </> "magic" </> "magic.mgc")
Just d -> magicLoad m
(d </> "magic" </> "magic.mgc")
return m return m
#endif #endif
let parse = parseToken $ commonTokens let parse = parseToken $ commonTokens

View file

@ -169,9 +169,8 @@ ingest' preferredbackend (Just (LockedDown cfg source)) mk = withTSDelta $ \delt
) )
go _ _ _ = failure "failed to generate a key" go _ _ _ = failure "failed to generate a key"
golocked key mcache s = do golocked key mcache s =
v <- tryNonAsync (moveAnnex key $ contentLocation source) tryNonAsync (moveAnnex key $ contentLocation source) >>= \case
case v of
Right True -> do Right True -> do
populateAssociatedFiles key source populateAssociatedFiles key source
success key mcache s success key mcache s
@ -184,8 +183,7 @@ ingest' preferredbackend (Just (LockedDown cfg source)) mk = withTSDelta $ \delt
-- already has a hard link. -- already has a hard link.
cleanCruft source cleanCruft source
cleanOldKeys (keyFilename source) key cleanOldKeys (keyFilename source) key
r <- linkToAnnex key (keyFilename source) (Just cache) linkToAnnex key (keyFilename source) (Just cache) >>= \case
case r of
LinkAnnexFailed -> failure "failed to link to annex" LinkAnnexFailed -> failure "failed to link to annex"
_ -> do _ -> do
finishIngestUnlocked' key source finishIngestUnlocked' key source
@ -259,8 +257,7 @@ cleanOldKeys file newkey = do
fs <- filter (/= ingestedf) fs <- filter (/= ingestedf)
. map (`fromTopFilePath` g) . map (`fromTopFilePath` g)
<$> Database.Keys.getAssociatedFiles key <$> Database.Keys.getAssociatedFiles key
fs' <- filterM (`sameInodeCache` caches) fs filterM (`sameInodeCache` caches) fs >>= \case
case fs' of
-- If linkToAnnex fails, the associated -- If linkToAnnex fails, the associated
-- file with the content is still present, -- file with the content is still present,
-- so no need for any recovery. -- so no need for any recovery.
@ -342,14 +339,12 @@ cachedCurrentBranch = maybe cache (return . Just)
=<< Annex.getState Annex.cachedcurrentbranch =<< Annex.getState Annex.cachedcurrentbranch
where where
cache :: Annex (Maybe Git.Branch) cache :: Annex (Maybe Git.Branch)
cache = do cache = inRepo Git.Branch.currentUnsafe >>= \case
mb <- inRepo Git.Branch.currentUnsafe Nothing -> return Nothing
case mb of Just b -> do
Nothing -> return Nothing Annex.changeState $ \s ->
Just b -> do s { Annex.cachedcurrentbranch = Just b }
Annex.changeState $ \s -> return (Just b)
s { Annex.cachedcurrentbranch = Just b }
return (Just b)
{- Adds a file to the work tree for the key, and stages it in the index. {- Adds a file to the work tree for the key, and stages it in the index.
- The content of the key may be provided in a temp file, which will be - The content of the key may be provided in a temp file, which will be
@ -389,10 +384,8 @@ addAnnexedFile file key mtmp = ifM (addUnlocked <&&> not <$> isDirect)
Nothing -> return True Nothing -> return True
) )
where where
linkunlocked mode = do linkunlocked mode = linkFromAnnex key file mode >>= \case
r <- linkFromAnnex key file mode LinkAnnexFailed -> liftIO $
case r of writePointerFile file key mode
LinkAnnexFailed -> liftIO $ _ -> return ()
writePointerFile file key mode
_ -> return ()
writepointer mode = liftIO $ writePointerFile file key mode writepointer mode = liftIO $ writePointerFile file key mode

View file

@ -93,8 +93,7 @@ initialize' mversion = do
whenM versionSupportsUnlockedPointers $ do whenM versionSupportsUnlockedPointers $ do
configureSmudgeFilter configureSmudgeFilter
scanUnlockedFiles scanUnlockedFiles
v <- checkAdjustedClone checkAdjustedClone >>= \case
case v of
NeedUpgradeForAdjustedClone -> NeedUpgradeForAdjustedClone ->
void $ upgrade True versionForAdjustedClone void $ upgrade True versionForAdjustedClone
InAdjustedClone -> return () InAdjustedClone -> return ()

View file

@ -49,12 +49,10 @@ tryLockExclusive m f = tryPidLock m f $ Posix.tryLockExclusive m f
checkLocked :: LockFile -> Annex (Maybe Bool) checkLocked :: LockFile -> Annex (Maybe Bool)
checkLocked f = Posix.checkLocked f `pidLockCheck` checkpid checkLocked f = Posix.checkLocked f `pidLockCheck` checkpid
where where
checkpid pidlock = do checkpid pidlock = Pid.checkLocked pidlock >>= \case
v <- Pid.checkLocked pidlock -- Only return true when the posix lock file exists.
case v of Just _ -> Posix.checkLocked f
-- Only return true when the posix lock file exists. Nothing -> return Nothing
Just _ -> Posix.checkLocked f
Nothing -> return Nothing
getLockStatus :: LockFile -> Annex LockStatus getLockStatus :: LockFile -> Annex LockStatus
getLockStatus f = Posix.getLockStatus f getLockStatus f = Posix.getLockStatus f

View file

@ -39,8 +39,7 @@ import Data.Time.Clock.POSIX
-} -}
genMetaData :: Key -> FilePath -> FileStatus -> Annex () genMetaData :: Key -> FilePath -> FileStatus -> Annex ()
genMetaData key file status = do genMetaData key file status = do
v <- catKeyFileHEAD file catKeyFileHEAD file >>= \case
case v of
Nothing -> noop Nothing -> noop
Just oldkey -> Just oldkey ->
whenM (copyMetaData oldkey key) whenM (copyMetaData oldkey key)

View file

@ -112,7 +112,7 @@ isContentWritePermOk file = ifM crippledFileSystem
go AllShared = want writeModes go AllShared = want writeModes
go _ = return True go _ = return True
want wantmode = do want wantmode = do
mmode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus file liftIO $ catchMaybeIO $ fileMode <$> getFileStatus file
return $ case mmode of return $ case mmode of
Nothing -> True Nothing -> True
Just havemode -> havemode == combineModes (havemode:wantmode) Just havemode -> havemode == combineModes (havemode:wantmode)

View file

@ -306,7 +306,7 @@ source-repository head
Executable git-annex Executable git-annex
Main-Is: git-annex.hs Main-Is: git-annex.hs
Build-Depends: Build-Depends:
base (>= 4.5 && < 5.0), base (>= 4.6 && < 5.0),
optparse-applicative (>= 0.11.0), optparse-applicative (>= 0.11.0),
containers (>= 0.5.0.0), containers (>= 0.5.0.0),
exceptions (>= 0.6), exceptions (>= 0.6),
@ -360,7 +360,7 @@ Executable git-annex
split split
CC-Options: -Wall CC-Options: -Wall
GHC-Options: -Wall -fno-warn-tabs GHC-Options: -Wall -fno-warn-tabs
Extensions: PackageImports Extensions: PackageImports, LambdaCase
-- Some things don't work with the non-threaded RTS. -- Some things don't work with the non-threaded RTS.
GHC-Options: -threaded GHC-Options: -threaded
Other-Extensions: TemplateHaskell Other-Extensions: TemplateHaskell