From 9b3a2e6c91afb886f1743769a5100fcf056d6ea7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 4 Apr 2016 13:17:24 -0400 Subject: Upgrading a direct mode repository to v6 has changed to enter an adjusted unlocked branch. This makes the direct mode to v6 upgrade able to be performed in one clone of a repository without affecting other clones, which can continue using v5 and direct mode. --- Upgrade/V5.hs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'Upgrade') diff --git a/Upgrade/V5.hs b/Upgrade/V5.hs index ab6df6689..ee213b613 100644 --- a/Upgrade/V5.hs +++ b/Upgrade/V5.hs @@ -1,6 +1,6 @@ {- git-annex v5 -> v6 upgrade support - - - Copyright 2015 Joey Hess + - Copyright 2015-2016 Joey Hess - - Licensed under the GNU GPL version 3 or higher. -} @@ -23,7 +23,9 @@ import qualified Git.Branch import Git.FilePath import Git.FileMode import Git.Config +import Git.Ref import Utility.InodeCache +import Annex.AdjustedBranch upgrade :: Bool -> Annex Bool upgrade automatic = do @@ -37,19 +39,27 @@ upgrade automatic = do setConfig (annexConfig "thin") (boolConfig True) Annex.changeGitConfig $ \c -> c { annexThin = True } {- Since upgrade from direct mode changes how files - - are represented in git, commit any changes in the - - work tree first. -} + - are represented in git, by checking out an adjusted + - branch, commit any changes in the work tree first. -} whenM stageDirect $ do unless automatic $ showAction "committing first" upgradeDirectCommit automatic "commit before upgrade to annex.version 6" setDirect False + cur <- fromMaybe (error "Somehow no branch is checked out") + <$> inRepo Git.Branch.current upgradeDirectWorkTree removeDirectCruft - showLongNote "Upgraded repository out of direct mode." - showLongNote "Changes have been staged for all annexed files in this repository; you should run `git commit` to commit these changes." - showLongNote "Any other clones of this repository that use direct mode need to be upgraded now, too." + {- Create adjusted branch where all files are unlocked. + - This should have the same content for each file as + - have been staged in upgradeDirectWorkTree. -} + adjbranch <- adjustBranch UnlockAdjustment cur + {- Since the work tree was already set up by + - upgradeDirectWorkTree, and contains unlocked file + - contents too, don't use git checkout to check out the + - adjust branch. Instead, update HEAD manually. -} + inRepo $ setHeadRef adjbranch configureSmudgeFilter -- Inode sentinal file was only used in direct mode and when -- locking down files as they were added. In v6, it's used more -- cgit v1.2.3