smudge: check for known annexed inodes before checking annex.largefiles
smudge: Fix a case where an unlocked annexed file that annex.largefiles does not match could get its unchanged content checked into git, due to git running the smudge filter unecessarily. When the file has the same inodecache as an already annexed file, we can assume that the user is not intending to change how it's stored in git. Note that checkunchangedgitfile already handled the inverse case, where the file was added to git previously. That goes further and actually sha1 hashes the new file and checks if it's the same hash in the index. It would be possible to generate a key for the file and see if it's the same as the old key, however that could be considerably more expensive than sha1 of a small file is, and it is not necessary for the case I have, at least, where the file is not modified or touched, and so its inode will match the cache. git-annex add was changed, when adding a small file, to remove the inode cache for it. This is necessary to keep the recipe in doc/tips/largefiles.mdwn for converting from annex to git working. It also avoids bugs/case_where_using_pathspec_with_git-commit_leaves_s.mdwn which the earlier try at this change introduced.
This commit is contained in:
parent
c60b66d442
commit
675556fd9a
5 changed files with 58 additions and 23 deletions
|
@ -22,6 +22,8 @@ import Git.FilePath
|
|||
import Config.GitConfig
|
||||
import Config.Smudge
|
||||
import Utility.OptParse
|
||||
import Utility.InodeCache
|
||||
import Annex.InodeSentinal
|
||||
import qualified Utility.RawFilePath as R
|
||||
|
||||
cmd :: Command
|
||||
|
@ -129,13 +131,24 @@ data SmallOrLarge = Small | Large
|
|||
addFile :: SmallOrLarge -> CheckGitIgnore -> RawFilePath -> Annex Bool
|
||||
addFile smallorlarge ci file = do
|
||||
ps <- gitAddParams ci
|
||||
cps <- case smallorlarge of
|
||||
-- In case the file is being converted from an annexed file
|
||||
-- to be stored in git, remove the cached inode, so that
|
||||
-- if the smudge clean filter later runs on the file,
|
||||
-- it will not remember it was annexed.
|
||||
--
|
||||
-- The use of bypassSmudgeConfig prevents the smudge
|
||||
-- filter from being run. So the changes to the database
|
||||
-- can be queued up and not flushed to disk immediately.
|
||||
Small -> do
|
||||
withTSDelta (liftIO . genInodeCache file) >>= \case
|
||||
Just ic -> Database.Keys.removeInodeCache ic
|
||||
Nothing -> return ()
|
||||
return bypassSmudgeConfig
|
||||
Large -> return []
|
||||
Annex.Queue.addCommand cps "add" (ps++[Param "--"])
|
||||
[fromRawFilePath file]
|
||||
return True
|
||||
where
|
||||
cps = case smallorlarge of
|
||||
Large -> []
|
||||
Small -> bypassSmudgeConfig
|
||||
|
||||
start :: AddOptions -> SeekInput -> RawFilePath -> AddUnlockedMatcher -> CommandStart
|
||||
start o si file addunlockedmatcher = do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue