Mention that --del is a popt alias for --delete-during, so there's
[rsync/rsync.git] / testsuite / exclude.test
CommitLineData
ff570659
WD
1#! /bin/sh
2
3# Copyright (C) 2003 by Wayne Davison <wayned@samba.org>
4
5# This program is distributable under the terms of the GNU GPL see
6# COPYING).
7
8# Test rsync handling of exclude/include directives.
9
10# Test some of the more obscure wildcard handling of exclude/include
11# processing.
12
7892e5ac 13. "$suitedir/rsync.fns"
ff570659
WD
14
15set -x
16
43a9d0e7
WD
17HOME="$scratchdir"
18CVSIGNORE='*.junk'
19export HOME CVSIGNORE
20
ff570659
WD
21# Build some files/dirs/links to copy
22
ff570659
WD
23makepath "$fromdir/foo/down/to/you"
24makepath "$fromdir/bar/down/to/foo/too"
25makepath "$fromdir/mid/for/foo/and/that/is/who"
26echo kept >"$fromdir/foo/file1"
27echo removed >"$fromdir/foo/file2"
43a9d0e7 28echo cvsout >"$fromdir/foo/file2.old"
ead751c6 29echo cvsout >"$fromdir/bar/down/to/home-cvs-exclude"
ff570659 30echo keeper >"$fromdir/bar/down/to/foo/file1"
43a9d0e7 31echo cvsout >"$fromdir/bar/down/to/foo/file1.bak"
ff570659
WD
32echo gone >"$fromdir/bar/down/to/foo/file3"
33echo lost >"$fromdir/bar/down/to/foo/file4"
43a9d0e7 34echo cvsout >"$fromdir/bar/down/to/foo/file4.junk"
ff570659 35echo smashed >"$fromdir/bar/down/to/foo/to"
43a9d0e7
WD
36echo cvsout >"$fromdir/mid/one-in-one-out"
37echo one-in-one-out >"$fromdir/mid/.cvsignore"
38echo cvsin >"$fromdir/mid/one-for-all"
ead751c6 39echo cvsin >"$fromdir/mid/for/one-in-one-out"
ff570659
WD
40echo expunged >"$fromdir/mid/for/foo/extra"
41echo retained >"$fromdir/mid/for/foo/keep"
42ln -s too "$fromdir/bar/down/to/foo/sym"
43
f1dd0f27 44# Setup our test exclude/include files.
ff570659 45
ff570659
WD
46excl="$scratchdir/exclude-from"
47cat >"$excl" <<EOF
48# If the second line of these two lines does anything, it's a bug.
49+ **/bar
50- /bar
51# This should match against the whole path, not just the name.
52+ foo**too
53# This should float at the end of the path.
54- foo/*/
55# Test some normal excludes. Competing lines are paired.
56+ t[o]/
57- to
58+ file4
59- file[2-9]
60- /mid/for/foo/extra
61EOF
62
f1dd0f27
WD
63cat >"$scratchdir/.cvsignore" <<EOF
64home-cvs-exclude
65EOF
66
ff570659 67# Create the chk dir with what we expect to be excluded
337a1a86 68
ff570659
WD
69checkit "$RSYNC -avv \"$fromdir/\" \"$chkdir/\"" "$fromdir" "$chkdir"
70
337a1a86 71sleep 1 # Ensures that the rm commands will tweak the directory times.
ff570659 72
ff570659 73rm -r "$chkdir"/foo/down
093acc5d 74rm -r "$chkdir"/mid/for/foo/and
ff570659 75rm "$chkdir"/foo/file[235-9]
093acc5d 76rm "$chkdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo/file[235-9]
ff570659
WD
77rm "$chkdir"/mid/for/foo/extra
78
337a1a86
WD
79# Un-tweak the directory times in our first (weak) exclude test (though
80# it's a good test of the --existing option).
81$RSYNC -av --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
ff570659 82
337a1a86 83# Now, test if rsync excludes the same files.
ff570659 84
f1dd0f27 85checkit "$RSYNC -avv --exclude-from=\"$excl\" \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
ff570659 86
43a9d0e7
WD
87# Modify the chk dir by removing cvs-ignored files and then tweaking the dir times.
88
89rm "$chkdir"/foo/*.old
90rm "$chkdir"/bar/down/to/foo/*.bak
91rm "$chkdir"/bar/down/to/foo/*.junk
92rm "$chkdir"/bar/down/to/home-cvs-exclude
93rm "$chkdir"/mid/one-in-one-out
94
95$RSYNC -av --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
96
97# Now, test if rsync excludes the same files, this time with --cvs-exclude
98# and --delete-excluded.
99
f1dd0f27
WD
100checkit "$RSYNC -avvC --exclude-from=\"$excl\" \
101 --delete-excluded \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
43a9d0e7 102
05118158 103# The script would have aborted on error, so getting here means we've won.
ff570659 104exit 0