Hi, As it looks like something easy enough for a beginner, I though I could give it a try. Here is what it looks like. If it's good enough, I'll add a few lines to document 'status.showStash' and send a patch. There is one thing I've noticed though. When using 'git stash pop', it shows the the number of stashes before dropping the commit and I'm not quite sure how to address this. -- diff --git a/wt-status.c b/wt-status.c index 25aafc35c833..fab66d4cd72e 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 commit", + "Your stash currently has %d commits", 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; @@ -1536,6 +1557,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, @@ -1641,6 +1663,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, On 10/06/17 06:22 AM, Jeff King wrote: > On Sat, Jun 10, 2017 at 06:12:28AM -0400, Samuel Lijin wrote: > >> On Sat, Jun 10, 2017 at 4:25 AM, Jeff King <peff@xxxxxxxx> wrote: >>> On Wed, Jun 07, 2017 at 06:46:18PM -0400, Houston Fortney wrote: >>> >>>> I sometimes forget about something that I stashed. It would be nice if >>>> the git status command would just say "There are x entries in the >>>> stash." It can say nothing if there is nothing stashed so it is >>>> usually not adding clutter. >>> >>> I think the clutter issue would depend on your workflow around stash. >>> >>> Some people carry tidbits in their stash for days or weeks. E.g., I >>> sometimes start on an idea and decide it's not worth pursuing (or more >>> likely, I post a snippet of a patch as a "how about this" to the mailing >>> list but don't plan on taking it further). Rather than run "git reset >>> --hard", I usually "git stash" the result. That means if I really do >>> decide I want it back, I can prowl through the stash list and find it. >>> >>> All of which is to say that if we had such a feature, it should probably >>> be optional. For some people it would be very useful, and for others it >>> would be a nuisance. >> >> Perhaps there should be a flag for this if it is implemented, say >> status.showStash? > > Yes, that was what I was thinking. > > -Peff > - Liam