Git: use NonEmpty in fullconfig

This is a nice win. Avoids partial functions, by encoding at the type
level the fact that fullconfig is never an empty list.
This commit is contained in:
Joey Hess 2024-09-26 17:54:36 -04:00
parent 936f22273e
commit 43f31121a5
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 28 additions and 21 deletions

View file

@ -14,6 +14,7 @@ import Data.String
import Data.Default
import qualified Data.Map as M
import qualified Data.ByteString as S
import qualified Data.List.NonEmpty as NE
import System.Posix.Types
import Utility.SafeCommand
import Utility.FileSystemEncoding
@ -42,7 +43,7 @@ data Repo = Repo
{ location :: RepoLocation
, config :: M.Map ConfigKey ConfigValue
-- a given git config key can actually have multiple values
, fullconfig :: M.Map ConfigKey [ConfigValue]
, fullconfig :: M.Map ConfigKey (NE.NonEmpty ConfigValue)
-- remoteName holds the name used for this repo in some other
-- repo's list of remotes, when this repo is such a remote
, remoteName :: Maybe RemoteName