summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-11-04 18:04:19 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-11-04 18:04:19 -0400
commit7dc28eee04443ce5f27fd1a15dcbededea07c7d9 (patch)
tree306082fceb81d0b366a4471ec08de76b0f5bcf71 /Annex
parent18a2ba583f5a2b882cb39d097b6d7aafb982b512 (diff)
Remove fixup code for bad bare repositories created by versions 5.20131118 through 5.20131127. That fixup code would accidentially fire when --git-dir was incorrectly pointed at the working tree of a git-annex repository, resulting in data loss. Closes: #768093
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Init.hs58
1 files changed, 1 insertions, 57 deletions
diff --git a/Annex/Init.hs b/Annex/Init.hs
index 2f7b66fbc..9c6952871 100644
--- a/Annex/Init.hs
+++ b/Annex/Init.hs
@@ -107,9 +107,7 @@ uninitialize = do
- Checks repository version and handles upgrades too.
-}
ensureInitialized :: Annex ()
-ensureInitialized = do
- getVersion >>= maybe needsinit checkUpgrade
- fixBadBare
+ensureInitialized = getVersion >>= maybe needsinit checkUpgrade
where
needsinit = ifM Annex.Branch.hasSibling
( initialize Nothing
@@ -194,60 +192,6 @@ enableDirectMode = unlessM isDirect $ do
maybe noop (`toDirect` f) =<< isAnnexLink f
void $ liftIO clean
-{- Work around for git-annex version 5.20131118 - 5.20131127, which
- - had a bug that unset core.bare when initializing a bare repository.
- -
- - This resulted in objects sent to the repository being stored in
- - repo/.git/annex/objects, so move them to repo/annex/objects.
- -
- - This check slows down every git-annex run somewhat (by one file stat),
- - so should be removed after a suitable period of time has passed.
- - Since the bare repository may be on an offline USB drive, best to
- - keep it for a while. However, git-annex was only buggy for a few
- - weeks, so not too long.
- -}
-fixBadBare :: Annex ()
-fixBadBare = whenM checkBadBare $ do
- ks <- getKeysPresent InAnnex
- liftIO $ debugM "Init" $ unwords
- [ "Detected bad bare repository with"
- , show (length ks)
- , "objects; fixing"
- ]
- g <- Annex.gitRepo
- gc <- Annex.getGitConfig
- d <- Git.repoPath <$> Annex.gitRepo
- void $ liftIO $ boolSystem "git"
- [ Param $ "--git-dir=" ++ d
- , Param "config"
- , Param Git.Config.coreBare
- , Param $ Git.Config.boolConfig True
- ]
- g' <- liftIO $ Git.Construct.fromPath d
- s' <- liftIO $ Annex.new $ g' { Git.location = Git.Local { Git.gitdir = d, Git.worktree = Nothing } }
- Annex.changeState $ \s -> s
- { Annex.repo = Annex.repo s'
- , Annex.gitconfig = Annex.gitconfig s'
- }
- forM_ ks $ \k -> do
- oldloc <- liftIO $ gitAnnexLocation k g gc
- thawContentDir oldloc
- moveAnnex k oldloc
- logStatus k InfoPresent
- let dotgit = d </> ".git"
- liftIO $ removeDirectoryRecursive dotgit
- `catchIO` const (renameDirectory dotgit (d </> "removeme"))
-
-{- A repostory with the problem won't know it's a bare repository, but will
- - have no pre-commit hook (which is not set up in a bare repository),
- - and will not have a HEAD file in its .git directory. -}
-checkBadBare :: Annex Bool
-checkBadBare = allM (not <$>)
- [isBare, hasPreCommitHook, hasDotGitHEAD]
- where
- hasPreCommitHook = inRepo $ doesFileExist . hookFile preCommitHook
- hasDotGitHEAD = inRepo $ \r -> doesFileExist $ Git.localGitDir r </> "HEAD"
-
checkSharedClone :: Annex ()
checkSharedClone = whenM (inRepo Git.Objects.isSharedClone) $ do
showSideAction "Repository was cloned with --shared; setting annex.hardlink=true and making repository untrusted."