From b8966433efab3e2e3f66744404c9aec0d36b0ff5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 7 Jan 2012 00:15:01 -0400 Subject: sped up git annex log rather a lot See comment! Isn't git fun, always interesting approaches to optimise things that seemed unfixably slow. --- Command/Log.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Command') 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 "--" -- cgit v1.2.3