## # systr_rsync_normal [] # # Perform normal rsync operations to transfer files to or from the # repository. If 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 # # Copy files from to , but only if they've changed # since the state in . Empty directories are # purged from 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 # # Delete files in , only if they have been deleted from # to . Deleted files in are 'backed up', # in rsync lingo, meaning they are actually renamed with a # suffix appended to the original filename. # # If 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 # # Finish setting up a merge, by copying files from the # temporary directory to the merge staging directory. # # Files in 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" } ## # systrunk clone # # Recursively create a complete copy of a directory tree # which, presumabally, contains systrunk repositories. # This copy preserves all underlying hard-links as to # preserve the disk space saved by systrunk commit. Note: # --delete is passed to rsync! ## function systr_clone { if [ $# -lt 2 ]; then echo "Fatal: too few args to clone" >&2 exit 1 fi src="$1" dst="$2" rsync -azH --info=progress2 --info=stats2 --delete "$src" "$dst" }