Got rid of a superfluous extern.
[rsync/rsync-patches.git] / omit-dir-changes.diff
CommitLineData
59d64e0b
WD
1This patch from Antti Tapaninen added the --omit-dir-changes option, which
2tells rsync to not affect any attributes on the directories in the transfer.
3
4--- old/generator.c
5+++ new/generator.c
6@@ -44,6 +44,7 @@ extern int preserve_uid;
7 extern int preserve_gid;
8 extern int preserve_times;
9 extern int omit_dir_times;
10+extern int omit_dir_changes;
11 extern int delete_mode;
12 extern int delete_before;
13 extern int delete_during;
14@@ -347,10 +348,11 @@ void itemize(struct file_struct *file, i
15 iflags |= ITEM_REPORT_TIME;
16 if ((file->mode & CHMOD_BITS) != (st->st_mode & CHMOD_BITS))
17 iflags |= ITEM_REPORT_PERMS;
18- if (preserve_uid && am_root && file->uid != st->st_uid)
19+ if (preserve_uid && am_root && file->uid != st->st_uid
20+ && !(omit_dir_changes && S_ISDIR(st->st_mode)))
21 iflags |= ITEM_REPORT_OWNER;
22- if (preserve_gid && file->gid != GID_NONE
23- && st->st_gid != file->gid)
24+ if (preserve_gid && file->gid != GID_NONE && st->st_gid != file->gid
25+ && !(omit_dir_changes && S_ISDIR(st->st_mode)))
26 iflags |= ITEM_REPORT_GROUP;
27 } else
28 iflags |= ITEM_IS_NEW;
29@@ -895,7 +897,7 @@ static void recv_generator(char *fname,
30
31 /* If we're not preserving permissions, change the file-list's
32 * mode based on the local permissions and some heuristics. */
33- if (!preserve_perms) {
34+ if (!preserve_perms || (omit_dir_changes && S_ISDIR(st.st_mode))) {
35 int exists = statret == 0
36 && S_ISDIR(st.st_mode) == S_ISDIR(file->mode);
37 file->mode = dest_mode(file->mode, st.st_mode, exists);
38--- old/options.c
39+++ new/options.c
40@@ -55,6 +55,7 @@ int preserve_uid = 0;
41 int preserve_gid = 0;
42 int preserve_times = 0;
43 int omit_dir_times = 0;
44+int omit_dir_changes = 0;
45 int update_only = 0;
46 int cvs_exclude = 0;
47 int dry_run = 0;
48@@ -311,6 +312,7 @@ void usage(enum logcode F)
49 rprintf(F," -D same as --devices --specials\n");
50 rprintf(F," -t, --times preserve times\n");
51 rprintf(F," -O, --omit-dir-times omit directories when preserving times\n");
52+ rprintf(F," --omit-dir-changes omit directories when preserving any attributes\n");
53 rprintf(F," --super receiver attempts super-user activities\n");
54 rprintf(F," -S, --sparse handle sparse files efficiently\n");
55 rprintf(F," -n, --dry-run show what would have been transferred\n");
56@@ -425,6 +427,7 @@ static struct poptOption long_options[]
57 {"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 },
58 {"no-t", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 },
59 {"omit-dir-times", 'O', POPT_ARG_VAL, &omit_dir_times, 2, 0, 0 },
60+ {"omit-dir-changes", 0, POPT_ARG_NONE, &omit_dir_changes, 0, 0, 0 },
61 {"modify-window", 0, POPT_ARG_INT, &modify_window, OPT_MODIFY_WINDOW, 0, 0 },
62 {"super", 0, POPT_ARG_VAL, &am_root, 2, 0, 0 },
63 {"no-super", 0, POPT_ARG_VAL, &am_root, 0, 0, 0 },
64@@ -1285,6 +1288,9 @@ int parse_arguments(int *argc, const cha
65 "P *%s", backup_suffix);
66 parse_rule(&filter_list, backup_dir_buf, 0, 0);
67 }
68+
69+ if (omit_dir_changes)
70+ omit_dir_times = 2;
71 if (make_backups && !backup_dir)
72 omit_dir_times = 1;
73
74@@ -1513,6 +1519,8 @@ void server_options(char **args,int *arg
75 argstr[x++] = 'm';
76 if (omit_dir_times == 2)
77 argstr[x++] = 'O';
78+ if (omit_dir_changes == 1)
79+ args[ac++] = "--omit-dir-changes";
80 } else {
81 if (copy_links)
82 argstr[x++] = 'L';
83--- old/receiver.c
84+++ new/receiver.c
85@@ -37,6 +37,7 @@ extern int protocol_version;
86 extern int relative_paths;
87 extern int preserve_hard_links;
88 extern int preserve_perms;
89+extern int omit_dir_changes;
90 extern int basis_dir_cnt;
91 extern int make_backups;
92 extern int cleanup_got_literal;
93@@ -541,7 +542,7 @@ int recv_files(int f_in, struct file_lis
94
95 /* If we're not preserving permissions, change the file-list's
96 * mode based on the local permissions and some heuristics. */
97- if (!preserve_perms) {
98+ if (!preserve_perms || (omit_dir_changes && S_ISDIR(st.st_mode))) {
99 int exists = fd1 != -1;
100 file->mode = dest_mode(file->mode, st.st_mode, exists);
101 }
102--- old/rsync.c
103+++ new/rsync.c
104@@ -36,6 +36,7 @@ extern int preserve_perms;
105 extern int preserve_executability;
106 extern int preserve_times;
107 extern int omit_dir_times;
108+extern int omit_dir_changes;
109 extern int am_root;
110 extern int am_server;
111 extern int am_sender;
112@@ -159,9 +160,11 @@ int set_file_attrs(char *fname, struct f
113 updated = 1;
114 }
115
116- change_uid = am_root && preserve_uid && st->st_uid != file->uid;
117+ change_uid = am_root && preserve_uid && st->st_uid != file->uid
118+ && !(omit_dir_changes && S_ISDIR(st->st_mode));
119 change_gid = preserve_gid && file->gid != GID_NONE
120- && st->st_gid != file->gid;
121+ && st->st_gid != file->gid
122+ && !(omit_dir_changes && S_ISDIR(st->st_mode));
123 #if !defined HAVE_LCHOWN && !defined CHOWN_MODIFIES_SYMLINK
124 if (S_ISLNK(st->st_mode))
125 ;