status: count stash entries in separate function

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Øystein Walle committed Oct 22, 2021 at 00:25 UTC 612942a1d201d33c2e952c89d58e5c6d26a028a2
1 file changed +8 -2
wt-status.c
+8 -2
@@ -948,11 +948,17 @@ static int stash_count_refs(struct object_id *ooid, struct object_id *noid,
948 return 0;
949 }
950
951 +static int count_stash_entries(void)
952 +{
953 + int n = 0;
954 + for_each_reflog_ent("refs/stash", stash_count_refs, &n);
955 + return n;
956 +}
957 +
958 static void wt_longstatus_print_stash_summary(struct wt_status *s)
959 {
953 - int stash_count = 0;
960 + int stash_count = count_stash_entries();
961
955 - for_each_reflog_ent("refs/stash", stash_count_refs, &stash_count);
962 if (stash_count > 0)
963 status_printf_ln(s, GIT_COLOR_NORMAL,
964 Q_("Your stash currently has %d entry",