Use the new diff-dependency feature to make the patch depend on
[rsync/rsync-patches.git] / ignore-case.diff
CommitLineData
8a524ae0 1From: David Bolen <db3l@fitlinxx.com>
5f7bb027 2To: Peter Tattam <peter@jazz-1.trumpet.com.au>
8a524ae0
MP
3Cc: rsync@lists.samba.org
4Subject: RE: mixed case file systems.
8a524ae0 5Date: Thu, 18 Apr 2002 23:04:06 -0400
8a524ae0
MP
6
7Peter Tattam [peter@jazz-1.trumpet.com.au] writes:
8
9> I believe a suitable workaround would be to ignore case for file names
10> when the rsync process is undertaken. Is this facility available or
11> planned in the near future?
12
13I've attached a context diff for some changes I made to our local copy
14a while back to add an "--ignore-case" option just for this purpose.
15In our case it came up in the context of disting between NTFS and FAT
16remote systems. I think we ended up not needing it, but it does make
17rsync match filenames in a case insensitive manner, so it might at
b11ed64f 18least be worth trying to see if it resolves your issue.
8a524ae0
MP
19
20A few caveats - both ends have to support the option - I couldn't make
21it backwards compatible because both ends exchange information about a
22sorted file list that has to sort the same way on either side (which
23very subtly bit me when I first did this). I also didn't bump the
24protocol in this patch (wasn't quite sure it was appropriate just for an
b11ed64f 25incompatible command line option) since it was for local use.
8a524ae0 26
b11ed64f 27NOTE: patch updated for latest CVS source by Wayne Davison, but UNTESTED!
8a524ae0
MP
28
29-- David
30
31/-----------------------------------------------------------------------\
32 \ David Bolen \ E-mail: db3l@fitlinxx.com /
33 | FitLinxx, Inc. \ Phone: (203) 708-5192 |
34 / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \
35\-----------------------------------------------------------------------/
36
37 - - - - - - - - - - - - - - - - - - - - - - - - -
38
7628f156
WD
39--- options.c 7 Jun 2004 22:05:22 -0000 1.156
40+++ options.c 18 Jun 2004 17:26:59 -0000
41@@ -92,6 +92,7 @@ int opt_ignore_existing = 0;
5f7bb027
WD
42 int max_delete = 0;
43 int ignore_errors = 0;
44 int modify_window = 0;
45+int ignore_case = 0;
46 int blocking_io = -1;
47 int checksum_seed = 0;
48 unsigned int block_size = 0;
7628f156 49@@ -279,6 +280,7 @@ void usage(enum logcode F)
5f7bb027
WD
50 rprintf(F," --include-from=FILE don't exclude patterns listed in FILE\n");
51 rprintf(F," --files-from=FILE read FILE for list of source-file names\n");
52 rprintf(F," -0 --from0 all *-from file lists are delimited by nulls\n");
53+ rprintf(F," --ignore-case ignore case when comparing filenames\n");
54 rprintf(F," --version print version number\n");
55 rprintf(F," --daemon run as an rsync daemon\n");
56 rprintf(F," --no-detach do not detach from the parent\n");
7628f156 57@@ -334,6 +336,7 @@ static struct poptOption long_options[]
5f7bb027
WD
58 {"include", 0, POPT_ARG_STRING, 0, OPT_INCLUDE, 0, 0 },
59 {"exclude-from", 0, POPT_ARG_STRING, 0, OPT_EXCLUDE_FROM, 0, 0 },
60 {"include-from", 0, POPT_ARG_STRING, 0, OPT_INCLUDE_FROM, 0, 0 },
61+ {"ignore-case", 0, POPT_ARG_NONE, &ignore_case, 0, 0, 0 },
62 {"safe-links", 0, POPT_ARG_NONE, &safe_symlinks, 0, 0, 0 },
63 {"help", 'h', POPT_ARG_NONE, 0, 'h', 0, 0 },
64 {"backup", 'b', POPT_ARG_NONE, &make_backups, 0, 0, 0 },
7628f156 65@@ -936,6 +939,9 @@ void server_options(char **args,int *arg
5f7bb027
WD
66 args[ac++] = arg;
67 }
7628f156 68
5f7bb027
WD
69+ if (ignore_case)
70+ args[ac++] = "--ignore-case";
7628f156 71+
5f7bb027
WD
72 if (keep_partial)
73 args[ac++] = "--partial";
7628f156
WD
74
75--- util.c 9 Jun 2004 21:51:07 -0000 1.149
76+++ util.c 18 Jun 2004 17:27:00 -0000
77@@ -951,6 +951,19 @@ int u_strcmp(const char *cs1, const char
5f7bb027
WD
78 {
79 const uchar *s1 = (const uchar *)cs1;
80 const uchar *s2 = (const uchar *)cs2;
81+ extern int ignore_case;
8a524ae0 82+
5f7bb027
WD
83+ if (ignore_case) {
84+ while (*s1 && *s2) {
85+ uchar c1 = islower(*s1) ? toupper(*s1) : *s1;
86+ uchar c2 = islower(*s2) ? toupper(*s2) : *s2;
87+ if (c1 != c2)
b11ed64f 88+ return (int)c1 - (int)c2;
5f7bb027
WD
89+ s1++; s2++;
90+ }
91+
92+ return (int)*s1 - (int)*s2;
93+ }
94
95 while (*s1 && *s2 && (*s1 == *s2)) {
96 s1++; s2++;
5f7bb027 97--- lib/wildmatch.c 14 Jul 2003 15:12:59 -0000 1.12
7628f156 98+++ lib/wildmatch.c 18 Jun 2004 17:27:00 -0000
5f7bb027
WD
99@@ -76,8 +76,20 @@ static int domatch(const unsigned char *
100 ch = *++p;
101 /* FALLTHROUGH */
102 default:
103- if (*text != ch)
104+ if (*text != ch) {
105+ extern int ignore_case;
106+ if (ignore_case) {
107+ if (ISUPPER(*text)) {
108+ if (tolower(*text) == ch)
109+ continue;
110+ }
111+ else if (ISUPPER(ch)) {
112+ if (*text == tolower(ch))
113+ continue;
114+ }
115+ }
116 return FALSE;
117+ }
118 continue;
119 case '?':
120 /* Match anything but '/'. */