From ce0be66cf75cd2c13644542b8ecbb18406ac4c32 Mon Sep 17 00:00:00 2001 From: ccalvarin Date: Tue, 17 Apr 2018 07:48:38 -0700 Subject: Make attempting to change --config in invocation policy an error. It will not work as expected, since config is already expanded by this point in options processing. RELNOTES: None. PiperOrigin-RevId: 193196664 GitOrigin-RevId: 9c8c77502ff52907a327e6bdc9ac282da0af6b44 Change-Id: I5fa3aaec852b2d16bb8974291735ba4da1709243 --- .../google/devtools/common/options/InvocationPolicyEnforcer.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java b/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java index 88deb46..3b42a29 100644 --- a/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java +++ b/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java @@ -248,6 +248,15 @@ public final class InvocationPolicyEnforcer { OptionPriority nextPriority = OptionPriority.lowestOptionPriorityAtCategory(PriorityCategory.INVOCATION_POLICY); for (FlagPolicy policy : invocationPolicy.getFlagPoliciesList()) { + // Explicitly disallow --config in invocation policy. + if (policy.getFlagName().equals("config")) { + throw new OptionsParsingException( + "Invocation policy is applied after --config expansion, changing config values now " + + "would have no effect and is disallowed to prevent confusion. Please remove the " + + "following policy : " + + policy); + } + // These policies are high-level, before expansion, and so are not the implicitDependents or // expansions of any other flag, other than in an obtuse sense from --invocation_policy. OptionPriority currentPriority = nextPriority; -- cgit v1.2.3