git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] For Real - Fixed pluralization in diff reports

From
Jon Forrest <nobozo@gmail.com>
Date
Aug 1, 2011, 04:46 UTC
Message-ID
<4E362F8E.1050105@gmail.com>

[I must have accidentally removed the "s" in "deletions" before. I just rebuilt everything and remade the patch. All looks well this time. This is my first submitted patch to anything so my fingers are still learning.]

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@gmail.com>
---
  diff.c |   10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)
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.351.gb35ac.dirty
Next: Nguyen Thai Ngoc Duy
Message 1 of 12 in “For Real - Fixed pluralization in diff reports”
  1. For Real - Fixed pluralization in diff reportsJon Forrest, Aug 1, 2011
  2. Nguyen Thai Ngoc DuyAug 1, 2011
  3. Jon ForrestAug 1, 2011
  4. Nguyen Thai Ngoc DuyAug 1, 2011
  5. Sverre RabbelierAug 1, 2011
  6. Jon ForrestAug 1, 2011
  7. Jeff KingAug 1, 2011
  8. Jon ForrestAug 1, 2011
  9. Sverre RabbelierAug 1, 2011
  10. Jeff KingAug 1, 2011
  11. Jakub NarebskiAug 3, 2011
  12. Jon ForrestAug 3, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.