If an arg is excluded, don't include its implied dirs.
[rsync/rsync.git] / flist.c
diff --git a/flist.c b/flist.c
index 4e302aa..bbba3ee 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -366,19 +366,23 @@ int change_pathname(struct file_struct *file, const char *dir, int dirlen)
                        change_dir(orig_dir, CD_SKIP_CHDIR);
        }
 
-       if (!change_dir(dir ? dir : orig_dir, CD_NORMAL)) {
+       pathname = dir;
+       pathname_len = dirlen;
+
+       if (!dir)
+               dir = orig_dir;
+
+       if (!change_dir(dir, CD_NORMAL)) {
          chdir_error:
                io_error |= IOERR_GENERAL;
                rsyserr(FERROR, errno, "change_dir %s failed", full_fname(dir));
-               change_dir(orig_dir, CD_NORMAL);
+               if (dir != orig_dir)
+                       change_dir(orig_dir, CD_NORMAL);
                pathname = NULL;
                pathname_len = 0;
                return 0;
        }
 
-       pathname = dir;
-       pathname_len = dirlen;
-
        return 1;
 }
 
@@ -2037,7 +2041,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
                }
 
                if (inc_recurse && relative_paths && *fbuf) {
-                       if ((p = strchr(fbuf+1, '/')) != NULL) {
+                       if ((p = strchr(fbuf+1, '/')) != NULL
+                        && !is_excluded(fbuf, S_ISDIR(st.st_mode) != 0, ALL_FILTERS)) {
                                if (p - fbuf == 1 && *fbuf == '.') {
                                        if ((fn = strchr(p+1, '/')) != NULL)
                                                p = fn;
@@ -2047,7 +2052,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
                                if (fn == p)
                                        continue;
                        }
-               } else if (implied_dirs && (p=strrchr(fbuf,'/')) && p != fbuf) {
+               } else if (implied_dirs && (p=strrchr(fbuf,'/')) && p != fbuf
+                   && !is_excluded(fbuf, S_ISDIR(st.st_mode) != 0, ALL_FILTERS)) {
                        /* Send the implied directories at the start of the
                         * source spec, so we get their permissions right. */
                        send_implied_dirs(f, flist, fbuf, fbuf, p, flags, 0);