better avoid switching to direct mode in clone of adjusted branch repo
This commit is contained in:
parent
1dcfd797fa
commit
3b97c09cde
2 changed files with 27 additions and 18 deletions
|
@ -20,6 +20,7 @@ module Annex.AdjustedBranch (
|
||||||
adjustToCrippledFileSystem,
|
adjustToCrippledFileSystem,
|
||||||
updateAdjustedBranch,
|
updateAdjustedBranch,
|
||||||
propigateAdjustedCommits,
|
propigateAdjustedCommits,
|
||||||
|
AdjustedClone(..),
|
||||||
checkAdjustedClone,
|
checkAdjustedClone,
|
||||||
isGitVersionSupported,
|
isGitVersionSupported,
|
||||||
checkVersionSupported,
|
checkVersionSupported,
|
||||||
|
@ -539,6 +540,8 @@ diffTreeToTreeItem dti = TreeItem
|
||||||
(Git.DiffTree.dstmode dti)
|
(Git.DiffTree.dstmode dti)
|
||||||
(Git.DiffTree.dstsha dti)
|
(Git.DiffTree.dstsha dti)
|
||||||
|
|
||||||
|
data AdjustedClone = InAdjustedClone | NotInAdjustedClone | NeedUpgradeForAdjustedClone
|
||||||
|
|
||||||
{- Cloning a repository that has an adjusted branch checked out will
|
{- Cloning a repository that has an adjusted branch checked out will
|
||||||
- result in the clone having the same adjusted branch checked out -- but
|
- result in the clone having the same adjusted branch checked out -- but
|
||||||
- the origbranch won't exist in the clone, nor will the basis.
|
- the origbranch won't exist in the clone, nor will the basis.
|
||||||
|
@ -547,12 +550,12 @@ diffTreeToTreeItem dti = TreeItem
|
||||||
- The repository may also need to be upgraded to a new version, if the
|
- The repository may also need to be upgraded to a new version, if the
|
||||||
- current version is too old to support adjusted branches. Returns True
|
- current version is too old to support adjusted branches. Returns True
|
||||||
- when this is the case. -}
|
- when this is the case. -}
|
||||||
checkAdjustedClone :: Annex Bool
|
checkAdjustedClone :: Annex AdjustedClone
|
||||||
checkAdjustedClone = go =<< inRepo Git.Branch.current
|
checkAdjustedClone = go =<< inRepo Git.Branch.current
|
||||||
where
|
where
|
||||||
go Nothing = return False
|
go Nothing = return NotInAdjustedClone
|
||||||
go (Just currbranch) = case adjustedToOriginal currbranch of
|
go (Just currbranch) = case adjustedToOriginal currbranch of
|
||||||
Nothing -> return False
|
Nothing -> return NotInAdjustedClone
|
||||||
Just (adj, origbranch) -> do
|
Just (adj, origbranch) -> do
|
||||||
let remotebranch = Git.Ref.underBase "refs/remotes/origin" origbranch
|
let remotebranch = Git.Ref.underBase "refs/remotes/origin" origbranch
|
||||||
let basis@(BasisBranch bb) = basisBranch (originalToAdjusted origbranch adj)
|
let basis@(BasisBranch bb) = basisBranch (originalToAdjusted origbranch adj)
|
||||||
|
@ -560,7 +563,10 @@ checkAdjustedClone = go =<< inRepo Git.Branch.current
|
||||||
setBasisBranch basis remotebranch
|
setBasisBranch basis remotebranch
|
||||||
unlessM (inRepo $ Git.Ref.exists origbranch) $
|
unlessM (inRepo $ Git.Ref.exists origbranch) $
|
||||||
inRepo $ Git.Branch.update' origbranch remotebranch
|
inRepo $ Git.Branch.update' origbranch remotebranch
|
||||||
not <$> versionSupportsUnlockedPointers
|
ifM versionSupportsUnlockedPointers
|
||||||
|
( return InAdjustedClone
|
||||||
|
, return NeedUpgradeForAdjustedClone
|
||||||
|
)
|
||||||
|
|
||||||
-- git 2.2.0 needed for GIT_COMMON_DIR which is needed
|
-- git 2.2.0 needed for GIT_COMMON_DIR which is needed
|
||||||
-- by updateAdjustedBranch to use withWorkTreeRelated.
|
-- by updateAdjustedBranch to use withWorkTreeRelated.
|
||||||
|
|
|
@ -93,20 +93,23 @@ initialize' mversion = do
|
||||||
whenM versionSupportsUnlockedPointers $ do
|
whenM versionSupportsUnlockedPointers $ do
|
||||||
configureSmudgeFilter
|
configureSmudgeFilter
|
||||||
Database.Keys.scanAssociatedFiles
|
Database.Keys.scanAssociatedFiles
|
||||||
whenM checkAdjustedClone $
|
v <- checkAdjustedClone
|
||||||
void $ upgrade True
|
case v of
|
||||||
ifM (crippledFileSystem <&&> (not <$> isBare))
|
NeedUpgradeForAdjustedClone -> void $ upgrade True
|
||||||
( ifM versionSupportsUnlockedPointers
|
InAdjustedClone -> return ()
|
||||||
( adjustToCrippledFileSystem
|
NotInAdjustedClone ->
|
||||||
, do
|
ifM (crippledFileSystem <&&> (not <$> isBare))
|
||||||
enableDirectMode
|
( ifM versionSupportsUnlockedPointers
|
||||||
setDirect True
|
( adjustToCrippledFileSystem
|
||||||
)
|
, do
|
||||||
-- Handle case where this repo was cloned from a
|
enableDirectMode
|
||||||
-- direct mode repo
|
setDirect True
|
||||||
, unlessM isBare
|
)
|
||||||
switchHEADBack
|
-- Handle case where this repo was cloned from a
|
||||||
)
|
-- direct mode repo
|
||||||
|
, unlessM isBare
|
||||||
|
switchHEADBack
|
||||||
|
)
|
||||||
createInodeSentinalFile False
|
createInodeSentinalFile False
|
||||||
|
|
||||||
uninitialize :: Annex ()
|
uninitialize :: Annex ()
|
||||||
|
|
Loading…
Reference in a new issue