[PATCH] Fixed pluralization in diff reports

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I got irritated by the

	 1 files changed, 0 insertions(+), 1 deletions(-)

lack of pluralization so I fixed it. Now it says

	 1 file changed, 0 insertions(+), 1 deletion(-)

and so forth.

Signed-off-by: Jon Forrest <nobozo@xxxxxxxxx>
---
 diff.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletion(-)

diff --git a/diff.c b/diff.c
index 93ef9a2..a179b24 100644
--- a/diff.c
+++ b/diff.c
@@ -1465,8 +1465,9 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 	}
 	fprintf(options->file, "%s", line_prefix);
 	fprintf(options->file,
-	       " %d files changed, %d insertions(+), %d deletions(-)\n",
-	       total_files, adds, dels);
+	       " %d file%s changed, %d insertion%s(+), %d deletion%s(-)\n",
+ total_files, total_files == 1 ? "" : "s", adds, adds == 1 ? "" : "s", dels,
+		dels == 1 ? "" : "s");
 }

static void show_shortstats(struct diffstat_t *data, struct diff_options *options) @@ -1496,8 +1497,9 @@ static void show_shortstats(struct diffstat_t *data, struct diff_options *option
 				options->output_prefix_data);
 		fprintf(options->file, "%s", msg->buf);
 	}
- fprintf(options->file, " %d files changed, %d insertions(+), %d deletions(-)\n",
-	       total_files, adds, dels);
+ fprintf(options->file, " %d file%s changed, %d insertion%s(+), %d deletion%s(-)\n", + total_files, total_files == 1 ? "" : "s", adds, adds == 1 ? "" : "s", dels,
+		dels == 1 ? "" : "s");
 }

static void show_numstat(struct diffstat_t *data, struct diff_options *options)
-- 1.7.6.347.g4db0d.dirty
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]