diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-04-04 13:51:42 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-04-04 13:51:42 -0400 |
commit | cdddad27e44443177b7878821a057c6eaf16cc05 (patch) | |
tree | 8a417dd20a01554e60d7c208d816c7ec8261f0cd /Annex/AdjustedBranch.hs | |
parent | 2f8436cd9bb2a9f16b0bbbf5a30043b911576317 (diff) |
deal with cloning a repo that has an ajdusted branch checked out
Diffstat (limited to 'Annex/AdjustedBranch.hs')
-rw-r--r-- | Annex/AdjustedBranch.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Annex/AdjustedBranch.hs b/Annex/AdjustedBranch.hs index 9de345895..43af5d372 100644 --- a/Annex/AdjustedBranch.hs +++ b/Annex/AdjustedBranch.hs @@ -18,6 +18,7 @@ module Annex.AdjustedBranch ( adjustToCrippledFileSystem, updateAdjustedBranch, propigateAdjustedCommits, + checkAdjustedClone, ) where import Annex.Common @@ -419,3 +420,17 @@ diffTreeToTreeItem dti = TreeItem (Git.DiffTree.file dti) (Git.DiffTree.dstmode dti) (Git.DiffTree.dstsha dti) + +{- Cloning a repository that has an adjusted branch checked out will + - result in the clone having the same adjusted branch checked out -- but + - the origbranch won't exist in the clone. Create the origbranch. -} +checkAdjustedClone :: Annex () +checkAdjustedClone = go =<< inRepo Git.Branch.current + where + go Nothing = return () + go (Just currbranch) = case adjustedToOriginal currbranch of + Nothing -> return () + Just (_adj, origbranch) -> + unlessM (inRepo $ Git.Ref.exists origbranch) $ do + let remotebranch = Git.Ref.underBase "refs/remotes/origin" origbranch + inRepo $ Git.Branch.update' origbranch remotebranch |