This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

commit 6b4ff833d2f171da3740f00e90b0613db72a5601
Author: Guillem Jover <[email protected]>
Date:   Fri Feb 13 04:22:58 2015 +0100

    dpkg-query: Do not fail on -W and -l when multiple arguments match a package
    
    We should not short-circuit on first match for a package, as that
    produces bogus errors when the following arguments do match those
    packages as well, either because they are repeated or because they
    are sub or super-patterns.
    
    Closes: #588505
---
 debian/changelog |  2 ++
 src/querycmd.c   | 27 +++++++++++++++++++--------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 179df9d..e49834e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -79,6 +79,8 @@ dpkg (1.18.0) UNRELEASED; urgency=low
   * Remove old trigger related Breaks and Conflicts from dpkg.
   * Set the SE Linux context on «dpkg-statoverride --update». Closes: #690361
   * Only use stackprotectorstrong when building dpkg with gcc >= 4.9.
+  * Do not fail on dpkg-query -W and -l when multiple arguments match the
+    same package. Closes: #588505
 
   [ Raphaël Hertzog ]
   * Drop myself from Uploaders.
diff --git a/src/querycmd.c b/src/querycmd.c
index 02c9f3b..04f8769 100644
--- a/src/querycmd.c
+++ b/src/querycmd.c
@@ -285,21 +285,21 @@ listpackages(const char *const *argv)
     }
 
     for (i = 0; i < array.n_pkgs; i++) {
+      bool pkg_found = false;
+
       pkg = array.pkgs[i];
       for (ip = 0; ip < argc; ip++) {
         if (pkg_spec_match_pkg(&ps[ip], pkg, &pkg->installed)) {
+          pkg_found = true;
           found[ip]++;
-          break;
         }
       }
-      if (ip == argc)
+      if (!pkg_found)
         array.pkgs[i] = NULL;
     }
 
     pkg_array_foreach(&array, pkg_array_list_item, &fmt);
 
-    /* FIXME: we might get non-matching messages for sub-patterns specified
-     * after their super-patterns, due to us skipping on first match. */
     for (ip = 0; ip < argc; ip++) {
       if (!found[ip]) {
         notice(_("no packages found matching %s"), argv[ip]);
@@ -519,6 +519,14 @@ enqperpackage(const char *const *argv)
   return failures;
 }
 
+static void
+pkg_array_show_item(struct pkg_array *array, struct pkginfo *pkg, void 
*pkg_data)
+{
+  struct pkg_format_node *fmt = pkg_data;
+
+  pkg_format_show(fmt, pkg, &pkg->installed);
+}
+
 static int
 showpackages(const char *const *argv)
 {
@@ -566,18 +574,21 @@ showpackages(const char *const *argv)
     }
 
     for (i = 0; i < array.n_pkgs; i++) {
+      bool pkg_found = false;
+
       pkg = array.pkgs[i];
       for (ip = 0; ip < argc; ip++) {
         if (pkg_spec_match_pkg(&ps[ip], pkg, &pkg->installed)) {
-          pkg_format_show(fmt, pkg, &pkg->installed);
+          pkg_found = true;
           found[ip]++;
-          break;
         }
       }
+      if (!pkg_found)
+        array.pkgs[i] = NULL;
     }
 
-    /* FIXME: we might get non-matching messages for sub-patterns specified
-     * after their super-patterns, due to us skipping on first match. */
+    pkg_array_foreach(&array, pkg_array_show_item, fmt);
+
     for (ip = 0; ip < argc; ip++) {
       if (!found[ip]) {
         notice(_("no packages found matching %s"), argv[ip]);

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/dpkg/dpkg.git


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to