commit:     3081142ae31a65cf0b52277cb421ca7b918d0155
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 10 10:13:20 2026 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan 10 10:13:20 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3081142a

libq/tree: dummify tree_foreach_pkg when no callback is given

This, while seemingly pointless, allows to build a cache when it's not
there yet.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 libq/tree.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libq/tree.c b/libq/tree.c
index e485af2..507549f 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -2213,6 +2213,8 @@ tree_foreach_pkg_int
                /* always exploit the cache if it exists (next_cat doesn't
                 * consider it if sorting isn't requested) */
                mode = TREE_FOREACH_SORT;
+               if (callback == NULL)
+                       traverse = false;
        } else {
                /* perform sorting post retrieval by caching first:
                 * - binpkgs can be a combination of files and directories,
@@ -2523,8 +2525,7 @@ tree_match_atom(tree_ctx *ctx, const depend_atom *query, 
int flags)
        /* activate cache for future lookups, tree_match_atom relies on
         * cache behaviour from tree, which means all categories and
         * packages remain in memory until tree_close is being called */
-       if (ctx->cache.categories == NULL)
-               tree_foreach_pkg_cached(ctx, NULL, NULL, NULL);  /* force cache 
*/
+       tree_foreach_pkg_cached(ctx, NULL, NULL, NULL);  /* force cache */
 
        ctx->do_sort = true;     /* often forces/enables cache usage */
 

Reply via email to