## # systr_rsync_normal <src> <dst> [<link>] # # Perform normal rsync operations to transfer files to or from the # repository. If <link> is set, it is used as the --link-dest value. ## function systr_rsync_normal { if [ $# -lt 2 ]; then echo "Fatal: too few args to rsync_normal" >&2 exit 1 fi src="$1" dst="$2" if [ $# -gt 2 ]; then link="--link-dest=$3" else link="" fi rsync -az --info=progress2 --info=stats2 --delete \ --exclude='*.systr' $link "$src" "$dst" } ## # systr_rsync_diff <src> <compare> <dst> # # Copy files from <src> to <dst>, but only if they've changed # since the state in <compare>. Empty directories are # purged from <dst> afterward. ## function systr_rsync_diff { if [ $# -lt 3 ]; then echo "Fatal: too few args to rsync_diff" >&2 exit 1 fi src="$1" compare="--compare-dest=$2" dst="$3" rsync -az --delete --exclude='*.systr' $compare \ "$src" "$dst" find "$dst" -type d -empty -delete } ## # systr_rsync_del <src> <compare> <dst> # # Delete files in <dst>, only if they have been deleted from # <compare> to <src>. Deleted files in <dst> are 'backed up', # in rsync lingo, meaning they are actually renamed with a # suffix appended to the original filename. # # If <src> is the worktree ("."), our file suffix will be # '&' to signify files deleted by us. Otherwise, the suffix # will be '~' to signify files deleted by 'them'. ## function systr_rsync_del { if [ $# -lt 3 ]; then echo "Fatal: too few args to rsync_del" >&2 exit 1 fi src="$1" compare="--compare-dest=$2" dst="$3" if [[ "$src" == "." ]]; then suffix="--suffix='&'" else suffix="--suffix='~'" fi rsync -azb $suffix --existing --ignore-existing \ --delete --exclude='*.systr' $compare \ "$src" "$dst" } ## # systr_rsync_merge <src> <dst> # # Finish setting up a merge, by copying files from the # temporary directory to the merge staging directory. # # Files in <dst> overwritten by this operation will # be suffixed with '*' to signify files modified by # both of us. ## function systr_rsync_merge { if [ $# -lt 2 ]; then echo "Fatal: too few args to rsync_merge" >&2 exit 1 fi src="$1" dst="$2" rsync -azb --suffix='*' --exclude='*.systr' \ "$src" "$dst" }