Intentional test of assert :_)
[rsync/rsync.git] / options.c
index 38bc63a..1696eea 100644 (file)
--- a/options.c
+++ b/options.c
 #include "popt.h"
 
 int make_backups = 0;
-int whole_file = -1;
+
+/**
+ * Should we send the whole file as literal data rather than trying to
+ * create an incremental diff?  This is on by default when both source
+ * and destination are local and we're not doing a batch delta,
+ * because there it's no cheaper to read the whole basis file than to
+ * just rewrite it.
+ *
+ * If both are 0, then look at whether we're local or remote and go by
+ * that.
+ **/
+int whole_file = 0;
+int no_whole_file = 0;
+
 int copy_links = 0;
 int preserve_links = 0;
 int preserve_hard_links = 0;
@@ -299,7 +312,7 @@ static struct poptOption long_options[] = {
   {"links",           'l', POPT_ARG_NONE,   &preserve_links},
   {"copy-links",      'L', POPT_ARG_NONE,   &copy_links},
   {"whole-file",      'W', POPT_ARG_NONE,   &whole_file},
-  {"no-whole-file",    0,  POPT_ARG_NONE,   0,                      OPT_NO_WHOLE_FILE},
+  {"no-whole-file",    0,  POPT_ARG_NONE,   &no_whole_file},
   {"copy-unsafe-links", 0, POPT_ARG_NONE,   &copy_unsafe_links},
   {"perms",           'p', POPT_ARG_NONE,   &preserve_perms},
   {"owner",           'o', POPT_ARG_NONE,   &preserve_uid},
@@ -463,10 +476,6 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
                        add_exclude_file(poptGetOptArg(pc), 1, 1);
                        break;
 
-               case OPT_NO_WHOLE_FILE:
-                       whole_file = 0;
-                       break;
-
                case OPT_NO_BLOCKING_IO:
                        blocking_io = 0;
                        break;
@@ -590,8 +599,6 @@ void server_options(char **args,int *argc)
 
        int i, x;
 
-       if (whole_file == -1)
-               whole_file = 0;
        if (blocking_io == -1)
                blocking_io = 0;
 
@@ -616,8 +623,14 @@ void server_options(char **args,int *argc)
                argstr[x++] = 'l';
        if (copy_links)
                argstr[x++] = 'L';
+
+       assert(whole_file == 0 || whole_file == 1);
        if (whole_file)
                argstr[x++] = 'W';
+       /* We don't need to send --no-whole-file, because it's the
+        * default for remote transfers, and in any case old versions
+        * of rsync will not understand it. */
+       
        if (preserve_hard_links)
                argstr[x++] = 'H';
        if (preserve_uid)
@@ -758,7 +771,6 @@ void server_options(char **args,int *argc)
                args[ac++] = compare_dest;
        }
 
-
        *argc = ac;
 }