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

[PATCH] diff and apply: fix singular/plural grammar nit.

From
David Ripton <dripton@ripton.net>
Date
Nov 27, 2011, 13:44 UTC
Message-ID
<4ED23EB5.1030208@ripton.net>

Remove the trailing 's' from "files", "insertions", and "deletions" when there is only one of the item.

Signed-off-by: David Ripton <dripton@ripton.net>
---
  builtin/apply.c |    5 ++++-
  diff.c          |   13 +++++++++----
  2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/builtin/apply.c b/builtin/apply.c
index 84a8a0b..47bbc23 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3244,7 +3244,10 @@ static void stat_patch_list(struct patch *patch)
                 show_stats(patch);
         }

-       printf(" %d files changed, %d insertions(+), %d deletions(-)\n", 
files, adds, dels);
+       printf(" %d file%s changed, %d insertion%s(+), %d deletion%s(-)\n",
+              files, (files == 1 ? "" : "s"),
+              adds, (adds == 1 ? "" : "s"),
+              dels, (dels == 1 ? "" : "s"));
  }

  static void numstat_patch_list(struct patch *patch)
diff --git a/diff.c b/diff.c
index 374ecf3..531dcb1 100644
--- a/diff.c
+++ b/diff.c
@@ -1467,8 +1467,10 @@ 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)
@@ -1498,8 +1500,11 @@ 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.8.rc3

-- 
David Ripton    dripton@ripton.net
Next: Jakub Narebski
Message 1 of 4 in “diff and apply: fix singular/plural grammar nit.”
  1. diff and apply: fix singular/plural grammar nit.David Ripton, Nov 27, 2011
  2. Jakub NarebskiNov 27, 2011
  3. Carlos Martín NietoNov 27, 2011
  4. Frans KlaverNov 27, 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.