revert recent bug fix temporarily for release
Decided this bug is not severe enough to delay the release until tomorrow, so this will be re-applied after the release.
This commit is contained in:
parent
c1ef4a7481
commit
16f1e24665
8 changed files with 33 additions and 42 deletions
|
@ -57,7 +57,7 @@ initRepo True primary_assistant_repo dir desc mgroup = inDir dir $ do
|
||||||
initRepo' desc mgroup
|
initRepo' desc mgroup
|
||||||
{- Initialize the master branch, so things that expect
|
{- Initialize the master branch, so things that expect
|
||||||
- to have it will work, before any files are added. -}
|
- to have it will work, before any files are added. -}
|
||||||
unlessM (fromMaybe False . Git.Config.isBare <$> gitRepo) $ do
|
unlessM (Git.Config.isBare <$> gitRepo) $ do
|
||||||
cmode <- annexCommitMode <$> Annex.getGitConfig
|
cmode <- annexCommitMode <$> Annex.getGitConfig
|
||||||
void $ inRepo $ Git.Branch.commitCommand cmode
|
void $ inRepo $ Git.Branch.commitCommand cmode
|
||||||
(Git.Branch.CommitQuiet True)
|
(Git.Branch.CommitQuiet True)
|
||||||
|
|
|
@ -24,9 +24,6 @@ git-annex (10.20230127) UNRELEASED; urgency=medium
|
||||||
* info, enableremotemote, renameremote: Avoid a confusing message when more
|
* info, enableremotemote, renameremote: Avoid a confusing message when more
|
||||||
than one repository matches the user provided name.
|
than one repository matches the user provided name.
|
||||||
* info: Exit nonzero when the input is not supported.
|
* info: Exit nonzero when the input is not supported.
|
||||||
* Fix more breakage caused by git's fix for CVE-2022-24765, this time
|
|
||||||
involving a remote that is a local bare repository not owned by the
|
|
||||||
current user.
|
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Mon, 06 Feb 2023 13:39:18 -0400
|
-- Joey Hess <id@joeyh.name> Mon, 06 Feb 2023 13:39:18 -0400
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ import Git.Sha
|
||||||
import Git.CatFile
|
import Git.CatFile
|
||||||
import Git.Branch (writeTreeQuiet, update')
|
import Git.Branch (writeTreeQuiet, update')
|
||||||
import qualified Git.Ref
|
import qualified Git.Ref
|
||||||
import Config
|
import qualified Git.Config
|
||||||
import Config.Smudge
|
import Config.Smudge
|
||||||
import qualified Utility.RawFilePath as R
|
import qualified Utility.RawFilePath as R
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ getAssociatedFiles k = emptyWhenBare $ runReaderIO AssociatedTable $
|
||||||
- in a bare repository, but it might happen if a non-bare repo got
|
- in a bare repository, but it might happen if a non-bare repo got
|
||||||
- converted to bare. -}
|
- converted to bare. -}
|
||||||
emptyWhenBare :: Annex [a] -> Annex [a]
|
emptyWhenBare :: Annex [a] -> Annex [a]
|
||||||
emptyWhenBare a = ifM isBareRepo
|
emptyWhenBare a = ifM (Git.Config.isBare <$> gitRepo)
|
||||||
( return []
|
( return []
|
||||||
, a
|
, a
|
||||||
)
|
)
|
||||||
|
@ -261,7 +261,7 @@ isInodeKnown i s = or <$> runReaderIO ContentTable
|
||||||
- is an associated file.
|
- is an associated file.
|
||||||
-}
|
-}
|
||||||
reconcileStaged :: Bool -> H.DbQueue -> Annex DbTablesChanged
|
reconcileStaged :: Bool -> H.DbQueue -> Annex DbTablesChanged
|
||||||
reconcileStaged dbisnew qh = ifM isBareRepo
|
reconcileStaged dbisnew qh = ifM (Git.Config.isBare <$> gitRepo)
|
||||||
( return mempty
|
( return mempty
|
||||||
, do
|
, do
|
||||||
gitindex <- inRepo currentIndexFile
|
gitindex <- inRepo currentIndexFile
|
||||||
|
|
|
@ -133,28 +133,14 @@ store' k v repo = repo
|
||||||
- based on the core.bare and core.worktree settings.
|
- based on the core.bare and core.worktree settings.
|
||||||
-}
|
-}
|
||||||
updateLocation :: Repo -> IO Repo
|
updateLocation :: Repo -> IO Repo
|
||||||
updateLocation r@(Repo { location = LocalUnknown d }) = case isBare r of
|
updateLocation r@(Repo { location = LocalUnknown d })
|
||||||
Just True -> ifM (doesDirectoryExist (fromRawFilePath dotgit))
|
| isBare r = ifM (doesDirectoryExist (fromRawFilePath dotgit))
|
||||||
( updateLocation' r $ Local dotgit Nothing
|
( updateLocation' r $ Local dotgit Nothing
|
||||||
, updateLocation' r $ Local d Nothing
|
, updateLocation' r $ Local d Nothing
|
||||||
)
|
)
|
||||||
Just False -> mknonbare
|
| otherwise = updateLocation' r $ Local dotgit (Just d)
|
||||||
{- core.bare not in config, probably because safe.directory
|
|
||||||
- did not allow reading the config -}
|
|
||||||
Nothing -> ifM (Git.Construct.isBareRepo (fromRawFilePath d))
|
|
||||||
( mkbare
|
|
||||||
, mknonbare
|
|
||||||
)
|
|
||||||
where
|
where
|
||||||
dotgit = d P.</> ".git"
|
dotgit = d P.</> ".git"
|
||||||
-- git treats eg ~/foo as a bare git repository located in
|
|
||||||
-- ~/foo/.git if ~/foo/.git/config has core.bare=true
|
|
||||||
mkbare = ifM (doesDirectoryExist (fromRawFilePath dotgit))
|
|
||||||
( updateLocation' r $ Local dotgit Nothing
|
|
||||||
, updateLocation' r $ Local d Nothing
|
|
||||||
)
|
|
||||||
mknonbare = updateLocation' r $ Local dotgit (Just d)
|
|
||||||
|
|
||||||
updateLocation r@(Repo { location = l@(Local {}) }) = updateLocation' r l
|
updateLocation r@(Repo { location = l@(Local {}) }) = updateLocation' r l
|
||||||
updateLocation r = return r
|
updateLocation r = return r
|
||||||
|
|
||||||
|
@ -226,9 +212,8 @@ boolConfig' :: Bool -> S.ByteString
|
||||||
boolConfig' True = "true"
|
boolConfig' True = "true"
|
||||||
boolConfig' False = "false"
|
boolConfig' False = "false"
|
||||||
|
|
||||||
{- Note that repoIsLocalBare is often better to use than this. -}
|
isBare :: Repo -> Bool
|
||||||
isBare :: Repo -> Maybe Bool
|
isBare r = fromMaybe False $ isTrueFalse' =<< getMaybe coreBare r
|
||||||
isBare r = isTrueFalse' =<< getMaybe coreBare r
|
|
||||||
|
|
||||||
coreBare :: ConfigKey
|
coreBare :: ConfigKey
|
||||||
coreBare = "core.bare"
|
coreBare = "core.bare"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- Construction of Git Repo objects
|
{- Construction of Git Repo objects
|
||||||
-
|
-
|
||||||
- Copyright 2010-2023 Joey Hess <id@joeyh.name>
|
- Copyright 2010-2021 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -23,7 +23,6 @@ module Git.Construct (
|
||||||
checkForRepo,
|
checkForRepo,
|
||||||
newFrom,
|
newFrom,
|
||||||
adjustGitDirFile,
|
adjustGitDirFile,
|
||||||
isBareRepo,
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
|
@ -217,7 +216,7 @@ checkForRepo :: FilePath -> IO (Maybe RepoLocation)
|
||||||
checkForRepo dir =
|
checkForRepo dir =
|
||||||
check isRepo $
|
check isRepo $
|
||||||
check (checkGitDirFile (toRawFilePath dir)) $
|
check (checkGitDirFile (toRawFilePath dir)) $
|
||||||
check (checkdir (isBareRepo dir)) $
|
check isBareRepo $
|
||||||
return Nothing
|
return Nothing
|
||||||
where
|
where
|
||||||
check test cont = maybe cont (return . Just) =<< test
|
check test cont = maybe cont (return . Just) =<< test
|
||||||
|
@ -226,17 +225,16 @@ checkForRepo dir =
|
||||||
, return Nothing
|
, return Nothing
|
||||||
)
|
)
|
||||||
isRepo = checkdir $
|
isRepo = checkdir $
|
||||||
doesFileExist (dir </> ".git" </> "config")
|
gitSignature (".git" </> "config")
|
||||||
<||>
|
<||>
|
||||||
-- A git-worktree lacks .git/config, but has .git/gitdir.
|
-- A git-worktree lacks .git/config, but has .git/gitdir.
|
||||||
-- (Normally the .git is a file, not a symlink, but it can
|
-- (Normally the .git is a file, not a symlink, but it can
|
||||||
-- be converted to a symlink and git will still work;
|
-- be converted to a symlink and git will still work;
|
||||||
-- this handles that case.)
|
-- this handles that case.)
|
||||||
doesFileExist (dir </> ".git" </> "gitdir")
|
gitSignature (".git" </> "gitdir")
|
||||||
|
isBareRepo = checkdir $ gitSignature "config"
|
||||||
isBareRepo :: FilePath -> IO Bool
|
<&&> doesDirectoryExist (dir </> "objects")
|
||||||
isBareRepo dir = doesFileExist (dir </> "config")
|
gitSignature file = doesFileExist $ dir </> file
|
||||||
<&&> doesDirectoryExist (dir </> "objects")
|
|
||||||
|
|
||||||
-- Check for a .git file.
|
-- Check for a .git file.
|
||||||
checkGitDirFile :: RawFilePath -> IO (Maybe RepoLocation)
|
checkGitDirFile :: RawFilePath -> IO (Maybe RepoLocation)
|
||||||
|
|
|
@ -81,7 +81,7 @@ get = do
|
||||||
}
|
}
|
||||||
r <- Git.Config.read $ (newFrom loc)
|
r <- Git.Config.read $ (newFrom loc)
|
||||||
{ gitDirSpecifiedExplicitly = True }
|
{ gitDirSpecifiedExplicitly = True }
|
||||||
return $ if fromMaybe False (Git.Config.isBare r)
|
return $ if Git.Config.isBare r
|
||||||
then r { location = (location r) { worktree = Nothing } }
|
then r { location = (location r) { worktree = Nothing } }
|
||||||
else r
|
else r
|
||||||
configure Nothing Nothing = giveup "Not in a git repository."
|
configure Nothing Nothing = giveup "Not in a git repository."
|
||||||
|
|
|
@ -304,7 +304,7 @@ tryGitConfigRead autoinit r hasuuid
|
||||||
Right r' -> do
|
Right r' -> do
|
||||||
-- Cache when http remote is not bare for
|
-- Cache when http remote is not bare for
|
||||||
-- optimisation.
|
-- optimisation.
|
||||||
unless (fromMaybe False $ Git.Config.isBare r') $
|
unless (Git.Config.isBare r') $
|
||||||
setremote setRemoteBare False
|
setremote setRemoteBare False
|
||||||
return r'
|
return r'
|
||||||
Left err -> do
|
Left err -> do
|
||||||
|
|
|
@ -12,4 +12,15 @@ This is specific to bare git remotes, for non-bare it
|
||||||
detects and warns that safe.directory is needed to use the
|
detects and warns that safe.directory is needed to use the
|
||||||
remote. --[[Joey]]
|
remote. --[[Joey]]
|
||||||
|
|
||||||
> [[fixed|done]] --[[Joey]]
|
> What's causing this is that Git.Config.read is called
|
||||||
|
> on the repo, but git refuses to list the repo's config,
|
||||||
|
> so updateLocation does not see that the repo is bare
|
||||||
|
> when it checks isBare. And so it proceeds to set gitdir
|
||||||
|
> to the default non-bare "dir/.git" value.
|
||||||
|
>
|
||||||
|
> One way to deal with this would be to make isBare a tristate,
|
||||||
|
> since core.bare is not in the listed config at all.
|
||||||
|
>
|
||||||
|
> Or, make Git.Construct.fromPath detect when a repo is bare
|
||||||
|
> w/o parsing config, and indicate that in the Repo it
|
||||||
|
> generates.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue