From 990941f6bda6df555eb6a53b044b02161dbe1411 Mon Sep 17 00:00:00 2001
From: Sertonix <sertonix@posteo.net>
Date: Sat, 30 Mar 2024 18:52:06 +0100
Subject: [PATCH] list: fix -P with filter

---
 src/app_list.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/app_list.c b/src/app_list.c
index b66622c5..efdf11df 100644
--- a/src/app_list.c
+++ b/src/app_list.c
@@ -118,7 +118,7 @@ static void print_manifest(const struct apk_package *pkg, const struct list_ctx
 	printf("%s " BLOB_FMT "\n", pkg->name->name, BLOB_PRINTF(*pkg->version));
 }
 
-static void filter_package(const struct apk_database *db, const struct apk_package *pkg, const struct list_ctx *ctx)
+static void filter_package(const struct apk_database *db, const struct apk_package *pkg, const struct list_ctx *ctx, const struct apk_name *name)
 {
 	if (ctx->match_origin && !origin_matches(ctx, pkg))
 		return;
@@ -135,6 +135,9 @@ static void filter_package(const struct apk_database *db, const struct apk_packa
 	if (ctx->upgradable && !is_upgradable(db, pkg))
 		return;
 
+	if (ctx->match_providers)
+		printf("<%s> ", name->name);
+
 	if (ctx->manifest)
 		print_manifest(pkg, ctx);
 	else
@@ -149,10 +152,7 @@ static void iterate_providers(const struct apk_database *db, const struct apk_na
 		if (!ctx->match_providers && p->pkg->name != name)
 			continue;
 
-		if (ctx->match_providers)
-			printf("<%s> ", name->name);
-
-		filter_package(db, p->pkg, ctx);
+		filter_package(db, p->pkg, ctx, name);
 	}
 }
 
-- 
GitLab