From 9cc002939afc0d2283fd2f5e7d6e7434af5d10ff Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 26 Oct 2020 13:54:26 +0100 Subject: pkgnames: Correctly set the default for AllNames to false We passed "false" instead of false, and that apparently got cast to bool, because it's a non-null pointer. LP: #1876495 --- cmdline/apt-cache.cc | 2 +- .../test-ubuntu-bug-1876495-pkgnames-virtual | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 test/integration/test-ubuntu-bug-1876495-pkgnames-virtual diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 23ab7e47f..b40ff6efa 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -980,7 +980,7 @@ static bool ShowPkgNames(CommandLine &CmdL) if (unlikely(CacheFile.BuildCaches(NULL, false) == false)) return false; pkgCache::GrpIterator I = CacheFile.GetPkgCache()->GrpBegin(); - bool const All = _config->FindB("APT::Cache::AllNames","false"); + bool const All = _config->FindB("APT::Cache::AllNames", false); if (CmdL.FileList[1] != 0) { diff --git a/test/integration/test-ubuntu-bug-1876495-pkgnames-virtual b/test/integration/test-ubuntu-bug-1876495-pkgnames-virtual new file mode 100755 index 000000000..77d68e085 --- /dev/null +++ b/test/integration/test-ubuntu-bug-1876495-pkgnames-virtual @@ -0,0 +1,23 @@ + +#!/bin/sh + +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" +setupenvironment +configarchitecture 'i386' + +insertinstalledpackage 'coolstuff' 'all' '1.0' 'Provides: virtual-package +Source: source-package' + +setupaptarchive +changetowebserver + +testsuccess aptget update -o Debug::Acquire::gpg=1 +testsuccessequal "coolstuff +dpkg" aptcache pkgnames + +testsuccessequal "source-package +coolstuff +dpkg" aptcache pkgnames --all-names -- cgit v1.2.3-70-g09d2