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:
5 rsync -avR --source-cd=/usr local/bin host:/
7 For two systems where one uses /usr/local/bin and the other /local/bin.
9 --- orig/flist.c 2005-02-26 05:22:50
10 +++ flist.c 2005-02-26 05:24:15
11 @@ -63,6 +63,7 @@ extern int force_delete;
12 extern int orig_umask;
13 extern int make_backups;
14 extern unsigned int curr_dir_len;
15 +extern char *source_cd;
16 extern char *backup_dir;
17 extern char *backup_suffix;
18 extern int backup_suffix_len;
19 @@ -1078,13 +1079,14 @@ struct file_list *send_file_list(int f,
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);
28 + source_cd = argv[0];
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);
38 char fname2[MAXPATHLEN];
39 --- orig/options.c 2005-02-25 18:44:31
40 +++ options.c 2005-02-22 18:06:58
41 @@ -81,6 +81,7 @@ char *remote_filesfrom_file = NULL;
45 +char *source_cd = NULL;
47 int daemon_over_rsh = 0;
49 @@ -267,6 +268,7 @@ void usage(enum logcode F)
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);
57 @@ -417,6 +419,7 @@ static struct poptOption long_options[]
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 },
65 @@ -910,6 +913,11 @@ int parse_arguments(int *argc, const cha
69 + if (source_cd && files_from) {
70 + snprintf(err_buf, sizeof err_buf,
71 + "--source-cd cannot be used with --files-from\n");
74 if (read_batch && files_from) {
75 snprintf(err_buf, sizeof err_buf,
76 "--read-batch cannot be used with --files-from\n");
77 @@ -1006,6 +1014,14 @@ int parse_arguments(int *argc, const cha
78 backup_dir = sanitize_path(NULL, backup_dir, NULL, 0);
80 files_from = sanitize_path(NULL, files_from, NULL, 0);
82 + source_cd = sanitize_path(NULL, source_cd, NULL, 0);
83 + } else if (source_cd && am_daemon) {
85 + for (i = *argc; i-- > 0; ) {
86 + if ((*argv)[i][0] == '/')
90 if (server_filter_list.head && !am_sender) {
91 struct filter_list_struct *elp = &server_filter_list;
92 @@ -1395,6 +1411,11 @@ void server_options(char **args,int *arg
93 } else if (keep_partial)
94 args[ac++] = "--partial";
96 + if (source_cd && !am_sender) {
97 + args[ac++] = "--source-cd";
98 + args[ac++] = source_cd;
102 args[ac++] = "--ignore-errors";
104 --- orig/rsync.yo 2005-02-26 05:22:51
105 +++ rsync.yo 2005-02-22 18:20:24
106 @@ -304,6 +304,7 @@ to the detailed description below for a
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)
114 @@ -510,6 +511,11 @@ the bf(--no-implied-dirs) option would o
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.
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.
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