avoid duplicate add action for v6 unlocked modified file

The new second pass sees the file as type changed because the first
pass's changes have typically not reached git yet. So, have to
explicitly check for unmodified files in the second pass.

Note that, if the file has been touched but not really modified,
the first pass will handle it, and so the second pass does nothing.

This commit was sponsored by Jochen Bartl on Patreon.
This commit is contained in:
Joey Hess 2018-09-12 15:20:34 -04:00
parent 8b21761a42
commit 50217f62a1
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 13 additions and 7 deletions

View file

@ -31,6 +31,8 @@ import Remote.List
import qualified Remote
import Annex.CatFile
import Annex.Content
import Annex.InodeSentinal
import qualified Database.Keys
withFilesInGit :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
withFilesInGit a l = seekActions $ prepFiltered a $
@ -146,15 +148,19 @@ isOldUnlocked f = liftIO (notSymlink f) <&&>
withFilesOldUnlockedToBeCommitted :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
withFilesOldUnlockedToBeCommitted = withFilesOldUnlocked' LsFiles.typeChangedStaged
{- v6 unlocked pointer files that are staged to be committed -}
withUnlockedPointersToBeCommitted :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
withUnlockedPointersToBeCommitted a l = seekActions $
{- v6 unlocked pointer files that are staged, and whose content has not been
- modified-}
withUnmodifiedUnlockedPointers :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
withUnmodifiedUnlockedPointers a l = seekActions $
prepFiltered a unlockedfiles
where
unlockedfiles = filterM isV6Unlocked =<< seekHelper LsFiles.typeChangedStaged l
unlockedfiles = filterM isV6UnmodifiedUnlocked
=<< seekHelper LsFiles.typeChangedStaged l
isV6Unlocked :: FilePath -> Annex Bool
isV6Unlocked f = (isJust <$> catKeyFile f <||> isJust <$> catKeyFileHEAD f)
isV6UnmodifiedUnlocked :: FilePath -> Annex Bool
isV6UnmodifiedUnlocked f = catKeyFile f >>= \case
Nothing -> return False
Just k -> sameInodeCache f =<< Database.Keys.getInodeCaches k
{- Finds files that may be modified. -}
withFilesMaybeModified :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek

View file

@ -70,7 +70,7 @@ seek o = allowConcurrentOutput $ do
go (withFilesNotInGit (not $ includeDotFiles o))
go withFilesMaybeModified
ifM versionSupportsUnlockedPointers
( go withUnlockedPointersToBeCommitted
( go withUnmodifiedUnlockedPointers
, unlessM isDirect $
go withFilesOldUnlocked
)