From: Joey Hess Date: Fri, 30 Jul 2021 22:36:03 +0000 (-0400) Subject: work around strange auto-init bug X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~91^2~8 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b3c4579c7907147a496bdf2c73b42238d8b239d6;p=git-annex.git work around strange auto-init bug git-annex get when run as the first git-annex command in a new repo did not populate unlocked files. (Reversion in version 8.20210621) I am not entirely happy with this, because I don't understand how 428c91606b434512d1986622e751c795edf4df44 caused the problem in the first place, and I don't fully understand how skipping calling scanAnnexedFiles during autoinit avoids the problem. Kept the explicit call to scanAnnexedFiles during git-annex init, so that when reconcileStaged is expensive, it can be made to run then, rather than at some later point when the information is needed. Sponsored-by: Brock Spratlen on Patreon --- diff --git a/Annex/Init.hs b/Annex/Init.hs index adbee09333..7bfd13b118 100644 --- a/Annex/Init.hs +++ b/Annex/Init.hs @@ -96,8 +96,8 @@ genDescription Nothing = do Right username -> [username, at, hostname, ":", reldir] Left _ -> [hostname, ":", reldir] -initialize :: Maybe String -> Maybe RepoVersion -> Annex () -initialize mdescription mversion = checkInitializeAllowed $ do +initialize :: Bool -> Maybe String -> Maybe RepoVersion -> Annex () +initialize autoinit mdescription mversion = checkInitializeAllowed $ do {- Has to come before any commits are made as the shared - clone heuristic expects no local objects. -} sharedclone <- checkSharedClone @@ -107,10 +107,10 @@ initialize mdescription mversion = checkInitializeAllowed $ do ensureCommit $ Annex.Branch.create prepUUID - initialize' mversion + initialize' autoinit mversion initSharedClone sharedclone - + u <- getUUID {- Avoid overwriting existing description with a default - description. -} @@ -119,8 +119,8 @@ initialize mdescription mversion = checkInitializeAllowed $ do -- Everything except for uuid setup, shared clone setup, and initial -- description. -initialize' :: Maybe RepoVersion -> Annex () -initialize' mversion = checkInitializeAllowed $ do +initialize' :: Bool -> Maybe RepoVersion -> Annex () +initialize' autoinit mversion = checkInitializeAllowed $ do checkLockSupport checkFifoSupport checkCrippledFileSystem @@ -135,9 +135,11 @@ initialize' mversion = checkInitializeAllowed $ do then configureSmudgeFilter else deconfigureSmudgeFilter unlessM isBareRepo $ do - scanAnnexedFiles hookWrite postCheckoutHook hookWrite postMergeHook + unless autoinit $ + scanAnnexedFiles + AdjustedBranch.checkAdjustedClone >>= \case AdjustedBranch.InAdjustedClone -> return () AdjustedBranch.NotInAdjustedClone -> @@ -198,7 +200,7 @@ ensureInitialized = getInitializedVersion >>= maybe needsinit checkUpgrade where needsinit = ifM autoInitializeAllowed ( do - initialize Nothing Nothing + initialize True Nothing Nothing autoEnableSpecialRemotes , giveup "First run: git-annex init" ) @@ -232,7 +234,7 @@ autoInitialize = getInitializedVersion >>= maybe needsinit checkUpgrade where needsinit = whenM (initializeAllowed <&&> autoInitializeAllowed) $ do - initialize Nothing Nothing + initialize True Nothing Nothing autoEnableSpecialRemotes {- Checks if a repository is initialized. Does not check version for ugrade. -} diff --git a/Annex/WorkTree.hs b/Annex/WorkTree.hs index 7bb4b9fe00..d7e423c6e8 100644 --- a/Annex/WorkTree.hs +++ b/Annex/WorkTree.hs @@ -58,10 +58,10 @@ ifAnnexed file yes no = maybe no yes =<< lookupKey file - Normally the keys database is updated incrementally when it's being - opened, and changes are noticed. Calling this explicitly allows - running the update at an earlier point. + - + - All that needs to be done is to open the database, + - that will result in Database.Keys.reconcileStaged + - running, and doing the work. -} scanAnnexedFiles :: Annex () -scanAnnexedFiles = - -- All that needs to be done is to open the database, - -- that will result in Database.Keys.reconcileStaged - -- running, and doing the work. - Database.Keys.runWriter (const noop) +scanAnnexedFiles = Database.Keys.runWriter (const noop) diff --git a/Assistant/MakeRepo.hs b/Assistant/MakeRepo.hs index 10f7628743..8132dbca53 100644 --- a/Assistant/MakeRepo.hs +++ b/Assistant/MakeRepo.hs @@ -85,7 +85,7 @@ initRepo False _ dir desc mgroup = inDir dir $ do initRepo' :: Maybe String -> Maybe StandardGroup -> Annex () initRepo' desc mgroup = unlessM isInitialized $ do - initialize desc Nothing + initialize False desc Nothing u <- getUUID maybe noop (defaultStandardGroup u) mgroup {- Ensure branch gets committed right away so it is diff --git a/CHANGELOG b/CHANGELOG index 44d25e8e77..7f00a83819 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,9 @@ git-annex (8.20210715) UNRELEASED; urgency=medium in a repository that was upgraded from v7. * fsck: Detect and correct stale or missing inode caches. * Fix a rounding bug in display of data sizes. + * git-annex get when run as the first git-annex command in a new repo + did not populate unlocked files. + (Reversion in version 8.20210621) -- Joey Hess Wed, 14 Jul 2021 14:26:36 -0400 diff --git a/Command/ConfigList.hs b/Command/ConfigList.hs index bb33f7102b..d259b87409 100644 --- a/Command/ConfigList.hs +++ b/Command/ConfigList.hs @@ -47,7 +47,7 @@ findOrGenUUID = do else ifM (Annex.Branch.hasSibling <||> (isJust <$> Fields.getField Fields.autoInit)) ( do liftIO checkNotReadOnly - initialize Nothing Nothing + initialize True Nothing Nothing getUUID , return NoUUID ) diff --git a/Command/Init.hs b/Command/Init.hs index 179a21e046..d1a0169724 100644 --- a/Command/Init.hs +++ b/Command/Init.hs @@ -70,7 +70,7 @@ perform os = do Just v | v /= wantversion -> giveup $ "This repository is already a initialized with version " ++ show (fromRepoVersion v) ++ ", not changing to requested version." _ -> noop - initialize + initialize False (if null (initDesc os) then Nothing else Just (initDesc os)) (initVersion os) Annex.SpecialRemote.autoEnable diff --git a/Command/Reinit.hs b/Command/Reinit.hs index abf9b1cdaf..1b525cbd42 100644 --- a/Command/Reinit.hs +++ b/Command/Reinit.hs @@ -35,6 +35,6 @@ perform s = do then return $ toUUID s else Remote.nameToUUID s storeUUID u - initialize' Nothing + initialize' False Nothing Annex.SpecialRemote.autoEnable next $ return True diff --git a/Command/Upgrade.hs b/Command/Upgrade.hs index 77f569a15b..f2f05122fc 100644 --- a/Command/Upgrade.hs +++ b/Command/Upgrade.hs @@ -45,6 +45,6 @@ start (UpgradeOptions { autoOnly = True }) = start _ = starting "upgrade" (ActionItemOther Nothing) (SeekInput []) $ do whenM (isNothing <$> getVersion) $ do - initialize Nothing Nothing + initialize False Nothing Nothing r <- upgrade False latestVersion next $ return r diff --git a/doc/bugs/initial_get_of_unlocked_file_fails_to_populate_pointer.mdwn b/doc/bugs/initial_get_of_unlocked_file_fails_to_populate_pointer.mdwn index a3dd95ebf8..d2eea4c95d 100644 --- a/doc/bugs/initial_get_of_unlocked_file_fails_to_populate_pointer.mdwn +++ b/doc/bugs/initial_get_of_unlocked_file_fails_to_populate_pointer.mdwn @@ -6,4 +6,12 @@ If any other git-annex command is run before the get, it avoids the problem. So the problem has to do with autoinit followed by reading associated files from the keys db. -Besected to [[!commit 428c91606b434512d1986622e751c795edf4df44]] --[[Joey]] +Bisected to [[!commit 428c91606b434512d1986622e751c795edf4df44]] --[[Joey]] + +It seems that reconcileStaged is populating the +associated files, but later when they're queried, the query returns an +empty list. So something to do with database write caching. + +Somehow, not having init call `scanAnnexedFiles` makes this bug go away. + +> [[fixed|done]] --[[Joey]]