fix breakage caused by recent commit
authorJoey Hess <joeyh@joeyh.name>
Tue, 26 Jan 2021 01:19:07 +0000 (21:19 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 26 Jan 2021 01:22:18 +0000 (21:22 -0400)
34a535ebeaf483f6643f949ae774939650d74837 broke the test suite.
Getting a file started failing in one case, because the annex object did
not have its inode cached, so was not trusted to be unmodified.

This adds something very similar to what was added to linkAnnex
in commit 2e9341a47d437b5a7b14824d3e5b2864b059a850 -- if there are not
yet any inodes cached for a key, add the inode of the annex object when
adding the inode of the unlocked file.

Feels like this should be handled in a more principled way. How
do we know the addInodeCaches call in getMoveRaceRecovery just above
this change is currently correct? It doesn't add the annex object inode
cache. Ah well, maybe sometime when I've not had my entire evening eaten
by a reversion that the test suite caught as I was cooking dinner.

Command/Smudge.hs

index a092b6ad6814087449ccefe089173ccc5ed3f065..907958a15f555b25cc1cf55344e9443959baa815 100644 (file)
@@ -259,8 +259,13 @@ updateSmudged restage = streamSmudged $ \k topf -> do
        f <- fromRepo (fromTopFilePath topf)
        whenM (inAnnex k) $ do
                obj <- calcRepo (gitAnnexLocation k)
+               objic <- withTSDelta (liftIO . genInodeCache obj)
                populatePointerFile restage k obj f >>= \case
-                       Just ic -> Database.Keys.addInodeCaches k [ic]
+                       Just ic -> do
+                               cs <- Database.Keys.getInodeCaches k
+                               if null cs
+                                       then Database.Keys.addInodeCaches k (catMaybes [Just ic, objic])
+                                       else Database.Keys.addInodeCaches k [ic]
                        Nothing -> liftIO (isPointerFile f) >>= \case
                                Just k' | k' == k -> toplevelWarning False $
                                        "unable to populate worktree file " ++ fromRawFilePath f