# This program is distributable under the terms of the GNU GPL (see
# COPYING).
-# Test rsync handling of exclude/include directives.
+# Test rsync handling of exclude/include directives.
# Test some of the more obscure wildcard handling of exclude/include
# processing.
echo cvsin >"$fromdir/mid/for/one-in-one-out"
echo expunged >"$fromdir/mid/for/foo/extra"
echo retained >"$fromdir/mid/for/foo/keep"
-ln -s too "$fromdir/bar/down/to/foo/sym"
# Setup our test exclude/include files.
home-cvs-exclude
EOF
-# Create the chk dir with what we expect to be excluded
+# Start with a check of --prune-empty-dirs:
+$RSYNC -av -f -_foo/too/ -f -_foo/down/ -f -_foo/and/ -f -_new/ "$fromdir/" "$chkdir/"
+checkit "$RSYNC -av --prune-empty-dirs '$fromdir/' '$todir/'" "$chkdir" "$todir"
+rm -rf "$todir"
-checkit "$RSYNC -avv \"$fromdir/\" \"$chkdir/\"" "$fromdir" "$chkdir"
+# Add a directory symlink.
+ln -s too "$fromdir/bar/down/to/foo/sym"
+# Create chkdir with what we expect to be excluded.
+checkit "$RSYNC -avv '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
sleep 1 # Ensures that the rm commands will tweak the directory times.
-
rm -r "$chkdir"/foo/down
rm -r "$chkdir"/mid/for/foo/and
rm -r "$chkdir"/new/keep/this
# Now, test if rsync excludes the same files.
-checkit "$RSYNC -avv --exclude-from=\"$excl\" \
- --delete-during \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
+checkit "$RSYNC -avv --exclude-from='$excl' \
+ --delete-during '$fromdir/' '$todir/'" "$chkdir" "$todir"
# Modify the chk dir by removing cvs-ignored files and then tweaking the dir times.
# Now, test if rsync excludes the same files, this time with --cvs-exclude
# and --delete-excluded.
-checkit "$RSYNC -avvC --filter=\"merge $excl\" --delete-excluded \
- --delete-during \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
+checkit "$RSYNC -avvC --filter='merge $excl' --delete-excluded \
+ --delete-during '$fromdir/' '$todir/'" "$chkdir" "$todir"
# Modify the chk dir for our merge-exclude test and then tweak the dir times.
rm "$chkdir"/foo/file1
rm "$chkdir"/bar/down/to/bar/baz/*.deep
-cp -p "$fromdir"/bar/down/to/foo/*.junk "$chkdir"/bar/down/to/foo
-cp -p "$fromdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo
+cp_touch "$fromdir"/bar/down/to/foo/*.junk "$chkdir"/bar/down/to/foo
+cp_touch "$fromdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo
$RSYNC -av --existing -f 'show .filt*' -f 'hide,! */' --del "$fromdir/" "$todir/"
echo retained >"$todir"/bar/down/to/bar/baz/nodel.deep
-cp -p "$todir"/bar/down/to/bar/baz/nodel.deep "$chkdir"/bar/down/to/bar/baz
+cp_touch "$todir"/bar/down/to/bar/baz/nodel.deep "$chkdir"/bar/down/to/bar/baz
$RSYNC -av --existing --filter='-! */' "$fromdir/" "$chkdir/"
# Now, test if rsync excludes the same files, this time with a merge-exclude
# file.
-checkit "sed '/!/d' \"$excl\" |
+checkit "sed '/!/d' '$excl' |
$RSYNC -avv -f dir-merge_.filt -f merge_- \
- --delete-during \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
+ --delete-during '$fromdir/' '$todir/'" "$chkdir" "$todir"
# Remove the files that will be deleted.
# Now, try the prior command with --delete-before and some side-specific
# rules.
-checkit "sed '/!/d' \"$excl\" |
+checkit "sed '/!/d' '$excl' |
$RSYNC -avv -f :s_.filt -f .s_- -f P_nodel.deep \
- --delete-before \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
+ --delete-before '$fromdir/' '$todir/'" "$chkdir" "$todir"
# Next, we'll test some rule-restricted filter files.
$RSYNC -av --delete-excluded --exclude='*' "$fromdir/" "$todir/"
checkit "$RSYNC -avv -f dir-merge,-_.excl \
- \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
+ '$fromdir/' '$todir/'" "$chkdir" "$todir"
relative_opts='--relative --chmod=Du+w --copy-unsafe-links'
$RSYNC -av $relative_opts "$fromdir/foo" "$chkdir/"
rm -rf "$chkdir$fromdir/foo/down"
$RSYNC -av $relative_opts --existing --filter='-! */' "$fromdir/foo" "$chkdir/"
-checkit "$RSYNC -avv $relative_opts --exclude=\"$fromdir/foo/down\" \
- \"$fromdir/foo\" \"$todir\"" "$chkdir$fromdir/foo" "$todir$fromdir/foo"
+checkit "$RSYNC -avv $relative_opts --exclude='$fromdir/foo/down' \
+ '$fromdir/foo' '$todir'" "$chkdir$fromdir/foo" "$todir$fromdir/foo"
# The script would have aborted on error, so getting here means we've won.
exit 0