- Make this code handle multibyte character encodings, and honor the
--iconv setting when converting case.
+based-on: 6c8ca91c731b7bf2b081694bda85b7dadc2b7aff
diff --git a/exclude.c b/exclude.c
--- a/exclude.c
+++ b/exclude.c
-@@ -21,6 +21,7 @@
- */
-
- #include "rsync.h"
-+#include "ifuncs.h"
-
- extern int verbose;
- extern int am_server;
-@@ -605,16 +606,15 @@ static int rule_matches(const char *fname, struct filter_struct *ex, int name_is
+@@ -966,16 +966,15 @@ static int rule_matches(const char *fname, filter_rule *ex, int name_flags)
if (litmatch_array(pattern, strings, slash_handling))
return ret_match;
} else if (anchored_match) {
diff --git a/flist.c b/flist.c
--- a/flist.c
+++ b/flist.c
-@@ -35,6 +35,7 @@ extern int inc_recurse;
- extern int do_progress;
+@@ -34,6 +34,7 @@ extern int am_generator;
+ extern int inc_recurse;
extern int always_checksum;
extern int module_id;
+extern int ignore_case;
extern int ignore_errors;
extern int numeric_ids;
- extern int recurse;
-@@ -2718,6 +2719,7 @@ int f_name_cmp(const struct file_struct *f1, const struct file_struct *f2)
+ extern int quiet;
+@@ -2638,7 +2639,8 @@ struct file_list *recv_file_list(int f, int dir_ndx)
+ cur_dir++;
+ if (cur_dir != good_dirname) {
+ const char *d = dir_ndx >= 0 ? f_name(dir_flist->files[dir_ndx], NULL) : empty_dir;
+- if (strcmp(cur_dir, d) != 0) {
++ int dir_differs = ignore_case ? strcasecmp(cur_dir, d) : strcmp(cur_dir, d);
++ if (dir_differs) {
+ rprintf(FERROR,
+ "ABORTING due to invalid path from sender: %s/%s\n",
+ cur_dir, file->basename);
+@@ -3205,6 +3207,7 @@ int f_name_cmp(const struct file_struct *f1, const struct file_struct *f2)
{
int dif;
const uchar *c1, *c2;
enum fnc_state state1, state2;
enum fnc_type type1, type2;
enum fnc_type t_path = protocol_version >= 29 ? t_PATH : t_ITEM;
-@@ -2828,7 +2830,15 @@ int f_name_cmp(const struct file_struct *f1, const struct file_struct *f2)
+@@ -3315,7 +3318,15 @@ int f_name_cmp(const struct file_struct *f1, const struct file_struct *f2)
if (type1 != type2)
return type1 == t_PATH ? 1 : -1;
}
diff --git a/ifuncs.h b/ifuncs.h
--- a/ifuncs.h
+++ b/ifuncs.h
-@@ -108,3 +108,38 @@ toUpper(const char *ptr)
- {
- return toupper(*(unsigned char *)ptr);
+@@ -110,3 +110,38 @@ static inline char *my_strdup(const char *str, const char *file, int line)
+ memcpy(buf, str, len);
+ return buf;
}
+
+static inline int
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -118,6 +118,7 @@ OFF_T max_size = 0;
- OFF_T min_size = 0;
+@@ -131,6 +131,7 @@ OFF_T max_size = -1;
+ OFF_T min_size = -1;
int ignore_errors = 0;
int modify_window = 0;
+int ignore_case = 0;
int blocking_io = -1;
int checksum_seed = 0;
int inplace = 0;
-@@ -408,6 +409,7 @@ void usage(enum logcode F)
- rprintf(F," --files-from=FILE read list of source-file names from FILE\n");
- rprintf(F," -0, --from0 all *-from/filter files are delimited by 0s\n");
- rprintf(F," -s, --protect-args no space-splitting; only wildcard special-chars\n");
-+ rprintf(F," --ignore-case ignore case when comparing filenames\n");
- rprintf(F," --address=ADDRESS bind address for outgoing socket to daemon\n");
- rprintf(F," --port=PORT specify double-colon alternate port number\n");
- rprintf(F," --sockopts=OPTIONS specify custom TCP options\n");
-@@ -614,6 +616,8 @@ static struct poptOption long_options[] = {
+@@ -784,6 +785,8 @@ static struct poptOption long_options[] = {
{"read-batch", 0, POPT_ARG_STRING, &batch_name, OPT_READ_BATCH, 0, 0 },
{"write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_WRITE_BATCH, 0, 0 },
{"only-write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_ONLY_WRITE_BATCH, 0, 0 },
{"files-from", 0, POPT_ARG_STRING, &files_from, 0, 0, 0 },
{"from0", '0', POPT_ARG_VAL, &eol_nulls, 1, 0, 0},
{"no-from0", 0, POPT_ARG_VAL, &eol_nulls, 0, 0, 0},
-@@ -1965,6 +1969,9 @@ void server_options(char **args, int *argc_p)
+@@ -2865,6 +2868,9 @@ void server_options(char **args, int *argc_p)
args[ac++] = arg;
}
if (partial_dir && am_sender) {
if (partial_dir != tmp_partialdir) {
args[ac++] = "--partial-dir";
-diff --git a/rsync.yo b/rsync.yo
---- a/rsync.yo
-+++ b/rsync.yo
-@@ -402,6 +402,7 @@ to the detailed description below for a complete description. verb(
- --files-from=FILE read list of source-file names from FILE
- -0, --from0 all *from/filter files are delimited by 0s
- -s, --protect-args no space-splitting; wildcard chars only
-+ --ignore-case ignore case when comparing filenames
- --address=ADDRESS bind address for outgoing socket to daemon
- --port=PORT specify double-colon alternate port number
- --sockopts=OPTIONS specify custom TCP options
-@@ -1438,6 +1439,10 @@ If you use this option with bf(--iconv), the args will also be translated
- from the local to the remote character-set. The translation happens before
- wild-cards are expanded. See also the bf(--files-from) option.
+diff --git a/rsync.1.md b/rsync.1.md
+--- a/rsync.1.md
++++ b/rsync.1.md
+@@ -528,6 +528,7 @@ has its own detailed description later in this manpage.
+ --secluded-args, -s use the protocol to safely send the args
+ --trust-sender trust the remote sender's file list
+ --copy-as=USER[:GROUP] specify user & optional group for the copy
++--ignore-case ignore case when comparing filenames
+ --address=ADDRESS bind address for outgoing socket to daemon
+ --port=PORT specify double-colon alternate port number
+ --sockopts=OPTIONS specify custom TCP options
+@@ -2583,6 +2584,12 @@ expand it.
-+dit(bf(--ignore-case)) This option tells rsync to ignore upper-/lower-case
-+differences when comparing filenames. This can avoid problems when sending
-+files to a filesystem that ignores these differences.
+ > sudo rsync -aive lsh -M--copy-as=joe src/ lh:dest/
+
++0. `--ignore-case`
++
++ This option tells rsync to ignore upper-/lower-case differences when
++ comparing filenames. This can avoid problems when sending files to a
++ filesystem that ignores these differences.
+
- dit(bf(-T, --temp-dir=DIR)) This option instructs rsync to use DIR as a
- scratch directory when creating temporary copies of the files transferred
- on the receiving side. The default behavior is to create each temporary
+ 0. `--temp-dir=DIR`, `-T`
+
+ This option instructs rsync to use DIR as a scratch directory when creating
+diff --git a/t_stub.c b/t_stub.c
+--- a/t_stub.c
++++ b/t_stub.c
+@@ -34,6 +34,7 @@ int preserve_perms = 0;
+ int preserve_executability = 0;
+ int omit_link_times = 0;
+ int open_noatime = 0;
++int ignore_case = 0;
+ size_t max_alloc = 0; /* max_alloc is needed when combined with util2.o */
+ char *partial_dir;
+ char *module_dir;
diff --git a/wildtest.c b/wildtest.c
--- a/wildtest.c
+++ b/wildtest.c
-@@ -31,6 +31,7 @@ int fnmatch_errors = 0;
+@@ -30,6 +30,7 @@
+ int fnmatch_errors = 0;
#endif
- int wildmatch_errors = 0;
+int ignore_case = 0;
+ int wildmatch_errors = 0;
typedef char bool;
-