[PATCH 1/2] Allow to print diffstat in English regardless current locale

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

 



Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 builtin/apply.c |  2 +-
 diff.c          | 19 ++++++++++++-------
 diff.h          |  2 +-
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index d453c83..3f2779f 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3627,7 +3627,7 @@ static void stat_patch_list(struct patch *patch)
 		show_stats(patch);
 	}
 
-	print_stat_summary(stdout, files, adds, dels);
+	print_stat_summary(stdout, 0, files, adds, dels);
 }
 
 static void numstat_patch_list(struct patch *patch)
diff --git a/diff.c b/diff.c
index 95706a5..47d7e50 100644
--- a/diff.c
+++ b/diff.c
@@ -1390,18 +1390,21 @@ static void fill_print_name(struct diffstat_file *file)
 	file->print_name = pname;
 }
 
-int print_stat_summary(FILE *fp, int files, int insertions, int deletions)
+int print_stat_summary(FILE *fp, int no_l10n, int files,
+		       int insertions, int deletions)
 {
+#define C_(s) (no_l10n ? s : _(s))
+#define CQ_(s1, s2, num) (no_l10n ? (num == 1 ? s1 : s2) : Q_(s1, s2, num))
 	struct strbuf sb = STRBUF_INIT;
 	int ret;
 
 	if (!files) {
 		assert(insertions == 0 && deletions == 0);
-		return fprintf(fp, "%s\n", _(" 0 files changed"));
+		return fprintf(fp, "%s\n", C_(" 0 files changed"));
 	}
 
 	strbuf_addf(&sb,
-		    Q_(" %d file changed", " %d files changed", files),
+		    CQ_(" %d file changed", " %d files changed", files),
 		    files);
 
 	/*
@@ -1418,7 +1421,7 @@ int print_stat_summary(FILE *fp, int files, int insertions, int deletions)
 		 * do not translate it.
 		 */
 		strbuf_addf(&sb,
-			    Q_(", %d insertion(+)", ", %d insertions(+)",
+			    CQ_(", %d insertion(+)", ", %d insertions(+)",
 			       insertions),
 			    insertions);
 	}
@@ -1429,7 +1432,7 @@ int print_stat_summary(FILE *fp, int files, int insertions, int deletions)
 		 * do not translate it.
 		 */
 		strbuf_addf(&sb,
-			    Q_(", %d deletion(-)", ", %d deletions(-)",
+			    CQ_(", %d deletion(-)", ", %d deletions(-)",
 			       deletions),
 			    deletions);
 	}
@@ -1437,6 +1440,8 @@ int print_stat_summary(FILE *fp, int files, int insertions, int deletions)
 	ret = fputs(sb.buf, fp);
 	strbuf_release(&sb);
 	return ret;
+#undef C_
+#undef CQ_
 }
 
 static void show_stats(struct diffstat_t *data, struct diff_options *options)
@@ -1682,7 +1687,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 		extra_shown = 1;
 	}
 	fprintf(options->file, "%s", line_prefix);
-	print_stat_summary(options->file, total_files, adds, dels);
+	print_stat_summary(options->file, 0, total_files, adds, dels);
 }
 
 static void show_shortstats(struct diffstat_t *data, struct diff_options *options)
@@ -1711,7 +1716,7 @@ static void show_shortstats(struct diffstat_t *data, struct diff_options *option
 				options->output_prefix_data);
 		fprintf(options->file, "%s", msg->buf);
 	}
-	print_stat_summary(options->file, total_files, adds, dels);
+	print_stat_summary(options->file, 0, total_files, adds, dels);
 }
 
 static void show_numstat(struct diffstat_t *data, struct diff_options *options)
diff --git a/diff.h b/diff.h
index e027650..eec79ef 100644
--- a/diff.h
+++ b/diff.h
@@ -329,7 +329,7 @@ extern struct userdiff_driver *get_textconv(struct diff_filespec *one);
 
 extern int parse_rename_score(const char **cp_p);
 
-extern int print_stat_summary(FILE *fp, int files,
+extern int print_stat_summary(FILE *fp, int no_l10n, int files,
 			      int insertions, int deletions);
 
 #endif /* DIFF_H */
-- 
1.7.12.rc1.27.g6d3049b.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]