adjust: Fix some bad behavior when unlocked files use URL keys.
authorJoey Hess <joeyh@joeyh.name>
Mon, 25 Jan 2021 21:25:42 +0000 (17:25 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 25 Jan 2021 21:25:42 +0000 (17:25 -0400)
This avoids the smudge --clean filter failing on the URL keys.

git checkout runs the post-checkout hook, which runs smudge --update.
That populates all the pointer files, but it neglected to store their inode
caches in the keys db. With that done, and the keys db flushed before
smudge --clean gets run (by restagePointerFile), the isUnmodifiedCheap
check can tell the file is not modified, so will not try to re-ingest it,
which does not work with URL keys because they do not support genKey.

It also seems possible that the isUnmodifiedCheap was also failing for
non-URL keys, which would cause them to be re-ingested, leading to a lot of
extra work. I have not verified that, but don't see why it wouldn't have
happened. So this probably also speeds up checking out adjusted branches.

This commit was sponsored by Boyd Stephen Smith Jr. on Patreon.

Annex/Link.hs
CHANGELOG
Command/Smudge.hs

index d7353d78894a953abf03fff2ab228a4276e24492..5b840bf7305af2a66e47c9d081eedbd42a400e6c 100644 (file)
@@ -35,6 +35,7 @@ import Utility.FileMode
 import Utility.InodeCache
 import Utility.Tmp.Dir
 import Utility.CopyFile
+import qualified Database.Keys.Handle
 import qualified Utility.RawFilePath as R
 
 import qualified Data.ByteString as S
@@ -202,6 +203,8 @@ restagePointerFile (Restage True) f orig = withTSDelta $ \tsd ->
        -- updated index file.
        runner :: Git.Queue.InternalActionRunner Annex
        runner = Git.Queue.InternalActionRunner "restagePointerFile" $ \r l -> do
+               liftIO . Database.Keys.Handle.flushDbQueue
+                       =<< Annex.getState Annex.keysdbhandle
                realindex <- liftIO $ Git.Index.currentIndexFile r
                let lock = fromRawFilePath (Git.Index.indexFileLock realindex)
                    lockindex = liftIO $ catchMaybeIO $ Git.LockFile.openLock' lock
index ef2a84fc7843a668a99d8646f9818998b00b2415..b91d85abe2e6affcd820ddd025f4420a3893c526 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -36,6 +36,7 @@ git-annex (8.20201130) UNRELEASED; urgency=medium
   * Fix a bug that prevented git-annex init from working in a submodule.
   * Fix a bug in view filename generation when a metadata value ended with
     "/" (or ":" or "\" on Windows)
+  * adjust: Fix some bad behavior when unlocked files use URL keys.
 
  -- Joey Hess <id@joeyh.name>  Mon, 04 Jan 2021 12:52:41 -0400
 
index ebf041018ae4d7a0ee16035137e1ed69f7fa72a5..62868796347c1c882b263087ce3d0ee37aa545d5 100644 (file)
@@ -255,8 +255,9 @@ updateSmudged restage = streamSmudged $ \k topf -> do
        f <- fromRepo (fromTopFilePath topf)
        whenM (inAnnex k) $ do
                obj <- calcRepo (gitAnnexLocation k)
-               unlessM (isJust <$> populatePointerFile restage k obj f) $
-                       liftIO (isPointerFile f) >>= \case
+               populatePointerFile restage k obj f >>= \case
+                       Just ic -> Database.Keys.addInodeCaches k [ic]
+                       Nothing -> liftIO (isPointerFile f) >>= \case
                                Just k' | k' == k -> toplevelWarning False $
                                        "unable to populate worktree file " ++ fromRawFilePath f
                                _ -> noop