check headRef not Branch.current

Support running v7 upgrade in a repo where there is no branch checked out,
but HEAD is set directly to some other ref.

This commit was sponsored by Jack Hill on Patreon.
This commit is contained in:
Joey Hess 2019-07-16 12:36:29 -04:00
parent 8028f14957
commit 7be690f326
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 27 additions and 2 deletions

View file

@ -73,13 +73,13 @@ ifAnnexed file yes no = maybe no yes =<< lookupFile file
-
- This is expensive, and so normally the associated files are updated
- incrementally when changes are noticed. So, this only needs to be done
- when initializing/upgrading a v6 mode repository.
- when initializing/upgrading a v6+ mode repository.
-
- Also, the content for the unlocked file may already be present as
- an annex object. If so, make the unlocked file use that content.
-}
scanUnlockedFiles :: Annex ()
scanUnlockedFiles = whenM (isJust <$> inRepo Git.Branch.current) $ do
scanUnlockedFiles = whenM (inRepo $ Git.Ref.exists Git.Ref.headRef) $ do
showSideAction "scanning for unlocked files"
Database.Keys.runWriter $
liftIO . Database.Keys.SQL.dropAllAssociatedFiles

View file

@ -6,6 +6,8 @@ git-annex (7.20190709) UNRELEASED; urgency=medium
parsing.
* Add BLAKE2BP512 and BLAKE2BP512E backends, using a blake2 variant
optimised for 4-way CPUs.
* Support running v7 upgrade in a repo where there is no branch checked
out, but HEAD is set directly to some other ref.
-- Joey Hess <id@joeyh.name> Mon, 08 Jul 2019 08:59:54 -0400

View file

@ -54,3 +54,5 @@ as you can see the arg-test.sim is only 68 bytes, not 2MB or a symlink.
[[!meta author=yoh]]
> [[fixed|done]] --[[Joey]]

View file

@ -0,0 +1,21 @@
[[!comment format=mdwn
username="joey"
subject="""comment 3"""
date="2019-07-16T16:13:49Z"
content="""
I notice that the keys database is not populated in the clone.
Also, the upgrade does not display "scanning for unlocked files".
And in Annex.WorkTree, we can see why:
scanUnlockedFiles = whenM (isJust <$> inRepo Git.Branch.current) $ do
showSideAction "scanning for unlocked files"
There is no current git branch in this case.
That check was added in [[!commit 9b995954731e05727d77c7bff487af10da9cb4b9]]
"only do scan when there's a branch, not in freshly created new repo"
Since it does a ls-tree of HEAD, what it really ought to check for is that
HEAD is set, which it's not in a fresh new repo. Done.
"""]]