Sped up git-annex init in a clone of an existing repository

Seems that hasOrigin was never finding origin's git-annex branch, so a new
one got created each time. And so then it later needed to merge the two
branches, which is expensive.

Added --no-track to git branch to avoid it displaying a message about
setting up tracking branches. Of course there's no reason to make the
git-annex branch a tracking branch since git-annex auto-merges it.
This commit is contained in:
Joey Hess 2021-03-23 15:22:51 -04:00
parent 798f685077
commit 5d78cd9d08
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 19 additions and 3 deletions

View file

@ -89,7 +89,7 @@ fullname = Git.Ref $ "refs/heads/" <> fromRef' name
{- Branch's name in origin. -}
originname :: Git.Ref
originname = Git.Ref $ "origin/" <> fromRef' name
originname = Git.Ref $ "refs/remotes/origin/" <> fromRef' name
{- Does origin/git-annex exist? -}
hasOrigin :: Annex Bool
@ -114,7 +114,11 @@ getBranch = maybe (hasOrigin >>= go >>= use) return =<< branchsha
where
go True = do
inRepo $ Git.Command.run
[Param "branch", Param $ fromRef name, Param $ fromRef originname]
[ Param "branch"
, Param "--no-track"
, Param $ fromRef name
, Param $ fromRef originname
]
fromMaybe (error $ "failed to create " ++ fromRef name)
<$> branchsha
go False = withIndex' True $ do

View file

@ -23,6 +23,7 @@ git-annex (8.20210311) UNRELEASED; urgency=medium
operating on keys.
* New annex.supportunlocked config that can be set to false to avoid
some expensive things needed to support unlocked files.
* Sped up git-annex init in a clone of an existing repository.
-- Joey Hess <id@joeyh.name> Fri, 12 Mar 2021 12:06:37 -0400

View file

@ -84,7 +84,8 @@ dateRef r (RefDate d) = Ref $ fromRef' r <> "@" <> encodeBS' d
fileFromRef :: Ref -> RawFilePath -> Ref
fileFromRef r f = let (Ref fr) = fileRef f in Ref (fromRef' r <> fr)
{- Checks if a ref exists. -}
{- Checks if a ref exists. Note that it must be fully qualified,
- eg refs/heads/master rather than master. -}
exists :: Ref -> Repo -> IO Bool
exists ref = runBool
[ Param "show-ref"

View file

@ -0,0 +1,10 @@
[[!comment format=mdwn
username="joey"
subject="""comment 6"""
date="2021-03-23T19:15:23Z"
content="""
Found a way to speed up git-annex init's setup of the git-annex branch when
run in a clone of an existing repo. In a 100,000 file repo, it improved
from 17s to 10s. I have a feeling that might have been what was really
making it seem slow to you.
"""]]