From: Eric N. Vander Weele Date: Mon, 04 Nov 2019 10:03:34 GMT Subject: [PATCH] status: teach "status --short" to respect "--show-stash" Message-ID: <20191104100334.60537-1-ericvw@gmail.com> 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 --- 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: (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