Merge branch 'master' into reorg

Conflicts:
	debian/changelog
This commit is contained in:
Joey Hess 2011-03-16 13:48:04 -04:00
commit 0f8edc99ee
2 changed files with 26 additions and 12 deletions

View file

@ -28,6 +28,25 @@ import Foreign.C
data TimeSpec = TimeSpec CTime CLong data TimeSpec = TimeSpec CTime CLong
touch :: FilePath -> TimeSpec -> Bool -> IO ()
touch file mtime follow = touchBoth file omitTime mtime follow
touchBoth :: FilePath -> TimeSpec -> TimeSpec -> Bool -> IO ()
omitTime :: TimeSpec
nowTime :: TimeSpec
#if (defined UTIME_OMIT && defined UTIME_NOW && defined AT_FDCWD && defined AT_SYMLINK_NOFOLLOW)
at_fdcwd :: CInt
at_fdcwd = #const AT_FDCWD
at_symlink_nofollow :: CInt
at_symlink_nofollow = #const AT_SYMLINK_NOFOLLOW
omitTime = TimeSpec 0 #const UTIME_OMIT
nowTime = TimeSpec 0 #const UTIME_NOW
instance Storable TimeSpec where instance Storable TimeSpec where
-- use the larger alignment of the two types in the struct -- use the larger alignment of the two types in the struct
alignment _ = max sec_alignment nsec_alignment alignment _ = max sec_alignment nsec_alignment
@ -43,12 +62,6 @@ instance Storable TimeSpec where
#{poke struct timespec, tv_sec} ptr sec #{poke struct timespec, tv_sec} ptr sec
#{poke struct timespec, tv_nsec} ptr nsec #{poke struct timespec, tv_nsec} ptr nsec
{- special timespecs -}
omitTime :: TimeSpec
omitTime = TimeSpec 0 #const UTIME_OMIT
nowTime :: TimeSpec
nowTime = TimeSpec 0 #const UTIME_NOW
{- While its interface is beastly, utimensat is in recent {- While its interface is beastly, utimensat is in recent
POSIX standards, unlike futimes. -} POSIX standards, unlike futimes. -}
foreign import ccall "utimensat" foreign import ccall "utimensat"
@ -56,7 +69,6 @@ foreign import ccall "utimensat"
{- Changes the access and/or modification times of an existing file. {- Changes the access and/or modification times of an existing file.
Can follow symlinks, or not. Throws IO error on failure. -} Can follow symlinks, or not. Throws IO error on failure. -}
touchBoth :: FilePath -> TimeSpec -> TimeSpec -> Bool -> IO ()
touchBoth file atime mtime follow = touchBoth file atime mtime follow =
allocaArray 2 $ \ptr -> allocaArray 2 $ \ptr ->
withCString file $ \f -> do withCString file $ \f -> do
@ -66,12 +78,13 @@ touchBoth file atime mtime follow =
then throwErrno "touchBoth" then throwErrno "touchBoth"
else return () else return ()
where where
at_fdcwd = #const AT_FDCWD
at_symlink_nofollow = #const AT_SYMLINK_NOFOLLOW
flags = if follow flags = if follow
then 0 then 0
else at_symlink_nofollow else at_symlink_nofollow
touch :: FilePath -> TimeSpec -> Bool -> IO () #else
touch file mtime follow = touchBoth file omitTime mtime follow #warning "utimensat not available; building without symlink timestamp preservation support"
omitTime = TimeSpec 0 (-1)
nowTime = TimeSpec 0 (-2)
touchBoth _ _ _ _ = return ()
#endif

1
debian/changelog vendored
View file

@ -18,6 +18,7 @@ git-annex (0.20110316) UNRELEASED; urgency=low
content are made to have the same mtime as the original file. content are made to have the same mtime as the original file.
While git does not preserve that information, this allows a tool While git does not preserve that information, this allows a tool
like metastore to be used with annexed files. like metastore to be used with annexed files.
(Currently this is only done on systems supporting POSIX 200809.)
-- Joey Hess <joeyh@debian.org> Sun, 13 Mar 2011 14:25:17 -0400 -- Joey Hess <joeyh@debian.org> Sun, 13 Mar 2011 14:25:17 -0400