From: Sonny Michaud <michaud.sonny@gmail.com>
To: git@vger.kernel.org, gitster@pobox.com
Subject: [PATCH 0/1] Add stash entry count summary to short status output
Date: Sun, 20 Aug 2017 00:53:04 -0400 [thread overview]
Message-ID: <c3ac0335-4f41-40d9-00ee-2a4e115bcf7a@gmail.com> (raw)
this patch adds a header in the same style as the one provided by the --branch option when the user supplies both --show-stash and --short. My attempt at creating a new test is broken[1], and I assume my changes could (and, likely need to) be improved. Any assistance would be greatly appreciated; I just wanted to get started by hacking first and asking questions later!
Thanks,
Sonny
1. https://travis-ci.org/sonnym/git/builds/266428128
--
From 9e9ffca5c4ed7dda34cad416c3eb68dc94a78b7e Mon Sep 17 00:00:00 2001
From: Sonny Michaud <michaud.sonny@gmail.com>
Date: Sat, 19 Aug 2017 23:46:15 -0400
Subject: [PATCH 1/1] status: learn to show stash in short output
This patch extends the functionality of the recently introduced
--show-stash option to the status command, providing a header similar to
the one displayed when using the --branch option.
---
t/t7508-status.sh | 5 +++++
wt-status.c | 12 ++++++++++++
2 files changed, 17 insertions(+)
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 43d19a9b2..734001bc6 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -1619,6 +1619,11 @@ test_expect_success 'show stash info with "--show-stash"' '
test_i18ngrep "^Your stash currently has 1 entry$" expected_with_stash
'
+test_expect_success 'show stash info with "--show-stash" and "--short"' '
+ git status --show-stash --short >expected_with_stash &&
+ test_i18ngrep "Stash entries: 2" expected_with_stash
+'
+
test_expect_success 'no stash info with "--show-stash --no-show-stash"' '
git status --show-stash --no-show-stash >expected_without_stash &&
test_cmp expected_default expected_without_stash
diff --git a/wt-status.c b/wt-status.c
index 77c27c511..651bb01f0 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1827,6 +1827,15 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
fputc(s->null_termination ? '\0' : '\n', s->fp);
}
+static void wt_shortstatus_print_stash_summary(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), "## Stash entries: %d", stash_count);
+}
+
static void wt_shortstatus_print(struct wt_status *s)
{
struct string_list_item *it;
@@ -1834,6 +1843,9 @@ static void wt_shortstatus_print(struct wt_status *s)
if (s->show_branch)
wt_shortstatus_print_tracking(s);
+ if (s->show_stash)
+ wt_shortstatus_print_stash_summary(s);
+
for_each_string_list_item(it, &s->change) {
struct wt_status_change_data *d = it->util;
--
2.14.0
next reply other threads:[~2017-08-20 4:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-20 4:53 Sonny Michaud [this message]
2017-08-22 15:25 ` [PATCH 0/1] Add stash entry count summary to short status output Sonny Michaud
2017-08-24 15:29 ` Sonny Michaud
2017-08-24 19:29 ` Junio C Hamano
2017-08-24 20:07 ` Junio C Hamano
2017-08-31 21:49 ` Sonny Michaud
2017-09-01 3:11 ` Jonathan Nieder
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=c3ac0335-4f41-40d9-00ee-2a4e115bcf7a@gmail.com \
--to=michaud.sonny@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).