Fix possibly missing pg1-* options for the remote command.

Some pg1-* options are required by the remote so if they are not provided in the remote's configuration file then it may cause a configuration error, depending on the operation. This currently only applies to the pg1-path option.

This is still an issue for repo-* options but the same solution cannot be applied because some repo-* options are secure and cannot be passed on the command-line.
This commit is contained in:
David Steele
2020-05-21 16:09:23 -04:00
committed by GitHub
parent ec7b7c5a3e
commit ae75ffc173
3 changed files with 24 additions and 6 deletions
+5 -3
View File
@@ -278,6 +278,7 @@ protocolRemoteParam(ProtocolStorageType protocolStorageType, unsigned int protoc
cfgOptionSource(optConfigPath) != cfgSourceDefault ? cfgOption(optConfigPath) : NULL);
// Update/remove repo/pg options that are sent to the remote
ConfigDefineCommand commandDefId = cfgCommandDefIdFromId(cfgCommand());
const String *repoHostPrefix = STR(cfgDefOptionName(cfgDefOptRepoHost));
const String *repoPrefix = strNewFmt("%s-", PROTOCOL_REMOTE_TYPE_REPO);
const String *pgHostPrefix = STR(cfgDefOptionName(cfgDefOptPgHost));
@@ -285,7 +286,8 @@ protocolRemoteParam(ProtocolStorageType protocolStorageType, unsigned int protoc
for (ConfigOption optionId = 0; optionId < CFG_OPTION_TOTAL; optionId++)
{
const String *optionDefName = STR(cfgDefOptionName(cfgOptionDefIdFromId(optionId)));
ConfigDefineOption optionDefId = cfgOptionDefIdFromId(optionId);
const String *optionDefName = STR(cfgDefOptionName(optionDefId));
bool remove = false;
// Remove repo host options that are not needed on the remote. The remote is not expecting to see host settings and it
@@ -308,10 +310,10 @@ protocolRemoteParam(ProtocolStorageType protocolStorageType, unsigned int protoc
}
else if (strBeginsWith(optionDefName, pgPrefix))
{
// Remove pg options when the remote type is repo since they won't be used
// Remove unrequired/defaulted pg options when the remote type is repo since they won't be used
if (protocolStorageType == protocolStorageTypeRepo)
{
remove = true;
remove = !cfgDefOptionRequired(commandDefId, optionDefId) || cfgDefOptionDefault(commandDefId, optionDefId) != NULL;
}
// Else move/remove pg options with index > 0 since they won't be used
else if (cfgOptionIndex(optionId) > 0)