git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Eric N. Vander Weele" <ericvw@gmail.com>
To: git@vger.kernel.org
Cc: "Eric N. Vander Weele" <ericvw@gmail.com>
Subject: [PATCH] status: teach "status --short" to respect "--show-stash"
Date: Mon,  4 Nov 2019 18:03:34 +0800	[thread overview]
Message-ID: <20191104100334.60537-1-ericvw@gmail.com> (raw)

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


             reply	other threads:[~2019-11-04 10:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04 10:03 Eric N. Vander Weele [this message]
2019-11-06  2:33 ` [PATCH] status: teach "status --short" to respect "--show-stash" 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191104100334.60537-1-ericvw@gmail.com \
    --to=ericvw@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).