Added the --8-bit (-8) option.
[rsync/rsync.git] / options.c
index 1c2cf33..55395cb 100644 (file)
--- a/options.c
+++ b/options.c
@@ -45,6 +45,7 @@ int copy_links = 0;
 int preserve_links = 0;
 int preserve_hard_links = 0;
 int preserve_perms = 0;
+int preserve_executability = 0;
 int preserve_devices = 0;
 int preserve_specials = 0;
 int preserve_uid = 0;
@@ -78,6 +79,7 @@ int orig_umask = 0;
 int relative_paths = -1;
 int implied_dirs = 1;
 int numeric_ids = 0;
+int allow_8bit_chars = 0;
 int force_delete = 0;
 int io_timeout = 0;
 int allowed_lull = 0;
@@ -179,7 +181,7 @@ static int refused_delete, refused_archive_part, refused_compress;
 static int refused_partial, refused_progress, refused_delete_before;
 static int refused_inplace;
 static char *max_size_arg, *min_size_arg;
-static char partialdir_for_delayupdate[] = ".~tmp~";
+static char tmp_partialdir[] = ".~tmp~";
 
 /** Local address to bind.  As a character string because it's
  * interpreted by the IPv6 layer: should be a numeric IP4 or IP6
@@ -221,20 +223,20 @@ static void print_rsync_version(enum logcode f)
        rprintf(f, "Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.\n");
        rprintf(f, "<http://rsync.samba.org/>\n");
        rprintf(f, "Capabilities: %d-bit files, %ssocketpairs, "
-               "%shard links, %ssymlinks, batchfiles, \n",
+               "%shard links, %ssymlinks, batchfiles,\n",
                (int) (sizeof (OFF_T) * 8),
                got_socketpair, hardlinks, links);
 
        /* Note that this field may not have type ino_t.  It depends
         * on the complicated interaction between largefile feature
         * macros. */
-       rprintf(f, "              %sinplace, %sIPv6, %d-bit system inums, %d-bit internal inums\n",
+       rprintf(f, "              %sinplace, %sIPv6, "
+               "%d-bit system inums, %d-bit internal inums\n",
                have_inplace, ipv6,
                (int) (sizeof dumstat->st_ino * 8),
                (int) (sizeof (int64) * 8));
 #ifdef MAINTAINER_MODE
-       rprintf(f, "              panic action: \"%s\"\n",
-               get_panic_action());
+       rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
 #endif
 
 #if SIZEOF_INT64 < 8
@@ -291,6 +293,8 @@ void usage(enum logcode F)
   rprintf(F," -H, --hard-links            preserve hard links\n");
   rprintf(F," -K, --keep-dirlinks         treat symlinked dir on receiver as dir\n");
   rprintf(F," -p, --perms                 preserve permissions\n");
+  rprintf(F," -E, --executability         preserve the file's executability\n");
+  rprintf(F,"     --chmod=CHMOD           change destination permissions\n");
   rprintf(F," -o, --owner                 preserve owner (super-user only)\n");
   rprintf(F," -g, --group                 preserve group\n");
   rprintf(F,"     --devices               preserve device files (super-user only)\n");
@@ -299,7 +303,6 @@ void usage(enum logcode F)
   rprintf(F," -t, --times                 preserve times\n");
   rprintf(F," -O, --omit-dir-times        omit directories when preserving times\n");
   rprintf(F,"     --super                 receiver attempts super-user activities\n");
-  rprintf(F,"     --chmod=CHMOD           change destination permissions\n");
   rprintf(F," -S, --sparse                handle sparse files efficiently\n");
   rprintf(F," -n, --dry-run               show what would have been transferred\n");
   rprintf(F," -W, --whole-file            copy files whole (without rsync algorithm)\n");
@@ -352,6 +355,7 @@ void usage(enum logcode F)
   rprintf(F,"     --sockopts=OPTIONS      specify custom TCP options\n");
   rprintf(F,"     --blocking-io           use blocking I/O for the remote shell\n");
   rprintf(F,"     --stats                 give some file-transfer stats\n");
+  rprintf(F," -8, --8-bit                 leave high-bit chars unescaped in output\n");
   rprintf(F," -h, --human-readable        output numbers in a human-readable format\n");
   rprintf(F,"     --si                    like human-readable, but use powers of 1000\n");
   rprintf(F,"     --progress              show progress during transfer\n");
@@ -406,6 +410,7 @@ static struct poptOption long_options[] = {
   {"perms",           'p', POPT_ARG_VAL,    &preserve_perms, 1, 0, 0 },
   {"no-perms",         0,  POPT_ARG_VAL,    &preserve_perms, 0, 0, 0 },
   {"no-p",             0,  POPT_ARG_VAL,    &preserve_perms, 0, 0, 0 },
+  {"executability",   'E', POPT_ARG_NONE,   &preserve_executability, 0, 0, 0 },
   {"times",           't', POPT_ARG_VAL,    &preserve_times, 1, 0, 0 },
   {"no-times",         0,  POPT_ARG_VAL,    &preserve_times, 0, 0, 0 },
   {"no-t",             0,  POPT_ARG_VAL,    &preserve_times, 0, 0, 0 },
@@ -507,6 +512,7 @@ static struct poptOption long_options[] = {
   {"ipv4",            '4', POPT_ARG_VAL,    &default_af_hint, AF_INET, 0, 0 },
   {"ipv6",            '6', POPT_ARG_VAL,    &default_af_hint, AF_INET6, 0, 0 },
 #endif
+  {"8-bit",           '8', POPT_ARG_NONE,   &allow_8bit_chars, 0, 0, 0 },
   {"address",          0,  POPT_ARG_STRING, &bind_address, 0, 0, 0 },
   {"port",             0,  POPT_ARG_INT,    &rsync_port, 0, 0, 0 },
   {"sockopts",         0,  POPT_ARG_STRING, &sockopts, 0, 0, 0 },
@@ -1042,7 +1048,7 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
 
                case OPT_CHMOD:
                        arg = poptGetOptArg(pc);
-                       if (!(chmod_modes = parse_chmod(arg, chmod_modes))) {
+                       if (!parse_chmod(arg, &chmod_modes)) {
                                snprintf(err_buf, sizeof err_buf,
                                    "Invalid argument passed to --chmod (%s)\n",
                                    arg);
@@ -1262,7 +1268,7 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
                snprintf(err_buf, sizeof err_buf,
                        "--suffix cannot be a null string without --backup-dir\n");
                return 0;
-       } else if (delete_mode && !delete_excluded) {
+       } else if (make_backups && delete_mode && !delete_excluded) {
                snprintf(backup_dir_buf, sizeof backup_dir_buf,
                        "P *%s", backup_suffix);
                parse_rule(&filter_list, backup_dir_buf, 0, 0);
@@ -1330,7 +1336,7 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
        }
 
        if (delay_updates && !partial_dir)
-               partial_dir = partialdir_for_delayupdate;
+               partial_dir = tmp_partialdir;
 
        if (inplace) {
 #ifdef HAVE_FTRUNCATE
@@ -1504,6 +1510,8 @@ void server_options(char **args,int *argc)
                argstr[x++] = 't';
        if (preserve_perms)
                argstr[x++] = 'p';
+       else if (preserve_executability && am_sender)
+               argstr[x++] = 'E';
        if (recurse)
                argstr[x++] = 'r';
        if (always_checksum)
@@ -1651,13 +1659,13 @@ void server_options(char **args,int *argc)
        }
 
        if (partial_dir && am_sender) {
-               if (partial_dir != partialdir_for_delayupdate) {
+               if (partial_dir != tmp_partialdir) {
                        args[ac++] = "--partial-dir";
                        args[ac++] = partial_dir;
                }
                if (delay_updates)
                        args[ac++] = "--delay-updates";
-       } else if (keep_partial)
+       } else if (keep_partial && am_sender)
                args[ac++] = "--partial";
 
        if (ignore_errors)
@@ -1684,7 +1692,7 @@ void server_options(char **args,int *argc)
        else if (inplace)
                args[ac++] = "--inplace";
 
-       if (tmpdir) {
+       if (tmpdir && am_sender) {
                args[ac++] = "--temp-dir";
                args[ac++] = tmpdir;
        }