Skip to content

Commit dc8e1e7

Browse files
committed
Clarify emptyIncludeConf logic
Suggestion from John Newbery <[email protected]> in bitcoin#15934 (comment)
1 parent 2fb6140 commit dc8e1e7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/util/system.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -894,14 +894,19 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
894894
if (!ReadConfigStream(stream, confPath, error, ignore_invalid_keys)) {
895895
return false;
896896
}
897-
// if there is an -includeconf in the override args, but it is empty, that means the user
898-
// passed '-noincludeconf' on the command line, in which case we should not include anything
899-
bool emptyIncludeConf;
897+
// `-includeconf` cannot be included in the command line arguments except
898+
// as `-noincludeconf` (which indicates that no conf file should be used).
899+
bool use_conf_file{true};
900900
{
901901
LOCK(cs_args);
902-
emptyIncludeConf = m_override_args.count("-includeconf") == 0;
902+
auto it = m_override_args.find("-includeconf");
903+
if (it != m_override_args.end()) {
904+
// ParseParameters() fails if a non-negated -includeconf is passed on the command-line
905+
assert(it->second.empty());
906+
use_conf_file = false;
907+
}
903908
}
904-
if (emptyIncludeConf) {
909+
if (use_conf_file) {
905910
std::string chain_id = GetChainName();
906911
std::vector<std::string> includeconf(GetArgs("-includeconf"));
907912
{

0 commit comments

Comments
 (0)