use GIT keys for export of non-annexed files
This solves the problem that import of such files gets confused and converts them back to annexed files. The import code already used GIT keys internally when it determined a file should not be annexed. So now when it sees a GIT key that export used, it already does the right thing. This also means that even older version of git-annex can import and will do the right thing, once a fixed version has exported. Still, there may be other complications around upgrades; still need to think it all through. Moved gitShaKey and keyGitSha from Key to Annex.Export since they're only used for export/import. Documented GIT keys in backends, since they do appear in the git-annex branch now. This commit was sponsored by Graham Spencer on Patreon.
This commit is contained in:
parent
deac6f12b5
commit
fc61915230
6 changed files with 80 additions and 88 deletions
20
Key.hs
20
Key.hs
|
@ -23,8 +23,6 @@ module Key (
|
|||
nonChunkKey,
|
||||
chunkKeyOffset,
|
||||
isChunkKey,
|
||||
gitShaKey,
|
||||
keyGitSha,
|
||||
isKeyPrefix,
|
||||
splitKeyNameExtension,
|
||||
|
||||
|
@ -37,7 +35,6 @@ import qualified Data.Attoparsec.ByteString as A
|
|||
|
||||
import Common
|
||||
import Types.Key
|
||||
import Git.Types
|
||||
import Utility.QuickCheck
|
||||
import Utility.Bloom
|
||||
import Utility.Aeson
|
||||
|
@ -61,23 +58,6 @@ chunkKeyOffset k = (*)
|
|||
isChunkKey :: Key -> Bool
|
||||
isChunkKey k = isJust (fromKey keyChunkSize k) && isJust (fromKey keyChunkNum k)
|
||||
|
||||
-- Encodes a git sha as a key.
|
||||
--
|
||||
-- This is not the same as a SHA1 key, because the mapping needs to be
|
||||
-- bijective, also because git may not always use SHA1.
|
||||
gitShaKey :: Sha -> Key
|
||||
gitShaKey (Ref s) = mkKey $ \kd -> kd
|
||||
{ keyName = s
|
||||
, keyVariety = OtherKey "GIT"
|
||||
}
|
||||
|
||||
-- Reverse of gitShaKey
|
||||
keyGitSha :: Key -> Maybe Sha
|
||||
keyGitSha k
|
||||
| fromKey keyVariety k == OtherKey "GIT" =
|
||||
Just (Ref (fromKey keyName k))
|
||||
| otherwise = Nothing
|
||||
|
||||
serializeKey :: Key -> String
|
||||
serializeKey = decodeBS' . serializeKey'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue