consistently use importKey when available

This avoids import with --no-content and with --content potentially
generating two different trees, leading to a merge conflict when run in
two different clones of a repo. And it's necessary groundwork to make
git-annex sync --no-content import from special remotes that support
importKey.

Only the directory special remote currently supports importKey, and it
generates the same key as git-annex usually does, so there is no
behavior change for it.

Future special remotes will need to take care when adding importKey,
if it generates different keys. Added some warnings about that to
comments.

This commit was sponsored by Noam Kremen on Patreon.
This commit is contained in:
Joey Hess 2020-09-28 15:03:15 -04:00
parent 15c1ee16d9
commit 3eaaec3113
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 84 additions and 49 deletions

View file

@ -186,7 +186,10 @@ support a request, it can reply with `UNSUPPORTED-REQUEST`.
rather than `EXPECTED`.
* `IMPORTKEY File`
This only needs to be implemented if IMPORTKEYSUPPORTED indicates
it is supported.
it is supported. And if a remote did not support it before, adding
it will make importing the same content as before generate a likely
different tree, which can lead to merge conflicts. So be careful
implementing this.
Generates a key by querying the remote for eg, a checksum.
(See [[internals/key_format]] for details of how to format a key.)
Any kind of key can be generated, depending on what the remote