Only look at reflogs for relevant branches, not for git-annex branches
This speeds it up quite a bit.. May still be too slow in large repos.
This commit is contained in:
parent
600717417f
commit
24800b1bf1
3 changed files with 9 additions and 9 deletions
|
@ -210,7 +210,7 @@ getHistorical :: RefDate -> FilePath -> Annex String
|
||||||
getHistorical date file =
|
getHistorical date file =
|
||||||
-- This check avoids some ugly error messages when the reflog
|
-- This check avoids some ugly error messages when the reflog
|
||||||
-- is empty.
|
-- is empty.
|
||||||
ifM (null <$> inRepo (Git.RefLog.get' [Param "-n1"] (Just fullname)))
|
ifM (null <$> inRepo (Git.RefLog.get' [Param (fromRef fullname), Param "-n1"]))
|
||||||
( error ("No reflog for " ++ fromRef fullname)
|
( error ("No reflog for " ++ fromRef fullname)
|
||||||
, getRef (Git.Ref.dateRef fullname date) file
|
, getRef (Git.Ref.dateRef fullname date) file
|
||||||
)
|
)
|
||||||
|
|
|
@ -219,7 +219,7 @@ withKeysReferencedInGit refspec a = do
|
||||||
shaHead <- maybe (return Nothing) (inRepo . Git.Ref.sha) current
|
shaHead <- maybe (return Nothing) (inRepo . Git.Ref.sha) current
|
||||||
rs <- relevantrefs (shaHead, current)
|
rs <- relevantrefs (shaHead, current)
|
||||||
<$> inRepo (Git.Command.pipeReadStrict [Param "show-ref"])
|
<$> inRepo (Git.Command.pipeReadStrict [Param "show-ref"])
|
||||||
usedrefs <- applyRefSpec refspec rs (inRepo Git.RefLog.getAll)
|
usedrefs <- applyRefSpec refspec rs (getreflog rs)
|
||||||
forM_ usedrefs $
|
forM_ usedrefs $
|
||||||
withKeysReferencedInGitRef a
|
withKeysReferencedInGitRef a
|
||||||
where
|
where
|
||||||
|
@ -242,6 +242,7 @@ withKeysReferencedInGit refspec a = do
|
||||||
Git.Ref.headRef
|
Git.Ref.headRef
|
||||||
: nubRefs (filter ((/= x) . fst) refs)
|
: nubRefs (filter ((/= x) . fst) refs)
|
||||||
_ -> nubRefs refs
|
_ -> nubRefs refs
|
||||||
|
getreflog rs = inRepo $ Git.RefLog.getMulti rs
|
||||||
|
|
||||||
{- Runs an action on keys referenced in the given Git reference which
|
{- Runs an action on keys referenced in the given Git reference which
|
||||||
- differ from those referenced in the work tree. -}
|
- differ from those referenced in the work tree. -}
|
||||||
|
|
|
@ -14,18 +14,17 @@ import Git.Sha
|
||||||
|
|
||||||
{- Gets the reflog for a given branch. -}
|
{- Gets the reflog for a given branch. -}
|
||||||
get :: Branch -> Repo -> IO [Sha]
|
get :: Branch -> Repo -> IO [Sha]
|
||||||
get b = get' [] (Just b)
|
get b = getMulti [b]
|
||||||
|
|
||||||
{- Gets all reflogs for all branches. -}
|
{- Gets reflogs for multiple branches. -}
|
||||||
getAll :: Repo -> IO [Sha]
|
getMulti :: [Branch] -> Repo -> IO [Sha]
|
||||||
getAll = get' [Param "--all"] Nothing
|
getMulti bs = get' (map (Param . fromRef) bs)
|
||||||
|
|
||||||
get' :: [CommandParam] -> Maybe Branch -> Repo -> IO [Sha]
|
get' :: [CommandParam] -> Repo -> IO [Sha]
|
||||||
get' ps b = mapMaybe extractSha . lines <$$> pipeReadStrict ps'
|
get' ps = mapMaybe extractSha . lines <$$> pipeReadStrict ps'
|
||||||
where
|
where
|
||||||
ps' = catMaybes
|
ps' = catMaybes
|
||||||
[ Just $ Param "log"
|
[ Just $ Param "log"
|
||||||
, Just $ Param "-g"
|
, Just $ Param "-g"
|
||||||
, Just $ Param "--format=%H"
|
, Just $ Param "--format=%H"
|
||||||
, Param . fromRef <$> b
|
|
||||||
] ++ ps
|
] ++ ps
|
||||||
|
|
Loading…
Reference in a new issue