From fa3c95921217159201c1713bd38721f01cfff938 Mon Sep 17 00:00:00 2001 From: louib Date: Fri, 15 Feb 2019 08:56:29 -0500 Subject: [PATCH] Fix quiet option for Merge (CLI) (#2695) --- src/cli/Merge.cpp | 5 ++++- tests/TestCli.cpp | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cli/Merge.cpp b/src/cli/Merge.cpp index 5bd926ebe..b0e4cabca 100644 --- a/src/cli/Merge.cpp +++ b/src/cli/Merge.cpp @@ -78,7 +78,10 @@ int Merge::execute(const QStringList& arguments) QSharedPointer db2; if (!parser.isSet("same-credentials")) { - db2 = Utils::unlockDatabase(args.at(1), parser.value(keyFileFromOption), Utils::STDOUT, Utils::STDERR); + db2 = Utils::unlockDatabase(args.at(1), + parser.value(keyFileFromOption), + parser.isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT, + Utils::STDERR); if (!db2) { return EXIT_FAILURE; } diff --git a/tests/TestCli.cpp b/tests/TestCli.cpp index 244ccc18d..e2e66c2a4 100644 --- a/tests/TestCli.cpp +++ b/tests/TestCli.cpp @@ -883,6 +883,14 @@ void TestCli::testMerge() mergeCmd.execute({"merge", "-q", "-s", sourceFile.fileName(), sourceFile.fileName()}); m_stdoutFile->seek(pos); QCOMPARE(m_stdoutFile->readAll(), QByteArray("")); + + // Quiet option without the -s option + pos = m_stdoutFile->pos(); + Utils::Test::setNextPassword("a"); + Utils::Test::setNextPassword("a"); + mergeCmd.execute({"merge", "-q", sourceFile.fileName(), sourceFile.fileName()}); + m_stdoutFile->seek(pos); + QCOMPARE(m_stdoutFile->readAll(), QByteArray("")); } void TestCli::testRemove()