Unmerged patch from David Bolen to add --ignore-case.
[rsync/rsync-patches.git] / ignore-case.diff
CommitLineData
8a524ae0
MP
1From rsync-admin@lists.samba.org Thu Apr 18 20:05:33 2002
2Return-Path: <rsync-admin@lists.samba.org>
3Delivered-To: mbp@samba.org
4Received: from va.samba.org (localhost [127.0.0.1])
5 by lists.samba.org (Postfix) with ESMTP
6 id 8AD0349D4; Thu, 18 Apr 2002 20:05:32 -0700 (PDT)
7Delivered-To: rsync@lists.samba.org
8Received: from ctmsg01.corp.fitlinxx.com (mail.fitlinxx.com [208.247.212.10])
9 by lists.samba.org (Postfix) with ESMTP id 12ED449C6
10 for <rsync@lists.samba.org>; Thu, 18 Apr 2002 20:05:00 -0700 (PDT)
11Received: by ctmsg01.corp.fitlinxx.com with Internet Mail Service (5.5.2653.19)
12 id <JCL2B4NB>; Thu, 18 Apr 2002 23:04:07 -0400
13Message-ID: <926F937512224245A616323693D3F16B1C0022@ctmsg01.corp.fitlinxx.com>
14From: David Bolen <db3l@fitlinxx.com>
15To: 'Peter Tattam' <peter@jazz-1.trumpet.com.au>
16Cc: rsync@lists.samba.org
17Subject: RE: mixed case file systems.
18MIME-Version: 1.0
19X-Mailer: Internet Mail Service (5.5.2653.19)
20Content-Type: text/plain;
21 charset="iso-8859-1"
22Sender: rsync-admin@lists.samba.org
23Errors-To: rsync-admin@lists.samba.org
24X-BeenThere: rsync@lists.samba.org
25X-Mailman-Version: 2.0.8
26Precedence: bulk
27List-Help: <mailto:rsync-request@lists.samba.org?subject=help>
28List-Post: <mailto:rsync@lists.samba.org>
29List-Subscribe: <http://lists.samba.org/mailman/listinfo/rsync>,
30 <mailto:rsync-request@lists.samba.org?subject=subscribe>
31List-Id: rsync user list <rsync.lists.samba.org>
32List-Unsubscribe: <http://lists.samba.org/mailman/listinfo/rsync>,
33 <mailto:rsync-request@lists.samba.org?subject=unsubscribe>
34List-Archive: <http://lists.samba.org/pipermail/rsync/>
35X-Original-Date: Thu, 18 Apr 2002 23:04:06 -0400
36Date: Thu, 18 Apr 2002 23:04:06 -0400
37Status: RO
38X-Status: A
39Content-Length: 6452
40Lines: 205
41
42Peter Tattam [peter@jazz-1.trumpet.com.au] writes:
43
44> I believe a suitable workaround would be to ignore case for file names
45> when the rsync process is undertaken. Is this facility available or
46> planned in the near future?
47
48I've attached a context diff for some changes I made to our local copy
49a while back to add an "--ignore-case" option just for this purpose.
50In our case it came up in the context of disting between NTFS and FAT
51remote systems. I think we ended up not needing it, but it does make
52rsync match filenames in a case insensitive manner, so it might at
53least be worth trying to see if it resolves your issue.
54
55A few caveats - both ends have to support the option - I couldn't make
56it backwards compatible because both ends exchange information about a
57sorted file list that has to sort the same way on either side (which
58very subtly bit me when I first did this). I also didn't bump the
59protocol in this patch (wasn't quite sure it was appropriate just for an
60incompatible command line option) since since it was for local use.
61
62The patch is based on a 2.4.x series rsync, but if it doesn't apply
63cleanly to 2.5.x, it's should be simple enough to just apply manually.
64
65-- David
66
67/-----------------------------------------------------------------------\
68 \ David Bolen \ E-mail: db3l@fitlinxx.com /
69 | FitLinxx, Inc. \ Phone: (203) 708-5192 |
70 / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \
71\-----------------------------------------------------------------------/
72
73 - - - - - - - - - - - - - - - - - - - - - - - - -
74
75Index: options.c
76===================================================================
77RCS file: e:/binaries/cvs/ni/bin/rsync/options.c,v
78retrieving revision 1.5
79retrieving revision 1.7
80diff -c -r1.5 -r1.7
81*** options.c 2000/12/28 00:30:18 1.5
82--- options.c 2001/06/20 19:25:24 1.7
83***************
84*** 72,77 ****
85--- 72,78 ----
86 #else
87 int modify_window=0;
88 #endif /* _WIN32 */
89+ int ignore_case=0;
90 int modify_window_set=0;
91 int delete_sent=0;
92
93***************
94*** 162,167 ****
95--- 164,170 ----
96 rprintf(F," --exclude-from=FILE exclude patterns listed in
97FILE\n");
98 rprintf(F," --include=PATTERN don't exclude files matching
99PATTERN\n");
100 rprintf(F," --include-from=FILE don't exclude patterns listed in
101FILE\n");
102+ rprintf(F," --ignore-case ignore case when comparing
103filenames\n");
104 rprintf(F," --version print version number\n");
105 rprintf(F," --daemon run as a rsync daemon\n");
106 rprintf(F," --address bind to the specified
107address\n");
108***************
109*** 186,194 ****
110 OPT_PROGRESS, OPT_COPY_UNSAFE_LINKS, OPT_SAFE_LINKS,
111OPT_COMPARE_DEST,
112 OPT_LOG_FORMAT, OPT_PASSWORD_FILE, OPT_SIZE_ONLY, OPT_ADDRESS,
113 OPT_DELETE_AFTER, OPT_EXISTING, OPT_MAX_DELETE, OPT_BACKUP_DIR,
114! OPT_IGNORE_ERRORS, OPT_MODIFY_WINDOW, OPT_DELETE_SENT};
115
116! static char *short_options = "oblLWHpguDCtcahvqrRIxnSe:B:T:zP";
117
118 static struct option long_options[] = {
119 {"version", 0, 0, OPT_VERSION},
120--- 189,198 ----
121 OPT_PROGRESS, OPT_COPY_UNSAFE_LINKS, OPT_SAFE_LINKS,
122OPT_COMPARE_DEST,
123 OPT_LOG_FORMAT, OPT_PASSWORD_FILE, OPT_SIZE_ONLY, OPT_ADDRESS,
124 OPT_DELETE_AFTER, OPT_EXISTING, OPT_MAX_DELETE, OPT_BACKUP_DIR,
125! OPT_IGNORE_ERRORS, OPT_MODIFY_WINDOW, OPT_DELETE_SENT,
126! OPT_IGNORE_CASE};
127
128! static char *short_options = "oblLWHpguDCtcahvqrRIxnSe:B:T:zP";
129
130 static struct option long_options[] = {
131 {"version", 0, 0, OPT_VERSION},
132***************
133*** 204,209 ****
134--- 208,214 ----
135 {"exclude-from",1, 0, OPT_EXCLUDE_FROM},
136 {"include", 1, 0, OPT_INCLUDE},
137 {"include-from",1, 0, OPT_INCLUDE_FROM},
138+ {"ignore-case", 0, 0, OPT_IGNORE_CASE},
139 {"rsync-path", 1, 0, OPT_RSYNC_PATH},
140 {"password-file", 1, 0, OPT_PASSWORD_FILE},
141 {"one-file-system",0, 0, 'x'},
142***************
143*** 401,406 ****
144--- 406,415 ----
145 add_exclude_file(optarg,1, 1);
146 break;
147
148+ case OPT_IGNORE_CASE:
149+ ignore_case=1;
150+ break;
151+
152 case OPT_COPY_UNSAFE_LINKS:
153 copy_unsafe_links=1;
154 break;
155***************
156*** 712,717 ****
157--- 727,736 ----
158 slprintf(mwindow,sizeof(mwindow),"--modify-window=%d",
159 modify_window);
160 args[ac++] = mwindow;
161+ }
162+
163+ if (ignore_case) {
164+ args[ac++] = "--ignore-case";
165 }
166
167 if (keep_partial)
168Index: exclude.c
169===================================================================
170RCS file: e:/binaries/cvs/ni/bin/rsync/exclude.c,v
171retrieving revision 1.1.1.1
172retrieving revision 1.2
173diff -c -r1.1.1.1 -r1.2
174*** exclude.c 2000/05/30 18:08:19 1.1.1.1
175--- exclude.c 2001/06/14 04:30:17 1.2
176***************
177*** 31,36 ****
178--- 31,37 ----
179 static struct exclude_struct *make_exclude(char *pattern, int include)
180 {
181 struct exclude_struct *ret;
182+ extern int ignore_case;
183
184 ret = (struct exclude_struct *)malloc(sizeof(*ret));
185 if (!ret) out_of_memory("make_exclude");
186***************
187*** 72,77 ****
188--- 73,82 ----
189
190 if (!strchr(ret->pattern,'/')) {
191 ret->local = 1;
192+ }
193+
194+ if (ignore_case) {
195+ ret->fnmatch_flags |= FNM_CASEFOLD;
196 }
197
198 return ret;
199Index: util.c
200===================================================================
201RCS file: e:/binaries/cvs/ni/bin/rsync/util.c,v
202retrieving revision 1.2
203retrieving revision 1.3
204diff -c -r1.2 -r1.3
205*** util.c 2000/07/07 03:23:40 1.2
206--- util.c 2001/06/14 04:30:17 1.3
207***************
208*** 838,849 ****
209 {
210 const uchar *s1 = (const uchar *)cs1;
211 const uchar *s2 = (const uchar *)cs2;
212
213! while (*s1 && *s2 && (*s1 == *s2)) {
214! s1++; s2++;
215 }
216-
217- return (int)*s1 - (int)*s2;
218 }
219
220 static OFF_T last_ofs;
221--- 836,856 ----
222 {
223 const uchar *s1 = (const uchar *)cs1;
224 const uchar *s2 = (const uchar *)cs2;
225+ extern int ignore_case;
226+
227+ if (ignore_case) {
228+ while (*s1 && *s2 && (toupper(*s1) == toupper(*s2))) {
229+ s1++; s2++;
230+ }
231+
232+ return (int)toupper(*s1) - (int)toupper(*s2);
233+ } else {
234+ while (*s1 && *s2 && (*s1 == *s2)) {
235+ s1++; s2++;
236+ }
237
238! return (int)*s1 - (int)*s2;
239 }
240 }
241
242 static OFF_T last_ofs;
243
244--
245To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync
246Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html
247