commit:     ecc0e22040bd5b395e26b3df0a4d8d82bc0eaed2
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat May  3 16:46:01 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat May  3 16:49:08 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=ecc0e220

qlist: have -S only show main slot by default

If people want the subslot, they can use -SS.

---
 qlist.c                                  | 17 ++++++++++++-----
 tests/qlist/dotest                       |  3 +++
 tests/qlist/list01.good                  |  1 +
 tests/qlist/list07.good                  |  1 +
 tests/qlist/list11.good                  |  1 +
 tests/qlist/list12.good                  |  1 +
 tests/qlist/{list07.good => list14.good} |  1 +
 tests/qlist/root/cat/sub-2/CONTENTS      |  0
 tests/qlist/root/cat/sub-2/SLOT          |  1 +
 tests/qlist/root/cat/sub-2/repository    |  1 +
 10 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/qlist.c b/qlist.c
index 1373361..d1d60ba 100644
--- a/qlist.c
+++ b/qlist.c
@@ -27,7 +27,7 @@ static struct option const qlist_long_opts[] = {
 };
 static const char * const qlist_opts_help[] = {
        "Just show installed packages",
-       "Display installed packages with slots",
+       "Display installed packages with slots (use twice for subslots)",
        "Display installed packages with repository",
        "Display installed packages with flags used",
        "Display column view",
@@ -260,7 +260,7 @@ struct qlist_opt_state {
        bool show_obj;
        bool show_repo;
        bool show_sym;
-       bool show_slots;
+       int show_slots;
        bool show_umap;
        bool show_dbg;
        bool columns;
@@ -288,8 +288,15 @@ _q_static int qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
                depend_atom *atom;
                atom = (verbose ? NULL : atom_explode(pkgname));
                if ((state->all + state->just_pkgname) < 2) {
-                       if (state->show_slots && !pkg_ctx->slot)
+                       if (state->show_slots && !pkg_ctx->slot) {
                                q_vdb_pkg_eat(pkg_ctx, "SLOT", &pkg_ctx->slot, 
&pkg_ctx->slot_len);
+                               /* chop off the subslot if desired */
+                               if (state->show_slots == 1) {
+                                       char *s = strchr(pkg_ctx->slot, '/');
+                                       if (s)
+                                               *s = '\0';
+                               }
+                       }
                        if (state->show_repo && !pkg_ctx->repo)
                                q_vdb_pkg_eat(pkg_ctx, "repository", 
&pkg_ctx->repo, &pkg_ctx->repo_len);
                        /* display it */
@@ -363,7 +370,7 @@ int qlist_main(int argc, char **argv)
                .show_obj = false,
                .show_repo = false,
                .show_sym = false,
-               .show_slots = false,
+               .show_slots = 0,
                .show_umap = false,
                .show_dbg = false,
                .columns = false,
@@ -380,7 +387,7 @@ int qlist_main(int argc, char **argv)
                COMMON_GETOPTS_CASES(qlist)
                case 'a': state.all = true;
                case 'I': state.just_pkgname = true; break;
-               case 'S': state.just_pkgname = state.show_slots = true; break;
+               case 'S': state.just_pkgname = true; ++state.show_slots; break;
                case 'R': state.just_pkgname = state.show_repo = true; break;
                case 'U': state.just_pkgname = state.show_umap = true; break;
                case 'e': state.exact = true; break;

diff --git a/tests/qlist/dotest b/tests/qlist/dotest
index dfc4779..b5e1a41 100755
--- a/tests/qlist/dotest
+++ b/tests/qlist/dotest
@@ -55,6 +55,9 @@ test 12 "qlist -ICSR"
 # exact CAT/PN:slot::repo files list test
 test 13 "qlist -Ce --showdebug app-arch/cpio:0::gentoo"
 
+# sub-SLOT test
+test 14 "qlist -ICSS"
+
 cleantmpdir
 
 end

diff --git a/tests/qlist/list01.good b/tests/qlist/list01.good
index 00fc0e3..82249bf 100644
--- a/tests/qlist/list01.good
+++ b/tests/qlist/list01.good
@@ -2,4 +2,5 @@ a-b/a
 a-b/b
 app-arch/cpio
 cat/pkg
+cat/sub
 sys-fs/mtools

diff --git a/tests/qlist/list07.good b/tests/qlist/list07.good
index 8540b4e..769299c 100644
--- a/tests/qlist/list07.good
+++ b/tests/qlist/list07.good
@@ -2,4 +2,5 @@ a-b/a:a-0
 a-b/b:b-0
 app-arch/cpio:0
 cat/pkg:1
+cat/sub:1
 sys-fs/mtools:0

diff --git a/tests/qlist/list11.good b/tests/qlist/list11.good
index 1f2bfe6..cb2abaf 100644
--- a/tests/qlist/list11.good
+++ b/tests/qlist/list11.good
@@ -2,4 +2,5 @@ a-b/a::a
 a-b/b::b
 app-arch/cpio::gentoo
 cat/pkg::repo
+cat/sub::repo
 sys-fs/mtools::gentoo

diff --git a/tests/qlist/list12.good b/tests/qlist/list12.good
index 61d8643..706cb29 100644
--- a/tests/qlist/list12.good
+++ b/tests/qlist/list12.good
@@ -2,4 +2,5 @@ a-b/a:a-0::a
 a-b/b:b-0::b
 app-arch/cpio:0::gentoo
 cat/pkg:1::repo
+cat/sub:1::repo
 sys-fs/mtools:0::gentoo

diff --git a/tests/qlist/list07.good b/tests/qlist/list14.good
similarity index 80%
copy from tests/qlist/list07.good
copy to tests/qlist/list14.good
index 8540b4e..37abd51 100644
--- a/tests/qlist/list07.good
+++ b/tests/qlist/list14.good
@@ -2,4 +2,5 @@ a-b/a:a-0
 a-b/b:b-0
 app-arch/cpio:0
 cat/pkg:1
+cat/sub:1/1234
 sys-fs/mtools:0

diff --git a/tests/qlist/root/cat/sub-2/CONTENTS 
b/tests/qlist/root/cat/sub-2/CONTENTS
new file mode 100644
index 0000000..e69de29

diff --git a/tests/qlist/root/cat/sub-2/SLOT b/tests/qlist/root/cat/sub-2/SLOT
new file mode 100644
index 0000000..88c6a1c
--- /dev/null
+++ b/tests/qlist/root/cat/sub-2/SLOT
@@ -0,0 +1 @@
+1/1234

diff --git a/tests/qlist/root/cat/sub-2/repository 
b/tests/qlist/root/cat/sub-2/repository
new file mode 100644
index 0000000..f606d5e
--- /dev/null
+++ b/tests/qlist/root/cat/sub-2/repository
@@ -0,0 +1 @@
+repo

Reply via email to