skip checkRepoConfigInaccessible when git directory specified explicitly

Fix a reversion that prevented git-annex from working in a repository when
--git-dir or GIT_DIR is specified to relocate the git directory to
somewhere else. (Introduced in version 10.20220525)

checkRepoConfigInaccessible could still run git config --list, just passing
--git-dir. It seems not necessary, because I know that passing --git-dir
bypasses git's check for repo ownership. I suppose it might be that git
eventually changes to check something about the ownership of the working
tree, so passing --git-dir without --work-tree would still be worth doing.
But for now this is the simple fix.

Sponsored-by: Nicholas Golder-Manning on Patreon
This commit is contained in:
Joey Hess 2022-09-20 14:52:43 -04:00
parent d1467a9b8e
commit 8d26fdd670
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 61 additions and 17 deletions

View file

@ -1,6 +1,6 @@
{- The current git repository.
-
- Copyright 2012-2020 Joey Hess <id@joeyh.name>
- Copyright 2012-2022 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -80,9 +80,10 @@ get = do
, worktree = Just curr
}
r <- Git.Config.read $ newFrom loc
return $ if Git.Config.isBare r
then r { location = (location r) { worktree = Nothing } }
else r
let r' = r { gitDirSpecifiedExplicitly = True }
return $ if Git.Config.isBare r'
then r' { location = (location r) { worktree = Nothing } }
else r'
configure Nothing Nothing = giveup "Not in a git repository."
addworktree w r = changelocation r $ Local