diff --git a/generator.c b/generator.c
--- a/generator.c
+++ b/generator.c
-@@ -47,6 +47,7 @@ extern int preserve_perms;
+@@ -45,6 +45,7 @@ extern int preserve_hard_links;
+ extern int preserve_executability;
+ extern int preserve_perms;
extern int preserve_mtimes;
++extern int omit_dir_changes;
extern int omit_dir_times;
extern int omit_link_times;
-+extern int omit_dir_changes;
extern int delete_mode;
- extern int delete_before;
- extern int delete_during;
-@@ -506,6 +507,7 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
- const char *xname)
- {
- if (statret >= 0) { /* A from-dest-dir statret can == 1! */
-+ int omit_changes = omit_dir_changes && S_ISDIR(sxp->st.st_mode);
- int keep_time = !preserve_mtimes ? 0
+@@ -510,6 +511,7 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
: S_ISDIR(file->mode) ? !omit_dir_times
: S_ISLNK(file->mode) ? !omit_link_times
+ : 1;
++ int omit_uid_gid = omit_dir_changes && S_ISDIR(sxp->st.st_mode);
+
+ if (S_ISREG(file->mode) && F_LENGTH(file) != sxp->st.st_size)
+ iflags |= ITEM_REPORT_SIZE;
@@ -543,9 +545,9 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
} else if (preserve_executability
&& ((sxp->st.st_mode & 0111 ? 1 : 0) ^ (file->mode & 0111 ? 1 : 0)))
iflags |= ITEM_REPORT_PERMS;
- if (uid_ndx && am_root && (uid_t)F_OWNER(file) != sxp->st.st_uid)
-+ if (uid_ndx && am_root && !omit_changes && (uid_t)F_OWNER(file) != sxp->st.st_uid)
++ if (uid_ndx && !omit_uid_gid && am_root && (uid_t)F_OWNER(file) != sxp->st.st_uid)
iflags |= ITEM_REPORT_OWNER;
- if (gid_ndx && !(file->flags & FLAG_SKIP_GROUP) && sxp->st.st_gid != (gid_t)F_GROUP(file))
-+ if (gid_ndx && !omit_changes && !(file->flags & FLAG_SKIP_GROUP) && sxp->st.st_gid != (gid_t)F_GROUP(file))
++ if (gid_ndx && !omit_uid_gid && !(file->flags & FLAG_SKIP_GROUP) && sxp->st.st_gid != (gid_t)F_GROUP(file))
iflags |= ITEM_REPORT_GROUP;
#ifdef SUPPORT_ACLS
if (preserve_acls && !S_ISLNK(file->mode)) {
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -77,6 +77,7 @@ int delete_before = 0;
- int delete_after = 0;
- int delete_excluded = 0;
- int remove_source_files = 0;
+@@ -62,6 +62,7 @@ int preserve_gid = 0;
+ int preserve_mtimes = 0;
+ int preserve_atimes = 0;
+ int preserve_crtimes = 0;
+int omit_dir_changes = 0;
- int one_file_system = 0;
- int protocol_version = PROTOCOL_VERSION;
- int sparse_files = 0;
+ int omit_dir_times = 0;
+ int omit_link_times = 0;
+ int update_only = 0;
@@ -643,6 +644,7 @@ static struct poptOption long_options[] = {
{"omit-link-times", 'J', POPT_ARG_VAL, &omit_link_times, 1, 0, 0 },
{"no-omit-link-times",0, POPT_ARG_VAL, &omit_link_times, 0, 0, 0 },
{"modify-window", '@', 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 },
-@@ -2296,6 +2298,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -2296,7 +2298,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
parse_filter_str(&filter_list, backup_dir_buf, rule_template(0), 0);
}
-+ if (omit_dir_changes)
-+ omit_dir_times = 1;
-+
- if (make_backups && !backup_dir)
+- if (make_backups && !backup_dir)
++ if (omit_dir_changes || (make_backups && !backup_dir))
omit_dir_times = -1; /* Implied, so avoid -O to sender. */
-@@ -2792,6 +2797,8 @@ void server_options(char **args, int *argc_p)
+ if (stdout_format) {
+@@ -2792,6 +2794,8 @@ void server_options(char **args, int *argc_p)
args[ac++] = "--size-only";
if (do_stats)
args[ac++] = "--stats";
extern int am_root;
extern int am_server;
extern int am_daemon;
-@@ -520,9 +521,11 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+@@ -490,6 +491,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+ stat_x sx2;
+ int change_uid, change_gid;
+ mode_t new_mode = file->mode;
++ int omit_uid_gid = omit_dir_changes && S_ISDIR(sxp->st.st_mode);
+ int inherit;
+
+ if (!sxp) {
+@@ -520,9 +522,9 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
get_acl(fname, sxp);
#endif
- change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file);
-+ change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file)
-+ && !(omit_dir_changes && S_ISDIR(sxp->st.st_mode));
- change_gid = gid_ndx && !(file->flags & FLAG_SKIP_GROUP)
+- change_gid = gid_ndx && !(file->flags & FLAG_SKIP_GROUP)
- && sxp->st.st_gid != (gid_t)F_GROUP(file);
-+ && sxp->st.st_gid != (gid_t)F_GROUP(file)
-+ && !(omit_dir_changes && S_ISDIR(sxp->st.st_mode));
++ change_uid = am_root && !omit_uid_gid && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file);
++ change_gid = gid_ndx && !omit_uid_gid && !(file->flags & FLAG_SKIP_GROUP)
++ && sxp->st.st_gid != (gid_t)F_GROUP(file);
#ifndef CAN_CHOWN_SYMLINK
if (S_ISLNK(sxp->st.st_mode)) {
;