sync --content now supports --hide-missing adjusted branches
This relies on git ls-files --with-tree, which I'm using in a way that its man page does not document. Hm. I emailed the git list to try to get the docs improved, but at least the git test suite does test the same kind of use case I'm using here. Performance impact when not in an adjusted branch is limited to some additional MVar accesses, and a single git call to determine the name of the current branch. So very minimal. When in an adjusted branch, the performance impact is in Annex.WorkTree.lookupFile, which starts doing an equal amount of work for files that didn't exist as it already did for files that were unlocked. This commit was sponsored by Jochen Bartl on Patreon.
This commit is contained in:
parent
8be5a7269a
commit
4a788fbb3b
9 changed files with 89 additions and 31 deletions
|
@ -29,6 +29,7 @@ import Logs.Transfer
|
|||
import Remote.List
|
||||
import qualified Remote
|
||||
import Annex.CatFile
|
||||
import Annex.CurrentBranch
|
||||
import Annex.Content
|
||||
import Annex.InodeSentinal
|
||||
import qualified Database.Keys
|
||||
|
@ -270,17 +271,33 @@ seekHelper a l = inRepo $ \g ->
|
|||
-- An item in the work tree, which may be a file or a directory.
|
||||
newtype WorkTreeItem = WorkTreeItem FilePath
|
||||
|
||||
-- When in an adjusted branch that hides some files, it may not exist
|
||||
-- in the current work tree, but in the original branch. This allows
|
||||
-- seeking for such files.
|
||||
newtype AllowHidden = AllowHidden Bool
|
||||
|
||||
-- Many git commands seek work tree items matching some criteria,
|
||||
-- and silently skip over anything that does not exist. But users expect
|
||||
-- an error message when one of the files they provided as a command-line
|
||||
-- parameter doesn't exist, so this checks that each exists.
|
||||
workTreeItems :: CmdParams -> Annex [WorkTreeItem]
|
||||
workTreeItems ps = do
|
||||
workTreeItems = workTreeItems' (AllowHidden False)
|
||||
|
||||
workTreeItems' :: AllowHidden -> CmdParams -> Annex [WorkTreeItem]
|
||||
workTreeItems' (AllowHidden allowhidden) ps = do
|
||||
currbranch <- getCurrentBranch
|
||||
forM_ ps $ \p ->
|
||||
unlessM (isJust <$> liftIO (catchMaybeIO $ getSymbolicLinkStatus p)) $ do
|
||||
unlessM (exists p <||> hidden currbranch p) $ do
|
||||
toplevelWarning False (p ++ " not found")
|
||||
Annex.incError
|
||||
return (map WorkTreeItem ps)
|
||||
where
|
||||
exists p = isJust <$> liftIO (catchMaybeIO $ getSymbolicLinkStatus p)
|
||||
hidden currbranch p
|
||||
| allowhidden = do
|
||||
f <- liftIO $ relPathCwdToFile p
|
||||
isJust <$> catObjectMetaDataHidden f currbranch
|
||||
| otherwise = return False
|
||||
|
||||
notSymlink :: FilePath -> IO Bool
|
||||
notSymlink f = liftIO $ not . isSymbolicLink <$> getSymbolicLinkStatus f
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue