diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-03-29 13:26:06 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-03-29 13:26:06 -0400 |
commit | 86c10bc681bb12936bc12c612d6a91096bc41f7b (patch) | |
tree | 5291fac68a6e2e505690e33a65a7575d28ee4eb9 /Annex/Ingest.hs | |
parent | c079545a6a3a85f92fbf592229b5f90dbb2da856 (diff) |
git annex add in adjusted unlocked branch
Cached the current branch lookup just because it seems unnecessary overhead
to run an extra git command per add to query the current branch.
Diffstat (limited to 'Annex/Ingest.hs')
-rw-r--r-- | Annex/Ingest.hs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/Annex/Ingest.hs b/Annex/Ingest.hs index b80f0e1e0..1bf1db146 100644 --- a/Annex/Ingest.hs +++ b/Annex/Ingest.hs @@ -35,6 +35,8 @@ import Logs.Location import qualified Annex import qualified Annex.Queue import qualified Database.Keys +import qualified Git +import qualified Git.Branch import Config import Utility.InodeCache import Annex.ReplaceFile @@ -43,6 +45,7 @@ import Utility.CopyFile import Utility.Touch import Git.FilePath import Annex.InodeSentinal +import Annex.AdjustedBranch import Control.Exception (IOException) @@ -309,15 +312,32 @@ forceParams = ifM (Annex.getState Annex.force) ) {- Whether a file should be added unlocked or not. Default is to not, - - unless symlinks are not supported. annex.addunlocked can override that. -} + - unless symlinks are not supported. annex.addunlocked can override that. + - Also, when in an adjusted unlocked branch, always add files unlocked. + -} addUnlocked :: Annex Bool addUnlocked = isDirect <||> (versionSupportsUnlockedPointers <&&> ((not . coreSymlinks <$> Annex.getGitConfig) <||> - (annexAddUnlocked <$> Annex.getGitConfig) + (annexAddUnlocked <$> Annex.getGitConfig) <||> + (maybe False (\b -> getAdjustment b == Just UnlockAdjustment) <$> cachedCurrentBranch) ) ) +cachedCurrentBranch :: Annex (Maybe Git.Branch) +cachedCurrentBranch = maybe cache (return . Just) + =<< Annex.getState Annex.cachedcurrentbranch + where + cache :: Annex (Maybe Git.Branch) + cache = do + mb <- inRepo Git.Branch.currentUnsafe + case mb of + Nothing -> return Nothing + Just b -> do + Annex.changeState $ \s -> + s { Annex.cachedcurrentbranch = Just b } + return (Just b) + {- Adds a file to the work tree for the key, and stages it in the index. - The content of the key may be provided in a temp file, which will be - moved into place. -} |