Don't print a meaningless speedup on a dry run (or --only-write-batch).
authorMatt McCutchen <matt@mattmccutchen.net>
Mon, 17 Mar 2008 21:00:16 +0000 (17:00 -0400)
committerMatt McCutchen <matt@mattmccutchen.net>
Thu, 20 Mar 2008 18:11:24 +0000 (14:11 -0400)
main.c
rsync.yo

diff --git a/main.c b/main.c
index 629f6d2..1211979 100644 (file)
--- a/main.c
+++ b/main.c
@@ -274,9 +274,17 @@ static void output_summary(void)
                        "sent %s bytes  received %s bytes  %s bytes/sec\n",
                        human_num(total_written), human_num(total_read),
                        human_dnum((total_written + total_read)/(0.5 + (endtime - starttime)), 2));
-               rprintf(FINFO, "total size is %s  speedup is %.2f%s\n",
-                       human_num(stats.total_size),
-                       (double)stats.total_size / (total_written+total_read),
+               rprintf(FINFO, "total size is %s  speedup is ",
+                       human_num(stats.total_size));
+               /* With --dry-run or with --only-write-batch (unless we're a
+                * client receiver), the byte count doesn't include actual file
+                * data, so the speedup is meaningless and we don't print it. */
+               if (write_batch < 0 ? (!am_server && !am_sender) : !dry_run)
+                       rprintf(FINFO, "%.2f",
+                               (double)stats.total_size / (total_written+total_read));
+               else
+                       rprintf(FINFO, "unknown");
+               rprintf(FINFO, "%s\n",
                        write_batch < 0 ? " (BATCH ONLY)" : dry_run ? " (DRY RUN)" : "");
        }
 
index 6bbf400..fdc0e23 100644 (file)
--- a/rsync.yo
+++ b/rsync.yo
@@ -1051,8 +1051,8 @@ call failures); if it isn't, that's a bug.  Other output is the same to the
 extent practical, but may differ in some areas.  Notably, a dry run does not
 send the actual data for file transfers, so bf(--progress) has no effect,
 the "bytes sent", "bytes received", "literal data", and "matched data"
-statistics are too small, and the "speedup" value is equivalent to a run
-where no file transfers are needed.
+statistics are too small; and the "speedup" is not printed at all because it
+is meaningless.
 
 dit(bf(-W, --whole-file)) With this option the delta-transfer algorithm
 is not used and the whole file is sent as-is instead.  The transfer may be