From d2ea5980ba7986ddd583b4f55737eb56a0ed66a6 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Mon, 1 Aug 2005 21:58:16 +0000 Subject: [PATCH] Allow the user to specify a dot dir in the source path when using --relative, making it trim the duplicated dirs. --- flist.c | 61 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/flist.c b/flist.c index 30e88ab4..4f40da8a 100644 --- a/flist.c +++ b/flist.c @@ -1166,7 +1166,41 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) dir = fname; fname = p + 1; } - } else if (implied_dirs && (p=strrchr(fname,'/')) && p != fname) { + } else if ((p = strstr(fname, "/./")) != NULL) { + *p = '\0'; + if (p == fname) + dir = "/"; + else + dir = fname; + fname = p + 3; + } + + if (!*fname) + fname = "."; + + if (dir && *dir) { + static char *lastdir; + static int lastdir_len; + + strcpy(olddir, curr_dir); /* can't overflow */ + + if (!push_dir(dir)) { + io_error |= IOERR_GENERAL; + rsyserr(FERROR, errno, "push_dir %s failed", + full_fname(dir)); + continue; + } + + if (lastdir && strcmp(lastdir, dir) == 0) { + flist_dir = lastdir; + flist_dir_len = lastdir_len; + } else { + flist_dir = lastdir = strdup(dir); + flist_dir_len = lastdir_len = strlen(dir); + } + } + + if (implied_dirs && (p=strrchr(fname,'/')) && p != fname) { /* Send the implied directories at the start of the * source spec, so we get their permissions right. */ char *lp = lastpath, *fn = fname, *slash = fname; @@ -1197,31 +1231,6 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) } } - if (!*fname) - fname = "."; - - if (dir && *dir) { - static char *lastdir; - static int lastdir_len; - - strcpy(olddir, curr_dir); /* can't overflow */ - - if (!push_dir(dir)) { - io_error |= IOERR_GENERAL; - rsyserr(FERROR, errno, "push_dir %s failed", - full_fname(dir)); - continue; - } - - if (lastdir && strcmp(lastdir, dir) == 0) { - flist_dir = lastdir; - flist_dir_len = lastdir_len; - } else { - flist_dir = lastdir = strdup(dir); - flist_dir_len = lastdir_len = strlen(dir); - } - } - if (one_file_system) filesystem_dev = st.st_dev; -- 2.34.1