commit: 4c61b246302353878ea28a90b5b0f4fe5e1e7ca3
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May 11 06:51:42 2019 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May 11 06:51:42 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4c61b246
libq/tree: allow reconstruction of atom in tree_get_atom
if SLOT or REPO got unset in the atom or slot or repo were somehow set
elsewhere, reuse those values to populate the atom with
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
libq/tree.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/libq/tree.c b/libq/tree.c
index 86dd18f..8384458 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -993,24 +993,28 @@ tree_get_atom(tree_pkg_ctx *pkg_ctx, bool complete)
tree_ctx *ctx = pkg_ctx->cat_ctx->ctx;
if (ctx->cachetype == CACHE_VDB) {
if (pkg_ctx->atom->SLOT == NULL) {
- tree_pkg_vdb_eat(pkg_ctx, "SLOT",
- &pkg_ctx->slot,
&pkg_ctx->slot_len);
+ if (pkg_ctx->slot == NULL)
+ tree_pkg_vdb_eat(pkg_ctx, "SLOT",
+ &pkg_ctx->slot,
&pkg_ctx->slot_len);
pkg_ctx->atom->SLOT = pkg_ctx->slot;
}
if (pkg_ctx->atom->REPO == NULL) {
- tree_pkg_vdb_eat(pkg_ctx, "repository",
- &pkg_ctx->repo,
&pkg_ctx->repo_len);
+ if (pkg_ctx->repo == NULL)
+ tree_pkg_vdb_eat(pkg_ctx, "repository",
+ &pkg_ctx->repo,
&pkg_ctx->repo_len);
pkg_ctx->atom->REPO = pkg_ctx->repo;
}
} else { /* metadata or ebuild */
if (pkg_ctx->atom->SLOT == NULL) {
- tree_pkg_meta *meta = tree_pkg_read(pkg_ctx);
- if (meta != NULL) {
- pkg_ctx->slot = xstrdup(meta->SLOT);
- pkg_ctx->slot_len =
strlen(pkg_ctx->slot);
- pkg_ctx->atom->SLOT = pkg_ctx->slot;
- tree_close_meta(meta);
+ if (pkg_ctx->slot == NULL) {
+ tree_pkg_meta *meta =
tree_pkg_read(pkg_ctx);
+ if (meta != NULL) {
+ pkg_ctx->slot =
xstrdup(meta->SLOT);
+ pkg_ctx->slot_len =
strlen(pkg_ctx->slot);
+ tree_close_meta(meta);
+ }
}
+ pkg_ctx->atom->SLOT = pkg_ctx->slot;
}
/* repo is set from the tree, when found */
if (pkg_ctx->atom->REPO == NULL)