-
- qsort(flist->files,flist->count,
- sizeof(flist->files[0]),
- (int (*)())file_compare);
-
- for (i=1;i<flist->count;i++) {
- if (flist->files[i]->basename &&
- flist->files[i-1]->basename &&
- strcmp(f_name(flist->files[i]),
- f_name(flist->files[i-1])) == 0) {
- if (verbose > 1 && !am_server)
- rprintf(FINFO,"removing duplicate name %s from file list %d\n",
- f_name(flist->files[i-1]),i-1);
- /* it's not great that the flist knows the semantics of the
- * file memory usage, but i'd rather not add a flag byte
- * to that struct. XXX can i use a bit in the flags field? */
+
+ qsort(flist->files, flist->count,
+ sizeof(flist->files[0]), (int (*)()) file_compare);
+
+ for (i = no_dups? 0 : flist->count; i < flist->count; i++) {
+ if (flist->files[i]->basename) {
+ prev_i = i;
+ break;
+ }
+ }
+ while (++i < flist->count) {
+ if (!flist->files[i]->basename)
+ continue;
+ if (f_name_cmp(flist->files[i], flist->files[prev_i]) == 0) {
+ if (verbose > 1 && !am_server) {
+ rprintf(FINFO,
+ "removing duplicate name %s from file list %d\n",
+ f_name(flist->files[i]), i);
+ }
+ /* Make sure that if we unduplicate '.', that we don't
+ * lose track of a user-specified starting point (or
+ * else deletions will mysteriously fail with -R). */
+ if (flist->files[i]->flags & FLAG_TOP_DIR)
+ flist->files[prev_i]->flags |= FLAG_TOP_DIR;
+ /* it's not great that the flist knows the semantics of
+ * the file memory usage, but i'd rather not add a flag
+ * byte to that struct.
+ * XXX can i use a bit in the flags field? */