fix some build warnings from ghc 9.4.6

It now notices that a RepoLocation may not be Local, in which case
pattern matching on Local wouldn't do.

However, in these cases, I think it always is a Local. In particular,
Git.Config.read is only run on local repos and upgrades LocalUnknown to
Local.
This commit is contained in:
Joey Hess 2023-09-21 12:11:01 -04:00
parent 784be819b3
commit e03e907705
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 5 additions and 3 deletions

View file

@ -260,7 +260,7 @@ adjustGitDirFile :: RepoLocation -> IO RepoLocation
adjustGitDirFile loc = fromMaybe loc <$> adjustGitDirFile' loc
adjustGitDirFile' :: RepoLocation -> IO (Maybe RepoLocation)
adjustGitDirFile' loc = do
adjustGitDirFile' loc@(Local {}) = do
let gd = gitdir loc
c <- firstLine <$> catchDefaultIO "" (readFile (fromRawFilePath gd))
if gitdirprefix `isPrefixOf` c
@ -275,7 +275,7 @@ adjustGitDirFile' loc = do
else return Nothing
where
gitdirprefix = "gitdir: "
adjustGitDirFile' _ = error "internal"
newFrom :: RepoLocation -> Repo
newFrom l = Repo

View file

@ -82,7 +82,9 @@ get = do
r <- Git.Config.read $ (newFrom loc)
{ gitDirSpecifiedExplicitly = True }
return $ if fromMaybe False (Git.Config.isBare r)
then r { location = (location r) { worktree = Nothing } }
then case location r of
loc'@(Local {}) -> r { location = loc' { worktree = Nothing } }
_ -> r
else r
configure Nothing Nothing = giveup "Not in a git repository."