status: disable translation when --porcelain is used

"git status --branch --porcelain" displays the status of the branch (ahead, behind, gone), and used gettext to translate the string. Use hardcoded strings when --porcelain is used, but keep the gettext translation for "git status --short" which is essentially the same, but meant to be read by a human. Reported-by: Anarky <ghostanarky@gmail.com> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthieu Moy committed Mar 20, 2014 at 13:12 UTC 7a76c28ff29d6f819bb0bf9852b858f974b5c53a
2 files changed +9 -5
wt-status.c
+8 -5
@@ -1483,19 +1483,21 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
1483 return;
1484 }
1485
1486 +#define LABEL(string) (s->no_gettext ? (string) : _(string))
1487 +
1488 color_fprintf(s->fp, header_color, " [");
1489 if (upstream_is_gone) {
1488 - color_fprintf(s->fp, header_color, _("gone"));
1490 + color_fprintf(s->fp, header_color, LABEL(N_("gone")));
1491 } else if (!num_ours) {
1490 - color_fprintf(s->fp, header_color, _("behind "));
1492 + color_fprintf(s->fp, header_color, LABEL(N_("behind ")));
1493 color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
1494 } else if (!num_theirs) {
1493 - color_fprintf(s->fp, header_color, _("ahead "));
1495 + color_fprintf(s->fp, header_color, LABEL(N_(("ahead "))));
1496 color_fprintf(s->fp, branch_color_local, "%d", num_ours);
1497 } else {
1496 - color_fprintf(s->fp, header_color, _("ahead "));
1498 + color_fprintf(s->fp, header_color, LABEL(N_(("ahead "))));
1499 color_fprintf(s->fp, branch_color_local, "%d", num_ours);
1498 - color_fprintf(s->fp, header_color, _(", behind "));
1500 + color_fprintf(s->fp, header_color, ", %s", LABEL(N_("behind ")));
1501 color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
1502 }
1503
@@ -1540,5 +1542,6 @@ void wt_porcelain_print(struct wt_status *s)
1542 s->use_color = 0;
1543 s->relative_paths = 0;
1544 s->prefix = NULL;
1545 + s->no_gettext = 1;
1546 wt_shortstatus_print(s);
1547 }
wt-status.h
+1
@@ -50,6 +50,7 @@ struct wt_status {
50 enum commit_whence whence;
51 int nowarn;
52 int use_color;
53 + int no_gettext;
54 int display_comment_prefix;
55 int relative_paths;
56 int submodule_summary;