Commit | Line | Data |
---|---|---|
df5a5090 WD |
1 | This adds the --source-cd option, which is useful when it is combined with |
2 | the --relative option because it lets you set how much of the source path | |
3 | is outside of the transfer. For instance: | |
4 | ||
5 | rsync -avR --source-cd=/usr local/bin host:/ | |
6 | ||
7 | For two systems where one uses /usr/local/bin and the other /local/bin. | |
8 | ||
18ae7b87 | 9 | --- orig/flist.c 2005-03-30 17:31:41 |
d608ca23 WD |
10 | +++ flist.c 2005-03-05 00:31:42 |
11 | @@ -57,6 +57,7 @@ extern int copy_unsafe_links; | |
e20f0bda WD |
12 | extern int protocol_version; |
13 | extern int sanitize_paths; | |
df5a5090 | 14 | extern int orig_umask; |
df5a5090 | 15 | +extern char *source_cd; |
d608ca23 WD |
16 | extern struct stats stats; |
17 | extern struct file_list *the_file_list; | |
e20f0bda | 18 | |
18ae7b87 | 19 | @@ -1086,13 +1087,14 @@ struct file_list *send_file_list(int f, |
df5a5090 WD |
20 | |
21 | io_start_buffering_out(); | |
22 | if (filesfrom_fd >= 0) { | |
23 | - if (argv[0] && !push_dir(argv[0])) { | |
24 | - rsyserr(FERROR, errno, "push_dir %s failed", | |
25 | - full_fname(argv[0])); | |
26 | - exit_cleanup(RERR_FILESELECT); | |
27 | - } | |
28 | + source_cd = argv[0]; | |
29 | use_ff_fd = 1; | |
30 | } | |
31 | + if (source_cd && !push_dir(source_cd)) { | |
32 | + rsyserr(FERROR, errno, "push_dir %s failed", | |
33 | + full_fname(source_cd)); | |
34 | + exit_cleanup(RERR_FILESELECT); | |
35 | + } | |
36 | ||
37 | while (1) { | |
36bbf3d1 | 38 | struct file_struct *file; |
18ae7b87 | 39 | --- orig/options.c 2005-03-31 00:24:21 |
def2ace9 WD |
40 | +++ options.c 2005-03-01 01:37:22 |
41 | @@ -81,6 +81,7 @@ char *filesfrom_host = NULL; | |
df5a5090 WD |
42 | int eol_nulls = 0; |
43 | int recurse = 0; | |
44 | int xfer_dirs = 0; | |
45 | +char *source_cd = NULL; | |
46 | int am_daemon = 0; | |
47 | int daemon_over_rsh = 0; | |
48 | int do_stats = 0; | |
36bbf3d1 | 49 | @@ -268,6 +269,7 @@ void usage(enum logcode F) |
df5a5090 WD |
50 | rprintf(F," -R, --relative use relative path names\n"); |
51 | rprintf(F," --no-relative turn off --relative\n"); | |
52 | rprintf(F," --no-implied-dirs don't send implied dirs with -R\n"); | |
53 | + rprintf(F," --source-cd=DIR a relative source path starts in this DIR\n"); | |
54 | rprintf(F," -b, --backup make backups (see --suffix & --backup-dir)\n"); | |
55 | rprintf(F," --backup-dir=DIR make backups into hierarchy based in DIR\n"); | |
56 | rprintf(F," --suffix=SUFFIX set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX); | |
e621c041 | 57 | @@ -420,6 +422,7 @@ static struct poptOption long_options[] |
df5a5090 WD |
58 | {"list-only", 0, POPT_ARG_VAL, &list_only, 2, 0, 0 }, |
59 | {"relative", 'R', POPT_ARG_VAL, &relative_paths, 1, 0, 0 }, | |
60 | {"no-relative", 0, POPT_ARG_VAL, &relative_paths, 0, 0, 0 }, | |
61 | + {"source-cd", 0, POPT_ARG_STRING, &source_cd, 0, 0, 0 }, | |
62 | {"rsh", 'e', POPT_ARG_STRING, &shell_cmd, 0, 0, 0 }, | |
63 | {"block-size", 'B', POPT_ARG_LONG, &block_size, 0, 0, 0 }, | |
64 | {"max-delete", 0, POPT_ARG_INT, &max_delete, 0, 0, 0 }, | |
e621c041 | 65 | @@ -914,6 +917,11 @@ int parse_arguments(int *argc, const cha |
1dd0573e WD |
66 | } else if (dry_run) |
67 | write_batch = 0; | |
df5a5090 WD |
68 | } |
69 | + if (source_cd && files_from) { | |
70 | + snprintf(err_buf, sizeof err_buf, | |
71 | + "--source-cd cannot be used with --files-from\n"); | |
72 | + return 0; | |
73 | + } | |
74 | if (read_batch && files_from) { | |
75 | snprintf(err_buf, sizeof err_buf, | |
76 | "--read-batch cannot be used with --files-from\n"); | |
e621c041 | 77 | @@ -1008,6 +1016,14 @@ int parse_arguments(int *argc, const cha |
def2ace9 WD |
78 | partial_dir = sanitize_path(NULL, partial_dir, NULL, 0); |
79 | if (backup_dir) | |
df5a5090 | 80 | backup_dir = sanitize_path(NULL, backup_dir, NULL, 0); |
df5a5090 WD |
81 | + if (source_cd) |
82 | + source_cd = sanitize_path(NULL, source_cd, NULL, 0); | |
83 | + } else if (source_cd && am_daemon) { | |
84 | + int i; | |
85 | + for (i = *argc; i-- > 0; ) { | |
86 | + if ((*argv)[i][0] == '/') | |
87 | + (*argv)[i]++; | |
88 | + } | |
89 | } | |
90 | if (server_filter_list.head && !am_sender) { | |
91 | struct filter_list_struct *elp = &server_filter_list; | |
18ae7b87 | 92 | @@ -1400,6 +1416,11 @@ void server_options(char **args,int *arg |
df5a5090 WD |
93 | } else if (keep_partial) |
94 | args[ac++] = "--partial"; | |
95 | ||
96 | + if (source_cd && !am_sender) { | |
97 | + args[ac++] = "--source-cd"; | |
98 | + args[ac++] = source_cd; | |
99 | + } | |
100 | + | |
101 | if (ignore_errors) | |
102 | args[ac++] = "--ignore-errors"; | |
103 | ||
18ae7b87 | 104 | --- orig/rsync.yo 2005-03-30 16:57:29 |
df5a5090 | 105 | +++ rsync.yo 2005-02-22 18:20:24 |
d608ca23 | 106 | @@ -303,6 +303,7 @@ to the detailed description below for a |
df5a5090 WD |
107 | -R, --relative use relative path names |
108 | --no-relative turn off --relative | |
109 | --no-implied-dirs don't send implied dirs with -R | |
110 | + --source-cd=DIR a relative source path starts in this DIR | |
111 | -b, --backup make backups (see --suffix & --backup-dir) | |
112 | --backup-dir=DIR make backups into hierarchy based in DIR | |
113 | --suffix=SUFFIX backup suffix (default ~ w/o --backup-dir) | |
e621c041 | 114 | @@ -511,6 +512,11 @@ the bf(--no-implied-dirs) option would o |
df5a5090 WD |
115 | which means that if "/path" was a real directory on one machine and a |
116 | symlink of the other machine, rsync would not try to change this. | |
117 | ||
118 | +dit(bf(--source-cd=DIR)) Set the specified directory as the default dir for | |
119 | +the source side of the transfer. This is most useful when combined with | |
120 | +the bf(--relative) option because it lets you move directories from the | |
121 | +source path outside the transfer. | |
122 | + | |
123 | dit(bf(-b, --backup)) With this option, preexisting destination files are | |
124 | renamed as each file is transferred or deleted. You can control where the | |
125 | backup file goes and what (if any) suffix gets appended using the |