Write out the inc_recurse flag into a protocol-30 batch file.
[rsync/rsync.git] / compat.c
index eaa7c55..a1a0f24 100644 (file)
--- a/compat.c
+++ b/compat.c
@@ -48,10 +48,7 @@ extern int preserve_acls;
 extern int preserve_xattrs;
 extern int need_messages_from_generator;
 extern int delete_mode, delete_before, delete_during, delete_after;
-extern int delete_excluded;
-extern int make_backups;
 extern char *shell_cmd; /* contains VER.SUB string if client is a pre-release */
-extern char *backup_dir, *backup_suffix;
 extern char *partial_dir;
 extern char *dest_option;
 extern char *files_from;
@@ -108,7 +105,7 @@ static void check_sub_protocol(void)
 void setup_protocol(int f_out,int f_in)
 {
        if (am_sender)
-               file_extra_cnt += PTR_EXTRA_LEN;
+               file_extra_cnt += PTR_EXTRA_CNT;
        else
                file_extra_cnt++;
        if (preserve_uid)
@@ -119,10 +116,6 @@ void setup_protocol(int f_out,int f_in)
                acls_ndx = ++file_extra_cnt;
        if (preserve_xattrs)
                xattrs_ndx = ++file_extra_cnt;
-#ifdef ICONV_OPTION
-       if (iconv_opt && (!am_sender || inc_recurse))
-               ic_ndx = ++file_extra_cnt;
-#endif
 
        if (remote_protocol == 0) {
                if (am_server && !local_server)
@@ -227,9 +220,25 @@ void setup_protocol(int f_out,int f_in)
                 && !delete_before && !delete_after && !delay_updates
                 && !use_qsort && !prune_empty_dirs)
                        inc_recurse = 1;
+               if (am_server || read_batch) {
+                       int i_r = read_byte(f_in);
+                       if (i_r && !inc_recurse) {
+                               fprintf(stderr,
+                                   "Incompatible options specified for inc-recursive %s.\n",
+                                   read_batch ? "batch file" : "connection");
+                               exit_cleanup(RERR_SYNTAX);
+                       }
+                       inc_recurse = i_r;
+               } else
+                       write_byte(f_out, inc_recurse);
                need_messages_from_generator = 1;
        }
 
+#ifdef ICONV_OPTION
+       if (iconv_opt && (!am_sender || inc_recurse))
+               ic_ndx = ++file_extra_cnt;
+#endif
+
        if (partial_dir && *partial_dir != '/' && (!am_server || local_server)) {
                int flags = MATCHFLG_NO_PREFIXES | MATCHFLG_DIRECTORY;
                if (!am_sender || protocol_version >= 30)