dropunused edge case when annex.thin caused unused object to be modified

dropunused: When an unused object file has gotten modified, eg due to
annex.thin being set, don't silently skip it, but display a warning and let
--force drop it.

This commit was sponsored by Ethan Aubin.
This commit is contained in:
Joey Hess 2018-12-04 12:20:34 -04:00
parent 96d2000570
commit aa8243df4c
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 63 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{- git-annex command
-
- Copyright 2010,2012 Joey Hess <id@joeyh.name>
- Copyright 2010,2012,2018 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@ -8,6 +8,7 @@
module Command.DropUnused where
import Command
import qualified Annex
import qualified Command.Drop
import qualified Remote
import qualified Git
@ -48,9 +49,19 @@ perform from numcopies key = case from of
showAction $ "from " ++ Remote.name r
Command.Drop.performRemote key (AssociatedFile Nothing) numcopies r
Nothing -> ifM (inAnnex key)
( Command.Drop.performLocal key (AssociatedFile Nothing) numcopies []
, next (return True)
( droplocal
, ifM (objectFileExists key)
( ifM (Annex.getState Annex.force)
( droplocal
, do
warning "Annexed object has been modified and dropping it would probably lose the only copy. Run this command with --force if you want to drop it anyway."
next $ return False
)
, next $ return True
)
)
where
droplocal = Command.Drop.performLocal key (AssociatedFile Nothing) numcopies []
performOther :: (Key -> Git.Repo -> FilePath) -> Key -> CommandPerform
performOther filespec key = do