aboutsummaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-09-28 12:56:35 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-09-28 12:56:35 -0400
commitbf4c5f82de894139789136457c04dd048956c617 (patch)
tree6fee6710a07cd51d28bef8d57da2195422810230 /Annex
parent5b3ff3fb3c8c4191e0d0a7653014d0b5fd9a0120 (diff)
Warn when metadata is inherited from a previous version of a file
to avoid the user being surprised in cases where that behavior is not desired or expected This commit was supported by the NSF-funded DataLad project.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/MetaData.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/Annex/MetaData.hs b/Annex/MetaData.hs
index 6642c3615..e22ed05a6 100644
--- a/Annex/MetaData.hs
+++ b/Annex/MetaData.hs
@@ -39,12 +39,20 @@ import Data.Time.Clock.POSIX
-}
genMetaData :: Key -> FilePath -> FileStatus -> Annex ()
genMetaData key file status = do
- maybe noop (`copyMetaData` key) =<< catKeyFileHEAD file
+ v <- catKeyFileHEAD file
+ case v of
+ Nothing -> noop
+ Just oldkey ->
+ whenM (copyMetaData oldkey key)
+ warncopied
whenM (annexGenMetaData <$> Annex.getGitConfig) $ do
curr <- getCurrentMetaData key
addMetaData key (dateMetaData mtime curr)
where
mtime = posixSecondsToUTCTime $ realToFrac $ modificationTime status
+ warncopied = warning $
+ "Copied metadata from old version of " ++ file ++ " to new version. " ++
+ "If you don't want this copied metadata, run: git annex metadata --remove-all " ++ file
{- Generates metadata for a file's date stamp.
- Does not overwrite any existing metadata values. -}