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

[PATCH] status: teach "status --short" to respect "--show-stash"

From
Eric N. Vander Weele <ericvw@gmail.com>
Date
Nov 4, 2019, 10:03 UTC
Message-ID
<20191104100334.60537-1-ericvw@gmail.com>

Enable printing the entries currently stashed away in the short format. This prints the stash information after the path status to be symmetric with "status --long --show-stash".

Signed-off-by: Eric N. Vander Weele <ericvw@gmail.com>
---
 Documentation/git-status.txt |  4 ++++
 wt-status.c                  | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)
diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index 7731b45f07..c1afc3282c 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -244,6 +244,10 @@ If -b is used the short-format status is preceded by a line
 
     ## branchname tracking info
 
+If --show-stash is used the short-format status is followed by a line
+
+    ## stash: <n> (entry|entries)
+
 Porcelain Format Version 1
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/wt-status.c b/wt-status.c
index cc6f94504d..c6d112081b 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1956,6 +1956,20 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
 	fputc(s->null_termination ? '\0' : '\n', s->fp);
 }
 
+static void wt_shortstatus_print_stash(struct wt_status *s)
+{
+	int stash_count = 0;
+
+	for_each_reflog_ent("refs/stash", stash_count_refs, &stash_count);
+	if (stash_count > 0) {
+		color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "## ");
+		status_printf_ln(s, GIT_COLOR_NORMAL,
+				 Q_("stash: %d entry",
+				    "stash: %d entries", stash_count),
+				 stash_count);
+	}
+}
+
 static void wt_shortstatus_print(struct wt_status *s)
 {
 	struct string_list_item *it;
@@ -1976,6 +1990,9 @@ static void wt_shortstatus_print(struct wt_status *s)
 
 	for_each_string_list_item(it, &s->ignored)
 		wt_shortstatus_other(it, s, "!!");
+
+	if (s->show_stash)
+		wt_shortstatus_print_stash(s);
 }
 
 static void wt_porcelain_print(struct wt_status *s)
-- 
2.24.0
Next: Junio C Hamano
Message 1 of 5 in “status: teach "status --short" to respect "--show-stash"”
  1. status: teach "status --short" to respect "--show-stash"Eric N. Vander Weele, Nov 4, 2019
  2. Junio C HamanoNov 6, 2019
  3. Eric N. Vander WeeleNov 7, 2019
  4. Junio C HamanoNov 7, 2019
  5. Eric N. Vander WeeleNov 8, 2019

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.