All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] status: teach "status --short" to respect "--show-stash"
@ 2019-11-04 10:03 Eric N. Vander Weele
  2019-11-06  2:33 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Eric N. Vander Weele @ 2019-11-04 10:03 UTC (permalink / raw)
  To: git; +Cc: Eric N. Vander Weele

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-11-08  3:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-04 10:03 [PATCH] status: teach "status --short" to respect "--show-stash" Eric N. Vander Weele
2019-11-06  2:33 ` Junio C Hamano
2019-11-07 10:31   ` Eric N. Vander Weele
2019-11-07 11:09     ` Junio C Hamano
2019-11-08  3:24       ` Eric N. Vander Weele

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.