From 2e59e78096313920df470b6645a4323e2d8c0c6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ystein=20Walle?= Date: Fri, 22 Oct 2021 00:25:32 +0200 Subject: status: print stash info with --porcelain=v2 --show-stash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The v2 porcelain format is very convenient for obtaining a lot of information about the current state of the repo, but does not contain any info about the stash. git status already accepts --show-stash but it's silently ignored when --porcelain=v2 is given. Let's add a simple line to print the number of stash entries but in a format similar in style to the rest of the format. Signed-off-by: Øystein Walle Signed-off-by: Junio C Hamano --- wt-status.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'wt-status.c') diff --git a/wt-status.c b/wt-status.c index 6c3edcdb45..5d215f4e4f 100644 --- a/wt-status.c +++ b/wt-status.c @@ -2182,6 +2182,18 @@ static void wt_porcelain_v2_print_tracking(struct wt_status *s) } } +/* + * Print the stash count in a porcelain-friendly format + */ +static void wt_porcelain_v2_print_stash(struct wt_status *s) +{ + int stash_count = count_stash_entries(); + char eol = s->null_termination ? '\0' : '\n'; + + if (stash_count > 0) + fprintf(s->fp, "# stash %d%c", stash_count, eol); +} + /* * Convert various submodule status values into a * fixed-length string of characters in the buffer provided. @@ -2443,6 +2455,9 @@ static void wt_porcelain_v2_print(struct wt_status *s) if (s->show_branch) wt_porcelain_v2_print_tracking(s); + if (s->show_stash) + wt_porcelain_v2_print_stash(s); + for (i = 0; i < s->change.nr; i++) { it = &(s->change.items[i]); d = it->util; -- cgit v1.2.3