I'm giving rsync multiple source directories, to make it merge several
directories into one.
By experiment (and reading --debug output), it seems that if a filename
appears in more than one source directory, the file in the
source named _earlier_ on the command line "wins".
Eg:
% mkdir -p dir1/sub dir2/sub
% echo first > dir1/sub/foo.txt
% echo second > dir2/sub/foo.txt
% rsync -r dir1/sub dir2/sub .
% cat sub/foo.txt
first
% rsync -r dir2/sub dir1/sub .
% cat sub/foo.txt
second
(I have rsync 3.1.1)
My question is whether I can rely on this behaviour not changing: it's a
little surprising, as it's the opposite of what (coreutils) 'cp -r'
does.
The closest thing I can find in the manpage is this text:
| Rsync always sorts the specified filenames into its internal transfer
| list. This handles the merging together of the contents of identically
| named directories, makes it easy to remove duplicate filenames, and
| may confuse someone when the files are transferred in a different
| order than what was given on the command-line.
That documents the order in which differently-named files are processed,
and suggests that letting rsync see duplicate filenames is supported,
but doesn't specify the priority of the 'candidates' for a given
named
file.
-M-