[patch] making rsync less verbose

Dick Streefland dick.streefland at altium.nl
Tue Jan 6 17:51:41 GMT 2004


Unless you suppress all output with the -q option, rsync will always
print an initial "building/receiving file list ... done" line. In my
opinion, this is a bit superfluous. When I want to see a progress
indication, I can use the --progress option. Another issue is the
3-line transfer speed and speedup factor report at the end. So every
rsync invocation produces at least four lines of output.

Attached are two patches to reduce the verbosity of rsync. The first
one removes the initial line. The second patch adds a new option
-s/--speedup to control the generation of the speedup report, which is
now disabled by default.

What do you think? Would you consider something like this for future
versions of rsync?

-- 
Dick Streefland                      ////                      Altium BV
dick.streefland at altium.nl           (@ @)          http://www.altium.com
--------------------------------oOO--(_)--OOo---------------------------
-------------- next part --------------
--- rsync-2.6.0/flist.c.orig	2004-01-06 16:16:09.000000000 +0100
+++ rsync-2.6.0/flist.c	2004-01-06 16:30:15.000000000 +0100
@@ -76,15 +76,12 @@
 
 static int show_filelist_p(void)
 {
-	return verbose && (recurse || files_from) && !am_server;
+	return do_progress && verbose && (recurse || files_from) && !am_server;
 }
 
 static void start_filelist_progress(char *kind)
 {
-	rprintf(FINFO, "%s ... ", kind);
-	if ((verbose > 1) || do_progress)
-		rprintf(FINFO, "\n");
-	rflush(FINFO);
+	rprintf(FINFO, "%s ... \n", kind);
 }
 
 
@@ -96,20 +93,16 @@
 
 static void maybe_emit_filelist_progress(const struct file_list *flist)
 {
-	if (do_progress && show_filelist_p() && ((flist->count % 100) == 0))
+	if (show_filelist_p() && ((flist->count % 100) == 0))
 		emit_filelist_progress(flist);
 }
 
 
 static void finish_filelist_progress(const struct file_list *flist)
 {
-	if (do_progress) {
-		/* This overwrites the progress line */
-		rprintf(FINFO, "%d file%sto consider\n",
-			flist->count, flist->count == 1 ? " " : "s ");
-	} else {
-		rprintf(FINFO, "done\n");
-	}
+	/* This overwrites the progress line */
+	rprintf(FINFO, "%d file%sto consider\n",
+		flist->count, flist->count == 1 ? " " : "s ");
 }
 
 void show_flist_stats(void)
-------------- next part --------------
--- rsync-2.6.0/main.c.orig	2003-12-20 17:57:24.000000000 +0100
+++ rsync-2.6.0/main.c	2004-01-06 17:10:19.000000000 +0100
@@ -32,6 +32,7 @@
 extern int am_daemon;
 extern int verbose;
 extern int protocol_version;
+extern int show_speedup;
 
 /* there's probably never more than at most 2 outstanding child processes,
  * but set it higher just in case.
@@ -146,7 +147,7 @@
 			(double)stats.total_read);
 	}
 
-	if (verbose || do_stats) {
+	if (show_speedup || do_stats) {
 		rprintf(FINFO,"\nwrote %.0f bytes  read %.0f bytes  %.2f bytes/sec\n",
 			(double)stats.total_written,
 			(double)stats.total_read,
--- rsync-2.6.0/options.c.orig	2003-12-30 19:16:25.000000000 +0100
+++ rsync-2.6.0/options.c	2004-01-06 17:10:19.000000000 +0100
@@ -74,6 +74,7 @@
 int am_daemon = 0;
 int daemon_over_rsh = 0;
 int do_stats=0;
+int show_speedup=0;
 int do_progress=0;
 int keep_partial=0;
 int safe_symlinks=0;
@@ -275,6 +276,7 @@
   rprintf(F,"     --blocking-io           use blocking IO for the remote shell\n");
   rprintf(F,"     --no-blocking-io        turn off --blocking-io\n");
   rprintf(F,"     --stats                 give some file transfer stats\n");
+  rprintf(F," -s, --speedup               show the speedup\n");
   rprintf(F,"     --progress              show progress during transfer\n");
   rprintf(F,"     --log-format=FORMAT     log file transfers using specified format\n");
   rprintf(F,"     --password-file=FILE    get password from FILE\n");
@@ -357,6 +359,7 @@
   {"daemon",           0,  POPT_ARG_NONE,   &am_daemon, 0, 0, 0 },
   {"no-detach",        0,  POPT_ARG_NONE,   &no_detach, 0, 0, 0 },
   {"stats",            0,  POPT_ARG_NONE,   &do_stats, 0, 0, 0 },
+  {"speedup",         's', POPT_ARG_NONE,   &show_speedup, 0, 0, 0 },
   {"progress",         0,  POPT_ARG_NONE,   &do_progress, 0, 0, 0 },
   {"partial",          0,  POPT_ARG_NONE,   &keep_partial, 0, 0, 0 },
   {"ignore-errors",    0,  POPT_ARG_NONE,   &ignore_errors, 0, 0, 0 },
--- rsync-2.6.0/rsync.1.orig	2004-01-01 20:00:11.000000000 +0100
+++ rsync-2.6.0/rsync.1	2004-01-06 17:11:56.000000000 +0100
@@ -379,6 +379,7 @@
      --blocking-io           use blocking IO for the remote shell
      --no-blocking-io        turn off --blocking-io
      --stats                 give some file transfer stats
+ -s, --speedup               show the speedup
      --progress              show progress during transfer
      --log-format=FORMAT     log file transfers using specified format
      --password-file=FILE    get password from FILE
@@ -940,6 +941,10 @@
 on the file transfer, allowing you to tell how effective the rsync
 algorithm is for your data\&.
 .IP 
+.IP "\fB--speedup\fP" 
+Show the transmission speed and the speedup achieved by the rsync
+algorithm\&.
+.IP 
 .IP "\fB--partial\fP" 
 By default, rsync will delete any partially
 transferred file if the transfer is interrupted\&. In some circumstances


More information about the rsync mailing list