summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
Diffstat (limited to 'Command')
-rw-r--r--Command/Log.hs29
1 files changed, 18 insertions, 11 deletions
diff --git a/Command/Log.hs b/Command/Log.hs
index 94c085adc..808b86b70 100644
--- a/Command/Log.hs
+++ b/Command/Log.hs
@@ -44,6 +44,7 @@ cmd = withGlobalOptions annexedMatchingOptions $
data LogOptions = LogOptions
{ logFiles :: CmdParams
+ , rawDateOption :: Bool
, gourceOption :: Bool
, passthruOptions :: [CommandParam]
}
@@ -52,6 +53,10 @@ optParser :: CmdParamsDesc -> Parser LogOptions
optParser desc = LogOptions
<$> cmdParams desc
<*> switch
+ ( long "raw-date"
+ <> help "display seconds from unix epoch"
+ )
+ <*> switch
( long "gource"
<> help "format output for gource"
)
@@ -86,14 +91,15 @@ start
-> Key
-> CommandStart
start m zone o file key = do
- showLog output =<< readLog <$> getLog key (passthruOptions o)
- -- getLog produces a zombie; reap it
- liftIO reapZombies
+ (ls, cleanup) <- getLog key (passthruOptions o)
+ showLog output (readLog ls)
+ void $ liftIO cleanup
stop
where
output
- | (gourceOption o) = gourceOutput lookupdescription file
- | otherwise = normalOutput lookupdescription file zone
+ | rawDateOption o = normalOutput lookupdescription file show
+ | gourceOption o = gourceOutput lookupdescription file
+ | otherwise = normalOutput lookupdescription file (showTimeStamp zone)
lookupdescription u = fromMaybe (fromUUID u) $ M.lookup u m
showLog :: Outputter -> [RefChange] -> Annex ()
@@ -109,11 +115,11 @@ showLog outputter ps = do
get ref = map toUUID . Logs.Presence.getLog . L.unpack <$>
catObject ref
-normalOutput :: (UUID -> String) -> FilePath -> TimeZone -> Outputter
-normalOutput lookupdescription file zone present ts us =
+normalOutput :: (UUID -> String) -> FilePath -> (POSIXTime -> String) -> Outputter
+normalOutput lookupdescription file formattime present ts us =
liftIO $ mapM_ (putStrLn . format) us
where
- time = showTimeStamp zone ts
+ time = formattime ts
addel = if present then "+" else "-"
format u = unwords [ addel, time, file, "|",
fromUUID u ++ " -- " ++ lookupdescription u ]
@@ -150,13 +156,13 @@ compareChanges format changes = concatMap diff $ zip changes (drop 1 changes)
- once the location log file is gone avoids it checking all the way back
- to commit 0 to see if it used to exist, so generally speeds things up a
- *lot* for newish files. -}
-getLog :: Key -> [CommandParam] -> Annex [String]
+getLog :: Key -> [CommandParam] -> Annex ([String], IO Bool)
getLog key os = do
top <- fromRepo Git.repoPath
p <- liftIO $ relPathCwdToFile top
config <- Annex.getGitConfig
let logfile = p </> locationLogFile config key
- inRepo $ pipeNullSplitZombie $
+ inRepo $ pipeNullSplit $
[ Param "log"
, Param "-z"
, Param "--pretty=format:%ct"
@@ -196,4 +202,5 @@ parseTimeStamp = utcTimeToPOSIXSeconds . fromMaybe (error "bad timestamp") .
#endif
showTimeStamp :: TimeZone -> POSIXTime -> String
-showTimeStamp zone = show . utcToLocalTime zone . posixSecondsToUTCTime
+showTimeStamp zone = formatTime defaultTimeLocale rfc822DateFormat
+ . utcToZonedTime zone . posixSecondsToUTCTime