Allow the user to specify a dot dir in the source path when
authorWayne Davison <wayned@samba.org>
Mon, 1 Aug 2005 21:58:16 +0000 (21:58 +0000)
committerWayne Davison <wayned@samba.org>
Mon, 1 Aug 2005 21:58:16 +0000 (21:58 +0000)
using --relative, making it trim the duplicated dirs.

flist.c

diff --git a/flist.c b/flist.c
index 30e88ab..4f40da8 100644 (file)
--- 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;