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

[PATCH] git-status: make porcelain more robust

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Mar 14, 2017, 16:02 UTC
Message-ID
<54df68bd46f7a417e77eb71b636f6f7afd4fce75.1489507239.git.git@drmicha.warpmail.net>

git status provides a porcelain mode for porcelain writers with a supposedly stable (plumbing) interface. 7a76c28ff2 ("status: disable translation when --porcelain is used", 2014-03-20) made sure that ahead/behind info is not translated (i.e. is stable).

Make sure that the remaining two strings (initial commit, detached head) are stable, too.

These changes are for the v1 porcelain interface. While we do have a perfectly stable v2 porcelain interface now, some tools (such as powerline-gitstatus) are written against v1 and profit from fixing v1 without any changes on their side.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 wt-status.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index d47012048f..234e77a6d6 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1730,12 +1730,14 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
 		return;
 	branch_name = s->branch;
 
+#define LABEL(string) (s->no_gettext ? (string) : _(string))
+
 	if (s->is_initial)
-		color_fprintf(s->fp, header_color, _("Initial commit on "));
+		color_fprintf(s->fp, header_color, LABEL(N_("Initial commit on ")));
 
 	if (!strcmp(s->branch, "HEAD")) {
 		color_fprintf(s->fp, color(WT_STATUS_NOBRANCH, s), "%s",
-			      _("HEAD (no branch)"));
+			      LABEL(N_("HEAD (no branch)")));
 		goto conclude;
 	}
 
@@ -1760,8 +1762,6 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
 	if (!upstream_is_gone && !num_ours && !num_theirs)
 		goto conclude;
 
-#define LABEL(string) (s->no_gettext ? (string) : _(string))
-
 	color_fprintf(s->fp, header_color, " [");
 	if (upstream_is_gone) {
 		color_fprintf(s->fp, header_color, LABEL(N_("gone")));
-- 
2.12.0.384.g157040b11f.dirty
Next: Junio C Hamano
Message 1 of 3 in “git-status: make porcelain more robust”
  1. git-status: make porcelain more robustMichael J Gruber, Mar 14, 2017
  2. Junio C HamanoMar 14, 2017
  3. Matthieu MoyMar 15, 2017

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.