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
|
@ -118,6 +118,9 @@ initialize mdescription mversion = checkInitializeAllowed $ \initallowed -> do
|
|||
initSharedClone sharedclone
|
||||
|
||||
u <- getUUID
|
||||
when (u == NoUUID) $
|
||||
giveup "Failed to read annex.uuid from git config after setting it. This should never happen. Please file a bug report."
|
||||
|
||||
{- Avoid overwriting existing description with a default
|
||||
- description. -}
|
||||
whenM (pure (isJust mdescription) <||> not . M.member u <$> uuidDescMapRaw) $
|
||||
|
|
|
@ -7,6 +7,7 @@ git-annex (10.20230627) UNRELEASED; urgency=medium
|
|||
* diffdriver: Added --text option for easy diffing of the contents of
|
||||
annexed text files.
|
||||
* assist: With --jobs, parallelize transferring content to/from remotes.
|
||||
* Fix breakage when git is configured with safe.bareRepository = explicit.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Mon, 26 Jun 2023 13:10:40 -0400
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,8 +13,9 @@ The breakage starts with git-annex init:
|
|||
+ joey@darkstar:~/tmp/g timestamp=1688579729.946567508s
|
||||
|
||||
uuid.log has a NoUUID item logged to it. This is despite annex.uuid being set.
|
||||
10.20230407 --[[Joey]]
|
||||
|
||||
And it seems this is because git-annex runs `git config --list`
|
||||
This is because git-annex runs `git config --list`
|
||||
inside `.git`.. Which with that config set, omits looking at
|
||||
`config`.
|
||||
`config` because it thinks it's in a bare repository.
|
||||
|
||||
> [[fixed|done]] --[[Joey]]
|
||||
|
|
Loading…
Add table
Reference in a new issue