automatic conflict resolution for v6 unlocked files
Several tricky parts: * When the conflict is just between the same key being locked and unlocked, the unlocked version wins, and the file is not renamed in this case. * Need to update associated file map when conflict resolution renames an unlocked file. * git merge runs the smudge filter on the conflicting file, and actually overwrites the file with the same content it had before, and so invalidates its inode cache. This makes it difficult to know when it's safe to remove such files as conflict cruft, without going so far as to compare their entire contents. Dealt with this by preventing the smudge filter from populating the file when a merge is run. However, that also prevents the smudge filter being run for non-conflicting files, so eg moving a file won't put its new content into place. * Ideally, if a merge or a merge conflict resolution renames an unlocked file, the file in the work tree can just be moved, rather than copying the content to a new worktree file. This is attempted to be done in merge conflict resolution, but due to git merge's behavior of running smudge filters, what actually seems to happen is the old worktree file with the content is deleted and rewritten as a pointer file, so doesn't get reused. So, this is probably not as efficient as it optimally could be. If that becomes a problem, could look into running the merge in a separate worktree and updating the real worktree more efficiently, similarly to the direct mode merge. However, the direct mode merge had a lot of bugs, and I'd rather not use that more error-prone method unless really needed.
This commit is contained in:
parent
bcdc6db2c3
commit
b6b34f4916
4 changed files with 145 additions and 54 deletions
|
@ -19,6 +19,9 @@ import Utility.InodeCache
|
|||
import Types.KeySource
|
||||
import Backend
|
||||
import Logs.Location
|
||||
import Annex.Index (addGitEnv)
|
||||
import Utility.Env
|
||||
import qualified Git
|
||||
import qualified Database.Keys
|
||||
|
||||
import qualified Data.ByteString.Lazy as B
|
||||
|
@ -56,7 +59,7 @@ smudge file = do
|
|||
-- don't provide such modified content as it
|
||||
-- will be confusing. inAnnex will detect such
|
||||
-- modifications.
|
||||
ifM (inAnnex k)
|
||||
ifM ((not <$> smudgeDisabled) <&&> inAnnex k)
|
||||
( do
|
||||
content <- calcRepo (gitAnnexLocation k)
|
||||
liftIO $ B.putStr . fromMaybe b
|
||||
|
@ -66,6 +69,16 @@ smudge file = do
|
|||
Database.Keys.addAssociatedFile k file
|
||||
stop
|
||||
|
||||
-- Environment variable to disable smudging providing the content of keys.
|
||||
smudgeDisabled :: Annex Bool
|
||||
smudgeDisabled = liftIO $ isJust <$> getEnv smudgeDisableEnv
|
||||
|
||||
smudgeDisableEnv :: String
|
||||
smudgeDisableEnv = "ANNEX_SMUDGE_DISABLE"
|
||||
|
||||
withSmudgeDisabled :: (Git.Repo -> IO a) -> Annex a
|
||||
withSmudgeDisabled a = inRepo $ \r -> addGitEnv r smudgeDisableEnv "1" >>= a
|
||||
|
||||
-- Clean filter is fed file content on stdin, decides if a file
|
||||
-- should be stored in the annex, and outputs a pointer to its
|
||||
-- injested content.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue