aboutsummaryrefslogtreecommitdiff
path: root/src/nix-store
diff options
context:
space:
mode:
authorThéophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>2023-04-03 20:43:02 +0200
committerGitHub <noreply@github.com>2023-04-03 20:43:02 +0200
commit523c3f722564f92e6dd7cd6256474c6d23db11b4 (patch)
treec8c9a26758c88f8ca1d4fdce50fad5a529eb2b1e /src/nix-store
parent81491e1379138e69138e30d18210badbd0765b89 (diff)
parentbf2c5c3958c258584ac66519124d05ccf446aaeb (diff)
Merge pull request #8157 from hercules-ci/switch-bugs
Fix current and future `switch` bugs
Diffstat (limited to 'src/nix-store')
-rw-r--r--src/nix-store/nix-store.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index a62cb874f..7035e6a7b 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -277,17 +277,17 @@ static void printTree(const StorePath & path,
static void opQuery(Strings opFlags, Strings opArgs)
{
enum QueryType
- { qDefault, qOutputs, qRequisites, qReferences, qReferrers
+ { qOutputs, qRequisites, qReferences, qReferrers
, qReferrersClosure, qDeriver, qBinding, qHash, qSize
, qTree, qGraph, qGraphML, qResolve, qRoots };
- QueryType query = qDefault;
+ std::optional<QueryType> query;
bool useOutput = false;
bool includeOutputs = false;
bool forceRealise = false;
std::string bindingName;
for (auto & i : opFlags) {
- QueryType prev = query;
+ std::optional<QueryType> prev = query;
if (i == "--outputs") query = qOutputs;
else if (i == "--requisites" || i == "-R") query = qRequisites;
else if (i == "--references") query = qReferences;
@@ -312,15 +312,15 @@ static void opQuery(Strings opFlags, Strings opArgs)
else if (i == "--force-realise" || i == "--force-realize" || i == "-f") forceRealise = true;
else if (i == "--include-outputs") includeOutputs = true;
else throw UsageError("unknown flag '%1%'", i);
- if (prev != qDefault && prev != query)
+ if (prev && prev != query)
throw UsageError("query type '%1%' conflicts with earlier flag", i);
}
- if (query == qDefault) query = qOutputs;
+ if (!query) query = qOutputs;
RunPager pager;
- switch (query) {
+ switch (*query) {
case qOutputs: {
for (auto & i : opArgs) {