diff --git a/Annex/Init.hs b/Annex/Init.hs index bb566ff9ad..6a499e4771 100644 --- a/Annex/Init.hs +++ b/Annex/Init.hs @@ -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) $ diff --git a/CHANGELOG b/CHANGELOG index 448dd62c4e..b3d0e06ef7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 Mon, 26 Jun 2023 13:10:40 -0400 diff --git a/Git/Config.hs b/Git/Config.hs index c76794bf1d..4ff3454d54 100644 --- a/Git/Config.hs +++ b/Git/Config.hs @@ -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 diff --git a/doc/bugs/safe.bareRepository_breaks_git-annex_uuid.mdwn b/doc/bugs/safe.bareRepository_breaks_git-annex_uuid.mdwn index 1a9296a056..8ba730ba8a 100644 --- a/doc/bugs/safe.bareRepository_breaks_git-annex_uuid.mdwn +++ b/doc/bugs/safe.bareRepository_breaks_git-annex_uuid.mdwn @@ -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]]