Please describe the problem.

background: I'm trying to use git-annex to manage tracking/off-site replication of a borgbackup repository. This requires direct access to files, and it's not feasible for me to operate without annex.thin set. I'm trying to workaround some of borg's inconvenient behavior--sometimes, a borg transaction will do something that is effectively just a file rename, but internally, it truncates+deletes the original file and creates a new file with the old content. This leads to annex adding the "new" file as a reference to known content, but that content was already lost. (maybe) MWE below

What steps will reproduce the problem?

set -x && \
mkdir tmp && cd tmp && \
git init && \
git-annex init  --version 7 base && \
git-annex config --set annex.thin true && \
\
echo "bar">foo && cat foo && git-annex add foo && ls -l && git-annex unlock foo && git-annex sync && \
truncate -s 0 foo && rm foo && git-annex sync && \
\
echo "bar">ffoo && cat ffoo && git-annex add ffoo && ls -l && git-annex unlock ffoo && git-annex sync && \
cat ffoo && git-annex whereis && git-annex fsck

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

# git-annex version
git-annex version: 7.20190129+git78-g3fa6be1fe-1~ndall+1
build flags: Assistant Webapp Pairing S3(multipartupload)(storageclasses) WebDAV Inotify DBus DesktopNotify TorrentParser MagicMime Feeds Testsuite
dependency versions: aws-0.20 bloomfilter-2.0.1.0 cryptonite-0.25 DAV-1.3.3 feed-1.0.0.0 ghc-8.4.4 http-client-0.5.13.1 persistent-sqlite-2.8.2 torrent-10000.1.1 uuid-1.3.13 yesod-1.6.0
key/value backends: SHA256E SHA256 SHA512E SHA512 SHA224E SHA224 SHA384E SHA384 SHA3_256E SHA3_256 SHA3_512E SHA3_512 SHA3_224E SHA3_224 SHA3_384E SHA3_384 SKEIN256E SKEIN256 SKEIN512E SKEIN512 BLAKE2B256E BLAKE2B256 BLAKE2B512E BLAKE2B512 BLAKE2B160E BLAKE2B160 BLAKE2B224E BLAKE2B224 BLAKE2B384E BLAKE2B384 BLAKE2S256E BLAKE2S256 BLAKE2S160E BLAKE2S160 BLAKE2S224E BLAKE2S224 BLAKE2SP256E BLAKE2SP256 BLAKE2SP224E BLAKE2SP224 SHA1E SHA1 MD5E MD5 WORM URL
remote types: git gcrypt p2p S3 bup directory rsync web bittorrent webdav adb tahoe glacier ddar hook external
operating system: linux x86_64
supported repository versions: 5 7
upgrade supported from repository versions: 0 1 2 3 4 5 6

# lsb_release -a
LSB Version:    core-9.20170808ubuntu1-noarch:printing-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: LinuxMint
Description:    Linux Mint 19 Tara
Release:    19
Codename:   tara

Please provide any additional information below.

# If you can, paste a complete transcript of the problem occurring here.
# If the problem is with the git-annex assistant, paste in .git/annex/daemon.log
+ mkdir tmp
+ cd tmp
+ git init
Initialized empty Git repository in /home/user/tmp/.git/
+ git-annex init --version 7 base
init base ok
(recording state in git...)
+ git-annex config --set annex.thin true
annex.thin true ok
(recording state in git...)
+ echo bar
+ cat foo
bar
+ git-annex add foo
add foo ok
(recording state in git...)
+ ls -l
total 4
lrwxrwxrwx 1 root root 178 Feb 23 13:34 foo -> .git/annex/objects/g7/9v/SHA256E-s4--7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730/SHA256E-s4--7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730
+ git-annex unlock foo
unlock foo ok
(recording state in git...)
+ git-annex sync
commit 
[master (root-commit) eebbbb5] git-annex in base
 1 file changed, 1 insertion(+)
 create mode 100644 foo
ok
+ truncate -s 0 foo
+ rm foo
+ git-annex sync
commit 
[master d043022] git-annex in base
 1 file changed, 1 deletion(-)
 delete mode 100644 foo
ok
+ echo bar
+ cat ffoo
bar
+ git-annex add ffoo #content is discarded here
add ffoo ok
(recording state in git...)
+ cat ffoo
+ ls -l
total 4
lrwxrwxrwx 1 root root 178 Feb 23 13:34 ffoo -> .git/annex/objects/g7/9v/SHA256E-s4--7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730/SHA256E-s4--7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730
+ git-annex unlock ffoo
unlock ffoo ok
(recording state in git...)
+ git-annex sync
commit 
[master fbc08bc] git-annex in base
 1 file changed, 1 insertion(+)
 create mode 100644 ffoo
ok
+ cat ffoo
/annex/objects/SHA256E-s4--7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730
+ git-annex whereis
whereis ffoo (1 copy) 
    e470821b-a101-4acc-91ac-a0ae5d3aa40d -- base [here]
ok
+ git-annex fsck
fsck ffoo ok
(recording state in git...)


# End of transcript or log.

Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)

I'm hopeful! But just getting started :(

git-annex fsck made to detect and clean up after this, which I consider sufficient, so done --Joey