tags 488248 + patch
quit

The attached patch implements this request via the "-q" option, and 
seems to work reliably here.  I'm going to forward the beastie upstream 
before applying it to the Debian package, however, since I'd rather not 
diverge unnecessarily if Thomas opts to implement it differently.
diff -urN diffstat-1.45.orig/diffstat.1 diffstat-1.45/diffstat.1
--- diffstat-1.45.orig/diffstat.1	2007-09-04 19:31:41.000000000 -0500
+++ diffstat-1.45/diffstat.1	2008-07-30 21:25:26.000000000 -0500
@@ -112,6 +112,9 @@
 override the logic that strips common pathnames, simulating the \fBpatch\fP
 "-p" option.
 .TP
+.B -q
+suppress the "0 files changed" message for empty diffs.
+.TP
 .B -r " code"
 provides optional rounding of the data shown in histogram,
 rather than truncating with error adjustments.
diff -urN diffstat-1.45.orig/diffstat.c diffstat-1.45/diffstat.c
--- diffstat-1.45.orig/diffstat.c	2007-09-04 19:27:21.000000000 -0500
+++ diffstat-1.45/diffstat.c	2008-07-30 21:23:51.000000000 -0500
@@ -276,7 +276,8 @@
 static int table_opt = 0;	/* if nonzero, write table rather than plot */
 static int trace_opt = 0;	/* if nonzero, write debugging information */
 static int sort_names = 1;	/* true if we sort filenames */
-static int verbose = 0;		/* -q/-v options */
+static int verbose = 0;		/* -v option */
+static int quiet = 0;		/* -q option */
 static int suppress_binary = 0;	/* -b option */
 static long plot_scale;		/* the effective scale (1:maximum) */
 
@@ -1486,14 +1487,16 @@
 
     if (!table_opt && !names_only) {
 #define PLURAL(n) n, n != 1 ? "s" : ""
-	printf("%s %d file%s changed", comment_opt, PLURAL(num_files));
-	if (total_ins)
-	    printf(", %ld insertion%s(+)", PLURAL(total_ins));
-	if (total_del)
-	    printf(", %ld deletion%s(-)", PLURAL(total_del));
-	if (total_mod)
-	    printf(", %ld modification%s(!)", PLURAL(total_mod));
-	(void) putchar('\n');
+	if (num_files > 0 || !quiet) {
+	   printf("%s %d file%s changed", comment_opt, PLURAL(num_files));
+	   if (total_ins)
+	      printf(", %ld insertion%s(+)", PLURAL(total_ins));
+	   if (total_del)
+	      printf(", %ld deletion%s(-)", PLURAL(total_del));
+	   if (total_mod)
+	      printf(", %ld modification%s(!)", PLURAL(total_mod));
+	   (void) putchar('\n');
+	}
     }
 }
 
@@ -1545,6 +1548,7 @@
 	"  -n NUM  specify minimum width for the filenames (default: auto)",
 	"  -o FILE redirect standard output to FILE",
 	"  -p NUM  specify number of pathname-separators to strip (default: common)",
+	"  -q      suppress the \"0 files changed\" message for empty diffs",
 	"  -r NUM  specify rounding for histogram (0=none, 1=simple, 2=adjusted)",
 	"  -t      print a table (comma-separated-values) rather than histogram",
 	"  -u      do not sort the input list",
@@ -1585,7 +1589,7 @@
 
     max_width = 80;
 
-    while ((j = getopt_helper(argc, argv, "bcde:f:hkln:o:p:r:tuvVw:", 'h', 'V'))
+    while ((j = getopt_helper(argc, argv, "bcde:f:hkln:o:p:qr:tuvVw:", 'h', 'V'))
 	   != -1) {
 	switch (j) {
 	case 'b':
@@ -1647,6 +1651,9 @@
 	case 'w':
 	    max_width = atoi(optarg);
 	    break;
+	case 'q':
+	    quiet = 1;
+	    break;
 	default:
 	    usage(stderr);
 	    return (EXIT_FAILURE);

Attachment: signature.asc
Description: Digital signature



Reply via email to