[patch] suggestions for -v option

Dick Streefland dick.streefland at altium.nl
Fri May 17 03:30:02 EST 2002


On Thursday 2002-05-16 15:55, Dave Dykstra wrote:
| I'm afraid we've got too much history behind the current way to change
| that now.  Undoubtedly there's lots of scripts around that expect the
| current behavior.  The --log-format option is intended for situations
| like yours.  Try "--log-format %f".  If the log-format option isn't
| flexible enough for what you want, a patch to it is much more likely
| to be accepted, especially if it is upward compatible.

I overlooked the --log-format option. I tried it, and it comes close
to what I want, but it doesn't report directory updates, file
deletions and hard links.  While I don't care very much about
directory time updates, deleted files and hard links are important.
I'm not sure whether the log_send() and log_recv() interfaces are
suitable to log these actions.

To ensure backward compatibility, a new option to suppress the
unwanted messages could be added, e.g. --no-stats. The attached patch
implements this. For completeness, I've attached a separate patch
for the second proposed change.

-- 
Dick Streefland                      ////             Altium Software BV
dick.streefland at altium.nl           (@ @)          http://www.altium.com
--------------------------------oOO--(_)--OOo---------------------------
-------------- next part --------------
--- rsync-2.5.5/flist.c.orig	Thu Mar 14 22:20:20 2002
+++ rsync-2.5.5/flist.c	Fri May 17 12:01:04 2002
@@ -34,6 +34,7 @@
 extern struct stats stats;
 
 extern int verbose;
+extern int do_stats;
 extern int do_progress;
 extern int am_server;
 extern int always_checksum;
@@ -72,7 +73,7 @@
 
 static int show_filelist_p(void)
 {
-	return verbose && recurse && !am_server;
+	return verbose && do_stats >= 0 && recurse && !am_server;
 }
 
 static void start_filelist_progress(char *kind)
--- rsync-2.5.5/main.c.orig	Wed Mar 27 06:10:44 2002
+++ rsync-2.5.5/main.c	Fri May 17 11:53:18 2002
@@ -57,7 +57,7 @@
 	extern int remote_version;
 	int send_stats;
 
-	if (do_stats) {
+	if (do_stats > 0) {
 		/* These come out from every process */
 		show_malloc_stats();
 		show_flist_stats();
@@ -93,7 +93,7 @@
 		stats.total_read = r;
 	}
 
-	if (do_stats) {
+	if (do_stats > 0) {
 		if (!am_sender && !send_stats) {
 		    /* missing the bytes written by the generator */
 		    rprintf(FINFO, "\nCannot show stats as receiver because remote protocol version is less than 20\n");
@@ -118,7 +118,7 @@
 		       (double)stats.total_read);
 	}
 	
-	if (verbose || do_stats) {
+	if ((verbose && do_stats == 0) || do_stats > 0) {
 		rprintf(FINFO,"wrote %.0f bytes  read %.0f bytes  %.2f bytes/sec\n",
 		       (double)stats.total_written,
 		       (double)stats.total_read,
--- rsync-2.5.5/options.c.orig	Tue Mar 19 21:16:42 2002
+++ rsync-2.5.5/options.c	Fri May 17 11:51:58 2002
@@ -260,6 +260,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,"     --no-stats              suppress file transfer stats with -v\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");
@@ -345,7 +346,8 @@
   {"compress",        'z', POPT_ARG_NONE,   &do_compression , 0, 0, 0 },
   {"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 },
+  {"stats",            0,  POPT_ARG_VAL,    &do_stats ,  1, 0, 0 },
+  {"no-stats",         0,  POPT_ARG_VAL,    &do_stats , -1, 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.5.5/rsync.1.orig	Wed Feb  6 22:21:19 2002
+++ rsync-2.5.5/rsync.1	Fri May 17 11:59:36 2002
@@ -305,6 +305,7 @@
      --blocking-io           use blocking IO for the remote shell
      --no-blocking-io        turn off --blocking-io
      --stats                 give some file transfer stats
+     --no-stats              suppress file transfer stats with -v
      --progress              show progress during transfer
      --log-format=FORMAT     log file transfers using specified format
      --password-file=FILE    get password from FILE
@@ -778,6 +779,10 @@
 This tells rsync to print a verbose set of statistics
 on the file transfer, allowing you to tell how effective the rsync
 algorithm is for your data\&.
+.IP 
+.IP "\fB--no-stats\fP" 
+When you specify the -v option, rsync will show a summary of file
+transfer statistics at the end\&. This option suppresses these statistics\&.
 .IP 
 .IP "\fB--partial\fP" 
 By default, rsync will delete any partially
-------------- next part --------------
--- rsync-2.5.5/generator.c.orig	Mon Mar 25 06:54:31 2002
+++ rsync-2.5.5/generator.c	Fri May 17 11:34:45 2002
@@ -417,7 +417,7 @@
 	} 
 
 	if (update_only && cmp_modtime(st.st_mtime,file->modtime)>0 && fnamecmp == fname) {
-		if (verbose > 1)
+		if (verbose)
 			rprintf(FINFO,"%s is newer\n",fname);
 		return;
 	}


More information about the rsync mailing list