From f9998046a3b0898810f8ed3b6368643b4c5874d9 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sat, 1 Sep 2007 16:57:01 +0000 Subject: [PATCH] Made omit_dir_times a static variable in options.c by encoding all the time-preserving semantics into preserve_times. --- generator.c | 5 ++--- options.c | 17 ++++++++++------- rsync.c | 3 +-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/generator.c b/generator.c index 5f042936..e91e3a6f 100644 --- a/generator.c +++ b/generator.c @@ -43,7 +43,6 @@ extern int preserve_specials; extern int preserve_hard_links; extern int preserve_perms; extern int preserve_times; -extern int omit_dir_times; extern int uid_ndx; extern int gid_ndx; extern int delete_mode; @@ -554,7 +553,7 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre { if (statret >= 0) { /* A from-dest-dir statret can == 1! */ int keep_time = !preserve_times ? 0 - : S_ISDIR(file->mode) ? !omit_dir_times + : S_ISDIR(file->mode) ? preserve_times > 1 : !S_ISLNK(file->mode); if (S_ISREG(file->mode) && F_LENGTH(file) != sxp->st.st_size) @@ -1879,7 +1878,7 @@ void generate_files(int f_out, const char *local_name) } solo_file = local_name; dir_tweaking = !(list_only || solo_file || dry_run); - need_retouch_dir_times = preserve_times && !omit_dir_times; + need_retouch_dir_times = preserve_times > 1; lull_mod = allowed_lull * 5; if (verbose > 2) diff --git a/options.c b/options.c index 32b574e3..4779cfa1 100644 --- a/options.c +++ b/options.c @@ -56,7 +56,6 @@ int preserve_specials = 0; int preserve_uid = 0; int preserve_gid = 0; int preserve_times = 0; -int omit_dir_times = 0; int update_only = 0; int cvs_exclude = 0; int dry_run = 0; @@ -192,6 +191,7 @@ char *iconv_opt = ICONV_OPTION; struct chmod_mode_struct *chmod_modes = NULL; static int daemon_opt; /* sets am_daemon after option error-reporting */ +static int omit_dir_times = 0; static int F_option_cnt = 0; static int modify_window_set; static int itemize_changes = 0; @@ -474,10 +474,10 @@ static struct poptOption long_options[] = { {"xattrs", 'X', POPT_ARG_NONE, 0, 'X', 0, 0 }, {"no-xattrs", 0, POPT_ARG_VAL, &preserve_xattrs, 0, 0, 0 }, {"no-X", 0, POPT_ARG_VAL, &preserve_xattrs, 0, 0, 0 }, - {"times", 't', POPT_ARG_VAL, &preserve_times, 1, 0, 0 }, + {"times", 't', POPT_ARG_VAL, &preserve_times, 2, 0, 0 }, {"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, {"no-t", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, - {"omit-dir-times", 'O', POPT_ARG_VAL, &omit_dir_times, 2, 0, 0 }, + {"omit-dir-times", 'O', POPT_ARG_VAL, &omit_dir_times, 1, 0, 0 }, {"modify-window", 0, POPT_ARG_INT, &modify_window, OPT_MODIFY_WINDOW, 0, 0 }, {"super", 0, POPT_ARG_VAL, &am_root, 2, 0, 0 }, {"no-super", 0, POPT_ARG_VAL, &am_root, 0, 0, 0 }, @@ -1015,7 +1015,7 @@ int parse_arguments(int *argc, const char ***argv, int frommain) preserve_links = 1; #endif preserve_perms = 1; - preserve_times = 1; + preserve_times = 2; preserve_gid = 1; preserve_uid = 1; preserve_devices = 1; @@ -1395,6 +1395,9 @@ int parse_arguments(int *argc, const char ***argv, int frommain) } } + if (omit_dir_times && preserve_times > 1) + preserve_times = 1; + if (!backup_suffix) backup_suffix = backup_dir ? "" : BACKUP_SUFFIX; backup_suffix_len = strlen(backup_suffix); @@ -1427,8 +1430,8 @@ int parse_arguments(int *argc, const char ***argv, int frommain) "P *%s", backup_suffix); parse_rule(&filter_list, backup_dir_buf, 0, 0); } - if (make_backups && !backup_dir) - omit_dir_times = 1; + if (make_backups && !backup_dir && preserve_times > 1) + preserve_times = 1; if (stdout_format) { if (am_server && log_format_has(stdout_format, 'I')) @@ -1654,7 +1657,7 @@ void server_options(char **args,int *argc) argstr[x++] = 'K'; if (prune_empty_dirs) argstr[x++] = 'm'; - if (omit_dir_times == 2) + if (omit_dir_times) argstr[x++] = 'O'; } else { if (copy_links) diff --git a/rsync.c b/rsync.c index 4fcdea1d..5d09fd3e 100644 --- a/rsync.c +++ b/rsync.c @@ -33,7 +33,6 @@ extern int preserve_xattrs; extern int preserve_perms; extern int preserve_executability; extern int preserve_times; -extern int omit_dir_times; extern int am_root; extern int am_server; extern int am_sender; @@ -311,7 +310,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, statx *sxp, set_stat_xattr(fname, file); #endif - if (!preserve_times || (S_ISDIR(sxp->st.st_mode) && omit_dir_times)) + if (!preserve_times || (S_ISDIR(sxp->st.st_mode) && preserve_times == 1)) flags |= ATTRS_SKIP_MTIME; if (!(flags & ATTRS_SKIP_MTIME) && cmp_time(sxp->st.st_mtime, file->modtime) != 0) { -- 2.34.1