From c74d1ee6dc7e7139f243cd57e258f51b3677d59c Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Sun, 12 May 2019 23:19:36 +0200 Subject: apt-cache: only show solutions if displayed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, apt-cache [r]depends always shows all solutions for a package, if appropriate, even if the package itself wasn’t displayed (e.g. “--installed” was specified). Thus, currently, with haskell-platform uninstalled and amd64 and i386 enabled, “apt-cache rdepends alex” shows alex Reverse Depends: haskell-platform alex:i386 haskell-platform alex:i386 and “apt-cache rdepends alex --installed” shows alex Reverse Depends: alex:i386 alex:i386 which is rather confusing. This patch changes the behaviour so that solutions are only displayed for packages which were themselves displayed; “apt-cache rdepends alex --installed” then shows alex Reverse Depends: Signed-off-by: Stephen Kitt --- apt-private/private-depends.cc | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/apt-private/private-depends.cc b/apt-private/private-depends.cc index 79d66b72a..95c747ee3 100644 --- a/apt-private/private-depends.cc +++ b/apt-private/private-depends.cc @@ -105,24 +105,24 @@ static bool ShowDepends(CommandLine &CmdL, bool const RevDepends) verset.insert(APT::VersionSet::FromPackage(CacheFile, Trg, APT::CacheSetHelper::CANDIDATE, helper)); } - } - - // Display all solutions - std::unique_ptr List(D.AllTargets()); - pkgPrioSortList(*Cache,List.get()); - for (pkgCache::Version **I = List.get(); *I != 0; I++) - { - pkgCache::VerIterator V(*Cache,*I); - if (V != Cache->VerP + V.ParentPkg()->VersionList || - V->ParentPkg == D->Package) - continue; - std::cout << " " << V.ParentPkg().FullName(true) << std::endl; - - if (Recurse == true && Shown[V.ParentPkg()->ID] == false) + // Display all solutions + std::unique_ptr List(D.AllTargets()); + pkgPrioSortList(*Cache,List.get()); + for (pkgCache::Version **I = List.get(); *I != 0; I++) { - Shown[V.ParentPkg()->ID] = true; - verset.insert(APT::VersionSet::FromPackage(CacheFile, V.ParentPkg(), APT::CacheSetHelper::CANDIDATE, helper)); + pkgCache::VerIterator V(*Cache,*I); + if (V != Cache->VerP + V.ParentPkg()->VersionList || + V->ParentPkg == D->Package) + continue; + std::cout << " " << V.ParentPkg().FullName(true) << std::endl; + + if (Recurse == true && Shown[V.ParentPkg()->ID] == false) + { + Shown[V.ParentPkg()->ID] = true; + verset.insert(APT::VersionSet::FromPackage(CacheFile, V.ParentPkg(), APT::CacheSetHelper::CANDIDATE, helper)); + } } + } if (ShowOnlyFirstOr == true) -- cgit v1.2.3-18-g5258