diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 14ba61562..8558d33e2 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -601,13 +601,16 @@ void CLI2::addContextFilter () //////////////////////////////////////////////////////////////////////////////// // Parse the command line, identifiying filter components, expanding syntactic // sugar as necessary. -void CLI2::prepareFilter (bool applyContext) +void CLI2::prepareFilter () { // Clear and re-populate. _id_ranges.clear (); _uuid_list.clear (); - if (applyContext) + // Context is only applied for commands that request it. + std::string command = getCommand (); + Command* cmd = context.commands[command]; + if (cmd && cmd->uses_context ()) addContextFilter (); // Classify FILTER and MODIFICATION args, based on CMD and READCMD/WRITECMD. diff --git a/src/CLI2.h b/src/CLI2.h index b8f9290fe..72bf2a0f1 100644 --- a/src/CLI2.h +++ b/src/CLI2.h @@ -77,7 +77,7 @@ public: void analyze (); void addFilter (const std::string& arg); void addContextFilter (); - void prepareFilter (bool applyContext = true); + void prepareFilter (); const std::vector getWords (bool filtered = true); bool canonicalize (std::string&, const std::string&, const std::string&) const; std::string getBinary () const; diff --git a/src/Filter.cpp b/src/Filter.cpp index 2c0aefc8f..74bddb659 100644 --- a/src/Filter.cpp +++ b/src/Filter.cpp @@ -69,12 +69,12 @@ Filter::~Filter () //////////////////////////////////////////////////////////////////////////////// // Take an input set of tasks and filter into a subset. -void Filter::subset (const std::vector & input, std::vector & output, bool applyContext /* = true */) +void Filter::subset (const std::vector & input, std::vector & output) { context.timer_filter.start (); _startCount = (int) input.size (); - context.cli2.prepareFilter (applyContext); + context.cli2.prepareFilter (); std::vector > precompiled; for (auto& a : context.cli2._args) @@ -115,11 +115,11 @@ void Filter::subset (const std::vector & input, std::vector & output //////////////////////////////////////////////////////////////////////////////// // Take the set of all tasks and filter into a subset. -void Filter::subset (std::vector & output, bool applyContext /* = true */) +void Filter::subset (std::vector & output) { context.timer_filter.start (); - context.cli2.prepareFilter (applyContext); + context.cli2.prepareFilter (); std::vector > precompiled; for (auto& a : context.cli2._args) diff --git a/src/Filter.h b/src/Filter.h index a576bd637..096d06794 100644 --- a/src/Filter.h +++ b/src/Filter.h @@ -40,8 +40,8 @@ public: Filter (); ~Filter (); - void subset (const std::vector &, std::vector &, bool applyContext = true); - void subset (std::vector &, bool applyContext = true); + void subset (const std::vector &, std::vector &); + void subset (std::vector &); bool hasFilter (); bool hasModifications (); bool pendingOnly (); diff --git a/src/TDB2.cpp b/src/TDB2.cpp index a7c2f99bd..9ef96c5fe 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -296,7 +296,7 @@ void TF2::load_tasks () { Task::status status = task.getStatus (); // Completed / deleted tasks in pending.data get an ID if GC is off. - if (!context.run_gc || + if (! context.run_gc || (status != Task::completed && status != Task::deleted)) task.id = context.tdb2.next_id (); } diff --git a/src/commands/CmdExport.cpp b/src/commands/CmdExport.cpp index 01ee1eec9..865b90ed4 100644 --- a/src/commands/CmdExport.cpp +++ b/src/commands/CmdExport.cpp @@ -60,7 +60,7 @@ int CmdExport::execute (std::string& output) // Apply filter. Filter filter; std::vector filtered; - filter.subset (filtered, false); + filter.subset (filtered); if (filter.hasModifications ()) throw std::string (STRING_ERROR_NO_MODS);