diff options
author | Joey Hess <joey@kitenet.net> | 2011-06-24 01:13:33 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-06-24 01:13:33 -0400 |
commit | 59b2e4ec1d7de3cfc9c477a68ee418d403bc21d7 (patch) | |
tree | a2f41eeb10ce7da79732a5bcff7123fad4d87a66 /Upgrade/V2.hs | |
parent | 69d3c1cec9f6be1dba1ffb391bf69464c52f5936 (diff) |
fixes for upgrading bare repos
Diffstat (limited to 'Upgrade/V2.hs')
-rw-r--r-- | Upgrade/V2.hs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Upgrade/V2.hs b/Upgrade/V2.hs index 57a2ba789..7f0062cf3 100644 --- a/Upgrade/V2.hs +++ b/Upgrade/V2.hs @@ -10,6 +10,7 @@ module Upgrade.V2 where import System.Directory import System.FilePath import Control.Monad.State (liftIO) +import Control.Monad.State (unless) import List import Data.Maybe @@ -22,8 +23,10 @@ import Messages import Utility import Locations -olddir :: FilePath -olddir = ".git-annex" +olddir :: Git.Repo -> FilePath +olddir g + | Git.repoIsLocalBare g = "" + | otherwise = ".git-annex" {- .git-annex/ moved to a git-annex branch. - @@ -46,14 +49,15 @@ upgrade = do g <- Annex.gitRepo Branch.create mapM_ (\(k, f) -> inject f $ logFile k) =<< locationLogs g - mapM_ (\f -> inject f f) =<< logFiles olddir + mapM_ (\f -> inject f f) =<< logFiles (olddir g) liftIO $ do - Git.run g "rm" [Param "-r", Param "-f", Param "-q", File olddir] - gitAttributesUnWrite g + Git.run g "rm" [Param "-r", Param "-f", Param "-q", File (olddir g)] + unless (Git.repoIsLocalBare g) $ gitAttributesUnWrite g showLongNote $ "git-annex branch created\n" ++ "Now you should push the new branch: git push origin git-annex\n" + showProgress return True @@ -71,7 +75,8 @@ locationLogs repo = liftIO $ do inject :: FilePath -> FilePath -> Annex () inject source dest = do - new <- liftIO (readFile $ olddir </> source) + g <- Annex.gitRepo + new <- liftIO (readFile $ olddir g </> source) prev <- Branch.get dest Branch.change dest $ unlines $ nub $ lines prev ++ lines new |