Fix breakage when git is configured with safe.bareRepository = explicit
Running git config --list inside .git then fails, so better to only do that when --git-dir was specified explicitly. Otherwise, when the repository is not bare, run the command inside the working tree. Also make init detect when the uuid it just set cannot be read and fail with an error, in case git changes something that breaks this later. I still don't actually understand why git-annex add/assist -J2 was affected but -J1 was not. But I did show that it was skipping writing to the location log, because the uuid was NoUUID. Sponsored-by: Graham Spencer on Patreon
This commit is contained in:
parent
321681cd1b
commit
a05bc6a314
4 changed files with 22 additions and 15 deletions
|
@ -57,20 +57,22 @@ reRead r = read' $ r
|
|||
read' :: Repo -> IO Repo
|
||||
read' repo = go repo
|
||||
where
|
||||
go Repo { location = Local { gitdir = d } } = git_config True d
|
||||
go Repo { location = LocalUnknown d } = git_config False d
|
||||
-- Passing --git-dir changes git's behavior when run in a
|
||||
-- repository belonging to another user. When the git directory
|
||||
-- was explicitly specified, pass that in order to get the local
|
||||
-- git config.
|
||||
go Repo { location = Local { gitdir = d } }
|
||||
| gitDirSpecifiedExplicitly repo = git_config ["--git-dir=."] d
|
||||
-- Run in worktree when there is one, since running in the .git
|
||||
-- directory will trigger safe.bareRepository=explicit, even
|
||||
-- when not in a bare repository.
|
||||
go Repo { location = Local { worktree = Just d } } = git_config [] d
|
||||
go Repo { location = Local { gitdir = d } } = git_config [] d
|
||||
go Repo { location = LocalUnknown d } = git_config [] d
|
||||
go _ = assertLocal repo $ error "internal"
|
||||
git_config isgitdir d = withCreateProcess p (git_config' p)
|
||||
git_config addparams d = withCreateProcess p (git_config' p)
|
||||
where
|
||||
params =
|
||||
-- Passing --git-dir changes git's behavior
|
||||
-- when run in a repository belonging to another
|
||||
-- user. When a gitdir is known, pass that in order
|
||||
-- to get the local git config.
|
||||
(if isgitdir && gitDirSpecifiedExplicitly repo
|
||||
then ["--git-dir=."]
|
||||
else [])
|
||||
++ ["config", "--null", "--list"]
|
||||
params = addparams ++ ["config", "--null", "--list"]
|
||||
p = (proc "git" params)
|
||||
{ cwd = Just (fromRawFilePath d)
|
||||
, env = gitEnv repo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue