I'm using version 10.20230321-gb624394c7 on Arch Linux and BTRFS. I'd love to have the directory special remote using cp --reflink=auto to export to a directory on the same file system.

My use case is using syncthing as a way to export (parts of my repo) to my phone. I'm deliberately not using adb as this needs my phone to be connected to the computer somehow. I basically want to do what's described on syncthing special remote under “Copying objects”.

The main drawback, as also noted in the linked document, is that all files are duplicated. As I'm using BTRFS it would really help if the export were to use cp --reflink=auto instead of its own copying mechanism. I've read here that you suggested (albeit 7 years ago) using a shared clone instead. However, this does not work for me as syncthing does not synchronize symlinks to Android (they are ignored even if they point to something). (Trying with a shared repo and adjust --unlock-present gives merge problems when dropping files from the directory.)

Nearly two years ago, you wrote here that you “Implemented CoW for directory special remote, comprehensively”. It seems to me that this is only true for importing files which, as I checked, actually uses cow.

Since I want to manage relatively many files of decent size (music, audio books, pictures, videos / movies) it would be much better if the tree export would also use reflink. Maybe having this as an option, for the cost of not having a nice progress bar, would be something worth considering.

A test script to show that an export does indeed use cow is the following:

mkdir export import
git init repo
cd repo
git annex init
git annex initremote import type=directory directory=../import encryption=none importtree=yes
git annex initremote export type=directory directory=../export encryption=none exporttree=yes
git config remote.import.annex-tracking-branch main
git config remote.export.annex-tracking-branch main

for i in {1..100}; do
    dd if=/dev/urandom bs=1M count=10 of=../import/file$i
done

git annex sync --content

After running, a btrfs filesystem du ... tells me that the repo and import files point to the same file, whereas export does not.


In general: Thank you so much for this wonderful piece of software, I'm using it for years now and manage virtually everything with it (audio, video, pictures, important documents, papers, …).

fixed --Joey