summaryrefslogtreecommitdiff
path: root/Command/Add.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-14 23:00:23 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-14 23:00:23 -0400
commitbc5c54c987f548505a3877e8a0e460abe0b2a081 (patch)
tree4074e799eef10edb2060abf9d1ba2863c47b256c /Command/Add.hs
parent96e074bb0333b6952fb9fbce2f0a810ebafd3d2c (diff)
symlink touching fun
When adding files to the annex, the symlinks pointing at the annexed content are made to have the same mtime as the original file. While git does not preserve that information, this allows a tool like metastore to be used with annexed files.
Diffstat (limited to 'Command/Add.hs')
-rw-r--r--Command/Add.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index 26e7fa258..09fff7cff 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -18,6 +18,7 @@ import Types
import Content
import Messages
import Utility
+import Touch
command :: [Command]
command = [Command "add" paramPath seek "add files to annex"]
@@ -53,5 +54,11 @@ cleanup file key = do
link <- calcGitLink file key
liftIO $ createSymbolicLink link file
+
+ -- touch the symlink to have the same mtime as the file it points to
+ s <- liftIO $ getFileStatus file
+ let mtime = modificationTime s
+ _ <- liftIO $ touch file (TimeSpec mtime 0) False
+
Annex.queue "add" [Param "--"] file
return True