avoid running scanUnlockedFiles in bare repo

It's not necessary. And if the bare repo somehow has a pointer
file in it with the same name as a file in HEAD, that file would be
populated, which would be surprising since the file is not really under
git's control.
This commit is contained in:
Joey Hess 2019-11-21 14:31:12 -04:00
parent f39e5a4219
commit 740e0ddbfe
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 4 additions and 3 deletions

View file

@ -108,9 +108,9 @@ initialize' mversion = checkCanInitialize $ do
unlessM (isJust <$> getVersion) $
setVersion (fromMaybe defaultVersion mversion)
configureSmudgeFilter
unlessM isBareRepo $ do
showSideAction "scanning for unlocked files"
scanUnlockedFiles
unlessM isBareRepo $ do
hookWrite postCheckoutHook
hookWrite postMergeHook
AdjustedBranch.checkAdjustedClone >>= \case

View file

@ -22,6 +22,7 @@ import qualified Git.Types
import Database.Types
import qualified Database.Keys
import qualified Database.Keys.SQL
import Config
{- Looks up the key corresponding to an annexed file in the work tree,
- by examining what the file links to.
@ -75,7 +76,7 @@ ifAnnexed file yes no = maybe no yes =<< lookupFile file
- as-is.
-}
scanUnlockedFiles :: Annex ()
scanUnlockedFiles = whenM (inRepo Git.Ref.headExists) $ do
scanUnlockedFiles = whenM (inRepo Git.Ref.headExists <&&> not <$> isBareRepo) $ do
Database.Keys.runWriter $
liftIO . Database.Keys.SQL.dropAllAssociatedFiles
(l, cleanup) <- inRepo $ Git.LsTree.lsTree Git.LsTree.LsTreeRecursive Git.Ref.headRef