From: Liam Beguin <liambeguin@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, houstonfortney@gmail.com,
kostix+git@007spb.ru, peff@peff.net, sxlijin@gmail.com,
Liam Beguin <liambeguin@gmail.com>
Subject: [PATCH 2/3] wt-status: add optional stash status information
Date: Fri, 16 Jun 2017 00:30:49 -0400 [thread overview]
Message-ID: <20170616043050.29192-3-liambeguin@gmail.com> (raw)
In-Reply-To: <20170616043050.29192-1-liambeguin@gmail.com>
Add the `status.showStash` configuration option to allow git-status to
show information about currently stashed entries.
Signed-off-by: Liam Beguin <liambeguin@gmail.com>
---
Documentation/config.txt | 5 +++++
wt-status.c | 24 ++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 23b807065d92..e83b0f641574 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2992,6 +2992,11 @@ status.displayCommentPrefix::
behavior of linkgit:git-status[1] in Git 1.8.4 and previous.
Defaults to false.
+status.showStash::
+ If set to true, linkgit:git-status[1] will display the number of
+ entries currently stashed away.
+ Defaults to false.
+
status.showUntrackedFiles::
By default, linkgit:git-status[1] and linkgit:git-commit[1] show
files which are not currently tracked by Git. Directories which
diff --git a/wt-status.c b/wt-status.c
index bf651f16fae8..7114eec123c8 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -801,6 +801,27 @@ static void wt_longstatus_print_changed(struct wt_status *s)
wt_longstatus_print_trailer(s);
}
+static int stash_count_refs(struct object_id *ooid, struct object_id *noid,
+ const char *email, timestamp_t timestamp, int tz,
+ const char *message, void *cb_data)
+{
+ int *c = cb_data;
+ (*c)++;
+ return 0;
+}
+
+static void wt_longstatus_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)
+ status_printf_ln(s, GIT_COLOR_NORMAL,
+ Q_("Your stash currently has %d entry",
+ "Your stash currently has %d entries", stash_count),
+ stash_count);
+}
+
static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncommitted)
{
struct child_process sm_summary = CHILD_PROCESS_INIT;
@@ -1537,6 +1558,7 @@ static void wt_longstatus_print(struct wt_status *s)
const char *branch_color = color(WT_STATUS_ONBRANCH, s);
const char *branch_status_color = color(WT_STATUS_HEADER, s);
struct wt_status_state state;
+ int show_stash = 0;
memset(&state, 0, sizeof(state));
wt_status_get_state(&state,
@@ -1642,6 +1664,8 @@ static void wt_longstatus_print(struct wt_status *s)
} else
printf(_("nothing to commit, working tree clean\n"));
}
+ if (!git_config_get_bool("status.showStash", &show_stash) && show_stash)
+ wt_longstatus_print_stash_summary(s);
}
static void wt_shortstatus_unmerged(struct string_list_item *it,
--
2.9.4
next prev parent reply other threads:[~2017-06-16 4:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-16 4:30 [PATCH 0/3] add stash count information to git-status command Liam Beguin
2017-06-16 4:30 ` [PATCH 1/3] stash: update documentation to use 'stash entries' Liam Beguin
2017-06-16 12:06 ` Jeff King
2017-06-16 21:24 ` Junio C Hamano
2017-06-16 4:30 ` Liam Beguin [this message]
2017-06-16 12:14 ` [PATCH 2/3] wt-status: add optional stash status information Jeff King
2017-06-16 21:29 ` Junio C Hamano
2017-06-16 4:30 ` [PATCH 3/3] glossary: define stash entries Liam Beguin
2017-06-16 12:16 ` Jeff King
2017-06-16 12:16 ` [PATCH 0/3] add stash count information to git-status command Jeff King
2017-06-16 12:47 ` Liam Beguin
2017-06-17 22:30 ` [PATCH v2 " Liam Beguin
2017-06-17 22:30 ` [PATCH v2 1/3] stash: update documentation to use 'stash entry' Liam Beguin
2017-06-17 22:30 ` [PATCH v2 2/3] status: add optional stash count information Liam Beguin
2017-06-17 22:30 ` [PATCH v2 3/3] glossary: define 'stash entry' Liam Beguin
2017-06-19 5:18 ` [PATCH v2 0/3] add stash count information to git-status command Junio C Hamano
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=20170616043050.29192-3-liambeguin@gmail.com \
--to=liambeguin@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=houstonfortney@gmail.com \
--cc=kostix+git@007spb.ru \
--cc=peff@peff.net \
--cc=sxlijin@gmail.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).