summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-01-07 00:15:01 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-01-07 00:15:01 -0400
commitb8966433efab3e2e3f66744404c9aec0d36b0ff5 (patch)
tree43e72df7a92391c6e27820ea82d962d39daa9a75
parent945f56f348c9c4963dbd6b6c969498a28da068bc (diff)
sped up git annex log rather a lot
See comment! Isn't git fun, always interesting approaches to optimise things that seemed unfixably slow.
-rw-r--r--Command/Log.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Command/Log.hs b/Command/Log.hs
index eba9226e5..32f03471a 100644
--- a/Command/Log.hs
+++ b/Command/Log.hs
@@ -94,6 +94,17 @@ compareChanges format changes = concatMap diff $ zip changes (drop 1 changes)
added = S.difference new old
removed = S.difference old new
+{- Gets the git log for a given location log file.
+ -
+ - This is complicated by git log using paths relative to the current
+ - directory, even when looking at files in a different branch. A wacky
+ - relative path to the log file has to be used.
+ -
+ - The --remove-empty is a significant optimisation. It relies on location
+ - log files never being deleted in normal operation. Letting git stop
+ - 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 os = do
top <- fromRepo Git.workTree
@@ -101,6 +112,7 @@ getLog key os = do
let logfile = p </> Logs.Location.logFile key
inRepo $ pipeNullSplit $
[ Params "log -z --pretty=format:%ct --raw --abbrev=40"
+ , Param "--remove-empty"
] ++ os ++
[ Param $ show Annex.Branch.fullname
, Param "--"