remove read of the heads
and one tail Removed head from Utility.PartialPrelude in order to avoid the build warning with recent ghc versions as well.
This commit is contained in:
parent
10216b44d2
commit
4ca3d1d584
12 changed files with 32 additions and 42 deletions
|
@ -15,6 +15,7 @@ import qualified Git.Config
|
|||
|
||||
import Text.EditDistance
|
||||
import Control.Concurrent
|
||||
import qualified Data.List.NonEmpty as NE
|
||||
|
||||
{- These are the same cost values as used in git. -}
|
||||
gitEditCosts :: EditCosts
|
||||
|
@ -44,7 +45,7 @@ fuzzymatches input showchoice choices = fst $ unzip $
|
|||
{- Takes action based on git's autocorrect configuration, in preparation for
|
||||
- an autocorrected command being run.
|
||||
-}
|
||||
prepare :: String -> (c -> String) -> [c] -> Maybe Repo -> IO ()
|
||||
prepare :: String -> (c -> String) -> NE.NonEmpty c -> Maybe Repo -> IO ()
|
||||
prepare input showmatch matches r =
|
||||
case readish . fromConfigValue . Git.Config.get "help.autocorrect" "0" =<< r of
|
||||
Just n
|
||||
|
@ -57,7 +58,7 @@ prepare input showmatch matches r =
|
|||
[ "Unknown command '" ++ input ++ "'"
|
||||
, ""
|
||||
, "Did you mean one of these?"
|
||||
] ++ map (\m -> "\t" ++ showmatch m) matches
|
||||
] ++ map (\m -> "\t" ++ showmatch m) (NE.toList matches)
|
||||
warn :: Maybe Float -> IO ()
|
||||
warn mdelaysec = hPutStr stderr $ unlines
|
||||
[ "WARNING: You called a git-annex command named '" ++
|
||||
|
@ -67,7 +68,7 @@ prepare input showmatch matches r =
|
|||
Just sec -> "Continuing in " ++ show sec ++ " seconds, assuming that you meant " ++ match
|
||||
]
|
||||
where
|
||||
match = "'" ++ showmatch (Prelude.head matches) ++ "'."
|
||||
match = "'" ++ showmatch (NE.head matches) ++ "'."
|
||||
sleep n = do
|
||||
warn (Just (fromIntegral n / 10 :: Float))
|
||||
threadDelay (n * 100000) -- deciseconds to microseconds
|
||||
|
|
14
Git/Sha.hs
14
Git/Sha.hs
|
@ -13,6 +13,7 @@ import Common
|
|||
import Git.Types
|
||||
|
||||
import qualified Data.ByteString as S
|
||||
import qualified Data.List.NonEmpty as NE
|
||||
import Data.Char
|
||||
|
||||
{- Runs an action that causes a git subcommand to emit a Sha, and strips
|
||||
|
@ -44,16 +45,15 @@ extractSha s
|
|||
]
|
||||
|
||||
{- Sizes of git shas. -}
|
||||
shaSizes :: [Int]
|
||||
shaSizes :: NE.NonEmpty Int
|
||||
shaSizes =
|
||||
[ 40 -- sha1 (must come first)
|
||||
, 64 -- sha256
|
||||
]
|
||||
40 -- sha1 (must come first)
|
||||
NE.:| [64] -- sha256
|
||||
|
||||
{- Git plumbing often uses a all 0 sha to represent things like a
|
||||
- deleted file. -}
|
||||
nullShas :: [Sha]
|
||||
nullShas = map (\n -> Ref (S.replicate n zero)) shaSizes
|
||||
nullShas :: NE.NonEmpty Sha
|
||||
nullShas = NE.map (\n -> Ref (S.replicate n zero)) shaSizes
|
||||
where
|
||||
zero = fromIntegral (ord '0')
|
||||
|
||||
|
@ -63,7 +63,7 @@ nullShas = map (\n -> Ref (S.replicate n zero)) shaSizes
|
|||
- sha1 to the sha256, or probably just treat all null sha1 specially
|
||||
- the same as all null sha256. -}
|
||||
deleteSha :: Sha
|
||||
deleteSha = Prelude.head nullShas
|
||||
deleteSha = NE.head nullShas
|
||||
|
||||
{- Git's magic empty tree.
|
||||
-
|
||||
|
|
|
@ -107,9 +107,9 @@ mergeFile info file hashhandle h = case S8.words info of
|
|||
- generating new content.
|
||||
-}
|
||||
calcMerge :: [(Ref, [L8.ByteString])] -> Either Ref [L8.ByteString]
|
||||
calcMerge shacontents
|
||||
| null reusable = Right new
|
||||
| otherwise = Left $ fst $ Prelude.head reusable
|
||||
calcMerge shacontents = case reusable of
|
||||
[] -> Right new
|
||||
(r:_) -> Left $ fst r
|
||||
where
|
||||
reusable = filter (\c -> sorteduniq (snd c) == new) shacontents
|
||||
new = sorteduniq $ concat $ map snd shacontents
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue