X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/3296f91bb01a376e0fe751ba2155ec25d7bcbb6b..13d00101e808ebfc327f8c5e830b96303facf31f:/options.c diff --git a/options.c b/options.c index 44619b6f..5ff1e9d6 100644 --- a/options.c +++ b/options.c @@ -59,6 +59,7 @@ int delete_during = 0; int delete_before = 0; int delete_after = 0; int delete_excluded = 0; +int remove_sent_files = 0; int one_file_system = 0; int protocol_version = PROTOCOL_VERSION; int sparse_files = 0; @@ -93,6 +94,7 @@ int fuzzy_basis = 0; size_t bwlimit_writemax = 0; int only_existing = 0; int opt_ignore_existing = 0; +int need_messages_from_generator = 0; int max_delete = 0; OFF_T max_size = 0; int ignore_errors = 0; @@ -142,6 +144,9 @@ int basis_dir_cnt = 0; int verbose = 0; int quiet = 0; int itemize_changes = 0; +int log_before_transfer = 0; +int log_format_has_i = 0; +int log_format_has_o_or_i = 0; int always_checksum = 0; int list_only = 0; @@ -151,7 +156,7 @@ char *batch_name = NULL; static int daemon_opt; /* sets am_daemon after option error-reporting */ static int F_option_cnt = 0; static int modify_window_set; -static int refused_verbose, refused_delete, refused_archive_part; +static int refused_delete, refused_archive_part; static int refused_partial, refused_progress, refused_delete_before; static char *dest_option = NULL; static char *max_size_arg; @@ -285,6 +290,7 @@ void usage(enum logcode F) rprintf(F," --rsync-path=PATH specify path to rsync on the remote machine\n"); rprintf(F," --existing only update files that already exist on receiver\n"); rprintf(F," --ignore-existing ignore files that already exist on receiving side\n"); + rprintf(F," --remove-sent-files sent files/symlinks are removed from sending side\n"); rprintf(F," --del an alias for --delete-during\n"); rprintf(F," --delete delete files that don't exist on the sending side\n"); rprintf(F," --delete-before receiver deletes before transfer (default)\n"); @@ -368,6 +374,7 @@ static struct poptOption long_options[] = { {"delete-during", 0, POPT_ARG_NONE, &delete_during, 0, 0, 0 }, {"delete-after", 0, POPT_ARG_NONE, &delete_after, 0, 0, 0 }, {"delete-excluded", 0, POPT_ARG_NONE, &delete_excluded, 0, 0, 0 }, + {"remove-sent-files",0, POPT_ARG_NONE, &remove_sent_files, 0, 0, 0 }, {"force", 0, POPT_ARG_NONE, &force_delete, 0, 0, 0 }, {"numeric-ids", 0, POPT_ARG_NONE, &numeric_ids, 0, 0, 0 }, {"filter", 'f', POPT_ARG_STRING, 0, OPT_FILTER, 0, 0 }, @@ -538,8 +545,7 @@ static void set_refuse_options(char *bp) if (!op->longName && !*shortname) break; if ((op->longName && wildmatch(bp, op->longName)) - || (*shortname && wildmatch(bp, shortname)) - || op->val == OPT_DAEMON) { + || (*shortname && wildmatch(bp, shortname))) { if (op->argInfo == POPT_ARG_VAL) op->argInfo = POPT_ARG_NONE; op->val = (op - long_options) + OPT_REFUSED_BASE; @@ -547,9 +553,6 @@ static void set_refuse_options(char *bp) /* These flags are set to let us easily check * an implied option later in the code. */ switch (*shortname) { - case 'v': - refused_verbose = op->val; - break; case 'r': case 'd': case 'l': case 'p': case 't': case 'g': case 'o': case 'D': refused_archive_part = op->val; @@ -578,6 +581,17 @@ static void set_refuse_options(char *bp) *cp = ' '; bp = cp + 1; } + + for (op = long_options; ; op++) { + *shortname = op->shortName; + if (!op->longName && !*shortname) + break; + if (op->val == OPT_DAEMON) { + if (op->argInfo == POPT_ARG_VAL) + op->argInfo = POPT_ARG_NONE; + op->val = (op - long_options) + OPT_REFUSED_BASE; + } + } } @@ -968,6 +982,17 @@ int parse_arguments(int *argc, const char ***argv, int frommain) return 0; } + if (remove_sent_files) { + /* We only want to infer this refusal of --remove-sent-files + * via the refusal of "delete", not any of the "delete-FOO" + * options. */ + if (refused_delete && am_sender) { + create_refuse_error(refused_delete); + return 0; + } + need_messages_from_generator = 1; + } + *argv = poptGetArgs(pc); *argc = count_args(*argv); @@ -1057,13 +1082,29 @@ int parse_arguments(int *argc, const char ***argv, int frommain) return 0; } - if (do_progress && !verbose && !itemize_changes) { - if (refused_verbose) { - create_refuse_error(refused_verbose); - return 0; - } + if (log_format) { + if (strstr(log_format, "%i") != NULL) + log_format_has_i = 1; + if (strstr(log_format, "%b") == NULL + && strstr(log_format, "%c") == NULL) + log_before_transfer = !am_server; + } else if (itemize_changes) { + log_format = "%i %n%L"; + log_format_has_i = 1; + log_before_transfer = !am_server; + } + + if ((do_progress || dry_run) && !verbose && !log_before_transfer + && !am_server) verbose = 1; + + if (verbose && !log_format) { + log_format = "%n%L"; + log_before_transfer = !am_server; } + if (log_format_has_i + || (log_format && strstr(log_format, "%o") != NULL)) + log_format_has_o_or_i = 1; if (daemon_bwlimit && (!bwlimit || bwlimit > daemon_bwlimit)) bwlimit = daemon_bwlimit; @@ -1214,8 +1255,6 @@ void server_options(char **args,int *argc) * default for remote transfers, and in any case old versions * of rsync will not understand it. */ - if (itemize_changes && am_sender) - argstr[x++] = 'i'; if (preserve_hard_links) argstr[x++] = 'H'; if (preserve_uid) @@ -1261,6 +1300,17 @@ void server_options(char **args,int *argc) if (list_only > 1) args[ac++] = "--list-only"; + /* The server side doesn't use our log-format, but in certain + * circumstances they need to know a little about the option. */ + if (log_format && am_sender) { + if (log_format_has_i) + args[ac++] = "--log-format=%i"; + else if (log_format_has_o_or_i) + args[ac++] = "--log-format=%o"; + else if (!verbose) + args[ac++] = "--log-format=X"; + } + if (block_size) { if (asprintf(&arg, "-B%lu", block_size) < 0) goto oom; @@ -1400,6 +1450,9 @@ void server_options(char **args,int *argc) if (fuzzy_basis && am_sender) args[ac++] = "--fuzzy"; + if (remove_sent_files) + args[ac++] = "--remove-sent-files"; + *argc = ac; return;