speed up init

This was making it git checkout master when that branch was already
checked out, for apparently no good reason at all. In a 100,000 file
repo, that takes about 1 second.

Note, I'm not sure why it checks out the branch in the Nothing case, so
I left that alone.
This commit is contained in:
Joey Hess 2021-03-23 15:43:42 -04:00
parent 5d78cd9d08
commit 1e3b228154
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -70,11 +70,12 @@ switchHEADBack = maybe noop switch =<< inRepo Git.Branch.currentUnsafe
let orighead = fromDirectBranch currhead
inRepo (Git.Ref.sha currhead) >>= \case
Just headsha
| orighead /= currhead -> do
| orighead == currhead -> noop
| otherwise -> do
inRepo $ Git.Branch.update "leaving direct mode" orighead headsha
inRepo $ Git.Branch.checkout orighead
inRepo $ Git.Branch.delete currhead
_ -> inRepo $ Git.Branch.checkout orighead
Nothing -> inRepo $ Git.Branch.checkout orighead
{- Absolute FilePaths of Files in the tree that are associated with a key. -}
associatedFiles :: Key -> Annex [FilePath]