commit:     c697c786bd4f24b0ec5c5aa1300fa9d8433062d6
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 10 18:17:58 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Sep 10 18:17:58 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c697c786

qlop: ignore empty runs for -l (lastrun)

doing something like emerge -pv blah will generate a run where nothing
is merged or unmerged, so ignore it.

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

 qlop.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/qlop.c b/qlop.c
index 7acb855..243c8b6 100644
--- a/qlop.c
+++ b/qlop.c
@@ -326,6 +326,7 @@ static int do_emerge_log(
        char *p;
        char *q;
        time_t tstart = LONG_MAX;
+       time_t tstart_emerge = 0;
        time_t last_merge = 0;
        time_t sync_start = 0;
        time_t sync_time = 0;
@@ -376,12 +377,8 @@ static int do_emerge_log(
                                continue;
 
                        if (flags->show_lastmerge) {
-                               if (strncmp(p, "  *** emerge ", 13) == 0) {
-                                       last_merge = tstart;
-                                       array_for_each(atoms, i, atomw)
-                                               atom_implode(atomw);
-                                       xarrayfree_int(atoms);
-                               }
+                               if (strncmp(p, "  *** emerge ", 13) == 0)
+                                       tstart_emerge = tstart;
                                if (!all_atoms)
                                        continue;
                        }
@@ -417,6 +414,16 @@ static int do_emerge_log(
                                atom->PVR = NULL;
                                atom->PR_int = 0;
 
+                               /* now we found a package, register this merge 
as a
+                                * "valid" one, such that dummy emerge calls 
(e.g.
+                                * emerge -pv foo) are ignored */
+                               if (last_merge != tstart_emerge) {
+                                       last_merge = tstart_emerge;
+                                       array_for_each(atoms, i, atomw)
+                                               atom_implode(atomw);
+                                       xarrayfree_int(atoms);
+                               }
+
                                atomw = NULL;
                                array_for_each(atoms, i, atomw) {
                                        if (atom_compare(atom, atomw) == EQUAL)

Reply via email to