All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Øystein Walle" <oystwa@gmail.com>
To: git@vger.kernel.org
Cc: "Øystein Walle" <oystwa@gmail.com>
Subject: [PATCH 1/2] status: count stash entries in separate function
Date: Fri, 22 Oct 2021 00:25:31 +0200	[thread overview]
Message-ID: <20211021222532.463375-2-oystwa@gmail.com> (raw)
In-Reply-To: <20211021222532.463375-1-oystwa@gmail.com>

Make the counting of stash entries contained in one simple function as
it will be used in the next commit.

Signed-off-by: Øystein Walle <oystwa@gmail.com>
---
 wt-status.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index e4f29b2b4c..97230477b2 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -948,11 +948,17 @@ static int stash_count_refs(struct object_id *ooid, struct object_id *noid,
 	return 0;
 }
 
+static int count_stash_entries()
+{
+	int n = 0;
+	for_each_reflog_ent("refs/stash", stash_count_refs, &n);
+	return n;
+}
+
 static void wt_longstatus_print_stash_summary(struct wt_status *s)
 {
-	int stash_count = 0;
+	int stash_count = count_stash_entries();
 
-	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",
-- 
2.27.0


  reply	other threads:[~2021-10-21 22:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 22:25 [PATCH 0/2] Print stash info in the v2 porcelain format Øystein Walle
2021-10-21 22:25 ` Øystein Walle [this message]
2021-10-21 23:38   ` [PATCH 1/2] status: count stash entries in separate function Junio C Hamano
2021-10-21 22:25 ` [PATCH 2/2] status: print stash info with --porcelain=v2 --show-stash Øystein Walle
2021-10-21 23:47   ` Junio C Hamano
2021-10-22  0:05   ` Eric Sunshine
2021-10-22  0:29     ` Junio C Hamano
2021-10-22  1:19       ` Eric Sunshine

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=20211021222532.463375-2-oystwa@gmail.com \
    --to=oystwa@gmail.com \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.