diff options
author | 2017-11-15 16:55:38 -0400 | |
---|---|---|
committer | 2017-11-15 16:59:32 -0400 | |
commit | 4888bd597e34dce996fd581bb417ce017099171b (patch) | |
tree | 8b97f6807b5528be6b00c8d21038057ca097ec29 /Annex/Direct.hs | |
parent | 01c524779136a688abf312e721abce41d2dd109c (diff) |
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.
Diffstat (limited to 'Annex/Direct.hs')
-rw-r--r-- | Annex/Direct.hs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/Annex/Direct.hs b/Annex/Direct.hs index 7a88a8755..57e363a86 100644 --- a/Annex/Direct.hs +++ b/Annex/Direct.hs @@ -111,9 +111,8 @@ preCommitDirect = do withkey (DiffTree.srcsha diff) (DiffTree.srcmode diff) removeAssociatedFile withkey (DiffTree.dstsha diff) (DiffTree.dstmode diff) addAssociatedFile where - withkey sha _mode a = when (sha /= nullSha) $ do - k <- catKey sha - case k of + withkey sha _mode a = when (sha /= nullSha) $ + catKey sha >>= \case Nothing -> noop Just key -> void $ a key $ makeabs $ DiffTree.file diff @@ -427,14 +426,12 @@ setDirect wantdirect = do then moveconfig coreworktree indirectworktree else moveconfig indirectworktree coreworktree setConfig (ConfigKey Git.Config.coreBare) val - moveconfig src dest = do - v <- getConfigMaybe src - case v of - Nothing -> noop - Just wt -> do - unsetConfig src - setConfig dest wt - reloadConfig + moveconfig src dest = getConfigMaybe src >>= \case + Nothing -> noop + Just wt -> do + unsetConfig src + setConfig dest wt + reloadConfig {- Since direct mode sets core.bare=true, incoming pushes could change - the currently checked out branch. To avoid this problem, HEAD @@ -474,8 +471,7 @@ switchHEADBack = maybe noop switch =<< inRepo Git.Branch.currentUnsafe where switch currhead = do let orighead = fromDirectBranch currhead - v <- inRepo $ Git.Ref.sha currhead - case v of + inRepo (Git.Ref.sha currhead) >>= \case Just headsha | orighead /= currhead -> do inRepo $ Git.Branch.update "leaving direct mode" orighead headsha |