3 # Copyright (C) 2003 by Wayne Davison <wayned@samba.org>
5 # This program is distributable under the terms of the GNU GPL see
8 # Test rsync handling of exclude/include directives.
10 # Test some of the more obscure wildcard handling of exclude/include
13 . "$suitedir/rsync.fns"
21 # Build some files/dirs/links to copy
23 makepath "$fromdir/foo/down/to/you"
24 makepath "$fromdir/bar/down/to/foo/too"
25 makepath "$fromdir/mid/for/foo/and/that/is/who"
26 cat >"$fromdir/.excl" <<EOF
35 echo kept >"$fromdir/foo/file1"
36 echo removed >"$fromdir/foo/file2"
37 echo cvsout >"$fromdir/foo/file2.old"
38 cat >"$fromdir/foo/.excl" <<EOF
42 cat >"$fromdir/bar/.excl" <<EOF
47 echo cvsout >"$fromdir/bar/down/to/home-cvs-exclude"
48 cat >"$fromdir/bar/down/to/.excl2" <<EOF
51 echo keeper >"$fromdir/bar/down/to/foo/file1"
52 echo cvsout >"$fromdir/bar/down/to/foo/file1.bak"
53 echo gone >"$fromdir/bar/down/to/foo/file3"
54 echo lost >"$fromdir/bar/down/to/foo/file4"
55 echo cvsout >"$fromdir/bar/down/to/foo/file4.junk"
56 echo smashed >"$fromdir/bar/down/to/foo/to"
57 cat >"$fromdir/bar/down/to/foo/.excl2" <<EOF
60 # This one should be ineffectual
61 cat >"$fromdir/mid/.excl2" <<EOF
64 echo cvsout >"$fromdir/mid/one-in-one-out"
65 echo one-in-one-out >"$fromdir/mid/.cvsignore"
66 echo cvsin >"$fromdir/mid/one-for-all"
67 cat >"$fromdir/mid/.excl" <<EOF
70 echo cvsin >"$fromdir/mid/for/one-in-one-out"
71 echo expunged >"$fromdir/mid/for/foo/extra"
72 echo retained >"$fromdir/mid/for/foo/keep"
73 ln -s too "$fromdir/bar/down/to/foo/sym"
75 # Setup our test exclude/include files.
77 excl="$scratchdir/exclude-from"
80 # If the second line of these two lines does anything, it's a bug.
83 # This should match against the whole path, not just the name.
85 # This should float at the end of the path.
87 # Test some normal excludes. Competing lines are paired.
95 cat >"$scratchdir/.cvsignore" <<EOF
99 # Create the chk dir with what we expect to be excluded
101 checkit "$RSYNC -avv \"$fromdir/\" \"$chkdir/\"" "$fromdir" "$chkdir"
103 sleep 1 # Ensures that the rm commands will tweak the directory times.
105 rm -r "$chkdir"/foo/down
106 rm -r "$chkdir"/mid/for/foo/and
107 rm "$chkdir"/foo/file[235-9]
108 rm "$chkdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo/file[235-9]
109 rm "$chkdir"/mid/for/foo/extra
111 # Un-tweak the directory times in our first (weak) exclude test (though
112 # it's a good test of the --existing option).
113 $RSYNC -av --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
115 # Now, test if rsync excludes the same files.
117 checkit "$RSYNC -avv --exclude-from=\"$excl\" \
118 --delete \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
120 # Modify the chk dir by removing cvs-ignored files and then tweaking the dir times.
122 rm "$chkdir"/foo/*.old
123 rm "$chkdir"/bar/down/to/foo/*.bak
124 rm "$chkdir"/bar/down/to/foo/*.junk
125 rm "$chkdir"/bar/down/to/home-cvs-exclude
126 rm "$chkdir"/mid/one-in-one-out
128 $RSYNC -av --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
130 # Now, test if rsync excludes the same files, this time with --cvs-exclude
131 # and --delete-excluded.
133 checkit "$RSYNC -avvC --filter=\". $excl\" \
134 --delete-excluded \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
136 # Modify the chk dir for our merge-exclude test and then tweak the dir times.
139 rm "$chkdir"/foo/file1
140 rm "$chkdir"/bar/.excl
141 rm "$chkdir"/bar/down/to/.excl2
142 rm "$chkdir"/bar/down/to/foo/.excl2
143 rm "$chkdir"/mid/.excl
144 cp -p "$fromdir"/bar/down/to/foo/*.junk "$chkdir"/bar/down/to/foo
145 cp -p "$fromdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo
147 $RSYNC -av --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
149 # Now, test if rsync excludes the same files, this time with a merge-exclude
152 checkit "sed '/!/d' \"$excl\" | $RSYNC -avv -f :_.excl -f ._- \
153 --delete-excluded \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
155 # The script would have aborted on error, so getting here means we've won.