Please describe the problem.

spent quite some time trying to figure out WTF I got some files not published due to tag being set... managed to reproduce in minimal setup -- if I set metadata to a file, rename a file (mv, git add; or even git mv), and add another file with different content but the same name -- it would obtain metadata of original key/file (unless I commit right after rename)

What steps will reproduce the problem?

see below

What version of git-annex are you using? On what operating system?

6.20170924+gitgd35053009-1~ndall+1

Please provide any additional information below.

$> sudo rm -rf /tmp/repo; mkdir /tmp/repo; cd /tmp/repo; git init; git annex init; echo 1 >| 1; git annex add 1; git commit -m 'added 1'; git annex metadata -s tag=value 1; git mv 1 2; git annex add 2; echo 2>1; git annex add 1; for f in 1 2; do echo "file $f"; ls -l $f; git annex metadata -g tag $f; done                                                                                                                          
Initialized empty Git repository in /tmp/repo/.git/
init  ok
(recording state in git...)
add 1 ok
(recording state in git...)
[master (root-commit) 750d619] added 1
 1 file changed, 1 insertion(+)
 create mode 120000 1
metadata 1 
  lastchanged=2017-09-26@17-59-22
  tag=value
  tag-lastchanged=2017-09-26@17-59-22
ok
(recording state in git...)

add 1 ok
(recording state in git...)
file 1
lrwxrwxrwx 1 yoh yoh 178 Sep 26 13:59 1 -> .git/annex/objects/pX/ZJ/SHA256E-s0--e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855/SHA256E-s0--e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
value
file 2
lrwxrwxrwx 1 yoh yoh 178 Sep 26 13:59 2 -> .git/annex/objects/2W/V5/SHA256E-s2--4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865/SHA256E-s2--4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865
value

you can see in above taht 1 and 2 have different content/keys, but they both acquire the same tag=value. If I commit 2 after it being renamed from 1, it is ok.

closing because I added a warning about the metadata copying, and that seems sufficient for users to understand why this happens. --Joey