change v6 git-annex add of staged unmodified unlocked file
v6: When a file is unlocked but has not been modified, and the unlocking is only staged, git-annex add did not lock it. Now it will, for consistency with how modified files are handled and with v5. Note the removal of the sameInodeCache check. Otherwise it would see that the unmodified file is unmodified and stop there. That check seems to have been copied from the direct mode branch. But, direct mode had a specific reason to check for unmodified content, that does not apply to v6. The second pass means there is potential for a race, eg the unlocked file could be modified in between the first and second passes. No problem with that, since both passes do the same thing. This commit was sponsored by Jake Vosloo on Patreon.
This commit is contained in:
parent
5e0c7bf81d
commit
2743224658
5 changed files with 49 additions and 8 deletions
|
@ -4,7 +4,7 @@
|
|||
- the values a user passes to a command, and prepare actions operating
|
||||
- on them.
|
||||
-
|
||||
- Copyright 2010-2016 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2018 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
@ -128,9 +128,6 @@ withFilesToBeCommitted a l = seekActions $ prepFiltered a $
|
|||
withFilesOldUnlocked :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
|
||||
withFilesOldUnlocked = withFilesOldUnlocked' LsFiles.typeChanged
|
||||
|
||||
withFilesOldUnlockedToBeCommitted :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
|
||||
withFilesOldUnlockedToBeCommitted = withFilesOldUnlocked' LsFiles.typeChangedStaged
|
||||
|
||||
{- Unlocked files before v6 have changed type from a symlink to a regular file.
|
||||
-
|
||||
- Furthermore, unlocked files used to be a git-annex symlink,
|
||||
|
@ -146,6 +143,19 @@ isOldUnlocked :: FilePath -> Annex Bool
|
|||
isOldUnlocked f = liftIO (notSymlink f) <&&>
|
||||
(isJust <$> catKeyFile f <||> isJust <$> catKeyFileHEAD 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 $
|
||||
prepFiltered a unlockedfiles
|
||||
where
|
||||
unlockedfiles = filterM isV6Unlocked =<< seekHelper LsFiles.typeChangedStaged l
|
||||
|
||||
isV6Unlocked :: FilePath -> Annex Bool
|
||||
isV6Unlocked f = (isJust <$> catKeyFile f <||> isJust <$> catKeyFileHEAD f)
|
||||
|
||||
{- Finds files that may be modified. -}
|
||||
withFilesMaybeModified :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
|
||||
withFilesMaybeModified a params = seekActions $
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue